/* ──────────────────────────────────────────────────────────
   Hero Lab — throwaway scratch page for the homepage redesign.
   Dark theme (the new site will be dark). Low-fidelity.
   ────────────────────────────────────────────────────────── */

:root {
  --bg: #100f0c;
  --panel: #1b1a15;
  --panel-2: #232118;
  --ink: #f1ede5;
  --muted: #9a9484;
  --muted-light: #6f695b;
  --green: #7bb37d;
  --green-dim: rgba(123, 179, 125, 0.14);
  --border: rgba(255, 255, 255, 0.10);
  --card-line: rgba(236, 230, 216, 0.55); /* timeline card outline stroke */
  --tile-bg: #2a2820;
  --blue: #4f9ae0;     /* brightened --sky (#2b5a8f) for dark-bg contrast */
  --line-light: #ece6d8;
  --detect: #d46b2a;   /* kestrel --orange */
  --gold: #f5c518;
  --font-ui: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
}

.lab-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.lab-bar strong { font-size: 0.95rem; }
.lab-note { color: var(--muted); font-size: 0.82rem; }
.lab-clock { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.82rem; }

.lab-main {
  display: grid;
  grid-template-columns: 1fr 230px;
  gap: 18px;
  padding: 18px;
  align-items: start;
}

.lab-stage-wrap { min-width: 0; }

.lab-stage {
  position: relative;
  width: 100%;
  height: 72vh;
  min-height: 500px;
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

/* zoom layer — tiles + SVG scale together (origin top-left); the header/star
   layer is OUTSIDE this so header text keeps a fixed size during the zoom */
.lab-zoomwrap {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  z-index: 1;
}

/* SVG scene-link layer sits BEHIND the tiles (threads through the gaps) */
.lab-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}

/* search bar (interactive end-state) — floats at the top of the stage */
.lab-search {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 110; display: flex; align-items: center; gap: 7px; /* above the scene panel (z100) */
  background: rgba(18, 17, 13, 0.86); border: 1px solid var(--card-line);
  border-radius: 999px; padding: 5px 13px; opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease; backdrop-filter: blur(4px);
}
.lab-stage.interactive .lab-search { opacity: 1; pointer-events: auto; }
.lab-search-icon { color: var(--muted); font-size: 0.95rem; line-height: 1; }
.lab-search input {
  background: none; border: 0; outline: 0; color: var(--ink);
  font: inherit; font-size: 0.82rem; width: 160px;
}
.lab-search input::placeholder { color: var(--muted-light); }

/* scrollbar for the (overflowing) timeline in the interactive end-state */
.lab-scrollbar {
  position: absolute; top: 6px; right: 4px; bottom: 6px; width: 8px;
  z-index: 90; opacity: 0; transition: opacity 0.25s ease; pointer-events: auto;
}
.lab-scrollthumb {
  position: absolute; left: 0; right: 0; border-radius: 4px;
  background: rgba(236, 230, 216, 0.28); cursor: grab;
}
.lab-scrollthumb:hover { background: rgba(236, 230, 216, 0.5); }
.lab-scrollthumb:active { cursor: grabbing; background: rgba(236, 230, 216, 0.6); }

/* in the interactive end-state, scene cards and filmstrip frames are clickable */
.lab-stage.interactive .tile { cursor: pointer; }
.lab-stage.interactive .tile:hover { outline: 2px solid var(--green); outline-offset: 1px; }

/* a photo tile in the capture-order grid (3:2, sized by JS) */
.tile {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 4px;
  overflow: hidden;
  background: var(--tile-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  z-index: 2;
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* tile matches 3:2 image aspect → no crop */
  display: block;
}

/* detection box — real normalized bbox, pops in as the head sweeps past */
.tile .bbox {
  position: absolute;
  border: 1.5px solid var(--detect);
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: scale(0.85);
  transform-origin: center;
  pointer-events: none;
}

/* star-rating strip beneath each photo (spawns during the sweep) */
.lab-meta { position: absolute; inset: 0; z-index: 50; pointer-events: none; }
.stars {
  position: absolute;
  top: 0; left: 0;
  text-align: center;
  line-height: 1;
  letter-spacing: 1px;
  white-space: nowrap;
}
.stars .star { color: rgba(255, 255, 255, 0.16); }
.stars .star.on { color: var(--gold); }

/* scene header elements (Scene N · species · shot count) — each is
   positioned individually so trailing parts can flow to the next row */
.hdr-part {
  position: absolute;
  top: 0; left: 0;
  white-space: nowrap;
  font-size: 11px;
  line-height: 1;
  transform-origin: 0 0; /* gentle zoom scales the text from its anchor */
}
.hdr-part.sh-name {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--ink);
}
.hdr-part.sh-name .sh-pre {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: top;
}
.hdr-part.sh-sp {
  color: #a9cef2;
  background: rgba(79, 154, 224, 0.16);
  border: 1px solid rgba(79, 154, 224, 0.45);
  border-radius: 999px;
  padding: 0.2em 0.7em;
  font-size: 10px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}
.hdr-part.sh-ct { color: var(--muted); font-size: 10px; }

/* timeline cluster label (time · scene count) */
.cluster-label {
  position: absolute;
  top: 0; left: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
  transform-origin: 0 0;
}
.cluster-label .cl-time { font-family: var(--font-serif); font-weight: 600; font-size: 13px; color: var(--green); }
.cluster-label .cl-count { font-size: 10px; color: var(--muted); }

/* date banner — marks where a multi-day outing crosses to a new day */
.day-label {
  position: absolute;
  top: 0; left: 0;
  white-space: nowrap;
  transform-origin: 0 0;
  pointer-events: none;
}
.day-label .dl-date { font-family: var(--font-serif); font-weight: 400; font-size: 20px; color: var(--ink); line-height: 1.1; display: block; }
.day-label .dl-bar { display: block; height: 2px; width: 58px; margin-top: 5px; border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), transparent); }

