/* DIG TO THE OTHER SIDE — molten amber on field-instrument dark */

:root {
  --amber: #ffb03a;
  --amber-deep: #e07818;
  --ink: #f5f5f0; /* near-white: all reading text */
  --faint: rgba(232, 228, 220, 0.55); /* micro-labels and metadata only, never body text */
  --panel: rgba(8, 10, 14, 0.78);
  --hairline: rgba(255, 176, 58, 0.35);
  --font-tech: 'Segoe UI Light', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: Consolas, 'Courier New', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: auto; }
body {
  background: #05070c;
  color: var(--ink);
  font-family: var(--font-tech);
  font-weight: 300;
  overflow-x: hidden;
}

.stage { position: fixed; inset: 0; z-index: 10; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- opening globe: hard-capped, clipped, right half ---------- */
#globe-stage { overflow: hidden; background: #05070c; }
/* randomly generated stars across the whole opening screen, behind everything */
#starfield { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
#globe-wrap { z-index: 1; }
.globe-ui, .attribution { z-index: 2; }
#globe-wrap {
  /* diameter never exceeds 60% of window height NOR 45% of window width;
     overflow hidden so nothing can ever spill past the window edges */
  position: absolute;
  right: 6vw; top: 50%; transform: translateY(-50%);
  width: min(60vh, 45vw);
  height: min(60vh, 45vw);
  max-width: 100vw; max-height: 100vh;
  overflow: hidden;
  transition: width 1s ease, height 1s ease, right 1s ease, top 1s ease, transform 1s ease;
}
#globe-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
/* when digging starts the globe expands to fill the window for the dive */
#globe-wrap.digging {
  right: 0; top: 0; transform: none;
  width: 100vw; height: 100vh;
}

/* ---------- globe phase ---------- */
.globe-ui {
  /* text and postcode box own the LEFT half; the globe owns the right */
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  padding: 3vh 4vw 3vh 6vw; max-width: min(720px, 50vw); pointer-events: none;
  max-height: 100vh; overflow-y: auto;
}
.globe-ui > * { pointer-events: auto; }
.hero-title {
  /* capped in vh too, so heading + globe + postcode box always share one screen */
  font-size: clamp(2rem, min(6.5vw, 9.5vh), 5.2rem);
  font-weight: 100; letter-spacing: 0.02em; line-height: 1.02;
  text-transform: uppercase;
}
.hero-title::after {
  content: ''; display: block; width: 6rem; height: 2px;
  background: var(--amber); margin-top: min(1.2rem, 1.6vh);
}
.hero-sub { margin-top: min(1.4rem, 2vh); font-size: clamp(0.85rem, 1.8vh, 1.05rem); color: var(--ink); font-weight: 400; max-width: 34rem; line-height: 1.55; text-shadow: 0 1px 8px rgba(0,0,0,0.8); }
#postcode-form { margin-top: min(2rem, 2.6vh); display: flex; gap: 0.6rem; width: 100%; max-width: 34rem; flex-wrap: wrap; }
.input-row { display: flex; gap: 0.6rem; flex: 1 1 100%; flex-wrap: wrap; }
#name-input, #town-input, #postcode-input, #country-input {
  background: var(--panel); border: 1px solid var(--hairline);
  color: var(--ink); font: 300 1rem var(--font-tech);
  padding: 0.95rem 1.1rem; letter-spacing: 0.06em; backdrop-filter: blur(6px);
  min-width: 0;
}
#name-input { flex: 1 1 8rem; }
#town-input { flex: 1.3 1 9rem; }
#postcode-input { flex: 1 1 7rem; }
#country-input { flex: 1 1 8rem; }
#name-input:focus, #town-input:focus, #postcode-input:focus, #country-input:focus { outline: none; border-color: var(--amber); }

