/* ============================================================================
 *  cph.bmwtpi.com — Jon Gold's Ultimatum Clock
 *  A committed dark Solari / airport departure-board aesthetic.
 * ==========================================================================*/

:root {
  --bg:        #0a0c10;
  --bg2:       #121620;
  --panel:     #151a24;
  --ink:       #f4f0e6;
  --dim:       #8b93a3;
  --amber:     #ffb020;
  --amber-hi:  #ffcc5c;
  --green:     #35d07f;
  --red:       #ff4d4d;
  --tile-line: rgba(0,0,0,.55);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Roboto Mono", monospace;
  --sans: "Helvetica Neue", Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* Visually hidden, but readable by screen readers (clock time mirror, etc.). */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1a2030 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  overflow-x: hidden;
}

/* ---------- Masthead ---------- */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem clamp(1rem, 4vw, 2.5rem);
  background: linear-gradient(#0d1017, #0a0c10);
  border-bottom: 2px solid #000;
  box-shadow: 0 2px 0 rgba(255,255,255,.03);
  position: sticky;
  top: 0;
  z-index: 20;
}
.mast-left { display: flex; align-items: center; gap: .8rem; min-width: 0; }
.plane { color: var(--amber); font-size: 1.8rem; line-height: 1; }
.mast-title {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--amber);
  font-size: clamp(.72rem, 2.6vw, 1.05rem);
  white-space: nowrap;
}
.mast-sub {
  color: var(--dim);
  font-size: clamp(.6rem, 2vw, .78rem);
  letter-spacing: .04em;
}
.mast-right { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.mast-flag {
  font-family: var(--mono);
  background: var(--amber);
  color: #1a1200;
  font-weight: 700;
  padding: .2rem .5rem;
  border-radius: 4px;
  font-size: clamp(.6rem, 2vw, .8rem);
  letter-spacing: .05em;
}
.mast-clock {
  font-family: var(--mono);
  color: var(--green);
  font-size: clamp(.6rem, 2vw, .8rem);
  letter-spacing: .1em;
  animation: pulse 2s infinite;
}
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- "We see you" watcher banner ---------- */
.watcher[hidden] { display: none; }
.watcher {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: linear-gradient(90deg, rgba(255,77,77,.16), rgba(255,176,32,.08));
  border: 1px solid rgba(255,77,77,.45);
  border-radius: 10px;
  padding: .7rem 1rem;
  margin: 0 0 1.6rem;
  font-family: var(--mono);
  font-size: clamp(.72rem, 2.4vw, .95rem);
  color: var(--amber-hi);
  line-height: 1.4;
  animation: watcher-in .5s ease;
}
@keyframes watcher-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.watcher b { color: var(--red); }
.watcher .rec {
  flex-shrink: 0;
  width: .62rem; height: .62rem;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
  animation: blink 1s steps(1) infinite;
}

/* ---------- Hero ---------- */
main { max-width: 1100px; margin: 0 auto; padding: clamp(1.2rem, 4vw, 3rem) 1rem 4rem; }
.hero { text-align: center; margin-bottom: 2.5rem; }
.kicker {
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .22em;
  font-size: clamp(.62rem, 2vw, .78rem);
  margin: 0 0 .6rem;
}
.ultimatum {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--ink);
  font-size: clamp(1.1rem, 5vw, 2.9rem);
  overflow-wrap: break-word;
  line-height: 1.15;
  margin: 0 0 1.6rem;
  text-shadow: 0 2px 14px rgba(0,0,0,.6);
}

