/* ══════════════════════════════════════════════════════════════════════════
   Homepage hero — living room backdrop, holographic globe and panels.

   Everything is scoped under .home-hero (Dash loads this file on every page).
   Colors come from the --hero-* tokens emitted by theme.py; the hero keeps
   one cinematic palette whatever skin is active.

   Desktop (≥1200px): a 16:9 "stage" carries the photo, and panels sit at
   fixed percentages of it so they stay anchored to the same spots on the
   couch and wall. Narrower screens re-flow into a grid instead of shrinking.
   ══════════════════════════════════════════════════════════════════════════ */

.home-hero {
  --hero-top-offset: 2.6rem;               /* sticky navbar height */
  --hero-ticker-h: 2.4rem;                 /* facts strip under the stage */
  --hero-room: url("/assets/hero/living-room-1672.webp");
  position: relative;
  overflow: hidden;
  margin-top: -0.5rem;                     /* sit flush under the navbar */
  background-color: rgb(var(--hero-shade-rgb));
  color: var(--hero-text);
}

@media (max-width: 1280px) {
  .home-hero { --hero-room: url("/assets/hero/living-room-1280.webp"); }
}

@media (max-width: 768px) {
  .home-hero { --hero-room: url("/assets/hero/living-room-768.webp"); }
}

/* Blurred, darkened copy of the room filling any space beside the stage on
   screens wider than 16:9. */
.hero-backdrop {
  position: absolute;
  inset: -40px;
  background: var(--hero-room) center / cover no-repeat;
  filter: blur(28px) brightness(0.22) saturate(0.7);
}

/* ── Stage ──────────────────────────────────────────────────────────────── */

.hero-stage {
  position: relative;
  margin: 0 auto;
  /* Leave room for the ticker so room, globe and ticker fit one screen. */
  width: min(
    100%,
    calc((100svh - var(--hero-top-offset) - var(--hero-ticker-h)) * 16 / 9)
  );
  aspect-ratio: 16 / 9;
  container-type: inline-size;
  background: var(--hero-room) center / cover no-repeat;
}

/* Cinematic grade: darker edges and floor, a cool pool of light from the
   globe. Purely decorative; sits under the panels. */
.hero-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 34% 46% at 50% 47%,
      rgba(var(--hero-holo-rgb), 0.22), transparent 70%),
    radial-gradient(ellipse 80% 75% at 50% 40%,
      transparent 45%, rgba(var(--hero-shade-rgb), 0.6) 100%),
    linear-gradient(to bottom,
      rgba(var(--hero-shade-rgb), 0.15) 0%,
      rgba(var(--hero-shade-rgb), 0.05) 45%,
      rgba(var(--hero-shade-rgb), 0.55) 100%);
}

/* ── Holographic panels ─────────────────────────────────────────────────── */

.hero-panel {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 1.1cqw;
  padding: 1cqw 1.4cqw;
  background: var(--hero-panel-bg);
  border: 1px solid rgba(var(--hero-holo-rgb), 0.55);
  border-radius: 0.7cqw;
  box-shadow:
    0 0 1.4cqw rgba(var(--hero-holo-rgb), 0.28),
    inset 0 0 1.6cqw rgba(var(--hero-holo-rgb), 0.1);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--hero-text);
}

