/* Silent Orbit viewer.
   Layout: a journal page turned sideways. The figure fills the left of the screen at full height;
   a column on the right holds the title between rules, the caption, the controls, "In this round"
   and the lanterns, so everything stays in view while a game plays. On a phone they stack.
   One deliberate night palette: flat navy page, pale ink lines, lanterns are the only warm colour. */
:root {
  --paper: #1f3a5c;          /* the flat page colour */
  --ink: #e7edf6;            /* lines and text */
  --ink-soft: rgba(231, 237, 246, 0.62);
  --ink-faint: rgba(231, 237, 246, 0.28);
  --rule: rgba(231, 237, 246, 0.55);
  --lantern: #f3c46a;        /* a lit lantern */
  --secret: #c3b2f2;         /* whispers and private thoughts (the dashed second colour) */
  --strike: #fff6dc;

  --font-title: "Barlow Semi Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --font-math: "STIX Two Text", "Times New Roman", Times, serif;

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-title);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding-block: 20px 32px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.side { display: grid; gap: 16px; align-content: start; min-width: 0; }
.side > * { min-width: 0; }

/* The planet: as big as the screen allows, no frame. */
.stage { position: relative; display: grid; place-items: center; min-width: 0; }
#fig {
  width: min(100%, 92vh);
  aspect-ratio: 1 / 1; max-width: 100%; display: block;
  touch-action: none; cursor: grab;
}
#fig.dragging { cursor: grabbing; }
.zoom { position: absolute; right: 4px; bottom: 4px; display: flex; gap: 6px; align-items: baseline; }
.zoom .link { font-size: 20px; padding: 2px 8px; }
.zoom .link.small { font-size: 12.5px; }
.hint { position: absolute; left: 4px; bottom: 6px; margin: 0; font-size: 12px; letter-spacing: 0.06em; color: var(--ink-faint); }

/* Wide screens: figure left at full height, everything else in a column on the right. */
@media (min-width: 1000px) {
  html, body { overflow: hidden; }
  .page { height: 100vh; grid-template-columns: minmax(0, 1fr) clamp(420px, 34vw, 520px); gap: 32px; padding-block: 0; padding-left: 0; }
  .stage { height: 100vh; }
  #fig { width: 100%; height: 100vh; aspect-ratio: auto; }
  .side { height: 100vh; overflow-y: auto; overflow-x: hidden; padding-block: 28px 28px; padding-right: 10px; scrollbar-width: thin; }
  .zoom { right: 8px; bottom: 10px; }
  .hint { left: max(16px, env(safe-area-inset-left, 0px)); bottom: 12px; }
}

/* ---------- Masthead: title between rules ---------- */
.masthead { display: grid; gap: 0; }
.meta {
  margin: 0 0 10px; display: flex; justify-content: space-between; gap: 6px 14px; flex-wrap: wrap;
  font-size: 14px; color: var(--ink-soft); font-variant-numeric: tabular-nums;
}
.title { margin: 0; display: grid; }
.title span {
  display: block;
  font-weight: 600;
  font-size: clamp(42px, 5.2vw, 64px);
  line-height: 1.02;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  padding: 4px 0 2px;
  border-top: 2px solid var(--rule);
}
.title span:last-child { border-bottom: 2px solid var(--rule); }
.kicker { margin: 10px 0 0; font-family: var(--font-math); font-style: italic; font-size: 16px; color: var(--ink-soft); }

.live { font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; font-size: 14px; color: var(--lantern); }
.live[data-state="idle"], .live[data-state="done"] { color: var(--ink-soft); }
.live[data-state="on"]::before, .live-stage::before { content: "●"; margin-right: 7px; display: inline-block; animation: liveblink 1.1s steps(1, end) infinite; }
@keyframes liveblink { 0% { opacity: 1; } 55% { opacity: 0; } }
.live-stage {
  position: absolute; top: 18px; left: max(16px, env(safe-area-inset-left, 0px)); margin: 0;
  font-weight: 600; font-size: 17px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--lantern);
}

/* ---------- Caption: under the figure, like a figure caption in a paper ---------- */
/* On a phone it simply follows the planet. On wide screens it is pinned to the bottom left of the
   figure and grows upward, so however long a thought is, nothing else on the page moves. */
