/* Night Shift visual system (D-048, Antigravity round three) and "the Watch" (D-045).
   Loaded last on every page, landing and dashboard. It remaps the shared tokens to the
   approved night-shift palette, sets local-only type, and styles the Watch, his lantern
   status and the scene illustrations. Design only: no behaviour lives here. */

:root {
  /* Night-shift surfaces */
  --bg: #0b1922;
  --surface: #112532;
  --surface2: #173142;
  --surface-lit: #1c3a4c;
  --surface-inset: #0d1f2a;
  /* Lines: a visible boundary for inputs and rows (3:1 against the surfaces) */
  --line: #36596b;
  --line-soft: rgba(154, 189, 209, 0.18);
  --border-warm: rgba(245, 184, 75, 0.42);
  /* Text */
  --text: #f4efe6;
  --muted: #bfd1dc;
  --text-quiet: #9ab3c2;
  /* Lantern accent */
  --amber: #f5b84b;
  --amber-hover: #f9c86b;
  --amber-soft: rgba(245, 184, 75, 0.14);
  --amber-text: #0b1922;
  /* Status: shape + words + colour */
  --good: #7ef0c8;
  --good-bg: #10322c;
  --warn: #fbcb6b;
  --warn-bg: #342812;
  --bad: #ff9e9e;
  --bad-bg: #3c191f;
  /* Local fonts only: nothing is downloaded. */
  --font-sans: "Plus Jakarta Sans", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --shadow-soft: 0 8px 24px rgba(3, 10, 15, 0.36);
  --shadow-lifted: 0 14px 34px rgba(3, 10, 15, 0.48);
  --shadow-lantern: 0 12px 32px rgba(245, 184, 75, 0.14);
  --ease-calm: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: var(--font-sans);
}

