/* ─── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg:          #0d0b0e;
  --surface:     #16121a;
  --surface2:    #1f1a25;
  --border:      #2e2639;
  --accent:      #d0443a;
  --accent-hover:#e25a50;
  --accent-soft: rgba(208, 68, 58, 0.14);
  --accent-text: #f0b7b2;
  --gold:        #c9a84c;
  --gold-soft:   rgba(201, 168, 76, 0.12);
  --ok:          #3fb27f;
  --ok-soft:     rgba(63, 178, 127, 0.12);
  --text:        #ede6dc;
  --text-dim:    #b3a9b5;
  --text-muted:  #7d7385;

  --radius:    10px;
  --radius-lg: 16px;
  --serif: 'Playfair Display', Georgia, serif;
  --script: 'Great Vibes', cursive;
  --sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --nav-h: 72px;
}

/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 16px; line-height: 1.6; min-height: 100dvh; overflow-x: hidden; display: flex; flex-direction: column; }
main { flex: 1; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 720px; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 999; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { left: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ─── Header ─────────────────────────────────────────────────────────────────── */
.site-nav { position: sticky; top: 0; z-index: 200; background: rgba(13, 11, 14, 0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.site-nav .wrap { display: flex; align-items: center; gap: 24px; height: var(--nav-h); }
.brand { font-family: var(--serif); font-size: 1.35rem; font-weight: 700; white-space: nowrap; }
.brand img { display: block; height: 56px; width: auto; }
@media (max-width: 520px) { .brand img { height: 48px; } }
@media (min-width: 821px) { :root { --nav-h: 80px; } .brand img { height: 64px; } }
.nav-links { display: flex; gap: 22px; margin-left: auto; align-items: center; }
.nav-links a, .nav-links .link { color: var(--text-dim); font-size: 0.94rem; font-weight: 500; }
.nav-links .link { background: none; border: none; }
.nav-links .btn { color: var(--text); }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--text); }
.nav-links form { display: contents; }
.menu-btn { display: none; margin-left: auto; background: none; border: 1px solid var(--border); border-radius: 8px; width: 44px; height: 44px; }
@media (max-width: 820px) {
  .nav-links { display: none; position: absolute; top: var(--nav-h); left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 20px 16px; }
  .nav-links.open { display: flex; }
  .nav-links a, .nav-links .link { padding: 12px 0; border-bottom: 1px solid var(--border); text-align: left; }
  .nav-links .btn { margin-top: 12px; }
  .menu-btn { display: block; }
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 999px; border: 1px solid transparent; font-weight: 600; font-size: 0.95rem; transition: background 0.15s, border-color 0.15s, color 0.15s; white-space: nowrap; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost { background: none; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--text-muted); }
.btn-ok { background: var(--ok-soft); border-color: rgba(63, 178, 127, 0.45); color: var(--ok); }
.btn-gold { background: var(--gold-soft); border-color: rgba(201, 168, 76, 0.45); color: var(--gold); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 0.85rem; }
.link-btn { background: none; border: none; color: var(--text-muted); text-decoration: underline; font-size: 0.88rem; min-height: 44px; }
.link-btn:hover { color: var(--text); }
.text-link { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }

/* ─── Chips (also used as checkbox labels: <label class="chip"><input type="checkbox">) ── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 8px 14px; font-size: 0.92rem; min-height: 40px; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; cursor: pointer; user-select: none; }
.chip:hover { border-color: var(--text-muted); }
.chip .n { color: var(--text-muted); font-size: 0.8rem; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked), .chip[aria-pressed="true"], .chip.on { background: var(--accent-soft); border-color: var(--accent); color: #fff; }
.chip:has(input:checked) .n, .chip.on .n { color: var(--accent-text); }
.chip:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.chip:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
.chip .x { color: var(--accent-text); font-size: 1.05rem; line-height: 1; }

/* ─── Book cards ─────────────────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 20px; }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 14px; } }
.book { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: transform 0.15s, border-color 0.15s; }
.book:hover { transform: translateY(-3px); border-color: var(--text-muted); }
.cover { aspect-ratio: 2 / 3; position: relative; overflow: hidden; background: var(--surface2); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 14px; text-align: center; font-family: var(--serif); color: var(--text-dim); font-size: 1.05rem; background: linear-gradient(160deg, var(--surface2), #2a1520); }
.badge { position: absolute; top: 8px; left: 8px; background: var(--accent); color: #fff; font-size: 0.75rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.book-body { padding: 12px 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.book-title { font-family: var(--serif); font-size: 1.02rem; line-height: 1.3; }
.book-author { color: var(--text-dim); font-size: 0.85rem; }
.tags { color: var(--text-muted); font-size: 0.8rem; line-height: 1.4; }
.meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.tw-count { color: var(--gold); font-size: 0.78rem; font-weight: 500; }
.spice { display: inline-flex; align-items: center; gap: 3px; }
.spice i { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.spice i.on { background: var(--accent); }
.spice-label { color: var(--text-muted); font-size: 0.78rem; }
.shelf { display: grid; grid-auto-flow: column; grid-auto-columns: 160px; gap: 16px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.shelf .book { scroll-snap-align: start; }

/* ─── Page structure ─────────────────────────────────────────────────────────── */
.page { padding: 48px 0 24px; }
.page-head { margin-bottom: 32px; }
.eyebrow { display: inline-block; color: var(--gold); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 12px; }
.page-title { font-family: var(--serif); font-size: clamp(1.9rem, 4.5vw, 2.8rem); line-height: 1.15; }
.page-sub { color: var(--text-dim); max-width: 640px; margin-top: 10px; }
.section { padding: 72px 0; }
.section-title { font-family: var(--serif); font-size: clamp(1.6rem, 3.5vw, 2.2rem); text-align: center; }
.section-sub { color: var(--text-dim); text-align: center; max-width: 600px; margin: 10px auto 40px; }
.row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.row-head h2, .row-head h3 { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; }
.row-head .note { color: var(--text-muted); font-size: 0.9rem; }
.row-head a { color: var(--accent-text); font-weight: 500; font-size: 0.92rem; }
.empty { color: var(--text-dim); text-align: center; padding: 48px 0; grid-column: 1 / -1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; }
@media (max-width: 600px) { .card { padding: 22px 18px; } }

/* ─── Alerts ─────────────────────────────────────────────────────────────────── */
.alert { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px; border: 1px solid; font-size: 0.95rem; }
.alert ul { padding-left: 18px; }
.alert-error { background: var(--accent-soft); border-color: rgba(208, 68, 58, 0.5); color: var(--accent-text); }
.alert-ok { background: var(--ok-soft); border-color: rgba(63, 178, 127, 0.45); color: #9fdcbf; }

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.lbl { display: block; font-size: 0.88rem; font-weight: 500; color: var(--text-dim); margin-bottom: 6px; }
.lbl .opt { color: var(--text-muted); font-weight: 400; }
.hint { color: var(--text-muted); font-size: 0.82rem; margin-top: 6px; }
input[type=text], input[type=number], input[type=url], input[type=email], input[type=password], input[type=search], textarea, select {
  width: 100%; background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 11px 14px; font: inherit; font-size: 1rem; border-radius: 8px; outline: none; transition: border-color 0.15s; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 96px; }
select { appearance: none; padding-right: 36px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23b3a9b5' stroke-width='1.6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.field { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.inline-field { display: flex; gap: 8px; }
.inline-field input { flex: 1; min-width: 0; }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } .inline-field { flex-wrap: wrap; } }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
fieldset { border: none; }
legend { font-size: 0.88rem; font-weight: 500; color: var(--text-dim); margin-bottom: 8px; }

/* Spice picker: radio buttons styled as five pips */
.spice-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.spice-pick label { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface2); color: var(--text-dim); font-size: 0.88rem; cursor: pointer; }
.spice-pick input { position: absolute; opacity: 0; pointer-events: none; }
.spice-pick label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: #fff; }
.spice-pick label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Trope picker: chip checkboxes grouped by category */
.trope-pick { display: flex; flex-direction: column; gap: 18px; }
.trope-pick h4 { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }

/* ─── Pagination ─────────────────────────────────────────────────────────────── */
.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 40px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; border: 1px solid var(--border); padding: 0 14px; font-size: 0.92rem; }
.pagination a:hover { border-color: var(--text-muted); }
.pagination .current { background: var(--surface2); border-color: var(--text-muted); }
.pagination .gap { border: none; color: var(--text-muted); }

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--border); padding: 28px 0; margin-top: 72px; color: var(--text-muted); font-size: 0.88rem; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer nav { display: flex; gap: 18px; flex-wrap: wrap; }
.site-footer a:hover { color: var(--text); }
.site-footer .disclosure { flex-basis: 100%; font-size: 0.8rem; }