/* "We found:" confirmation before the dig starts */
.confirm-panel {
  margin-top: 1rem; max-width: 34rem; width: 100%;
  background: rgba(5, 6, 10, 0.8); border: 1px solid var(--hairline); border-left: 3px solid var(--amber);
  border-radius: 12px; backdrop-filter: blur(8px);
  padding: 1.1rem 1.3rem;
}
.confirm-text { color: #f5f5f0; font-weight: 400; line-height: 1.5; }
.confirm-text strong { font-weight: 600; }
.confirm-question { color: var(--amber); font-weight: 500; margin-top: 0.4rem; }
.confirm-buttons { display: flex; gap: 0.6rem; margin-top: 0.9rem; flex-wrap: wrap; }
.confirm-buttons button {
  background: var(--amber); border: none; color: #14100a; cursor: pointer;
  font: 600 0.8rem var(--font-tech); letter-spacing: 0.12em; text-transform: uppercase;
  padding: 0.8rem 1.3rem;
}
.confirm-buttons button:hover { background: #ffc766; }
.confirm-buttons .ghost {
  background: none; border: 1px solid var(--hairline); color: var(--ink);
}
.confirm-buttons .ghost:hover { background: rgba(255, 176, 58, 0.12); }
#start-btn, .again, .poster-buttons button {
  background: var(--amber); border: none; color: #14100a; cursor: pointer;
  font: 600 0.85rem var(--font-tech); letter-spacing: 0.14em; text-transform: uppercase;
  padding: 0.95rem 1.6rem; transition: background 0.2s;
}
#start-btn:hover, .again:hover, .poster-buttons button:hover { background: #ffc766; }
#start-btn:disabled { background: #6b5b3c; cursor: wait; }
.hero-note { margin-top: min(1.1rem, 1.6vh); font: clamp(0.62rem, 1.4vh, 0.78rem) var(--font-mono); color: rgba(245, 245, 240, 0.82); max-width: 32rem; text-shadow: 0 1px 8px rgba(0,0,0,0.8); }
.geo-error { margin-top: 0.8rem; color: #ff7a5c; font-size: 0.9rem; }
.journeys-line {
  margin-top: 0.7rem;
  font: 0.68rem var(--font-mono); letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--amber);
}
.attribution {
  position: absolute; bottom: 0.7rem; right: 1rem;
  font: 0.62rem var(--font-mono); color: rgba(232,228,220,0.35);
}

/* ---------- zoom phase ---------- */
.zoom-caption {
  position: absolute; left: 50%; bottom: 8vh; transform: translateX(-50%);
  font: 0.85rem var(--font-mono); letter-spacing: 0.2em; color: var(--ink);
  background: var(--panel); border: 1px solid var(--hairline);
  padding: 0.7rem 1.4rem; text-transform: uppercase; white-space: nowrap;
}

/* ---------- journey phase ---------- */
.journey-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; }
.journey-scroll { position: relative; z-index: 0; }

.hud {
  position: fixed; right: 1.2rem; top: 50%; transform: translateY(-50%);
  z-index: 5; width: 12.5rem;
  background: var(--panel); border: 1px solid var(--hairline);
  backdrop-filter: blur(8px);
  padding: 1.1rem 1.2rem 1.3rem;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), inset 0 0 24px rgba(255,176,58,0.04);
}
.hud::before {
  content: 'FIELD INSTRUMENT · 01'; display: block;
  font: 0.55rem var(--font-mono); letter-spacing: 0.22em; color: var(--faint);
  border-bottom: 1px solid var(--hairline); padding-bottom: 0.55rem; margin-bottom: 0.8rem;
}
.hud-cell { margin-bottom: 1rem; position: relative; }
.hud-label { font: 0.58rem var(--font-mono); letter-spacing: 0.26em; color: var(--faint); margin-bottom: 0.25rem; }
.hud-value { font-size: 1.7rem; font-weight: 200; color: var(--amber); font-variant-numeric: tabular-nums; letter-spacing: 0.03em; }
.hud-unit { font-size: 0.9rem; color: var(--faint); }
.hud-zone { font-size: 0.95rem; letter-spacing: 0.12em; color: var(--ink); min-height: 2.2em; }
.hud-zone.tick { animation: zonetick 0.5s ease; }
@keyframes zonetick { 0% { opacity: 0; transform: translateY(0.5em); } 100% { opacity: 1; transform: none; } }
.hud-gauge {
  position: absolute; right: -0.35rem; top: 0; width: 3px; height: 100%;
  background: rgba(232,228,220,0.12);
}
.hud-gauge-fill { width: 100%; height: 0%; background: linear-gradient(var(--amber), var(--amber-deep)); }

