/* ===========================================================================
   Weather Wrapped - your shareable year (or decade) in weather
   Full-screen vertical story over the 87-year archive. Apple Liquid Glass.
   Self-contained: namespaced .wwx-* so it never collides with the page.
   =========================================================================== */

:root {
  --wwx-ink: #f4f7fb;
  --wwx-ink-soft: rgba(244, 247, 251, .72);
  --wwx-ink-faint: rgba(244, 247, 251, .5);
  --wwx-edge: rgba(255, 255, 255, .26);
  --wwx-edge-bright: rgba(255, 255, 255, .55);
  --wwx-glass: rgba(255, 255, 255, .1);
  --wwx-spring: cubic-bezier(.32, 1.32, .42, 1);
  --wwx-ease: cubic-bezier(.4, 0, .2, 1);
}

/* ---- launch button (matches sibling tm87-launch styling) ---------------- */
.wwx-launch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 137, 84, .42);
  background: linear-gradient(120deg, rgba(20, 116, 230, .22), rgba(245, 184, 75, .22), rgba(217, 74, 56, .2));
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  color: var(--ink, #0b1220);
  font: 600 13px/1 system-ui, -apple-system, "SF Pro Text", sans-serif;
  letter-spacing: .01em;
  cursor: pointer;
  transition: transform .25s var(--wwx-spring), box-shadow .25s ease, border-color .25s ease;
  box-shadow: 0 4px 16px rgba(217, 74, 56, .16);
}
.wwx-launch:hover {
  transform: translateY(-1px) scale(1.03);
  border-color: rgba(255, 137, 84, .7);
  box-shadow: 0 8px 26px rgba(217, 74, 56, .28);
}
.wwx-launch:focus-visible { outline: 2px solid var(--wx-blue, #1474e6); outline-offset: 3px; }
.wwx-launch-spark {
  width: 9px; height: 9px; border-radius: 50%;
  background: conic-gradient(from 0deg, #f5b84b, #d94a38, #5aa6ff, #21b7d7, #f5b84b);
  box-shadow: 0 0 10px rgba(245, 184, 75, .8);
  animation: wwx-spin 4.5s linear infinite;
}
@keyframes wwx-spin { to { transform: rotate(360deg); } }

/* ---- full-screen stage -------------------------------------------------- */
.wwx-stage {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  background: #05070f;
  color: var(--wwx-ink);
  opacity: 0;
  transition: opacity .35s var(--wwx-ease);
  -webkit-font-smoothing: antialiased;
}
.wwx-stage.is-open { display: block; opacity: 1; }
.wwx-stage * { box-sizing: border-box; }

/* animated mood backdrop (cross-fades per card) */
.wwx-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  transition: background 1.1s var(--wwx-ease);
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(20, 40, 90, .9), transparent 60%),
    linear-gradient(180deg, #0a1430, #05070f);
}
.wwx-particles {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* progress bar (story-style segmented) */
.wwx-progress {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: 16px; right: 16px;
  z-index: 12;
  display: flex;
  gap: 5px;
}
.wwx-progress-seg {
  flex: 1;
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .2);
  overflow: hidden;
}
.wwx-progress-seg > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, .6);
}
.wwx-progress-seg.is-done > i { width: 100%; }
.wwx-progress-seg.is-active > i { width: var(--wwx-seg, 0%); transition: width .2s linear; }

/* top bar */
.wwx-topbar {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 26px);
  left: 16px; right: 16px;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.wwx-brand {
  display: flex; align-items: center; gap: 8px;
  font: 700 13px/1 system-ui, sans-serif;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--wwx-ink-soft);
}
.wwx-brand-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: conic-gradient(from 0deg, #f5b84b, #d94a38, #5aa6ff, #21b7d7, #f5b84b);
  box-shadow: 0 0 8px rgba(245, 184, 75, .7);
}
.wwx-close {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--wwx-edge);
  background: rgba(255, 255, 255, .08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 20px; line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background .2s, transform .2s var(--wwx-spring);
}
.wwx-close:hover { background: rgba(255, 255, 255, .18); transform: scale(1.08); }