body {
  background: radial-gradient(circle at 18% 0%, #142f3f 0%, var(--bg) 520px) no-repeat, var(--bg);
  font-family: var(--font-sans);
}
.mono, code, time, .readout, kbd, pre { font-family: var(--font-mono); }

/* Panels: depth from tint and soft night shadow, one subtle outline */
.panel, .report-paper, .finding, .scan-panel, .translator-panel, .free-panel {
  border-color: var(--line-soft);
  box-shadow: var(--shadow-soft);
}
.panel { background: linear-gradient(170deg, var(--surface) 0%, #0f2230 100%); }
.button.primary { box-shadow: var(--shadow-lantern); }
.button:not(.primary):hover { background: var(--surface-lit); }
input:not([type=range]):not([type=radio]):not([type=checkbox]), select, textarea { background: var(--surface-inset); }
.top, .dashboard-footer, .watch-list, .watch, .rows li { border-color: var(--line-soft); }
.status.bad { color: var(--bad); }

/* ---------- The Watch: brand mark ---------- */
.watch-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.watch-brand img { width: 40px; height: 40px; flex: none; border-radius: 10px; }
.watch-brand .brand-wordmark { font-size: 18px; }
.brand-mark { border-radius: 9px; }

/* ---------- Lantern status: the Watch's lantern glow carries the status, words always beside it ---------- */
.lantern-status { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; white-space: nowrap; }
.lantern { width: 30px; height: 34px; flex: none; overflow: visible; }
.lantern .frame { fill: #0f2431; stroke: #f5efe3; stroke-width: 2; stroke-linejoin: round; }
.lantern .handle, .lantern .cap { fill: none; stroke: #f5efe3; stroke-width: 2; stroke-linecap: round; }
.lantern .halo { opacity: .55; }
.lantern .flame { transform-box: fill-box; transform-origin: 50% 90%; }
.lantern-status.good { color: var(--good); }
.lantern-status.good .flame { fill: #ffefb8; }
.lantern-status.good .halo { fill: #f5b84b; opacity: .5; }
.lantern-status.warn { color: var(--warn); }
.lantern-status.warn .flame { fill: #f5b84b; animation: lantern-flicker 3.2s ease-in-out infinite; }
.lantern-status.warn .halo { fill: #f5b84b; opacity: .32; animation: lantern-breathe 3.2s ease-in-out infinite; }
.lantern-status.bad { color: var(--bad); }
.lantern-status.bad .flame { fill: #ff6b6b; }
.lantern-status.bad .halo { fill: #ff6b6b; opacity: .5; }
.lantern-status.idle { color: var(--muted); }
.lantern-status.idle .flame { fill: #6f8796; }
.lantern-status.idle .halo { opacity: 0; }
/* Slow, CSS-only idle loop for "needs attention"; off under reduced motion. */
@keyframes lantern-flicker { 0%, 100% { transform: scale(1); opacity: 1; } 40% { transform: scale(.9, .96); opacity: .82; } 70% { transform: scale(1.04, .98); opacity: .95; } }
@keyframes lantern-breathe { 0%, 100% { opacity: .32; } 50% { opacity: .16; } }

/* ---------- Scene illustrations ---------- */
.scene { margin: 0; border-radius: 16px; overflow: hidden; background: #0b1922; box-shadow: var(--shadow-lifted); border: 1px solid var(--line-soft); }
.scene img { display: block; width: 100%; height: auto; }
.scene-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 300px); gap: 24px; align-items: center; }
.scene-row > .scene { order: 2; }
.panel .scene-row + * { margin-top: 18px; }
.empty-scene { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 28px; align-items: center; }
.site-scene { max-width: 340px; }
.side-scene { max-width: 280px; margin-bottom: 16px; }
.connect-scene { max-width: 360px; }
.report-scene { max-width: 320px; }

/* ---------- Section icons (new 24px UI set) ---------- */
.ui-icon { display: inline-block; width: 24px; height: 24px; flex: none; background: var(--amber); -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; vertical-align: -4px; margin-right: 10px; }
.icon-heading { display: flex; align-items: center; }

/* ---------- Tour: illustration plus a copy of the exact control the step teaches ---------- */
.tour-panel { width: min(400px, calc(100% - 32px)); background: linear-gradient(170deg, var(--surface-lit), var(--surface)); border-color: var(--border-warm); box-shadow: var(--shadow-lifted), var(--shadow-lantern); max-height: calc(100vh - 44px); overflow: auto; }
.tour-scene { margin: -6px -6px 12px; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 8; background: #0b1922; }
.tour-scene img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tour-control { margin: 12px 0 4px; padding: 12px; border-radius: 12px; background: var(--surface-inset); border: 1px dashed var(--border-warm); }
.tour-control .label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.tour-control .replica { pointer-events: none; }
.tour-control .mini-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tour-control .mini-row strong { font-size: 16px; }

/* ---------- Landing hero: the 2 am shophouse street, fully drawn in the first frame ---------- */
.hero.hero-night { grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr); min-height: 0; }
.hero-art { margin: 0; border-radius: 20px; overflow: hidden; border: 1px solid var(--border-warm); box-shadow: var(--shadow-lifted), var(--shadow-lantern); background: #0b1922; aspect-ratio: 16 / 9; }
.hero-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.hero-art figcaption { position: absolute; left: -9999px; }
.try-scan { padding-block: 10px 60px; }
.try-scan .try-layout { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 46px; align-items: center; }
.night-art { max-width: 520px; margin: 0 0 26px; }

/* ---------- Type floor: nothing under 14px ---------- */
.eyebrow { font-size: 14px; letter-spacing: .08em; }
small, .readout { font-size: 14px; }

@media (max-width: 1000px) {
  .scene-row, .empty-scene { grid-template-columns: 1fr; }
  .scene-row > .scene { order: 0; max-width: 420px; }
}
@media (max-width: 800px) {
  .hero.hero-night, .try-scan .try-layout { grid-template-columns: 1fr; }
  .try-scan .try-layout { gap: 24px; }
}
@media (max-width: 780px) {
  .tour-scene { aspect-ratio: 16 / 7; }
  .tour-panel { max-height: calc(100vh - 100px); }
}

@media (prefers-reduced-motion: reduce) {
  .lantern-status .flame, .lantern-status .halo { animation: none !important; }
}

/* Site rows: room for the lantern and its words; a down row is tinted red to match the red lantern. */
.watch { grid-template-columns: minmax(0, 1fr) auto auto auto; column-gap: 22px; }
.watch-state { gap: 14px; }
.watch.down { background: linear-gradient(90deg, rgba(60, 25, 31, .85), rgba(60, 25, 31, .25)); border-left-color: var(--bad); }
@media (max-width: 1100px) {
  .watch { grid-template-columns: minmax(0, 1fr) auto; }
  .watch-state { flex-wrap: wrap; }
}

/* Landing section tints moved onto the night-shift palette (were green-grey). */
.translator { background: #0d1f2a; }
.night { background: #0a1720; }
.clock-face { background: radial-gradient(circle at 50% 45%, #1c3a4c 0%, var(--surface) 64%); box-shadow: 0 0 0 16px #0f2230, var(--shadow-lantern); }
.phone { border-color: #24465a; }
.button.primary:hover { background: var(--amber-hover); }
@media (max-width: 780px) {
  /* Phone rows: name, then heartbeat + lantern + words on one line, then "checked" and the button. */
  .watch-state { grid-column: 1 / -1; flex-wrap: nowrap; }
  .watch > .mono.small { align-self: center; }
}
@media (max-width: 780px) {
  .tour-scene { aspect-ratio: 16 / 6; }
  .tour-panel p[data-body] { margin-bottom: 8px; }
  .tour-control { margin-top: 8px; padding: 10px; }
  .tour-dots { margin: 12px 0; }
}
@media (max-width: 780px) {
  /* While the tour is open, leave room so the last controls can scroll above the bottom panel. */
  body.touring .main { padding-bottom: 100vh; }
}