/* ── transport ── */
.lab-transport {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.lab-transport button {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.lab-transport button:hover { background: var(--green-dim); border-color: var(--green); color: var(--green); }
.lab-transport input[type=range] { flex: 1; accent-color: var(--green); }
.lab-loop { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

.lab-status {
  margin-top: 8px;
  min-height: 1.3em;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}
.lab-status strong { color: var(--ink); }

/* ── controls ── */
.lab-controls {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  position: sticky;
  top: 18px;
}
.lab-controls h2 { margin: 0 0 10px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.lab-controls label { display: block; font-size: 0.78rem; color: var(--ink); margin-bottom: 14px; }
.lab-controls output { font-weight: 700; color: var(--green); }
.lab-controls input[type=range] { width: 100%; margin-top: 4px; accent-color: var(--green); }
.lab-controls hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0 12px; }

.lab-legend { display: flex; flex-direction: column; gap: 7px; font-size: 0.74rem; color: var(--muted); }
.lab-legend span { display: flex; align-items: center; gap: 8px; }
.sw { width: 16px; height: 0; border-top: 3px solid; border-radius: 2px; display: inline-block; }
.sw-box { width: 12px; height: 12px; border: 1.5px solid var(--detect); border-radius: 2px; }
.sw-star { border: 0; color: var(--gold); width: 12px; text-align: center; font-size: 12px; }
.sw-container { width: 14px; height: 11px; border: 1.5px solid rgba(236, 230, 216, 0.6); border-radius: 3px; background: rgba(123, 179, 125, 0.08); }

.lab-hint { font-size: 0.72rem; color: var(--muted-light); margin: 10px 0 0; }

/* ── finale: expanded scene viewer — opens in the timeline under the
   selected scene's row (the card "extends down" into this panel) ── */
.lab-finale {
  position: absolute;            /* left/top/width/height set per-frame by JS */
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px 12px;
  background: var(--panel-2);
  border: 1px solid var(--card-line); /* same light grey as the timeline card outlines */
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
}
/* little arrow that ties the panel back up to the selected card (its border morphs into the panel) */
.fin-notch {
  position: absolute; width: 12px; height: 12px; z-index: 101;
  background: var(--panel-2);
  border-top: 1px solid var(--card-line); border-left: 1px solid var(--card-line);
  transform: translateX(-50%) rotate(45deg);
  opacity: 0; pointer-events: none;
}

.fin-hdr { display: flex; align-items: baseline; gap: 8px; flex: 0 0 auto; flex-wrap: nowrap; overflow: hidden; font-size: var(--fin-hdr, 12.5px); }
.fin-scene { font-family: var(--font-serif); font-weight: 600; font-size: 1.1em; color: var(--ink); white-space: nowrap; }
.fin-species {
  color: #a9cef2; background: rgba(79, 154, 224, 0.16);
  border: 1px solid rgba(79, 154, 224, 0.45); border-radius: 999px;
  padding: 0.1em 0.6em; font-size: 0.84em; font-weight: 500; white-space: nowrap;
}
.fin-time { color: var(--green); font-family: var(--font-serif); font-size: 0.86em; white-space: nowrap; }
.fin-stars { letter-spacing: 1px; font-size: 0.95em; white-space: nowrap; }
.fin-stars .star { color: rgba(255, 255, 255, 0.16); }
.fin-stars .star.on { color: var(--gold); }
.fin-q { font-size: 0.84em; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-note { margin-left: auto; font-size: 0.82em; color: var(--muted-light); flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-note strong { color: var(--ink); }

/* export(3:2) + crop(1:1) row ≈ 2.5:1; height is set in JS so it's never cut */
.fin-top { flex: 0 0 auto; display: flex; gap: 10px; min-height: 0; justify-content: flex-start; }
.fin-main { position: relative; height: 100%; aspect-ratio: 3 / 2; border-radius: 8px; overflow: hidden; background: var(--tile-bg); flex: 0 0 auto; }
.fin-main img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fin-bbox { position: absolute; border: 2px solid var(--detect); border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); }
.fin-crop { position: relative; height: 100%; aspect-ratio: 1 / 1; border-radius: 8px; overflow: hidden; background-color: var(--tile-bg); background-repeat: no-repeat; border: 1px solid var(--border); flex: 0 0 auto; }
.fin-crop-label { position: absolute; top: 6px; left: 6px; font-size: 0.66rem; font-weight: 700; color: #fff; background: var(--detect); padding: 1px 6px; border-radius: 3px; }

.fin-filmstrip { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }
.fin-fs-label { font-size: 0.7rem; white-space: nowrap; font-weight: 600; }
.fin-fs-label.sharp { color: var(--green); }
.fin-fs-label.blur { color: var(--detect); }
.fin-fs-thumbs { display: flex; gap: 5px; flex: 1 1 auto; min-width: 0; }
/* thumbs flex to show the whole scene: shrink when many, capped when few */
.fin-thumb {
  position: relative; height: 46px; border-radius: 5px; overflow: hidden;
  cursor: pointer; opacity: 0.55; border: 2px solid transparent;
  flex: 1 1 0; min-width: 0; max-width: 78px;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}
.fin-thumb:hover { opacity: 0.85; }
.fin-thumb.current { opacity: 1; border-color: var(--gold); }
.fin-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fin-thumb-q { position: absolute; right: 3px; bottom: 3px; width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.9); }

/* narrow widths: stack controls below so the stage can be tested at mobile size */
@media (max-width: 720px) {
  .lab-main { grid-template-columns: 1fr; }
  .lab-controls { position: static; }
}