/* ---- the scroll-snap track --------------------------------------------- */
.wwx-track {
  position: relative;
  z-index: 5;
  height: 100%;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.wwx-track::-webkit-scrollbar { display: none; }

.wwx-card {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: grid;
  place-items: center;
  padding: 86px 22px 110px;
}
.wwx-slab {
  position: relative;
  width: min(440px, 92vw);
  border-radius: 30px;
  padding: 40px 32px 34px;
  background: var(--wwx-glass);
  border: 1px solid var(--wwx-edge);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  box-shadow:
    0 40px 100px -30px rgba(0, 0, 0, .7),
    inset 0 1px 0 var(--wwx-edge-bright),
    inset 0 -1px 0 rgba(0, 0, 0, .25);
  text-align: center;
  overflow: hidden;
  opacity: 0;
  transform: translateY(34px) scale(.97);
  transition: opacity .6s var(--wwx-ease), transform .7s var(--wwx-spring);
}
.wwx-card.is-live .wwx-slab { opacity: 1; transform: none; }
/* specular sweep on the glass edge */
.wwx-slab::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, .22), transparent 40%);
  pointer-events: none;
  mix-blend-mode: screen;
}

.wwx-kicker {
  font: 700 12px/1 system-ui, sans-serif;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--wwx-ink-soft);
  margin-bottom: 18px;
}
.wwx-hero {
  font: 800 96px/.92 -apple-system, "SF Pro Display", system-ui, sans-serif;
  letter-spacing: -.04em;
  margin: 4px 0;
  background: linear-gradient(180deg, #fff, rgba(255, 255, 255, .72));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 8px 40px rgba(255, 255, 255, .12);
}
.wwx-hero.is-small { font-size: 64px; }
.wwx-hero-unit {
  font-size: .34em;
  letter-spacing: 0;
  font-weight: 700;
  margin-left: 4px;
  color: var(--wwx-ink-soft);
  -webkit-text-fill-color: var(--wwx-ink-soft);
}
.wwx-title {
  font: 700 24px/1.2 -apple-system, system-ui, sans-serif;
  letter-spacing: -.01em;
  margin: 12px 0 6px;
  color: #fff;
}
.wwx-sub {
  font: 400 15px/1.45 -apple-system, system-ui, sans-serif;
  color: var(--wwx-ink-soft);
  margin: 0 auto;
  max-width: 34ch;
}
.wwx-caption {
  margin-top: 18px;
  font: 500 15px/1.5 ui-serif, Georgia, "Times New Roman", serif;
  font-style: italic;
  color: var(--wwx-ink);
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--wwx-edge);
  min-height: 20px;
}
.wwx-caption.is-loading { color: var(--wwx-ink-faint); font-style: normal; }
.wwx-caption-tag {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 10px;
  font: 600 10px/1 system-ui, sans-serif;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--wwx-ink-faint);
}
.wwx-caption-tag i {
  width: 5px; height: 5px; border-radius: 50%;
  background: #5aa6ff; box-shadow: 0 0 6px #5aa6ff;
}

.wwx-statline {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--wwx-edge);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.wwx-stat-label {
  font: 500 13px/1.3 system-ui, sans-serif;
  color: var(--wwx-ink-soft);
  text-align: left;
}
.wwx-stat-value {
  font: 800 26px/1 -apple-system, system-ui, sans-serif;
  color: #fff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* share button on each card */
.wwx-share {
  margin-top: 24px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  border: 1px solid var(--wwx-edge-bright);
  background: rgba(255, 255, 255, .14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font: 700 14px/1 system-ui, sans-serif;
  cursor: pointer;
  transition: transform .2s var(--wwx-spring), background .2s;
}
.wwx-share:hover { background: rgba(255, 255, 255, .26); transform: translateY(-1px) scale(1.03); }
.wwx-share:active { transform: scale(.97); }
.wwx-share svg { width: 15px; height: 15px; fill: currentColor; }

/* nav hint at the bottom */
.wwx-scrollhint {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--wwx-ink-faint);
  font: 600 11px/1 system-ui, sans-serif;
  letter-spacing: .08em; text-transform: uppercase;
  animation: wwx-bob 2.2s ease-in-out infinite;
  pointer-events: none;
}
.wwx-scrollhint svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
@keyframes wwx-bob { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, 5px); } }
.wwx-stage.at-end .wwx-scrollhint { opacity: 0; }

