/* ==========================================================================
   Dhaka Climate Week: motion layer
   Hidden starting states are scoped to html.motion, which is only set in
   <head> when the visitor has not asked for reduced motion.
   ========================================================================== */

:root {
  --intro: 0s;
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
}
html.has-intro { --intro: 1.15s; }

/* ---------- Intro curtain (first visit per session) ---------- */
.intro { display: none; }
html.has-intro .intro {
  position: fixed; inset: 0; z-index: 400;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.25rem;
  background: var(--stripe);
  clip-path: inset(0 0 0 0);
  pointer-events: none;
  animation: intro-lift 1s var(--ease-io) 1.05s forwards;
}
.intro__logo { width: clamp(150px, 20vw, 240px); height: auto; opacity: 0; animation: intro-logo 0.8s var(--ease) 0.1s forwards; }
.intro__line {
  display: block; width: clamp(150px, 20vw, 240px); height: 2px; background: var(--tiger);
  transform: scaleX(0); transform-origin: left center;
  animation: intro-line 0.9s var(--ease-io) 0.2s forwards;
}
@keyframes intro-logo { from { opacity: 0; translate: 0 14px; } to { opacity: 1; translate: 0 0; } }
@keyframes intro-line { to { transform: scaleX(1); } }
@keyframes intro-lift { to { clip-path: inset(0 0 100% 0); visibility: hidden; } }