/* Stat panels link to the page behind their number. */
a.hero-panel {
  text-decoration: none;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

a.hero-panel:not(.hero-title-panel):hover,
a.hero-panel:not(.hero-title-panel):focus-visible {
  color: var(--hero-text);
  border-color: var(--hero-cyan);
  box-shadow:
    0 0 2.4cqw rgba(var(--hero-holo-rgb), 0.55),
    inset 0 0 1.8cqw rgba(var(--hero-holo-rgb), 0.18);
}

a.hero-panel:focus-visible {
  outline: 2px solid var(--hero-cyan);
  outline-offset: 2px;
}

/* Minimum widths match the reference; panels grow rather than wrap. */
.hero-panel--places   { left: 16%;   top: 33.5%; min-width: 14.5%; }
.hero-panel--days     { left: 15%;   top: 52%;   min-width: 14.5%; }
.hero-panel--distance { left: 68%;   top: 33%;   min-width: 15.5%; }
.hero-panel--modes    { left: 68.5%; top: 52%;   min-width: 16.5%; }

.hero-stat-label,
.hero-stat-value { white-space: nowrap; }

.hero-icon,
.hero-mode-icon,
.hero-title-icon,
.hero-toggle-icon,
.hero-replay-icon {
  flex: none;
  display: inline-block;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.hero-icon {
  width: max(2.6cqw, 30px);
  height: max(2.6cqw, 30px);
  color: var(--hero-holo);
  filter: drop-shadow(0 0 0.4cqw rgba(var(--hero-holo-rgb), 0.7));
}

.hero-stat-label {
  font-size: max(0.72cqw, 10px);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hero-text-dim);
}

.hero-stat-value {
  font-size: max(1.95cqw, 22px);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: 0.01em;
  text-shadow: 0 0 1cqw rgba(var(--hero-holo-rgb), 0.45);
  font-variant-numeric: tabular-nums;
}

.hero-stat-unit {
  margin-left: 0.35em;
  font-size: 0.45em;
  font-weight: 400;
  color: var(--hero-text-dim);
}

/* Modes of travel: donut + one icon/count per mode */
.hero-donut {
  flex: none;
  width: max(3.3cqw, 40px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--donut);
  -webkit-mask: radial-gradient(circle, transparent 52%, black 54%);
  mask: radial-gradient(circle, transparent 52%, black 54%);
  filter: drop-shadow(0 0 0.5cqw rgba(var(--hero-holo-rgb), 0.5));
}

.hero-modes-body { min-width: 0; }

.hero-mode-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25cqw 0.7cqw;
  margin: 0.35cqw 0 0;
  padding: 0;
  list-style: none;
}

.hero-mode-list li {
  display: flex;
  align-items: center;
  gap: 0.2cqw;
  color: var(--mode-color);
}

.hero-mode-icon {
  width: max(1.35cqw, 16px);
  height: max(1.35cqw, 16px);
}

.hero-mode-count {
  font-size: max(0.75cqw, 11px);
  color: var(--hero-text);
  font-variant-numeric: tabular-nums;
}

/* ── Title panel ────────────────────────────────────────────────────────── */

