/* DualLux — Titanium expedition console
   Palette: slate graphite, olive, amber, titanium silver, night navy
   Avoid: newsprint, fight-broadcast, winter snowfall lab */

:root {
  --graphite: #1a1d1a;
  --graphite-2: #222622;
  --graphite-3: #2a3028;
  --olive: #5c6b4a;
  --olive-dim: #3d4734;
  --olive-bright: #7a8f62;
  --amber: #d4a017;
  --amber-dim: #9a7510;
  --amber-glow: rgba(212, 160, 23, 0.35);
  --titanium: #8a9096;
  --titanium-bright: #c4c8cc;
  --navy: #0c1220;
  --navy-2: #141c2e;
  --ink: #e8e6e1;
  --ink-dim: #a8a69e;
  --danger: #b54a3a;
  --rail-w: min(420px, 100%);
  --gap: 12px;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--graphite);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--amber); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--titanium-bright); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; margin: 0 0 0.5em; }
p { margin: 0 0 0.85em; }
ul { margin: 0 0 1em; padding-left: 1.15em; }
code, .mono { font-family: var(--font-mono); font-size: 0.9em; }

/* Noise overlay */
.noise-layer {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 9998;
  opacity: 0.04;
  background: url("assets/noise.svg") repeat;
  mix-blend-mode: overlay;
}

/* —— Top strip —— */
.console-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 10px 14px;
  background: var(--navy);
  border-bottom: 1px solid var(--olive-dim);
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand-lock {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}
.brand-lock img { width: 110px; height: auto; }
.brand-word {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: 0.95rem;
}
.bar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--titanium);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pill {
  border: 1px solid var(--olive-dim);
  padding: 3px 8px;
  background: var(--graphite-2);
  color: var(--olive-bright);
}
.pill.amber { border-color: var(--amber-dim); color: var(--amber); }

/* —— Asymmetric shell —— */
.console {
  display: grid;
  grid-template-columns: 1fr;
  min-height: calc(100dvh - 52px);
}
@media (min-width: 960px) {
  .console {
    grid-template-columns: var(--rail-w) 1fr;
    align-items: stretch;
  }
}

/* Left rail */
.rail {
  background: linear-gradient(180deg, var(--graphite-2) 0%, var(--graphite) 100%);
  border-right: 1px solid var(--olive-dim);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  max-height: none;
}
@media (min-width: 960px) {
  .rail {
    max-height: calc(100dvh - 52px);
    overflow-y: auto;
    position: sticky;
    top: 52px;
  }
}

.rail-head {
  border: 1px solid var(--olive-dim);
  background: var(--navy);
  padding: 12px;
}
.rail-head h1 {
  font-size: 1.55rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 4px;
}
.rail-head .hook {
  font-size: 0.88rem;
  color: var(--ink-dim);
  margin: 0;
}
.rail-head .price {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--amber);
}

/* Field panels (not glass cards) */
.field {
  border: 1px solid var(--graphite-3);
  border-left: 3px solid var(--olive);
  background: var(--graphite);
  padding: 10px 12px;
}
.field.amber-edge { border-left-color: var(--amber); }
.field.navy-edge { border-left-color: var(--titanium); background: var(--navy); }
.field-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--olive-bright);
}
.field-title .tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--titanium);
  letter-spacing: 0.04em;
}