/* ---------- Split-flap clock ---------- */
.clock {
  --fs: clamp(2.3rem, 13vw, 9rem);   /* glyph font-size = tile scale */
  --fw: calc(var(--fs) * 0.72);      /* tile width  */
  --fh: calc(var(--fs) * 1.12);      /* tile height */
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(.15rem, 1.2vw, .55rem);
  padding: clamp(.8rem, 3vw, 1.6rem) 0;
  filter: drop-shadow(0 18px 30px rgba(0,0,0,.55));
}
.flap-group { display: flex; flex-direction: column; align-items: center; }
.flap-row { display: flex; gap: clamp(.1rem, .8vw, .35rem); }
.flap-label {
  margin-top: .55rem;
  font-family: var(--mono);
  color: var(--dim);
  letter-spacing: .35em;
  font-size: clamp(.55rem, 2vw, .85rem);
  padding-left: .35em;
}
.flap-sep {
  font-family: var(--mono);
  font-size: var(--fs);
  color: var(--amber);
  line-height: var(--fh);
  font-weight: 700;
  align-self: flex-start;
  animation: pulse 1s steps(1) infinite;
}

.flap {
  position: relative;
  width: var(--fw);
  height: var(--fh);
  perspective: 320px;
  font-family: var(--mono);
  font-weight: 700;
}
.flap-card, .flap-fold {
  position: absolute;
  left: 0;
  width: 100%;
  height: 50%;
  overflow: hidden;
  backface-visibility: hidden;
  background: linear-gradient(#22262f, #191c23);
}
.flap-card.top,  .flap-fold-top {
  top: 0;
  border-radius: 10px 10px 0 0;
  border-bottom: 1px solid var(--tile-line);
}
.flap-card.bottom, .flap-fold-bottom {
  bottom: 0;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(#1b1e25, #14171d);
}
.flap-card span, .flap-fold span {
  position: absolute;
  left: 0;
  width: 100%;
  height: var(--fh);
  line-height: var(--fh);
  text-align: center;
  font-size: var(--fs);
  color: var(--ink);
  text-shadow: 0 1px 1px rgba(0,0,0,.7);
}
.flap-card.top span,    .flap-fold-top span    { top: 0; }
.flap-card.bottom span, .flap-fold-bottom span { top: -100%; }

.flap-fold        { visibility: hidden; }  /* only shown mid-flip */
.flap-fold-top    { transform-origin: center bottom; z-index: 5; }
.flap-fold-bottom { transform-origin: center top;    z-index: 5; }
.flap-fold-top    { box-shadow: inset 0 -18px 24px -18px rgba(0,0,0,.8); }
.flap-fold-bottom { box-shadow: inset 0 18px 24px -18px rgba(0,0,0,.6); }

/* subtle center seam + side gutters on the whole tile */
.flap::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03),
              0 3px 6px rgba(0,0,0,.4);
  pointer-events: none;
}

.clock-caption {
  color: var(--ink);
  font-size: clamp(.85rem, 2.6vw, 1.1rem);
  max-width: 40ch;
  margin: 1.2rem auto .2rem;
}
.clock-caption strong { color: var(--amber-hi); }

/* ---------- Defuse button ---------- */
.defuse-wrap { margin-top: 1.6rem; display: flex; flex-direction: column; align-items: center; gap: .4rem; }
#defuse {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: .06em;
  font-size: clamp(.85rem, 3vw, 1.1rem);
  color: #06210f;
  background: var(--green);
  border: none;
  border-radius: 10px;
  padding: .8rem 1.5rem;
  cursor: pointer;
  box-shadow: 0 6px 0 #1f8f57, 0 10px 20px rgba(0,0,0,.4);
  transition: transform .08s ease, box-shadow .08s ease;
}
#defuse:hover { filter: brightness(1.06); }
#defuse:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 #1f8f57; }
#defuse:disabled { background: var(--dim); box-shadow: none; color: #0a0c10; cursor: default; }
#defuse.denied { animation: shake .5s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-7px)} 40%,80%{transform:translateX(7px)} }
.defuse-note { color: var(--dim); font-size: .72rem; letter-spacing: .04em; }
.booked-banner {
  margin: 1.4rem auto 0;
  max-width: 46ch;
  background: rgba(53,208,127,.12);
  border: 1px solid rgba(53,208,127,.4);
  color: var(--green);
  border-radius: 10px;
  padding: .8rem 1rem;
  font-family: var(--mono);
  font-size: clamp(.75rem, 2.4vw, .95rem);
}

