/* SciFi Quotes. Always dark: deep space, a slowly drifting starfield, panels like a ship's displays.
   Quotes stay in a book serif so long passages read easily; headings and controls use Space Grotesk,
   the logo Orbitron (both self-hosted in assets/fonts, SIL Open Font License). */

@font-face {
  font-family: "Space Grotesk";
  src: url("fonts/space-grotesk.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Orbitron";
  src: url("fonts/orbitron.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --bg: #04060d;
  --bg-2: #0a0f1e;
  --panel: rgba(14, 21, 40, .78);
  --panel-solid: #0e1528;
  --panel-2: rgba(22, 32, 60, .85);
  --line: #1f2b4d;
  --edge: rgba(111, 211, 199, .22);
  --text: #e9ecf5;
  --muted: #8f9abb;
  --accent: #f2b84b;
  --accent-2: #6fd3c7;
  --accent-ink: #1a1203;
  --glow: 0 0 18px rgba(242, 184, 75, .35);
  --glow-2: 0 0 22px rgba(111, 211, 199, .28);
  --star: #f2b84b;
  --star-off: #2c3658;
  --book: #8fb4ff;
  --movie: #ff9a8a;
  --danger: #ff8a7a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Space Grotesk", var(--sans);
  --logo: "Orbitron", "Space Grotesk", var(--sans);
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1000px 600px at 85% -10%, rgba(111, 211, 199, .10), transparent 70%),
    radial-gradient(900px 600px at -10% 15%, rgba(242, 184, 75, .07), transparent 70%),
    radial-gradient(1200px 800px at 50% 120%, rgba(120, 90, 220, .10), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 17px/1.6 var(--sans);
  position: relative;
}
/* Two tiled star layers, drifting at different speeds for depth. */
body::before, body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}
body::before {
  background-image:
    radial-gradient(1px 1px at 20px 30px, rgba(255,255,255,.55), transparent 60%),
    radial-gradient(1px 1px at 140px 90px, rgba(255,255,255,.35), transparent 60%),
    radial-gradient(1px 1px at 230px 170px, rgba(200,225,255,.5), transparent 60%),
    radial-gradient(1px 1px at 60px 210px, rgba(255,255,255,.3), transparent 60%),
    radial-gradient(1px 1px at 280px 40px, rgba(255,240,210,.4), transparent 60%),
    radial-gradient(1px 1px at 180px 260px, rgba(255,255,255,.35), transparent 60%);
  background-size: 300px 300px;
  animation: drift 240s linear infinite;
}
body::after {
  background-image:
    radial-gradient(1.6px 1.6px at 90px 120px, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1.4px 1.4px at 400px 60px, rgba(180,230,255,.6), transparent 60%),
    radial-gradient(1.8px 1.8px at 310px 390px, rgba(255,230,190,.6), transparent 60%),
    radial-gradient(1.4px 1.4px at 480px 300px, rgba(255,255,255,.5), transparent 60%);
  background-size: 540px 540px;
  animation: drift 150s linear infinite;
}
@keyframes drift { to { background-position: -600px 300px; } }
@media (prefers-reduced-motion: reduce) { body::before, body::after { animation: none; } }

::selection { background: rgba(111, 211, 199, .35); color: #fff; }
a { color: var(--accent-2); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; font-family: var(--display); font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: .4em 0 .5em; }
h2 { font-size: 1.4rem; }
img, iframe { max-width: 100%; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 720px; margin-left: auto; margin-right: auto; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--panel-solid); padding: 8px 12px; z-index: 10; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: rgba(4, 6, 13, .78); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 5; }
.site-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: linear-gradient(90deg, transparent, var(--accent-2) 30%, var(--accent) 70%, transparent); opacity: .45; }
.header-inner { display: flex; align-items: center; gap: 20px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font: 600 1.08rem/1 var(--logo); letter-spacing: .08em; text-transform: uppercase; }
.brand b { color: var(--accent); font-weight: 800; text-shadow: var(--glow); }
.brand-mark { width: 28px; height: 28px; color: var(--accent); filter: drop-shadow(0 0 6px rgba(242, 184, 75, .5)); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font: 500 .95rem/1.4 var(--display); letter-spacing: .01em; }
.nav a:hover { color: var(--text); background: var(--panel-2); }
.nav a[aria-current] { color: var(--accent-2); background: rgba(111, 211, 199, .08); box-shadow: inset 0 -2px 0 var(--accent-2); }
.search { margin-left: auto; }
.search input { background: var(--panel-solid); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 7px 14px; width: 210px; font: inherit; font-size: .95rem; }
@media (max-width: 860px) {
  .header-inner { padding: 10px 16px; gap: 8px 14px; }
  .search { margin-left: 0; width: 100%; order: 3; }
  .search input { width: 100%; }
  .nav { order: 2; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .nav a { white-space: nowrap; }
}

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: rgba(4, 6, 13, .6); margin-top: 64px; padding: 24px 0 40px; color: var(--muted); font-size: .95rem; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px; }
.footer-inner p { margin: 0; }

