/* nimbiweather.app: one stylesheet for every page. Mobile first.
 * Shared chapter layout (from the lab prototypes), then each chapter's scene, then the
 * hero, the bridges between chapters, the footer and the plain text pages. */

@font-face {
  font-family: "Oswald";
  src: url("fonts/oswald.woff2") format("woff2");
  font-weight: 200 700;
  font-display: swap;
}

/* Headlines: Kanit SemiBold (Latin subset). Small caps text (labels, wordmark, button) stays Oswald. */
@font-face {
  font-family: "Kanit";
  src: url("fonts/kanit-semibold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  --blue: #2E6FAE;
  --navy: #0F1F3B;
  --cream: #F3EAD3;
  --ink: #14223A;
  --accent: var(--blue);
  color-scheme: only light; /* opts out of browsers' forced dark mode: the palette is fixed */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 400 1.0625rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.display {
  font-family: "Kanit", "Arial", sans-serif;
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin: 0;
}

.kicker {
  font-family: "Oswald", "Arial Narrow", sans-serif;
  font-weight: 500;
  font-size: 0.8125rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 0 0 0.9rem;
  opacity: 0.8;
}

/* Intro and outro: plain paper blocks, so the pin is felt starting and ending. */
.block {
  min-height: 75vh;
  min-height: 75svh;
  display: grid;
  align-content: center;
  gap: 0.25rem;
  padding: 14vh 7vw;
  max-width: 44rem;
  margin: 0 auto;
}
.block h1 { font-size: clamp(4rem, 22vw, 9rem); color: var(--accent); }
.block h2 { font-size: clamp(2.6rem, 11vw, 5rem); color: var(--navy); }
.block p { margin: 0.6rem 0 0; max-width: 32rem; }
.block a { color: var(--accent); font-weight: 600; }
.cue { font-size: 1.6rem; color: var(--accent); }
.lab-nav { display: flex; gap: 1.2rem; flex-wrap: wrap; }

/* The chapter: 100 + 250 viewport heights; the stage pins for the 250.
 * No scroll anchoring inside: when a stage's words change height, the browser would otherwise
 * "correct" the scroll position to keep a pinned element still, which jumps the progress back. */
.chapter {
  position: relative;
  height: 350vh;
  height: 350svh;
  overflow-anchor: none;
}

.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  color: var(--cream);
  isolation: isolate;
  transition: color 0.6s ease;
}

/* Scene layers sit behind the content; overlays sit over the phone but under the words. */
.layer, .overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.overlay { z-index: 2; }

/* Content: phone above, copy below on narrow screens. */
.content {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  align-items: center;
  gap: 3svh;
  padding: calc(env(safe-area-inset-top) + 5svh) 6vw calc(env(safe-area-inset-bottom) + 6svh);
}

.phone-slot { position: relative; z-index: 1; min-height: 0; display: grid; place-items: center; }

.phone {
  --ph: min(56svh, 118vw, calc(100svh - 330px));
  --pw: calc(var(--ph) * 0.4925);
  --r: calc(var(--pw) * 0.14);
  --L: 260svh;
  position: relative;
  width: var(--pw);
  height: var(--ph);
}

/* Long hard diagonal shadow: the phone swept down-right, tangent to its rounded corners. */
.phone-shadow {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--pw) + var(--L));
  height: calc(var(--ph) + var(--L));
  background: var(--phone-shadow, rgba(4, 10, 26, 0.26));
  clip-path: polygon(
    calc(var(--pw) - var(--r) * 0.293) calc(var(--r) * 0.293),
    calc(var(--pw) - var(--r) * 0.293 + var(--L)) calc(var(--r) * 0.293 + var(--L)),
    calc(var(--r) * 0.293 + var(--L)) calc(var(--ph) - var(--r) * 0.293 + var(--L)),
    calc(var(--r) * 0.293) calc(var(--ph) - var(--r) * 0.293)
  );
  pointer-events: none;
}