.scroll-hint {
  position: fixed; left: 50%; bottom: 3vh; transform: translateX(-50%);
  z-index: 5; font: 0.7rem var(--font-mono); letter-spacing: 0.34em; color: var(--ink);
  opacity: 0.9; transition: opacity 0.6s; text-align: center;
}
.scroll-hint .chev { display: block; animation: bob 1.4s ease-in-out infinite; margin-top: 0.4rem; }
@keyframes bob { 50% { transform: translateY(0.35rem); } }
.scroll-hint.gone { opacity: 0; }

.fact-card {
  /* reading text lives on the LEFT; the HUD owns the right edge. The width
     cap guarantees they can never meet, whatever the viewport. */
  position: fixed; left: 4vw; bottom: 7vh; z-index: 5;
  max-width: min(24rem, calc(100vw - 4vw - 15.5rem));
  background: rgba(5, 6, 10, 0.8); border: 1px solid var(--hairline); border-left: 3px solid var(--amber);
  border-radius: 12px;
  backdrop-filter: blur(8px); padding: 1.1rem 1.3rem;
  opacity: 0; transform: translateY(1rem); transition: opacity 0.35s, transform 0.35s;
}
/* while a section is on screen its text sits at FULL strength — the only
   fade is the brief entrance/exit of the card itself */