/* ---------- Shared keyframes ---------- */
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; translate: 0 28px; } }
@keyframes line-up { from { translate: 0 112%; rotate: 3deg; } }
@keyframes draw { from { stroke-dashoffset: 1.05; } to { stroke-dashoffset: 0; } }
@keyframes tide { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes img-settle { from { scale: 1.22; } }
@keyframes item-in { from { opacity: 0; translate: 0 34px; } }

/* ---------- Header ---------- */
.site-header {
  transition: height 0.4s var(--ease), background 0.45s var(--ease), border-color 0.45s var(--ease), translate 0.6s var(--ease);
}
.site-header.is-hidden { translate: 0 -100%; }
body.menu-open .site-header.is-hidden { translate: none; }
html.motion .site-header { animation: header-in 1.1s var(--ease) calc(var(--intro) + 0.15s) backwards; }
@keyframes header-in { from { translate: 0 -100%; } }

/* ---------- Hero ---------- */
/* Anek's tall Bangla metrics put Latin ascenders close to the line box, so the masks get headroom. */
.hero__title .ln { display: block; overflow: hidden; padding: 0.08em 0.1em 0.12em; margin: -0.08em -0.1em -0.12em; }
.hero__title .ln > span { display: inline-block; transform-origin: 0 100%; }
.hero__em { position: relative; display: inline-block; }
.hero__wave {
  position: absolute; left: 0; top: 100%; margin-top: -0.1em;
  width: 100%; height: auto; overflow: visible;
  fill: none; stroke: var(--tiger); stroke-width: 4; stroke-linecap: round;
}
.hero__wave path { stroke-dasharray: 1 1.05; stroke-dashoffset: 0; }

html.motion .hero { background: var(--stripe); }
html.motion .hero__bg {
  translate: 0 calc(var(--hero-p, 0) * 18%);
  animation: hero-settle 2.8s var(--ease) calc(var(--intro) * 0.4) backwards;
}
html.motion .hero__scrim { animation: fade-in 1.8s ease calc(var(--intro) * 0.8) backwards; }
html.motion .hero__inner {
  translate: 0 calc(var(--hero-p, 0) * -70px);
  opacity: calc(1 - var(--hero-p, 0) * 1.25);
}
html.motion .hero__inner > .kicker,
html.motion .hero__lede,
html.motion .hero__meta,
html.motion .hero__actions { animation: rise-in 1.1s var(--ease) backwards; }
html.motion .hero__inner > .kicker { animation-delay: calc(var(--intro) + 0.2s); }
html.motion .hero__title .ln > span { animation: line-up 1.3s var(--ease) backwards; }
html.motion .hero__title .ln:nth-child(1) > span { animation-delay: calc(var(--intro) + 0.3s); }
html.motion .hero__title .ln:nth-child(2) > span { animation-delay: calc(var(--intro) + 0.42s); }
html.motion .hero__wave path { animation: draw 1.5s var(--ease-io) calc(var(--intro) + 1.05s) backwards; }
html.motion .hero__lede { animation-delay: calc(var(--intro) + 0.75s); }
html.motion .hero__meta { animation-delay: calc(var(--intro) + 0.9s); }
html.motion .hero__actions { animation-delay: calc(var(--intro) + 1.05s); }
html.motion .hero__scroll { animation: fade-in 1.2s ease calc(var(--intro) + 1.6s) backwards; }
@keyframes hero-settle { from { scale: 1.18; } }

/* ---------- Dhaka icons drifting like the city itself ---------- */
html.motion .deco--boat { animation: bob 6.5s ease-in-out infinite; }
html.motion .deco--lily { transform-origin: 50% 85%; animation: sway 8s ease-in-out infinite; }
html.motion .deco--rickshaw { animation: roll 10s ease-in-out infinite; }
html.motion .deco--metro { animation: glide 14s ease-in-out infinite; }
@keyframes bob { 0%, 100% { translate: 0 0; rotate: -1.5deg; } 50% { translate: 0 -7px; rotate: 1.5deg; } }
@keyframes sway { 0%, 100% { rotate: -2.5deg; } 50% { rotate: 2.5deg; } }
@keyframes roll { 0%, 100% { translate: -10px 0; } 50% { translate: 12px 0; } }
@keyframes glide { 0%, 100% { translate: -16px 0; } 50% { translate: 16px 0; } }

/* ---------- Headings: word-by-word rise ---------- */
.m-split .w { display: inline-block; overflow: hidden; vertical-align: top; padding: 0.08em 0.05em 0.14em; margin: -0.08em -0.05em -0.14em; }
.m-split .w > span {
  display: inline-block; translate: 0 108%;
  transition: translate 1.15s var(--ease);
  transition-delay: calc(var(--wi, 0) * 60ms + 80ms);
}
.m-split.m-in .w > span { translate: 0 0; }

/* ---------- Grid items: row-aware stagger ---------- */
html.motion .m-item:not(.m-in) { opacity: 0; }
html.motion .m-item.m-in { animation: item-in 1s var(--ease) calc(var(--i, 0) * 85ms) backwards; }

html.motion .m-item:not(.m-in) :is(.speaker__photo, .person__photo) { clip-path: inset(100% 0 0 0); }
html.motion .m-item.m-in :is(.speaker__photo, .person__photo) {
  animation: tide 1.3s var(--ease-io) calc(var(--i, 0) * 85ms + 80ms) backwards;
}
html.motion .m-item.m-in :is(.speaker__photo, .person__photo) img {
  animation: img-settle 1.8s var(--ease) calc(var(--i, 0) * 85ms + 80ms) backwards;
}

/* ---------- Four lenses: ripples widen from local to collaboration ---------- */
.lens { position: relative; overflow: hidden; isolation: isolate; }
.lens__ripple {
  position: absolute; top: -84px; right: -84px; z-index: -1;
  width: 228px; height: 228px; pointer-events: none;
  fill: none; stroke: var(--tiger); stroke-width: 1.2;
  transition: scale 0.9s var(--ease);
}
.lens__ring { opacity: 0.22; }
.lens__dot { fill: var(--tiger); stroke: none; }
.lens:hover .lens__ripple { scale: 1.08; }
html.motion .lens__ring { animation: ring-pulse 4.2s ease-in-out infinite; animation-delay: calc(var(--r, 0) * 0.42s); }
@keyframes ring-pulse { 0%, 100% { opacity: 0.16; } 35% { opacity: 0.72; } 70% { opacity: 0.16; } }

/* ---------- Programme: icons draw in, a boat travels the river ---------- */
.program { position: relative; }
.program__icon { transition: color 0.5s var(--ease); }
.program__day.is-current .program__icon { color: var(--accent); }
html.motion .program__day.m-item .program__icon > * { stroke-dasharray: 1 1.05; }
html.motion .program__day.m-item:not(.m-in) .program__icon > * { stroke-dashoffset: 1.05; }
html.motion .program__day.m-in .program__icon > * {
  animation: draw 1.8s var(--ease-io) calc(var(--i, 0) * 120ms + 300ms) backwards;
}
.program__river { display: none; }
@media (min-width: 961px) {
  html.motion .program__river {
    display: block; position: absolute; left: -1px; right: -1px; top: -1px; z-index: 2;
    height: 2px; pointer-events: none;
  }
  .program__river::before {
    content: ""; position: absolute; inset: 0; background: var(--tiger);
    transform: scaleX(var(--river, 0)); transform-origin: left center;
  }
  .program__boat {
    position: absolute; left: calc(var(--river, 0) * 100%); bottom: 3px;
    width: 58px; aspect-ratio: 130 / 110; translate: -50% 0;
    fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round;
    color: var(--ink); transform-origin: 50% 100%;
    animation: boat-bob 3.4s ease-in-out infinite;
  }
  @keyframes boat-bob {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-3px) rotate(2deg); }
  }
}