/* Shared bits */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: inset 0 1px 0 var(--edge); backdrop-filter: blur(4px); }
.eyebrow { font: 500 .78rem/1.4 var(--display); text-transform: uppercase; letter-spacing: .2em; color: var(--accent-2); margin: 0 0 14px; }
.eyebrow::before { content: ""; display: inline-block; width: 22px; height: 1px; background: currentColor; vertical-align: middle; margin-right: 10px; opacity: .7; }
.section-title { font-size: 1.3rem; margin: 40px 0 16px; }
.subhead { font: 600 .8rem/1 var(--display); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 20px 0 10px; }
.button { display: inline-block; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: 999px; padding: 10px 20px; font: 600 1rem/1.2 var(--display); letter-spacing: .01em; text-decoration: none; cursor: pointer; box-shadow: var(--glow); transition: box-shadow .15s, filter .15s; }
.button:hover { filter: brightness(1.08); color: var(--accent-ink); box-shadow: 0 0 26px rgba(242, 184, 75, .55); }
.button-ghost { background: rgba(111, 211, 199, .04); color: var(--text); border-color: rgba(111, 211, 199, .35); box-shadow: none; }
.button-ghost:hover { border-color: var(--accent-2); color: var(--text); box-shadow: var(--glow-2); }
.linkish { background: none; border: 0; color: var(--accent-2); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
.badge { display: inline-block; font: 600 .68rem/1 var(--display); letter-spacing: .08em; text-transform: uppercase; padding: 4px 7px; border-radius: 6px; border: 1px solid currentColor; vertical-align: middle; }
.badge-book { color: var(--book); }
.badge-movie { color: var(--movie); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 16px; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); text-decoration: none; font: 500 .92rem/1.4 var(--display); }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current] { background: rgba(242, 184, 75, .1); color: var(--text); border-color: var(--accent); box-shadow: 0 0 12px rgba(242, 184, 75, .2); }
.list-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.list-head .section-title { margin: 24px 0 16px; }
.crumbs { font-size: .9rem; color: var(--muted); margin: 24px 0 0; }
.crumbs a { color: var(--muted); }
.stats { text-align: center; color: var(--muted); margin-top: 40px; font: .9rem/1.6 var(--display); letter-spacing: .06em; text-transform: uppercase; }
.explainer { max-width: 760px; }

