/* ==========================================================================
   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(--green-deep);
  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(--mustard);
  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 ---------- */
.hero__title .ln { display: block; overflow: hidden; padding: 0 0.1em 0.12em; margin: 0 -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.07em;
  width: 100%; height: auto; overflow: visible;
  fill: none; stroke: var(--mustard); stroke-width: 4; stroke-linecap: round;
}
.hero__wave path { stroke-dasharray: 1 1.05; stroke-dashoffset: 0; }

html.motion .hero { background: var(--green-deep); }
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 0.05em 0.14em; margin: 0 -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;
}

/* ---------- About: the image rises like the tide ---------- */
html.motion .about:not(.in) .about__img { clip-path: inset(100% 0 0 0); }
html.motion .about.in .about__img { animation: tide 1.6s var(--ease-io) 0.1s backwards; }
html.motion .about.in .about__img img { animation: img-settle 2.2s var(--ease) 0.1s backwards; }
html.motion .about:not(.in) .about__badge { opacity: 0; }
html.motion .about.in .about__badge { animation: rise-in 1s var(--ease) 0.85s 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(--mustard); stroke-width: 1.2;
  transition: scale 0.9s var(--ease);
}
.lens__ring { opacity: 0.22; }
.lens__dot { fill: var(--mustard); 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(--coral); }
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(--green);
    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(--green); 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 rgba(250, 197, 90, 0.55); }
  70%, 100% { box-shadow: 0 0 0 1.25rem rgba(250, 197, 90, 0); }
}

/* ==========================================================================
   Signature: warming stripes (NASA GISTEMP v4, 1880 to 2025)
   ========================================================================== */
.warming { position: relative; background: var(--green-deep); color: var(--paper); }
.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: 14ch; text-wrap: balance; }
.warming__title em { font-style: normal; color: var(--mustard); }
.warming__lede { max-width: 31rem; font-size: clamp(0.92rem, 1.2vw, 1.02rem); line-height: 1.6; color: rgba(251, 250, 246, 0.74); text-wrap: pretty; }

.warming__figure { position: relative; height: clamp(150px, 36vh, 400px); margin: 0; }
.warming__figure:empty { display: none; }
.warming__stripes { position: absolute; inset: 0; display: flex; }
.warming__stripes i { flex: 1 1 0; min-width: 0; background: var(--c); box-shadow: 0.6px 0 0 var(--c); transform-origin: 50% 100%; }
html.motion .warming__stripes i { transform: scaleY(0.035); opacity: 0.22; transition: transform 0.8s var(--ease), opacity 0.5s ease; }
html.motion .warming__stripes i.on { transform: scaleY(1); opacity: 1; }

.warming__trace {
  position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none;
  clip-path: inset(-12px calc(100% - var(--p, 1) * 100%) -12px 0);
  transition: clip-path 0.35s var(--ease);
}
.warming__trace path { fill: none; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.warming__trace .halo { stroke: var(--green-deep); stroke-width: 5; opacity: 0.45; }
.warming__trace .line { stroke: var(--paper); stroke-width: 1.75; }

.warming__marker {
  position: absolute; top: 0; bottom: 0; left: calc(var(--x, 1) * 100%); width: 1px;
  background: rgba(251, 250, 246, 0.55); pointer-events: none;
  transition: left 0.35s var(--ease);
}
.warming__dot {
  position: absolute; left: 50%; top: calc(var(--y, 0) * 100%);
  width: 10px; height: 10px; margin: -5px 0 0 -5px;
  background: var(--paper); box-shadow: 0 0 0 3px var(--green-deep);
  transition: top 0.35s var(--ease);
}

.warming__foot { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 2.5rem; }
.warming__readout { display: grid; grid-template-columns: auto auto; justify-content: start; align-items: baseline; gap: 0.35rem 1.1rem; }
.warming__year {
  font-family: var(--font-display); font-weight: 900; font-size: clamp(2.4rem, 6vw, 4.5rem);
  line-height: 0.9; letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.warming__anom {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(1.05rem, 2vw, 1.5rem);
  color: var(--mustard); font-variant-numeric: tabular-nums;
}
.warming__swatch { display: inline-block; width: 0.75rem; height: 0.75rem; background: var(--coral); transition: background 0.35s ease; }
.warming__note {
  grid-column: 1 / -1; min-height: 1.3em;
  font-family: var(--font-display); font-weight: 700; font-size: 0.7rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: rgba(251, 250, 246, 0.7);
}
.warming__source { max-width: 19rem; font-size: 0.76rem; line-height: 1.55; color: rgba(251, 250, 246, 0.58); }
.warming__source span { display: block; margin-top: 0.2rem; color: rgba(251, 250, 246, 0.82); }

@media (max-width: 700px) {
  .warming.is-scrolly { height: 260vh; }
  .warming__figure { height: clamp(140px, 30vh, 260px); }
  .warming__source { max-width: none; }
}
@media (max-height: 700px) {
  .warming.is-scrolly .warming__lede { display: none; }
  .warming__figure { height: clamp(120px, 30vh, 260px); }
}

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