/* The Batik Forest. One accent colour (hibiscus red), cream on deep forest green. */
:root {
  --ink: #0f2219;
  --forest: #142a20;
  --moss: #26443a;
  --cream: #f2ead8;
  --cream-2: rgba(242, 234, 216, 0.8);
  --cream-3: rgba(242, 234, 216, 0.62);
  --line: rgba(242, 234, 216, 0.14);
  --red: #c42d25;
  --red-press: #a8231d;
  --serif: 'Gambarino', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --sans: 'Switzer', 'Segoe UI', system-ui, sans-serif;
  --gutter: clamp(1rem, 4vw, 4rem);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { background: var(--ink); color-scheme: dark; -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font: 400 1.0625rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
html.is-viewing,
html.is-viewing body { overflow: hidden; }
img { max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cream); outline-offset: 3px; }
.forest:focus { outline: none; }

.skip {
  position: fixed; left: 1rem; top: 1rem; z-index: 80;
  padding: 0.6rem 1rem; border-radius: 999px;
  background: var(--cream); color: var(--ink); text-decoration: none;
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

.label {
  margin: 0;
  font: 500 0.75rem/1.3 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cream-3);
}

/* ---------- buttons ---------- */

.pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 1.4rem;
  border: 0; border-radius: 999px;
  background: var(--red); color: #fff8ee;
  font: 500 1rem/1 var(--sans);
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: transform 0.14s var(--ease), background-color 0.16s var(--ease);
}
.pill:hover { background: var(--red-press); }
.pill:active { transform: scale(0.97); }
.pill--quiet { background: var(--moss); color: var(--cream); }
.pill--quiet:hover { background: #2f5146; }
.pill--small { min-height: 40px; padding: 0 1.05rem; font-size: 0.875rem; }
.pill--big { min-height: 56px; padding: 0 2rem; font-size: 1.0625rem; }

.textlink {
  padding: 0; border: 0; background: none; cursor: pointer;
  font: 500 1rem/1.4 var(--sans); color: var(--cream);
  text-decoration: underline; text-underline-offset: 0.3em; text-decoration-color: rgba(242, 234, 216, 0.4);
  transition: text-decoration-color 0.16s;
}
.textlink:hover { text-decoration-color: var(--cream); }

/* ---------- header ---------- */

.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(0.75rem, env(safe-area-inset-top)) var(--gutter) 0.75rem;
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.bar__name {
  font: 400 1.25rem/1 var(--serif); text-decoration: none;
  text-shadow: 0 1px 12px rgba(6, 16, 11, 0.8);
  opacity: 0; transform: translateY(-6px);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}
.is-past-hero .bar__name { opacity: 1; transform: none; }
.bar .pill { margin-left: auto; }
.bar::before {
  content: ''; position: absolute; inset: 0 0 -2.5rem 0; z-index: -1; pointer-events: none;
  background: linear-gradient(rgba(10, 24, 17, 0.7), rgba(10, 24, 17, 0));
  transition: background-color 0.3s var(--ease);
}
.is-below-forest .bar::before { bottom: 0; background: rgba(15, 34, 25, 0.94); }
.bar { transition: opacity 0.3s var(--ease); }
.is-viewing .bar { opacity: 0; pointer-events: none; }
.is-viewing .bar > * { pointer-events: none; }

/* ---------- the forest ---------- */

.forest { position: relative; height: 320svh; background: var(--ink); }
.stage {
  position: sticky; top: 0;
  height: 100svh; overflow: hidden; overflow: clip;
  background: #1d3a2d;
  contain: paint;
}
/* the far forest: two real photographs, canopy above and understory below, one fading into the other */
.sky { position: absolute; left: 0; top: 0; width: 100%; height: 114%; will-change: transform; }
.sky__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.sky__floor { opacity: 0; object-position: 50% 70%; }
.layer { position: absolute; left: 0; top: 0; width: 100%; pointer-events: none; will-change: transform; }
/* the same heights main.js sets (stage height x (1 + depth)), so nothing jumps when it does */
.layer[data-layer='1'] { height: 122%; }
.layer[data-layer='2'] { height: 145%; }
.layer[data-layer='3'] { height: 170%; }
.layer[data-layer='4'] { height: 200%; }
.layer[data-layer='5'] { height: 238%; }

.rays {
  position: absolute; left: 0; top: -12%; width: 100%; height: 150%;
  pointer-events: none; mix-blend-mode: screen; will-change: transform; opacity: 0.55;
}
.rays i {
  position: absolute; top: -10%; height: 115%;
  background: linear-gradient(to bottom, rgba(255, 238, 190, 0.78), rgba(255, 238, 190, 0.22) 55%, rgba(255, 238, 190, 0) 92%);
  transform-origin: 50% 0;
  filter: blur(8px);
  animation: ray 10s ease-in-out infinite alternate;
}
.rays i:nth-child(1) { left: 24%; width: 5%; --r: 22deg; animation-duration: 11s; }
.rays i:nth-child(2) { left: 41%; width: 9%; --r: 18deg; animation-duration: 13s; animation-delay: -4s; }
.rays i:nth-child(3) { left: 58%; width: 6%; --r: 20deg; animation-duration: 9s; animation-delay: -2s; }
.rays i:nth-child(4) { left: 70%; width: 11%; --r: 16deg; animation-duration: 15s; animation-delay: -7s; }
.rays i:nth-child(5) { left: 86%; width: 4%; --r: 21deg; animation-duration: 10s; animation-delay: -5s; }
@keyframes ray {
  from { transform: rotate(var(--r)) translateX(-6%); opacity: 0.5; }
  to { transform: rotate(calc(var(--r) - 3deg)) translateX(6%); opacity: 1; }
}

.flyby { position: absolute; inset: 0; pointer-events: none; will-change: transform; }
/* the hornbill: 12 frames of a wingbeat rendered in Blender, played as a strip */
.hornbill {
  position: absolute; left: 0; top: 0; width: 140px; aspect-ratio: 300 / 340;
  background: url('../img/anim/hornbill.webp') 0 0 / 1200% 100% no-repeat;
  animation: hornbill-beat 0.85s steps(12) infinite;
  filter: drop-shadow(0 10px 18px rgba(4, 12, 8, 0.35));
}
@keyframes hornbill-beat { to { background-position: 109.0909% 0; } }

.deep { position: absolute; inset: 0; background: linear-gradient(rgba(8, 20, 14, 0.2), rgba(8, 20, 14, 0.85)); opacity: 0; pointer-events: none; }
.dim { position: absolute; inset: 0; background: #08140e; opacity: 0; pointer-events: none; }
.veil { position: absolute; inset: 0; background: #07120d; opacity: 0; pointer-events: none; }

.cloth {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}
.cloth.is-grabbing { cursor: grabbing !important; }

.layer--near,
.layer--front { pointer-events: none; }
.sway { position: absolute; pointer-events: none; }
.sway__in { width: 100%; animation: sway 6s ease-in-out infinite alternate; }
.sway__in img { display: block; width: 100%; height: auto; user-select: none; }
@keyframes sway {
  from { transform: rotate(calc(var(--amp) * -1)); }
  to { transform: rotate(var(--amp)); }
}

/* the title */
.hero {
  position: absolute; left: var(--gutter); right: var(--gutter);
  top: clamp(4.75rem, 11svh, 8rem);
  max-width: 44rem;
  pointer-events: none;
  opacity: var(--fade, 1);
}
/* a soft shade behind the words, no box */
.hero::before {
  content: ''; position: absolute; z-index: -1;
  inset: -60% -40% -70% -30%;
  background: radial-gradient(closest-side, rgba(8, 22, 15, 0.86), rgba(8, 22, 15, 0.6) 55%, rgba(8, 22, 15, 0));
}
.hero { text-shadow: 0 1px 14px rgba(6, 16, 11, 0.75), 0 0 2px rgba(6, 16, 11, 0.5); }
.hero__kicker { color: var(--cream); margin-bottom: 0.9rem; text-shadow: 0 0 10px rgba(6, 16, 11, 0.95), 0 1px 3px rgba(6, 16, 11, 0.9); }
.hero__title {
  margin: 0;
  font: 400 clamp(3.25rem, 13.5vw, 6.75rem)/0.92 var(--serif);
  letter-spacing: -0.02em;
}
.hero__title .line { display: inline-block; overflow: hidden; padding-bottom: 0.08em; vertical-align: top; }
.hero__title .line > span { display: inline-block; }
.hero__sub { margin: 1rem 0 0; max-width: 24rem; color: var(--cream); font-weight: 500; }
@media (max-height: 690px) and (max-width: 700px) { .hero__sub { display: none; } }
@media (min-width: 900px) {
  .hero__title { font-size: clamp(4rem, 6.6vw, 6.75rem); }
}

.hint {
  position: absolute; left: 50%; bottom: max(1.25rem, env(safe-area-inset-bottom));
  margin: 0; width: max-content; max-width: calc(100% - 2rem);
  transform: translateX(-50%);
  pointer-events: none;
}
.hint span {
  display: block; padding: 0.6rem 1rem; border-radius: 999px;
  background: rgba(10, 24, 17, 0.72);
  font: 500 0.875rem/1.3 var(--sans); color: var(--cream); text-align: center;
}
.hint--cue { opacity: 0; transition: opacity 0.3s var(--ease); }
.hint--cue.is-on { opacity: 1; transition: opacity 0.6s var(--ease) 0.6s; } /* waits for the first hint to fade */
.hint--cue span::after {
  content: ''; display: inline-block; width: 0.5em; height: 0.5em; margin-left: 0.6em;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-0.2em) rotate(45deg);
}

/* ---------- the forest floor ---------- */

.floor { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; }
.floor__copy {
  position: absolute; left: var(--gutter); top: clamp(4.5rem, 11svh, 7rem);
  width: min(26rem, 58vw);
  opacity: 0;
  text-shadow: 0 1px 12px rgba(6, 16, 11, 0.8), 0 0 2px rgba(6, 16, 11, 0.6);
}
.floor__copy::before {
  content: ''; position: absolute; z-index: -1; inset: -45% -45% -40% -30%;
  background: radial-gradient(closest-side, rgba(8, 22, 15, 0.84), rgba(8, 22, 15, 0.55) 60%, rgba(8, 22, 15, 0));
}
.floor__title { margin: 0; font: 400 clamp(1.75rem, 7vw, 2.75rem)/1.05 var(--serif); letter-spacing: -0.01em; }
.floor__line { margin: 0.6rem 0 0; color: var(--cream); font-size: 0.9375rem; font-weight: 500; }
.notes { display: grid; gap: 0.7rem; margin-top: 0.9rem; }
.note {
  margin: 0;
  padding-left: 0.8rem; border-left: 2px solid var(--red);
  font-size: 0.9375rem; line-height: 1.5; color: var(--cream);
}
.note__name { display: block; font: 400 1.25rem/1.3 var(--serif); color: var(--cream); }

.bloom { position: absolute; }
.bloom__art { position: relative; aspect-ratio: 1; }
.bloom__ground, .bloom__cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.perch { position: absolute; width: 1px; height: 1px; pointer-events: none; }
.bloom--raya { right: -3%; top: 13%; width: min(40vw, 260px); }
.bloom--rafflesia { left: 0; bottom: -4%; width: min(100vw, 600px); }
@media (min-width: 900px) {
  .floor__copy { top: 16%; width: 26rem; }
  .bloom--raya { right: 7%; top: 12%; width: min(27vw, 380px); }
  .bloom--rafflesia { left: 26%; bottom: -5%; width: min(40vw, 600px); }
}

/* without WebGL: flat cloths that drift */
.fallback { position: absolute; inset: 0; }
.fallback__cloth {
  position: absolute; width: clamp(120px, 19vw, 240px); aspect-ratio: 1;
  padding: clamp(6px, 1vw, 12px); border: 0; background: #3a1f24; cursor: pointer;
  box-shadow: 0 20px 40px -18px rgba(0, 0, 0, 0.6);
  animation: drift 7s ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * -1.7s);
}
.fallback__cloth img { display: block; width: 100%; height: 100%; object-fit: cover; }
.fallback__cloth:nth-child(1) { left: 6%; top: 42%; }
.fallback__cloth:nth-child(2) { left: 29%; top: 50%; }
.fallback__cloth:nth-child(3) { left: 53%; top: 40%; }
.fallback__cloth:nth-child(4) { left: 76%; top: 49%; }
@media (max-width: 780px) {
  .fallback__cloth { width: 40vw; }
  .fallback__cloth:nth-child(1) { left: 6%; top: 36%; }
  .fallback__cloth:nth-child(2) { left: 52%; top: 42%; }
  .fallback__cloth:nth-child(3) { left: 8%; top: 60%; }
  .fallback__cloth:nth-child(4) { left: 54%; top: 66%; }
}
@keyframes drift {
  from { transform: translateY(-8px) rotate(-3deg); }
  to { transform: translateY(8px) rotate(3deg); }
}

/* ---------- the four cloths ---------- */

.cloths { position: relative; padding: clamp(5rem, 12vw, 9rem) var(--gutter) clamp(4rem, 9vw, 7rem); }
.cloths::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 9rem; background: linear-gradient(#1b382a, var(--ink)); pointer-events: none; }
.cloths > * { position: relative; }
.cloths__head { max-width: 72rem; margin: 0 auto clamp(3rem, 7vw, 5rem); }
.section-title { margin: 0; font: 400 clamp(2.25rem, 7vw, 4rem)/1 var(--serif); letter-spacing: -0.015em; }
.cloths__lede { margin: 1rem 0 0; max-width: 32rem; color: var(--cream-2); }
.cloths__list {
  list-style: none; margin: 0 auto; padding: 0;
  max-width: 72rem;
  display: grid; gap: 4rem clamp(2rem, 5vw, 4.5rem);
}
@media (min-width: 760px) {
  .cloths__list { grid-template-columns: 1fr 1fr; }
  .piece:nth-child(even) { margin-top: 7rem; }
}
.piece__img {
  display: block; width: 100%; padding: 0; border: 0; background: var(--forest);
  aspect-ratio: 1; overflow: hidden; border-radius: 4px; cursor: zoom-in;
}
.piece__img img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.7s var(--ease); }
.piece__img:hover img { transform: scale(1.035); }
.piece__text { margin-top: 1.25rem; max-width: 30rem; }
.piece__title { margin: 0.35rem 0 0.5rem; font: 400 clamp(1.75rem, 4vw, 2.25rem)/1.1 var(--serif); }
.piece__text > p:not(.label) { margin: 0 0 0.9rem; color: var(--cream-2); }

.contact {
  padding: clamp(4rem, 10vw, 8rem) var(--gutter);
  border-top: 1px solid var(--line);
  text-align: center;
}
.contact__line { margin: 1rem auto 2rem; max-width: 28rem; color: var(--cream-2); }

.foot { padding: 2rem var(--gutter) max(2.5rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.foot p { margin: 0 auto; max-width: 72rem; font-size: 0.8125rem; line-height: 1.6; color: var(--cream-3); }
.foot p + p { margin-top: 0.6rem; }
.foot__k { color: var(--cream-2); font-weight: 500; margin-right: 0.35em; }

/* ---------- butterflies ---------- */

.flutter { position: fixed; inset: 0; z-index: 20; width: 100%; height: 100%; pointer-events: none; }

/* ---------- the viewer ---------- */

.viewer { position: fixed; inset: 0; z-index: 50; }
.viewer[hidden] { display: none; }
.viewer__scrim { position: absolute; inset: 0; background: rgba(7, 18, 13, 0.94); }
.viewer.is-from-cloth .viewer__scrim { background: transparent; }
.viewer__frame {
  position: relative; height: 100%;
  overflow-y: auto; overscroll-behavior: contain;
  display: grid; justify-items: center; align-content: start; gap: 1.5rem;
  padding: max(4.5rem, calc(env(safe-area-inset-top) + 3.5rem)) var(--gutter) 2.5rem;
  pointer-events: none;
}
.viewer__frame > * { pointer-events: auto; }
.viewer__media {
  position: relative;
  width: min(100%, 58svh, 34rem); aspect-ratio: 1;
  touch-action: none; cursor: crosshair;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.viewer__img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 30px 70px -24px rgba(0, 0, 0, 0.7);
}
.loupe {
  position: absolute; left: 0; top: 0;
  width: clamp(130px, 36vw, 200px); aspect-ratio: 1; border-radius: 50%;
  background-repeat: no-repeat; background-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(242, 234, 216, 0.92), 0 18px 40px rgba(0, 0, 0, 0.5);
  opacity: 0; transition: opacity 0.18s; pointer-events: none; will-change: transform;
}
.loupe.is-on { opacity: 1; }
.viewer__text { width: min(100%, 34rem); }
.viewer__title { margin: 0.4rem 0 0.75rem; font: 400 clamp(2rem, 7vw, 3rem)/1.05 var(--serif); letter-spacing: -0.01em; }
.viewer__story { margin: 0; color: var(--cream-2); }
.viewer__tip { margin-top: 1rem; }
.viewer__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }
.viewer__credit { margin: 1.25rem 0 0; font-size: 0.8125rem; color: var(--cream-2); }
.viewer__tip { color: var(--cream-2); }
.viewer__close {
  position: fixed; z-index: 3;
  top: max(0.85rem, env(safe-area-inset-top)); right: max(0.85rem, env(safe-area-inset-right));
  width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--moss); color: var(--cream); cursor: pointer;
  transition: transform 0.14s var(--ease), background-color 0.16s;
}
.viewer__close:hover { background: #2f5146; }
.viewer__close:active { transform: scale(0.94); }
.viewer__close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
@media (min-width: 900px) {
  .viewer__frame {
    grid-template-columns: auto minmax(0, 24rem);
    align-content: center; align-items: center; justify-content: center;
    gap: clamp(2.5rem, 5vw, 4.5rem);
    padding: 2rem var(--gutter);
  }
  .viewer__media { width: min(74svh, 42vw, 46rem); }
}

.curtain { position: fixed; inset: 0; z-index: 60; background: var(--ink); pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .sway__in, .rays i, .fallback__cloth, .hornbill { animation: none; }
}
