/* The night world: the story's sky on the pages a person walks into from it,
 * and the same world in daylight when the day theme is chosen.
 *
 * theme-toggle.js sets html[data-world="night"] on the brief (/brief), the run
 * tab (/?run=…), a saved plan (/?plan=…), the dashboard and the workspace,
 * and paints them in the Night
 * palette (lib/palette.js), so every colour on those pages still comes from
 * the derivation and is held to its contrast rules. This file adds only what a
 * palette cannot carry: the story's type, and its sky. Every rule is scoped to
 * the world, so a page outside it is untouched.
 */
html[data-world="night"] {
  --font-body: "Geist", "Vazirmatn", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Instrument Serif", "Vazirmatn", "Iowan Old Style", Georgia, serif;
  --font-mono-night: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
html[data-world="night"][data-theme="dark"] { color-scheme: dark; }

/* The sky: the story's two glows (gold where Polaris sits, a cool haze
   opposite) and a sparse field of stars, fixed behind the page. */
html[data-world="night"][data-theme="dark"] body {
  background:
    radial-gradient(55% 38% at 82% -6%, color-mix(in srgb, var(--c-accent) 14%, transparent), transparent 72%),
    radial-gradient(70% 50% at 6% -4%, rgba(126, 178, 255, 0.07), transparent 70%),
    var(--c-ground);
  background-attachment: fixed;
}
html[data-world="night"][data-theme="dark"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    radial-gradient(1px 1px at 8% 14%, #eef2f8 50%, transparent 51%),
    radial-gradient(1px 1px at 23% 61%, #9fb3d9 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 37% 27%, #eef2f8 50%, transparent 51%),
    radial-gradient(1px 1px at 52% 83%, #9fb3d9 50%, transparent 51%),
    radial-gradient(1px 1px at 64% 41%, #eef2f8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 79% 9%, #ffe2a0 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 67%, #9fb3d9 50%, transparent 51%),
    radial-gradient(1px 1px at 95% 33%, #eef2f8 50%, transparent 51%);
  background-size: 520px 520px;
}
@media (prefers-reduced-transparency: reduce) {
  html[data-world="night"] body::before { display: none; }
}

/* Type: the story's serif for headings, its mono for labels. Instrument Serif
   has one weight, so headings set it at 400 and gain size instead. */
html[data-world="night"] h1,
html[data-world="night"] h2 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0;
}
html[data-world="night"] .sec .sh h2 { font-size: 24px; line-height: 1.1; }
/* The app's panel titles are small uppercase labels, not headings to read:
   they take the story's kicker (gold mono), as its chapters do. */
html[data-world="night"] .panel-head h2 {
  font-family: var(--font-mono-night);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--c-accent);
}
html[data-world="night"] .k,
html[data-world="night"] .section-kicker,
html[data-world="night"] .run-banner .rb-note {
  font-family: var(--font-mono-night);
  letter-spacing: 0.08em;
}

/* Day: the same world at dawn. No stars; the gold glow where Polaris sits
   stays, faint, over the palette's daylight ground. */
html[data-world="night"][data-theme="light"] body {
  background:
    radial-gradient(55% 38% at 82% -6%, color-mix(in srgb, var(--c-accent) 12%, transparent), transparent 72%),
    var(--c-ground);
  background-attachment: fixed;
}

/* Fields. Everywhere else a field stays light in the dark theme (lib/palette.js:
   "the one place a surface does not flip"); on the story's sky a white slab is
   the loudest thing on the page, so here a field is a raised night with the
   page's own ink on it. */
html[data-world="night"][data-theme="dark"],
html[data-world="night"][data-theme="dark"] body {   /* body too: the palette also writes its tokens on body.theme-dark */
  --c-field: #131C30;
  --c-on-field: var(--c-ink);
}
html[data-world="night"] input::placeholder,
html[data-world="night"] textarea::placeholder { color: var(--c-ink-3); opacity: 1; }

/* Surfaces read as glass over the sky rather than slabs on it. */
html[data-world="night"] .pol-card,
html[data-world="night"] .card {
  background: color-mix(in srgb, var(--c-surface) 84%, transparent);
  border-color: var(--c-line);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* The story's buttons are pills. */
html[data-world="night"] .pri,
html[data-world="night"] .ghost,
html[data-world="night"] .acct-signin {
  border-radius: 999px;
}

/* The day/night switch, as a pill like the story's controls. */
html[data-world="night"] .theme-toggle { border-radius: 999px; }

/* The language switch, as the story draws it: one pill, the chosen language
   lit in gold. */
html[data-world="night"] .lang-toggle {
  display: inline-flex;
  border: 1px solid var(--c-line);
  border-radius: 999px;
  padding: 3px;
  background: transparent;
  gap: 0;
}
html[data-world="night"] .lang-toggle button,
html[data-world="night"] body .lang-toggle button {   /* body: outranks the app's [data-theme="dark"] body rule */
  min-height: 32px;
  min-width: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--c-ink-2);
  font: 500 13px var(--font-body);
  cursor: pointer;
}
html[data-world="night"] .lang-toggle button[aria-pressed="true"],
html[data-world="night"] body .lang-toggle button.active {
  background: var(--c-accent);
  color: var(--c-on-accent);
}