/* ---------- Media: play buttons ripple ---------- */
html.motion .media-feature__play { animation: play-pulse 2.6s var(--ease) infinite; }
@keyframes play-pulse {
  0% { box-shadow: 0 0 0 0 rgb(232 116 42 / 0.55); }
  70%, 100% { box-shadow: 0 0 0 1.25rem rgb(232 116 42 / 0); }
}

/* ==========================================================================
   Signature: scroll-driven temperature chart (NASA GISTEMP v4, 1880 to 2025)
   The heat scale runs from river teal through ochre and rust to ember (motion.js HEAT_STOPS).
   ========================================================================== */
.warming { --cool: #2F5D57; --warm: #87581A; --rust: #A3460C; --hot: #8A1F08; position: relative; background: var(--moon); color: var(--ink); }
.warming.is-scrolly { height: 300vh; }
.warming__sticky {
  position: relative; display: flex; flex-direction: column; justify-content: center;
  gap: clamp(1.25rem, 4vh, 2.75rem); padding: var(--section) 0; overflow: hidden;
}
.warming.is-scrolly .warming__sticky {
  position: sticky; top: 0; height: 100vh; height: 100svh;
  padding: calc(var(--header) + clamp(0.5rem, 2vh, 1.5rem)) 0 clamp(1.25rem, 4vh, 2.5rem);
}
.warming__top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 3rem; }
.warming__title { margin-top: 0.85rem; max-width: 12ch; text-wrap: balance; }
.warming__title em { font-style: normal; color: var(--accent); }
.warming__lede { max-width: 31rem; font-size: clamp(0.94rem, 1.2vw, 1.04rem); line-height: 1.6; color: var(--ink-soft); text-wrap: pretty; }

.warming__figure { position: relative; height: clamp(230px, 42vh, 440px); margin: 0 auto; }
.warming__figure:not(.is-live) { display: none; }
.warming.is-scrolly .warming__figure { flex: 1 1 0; height: auto; min-height: 170px; max-height: 480px; }

.wc { display: block; overflow: visible; }
.wc text { font-family: var(--font-display); font-size: 12.5px; font-weight: 600; fill: var(--ink-soft); font-variant-numeric: tabular-nums; }
.wc.is-compact text { font-size: 11px; }
.wc-grid line { stroke: var(--rule); stroke-width: 1; shape-rendering: crispEdges; }
.wc-grid .wc-zero { stroke: var(--rule-strong); }
.wc-grid .wc-paris { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 6 5; shape-rendering: auto; opacity: 0.75; transition: opacity 0.5s ease; }
.wc.is-near .wc-paris { opacity: 1; }
.wc .wc-paris-label { fill: var(--accent); font-weight: 700; letter-spacing: 0.02em; }
.wc .wc-zero-label { fill: var(--ink-soft); }
.wc-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.wc.is-compact .wc-line { stroke-width: 2; }

.wc-rec { opacity: 0; transition: opacity 0.3s ease; }
.wc-rec.on { opacity: 1; }
.wc-rec__dot { fill: var(--ink); stroke: var(--surface); stroke-width: 1.5; }
.wc-rec__ping { fill: none; stroke: var(--tiger); stroke-width: 1.5; opacity: 0; transform-box: fill-box; transform-origin: center; vector-effect: non-scaling-stroke; }
html.motion .wc-rec.ping .wc-rec__ping { animation: wc-ping 1.1s var(--ease) forwards; }

.wc-note { opacity: 0; transition: opacity 0.45s ease; }
.wc-note.on { opacity: 1; }
.wc .wc-note text { fill: var(--ink); font-weight: 700; }
.wc .wc-note--hot text { fill: var(--accent); }
.wc-note__ring { fill: none; stroke: var(--ink-soft); stroke-width: 1.25; }

