/* Chrome for the /demo viewers. Layers on landing.css — tokens come from there. */

.demo-shell {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--panel);
  margin-top: 28px;
}

.demo-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: min(72vh, 720px);
  min-height: 560px;
}

/* min-height:0 on both tracks: grid items default to min-height:auto, which lets the
   side panel's content override the row height instead of scrolling inside it. */
.demo-canvas {
  position: relative;
  background: #000;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* Absolute, not height:100% — a percentage height on a canvas inside an auto-sized grid
   item feeds back into the track size and the canvas grows without bound. */
.demo-canvas > canvas,
.demo-canvas > .demo-map {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.demo-side {
  background: var(--panel-2);
  border-left: 1px solid var(--line);
  padding: 18px;
  overflow-y: auto;
  min-height: 0;
  font-size: 13px;
}

.demo-side h3 {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--brand-orange);
  margin: 0 0 10px;
  font-weight: 400;
}

.demo-side section {
  padding: 0 0 18px;
  border: none;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.demo-side section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.demo-side p { font-size: 12.5px; margin: 0 0 8px; line-height: 1.55; }

/* ---------- controls ---------- */

.demo-row { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }

.demo-btn {
  background: rgba(246, 246, 242, .05);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-family: var(--ui);
  font-size: 12.5px;
  font-weight: 500;
  transition: .15s ease;
}

.demo-btn:hover { border-color: var(--line-strong); background: rgba(246, 246, 242, .1); }

.demo-btn.on {
  background: var(--brand-orange);
  border-color: var(--brand-orange);
  color: #12060a;
  font-weight: 600;
}

.demo-btn[disabled] { opacity: .4; cursor: default; }

.demo-btn.wide { width: 100%; justify-content: center; text-align: center; }

input[type=range].demo-range {
  width: 100%;
  accent-color: var(--brand-orange);
  margin: 6px 0 2px;
}

/* ---------- readouts ---------- */

.demo-metric {
  font-family: var(--headline);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.demo-metric span { font-size: 14px; color: var(--dim); font-weight: 400; }

.demo-code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.7;
  word-break: break-word;
  display: block;
}

.demo-note { font-size: 11.5px; color: var(--dim); line-height: 1.5; }
.demo-warn { color: #ffb27a; }

.demo-hud {
  position: absolute;
  left: 14px;
  bottom: 14px;
  background: rgba(2, 3, 3, .84);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.demo-badge {
  position: absolute;
  right: 14px;
  top: 14px;
  background: rgba(2, 3, 3, .84);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 5px 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
  pointer-events: none;
  backdrop-filter: blur(8px);
}

/* ---------- loading / error ---------- */

.demo-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(2, 3, 3, .9);
  text-align: center;
  padding: 32px;
  z-index: 5;
}

.demo-overlay[hidden] { display: none; }
.demo-overlay p { max-width: 46ch; margin: 8px auto 0; font-size: 13px; }

.demo-bar {
  width: 220px;
  height: 3px;
  background: rgba(246, 246, 242, .12);
  border-radius: 99px;
  margin: 14px auto 0;
  overflow: hidden;
}

.demo-bar i { display: block; height: 100%; width: 0; background: var(--brand-orange); transition: width .2s ease; }

/* ---------- caption strip under the viewer ---------- */

.demo-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.demo-facts div {
  flex: 1 1 160px;
  padding: 14px 18px;
  border-right: 1px solid var(--line);
}

.demo-facts div:last-child { border-right: none; }

.demo-facts b {
  display: block;
  font-family: var(--headline);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.demo-facts span {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
}

/* ---------- legend ---------- */

.demo-legend { display: grid; gap: 5px; margin-top: 4px; }

.demo-legend label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

.demo-legend i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: 0 0 auto;
}

.demo-legend b { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--dim); font-weight: 400; }
.demo-legend input { accent-color: var(--brand-orange); }

/* ---------- annotated video clips ---------- */

.demo-clips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.demo-clips figure {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

/* No fixed aspect: the road clips are 16:9 but the sign clip is a 2.37:1 ultrawide,
   and cropping it to 16:9 cuts off the signs at the edges of the frame. */
.demo-clips video {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
}

.demo-clips figcaption {
  padding: 16px 18px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  border-top: 1px solid var(--line);
}

.demo-clips figcaption b {
  display: block;
  font-family: var(--headline);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 5px;
}

/* ---------- class frequency rows ---------- */

.sign-rows { margin-top: 6px; }

.sign-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px 46px;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 12.5px;
  color: var(--muted);
  border-bottom: 1px solid rgba(246, 246, 242, .06);
}

.sign-row:last-child { border-bottom: none; }
.sign-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sign-row i {
  display: block;
  height: 4px;
  border-radius: 99px;
  background: var(--brand-orange);
  opacity: .75;
  min-width: 2px;
}

.sign-row b {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--dim);
  text-align: right;
}

/* ---------- demo hub cards ---------- */

.demo-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-top: 28px; }

.demo-cards a {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  text-decoration: none;
  color: inherit;
  transition: .18s ease;
}

.demo-cards a:hover { border-color: var(--line-strong); background: var(--panel-2); }
.demo-cards h3 { margin-bottom: 8px; }
.demo-cards p { font-size: 13.5px; margin: 0; }
.demo-cards .spec { font-family: var(--mono); font-size: 10.5px; color: var(--brand-orange); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 12px; }

/* ---------- leaflet dark fit ---------- */

.leaflet-container { background: #05070a !important; font-family: var(--ui) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 8px 32px rgba(0,0,0,.6); }
.leaflet-popup-content { margin: 12px 14px; font-size: 12.5px; }
.leaflet-popup-content b { font-family: var(--headline); }
.leaflet-popup-content code { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.leaflet-control-attribution { background: rgba(2,3,3,.7) !important; color: var(--dim) !important; font-size: 10px !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar a { background: var(--panel-2) !important; color: var(--ink) !important; border-color: var(--line) !important; }
.leaflet-bar a:hover { background: var(--panel) !important; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .demo-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: 58vh auto; min-height: 0; }
  .demo-canvas { min-height: 340px; }
  .demo-side { border-left: none; border-top: 1px solid var(--line); max-height: none; }
  .demo-facts div { flex-basis: 50%; }
}