.hero-title-panel {
  left: 25%;
  top: 79.5%;
  width: 50%;
  flex-direction: column;
  justify-content: center;
  gap: 0.6cqw;
  padding: 1.3cqw 2cqw;
  border-radius: 1.2cqw;
  border-color: rgba(var(--hero-holo-rgb), 0.75);
  box-shadow:
    0 0 2.2cqw rgba(var(--hero-holo-rgb), 0.4),
    inset 0 0 2.4cqw rgba(var(--hero-holo-rgb), 0.16);
  transform: perspective(60cqw) rotateX(24deg);
  text-decoration: none;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.hero-title-panel:hover,
.hero-title-panel:focus-visible {
  color: var(--hero-text);
  border-color: var(--hero-cyan);
  box-shadow:
    0 0 3cqw rgba(var(--hero-holo-rgb), 0.6),
    inset 0 0 2.6cqw rgba(var(--hero-holo-rgb), 0.22);
}

.hero-title-row {
  display: flex;
  align-items: center;
  gap: 1.2cqw;
}

.hero-title-icon {
  width: max(2.8cqw, 30px);
  height: max(2.8cqw, 30px);
  color: var(--hero-holo);
  filter: drop-shadow(0 0 0.6cqw rgba(var(--hero-holo-rgb), 0.8));
}

.hero-title-panel h1 {
  margin: 0;
  font-size: max(2.2cqw, 24px);
  font-weight: 400;
  letter-spacing: 0.28em;
  color: var(--hero-text);
  text-shadow: 0 0 1.2cqw rgba(var(--hero-holo-rgb), 0.7);
}

.hero-subtitle {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.2em 1.1em;
  font-size: max(0.92cqw, 11px);
  letter-spacing: 0.32em;
  color: var(--hero-text-dim);
}

.hero-subtitle-dot { color: var(--hero-holo); }

/* ── Replay button (opens the Journey page already playing) ─────────────── */

.hero-replay {
  position: absolute;
  z-index: 2;
  /* Centered with auto margins: the intro animates `translate`. */
  inset-inline: 0;
  top: 92.6%;
  width: fit-content;
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.45em 1.3em;
  font-size: max(0.82cqw, 12px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  text-decoration: none;
  color: var(--hero-text);
  background: var(--hero-panel-bg);
  border: 1px solid rgba(var(--hero-holo-rgb), 0.6);
  border-radius: 999px;
  box-shadow: 0 0 1cqw rgba(var(--hero-holo-rgb), 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.hero-replay:hover,
.hero-replay:focus-visible {
  color: var(--hero-text);
  border-color: var(--hero-cyan);
  box-shadow: 0 0 1.8cqw rgba(var(--hero-holo-rgb), 0.55);
}

.hero-replay:focus-visible {
  outline: 2px solid var(--hero-cyan);
  outline-offset: 2px;
}

.hero-replay-icon {
  width: 1em;
  height: 1em;
  color: var(--hero-cyan);
}

/* ── Globe ──────────────────────────────────────────────────────────────── */

/* Square box sized so the Earth (about two thirds of the canvas at the
   initial camera distance) spans half the stage height. */
.hero-globe {
  position: absolute;
  z-index: 1;
  left: 28.6%;
  top: 9%;
  width: 42.75%;
  aspect-ratio: 1;
}

.hero-globe-canvas,
.hero-globe-fallback {
  position: absolute;
  inset: 0;
}

.hero-globe-canvas {
  z-index: 1;
  opacity: 0;
  transition: opacity 1.2s ease;
}

/* The canvas appears once Globe.gl is built AND the intro reaches the globe. */
.home-hero.is-globe-ready.is-globe-visible .hero-globe-canvas { opacity: 1; }

/* Plotly globe, only revealed when WebGL or Globe.gl is unavailable. */
.hero-globe-fallback {
  z-index: 1;
  inset: 17%;
  visibility: hidden;
}

.home-hero.is-globe-fallback .hero-globe-fallback { visibility: visible; }
.home-hero.is-globe-fallback .hero-globe-canvas { display: none; }

.hero-globe-halo {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(var(--hero-holo-rgb), 0.35) 0%,
    rgba(var(--hero-holo-rgb), 0.12) 45%,
    transparent 70%);
  pointer-events: none;
}

/* Projector base: concentric light rings on the cushions below the globe. */
.hero-projector {
  position: absolute;
  left: 3%;
  width: 94%;
  top: 84%;
  height: 12%;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center,
      rgba(var(--hero-holo-rgb), 0.55) 0%,
      rgba(var(--hero-holo-rgb), 0.18) 30%,
      transparent 70%),
    repeating-radial-gradient(ellipse at center,
      transparent 0 9%,
      rgba(var(--hero-holo-rgb), 0.35) 9.6% 10.4%,
      transparent 11% 17%);
  -webkit-mask: radial-gradient(ellipse at center, black 40%, transparent 72%);
  mask: radial-gradient(ellipse at center, black 40%, transparent 72%);
}

/* Globe.gl hover label */
.hero-globe-tooltip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid rgba(var(--hero-holo-rgb), 0.6);
  border-radius: 8px;
  background: var(--hero-panel-bg);
  backdrop-filter: blur(6px);
  font-family: Inter, sans-serif;
  font-size: 12px;
  color: var(--hero-text-dim);
}

.hero-globe-tooltip strong { font-size: 13px; color: var(--hero-text); }
.hero-globe-tooltip em { font-style: normal; color: var(--hero-cyan); }

/* ── Tablet and laptop: re-flow into a grid ─────────────────────────────── */

@media (max-width: 1199.98px) {
  .hero-stage {
    width: 100%;
    aspect-ratio: auto;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas:
      "globe globe globe globe"
      "title title title title"
      "replay replay replay replay"
      "places days distance modes";
    gap: 14px;
    padding: 12px 24px 28px;
    background-position: center 55%;
  }

  .hero-panel,
  .hero-globe {
    position: relative;
    left: auto;
    top: auto;
    width: auto;
    min-width: 0;
  }

  .hero-panel { padding: 12px 14px; border-radius: 10px; gap: 12px; }
  .hero-panel--places   { grid-area: places; }
  .hero-panel--days     { grid-area: days; }
  .hero-panel--distance { grid-area: distance; }
  .hero-panel--modes    { grid-area: modes; }

  .hero-globe {
    grid-area: globe;
    justify-self: center;
    width: min(88vw, 62svh);
  }

  .hero-title-panel {
    grid-area: title;
    justify-self: center;
    width: min(100%, 620px);
    margin-top: -8%;
    padding: 14px 20px;
    border-radius: 14px;
    transform: none;
  }

  .hero-replay {
    position: relative;
    inset-inline: auto;
    top: auto;
    grid-area: replay;
    justify-self: center;
  }
}

/* ── Phones: two-column stats under the globe ───────────────────────────── */

@media (max-width: 767.98px) {
  .hero-stage {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "globe globe"
      "title title"
      "replay replay"
      "places days"
      "distance modes";
    gap: 10px;
    padding: 8px 12px 20px;
  }

  .hero-panel { flex-direction: column; align-items: flex-start; gap: 6px; }
  .hero-title-panel { align-items: center; }
  /* The globe takes whatever height the navbar, title, replay button, stat
     panels and ticker leave (about 500px), so the ticker stays on the
     first screen; very short phones keep a usable minimum instead. */
  .hero-globe { width: min(96vw, max(240px, 100svh - 500px)); }
  .hero-title-panel h1 { letter-spacing: 0.2em; }
  .hero-subtitle { letter-spacing: 0.18em; }
}


/* ── Facts ticker along the bottom of the hero ──────────────────────────── */

.hero-ticker {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  height: var(--hero-ticker-h);
  overflow: hidden;
  white-space: nowrap;
  background: rgba(var(--hero-shade-rgb), 0.78);
  border-top: 1px solid rgba(var(--hero-holo-rgb), 0.45);
  box-shadow: 0 -6px 18px rgba(var(--hero-holo-rgb), 0.12);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* .home-hero prefix outranks the shared ticker rules in style.css. */
.home-hero .hero-ticker .scrolling-ticker-inner { color: var(--hero-text-dim); }
.home-hero .hero-ticker .ticker-highlight { color: var(--hero-cyan); }

/* Hold still while being read, or when motion is paused. */
.hero-ticker:hover .scrolling-ticker-inner,
.home-hero.is-motion-paused .hero-ticker .scrolling-ticker-inner {
  animation-play-state: paused;
}

/* ── Globe motion toggle ────────────────────────────────────────────────── */

.hero-motion-toggle {
  position: absolute;
  z-index: 3;
  right: 13%;
  bottom: 17%;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(var(--hero-holo-rgb), 0.5);
  border-radius: 50%;
  background: var(--hero-panel-bg);
  color: var(--hero-text-dim);
  opacity: 0.55;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.hero-motion-toggle:hover,
.hero-motion-toggle:focus-visible {
  opacity: 1;
  color: var(--hero-text);
}

.hero-motion-toggle:focus-visible {
  outline: 2px solid var(--hero-cyan);
  outline-offset: 2px;
}

.hero-toggle-icon { width: 14px; height: 14px; }
.hero-toggle-play { display: none; }
.home-hero.is-motion-paused .hero-toggle-pause { display: none; }
.home-hero.is-motion-paused .hero-toggle-play { display: inline-block; }

/* ── Intro sequence (PLAN.txt §5) ───────────────────────────────────────────
   Until home-globe.js decides whether to play the intro, the hero holds
   still and dark so nothing flashes. The globe fades in when the script adds
   .is-globe-visible (2 s into the intro, or immediately when skipped). */

.home-hero.is-intro-pending .hero-stage,
.home-hero.is-intro-pending .hero-backdrop,
.home-hero.is-intro-pending .hero-ticker { visibility: hidden; }

.hero-globe {
  opacity: 0;
  transition: opacity 1.4s ease;
}

.home-hero.is-globe-visible .hero-globe { opacity: 1; }

/* 0–2 s: the room comes up out of darkness */
.home-hero.is-intro .hero-stage::after,
.home-hero.is-intro .hero-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: rgb(var(--hero-shade-rgb));
  animation: hero-fade-out 2s ease-out both;
}

/* ~5 s: title; 6–6.5 s: the four panels, one after another */
.home-hero.is-intro .hero-panel {
  animation: hero-panel-in 0.9s ease-out both;
}

.home-hero.is-intro .hero-title-panel     { animation-delay: 5.2s; }
.home-hero.is-intro .hero-replay          { animation: hero-panel-in 0.9s ease-out 5.6s both; }
.home-hero.is-intro .hero-panel--places   { animation-delay: 6s; }
.home-hero.is-intro .hero-panel--days     { animation-delay: 6.15s; }
.home-hero.is-intro .hero-panel--distance { animation-delay: 6.3s; }
.home-hero.is-intro .hero-panel--modes    { animation-delay: 6.45s; }

.home-hero.is-intro .hero-ticker {
  animation: hero-panel-in 0.9s ease-out 6.8s both;
}

@keyframes hero-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Uses the separate `translate` property so the title panel keeps its
   perspective tilt from `transform`. */
@keyframes hero-panel-in {
  from { opacity: 0; translate: 0 12px; filter: blur(4px); }
  to   { opacity: 1; translate: 0 0;    filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-globe,
  .hero-globe-canvas,
  a.hero-panel,
  .hero-replay,
  .hero-motion-toggle { transition: none; }

  /* No auto-scroll: the facts stay put and can be scrolled by hand. */
  .hero-ticker { overflow-x: auto; }
  .hero-ticker .scrolling-ticker-inner { animation: none; padding: 0 16px; }
}