/* ---------- Ticker ---------- */
.ticker {
  display: flex;
  align-items: center;
  gap: .8rem;
  background: #05070b;
  border: 1px solid #000;
  border-radius: 8px;
  padding: .7rem 1rem;
  margin: 0 auto 2.5rem;
  max-width: 900px;
  overflow: hidden;
}
.ticker-badge {
  flex-shrink: 0;
  font-family: var(--mono);
  color: var(--amber);
  font-size: clamp(.6rem, 2vw, .8rem);
  letter-spacing: .08em;
  font-weight: 700;
}
.ticker-text {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  color: var(--amber-hi);
  font-size: clamp(.72rem, 2.4vw, .95rem);
  transition: opacity .4s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid #000;
  border-radius: 14px;
  padding: clamp(1.1rem, 3.5vw, 2rem);
  margin-bottom: 2rem;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.panel-title {
  font-family: var(--mono);
  color: var(--amber);
  letter-spacing: .1em;
  font-size: clamp(1rem, 3.4vw, 1.4rem);
  margin: 0 0 .3rem;
  text-transform: uppercase;
}
.panel-lede, .panel-foot { color: var(--dim); font-size: .85rem; }
.panel-lede { margin: 0 0 1.2rem; }
.panel-foot { margin: 1rem 0 0; }

/* ---------- Manifest ---------- */
.manifest { font-family: var(--mono); }
.m-row {
  display: grid;
  grid-template-columns: 1.6fr 1.1fr .9fr .8fr 1.1fr;
  gap: .5rem;
  align-items: center;
  padding: .7rem .3rem;
  border-bottom: 1px dashed rgba(255,255,255,.07);
  font-size: clamp(.62rem, 2vw, .9rem);
}
.m-head { color: var(--dim); font-size: .68rem; letter-spacing: .1em; border-bottom: 1px solid rgba(255,255,255,.15); }
.m-name { font-weight: 700; letter-spacing: .04em; }
.m-col { color: var(--ink); }
.m-flt { color: var(--dim); }
.m-you { background: rgba(255,176,32,.06); border-radius: 6px; }
.m-you .m-name { color: var(--amber-hi); }
.m-status { font-weight: 700; letter-spacing: .06em; text-align: right; }
.tone-ok   { color: var(--green); }
.tone-warn { color: var(--red); }
.tone-dim  { color: var(--dim); }
.blink { animation: blink 1.05s steps(1) infinite; }
@keyframes blink { 50% { opacity: .18; } }

/* ---------- Exhibits ---------- */
.exhibits {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.exhibit {
  margin: 0;
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,.06);
  border-left: 3px solid var(--red);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}
.exhibit-defense { border-left-color: var(--green); }
.exhibit-tag {
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .18em;
  color: var(--dim);
  margin-bottom: .5rem;
}
.exhibit blockquote {
  margin: 0 0 .6rem;
  font-size: clamp(.85rem, 2.5vw, 1rem);
  color: var(--ink);
  line-height: 1.4;
}
.exhibit figcaption {
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--amber);
}
.exhibit-defense figcaption { color: var(--green); }

/* ---------- Boarding-pass exhibit (Jon's real booking) ---------- */
.boarding { margin: 0; }
.boarding img {
  display: block;
  width: 100%;
  max-width: 760px;
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
  background: #fff;                 /* fills the light card cleanly */
  padding: 10px;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 14px 34px rgba(0,0,0,.5);
}
.boarding figcaption {
  max-width: 760px;
  margin: 1rem auto 0;
  color: var(--dim);
  font-size: clamp(.78rem, 2.4vw, .92rem);
  text-align: center;
  line-height: 1.55;
}
.boarding figcaption strong { color: var(--amber-hi); }
.boarding-stamp {
  display: inline-block;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: .08em;
  color: #06210f;
  background: var(--green);
  padding: .12rem .5rem;
  border-radius: 4px;
  margin-right: .35rem;
  transform: rotate(-2deg);
}