/* Home */
.hero { padding: 56px 0 28px; max-width: 860px; }
.hero-quote { margin: 0; }
.hero-quote blockquote { margin: 0; font: 400 clamp(1.4rem, 3.4vw, 2.1rem)/1.4 var(--serif); }
.hero-quote blockquote p { margin: 0 0 .5em; }
.hero-more { margin: .25em 0 .75em; }
.hero-quote blockquote p:first-child::before { content: "“"; color: var(--accent); margin-left: -.45em; padding-right: .05em; text-shadow: var(--glow); }
.hero-quote figcaption, .quote-full figcaption { margin-top: 18px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.speaker::before { content: "— "; }
cite { font-style: italic; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; }
.duel-teaser { display: flex; justify-content: space-between; align-items: center; gap: 16px 32px; flex-wrap: wrap; margin-top: 24px;
  background: linear-gradient(120deg, rgba(242, 184, 75, .14), rgba(111, 211, 199, .06) 55%, var(--panel)); border-color: rgba(242, 184, 75, .3); }
.duel-teaser h2 { margin: 0 0 4px; }
.duel-teaser p { margin: 0; color: var(--muted); max-width: 620px; }
.columns { display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; }
@media (max-width: 860px) { .columns { grid-template-columns: 1fr; gap: 0; } }
.work-list { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 24px; }
.work-list li { break-inside: avoid; padding: 3px 0; font-size: .97rem; }
.count { color: var(--muted); font-size: .85em; }
@media (max-width: 480px) { .work-list { columns: 1; } }

/* Quote cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
@media (max-width: 400px) { .card-grid { grid-template-columns: 1fr; } }
.quote-card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 16px; margin-bottom: 14px; display: flex; flex-direction: column; box-shadow: inset 0 1px 0 var(--edge); transition: border-color .15s, box-shadow .15s; }
.card-grid .quote-card { margin-bottom: 0; }
.quote-card:hover { border-color: rgba(111, 211, 199, .5); box-shadow: inset 0 1px 0 var(--edge), var(--glow-2); }
.quote-card-body { color: var(--text); text-decoration: none; flex: 1; }
.quote-card-body:hover { color: var(--text); }
.quote-card blockquote { margin: 0 0 14px; font: 1.08rem/1.55 var(--serif); }
.quote-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: .88rem; color: var(--muted); }
.quote-card-title { color: var(--text); font: 600 .95rem/1.4 var(--display); text-decoration: none; }
.quote-card-meta .work { color: var(--muted); }
.quote-card-meta .rating { margin-left: auto; white-space: nowrap; }
.rank { position: absolute; left: -12px; top: 14px; background: var(--accent); color: var(--accent-ink); box-shadow: var(--glow); font: 700 .85rem/1 var(--display); min-width: 28px; height: 28px; border-radius: 999px; display: grid; place-items: center; padding: 0 6px; }
.ranked .quote-card, .columns .quote-card { margin-left: 14px; }

/* Quote page */
.quote-page { max-width: 820px; }
.quote-page h1 { margin-top: 12px; }
.quote-full { margin: 0 0 28px; }
.quote-full blockquote { margin: 0; padding: 4px 0 4px 24px; border-left: 3px solid var(--accent); box-shadow: -8px 0 14px -10px rgba(242, 184, 75, .6); font: clamp(1.25rem, 2.6vw, 1.6rem)/1.55 var(--serif); }
.quote-full blockquote p { margin: 0 0 .8em; }
.quote-full blockquote p:last-child { margin-bottom: 0; }
.context { color: var(--muted); }
.video { position: relative; aspect-ratio: 16 / 9; margin: 0 0 28px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: var(--radius); }
.quote-actions { display: grid; gap: 14px; }
.duel-standing { font-family: var(--display); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: .95rem; border-top: 1px solid var(--line); padding-top: 14px; }
.citation { font-size: .9rem; margin-top: 18px; }

/* Stars */
.stars { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; }
.stars-label { font: 600 1rem/1.4 var(--display); }
.stars-buttons { display: inline-flex; }
.stars-buttons button { background: none; border: 0; padding: 0 3px; font-size: 2rem; line-height: 1; cursor: pointer; color: var(--star-off); transition: transform .1s, color .1s; }
.stars-buttons button.on { color: var(--star); text-shadow: 0 0 10px rgba(242, 184, 75, .6); }
.stars-buttons:hover button { color: var(--star); text-shadow: 0 0 10px rgba(242, 184, 75, .6); }
.stars-buttons button:hover ~ button { color: var(--star-off); text-shadow: none; }
.stars-buttons button:hover { transform: scale(1.15); }
.stars-summary { color: var(--muted); font-size: .95rem; }
.stars-clear { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; font-size: .85rem; padding: 0; }
.stars.busy { opacity: .6; pointer-events: none; }
.stars-error { color: var(--danger); font-size: .9rem; width: 100%; }

/* Works */
.work-header { margin: 24px 0 8px; }
.work-header h1 { margin: 6px 0 4px; }
.byline { color: var(--muted); margin: 0; }
.summary { margin: 24px 0 8px; max-width: 820px; }
.summary h2 { margin: 0 0 8px; font-size: 1.1rem; color: var(--accent-2); }
.summary p { margin: 0; }
.ai-note { color: var(--muted); font-size: .82rem; margin-top: 10px !important; }
.ai-note::before { content: "✦ "; color: var(--accent); }
.work-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.work-card { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; box-shadow: inset 0 1px 0 var(--edge); transition: border-color .15s, box-shadow .15s; }
.work-card:hover { border-color: rgba(111, 211, 199, .5); color: var(--text); box-shadow: inset 0 1px 0 var(--edge), var(--glow-2); }
.work-card strong { font: 600 1.12rem/1.3 var(--display); }
.work-card-top { display: flex; justify-content: space-between; font-size: .85rem; }
.work-card .muted { font-size: .9rem; }

/* Duel */
.duel-header { text-align: center; margin: 32px 0 20px; }
.duel-header h1 { margin-bottom: 4px; }
.duel-header p { margin: 0; }
.duel { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: stretch; }
.duel.loading { opacity: .5; pointer-events: none; }
.duel-side { display: flex; }
.duel-pick { display: flex; flex-direction: column; width: 100%; text-align: left; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; cursor: pointer; font: inherit; box-shadow: inset 0 1px 0 var(--edge); transition: border-color .15s, transform .15s, box-shadow .15s; }
.duel-pick:hover, .duel-pick:focus-visible { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,.4), 0 0 24px rgba(242, 184, 75, .25); }
.duel-text { font: 1.2rem/1.55 var(--serif); flex: 1; }
.duel-text p { margin: 0 0 .7em; }
.duel-source { color: var(--muted); font-size: .92rem; margin-top: 12px; }
.duel-cta { margin-top: 18px; align-self: flex-start; background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 8px 18px; font: 600 1rem/1.2 var(--display); box-shadow: var(--glow); }
.duel-vs { align-self: center; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--accent-2); font: 800 .95rem/1 var(--logo); letter-spacing: .06em; color: var(--accent-2); text-shadow: 0 0 10px rgba(111, 211, 199, .8); box-shadow: var(--glow-2), inset 0 0 12px rgba(111, 211, 199, .2); background: rgba(4, 6, 13, .7); }
.duel-pick.picked { border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 40%, transparent); }
.duel-result { text-align: center; color: var(--muted); min-height: 1.6em; }
.duel-skip { text-align: center; margin-top: 18px; font-size: .95rem; }
@media (max-width: 760px) {
  .duel { grid-template-columns: 1fr; }
  .duel-vs { justify-self: center; }
  .duel-pick { padding: 18px; }
}