.bezel {
  position: relative;
  height: 100%;
  padding: calc(var(--pw) * 0.03);
  border-radius: var(--r);
  background: #0C0F16;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

.screen {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: calc(var(--r) - var(--pw) * 0.03);
  background: #1A2B44;
}
.screen img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.screen img.on { opacity: 1; }

/* Above the phone's long shadow and the overlays. */
.copy { position: relative; z-index: 3; text-align: center; width: 100%; max-width: 34rem; }
.copy .display { text-shadow: 0 0.04em 0 var(--text-shadow, rgba(6, 12, 28, 0.35)); }

.lines { display: grid; }
.line {
  grid-area: 1 / 1;
  opacity: 0;
  transform: translate3d(0, 0.25em, 0);
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.line.on { opacity: 1; transform: none; }
.line h2 { font-size: clamp(2.1rem, 9.4vw, 3.7rem); text-wrap: balance; }
.line .sub { margin: 0.55rem 0 0; font-size: 1rem; opacity: 0.85; }

.dots {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 1.1rem;
}
.dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  transition: opacity 0.3s, transform 0.3s;
}
.dots span.on { opacity: 1; transform: scale(1.3); }

.hint {
  display: inline-block;
  margin: 1rem 0 0;
  padding: 0.35rem 0.85rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s, visibility 0s 0.4s;
}
.hint.show { opacity: 0.8; visibility: visible; transition: opacity 0.4s; }

/* Wide: side by side. */
@media (min-width: 820px) and (min-aspect-ratio: 1/1) {
  .content {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
    gap: 4vw;
    padding: 6svh 7vw;
  }
  .phone { --ph: min(80svh, 760px); }
  .copy { text-align: left; justify-self: start; max-width: none; }
  .line h2 { font-size: clamp(2.8rem, 4.6vw, 5.4rem); text-wrap: balance; }
  .dots { justify-content: flex-start; }
}

/* Reduced motion: no pin. The engine turns the stage into three stacked static panels. */
.chapter.static { height: auto; background: none !important; }
.chapter.static .stage { position: relative; min-height: 560px; }
.chapter.static .live-only { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .chapter { height: auto; }
  .stage { position: relative; }
}

/* ---- Water: cloudy, rain, storm ---- */

#water { background: #2E6FAE; }
#water .stage { --cloud: #F6EEDB; --shade: #C8D3DE; }

#water .cloud {
  position: absolute;
  left: 0;
  top: 0;
  width: 200px;
  transform: translate3d(-200vw, 0, 0);
  will-change: transform;
}
#water .cloud svg { display: block; width: 100%; height: auto; overflow: visible; }
#water .cloud .b { fill: var(--cloud); }
#water .cloud .s { fill: var(--shade); }

/* Storm alert skyline layers, flat parallax. */
#water .city { opacity: 0; }
#water .city img {
  position: absolute;
  bottom: calc(5svh - 1px);
  height: auto;
  will-change: transform;
}
#water .city .far  { left: 0; right: 0; margin: 0 auto; width: clamp(380px, 96vw, 900px); }
#water .city .mid  { left: -4%; width: clamp(300px, 62vw, 760px); }
#water .city .near { right: -3%; width: clamp(220px, 40vw, 560px); }
#water .city .ground {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 5svh;
  background: #17243A;
}

#water .flash { background: #C9B8FF; opacity: 0; }

/* ---- Sky: noon, golden hour, night. The world is one canvas. ---- */

#sky { background: #E8622B; }
/* The phone's shadow is drawn in the world, in the same light as everything else. */
#sky .phone-shadow { display: none; }

/* Golden hour: the sky turns light, so the words turn dark. */
#sky .stage[data-stage="1"] { color: #3A1A10; --text-shadow: rgba(255, 226, 170, 0.45); }

/* ---- Air: fog, wind, freezing ---- */

#air { background: #7A929C; }

/* Fog: dark words on pale air. Wind: cream on the storm. Freezing: navy on ice. */
#air .stage[data-stage="0"] { color: #2C3B33; --text-shadow: rgba(255, 255, 255, 0.35); --phone-shadow: rgba(40, 56, 50, 0.18); }
#air .stage[data-stage="2"] { color: #12304D; --text-shadow: rgba(255, 255, 255, 0.45); --phone-shadow: rgba(30, 70, 110, 0.22); }