.fact-card.show { opacity: 1; }
.fact-card.show { opacity: 1; transform: none; }
.fact-zone { font: 0.6rem var(--font-mono); letter-spacing: 0.3em; color: var(--amber); margin-bottom: 0.5rem; }
.fact-text { font-size: 0.94rem; line-height: 1.5; color: #f5f5f0; font-weight: 500; }
/* short fact lines with a small amber tick; the card scrolls if a set runs tall */
.fact-line { margin: 0 0 0.55rem; padding-left: 0.95rem; position: relative; }
.fact-line:last-child { margin-bottom: 0; }
.fact-line::before { content: '—'; position: absolute; left: 0; color: var(--amber); font-weight: 600; }
.fact-card { max-height: 62vh; overflow-y: auto; }
.centre-panel p { margin-bottom: 0.55rem; }
.centre-panel p:last-child { margin-bottom: 0; }

/* Gregg's friendly heads-up on the opening dig screen */
.dig-honesty {
  position: fixed; left: 4vw; top: 6vh; z-index: 5;
  max-width: min(24rem, calc(100vw - 4vw - 15.5rem));
  max-height: 56vh; overflow-y: auto;
  background: rgba(5, 6, 10, 0.8); border: 1px solid var(--hairline); border-left: 3px solid var(--amber);
  border-radius: 12px; backdrop-filter: blur(8px);
  padding: 1.1rem 1.3rem;
  opacity: 0; transform: translateY(-0.6rem); transition: opacity 0.5s, transform 0.5s;
  pointer-events: none;
}
.dig-honesty.show { opacity: 1; transform: none; pointer-events: auto; }
.dig-honesty p { font-size: 0.9rem; line-height: 1.55; color: #f5f5f0; font-weight: 400; margin-bottom: 0.55rem; }
.dig-honesty p:last-child, .dig-honesty div p:last-child { margin-bottom: 0; }
.dig-honesty-kicker { color: var(--amber) !important; font-weight: 500 !important; }

.centre-panel {
  /* same dark left-hand box as the fact cards: high contrast, clear of the
     weightless figure in the middle of the frame */
  position: fixed; left: 4vw; top: 50%; transform: translateY(-50%);
  z-index: 6; pointer-events: none;
  max-width: min(26rem, calc(100vw - 4vw - 15.5rem));
  background: rgba(5, 6, 10, 0.8); border: 1px solid var(--hairline); border-left: 3px solid var(--amber);
  border-radius: 12px; backdrop-filter: blur(8px);
  padding: 1.3rem 1.5rem;
  opacity: 0; transition: opacity 0.4s;
}
.centre-panel.show { opacity: 1; }
.centre-title { font: 0.7rem var(--font-mono); letter-spacing: 0.4em; color: var(--amber); margin-bottom: 0.9rem; }
.centre-panel p { color: #f5f5f0; font-size: 1.05rem; line-height: 1.55; font-weight: 500; }
.centre-kicker { margin-top: 0.9rem; font-weight: 500 !important; letter-spacing: 0.06em; color: var(--amber) !important; }

/* ---------- surfacing ---------- */
#surface-stage { overflow-y: auto; }
#surface-globe-canvas { position: fixed !important; inset: 0; z-index: 0; }
#poster-preview { position: static; }
.surface-ui {
  /* the ending reads top-to-bottom as a proper scrolling page:
     greeting -> you came out at -> Earth in numbers -> poster */
  position: relative; z-index: 2; max-width: 44rem;
  margin: 8vh auto 0; padding: 0 1.4rem 14vh;
  display: flex; flex-direction: column; gap: 2.4rem;
}
.surface-ui > * { flex-shrink: 0; }
.gregg-row { display: flex; gap: 1rem; align-items: flex-end; }
#gregg-face {
  width: 108px; height: 108px; object-fit: cover;
  border-radius: 50%; border: 2px solid var(--amber); flex-shrink: 0;
}
.speech-bubble {
  position: relative; background: var(--panel); border: 1px solid var(--hairline);
  backdrop-filter: blur(8px); padding: 1rem 1.3rem; font-size: 1.02rem; line-height: 1.5;
}
.speech-bubble::before {
  content: ''; position: absolute; left: -0.55rem; bottom: 1.4rem;
  width: 1rem; height: 1rem; background: inherit;
  border-left: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline);
  transform: rotate(45deg);
}
.exit-card, .numbers-panel, .poster-panel {
  background: rgba(5, 6, 10, 0.8); border: 1px solid var(--hairline);
  border-radius: 12px;
  backdrop-filter: blur(8px); padding: 1.5rem 1.7rem;
}
.speech-bubble { border-radius: 12px; background: rgba(5, 6, 10, 0.8); color: #f5f5f0; font-weight: 400; }
.exit-label, .numbers-title { font: 0.6rem var(--font-mono); letter-spacing: 0.3em; color: var(--amber); margin-bottom: 0.7rem; }
.exit-card h2 { font-size: 2rem; font-weight: 200; letter-spacing: 0.02em; margin-bottom: 0.5rem; }
.exit-scene {
  width: 100%; height: auto; display: block;
  border: 1px solid var(--hairline); border-radius: 8px;
  margin: 0.4rem 0 0.8rem;
}
.exit-card p { color: #f5f5f0; font-weight: 400; line-height: 1.55; margin-bottom: 0.5rem; }
.exit-fact { color: #f5f5f0 !important; font-weight: 500 !important; }
.exit-note { font: 0.75rem var(--font-mono); color: rgba(245, 245, 240, 0.82); margin-top: 0.6rem; }
.numbers-panel dl { display: grid; grid-template-columns: auto 1fr; gap: 0.45rem 1.2rem; }
.numbers-panel dt { font: 0.72rem var(--font-mono); color: var(--amber); letter-spacing: 0.08em; padding-top: 0.15rem; white-space: nowrap; }
.numbers-panel dd { color: #f5f5f0; font-weight: 400; font-size: 0.95rem; }

.poster-sub { color: #f5f5f0; font-weight: 400; font-size: 0.92rem; margin-bottom: 1rem; }
/* the two poster designs, side by side */
.poster-designs { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.design-card {
  flex: 1 1 12rem; max-width: 15rem;
  border: 1px solid var(--hairline); border-radius: 12px;
  padding: 0.8rem; cursor: pointer;
  display: flex; flex-direction: column; gap: 0.5rem;
  transition: border-color 0.2s, background 0.2s;
}
.design-card:hover { background: rgba(255, 176, 58, 0.06); }
.design-card.selected { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.design-card canvas {
  /* the generic .stage canvas rule must not grab these previews */
  position: static !important; inset: auto;
  width: 100% !important; height: auto !important; display: block;
  border: 1px solid var(--hairline); border-radius: 4px;
  cursor: zoom-in;
}
.design-pick { font-size: 0.92rem; font-weight: 600; color: #f5f5f0; display: flex; align-items: center; gap: 0.45rem; }
.design-pick input { accent-color: var(--amber); }
.design-note { font: 0.68rem var(--font-mono); color: rgba(245, 245, 240, 0.82); line-height: 1.5; }

/* full-size poster lightbox */
.poster-lightbox[hidden] { display: none; }
.poster-lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(2, 3, 6, 0.88);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.poster-lightbox img {
  max-width: 92vw; max-height: 92vh;
  border: 1px solid var(--hairline); border-radius: 4px;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.8);
  cursor: default;
}
.lightbox-close {
  position: absolute; top: 1rem; right: 1.4rem;
  background: none; border: none; color: var(--ink);
  font-size: 2.4rem; line-height: 1; cursor: pointer; z-index: 101;
}
.lightbox-close:hover { color: var(--amber); }
.poster-buttons { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.poster-buttons button { padding: 0.75rem 1.1rem; font-size: 0.72rem; }
.affiliate { margin-top: 1.4rem; border-top: 1px solid var(--hairline); padding-top: 1rem; display: flex; flex-direction: column; gap: 0.45rem; }
.affiliate-label { font: 0.58rem var(--font-mono); letter-spacing: 0.26em; color: var(--faint); margin-bottom: 0.2rem; }
.affiliate a { color: var(--amber); text-decoration: none; font-size: 0.9rem; }
.affiliate a:hover { text-decoration: underline; }

.honesty {
  font: 0.78rem var(--font-mono); color: rgba(245, 245, 240, 0.88); line-height: 1.7;
  border-left: 2px solid var(--hairline); padding-left: 1rem;
  background: rgba(5, 6, 10, 0.8); border-radius: 0 12px 12px 0; padding: 1rem 1.2rem;
}
.again { align-self: flex-start; }

@media (max-width: 720px) {
  /* opening screen stacks: text on top, smaller globe below, both fully visible */
  .globe-ui {
    position: relative; inset: auto; max-width: none; max-height: none;
    padding: 5vh 6vw 0; justify-content: flex-start;
  }
  #globe-wrap {
    position: relative; right: auto; top: auto; transform: none;
    margin: 3vh auto 0;
    width: min(34vh, 78vw); height: min(34vh, 78vw);
  }
  #globe-wrap.digging {
    position: fixed; right: 0; top: 0; margin: 0;
    width: 100vw; height: 100vh;
  }
  #globe-stage { display: flex; flex-direction: column; }
  .globe-ui { order: 1; } /* text on top... */
  #globe-wrap { order: 2; } /* ...globe below */

  /* stacked: reading text low on screen, HUD as a slim bottom bar — never overlapping */
  .hud {
    top: auto; bottom: 0; right: 0; left: 0; transform: none;
    width: 100%; border-left: none; border-right: none; border-bottom: none;
    display: flex; gap: 1rem; align-items: center;
    padding: 0.5rem 0.9rem;
  }
  .hud::before { display: none; }
  .hud-cell { margin-bottom: 0; flex: 1; }
  .hud-value { font-size: 1.05rem; }
  .hud-zone { font-size: 0.68rem; min-height: 0; }
  .hud-gauge { display: none; }
  .fact-card {
    left: 3vw; right: 3vw; max-width: none;
    bottom: 5.4rem; /* clear of the slim HUD bar */
    max-height: 44vh; /* longer fact sets scroll rather than cover the video */
  }
  .centre-panel { left: 3vw; right: 3vw; max-width: none; top: 38%; }
  .scroll-hint { bottom: 6rem; }
}

@media (max-height: 700px) {
  .hero-sub { max-width: 30rem; }
  .globe-ui { justify-content: center; }
}
