/* Switchyard control room. Tailwind (CDN) handles layout utilities; this file holds the
   parts that are specific to the control room. */

:root {
  --bg: #0b0f17;
  --panel: #131a26;
  --line: #1f2937;
  --ink: #e5e7eb;
  --muted: #9ca3af;
  --rose: #fb7185;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
}

html { background: var(--bg); }
body { background: var(--bg); color: var(--ink); font-family: Inter, system-ui, sans-serif; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.hidden-view { display: none !important; }

/* Navigation */
.nav-btn { padding: 6px 12px; border-radius: 8px; font-size: 13px; color: var(--muted); border: 1px solid transparent; white-space: nowrap; }
.nav-btn:hover { color: var(--ink); }
.nav-btn.active { color: var(--ink); background: var(--panel); border-color: var(--line); }
.tour-btn { padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: #0b0f17; background: var(--rose); white-space: nowrap; }
.tour-btn:hover { filter: brightness(1.08); }

/* Headline */
.headline { font-size: clamp(17px, 2.1vw, 27px); line-height: 1.28; font-weight: 600; letter-spacing: -0.01em; max-width: 60ch; }
.headline b { color: var(--rose); font-family: "JetBrains Mono", monospace; font-weight: 600; }
.mock-banner { background: #3b2a06; color: #fcd34d; border: 1px solid #92400e; border-radius: 8px; padding: 6px 12px; font-size: 13px; }

/* Yard panels */
.yard-panel { background: linear-gradient(180deg, #0f1521 0%, #0c111b 100%); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; min-width: 0; }
.yard-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.yard-sub { font-size: 12px; color: var(--muted); }
.yard-canvas { display: block; width: 100%; height: var(--yard-h, clamp(340px, calc(100vh - 450px), 640px)); cursor: crosshair; }
.yard-panel select { background: var(--panel); border: 1px solid var(--line); border-radius: 7px; color: var(--ink); font-size: 12.5px; padding: 3px 6px; }

.dials { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.dial { padding: 9px 10px 10px; border-right: 1px solid var(--line); min-width: 0; }
.dial:last-child { border-right: 0; }
.dial-label { font-size: 10px; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dial-value { font-family: "JetBrains Mono", monospace; font-variant-numeric: tabular-nums; font-size: clamp(15px, 1.5vw, 21px); font-weight: 600; margin-top: 2px; white-space: nowrap; }
.dial-value small { font-size: 0.6em; font-weight: 400; color: var(--muted); margin-left: 2px; }
.dial-value.good { color: var(--good); }
.dial-value.warn { color: var(--warn); }
.dial-value.bad { color: var(--bad); }
.dial-value.rose { color: var(--rose); }

/* Scoreboard between the two yards */
.scoreboard { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.score-title { font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.score-row { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; align-items: baseline; padding: 9px 0; border-top: 1px solid var(--line); }
.score-name { grid-column: 1 / -1; font-size: 12px; color: var(--muted); text-align: center; }
.score-val { font-family: "JetBrains Mono", monospace; font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 600; white-space: nowrap; }
.score-val.right { text-align: right; }
.score-val.win { color: var(--good); }
.score-bar { grid-column: 1 / -1; height: 3px; background: var(--line); border-radius: 2px; display: flex; overflow: hidden; margin-top: 2px; }
.score-bar i { display: block; height: 100%; }

/* Transport */
.transport { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.play-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--rose); color: #0b0f17; display: grid; place-items: center; flex: none; }
.play-btn:hover { filter: brightness(1.08); }
.speed-group { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; }
.speed-btn { padding: 5px 9px; font-size: 12px; color: var(--muted); font-family: "JetBrains Mono", monospace; }
.speed-btn.active { background: var(--rose); color: #0b0f17; font-weight: 600; }
.scrub-wrap { position: relative; flex: 1 1 260px; height: 44px; min-width: 200px; }
.scrub-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.scrub-wrap input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; margin: 0; }
.time-readout { font-family: "JetBrains Mono", monospace; font-size: 13px; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.time-readout b { color: var(--ink); font-weight: 600; }

/* Inspector */
.inspector { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; font-size: 13px; }
.inspector.floating { position: fixed; right: 16px; bottom: 16px; width: min(340px, calc(100vw - 32px)); z-index: 40; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55); }
.inspector h3 { font-size: 13px; font-weight: 600; }
.inspector dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin-top: 10px; }
.inspector dt { color: var(--muted); }
.inspector dd { font-family: "JetBrains Mono", monospace; font-variant-numeric: tabular-nums; text-align: right; }
.inspector .why { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: #0e1420; border: 1px solid var(--line); color: var(--ink); line-height: 1.45; }

.tip { position: fixed; z-index: 50; pointer-events: none; background: #0e1420; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 12px; max-width: 280px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: baseline; }
.honest { font-size: 12.5px; color: var(--muted); }
.honest b { color: var(--ink); font-weight: 500; }
.tag { display: inline-block; font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; padding: 2px 7px; border-radius: 5px; border: 1px solid var(--line); color: var(--muted); }
.tag.real { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.tag.modeled { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }

input[type="range"].slo { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 2px; background: var(--line); outline: none; }
input[type="range"].slo::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--rose); cursor: pointer; border: 2px solid var(--bg); }
input[type="range"].slo::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--rose); cursor: pointer; border: 2px solid var(--bg); }

/* Tour and captions */
.tour-layer { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.tour-card { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); width: min(560px, calc(100vw - 32px)); background: #0e1420; border: 1px solid var(--rose); border-radius: 14px; padding: 16px 18px; pointer-events: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); }
.tour-card h4 { font-size: 16px; font-weight: 600; }
.tour-card p { margin-top: 6px; color: #cbd5e1; font-size: 14px; line-height: 1.5; }
.tour-spot { position: fixed; border: 2px solid var(--rose); border-radius: 16px; box-shadow: 0 0 0 9999px rgba(5, 8, 13, 0.62); }

@media (max-width: 900px) {
  .dials { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dial:nth-child(3) { border-right: 0; }
  .dial:nth-child(-n + 3) { border-bottom: 1px solid var(--line); }
  .yard-canvas { height: var(--yard-h-mobile, 300px); }
}

@media (min-width: 1024px) {
  #view-room .yard-canvas { height: var(--yard-h, clamp(420px, calc(100vh - 440px), 700px)); }
}

/* Page layouts. Plain CSS (not Tailwind classes) so they apply before the first paint. */
.layout-split, .layout-side { display: grid; gap: 12px; align-items: start; grid-template-columns: minmax(0, 1fr); }
.layout-split .scoreboard { order: 3; }
@media (min-width: 1024px) {
  .layout-split { grid-template-columns: minmax(0, 1fr) 230px minmax(0, 1fr); }
  .layout-split .scoreboard { order: 0; }
  .layout-side { grid-template-columns: minmax(0, 1fr) 350px; }
}

/* Record mode (video capture). Every animated value is set per frame by js/record.js. */
body.recording { overflow: hidden; }
body.recording #pickers, body.recording #tour-start { display: none !important; }
body.recording .yard-canvas { height: var(--rec-yard-h, 560px); }
body.recording main { max-width: 1840px; }
body.recording header > div { max-width: 1840px; }
body.recording .headline { font-size: 30px; max-width: 70ch; }
body.recording .dial-value { font-size: 26px; }
body.recording .dial-label { font-size: 12px; }
body.recording .score-val { font-size: 22px; }
body.recording .score-name { font-size: 13.5px; }
body.recording #view-split { grid-template-columns: minmax(0, 1fr) 270px minmax(0, 1fr); }
body.recording.vertical #view-split { grid-template-columns: minmax(0, 1fr); }
body.recording.vertical .yard-canvas { height: var(--rec-yard-h, 470px); }
body.recording.vertical #view-split .scoreboard { order: 0; }
body.recording.vertical .headline { font-size: 34px; }

#rec-layer { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
#rec-layer > div { position: absolute; }
#rec-cine { inset: 0; background: #05080d; display: none; }
#rec-cine canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
body.vertical #rec-cine canvas { top: 30%; height: 40%; }
#rec-curtain { inset: 0; background: #05080d; opacity: 0; }
#rec-badge { left: 50%; top: 16%; transform: translateX(-50%); display: none; padding: 14px 28px; border-radius: 999px; background: rgba(11, 15, 23, 0.92); border: 2px solid var(--rose); color: var(--rose); font: 600 30px "JetBrains Mono", monospace; }
#rec-caption { left: 0; right: 0; bottom: 12%; text-align: center; padding: 0 6%; }
#rec-caption.top { bottom: auto; top: 7.5%; }
.rec-caption-box { display: inline-block; padding: 18px 34px; border-radius: 18px; background: rgba(5, 8, 13, 0.86); border: 1px solid var(--line); font: 600 46px/1.25 Inter, sans-serif; letter-spacing: -0.015em; color: var(--ink); max-width: 30ch; }
body.vertical .rec-caption-box { font-size: 50px; max-width: 18ch; }
#rec-number { inset: 0; background: #05080d; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 46px; padding: 0 6%; text-align: center; }
.rec-number-line { font: 500 34px/1.3 Inter, sans-serif; color: var(--muted); max-width: 30ch; }
.rec-number-row { display: flex; gap: 90px; flex-wrap: wrap; justify-content: center; }
body.vertical .rec-number-row { flex-direction: column; gap: 54px; }
.rec-number-value { font: 600 150px/1 "JetBrains Mono", monospace; color: var(--rose); letter-spacing: -0.04em; }
.rec-number-label { margin-top: 14px; font: 500 28px Inter, sans-serif; color: var(--ink); max-width: 16ch; margin-inline: auto; }
.rec-number-foot { font: 400 22px Inter, sans-serif; color: var(--muted); max-width: 60ch; }
#rec-end { inset: 0; background: #05080d; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; padding: 0 8%; }
.rec-end-name { font: 700 96px Inter, sans-serif; letter-spacing: -0.03em; margin-top: 16px; }
.rec-end-line { font: 400 32px/1.35 Inter, sans-serif; color: var(--muted); max-width: 32ch; }
.rec-end-url { margin-top: 20px; font: 600 28px "JetBrains Mono", monospace; color: var(--rose); }

/* Record mode, replay scenes: the headline band is kept empty for the captions. */
body.recording #headline { visibility: hidden; }
body.recording #headline-box { min-height: 92px; }
body.recording #view-room .yard-canvas { height: var(--rec-yard-h, 600px); } /* footer stays inside 1080 px */
body.recording #view-split .yard-canvas { height: var(--rec-yard-h, 600px); }
#rec-caption.top .rec-caption-box { font-size: 38px; max-width: 48ch; padding: 14px 30px; }
body.recording.vertical header { display: none; }
body.recording.vertical #headline-box { min-height: 196px; }
body.recording.vertical #view-split .yard-canvas { height: 384px; } /* footer stays inside 1920 px */
/* Vertical cut, one router: the yard fills the frame, the side panels are left out. */
body.recording.vertical #view-room { grid-template-columns: minmax(0, 1fr); }
body.recording.vertical #view-room > div:last-child { display: none; }
body.recording.vertical #view-room .yard-canvas { height: 1380px; }
body.recording.vertical #view-whatif .layout-side { grid-template-columns: minmax(0, 1fr); } /* chart on top, full width */
body.recording #rec-badge { top: 8.5%; }
body.recording.vertical #rec-badge { top: 4%; }
body.recording.vertical #rec-caption.top { top: 1.4%; }
body.recording.vertical #rec-caption.top .rec-caption-box { font-size: 44px; max-width: 22ch; }
body.recording.vertical .score-row { padding: 6px 0; }