.now { display: flex; flex-direction: column; gap: 8px; max-width: 62ch; margin-top: 4px; }
.stage .now { justify-self: stretch; margin-bottom: 44px; }  /* phones: leave room for the zoom row under it */
@media (min-width: 1000px) {
  .stage .now {
    position: absolute; left: max(28px, env(safe-area-inset-left, 0px)); bottom: 46px;
    width: min(620px, calc(100% - 220px)); max-height: 46vh; overflow-y: auto; scrollbar-width: thin;
    padding: 0 8px 0 0;
    margin: 0;
  }
}
.now > p { flex: none; }
.caption { margin: 0; font-family: var(--font-math); font-size: 18px; line-height: 1.5; color: var(--ink); text-wrap: pretty; }
.caption b { font-family: var(--font-title); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; font-size: 13px; }
.caption .fig-no { font-family: var(--font-title); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; font-size: 13px; color: var(--ink-soft); margin-right: 6px; }
.speech { margin: 0; font-family: var(--font-math); font-size: 17.5px; line-height: 1.45; padding-left: 14px; border-left: 2px solid var(--ink-faint); }
.speech.whisper { border-left: 2px dashed var(--secret); color: var(--secret); }
.thought { margin: 0; font-family: var(--font-math); font-style: italic; font-size: 17px; line-height: 1.45; color: var(--secret); }
.thought::before { content: "privately: "; font-family: var(--font-title); font-style: normal; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.outcome { margin: 0; font-family: var(--font-math); font-size: 17px; line-height: 1.5; padding-top: 8px; border-top: 1px solid var(--ink-faint); }
.outcome strong { font-family: var(--font-title); letter-spacing: 0.08em; text-transform: uppercase; font-size: 13px; color: var(--lantern); margin-right: 6px; }

/* ---------- Controls: plain text, no boxes ---------- */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; }
.link {
  background: none; border: 0; padding: 6px 2px; cursor: pointer;
  font-family: var(--font-title); font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-soft); border-bottom: 1px solid transparent;
}
.link:hover { color: var(--ink); border-bottom-color: var(--ink-faint); }
.link.strong { color: var(--ink); font-weight: 600; min-width: 4.5em; }
.link[aria-pressed="true"] { color: var(--lantern); }
.link:focus-visible, .scrub:focus-visible, select:focus-visible, .check input:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }
.check { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.check input { accent-color: var(--secret); width: 14px; height: 14px; margin: 0; }

.progress { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: center; }
.round-label { font-size: 13.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); font-variant-numeric: tabular-nums; min-width: 9.5em; }
.scrub { width: 100%; accent-color: var(--ink); background: transparent; }

/* ---------- Under the figure: like "In this issue" ---------- */
.issue h2, .lanterns h2 { margin: 0 0 8px; font-size: 16px; font-weight: 600; letter-spacing: 0.02em; }
.issue ul { margin: 0; padding-left: 18px; display: grid; gap: 7px; }
.issue li { font-size: 16.5px; line-height: 1.45; color: var(--ink); max-width: 62ch; }
.issue li::marker { color: var(--ink-soft); }
.issue li.k-strike, .issue li.k-faded { color: var(--lantern); }
.issue li.secret { color: var(--secret); }
.issue li .q { font-family: var(--font-math); font-style: italic; }

.lanterns table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 15px; }
.lanterns th { text-align: left; font-weight: 500; font-size: 12.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); padding: 0 8px 6px 0; border-bottom: 1px solid var(--ink-faint); }
.lanterns td { padding: 6px 8px 6px 0; border-bottom: 1px solid rgba(231, 237, 246, 0.1); vertical-align: baseline; }
.lanterns td.mk { color: var(--lantern); width: 1.4em; font-size: 13px; }
.lanterns tr.out td { color: var(--ink-faint); }
.lanterns tr.out td.mk { color: var(--ink-faint); }
.lanterns tr.out td.nm { text-decoration: line-through; }
.lanterns .role { display: block; font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--secret); }
.lanterns .role.hunter { color: #ff9fae; }

/* ---------- Footer ---------- */
.foot { display: grid; justify-items: stretch; min-width: 0; gap: 10px; padding-top: 14px; border-top: 2px solid var(--rule); }
.foot p { margin: 0; font-size: 13px; color: var(--ink-soft); letter-spacing: 0.03em; }
.picker { display: flex; gap: 10px; align-items: center; width: 100%; min-width: 0; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); max-width: 100%; }
.picker select {
  flex: 1 1 0; width: 100%; max-width: 100%; min-width: 0; text-overflow: ellipsis; background: transparent; color: var(--ink); border: 0; border-bottom: 1px solid var(--ink-faint);
  font-family: var(--font-title); font-size: 14px; padding: 4px 2px;
}
.picker option { background: var(--paper); color: var(--ink); }

@media (prefers-reduced-motion: reduce) { .live[data-state="on"]::before, .live-stage::before { animation: none; } }
