/* TotalWOR — the front door.
   Concept: THE TABLE. A dark room, one warm lamp off to the left (the radio's
   dial glow), and the worlds lifted off the tabletop as a slow brass orrery.
   Warm umber ground + brass light; each world carries its own cool accent so
   they read apart at a glance. */

:root {
  --void: #0b0809;
  --table: #150f11;
  --panel: #1c1418;
  --edge: #34262b;
  --ink: #f2ebe4;
  --dim: #a3948b;
  --brass: #c9a227;
  --brass-soft: rgba(201, 162, 39, .14);
  --accent: #b8465a;           /* replaced per selected world at runtime */
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace;
  --serif: "Hoefler Text", Georgia, "Times New Roman", serif;
  --sans: system-ui, "Segoe UI", -apple-system, sans-serif;
  --shell: min(1180px, 100% - 48px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(120% 90% at 8% 18%, rgba(201, 162, 39, .10), transparent 60%),
    radial-gradient(90% 70% at 90% 100%, rgba(184, 70, 90, .07), transparent 60%),
    var(--void);
  color: var(--ink);
  font-family: var(--sans);
  overflow-x: hidden;
}

/* the orrery canvas sits behind everything */
/* width/height are NOT optional here. <canvas> is a replaced element: with inset:0
   but auto sizing it takes its INTRINSIC size (the drawing-buffer attributes,
   which Three sets to viewport x devicePixelRatio) instead of filling the
   viewport — so on a dpr-3 phone the canvas rendered at 3x the screen, anchored
   top-left, putting the orrery's centre off-screen to the bottom-right. */
#sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }
#sky.idle { pointer-events: none; }

.plate {
  font: 11px var(--mono);
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--brass);
}