/* Form controls */
.ctrl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ctrl-grid .full { grid-column: 1 / -1; }
label.ctrl {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--titanium);
}
label.ctrl input,
label.ctrl select,
label.ctrl textarea {
  background: var(--navy);
  border: 1px solid var(--olive-dim);
  padding: 8px 9px;
  color: var(--ink);
  border-radius: 0;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.92rem;
}
label.ctrl input:focus,
label.ctrl select:focus,
label.ctrl textarea:focus {
  outline: 1px solid var(--amber);
  border-color: var(--amber);
}
label.ctrl input[type="range"] {
  padding: 0;
  accent-color: var(--amber);
  height: 28px;
}
.range-val {
  font-family: var(--font-mono);
  color: var(--amber);
  font-size: 0.85rem;
}

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.seg button {
  flex: 1;
  min-width: 0;
  background: var(--navy);
  border: 1px solid var(--olive-dim);
  color: var(--ink-dim);
  padding: 7px 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.seg button.active {
  background: var(--olive-dim);
  border-color: var(--olive);
  color: var(--ink);
}
.seg button:hover { border-color: var(--amber-dim); color: var(--ink); }

.btn-row { display: flex; flex-wrap: wrap; gap: 6px; }
.btn {
  background: var(--olive-dim);
  border: 1px solid var(--olive);
  color: var(--ink);
  padding: 8px 12px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.btn:hover { background: var(--olive); }
.btn.primary {
  background: var(--amber-dim);
  border-color: var(--amber);
  color: var(--navy);
  font-weight: 600;
}
.btn.primary:hover { background: var(--amber); }
.btn.ghost {
  background: transparent;
  border-color: var(--titanium);
  color: var(--titanium-bright);
}
.btn.danger {
  background: transparent;
  border-color: var(--danger);
  color: #e8a090;
}

/* Result readout */
.readout {
  background: var(--navy);
  border: 1px solid var(--amber-dim);
  padding: 12px;
}
.readout .days-big {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 3.2rem);
  font-weight: 700;
  color: var(--amber);
  line-height: 1;
  letter-spacing: -0.03em;
}
.readout .days-unit {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--titanium);
  margin-left: 6px;
}
.readout .band {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--olive-bright);
}
.readout .sub {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--ink-dim);
}

.assumptions {
  font-size: 0.78rem;
  color: var(--ink-dim);
  max-height: 220px;
  overflow-y: auto;
}
.assumptions ul { padding-left: 1em; margin: 0; }
.assumptions li { margin-bottom: 4px; }
.assumptions code { color: var(--amber); }

/* Preset chips */
.preset-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.preset-list button {
  text-align: left;
  background: var(--graphite-2);
  border: 1px solid var(--graphite-3);
  color: var(--ink);
  padding: 8px 10px;
  font-size: 0.85rem;
}
.preset-list button:hover,
.preset-list button.active {
  border-color: var(--olive);
  background: var(--olive-dim);
}
.preset-list button .p-note {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-dim);
  margin-top: 2px;
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}
.saved-item {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--graphite-3);
  padding: 6px 8px;
  background: var(--graphite-2);
  font-size: 0.82rem;
}
.saved-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-item button {
  background: transparent;
  border: none;
  color: var(--titanium);
  padding: 2px 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
}
.saved-item button:hover { color: var(--amber); }

.empty-hint { font-size: 0.78rem; color: var(--ink-dim); margin: 0; }

/* —— Stage (right) —— */
.stage {
  background:
    radial-gradient(ellipse 60% 40% at 70% 20%, rgba(212,160,23,0.12), transparent 60%),
    linear-gradient(165deg, rgba(12,18,32,0.92) 0%, rgba(26,29,26,0.88) 55%, rgba(20,28,46,0.94) 100%),
    url("assets/backdrop.png") center / cover no-repeat;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.stage-hero {
  position: relative;
  border: 1px solid var(--olive-dim);
  background: var(--graphite-2);
  min-height: 200px;
  overflow: hidden;
}
.stage-hero img,
.stage-hero .hero-ph {
  width: 100%;
  height: clamp(180px, 28vw, 280px);
  object-fit: cover;
  display: block;
}
.stage-hero .hero-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 8px 12px;
  background: linear-gradient(transparent, rgba(12,18,32,0.92));
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--titanium-bright);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stage-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 720px) {
  .stage-split { grid-template-columns: 1.1fr 0.9fr; }
}

.viewport-wrap {
  position: relative;
  border: 1px solid var(--titanium);
  background: #05080f;
  aspect-ratio: 1 / 1;
  max-height: 480px;
  min-height: 280px;
}
#watch-canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.viewport-hud {
  position: absolute;
  left: 8px; right: 8px; top: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--olive-bright);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.viewport-hud .live {
  color: var(--amber);
}
.viewport-actions {
  position: absolute;
  left: 8px; bottom: 8px; right: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: auto;
}
.viewport-actions .btn { padding: 6px 10px; font-size: 0.72rem; }

.side-viz {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.chart-box {
  border: 1px solid var(--olive-dim);
  background: var(--graphite-2);
  padding: 10px;
}
.chart-box h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--olive-bright);
  margin-bottom: 8px;
}
#lux-days-chart, #contrib-chart {
  width: 100%;
  height: auto;
  display: block;
  background: var(--navy);
}

