/* ============================================================
   STYLE — layout, base element styles, BEM components
   ============================================================ */

/* ---- Reset & base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Font tokens — swap the whole site's type here.
   display: titles, headings, nav, pills, labels
   body:    anything meant to be read (paragraphs, excerpts, notes, lists) */
:root {
  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'Newsreader', Georgia, serif;
}

body {
  background-color: #0d1630; /* overridden per theme via data-theme; default matches night */
  font-family: var(--font-display);
}

/* Only transition background-color once the initial theme has been applied
   (main.js adds this class right after initTheme() runs) — otherwise the
   very first data-theme change on page load animates from the #0d1630
   default, a 3s fade visible on every load. Deliberate theme changes after
   that (orb click) still crossfade smoothly. Mirrors the themeReady flag
   that already suppresses the sky crossfade on load, in main.js. */
body.theme-ready {
  transition: background-color 3s ease;
}

/* ============================================================
   Scene container
   ============================================================ */

.scene {
  --u: max(100vw, 177.78vh);   /* 16:9 scene width that covers the viewport (see .layer-land) */
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   Scene inner — locked 16:9 canvas, always covers the viewport.
   Crops at edges on non-16:9 viewports so composition stays intact.
   All visual scene layers are positioned inside this element.
   ============================================================ */

.scene-inner {
  position: absolute;
  aspect-ratio: 16 / 9;
  min-width: 100%;
  min-height: 100%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  overflow: hidden;
}

/* ============================================================
   Layer 1 — Sky background
   ============================================================ */

.layer-sky {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  transition: background-color 3s ease, filter 3s ease;
}

/* Crossfade layer — sits above layer-sky (same z-index, later in DOM).
   JS sets a theme class matching the old sky, snaps to opacity:1,
   then transitions to opacity:0, revealing the new sky below. */
.layer-sky-prev {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  opacity: 0;
  pointer-events: none;
}

/* ============================================================
   Layer 2 — Stars
   ============================================================ */

.layer-stars {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.star {
  position: absolute;
  border-radius: 50%;
  background: #ffffff;
  animation: twinkle var(--dur, 7s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  transition: opacity 3s ease;
}

.star.s-small  { width: 1.5px; height: 1.5px; }
.star.s-medium { width: 2px;   height: 2px;   }
.star.s-large  { width: 3px;   height: 3px;   }

/* 4-pointed feature stars — clip-path diamond cross, dramatic twinkle */
.star.s-feature {
  width: 9px;
  height: 9px;
  border-radius: 0;
  clip-path: polygon(50% 0%, 53% 47%, 100% 50%, 53% 53%, 50% 100%, 47% 53%, 0% 50%, 47% 47%);
  animation-name: twinkle-bright;
}

.star.s-feature-lg {
  width: 14px;
  height: 14px;
  border-radius: 0;
  clip-path: polygon(50% 0%, 53% 47%, 100% 50%, 53% 53%, 50% 100%, 47% 53%, 0% 50%, 47% 47%);
  animation-name: twinkle-bright;
}

/* ============================================================
   Layer 3 — Orb (sun / moon)
   ============================================================ */

.orb {
  position: absolute;
  z-index: 3;
  border-radius: 50%;
  cursor: default;
  /* Centred on its left/top anchor; the orb-pulse animation also carries this translate */
  animation: orb-pulse 6s ease-in-out infinite;
  /* Smooth position, size, colour transitions between themes */
  transition:
    left    3s ease,
    top     3s ease,
    width   3s ease,
    height  3s ease,
    background 3s ease,
    filter  3s ease,
    opacity 3s ease,
    box-shadow 3s ease;
}

.orb:focus-visible {
  outline: 2px solid rgba(255, 236, 217, 0.8);
  outline-offset: 6px;
}

/* Ripple pseudo-element — triggered by .is-rippling class added in JS */
.orb::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  pointer-events: none;
  opacity: 0;
}

.orb.is-rippling::after {
  animation: orb-ripple 0.8s ease-out forwards;
}

/* Tooltip shown briefly after orb click */
.orb-tooltip {
  position: absolute;
  z-index: 15;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 13px;
  color: rgba(255, 236, 217, 0.9);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  /* Positioned in JS relative to current orb location */
  transform: translateX(-50%);
  letter-spacing: 0.05em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.orb-tooltip.is-visible {
  animation: tooltip-fade-out 1.5s ease-out forwards;
}

/* ============================================================
   Layer 4 — CSS Atmospheric Blobs
   ============================================================ */

.layer-blobs {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  /* Colours per theme set in themes.css */
  transition: background 3s ease;
}

/* TUNE: adjust positions and sizes once overall composition is reviewed */
.blob-a {
  width: 42%;
  height: 46%;
  left: -6%;
  top: 12%;
  filter: blur(28px);
  opacity: 0.45;
  animation: float-blob-a 55s ease-in-out infinite alternate;
}

.blob-b {
  width: 36%;
  height: 39%;
  right: 8%;
  top: 10%;
  filter: blur(24px);
  opacity: 0.45;
  animation: float-blob-b 70s ease-in-out infinite alternate;
}

.blob-c {
  width: 30%;
  height: 32%;
  left: 28%;
  top: 26%;
  filter: blur(30px);
  opacity: 0.45;
  animation: float-blob-c 85s ease-in-out infinite alternate;
}

/* ============================================================
   Cloud wrapper — holds parallax offset (via JS transform)
   Cloud img inside holds the sway animation
   ============================================================ */

.cloud-wrapper {
  position: absolute;
  will-change: transform;
  pointer-events: none; /* decorative — must not intercept orb clicks */
}

/* BG cloud imgs — filter per theme set in themes.css */
.cloud-bg {
  display: block;
  width: 100%;
  height: auto;
  will-change: transform;
  pointer-events: none;
  transition: filter 3s ease, opacity 3s ease;
}

/* FG cloud imgs */
.cloud-fg {
  display: block;
  width: 100%;
  height: auto;
  will-change: transform;
  pointer-events: none;
  transition: filter 3s ease, opacity 3s ease;
}

/* ============================================================
   Layer 5 — Background cloud PNGs (z-index 5)
   TUNE: all top/left/width values below — adjust once assets loaded
   ============================================================ */

.layer-clouds-bg {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

/* Left-side bg clouds — spread across a wide vertical range */
/* ADJUST TO MATCH GROUND PNG */
#cw-bg-01 { top:  7%; left: -2%;  width: 26%; }
#cw-bg-02 { top: 45%; left:  4%;  width: 21%; }
#cw-bg-03 { top: 20%; left: 14%;  width: 23%; }

/* Right-side bg clouds — wide vertical spread to match */
/* ADJUST TO MATCH GROUND PNG */
#cw-bg-04 { top: 10%; left: 57%;  width: 25%; }
#cw-bg-05 { top: 35%; left: 80%;  width: 22%; }
#cw-bg-06 { top:  3%; left: 74%;  width: 20%; }
#cw-bg-07 { top: 30%; left: 78%;  width: 19%; }

/* Wide duration spread (52s–170s, ~3× ratio) + mismatched delays = visibly independent */
#cloud-bg-01 { animation: cloud-sway-bg  52s ease-in-out infinite alternate; animation-delay:  -9s; }
#cloud-bg-02 { animation: cloud-sway-bg 170s ease-in-out infinite alternate; animation-delay: -85s; }
#cloud-bg-03 { animation: cloud-sway-bg  88s ease-in-out infinite alternate; animation-delay: -22s; }
#cloud-bg-04 { animation: cloud-sway-bg 130s ease-in-out infinite alternate; animation-delay: -55s; }
#cloud-bg-05 { animation: cloud-sway-bg  65s ease-in-out infinite alternate; animation-delay: -38s; }
#cloud-bg-06 { animation: cloud-sway-bg 145s ease-in-out infinite alternate; animation-delay: -12s; }
#cloud-bg-07 { animation: cloud-sway-bg  75s ease-in-out infinite alternate; animation-delay: -60s; }

/* Day bg cloud imgs — base style mirrors .cloud-bg */
.cloud-bg-day {
  display: block;
  width: 100%;
  height: auto;
  will-change: transform;
  pointer-events: none;
  transition: filter 3s ease, opacity 3s ease;
}

/* Day bg cloud positions — start identical to dawn equivalents; tune independently */
/* ADJUST TO MATCH GROUND PNG */
#cw-bg-day-01 { top:  7%; left: -2%;  width: 26%; }
#cw-bg-day-02 { top: 45%; left:  4%;  width: 21%; }
#cw-bg-day-03 { top: 20%; left: 14%;  width: 23%; }
#cw-bg-day-04 { top: 10%; left: 57%;  width: 25%; }
#cw-bg-day-05 { top: 35%; left: 80%;  width: 22%; }
#cw-bg-day-06 { top:  3%; left: 74%;  width: 20%; }
#cw-bg-day-07 { top: 30%; left: 78%;  width: 19%; }

#cloud-bg-day-01 { animation: cloud-sway-bg  52s ease-in-out infinite alternate; animation-delay:  -9s; }
#cloud-bg-day-02 { animation: cloud-sway-bg 170s ease-in-out infinite alternate; animation-delay: -85s; }
#cloud-bg-day-03 { animation: cloud-sway-bg  88s ease-in-out infinite alternate; animation-delay: -22s; }
#cloud-bg-day-04 { animation: cloud-sway-bg 130s ease-in-out infinite alternate; animation-delay: -55s; }
#cloud-bg-day-05 { animation: cloud-sway-bg  65s ease-in-out infinite alternate; animation-delay: -38s; }
#cloud-bg-day-06 { animation: cloud-sway-bg 145s ease-in-out infinite alternate; animation-delay: -12s; }
#cloud-bg-day-07 { animation: cloud-sway-bg  75s ease-in-out infinite alternate; animation-delay: -60s; }

/* Night bg cloud imgs — hidden by default; shown only on night theme via themes.css */
.cloud-bg-night {
  display: block;
  width: 100%;
  height: auto;
  will-change: transform;
  pointer-events: none;
  transition: filter 3s ease, opacity 3s ease;
  opacity: 0;
}

/* Night bg cloud positions — start identical to dawn equivalents; tune independently */
/* ADJUST TO MATCH GROUND PNG */
#cw-bg-night-01 { top:  7%; left: -2%;  width: 26%; }
#cw-bg-night-02 { top: 45%; left:  4%;  width: 21%; }
#cw-bg-night-03 { top: 20%; left: 14%;  width: 23%; }
#cw-bg-night-04 { top: 10%; left: 57%;  width: 25%; }
#cw-bg-night-05 { top: 35%; left: 80%;  width: 22%; }
#cw-bg-night-06 { top:  3%; left: 74%;  width: 20%; }

#cloud-bg-night-01 { animation: cloud-sway-bg  52s ease-in-out infinite alternate; animation-delay:  -9s; }
#cloud-bg-night-02 { animation: cloud-sway-bg 170s ease-in-out infinite alternate; animation-delay: -85s; }
#cloud-bg-night-03 { animation: cloud-sway-bg  88s ease-in-out infinite alternate; animation-delay: -22s; }
#cloud-bg-night-04 { animation: cloud-sway-bg 130s ease-in-out infinite alternate; animation-delay: -55s; }
#cloud-bg-night-05 { animation: cloud-sway-bg  65s ease-in-out infinite alternate; animation-delay: -38s; }
#cloud-bg-night-06 { animation: cloud-sway-bg 145s ease-in-out infinite alternate; animation-delay: -12s; }

/* ============================================================
   Layer 6 — Depth overlay (z-index 6)
   ============================================================ */

.layer-depth {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  transition: background 3s ease;
}

/* ============================================================
   Layer 7 — Foreground cloud PNGs (z-index 7)
   TUNE: all positions below — adjust once assets loaded
   ============================================================ */

.layer-clouds-fg {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
}

/* Left-side fg clouds — pushed toward left edge, partially off-screen is fine */
/* ADJUST TO MATCH GROUND PNG */
#cw-fg-01 { top: 35%; left: -5%; width: 30%; }
#cw-fg-02 { top: 40%; left:   3%; width: 27%; }

/* Right-side fg clouds */
/* ADJUST TO MATCH GROUND PNG */
#cw-fg-03 { top: 32%; left: 40%;  width: 30%; }
#cw-fg-04 { top: 35%; left: 53%;  width: 32%; }
#cw-fg-05 { top: 26%; left: 62%;  width: 26%; }
#cw-fg-06 { top: 40%; left: 79%;  width: 28%; }

/* Wide duration spread (45s–155s) + mismatched delays = visibly independent */
#cloud-fg-01 { animation: cloud-sway-fg  45s ease-in-out infinite alternate; animation-delay:  -7s; }
#cloud-fg-02 { animation: cloud-sway-fg 155s ease-in-out infinite alternate; animation-delay: -70s; }
#cloud-fg-03 { animation: cloud-sway-fg  80s ease-in-out infinite alternate; animation-delay: -18s; }
#cloud-fg-04 { animation: cloud-sway-fg 120s ease-in-out infinite alternate; animation-delay: -50s; }
#cloud-fg-05 { animation: cloud-sway-fg  58s ease-in-out infinite alternate; animation-delay: -30s; }
#cloud-fg-06 { animation: cloud-sway-fg 105s ease-in-out infinite alternate; animation-delay: -42s; }

/* Day fg cloud imgs — base style mirrors .cloud-fg */
.cloud-fg-day {
  display: block;
  width: 100%;
  height: auto;
  will-change: transform;
  pointer-events: none;
  transition: filter 3s ease, opacity 3s ease;
}

/* Day fg cloud positions — start identical to dawn equivalents; tune independently */
/* ADJUST TO MATCH GROUND PNG */
#cw-fg-day-01 { top: 35%; left: -5%;  width: 30%; }
#cw-fg-day-02 { top: 40%; left:  3%;  width: 27%; }
#cw-fg-day-03 { top: 32%; left: 40%;  width: 30%; }
#cw-fg-day-04 { top: 35%; left: 53%;  width: 32%; }
#cw-fg-day-05 { top: 26%; left: 62%;  width: 26%; }
#cw-fg-day-06 { top: 40%; left: 79%;  width: 28%; }

#cloud-fg-day-01 { animation: cloud-sway-fg  45s ease-in-out infinite alternate; animation-delay:  -7s; }
#cloud-fg-day-02 { animation: cloud-sway-fg 155s ease-in-out infinite alternate; animation-delay: -70s; }
#cloud-fg-day-03 { animation: cloud-sway-fg  80s ease-in-out infinite alternate; animation-delay: -18s; }
#cloud-fg-day-04 { animation: cloud-sway-fg 120s ease-in-out infinite alternate; animation-delay: -50s; }
#cloud-fg-day-05 { animation: cloud-sway-fg  58s ease-in-out infinite alternate; animation-delay: -30s; }
#cloud-fg-day-06 { animation: cloud-sway-fg 105s ease-in-out infinite alternate; animation-delay: -42s; }

/* Night fg cloud imgs — hidden by default; shown only on night theme via themes.css */
.cloud-fg-night {
  display: block;
  width: 100%;
  height: auto;
  will-change: transform;
  pointer-events: none;
  transition: filter 3s ease, opacity 3s ease;
  opacity: 0;
}

/* Night fg cloud positions — start identical to dawn equivalents; tune independently */
/* ADJUST TO MATCH GROUND PNG */
#cw-fg-night-01 { top: 35%; left: -5%;  width: 30%; }
#cw-fg-night-05 { top: 26%; left: 62%;  width: 26%; }
#cw-fg-night-03 { top: 32%; left: 40%;  width: 30%; }
#cw-fg-night-04 { top: 35%; left: 53%;  width: 32%; }

#cloud-fg-night-01 { animation: cloud-sway-fg  45s ease-in-out infinite alternate; animation-delay:  -7s; }
#cloud-fg-night-05 { animation: cloud-sway-fg  58s ease-in-out infinite alternate; animation-delay: -30s; }
#cloud-fg-night-03 { animation: cloud-sway-fg  80s ease-in-out infinite alternate; animation-delay: -18s; }
#cloud-fg-night-04 { animation: cloud-sway-fg 120s ease-in-out infinite alternate; animation-delay: -50s; }

/* ============================================================
   Day CSS clouds — substitute for PNG clouds on day theme (z-index 5)
   Hidden on all non-day themes via themes.css.
   ============================================================ */

.layer-clouds-day {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.css-cloud-day {
  position: absolute;
  border-radius: 50%;
  /* Slightly sharper than atmospheric blobs — hints at cloud definition */
  filter: blur(18px);
  opacity: 0;
  transition: opacity 3s ease, background 3s ease;
}

/* TUNE: positions once you review the day sky composition */
.css-cloud-day--1 {
  width: 44%;
  height: 46%;
  top:  8%;
  left: 0%;
  animation: float-blob-a 60s ease-in-out infinite alternate;
}
.css-cloud-day--2 {
  width: 40%;
  height: 43%;
  top:  4%;
  right: -4%;
  animation: float-blob-b 75s ease-in-out infinite alternate;
}
.css-cloud-day--3 {
  width: 36%;
  height: 36%;
  top: 30%;
  left: -4%;
  animation: float-blob-c 90s ease-in-out infinite alternate;
}
.css-cloud-day--4 {
  width: 34%;
  height: 32%;
  top: 24%;
  right: -4%;
  animation: float-blob-b 80s ease-in-out infinite alternate-reverse;
}
.css-cloud-day--5 {
  width: 30%;
  height: 28%;
  top: 38%;
  left: 28%;
  animation: float-blob-a 95s ease-in-out infinite alternate-reverse;
}

/* ============================================================
   Layer 7.5 — Birds
   ============================================================ */

.bird {
    width: 200px;
    height: 200px;
    background-image: url('../images/bird_strip.png');
    background-size: auto 200px;
    background-repeat: no-repeat;
    position: absolute;
    z-index: 8;
    animation: flap 1.4s steps(13) infinite;
    pointer-events: none;
}

@keyframes flap {
    from { background-position: 0 0; }
    to   { background-position: -2600px 0; } /* 200px × 13 frames */
}

.bird-1 { top: 67%; left: 20%; animation-delay: 0s; transform: scale(.15)}
.bird-2 { top: 68.5%; left: 19.3%; animation-delay: -0.21s; transform: scale(.10)}
.bird-3 { top: 68%; left: 21%; animation-delay: -0.5s; transform: scale(.12)}

/* ============================================================
   Layer 8 — Ground
   ============================================================ */

.layer-ground {
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 8;
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none; /* hotspot <a> elements handle all ground interactions */
  transition: opacity 3s ease;
}

/* ============================================================
   Layer 8 (desktop) — split ground + foreground + signature
   Lives inside .scene-inner but is sized and positioned against the
   *viewport* (calc against 100vw / 100vh), so nothing is cropped when the
   window isn't 16:9. --u is the "scene width": it equals the viewport width
   at 16:9 and grows on taller windows so the art doesn't shrink.
   Hidden at ≤768px, where the original single-image ground is used.
   ============================================================ */

.layer-land {
  --fg-right: 12.3vw;                 /* gap between foreground and right edge */
  display: none;
  position: absolute;
  z-index: 8;
  left: calc((100% - 100vw) / 2);
  bottom: calc((100% - 100vh) / 2);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  pointer-events: none;
  transition: filter 3s ease;
}

.land-ground {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: var(--u);
  height: auto;
  transform: translateX(-50%);
}

.land-fg {
  position: absolute;
  bottom: 0;
  right: var(--fg-right);
  /* natural width is 1582 of 3840; shrinks only if it would run off the left edge */
  width: min(calc(var(--u) * 0.412), calc(100vw - var(--fg-right) - 2vw));
}

.land-fg__img { display: block; width: 100%; height: auto; }
.land-fg__img--over { position: absolute; left: 0; top: 0; }

.land-sig {
  position: absolute;
  right: 0.7vw;
  bottom: 0.6vw;
  width: calc(var(--u) * 0.019);
  height: auto;
}

/* Birds: same spots as before, but now sized and placed in --u units (centre point,
   measured from the centred ground's left edge and the bottom) so they scale with the
   mountains and stay put relative to the labels pointing at them. */
.land-bird {
  width: calc(var(--u) * var(--bw));
  height: calc(var(--u) * var(--bw));
  background-size: 1300% 100%;       /* 13 frames across the box */
  transform: translate(-50%, -50%);
  animation: land-flap 1.4s steps(13) infinite;
  left: calc((100% - var(--u)) / 2 + var(--u) * var(--bx));
  top: calc(100% - var(--u) * var(--by));
}
@keyframes land-flap {
  from { background-position: 0 0; }
  to   { background-position: 108.3333% 0; }
}
.land-bird-1 { --bw: .015625; --bx: .2521; --by: .1336; animation-delay: 0s; }
.land-bird-2 { --bw: .010417; --bx: .2451; --by: .1251; animation-delay: -0.21s; }
.land-bird-3 { --bw: .0125;   --bx: .2621; --by: .1279; animation-delay: -0.5s; }

@media (min-width: 769px) {
  .layer-land   { display: block; }
  .layer-ground { display: none; }
  .bird--canvas { display: none; }
}

/* ============================================================
   Navigation hotspots (over ground layer, z-index 9)
   ============================================================ */

.hotspot {
  position: fixed;
  z-index: 50;
  cursor: pointer;
  text-decoration: none;
}

.hotspot:hover {
  background: rgba(255, 220, 180, 0.06);
  border-radius: 4px;
  outline: 1px solid rgba(255, 220, 180, 0.15);
}

/* Hover label — uses aria-label attribute */
.hotspot::after {
  content: attr(aria-label);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 15px;
  color: rgba(252, 228, 210, 0.0);
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0);
  transition: color 0.35s ease, transform 0.35s ease, text-shadow 0.35s ease;
}

.hotspot:hover::after {
  color: rgba(252, 228, 210, 0.95);
  transform: translateX(-50%) translateY(0);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

/* ============================================================
   Title block (z-index 10)
   ============================================================ */

.title-block {
  position: absolute;
  top: 5%;
  left: 4%;
  z-index: 10;
  pointer-events: none;
  user-select: none;
}

/* Shared type styles */
.title-block__line1,
.title-block__line2 {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  color: var(--text-cream, rgba(255, 236, 217, 0.95));
  /* Fraunces variable-font axes */
  font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 144;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  line-height: 1.2;
}

.title-block__line1 {
  font-size: clamp(28px, 2.5vw, 38px);
}

.title-block__line2 {
  font-size: clamp(24px, 2.2vw, 34px);
  display: flex;
  align-items: baseline;
  /* Sits just below line1 with a small gap */
  margin-top: 0.5em;
}

.title-block__static {
  white-space: nowrap;
}

/* Word slot — clips to one word height, JS swaps words via translateY */
.word-slot {
  display: inline-block;
  overflow: hidden;
  /* TUNE: min-width sized for "paper mache" — adjust if font renders differently */
  min-width: 240px;
  vertical-align: bottom;
  /* height matches the line-height of one word */
  height: 1.2em;
  /* Guaranteed gap between "efua makes" and the word, even if trailing space is trimmed */
  margin-left: 0.17em;
}

.word-slot__inner {
  display: block;
  transition: transform 0.45s ease-in-out, opacity 0.45s ease-in-out;
}

/* States driven by JS */
.word-slot__inner.is-exiting {
  transform: translateY(110%);
  opacity: 0;
}

.word-slot__inner.is-entering {
  transform: translateY(-110%);
  opacity: 0;
  transition: none; /* snap to bottom position, then JS removes class to animate in */
}

/* ============================================================
   Top navigation (z-index 20)
   ============================================================ */

.site-nav {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 28px;
  opacity: 1;
  transition: opacity 0.6s ease;
}

.site-nav.is-faded {
  opacity: 0.35;
}

.site-nav__links {
  display: flex;
  align-items: center;
  gap: 32px;
}

.site-nav__link {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 13px;
  font-variation-settings: "SOFT" 80, "WONK" 0, "opsz" 12;
  color: rgba(255, 236, 217, 0.75);
  letter-spacing: 0.04em;
  text-decoration: none;
  position: relative;
  transition: color 0.3s ease;
}

.site-nav__link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 236, 217, 0.7);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.site-nav__link:hover {
  color: rgba(255, 236, 217, 1);
}

.site-nav__link:hover::after {
  opacity: 1;
}

/* ============================================================
   Constellation Easter egg (z-index 9)
   Visibility per theme set in themes.css
   ============================================================ */

.constellation {
  position: absolute;
  left: 36%;
  top: 16%;
  z-index: 9;
  display: block;
  text-decoration: none;
  transition: opacity 3s ease, transform 0.5s ease;
}

.constellation {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.constellation:hover {
  opacity: 1 !important;
  transform: scale(1.1);
}

/* Cluster steps aside while the dragon is out */
.constellation.is-away {
  opacity: 0 !important;
  pointer-events: none;
  transition: opacity 1.2s ease;
}

/* Dragon constellation — sized and positioned by assets/js/dragon.js */
.dragon {
  position: absolute;
  z-index: 9;
  pointer-events: none;
  visibility: hidden;
  transform-origin: 50% 50%;
  will-change: transform;
}
.dragon.is-on { visibility: visible; }
.dragon svg { width: 100%; height: 100%; overflow: visible; display: block; }

.dragon__line {
  fill: none;
  stroke: rgba(200, 217, 233, 0.75);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dragon__star {
  fill: #fff8dc;
  filter: drop-shadow(0 0 3px rgba(255, 248, 220, 0.9));
  animation: dragon-twinkle 2.4s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes dragon-twinkle {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1; }
}

/* Dim stars: fainter, no glow */
.dragon__star--dim {
  filter: none;
  animation-name: dragon-twinkle-dim;
}
@keyframes dragon-twinkle-dim {
  0%, 100% { opacity: 0.08; }
  50%      { opacity: 0.3; }
}

/* ============================================================
   Particles canvas (appended by particles.js)
   ============================================================ */

#particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  pointer-events: none;
}

/* ============================================================
   Scene controls — theme selector + notes toggle (z-index 15)
   ============================================================ */

/* Notes control — sits just below the nav, right-aligned to match it.
   z-index 19 (below nav's 20) so the theme dropdown overlaps it correctly. */
.scene-controls {
  position: absolute;
  top: 52px;
  right: 28px;
  z-index: 19;
  display: flex;
  align-items: center;
  gap: 6px;
}

.notes-label {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 11px;
  color: rgba(255, 236, 217, 0.55);
  letter-spacing: 0.04em;
  pointer-events: none;
  user-select: none;
}

/* ---- Theme selector — lives inside site-nav ---- */

.theme-selector {
  position: relative;
  margin-left: 20px; /* gap after last nav link */
}

.ts-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 13px;
  color: rgba(255, 236, 217, 0.75);
  letter-spacing: 0.04em;
  transition: color 0.3s ease;
}

.ts-btn:hover {
  color: rgba(255, 236, 217, 1);
}

.ts-icon {
  font-size: 14px;
  line-height: 1;
}

.ts-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: rgba(10, 10, 20, 0.88);
  border: 1px solid rgba(255, 236, 217, 0.15);
  border-radius: 10px;
  padding: 6px 0;
  list-style: none;
  backdrop-filter: blur(10px);
  min-width: 110px;
  display: none;
  z-index: 1;
}

.ts-menu.is-open {
  display: block;
}

.ts-menu li {
  list-style: none;
}

.ts-menu [data-theme] {
  display: block;
  width: 100%;
  padding: 7px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 12px;
  color: rgba(255, 236, 217, 0.8);
  letter-spacing: 0.04em;
  text-align: left;
  transition: color 0.2s ease, background 0.2s ease;
}

.ts-menu [data-theme]:hover {
  color: rgba(255, 236, 217, 1);
  background: rgba(255, 255, 255, 0.07);
}

/* ---- Notes toggle ---- */

.notes-toggle {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 236, 217, 0.2);
  border-radius: 20px;
  padding: 3px 10px;
  cursor: pointer;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 11px;
  color: rgba(255, 236, 217, 0.6);
  letter-spacing: 0.04em;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.notes-toggle:hover {
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 236, 217, 0.35);
  color: rgba(255, 236, 217, 0.9);
}

/* ============================================================
   Layer 8.5 — Scene labels / notes (z-index 9)
   pointer-events: none — never blocks hotspot clicks.
   TUNE: position each label via inline style or .scene-label--N subclass.
   ============================================================ */

.layer-labels {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.layer-labels.is-hidden {
  opacity: 0;
}

.scene-label {
  position: absolute;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 13px;
  color: rgba(255, 236, 217, 0.85);
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transition: filter 3s ease;
  /* Size scales with the scene (--u) so labels keep their size relative to
     the art they point at. Written as --w (share of --u) and positioned by its
     centre via left/top, so TUNE: set --w, left and top per label inline. */
  width: calc(var(--u) * var(--w, 0.08));
  height: auto;
  transform: translate(-50%, -50%);
}

/* ============================================================
   Rain effect
   z-index 11–13: above visual layers and title (10),
   below scene-controls (15) and nav (20) so they stay accessible.
   ============================================================ */

/* Tints the whole scene grey-blue */
.rain-overlay {
  position: absolute;
  inset: 0;
  background: rgba(90, 100, 130, 0);
  pointer-events: none;
  z-index: 11;
  transition: background 4s ease;
}
.scene.rain-overlay-on .rain-overlay {
  background: rgba(90, 100, 130, 0.5);
}

/* Desaturate sky and existing clouds */
.scene.rain-sky-dim .layer-sky,
.scene.rain-sky-dim .cloud-bg,
.scene.rain-sky-dim .cloud-bg-day,
.scene.rain-sky-dim .cloud-fg,
.scene.rain-sky-dim .cloud-fg-day,
.scene.rain-sky-dim .css-cloud {
  filter: brightness(0.82) saturate(0.45);
  transition: filter 4s ease;
}

/* Heavy dark clouds drift in from off-screen */
.rain-cloud {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 8s ease, transform 10s ease;
  z-index: 12;
}
.scene.rain-clouds-on .rain-cloud { opacity: 1; }
.scene.rain-clearing .rain-cloud { opacity: 0; transition: opacity 3s ease; }

.rain-cloud-1 {
  width: 70%;
  height: 180px;
  background: radial-gradient(ellipse at 50% 60%,
    rgba(55, 62, 90, 0.82) 0%, rgba(55, 62, 90, 0.4) 50%, transparent 80%);
  filter: blur(32px);
  top: 30%;
  left: -10%;
  transform: translateX(-128px);
}
.scene.rain-clouds-on .rain-cloud-1 { transform: translateX(0); }

.rain-cloud-2 {
  width: 60%;
  height: 160px;
  background: radial-gradient(ellipse at 50% 60%,
    rgba(45, 52, 80, 0.78) 0%, rgba(45, 52, 80, 0.35) 55%, transparent 82%);
  filter: blur(38px);
  top: 38%;
  right: -5%;
  transform: translateX(128px);
}
.scene.rain-clouds-on .rain-cloud-2 { transform: translateX(0); }

.rain-cloud-3 {
  width: 50%;
  height: 140px;
  background: radial-gradient(ellipse at 50% 65%,
    rgba(50, 58, 85, 0.7) 0%, rgba(50, 58, 85, 0.3) 55%, transparent 80%);
  filter: blur(28px);
  top: 44%;
  left: 25%;
  transform: translateY(-12px);
}
.scene.rain-clouds-on .rain-cloud-3 { transform: translateY(0); }

.rain-cloud-4 {
    width: 50%;
    height: 140px;
    background: radial-gradient(ellipse at 50% 65%,
    rgba(50, 58, 85, 0.7) 0%, rgba(50, 58, 85, 0.3) 55%, transparent 80%);
    filter: blur(28px);
    top: 0;
    left: 25%;
    transform: translateY(-12px);
}
.scene.rain-clouds-on .rain-cloud-4 { transform: translateY(0); }

.rain-cloud-5 {
    width: 30%;
    height: 240px;
    background: radial-gradient(ellipse at 50% 65%,
    rgba(50, 58, 85, 0.5) 0%, rgba(50, 58, 85, 0.2) 55%, transparent 80%);
    filter: blur(28px);
    top: 50%;
    left: 45%;
    transform: translateY(-12px);
}
.scene.rain-clouds-on .rain-cloud-5 { transform: translateY(0); }

/* Rain canvas — direct .scene child, position:fixed covers the full viewport
   so rain reaches letterboxed edges at non-16:9 aspect ratios. */
#rain-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 13;
  opacity: 0;
  transition: opacity 5s ease;
}
#rain-canvas.visible { opacity: 1; }

/* Easter egg trigger — invisible button over cloud-bg-01.
   No cursor change to keep it hidden. */
.rain-trigger {
  position: absolute;
  z-index: 9;
  background: none;
  border: none;
  cursor: default;
}

/* ============================================================
   Reduced motion — disable parallax and animations via JS flag
   CSS counterpart: collapse all transitions
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .orb,
  .cloud-bg,
  .cloud-fg,
  .layer-sky,
  .layer-depth,
  .blob,
  .star,
  .constellation,
  .site-nav,
  .word-slot__inner,
  .hotspot {
    transition-duration: 0.01ms !important;
  }
}

/* =============================================
   MOBILE NAV — large centered link list
   Shown only on mobile; hidden on desktop.
   ============================================= */

.mobile-nav {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  text-align: center;
  pointer-events: auto;
}

.mobile-nav__link {
  display: block;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 72;
  font-size: clamp(32px, 9vw, 52px);
  color: var(--text-cream, rgba(255, 236, 217, 0.95));
  text-decoration: none;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
  line-height: 1.7;
  letter-spacing: 0.02em;
  transition: color 0.25s ease;
}

.mobile-nav__link:hover,
.mobile-nav__link:focus {
  color: rgba(255, 255, 255, 1);
}

/* =============================================
   MOBILE LAYOUT — below 768px
   Scene stays visible; ground elements remain
   for composition. Clickable ground hotspots
   and notes are hidden; top nav links replaced
   by the centered mobile nav list.
   ============================================= */
@media (max-width: 768px) {
  .hotspot        { display: none; }        /* ground hotspots not usable at this size */
  .scene-controls { display: none; }        /* notes toggle hidden on mobile */
  .layer-labels   { display: none; }        /* notes overlay hidden on mobile */
  .site-nav__links { display: none; }       /* top nav links hidden; theme selector stays */
  .mobile-nav     { display: block; }       /* centered link list takes over */

  .ts-btn  { font-size: clamp(32px, 9vw, 52px); }
  .ts-icon { font-size: clamp(32px, 9vw, 52px); }
}

/* ============================================================
   Pause scene animations while a panel fully covers the scene.
   Toggled by panels.js (body.scene-covered). Resumes in place.
   ============================================================ */

body.scene-covered .scene *,
body.scene-covered .scene *::before,
body.scene-covered .scene *::after {
  animation-play-state: paused !important;
}

/* ============================================================
   Gallery mode (studio, birds panels) — toggled by panels.js.
   Everything except sky, stars, clouds fades out so the gallery
   cards float on the bare sky. The theme selector and top nav stay.
   `gallery-fade` supplies the quick transition (and outlives
   `gallery-mode` by ~0.9s so the return fade is quick as well).
   ============================================================ */

body.gallery-fade :is(.orb, .scene-controls, .layer-ground, .layer-land, .bird--canvas, #layer-labels,
  .dragon, .constellation, .title-block:not(.title-block--page), .mobile-nav, .hotspot,
  .rain-overlay, .rain-cloud, #rain-canvas) {
  transition: opacity 0.6s ease !important;
}

body.gallery-mode :is(.orb, .scene-controls, .layer-ground, .layer-land, .bird--canvas, #layer-labels,
  .dragon, .constellation, .title-block:not(.title-block--page), .mobile-nav, .hotspot,
  .rain-overlay, .rain-cloud, #rain-canvas) {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Page title: sits exactly where the main title does, shown in gallery mode */
.title-block--page { opacity: 0; transition: opacity 0.6s ease; }
body.gallery-mode .title-block--page { opacity: 1; }