/* ── top bar ─────────────────────────────────────────────────────────── */
header {
  position: relative; z-index: 3;
  width: var(--shell); margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  padding: 20px 0;
}
.wordmark {
  font: 700 15px var(--mono); letter-spacing: .3em;
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.wordmark span { color: var(--brass); }
header nav { margin-left: auto; display: flex; gap: 18px; align-items: center; }
header nav a { color: var(--dim); text-decoration: none; font: 13px var(--sans); }
header nav a:hover { color: var(--ink); }

/* ── stage: the two states of the page ───────────────────────────────── */
main { position: relative; z-index: 2; width: var(--shell); margin: 0 auto; }

.stage { display: none; }
.stage.on { display: block; animation: rise .6s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ── landing ─────────────────────────────────────────────────────────── */
.hero { padding: 8vh 0 0; max-width: 620px; }
.hero h1 {
  font: 400 clamp(38px, 7.2vw, 76px)/.98 var(--serif);
  margin: 14px 0 0; text-wrap: balance; letter-spacing: -.01em;
}
.hero h1 em { font-style: italic; color: var(--brass); }
.hero .lede {
  font: 17px/1.65 var(--serif); color: var(--dim);
  margin: 20px 0 0; max-width: 52ch;
}
.cta-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 32px 0 0; }
.cta {
  background: var(--brass); color: #17110a; border: 0; border-radius: 3px;
  font: 700 15px var(--sans); padding: 14px 26px; cursor: pointer;
  display: inline-block; text-decoration: none; text-align: center;
  transition: transform .15s ease, filter .15s ease;
}
.cta:hover { filter: brightness(1.08); transform: translateY(-1px); }
.cta.ghost { background: transparent; color: var(--ink); border: 1px solid var(--edge); }
.cta.ghost:hover { border-color: var(--brass); }
.fineprint { font: 13px var(--sans); color: var(--dim); }

.proof { display: flex; flex-wrap: wrap; gap: 26px; margin: 46px 0 0; padding: 0 0 8vh; }
.proof div { max-width: 230px; }
.proof dt { font: 11px var(--mono); letter-spacing: .16em; color: var(--brass); text-transform: uppercase; }
.proof dd { margin: 6px 0 0; font: 14px/1.55 var(--sans); color: var(--dim); }

/* ── selector ────────────────────────────────────────────────────────── */
.selector { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 30px; align-items: start; padding: 3vh 0 6vh; min-height: 74vh; }

.panel {
  background: linear-gradient(180deg, rgba(28, 20, 24, .92), rgba(21, 15, 17, .92));
  border: 1px solid var(--edge); border-left: 2px solid var(--accent);
  border-radius: 4px; padding: 22px;
  backdrop-filter: blur(6px);
}
.panel h2 { font: 400 30px/1.1 var(--serif); margin: 8px 0 4px; text-wrap: balance; }
.panel .genre { font: 11px var(--mono); letter-spacing: .16em; color: var(--accent); text-transform: uppercase; }
.panel .tagline { font: italic 15px/1.5 var(--serif); color: var(--ink); margin: 12px 0 0; }
.panel .blurb { font: 14px/1.65 var(--sans); color: var(--dim); margin: 12px 0 0; }
.panel .hint { font: 12.5px/1.5 var(--sans); color: var(--dim); margin: 16px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 16px 0 0; }
.chip {
  background: rgba(255, 255, 255, .03); border: 1px solid var(--edge); color: var(--ink);
  border-radius: 999px; padding: 7px 13px; font: 12.5px var(--sans); cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #140d10; font-weight: 600; }
.chip:disabled { opacity: .4; cursor: not-allowed; }

.step-label { font: 11px var(--mono); letter-spacing: .16em; color: var(--dim); text-transform: uppercase; margin: 20px 0 0; }

.enter { width: 100%; margin: 22px 0 0; background: var(--accent); color: #140d10; border: 0; border-radius: 3px; font: 700 15px var(--sans); padding: 14px; cursor: pointer; }
.enter:disabled { opacity: .35; cursor: not-allowed; }
.backlink { display: inline-block; margin: 14px 0 0; background: none; border: 0; color: var(--dim); font: 12.5px var(--sans); cursor: pointer; padding: 0; text-decoration: underline; }
.backlink:hover { color: var(--ink); }

.sealed { border-left-color: #6f63a0; }
.sealed .genre { color: #8d80c6; }

/* world list (the orrery's text twin — also the whole UI on small screens) */
.worldlist { display: flex; flex-direction: column; gap: 8px; align-self: end; }
.worldbtn {
  display: flex; align-items: baseline; gap: 12px; text-align: left;
  background: rgba(20, 14, 17, .72); border: 1px solid var(--edge); border-radius: 4px;
  padding: 11px 14px; color: var(--ink); font: 14px var(--sans); cursor: pointer;
  backdrop-filter: blur(4px);
  transition: border-color .15s ease, transform .15s ease;
}
.worldbtn:hover, .worldbtn:focus-visible { transform: translateX(3px); outline: none; }
.worldbtn .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; align-self: center; }
.worldbtn .nm { font-weight: 600; }
.worldbtn .kc { font: 10.5px var(--mono); letter-spacing: .12em; color: var(--dim); margin-left: auto; text-transform: uppercase; }
.worldbtn[aria-pressed="true"] { background: rgba(38, 26, 32, .9); }

:where(button, a):focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

footer { position: relative; z-index: 2; width: var(--shell); margin: 0 auto; padding: 26px 0 40px; color: var(--dim); font: 12px var(--sans); border-top: 1px solid var(--edge); }

@media (max-width: 880px) {
  .selector { grid-template-columns: 1fr; }
  .hero { padding-top: 4vh; }
}

/* ── the landing (no canvas — it is a page of words) ──────────────────── */
body.plain { background-attachment: fixed; }
body.plain main { padding-bottom: 6vh; }

/* the promise */
.soon {
  margin: 34px 0 0; padding: 20px 22px;
  border: 1px solid var(--edge); border-left: 2px solid var(--brass);
  border-radius: 4px; background: rgba(201, 162, 39, .05);
}
.soon-kicker { font: 11px var(--mono); letter-spacing: .22em; color: var(--brass); text-transform: uppercase; margin: 0; }
.soon-date { font: 400 clamp(26px, 4.6vw, 40px)/1.05 var(--serif); margin: 8px 0 0; color: var(--ink); }
.soon-pre {
  display: inline-block; margin: 10px 0 0; padding: 5px 11px;
  border: 1px solid var(--brass); border-radius: 999px;
  font: 12.5px var(--sans); color: var(--brass); letter-spacing: .02em;
}
.soon-pre b { color: var(--ink); font-weight: 700; }
.soon-what { font: 14.5px/1.65 var(--sans); color: var(--dim); margin: 12px 0 0; max-width: 54ch; }
.soon-what b { color: var(--ink); }

/* ── the sky page (the orrery IS the interface) ───────────────────────── */
body.sky-page { height: 100%; overflow: hidden; }
body.sky-page #sky { opacity: 1; }
.sky-hint {
  position: fixed; left: 0; right: 0; bottom: 26px; z-index: 2;
  text-align: center; margin: 0; pointer-events: none;
  font: 11px var(--mono); letter-spacing: .24em; text-transform: uppercase; color: var(--dim);
  animation: breathe 3.4s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: .35; } 50% { opacity: .85; } }
.sky-hint.gone { display: none; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.visually-hidden:focus-within {
  position: fixed; top: 12px; left: 12px; width: auto; height: auto;
  clip: auto; clip-path: none; z-index: 20;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--panel); border: 1px solid var(--brass); border-radius: 4px; padding: 8px;
}

/* ── the world card ───────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(8, 6, 7, .58);
  backdrop-filter: blur(3px);
  animation: fade .22s ease both;
}
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal .panel {
  position: relative; width: min(440px, 100%);
  max-height: min(78vh, 640px); overflow-y: auto;
  animation: pop .26s cubic-bezier(.2, .7, .3, 1) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.close {
  position: absolute; top: 10px; right: 10px;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--edge);
  color: var(--ink); font: 20px/1 var(--sans); cursor: pointer;
}
.close:hover { border-color: var(--accent); }
.modal .genre { padding-right: 40px; }

/* On a phone the card is a sheet, not a curtain: the chosen world lifts into the
   space above it (see applyFraming) and keeps turning while you read. The
   backdrop stays clear at the top so nothing covers it. */
@media (orientation: portrait) {
  .modal {
    align-items: flex-end; padding: 0;
    backdrop-filter: none;
    background: linear-gradient(to bottom,
      rgba(8, 6, 7, 0) 0%, rgba(8, 6, 7, 0) 34%,
      rgba(8, 6, 7, .72) 46%, rgba(8, 6, 7, .93) 60%);
  }
  .modal .panel {
    width: 100%; max-height: 60vh;
    border-radius: 12px 12px 0 0;
    border-left: 1px solid var(--edge); border-top: 2px solid var(--accent);
    padding-bottom: 28px;
  }
  .modal .panel::before {           /* the grab-handle affordance */
    content: ""; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 99px; background: var(--edge);
  }
  .close { top: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .sky-hint { animation: none; opacity: .6; }
  .modal, .modal .panel { animation: none; }
}
@media (prefers-reduced-motion: reduce) {
  .stage.on { animation: none; }
  .cta, .worldbtn, .chip { transition: none; }
}