/* Forms */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; }
.field label, .field legend { font-weight: 600; }
.field input, .field textarea, .field select { width: 100%; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 10px 12px; font: inherit; }
.field textarea { font-family: var(--serif); font-size: 1.05rem; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent-2); outline: none; box-shadow: var(--glow-2); }
.hint { margin: 0; color: var(--muted); font-size: .9rem; }
.radio { display: inline-flex; align-items: center; gap: 6px; margin-right: 18px; font-weight: 400 !important; }
.radio input { width: auto; }
.has-error input, .has-error textarea { border-color: var(--danger); }
.error { color: var(--danger); margin: 0; }
.notice { border-color: var(--accent-2); }
.hp { position: absolute; left: -5000px; }
.search-big { display: flex; gap: 8px; margin: 0 0 20px; }
.search-big input { flex: 1; min-width: 0; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 999px; color: var(--text); padding: 12px 18px; font: inherit; }
.search-big button { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 0 22px; font: 600 1rem var(--display); cursor: pointer; box-shadow: var(--glow); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 20px; margin: 32px 0 0; color: var(--muted); }
.prose h2 { margin-top: 1.6em; }

/* Admin */
.admin-nav { align-items: center; margin-top: 20px; }
.admin-nav form { margin-left: auto; }
.admin blockquote { font-family: var(--serif); }
.new-work { border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; }
.table { border-collapse: collapse; width: 100%; }
.table th, .table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.plain { padding-left: 18px; }
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-form input { background: var(--panel-solid); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 8px; font: inherit; }