.wc-leader { stroke: var(--rule-strong); stroke-width: 1; stroke-dasharray: 2 4; }
.wc-glass { fill: var(--rule); stroke: var(--rule-strong); stroke-width: 1.25; }
.wc-shine { stroke: var(--moon); stroke-width: 1.25; stroke-linecap: round; opacity: 0.6; }
.wc-shine-dot { fill: var(--moon); opacity: 0.6; }
.wc-tick { stroke: var(--rule-strong); stroke-width: 1; }
.wc-tick--major { stroke: var(--ink-soft); }
.wc .wc-tlabel { fill: var(--ink-soft); font-weight: 700; }
.wc .wc-tlabel--paris { fill: var(--accent); }
.wc-head__dot { stroke: var(--ink); stroke-width: 2; }
.wc-head__halo { fill: none; stroke: var(--ink); stroke-width: 1.25; opacity: 0; transform-box: fill-box; transform-origin: center; vector-effect: non-scaling-stroke; }
html.motion .wc-head__halo { animation: wc-pulse 2.4s ease-out infinite; }
@keyframes wc-pulse { from { transform: scale(1); opacity: 0.8; } to { transform: scale(3.4); opacity: 0; } }
@keyframes wc-ping { from { transform: scale(1); opacity: 0.95; } to { transform: scale(4.6); opacity: 0; } }

html.motion .warming__figure .wc-grid line { transform-box: fill-box; transform-origin: 0 50%; scale: 0 1; transition: scale 1.5s var(--ease); }
html.motion .warming__figure .wc-grid line:nth-child(2) { transition-delay: 0.08s; }
html.motion .warming__figure .wc-grid line:nth-child(3) { transition-delay: 0.16s; }
html.motion .warming__figure .wc-grid .wc-paris { transition: scale 1.5s var(--ease) 0.24s, opacity 0.5s ease; }
html.motion .warming__figure.m-in .wc-grid line { scale: 1 1; }
html.motion .warming__figure .wc-years,
html.motion .warming__figure .wc-axis,
html.motion .warming__figure .wc-thermo { opacity: 0; translate: 0 12px; transition: opacity 0.8s ease 0.3s, translate 1.1s var(--ease) 0.3s; }
html.motion .warming__figure.m-in .wc-years,
html.motion .warming__figure.m-in .wc-axis,
html.motion .warming__figure.m-in .wc-thermo { opacity: 1; translate: 0 0; }

.warming__foot { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.25rem 2.5rem; }
.warming__readout { display: grid; grid-template-columns: auto auto; justify-content: start; align-items: end; column-gap: 1.1rem; row-gap: 0.2rem; margin: 0; }
.warming__year {
  grid-row: 1 / span 2;
  font-family: var(--font-display); font-stretch: var(--narrow); font-weight: 800; font-size: clamp(3rem, 7.5vw, 5.5rem);
  line-height: 0.85; font-variant-numeric: tabular-nums;
}
.warming__anom {
  grid-column: 2; grid-row: 1;
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-display); font-stretch: var(--narrow); font-weight: 700; font-size: clamp(1.3rem, 2.4vw, 1.85rem);
  line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums;
}
.warming__swatch { display: inline-block; width: 0.75rem; height: 0.75rem; background: var(--tiger); transition: background 0.35s ease; }
.warming__vs { grid-column: 2; grid-row: 2; font-size: 0.86rem; line-height: 1.3; color: var(--ink-soft); }
.warming__note {
  grid-column: 1 / -1; grid-row: 3; min-height: 1.3em; margin-top: 0.6rem;
  font-family: var(--font-display); font-stretch: var(--wide); font-weight: 600; font-size: 0.72rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ink-soft);
}
.warming__key { display: flex; flex-direction: column; gap: 0.75rem; max-width: 21rem; }
.warming__legend {
  display: flex; flex-wrap: wrap; gap: 0.45rem 1.4rem; margin: 0; padding: 0; list-style: none;
  font-size: 0.86rem; color: var(--ink-soft);
}
.warming__legend li { display: inline-flex; align-items: center; gap: 0.55rem; }
.warming__lg { display: inline-block; flex: none; }
.warming__lg--line { width: 1.5rem; height: 3px; background: linear-gradient(90deg, var(--cool), var(--warm) 40%, var(--rust) 68%, var(--hot)); }
.warming__lg--dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px rgb(232 116 42 / 0.6); }
.warming__source { margin: 0; font-size: 0.8rem; line-height: 1.55; color: var(--ink-soft); }
.warming__source span { display: block; margin-top: 0.2rem; color: var(--ink); text-wrap: balance; }

@media (max-width: 700px) {
  .warming.is-scrolly { height: 260vh; }
  .warming.is-scrolly .warming__sticky { gap: clamp(0.9rem, 2.6vh, 1.5rem); }
  .warming__lede { font-size: 0.9rem; line-height: 1.55; }
  .warming__figure { height: clamp(210px, 34vh, 300px); }
  .warming__key { max-width: none; }
}
@media (max-height: 700px) {
  .warming.is-scrolly .warming__lede { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .intro { display: none !important; }
}