/* ---------- Itinerary ---------- */
.itin { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.itin-card { background: var(--bg2); border: 1px solid rgba(255,255,255,.06); border-radius: 10px; padding: 1.1rem; }
.itin-h { font-family: var(--mono); color: var(--amber-hi); font-size: .95rem; margin-bottom: .4rem; letter-spacing: .03em; }
.itin-card p { margin: 0; color: var(--dim); font-size: .88rem; }
.itin-card strong { color: var(--ink); }

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  color: var(--dim);
  font-family: var(--mono);
  font-size: .72rem;
  padding: 2rem 1rem 3rem;
  border-top: 1px solid #000;
  letter-spacing: .04em;
}
.footer-fine { margin-top: .4rem; opacity: .6; font-size: .66rem; }

/* ---------- Panic mode (final hour) ---------- */
body.panic { animation: panicbg 1.4s ease-in-out infinite; }
@keyframes panicbg { 50% { background-color: #1c0a0a; } }
body.panic .flap-sep { color: var(--red); }
body.panic .ultimatum { color: var(--red); }

/* ---------- Nuclear overlay ---------- */
body.nuclear { animation: nukebg .6s steps(2) infinite; }
@keyframes nukebg { 50% { background-color: #2a0000; } }
.boom[hidden] { display: none; }
.boom {
  position: fixed; inset: 0;
  background: rgba(10,0,0,.94);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  text-align: center;
  padding: 1.5rem;
  animation: boomflash 1s steps(2) infinite;
}
@keyframes boomflash { 50% { background: rgba(40,0,0,.9); } }
.boom-inner { max-width: 640px; }
.boom-siren {
  font-family: var(--mono);
  color: var(--red);
  font-size: clamp(1.4rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: .12em;
  margin-bottom: 1rem;
  text-shadow: 0 0 24px rgba(255,0,0,.6);
}
.boom h2 {
  font-family: var(--mono);
  color: var(--ink);
  font-size: clamp(1.1rem, 4vw, 2rem);
  letter-spacing: .06em;
  margin: 0 0 1rem;
}
.boom p { color: var(--amber-hi); font-size: clamp(.9rem, 3vw, 1.2rem); margin: .4rem 0; }
.boom-small { color: var(--dim) !important; font-size: .82rem !important; margin-top: 1.2rem !important; }

/* ---------- Mute toggle (corner) ---------- */
#mute-toggle {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 90;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(18,22,32,.92);
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0,0,0,.5);
  transition: transform .1s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(4px);
}
#mute-toggle:hover { background: rgba(30,36,50,.96); }
#mute-toggle:active { transform: scale(.9); }
#mute-toggle:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
#mute-toggle.is-muted { color: var(--dim); opacity: .8; }

/* ---------- Reduced motion ---------- */
/* NB: the split-flap animation is bypassed in JS (REDUCED_MOTION in flap.js) —
   we deliberately do NOT force `.flap-fold { transition: none }` here, because
   that would strand the flip mid-way (its `transitionend` handler never fires). */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- Narrow screens ---------- */
@media (max-width: 560px) {
  /* Masthead: let the title shrink/wrap, drop the gate flag + LIVE badge. */
  .mast-title { white-space: normal; }
  .mast-right { display: none; }

  /* Manifest collapses to PASSENGER · ROUTE · STATUS (hide FLIGHT + DATE). */
  .m-row { grid-template-columns: 1.5fr 1fr 1.1fr; }
  .m-row > *:nth-child(3),
  .m-row > *:nth-child(4) { display: none; }
}