/* Wind alert layers: painterly backdrop for the wind stage. */
#air .wind { opacity: 0; }
#air .wind img { position: absolute; height: auto; }
#air .wind .wind-sky { inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
#air .wind .wind-houses { right: -4%; bottom: calc(6svh - 2px); width: clamp(300px, 62vw, 760px); }
#air .wind .wind-houses-left { left: 8%; bottom: calc(6svh - 2px); width: clamp(240px, 46vw, 620px); }
#air .wind .wind-tree {
  left: -6%;
  bottom: calc(6svh - 4px);
  height: 74%;
  width: auto;
  transform-origin: 30% 100%;
  will-change: transform;
}
#air .wind-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 6svh; background: #1E2C36; }

@media (min-width: 820px) and (min-aspect-ratio: 1/1) {
  #air .wind .wind-houses-left { left: 22%; }
}


/* ---- Hero: a flat blue poster; the canvas behind paints the sun and the long shadows ---- */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: max(100svh, 620px);
  background: var(--blue);
  color: var(--cream);
  overflow: hidden;
  isolation: isolate;
}
.hero-sky { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.hero-in {
  min-height: inherit;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  justify-items: center;
  gap: 3svh;
  padding: calc(env(safe-area-inset-top) + 4svh) 7vw calc(env(safe-area-inset-bottom) + 7svh);
}
.wordmark {
  justify-self: start;
  margin: 0;
  font-family: "Oswald", "Arial Narrow", sans-serif;
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.hero-copy { text-align: center; max-width: 36rem; }
.hero-copy h1 { font-size: clamp(2.6rem, 12.6vw, 7rem); text-wrap: balance; }
.hero-copy h1 span { display: inline-block; }
.hero-sub { margin: 1.3rem 0 0; font-size: 1.0625rem; opacity: 0.92; }
.pill {
  display: inline-block;
  margin-top: 1.3rem;
  padding: 0.85rem 1.8rem;
  border-radius: 999px;
  background: var(--cream);
  color: var(--navy);
  font-family: "Oswald", "Arial Narrow", sans-serif;
  font-weight: 600;
  font-size: 1.125rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
}
.pill:hover { background: #fff; }
.pill:focus-visible { outline: 3px solid var(--cream); outline-offset: 4px; }

/* The phone: a turned handset with the screen composited in, one image (assets/img/hero-phone.webp). */
.hero-art {
  /* On a phone the whole poster fits the first screen: the words take about 430px. */
  --ph: clamp(300px, calc(100svh - 450px), min(110vw, 580px));
  --pw: calc(var(--ph) * 0.5736);
  position: relative;
  align-self: center;
  width: var(--pw);
  height: var(--ph);
  margin-left: calc(var(--pw) * 0.42);
}
.hero-phone { display: block; width: 100%; height: 100%; }
.hero-nimbi {
  position: absolute;
  z-index: 1;
  left: -58%;
  top: 2%;
  width: 64%;
  height: auto;
}

@media (min-width: 820px) and (min-aspect-ratio: 1/1) {
  .hero-in {
    grid-template-columns: 1.15fr 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0 4vw;
    padding: 4svh 7vw 6svh;
  }
  .wordmark { grid-column: 1 / -1; }
  .hero-copy { justify-self: start; align-self: center; text-align: left; max-width: 40rem; padding-bottom: 6svh; }
  .hero-copy h1 { font-size: clamp(3.6rem, 6.1vw, 7rem); }
  .hero-art { --ph: min(78svh, 740px); margin-left: calc(var(--pw) * 0.42); }
}

/* ---- Between chapters: one line, over the last sky of one chapter turning into the next.
 * Not pinned; the canvas behind animates with the scroll (assets/site.js, Bridges). ---- */
.bridge {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  min-height: 90vh;
  min-height: 90svh;
  display: grid;
  place-items: center;
  padding: 10svh 7vw;
  color: var(--cream);
  text-align: center;
}
.bridge-fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.bridge h2 { font-size: clamp(2.2rem, 9vw, 4.2rem); text-shadow: 0 0.04em 0 rgba(6, 12, 28, 0.3); }
.bridge .turn { display: inline-block; transform-origin: 15% 85%; will-change: transform; }
.bridge-sky { background: linear-gradient(#0A1730, #E8622B); place-items: end center; padding-bottom: 19svh; } /* under the rainbow */
.bridge-air { background: linear-gradient(#0F1F3B, #7A929C); }
.bridge-end { background: linear-gradient(#A9CBE6, #0F1F3B); }

/* ---- Footer: Nimbi asleep ---- */
.foot {
  background: var(--navy);
  color: var(--cream);
  text-align: center;
  padding: 16svh 7vw calc(env(safe-area-inset-bottom) + 6svh);
}
.sleeper { position: relative; width: clamp(150px, 42vw, 240px); margin: 0 auto 2.4rem; }
.sleeper img { display: block; width: 100%; height: auto; animation: breathe 5s ease-in-out infinite; transform-origin: 50% 90%; }
.zz {
  position: absolute;
  top: -8%;
  right: 4%;
  font-family: "Oswald", "Arial Narrow", sans-serif;
  font-weight: 500;
  color: var(--cream);
  opacity: 0;
  animation: zz 6s ease-out infinite;
}
.zz:nth-child(3) { font-size: 1.1rem; animation-delay: 2s; }
.zz:nth-child(4) { font-size: 1.5rem; animation-delay: 4s; }
.zz:nth-child(2) { font-size: 0.85rem; }
@keyframes breathe { 50% { transform: scale(1.025, 0.985); } }
@keyframes zz {
  0% { opacity: 0; transform: translate(0, 0); }
  20% { opacity: 0.8; }
  100% { opacity: 0; transform: translate(1.6rem, -3.2rem); }
}
.foot h2 { font-size: clamp(2.6rem, 11vw, 4.6rem); }
.foot .promise { margin: 0.9rem 0 0; font-size: 1.125rem; }
.foot nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem 1.6rem; margin: 3.2rem 0 0; }
.foot a { color: var(--cream); text-underline-offset: 0.2em; }
.foot .fine { margin: 2rem 0 0; font-size: 0.8125rem; opacity: 0.65; }

@media (prefers-reduced-motion: reduce) {
  .sleeper img { animation: none; }
  .zz { animation: none; opacity: 0.7; }
  .zz:nth-child(2) { transform: translate(0, 0.6rem); }
  .zz:nth-child(3) { transform: translate(0.8rem, -1.2rem); }
  .zz:nth-child(4) { transform: translate(1.6rem, -3rem); }
}

/* ---- Text pages: privacy, support ---- */
.page-top {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1.2rem 7vw;
  background: var(--blue);
}
.page-top a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--cream);
  text-decoration: none;
  font-family: "Oswald", "Arial Narrow", sans-serif;
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.page-top img { width: 2.2rem; height: 2.2rem; border-radius: 22%; }
.doc { max-width: 43rem; margin: 0 auto; padding: 9svh 1.5rem 12svh; }
.doc h1 { font-size: clamp(2.4rem, 10vw, 3.8rem); color: var(--blue); }
.doc .updated { margin: 0.8rem 0 2.4rem; opacity: 0.7; font-size: 0.9375rem; }
.doc h2 {
  font-family: "Kanit", "Arial", sans-serif;
  font-weight: 600;
  font-size: 1.45rem;
  line-height: 1.1;
  color: var(--navy);
  margin: 2.6rem 0 0.6rem;
}
.doc p, .doc li { line-height: 1.6; }
.doc ul { padding-left: 1.2rem; }
.doc li + li { margin-top: 0.5rem; }
.doc a { color: var(--blue); font-weight: 600; text-underline-offset: 0.15em; }
.doc dt { font-weight: 700; margin-top: 1.4rem; }
.doc dd { margin: 0.3rem 0 0; line-height: 1.6; }
.page-foot { text-align: center; padding: 2.4rem 7vw 3rem; background: var(--navy); color: var(--cream); font-size: 0.875rem; }
.page-foot a { color: var(--cream); margin: 0 0.7rem; text-underline-offset: 0.2em; }
.page-foot p { margin: 0.4rem 0; }
.page-foot .fine { opacity: 0.65; }