/* ---- year picker (entry screen) ---------------------------------------- */
.wwx-picker {
  position: relative;
  z-index: 6;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 90px 22px 60px;
}
.wwx-picker-inner {
  width: min(520px, 94vw);
  text-align: center;
}
.wwx-picker-title {
  font: 800 40px/1 -apple-system, "SF Pro Display", system-ui, sans-serif;
  letter-spacing: -.03em;
  background: linear-gradient(120deg, #f5b84b, #d94a38, #5aa6ff, #21b7d7);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.wwx-picker-sub {
  margin: 14px auto 28px;
  max-width: 40ch;
  color: var(--wwx-ink-soft);
  font: 400 16px/1.5 system-ui, sans-serif;
}
.wwx-year-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 9px;
  max-height: 44vh;
  overflow-y: auto;
  padding: 6px;
  scrollbar-width: thin;
}
.wwx-year-btn {
  padding: 13px 6px;
  border-radius: 14px;
  border: 1px solid var(--wwx-edge);
  background: rgba(255, 255, 255, .06);
  color: #fff;
  font: 700 16px/1 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform .18s var(--wwx-spring), background .18s, border-color .18s;
}
.wwx-year-btn:hover {
  background: rgba(255, 255, 255, .16);
  border-color: var(--wwx-edge-bright);
  transform: translateY(-2px) scale(1.04);
}
.wwx-year-btn.wwx-all {
  grid-column: 1 / -1;
  background: linear-gradient(120deg, rgba(245, 184, 75, .3), rgba(217, 74, 56, .26), rgba(33, 183, 215, .26));
  border-color: rgba(255, 255, 255, .4);
  font-size: 17px;
  padding: 16px;
}

/* loading + error */
.wwx-loading, .wwx-errstate {
  position: absolute; inset: 0; z-index: 7;
  display: grid; place-items: center; text-align: center;
  color: var(--wwx-ink-soft);
  padding: 40px;
}
.wwx-spinner {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .18);
  border-top-color: #fff;
  margin: 0 auto 18px;
  animation: wwx-rot .8s linear infinite;
}
@keyframes wwx-rot { to { transform: rotate(360deg); } }
.wwx-loading-text { font: 500 15px/1.5 system-ui, sans-serif; }
.wwx-restart {
  margin-top: 16px;
  padding: 10px 20px; border-radius: 999px;
  border: 1px solid var(--wwx-edge-bright);
  background: rgba(255,255,255,.12); color: #fff;
  font: 700 14px/1 system-ui, sans-serif; cursor: pointer;
}

/* offscreen share canvas (1080x1920 vertical story export) */
.wwx-export-canvas { position: fixed; left: -99999px; top: 0; }

/* ---- reduced motion: collapse to a clean scrollable list --------------- */
@media (prefers-reduced-motion: reduce) {
  .wwx-stage, .wwx-slab, .wwx-share, .wwx-launch, .wwx-close, .wwx-year-btn { transition: none !important; }
  .wwx-backdrop { transition: none !important; }
  .wwx-card { scroll-snap-align: none; height: auto; min-height: 100%; }
  .wwx-track { scroll-snap-type: none; }
  .wwx-slab { opacity: 1 !important; transform: none !important; }
  .wwx-scrollhint, .wwx-brand-dot, .wwx-launch-spark { animation: none !important; }
  .wwx-particles { display: none; }
}

/* small screens */
@media (max-width: 420px) {
  .wwx-hero { font-size: 78px; }
  .wwx-hero.is-small { font-size: 52px; }
  .wwx-slab { padding: 32px 22px 28px; }
}
