/* =========================================================================
   DRIVER TRACE DEMO (#driverTraceDemo).
   See src/components/DriverTraceDemo.astro for the storyboard.
   Timeline: public/js/driver-trace-demo.js toggles `is-*` classes and
   positions `.dtd__cursor` at runtime.

   A single steady scene, no crossfade — a ranked driver list, then a
   click traces the top driver down to its source records. Same --xxx-*
   palette likeness rules as every other demo on the site.
   ========================================================================= */

.dtd {
  --dtd-canvas: #FAF9F5;
  --dtd-card: #FFFFFF;
  --dtd-border: #DBDBDE;
  --dtd-line: #EAEAEA;
  --dtd-head: #F6F6F7;
  --dtd-ink: #2B2B2B;
  --dtd-ink2: #777777;
  --dtd-accent: #6A5BC6;
  --dtd-accent-soft: #ECECFF;
}

.dtd__stage {
  position: relative; overflow: hidden; width: 100%;
  aspect-ratio: 3 / 2; min-height: 380px; max-width: 640px; margin: 0 auto;
  background: var(--dtd-canvas);
  display: flex; flex-direction: column;
  transition: opacity .5s ease;
}
.dtd.is-out .dtd__stage { opacity: 0; }

.dtd__topBar {
  flex: none; font-size: 11px; font-weight: 600; color: var(--dtd-ink);
  padding: 12px 14px 9px; border-bottom: 1px solid var(--dtd-line);
  white-space: nowrap;
}
.dtd__pane { flex: 1; min-height: 0; min-width: 0; padding: 18px 20px; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.dtdQuestion { margin: 0; font-size: 12px; font-weight: 600; color: var(--dtd-ink); }

.dtdList {
  background: var(--dtd-card); border: 1px solid var(--dtd-border); border-radius: 8px; overflow: hidden;
}
.dtdRow {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; font-size: 10.5px; color: var(--dtd-ink2);
  border-bottom: 1px solid var(--dtd-line);
  transition: background .3s ease;
}
.dtdList .dtdRow:last-child { border-bottom: none; }
.dtdRow__rank {
  flex: none; width: 16px; height: 16px; border-radius: 50%; background: var(--dtd-head);
  display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: var(--dtd-ink2);
}
.dtdRow--top .dtdRow__rank { background: var(--dtd-accent-soft); color: var(--dtd-accent); }
.dtdRow__label { flex: 1; font-weight: 600; color: var(--dtd-ink); }
.dtdRow__val { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--dtd-ink); }
.dtd.is-flash .dtdRow--top { background: var(--dtd-accent-soft); }

.dtdTrace {
  max-height: 0; overflow: hidden; transition: max-height .4s ease;
  background: var(--dtd-card); border: 0 solid var(--dtd-border); border-radius: 8px;
}
.dtd.is-expanded .dtdTrace { max-height: 140px; border-width: 1px; }
.dtdTrace__label { margin: 0; padding: 8px 12px 4px; font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--dtd-ink2); }
.dtdTrace__row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 12px; font-size: 9.5px; color: var(--dtd-ink); border-top: 1px solid var(--dtd-line);
  font-variant-numeric: tabular-nums;
}

.dtd__cursor {
  position: absolute; top: 0; left: 0; opacity: 0; pointer-events: none; z-index: 9;
  transition: left .6s cubic-bezier(.5, .05, .3, 1), top .6s cubic-bezier(.5, .05, .3, 1), opacity .3s ease;
}
.dtd.is-cursor-visible .dtd__cursor { opacity: 1; }

@media (max-width: 460px) {
  .dtd__stage { aspect-ratio: auto; min-height: 420px; }
}