.bars-compare {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  font-size: 0.8rem;
}
.bar-row {
  display: grid;
  grid-template-columns: 72px 1fr 48px;
  gap: 8px;
  align-items: center;
}
.bar-row .label { color: var(--titanium); font-family: var(--font-mono); font-size: 0.7rem; }
.bar-track {
  height: 10px;
  background: var(--navy);
  border: 1px solid var(--graphite-3);
}
.bar-fill {
  height: 100%;
  background: var(--olive);
  width: 0%;
  transition: width 0.35s ease;
}
.bar-fill.rear { background: var(--amber); }
.bar-fill.gps { background: var(--titanium); }
.bar-row .val { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink); text-align: right; }

/* Compare table */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.compare-table th,
.compare-table td {
  border: 1px solid var(--graphite-3);
  padding: 6px 8px;
  text-align: left;
}
.compare-table th {
  background: var(--navy);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--olive-bright);
}
.compare-table td { background: var(--graphite-2); }
.compare-table .hi { color: var(--amber); font-family: var(--font-mono); }

/* Imagery strip */
.img-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
@media (min-width: 720px) {
  .img-strip { grid-template-columns: repeat(4, 1fr); }
}
.share-still-wrap {
  margin: 0;
  border: 1px solid var(--olive-dim);
  background: var(--graphite-2);
  position: relative;
  overflow: hidden;
}
.share-still-wrap img {
  width: 100%;
  height: auto;
  max-height: 280px;
  object-fit: cover;
  display: block;
}
.share-still-wrap figcaption,
.share-still-wrap .slot-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 6px 10px;
  background: rgba(12,18,32,0.88);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--titanium);
}
.img-slot {
  border: 1px solid var(--graphite-3);
  background: var(--graphite-2);
  min-height: 120px;
  position: relative;
  overflow: hidden;
}
.img-slot img { width: 100%; height: 140px; object-fit: cover; }
.img-slot .slot-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 4px 8px;
  background: rgba(12,18,32,0.85);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--titanium);
}

/* Manual / guide */
.manual {
  border: 1px solid var(--olive-dim);
  background: var(--graphite);
  padding: 16px 14px 20px;
}
.manual h2 {
  font-size: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--olive-dim);
  padding-bottom: 8px;
  margin-bottom: 12px;
}
.manual h3 {
  font-size: 0.95rem;
  color: var(--amber);
  margin-top: 1.1em;
}
.manual .cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 720px) {
  .manual .cols { grid-template-columns: 1fr 1fr; }
}
.glossary dt {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--olive-bright);
  margin-top: 8px;
}
.glossary dd {
  margin: 2px 0 0;
  color: var(--ink-dim);
  font-size: 0.88rem;
}

.loc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 520px) {
  .loc-grid { grid-template-columns: 1fr 1fr; }
}
.loc-card {
  border: 1px solid var(--graphite-3);
  border-left: 2px solid var(--titanium);
  padding: 8px 10px;
  background: var(--navy);
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.loc-card:hover { border-left-color: var(--amber); }
.loc-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 0.9rem;
  margin-bottom: 2px;
}
.loc-card .lux {
  font-family: var(--font-mono);
  color: var(--amber);
  font-size: 0.78rem;
}
.loc-card .note { font-size: 0.75rem; color: var(--ink-dim); margin-top: 4px; }

.cite-block {
  font-size: 0.75rem;
  color: var(--ink-dim);
  border-top: 1px solid var(--graphite-3);
  margin-top: 14px;
  padding-top: 10px;
}
.cite-block a { word-break: break-all; }

footer.site-foot {
  margin-top: 8px;
  padding: 16px 14px 28px;
  border-top: 1px solid var(--olive-dim);
  text-align: center;
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: var(--titanium);
}
footer.site-foot a { color: var(--ink); text-decoration: none; }
footer.site-foot a:hover { color: var(--amber); }
footer.site-foot .extra {
  display: block;
  margin-top: 6px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-dim);
}

/* Toast (non-overlay on 3D — fixed bottom rail, not over canvas center) */
.toast {
  position: fixed;
  bottom: 12px;
  left: 12px;
  right: 12px;
  max-width: 420px;
  z-index: 50;
  background: var(--navy);
  border: 1px solid var(--olive);
  padding: 10px 12px;
  font-size: 0.82rem;
  color: var(--ink);
  transform: translateY(120%);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  border: 0;
}

@media (max-width: 389px) {
  .ctrl-grid { grid-template-columns: 1fr; }
  .bar-meta { width: 100%; margin-left: 0; }
}
