/* ---------- The Moonlight opening (her pick, Nov 30, with the silver serif name) ----------
   The first screen opens dark. Her moon cursor carries a soft circle of moonlight, and wherever it goes her photos
   light up underneath. Her name sits in the middle in Instrument Serif, glowing like moonlit silver. Phones have no
   cursor, so the light drifts by itself (tap to send it, or "follow my tilt"). The behaviour is features/moonlight.js.
   The prototype it came from is lab/opening-moon.html.

   One switch: class="moonlight" on <html> (index.html). Every rule here sits behind it. Take the class off and the
   older opening comes back as it was: the flip and deal (script.js), the black and white tile sign and its glitter
   (features/design.css and design.js) and the cursor zones for the living tiles (features/motion.js).
   The opening is night in both site themes. Nothing here moves the photos: only the night layer moves. */

.night { display: none; }

html.moonlight .hero { background: #171513; color-scheme: dark; }
html.moonlight .hero-collage, html.moonlight .hc { background: #0E0C0A; }
/* the collage is simply there (no flip, no deal); the light is what reveals it */
html.moonlight .flick { display: none !important; }
html.moonlight .hero-collage .hc { opacity: 1; animation: none; }

/* ---- the night: a soft hole of moonlight in the middle (.n-c) and plain dark everywhere else ----
   features/moonlight.js moves it with the `translate` property only (compositor work, the photos are never redrawn).
   The plain pieces are single-colour tiles, so the big layer costs almost no GPU memory. Scrolling (--p, set by the
   name glide in script.js) lifts the night and widens the light, so every photo comes up while her name glides off. */
html.moonlight .hero.moon-on .night {
  --ghost: 0.86; --haze: 0.05;
  display: block; position: absolute; left: 0; top: 0; z-index: 1; width: var(--ow, 200vw); height: var(--oh, 200vh);
  pointer-events: none; transform-origin: 50% 50%; will-change: translate, scale, opacity;
  opacity: calc(1 - var(--p, 0)); scale: calc(1 + var(--p, 0) * 2.4);
}
html.moonlight .night i { position: absolute; background: rgba(23, 21, 19, var(--ghost)); }
html.moonlight .night .n-t { left: 0; right: 0; top: 0; height: calc(50% - var(--h)); }
html.moonlight .night .n-b { left: 0; right: 0; bottom: 0; height: calc(50% - var(--h)); }
html.moonlight .night .n-l { left: 0; top: calc(50% - var(--h)); width: calc(50% - var(--h)); height: calc(var(--h) * 2); }
html.moonlight .night .n-r { right: 0; top: calc(50% - var(--h)); width: calc(50% - var(--h)); height: calc(var(--h) * 2); }
html.moonlight .night .n-c { left: calc(50% - var(--h)); top: calc(50% - var(--h)); width: calc(var(--h) * 2); height: calc(var(--h) * 2);
  background: radial-gradient(circle at 50% 50%,
    rgba(255, 246, 228, var(--haze)) 0,
    rgba(255, 246, 228, 0) calc(var(--r, 0px) * 0.32),
    rgba(23, 21, 19, calc(var(--ghost) * 0.07)) calc(var(--r, 0px) * 0.46),
    rgba(23, 21, 19, calc(var(--ghost) * 0.22)) calc(var(--r, 0px) * 0.6),
    rgba(23, 21, 19, calc(var(--ghost) * 0.45)) calc(var(--r, 0px) * 0.74),
    rgba(23, 21, 19, calc(var(--ghost) * 0.7)) calc(var(--r, 0px) * 0.87),
    rgba(23, 21, 19, calc(var(--ghost) * 0.9)) calc(var(--r, 0px) * 1),
    rgba(23, 21, 19, var(--ghost)) calc(var(--r, 0px) * 1.14)); }

/* ---- eyes adjusting: the room starts black and fades up to its faint ghost ----
   The late fade is a safety net in case the script never starts the opening. */
html.moonlight.motion .hero::after { content: ""; position: absolute; inset: 0; z-index: 2; background: #171513; pointer-events: none; animation: moon-veil-late 1.2s ease 2.6s both; }
html.moonlight.motion .hero.moon-go::after { animation: moon-veil 2s ease 0.3s both; }
html.moonlight .hero.moon-still::after { display: none; }
@keyframes moon-veil { from { opacity: 1; } to { opacity: 0; visibility: hidden; } }
@keyframes moon-veil-late { from { opacity: 1; } to { opacity: 0; visibility: hidden; } }

/* ---- her name: Instrument Serif in brushed moonlit silver (the tile sign steps aside, see design.css) ----
   ::before is a soft shadow that keeps it readable when the light passes behind it, .hn::before the glow,
   .hn::after the sheen where the light falls (features/moonlight.js sets --hx, --hy, --sr and --lit), and ::after
   the halo of the moon dot, which brightens as the light comes near (--glow). */
html.moonlight .hero-name { isolation: isolate; padding: 0.06em 0.08em; background: none; box-shadow: none; white-space: nowrap;
  font-size: clamp(52px, 8.6vw, 136px); }
@media (max-width: 640px) { html.moonlight .hero-name { font-size: clamp(44px, 12.4vw, 60px); padding: 0.06em 0.08em; } }
html.moonlight .hero-name::before, html.moonlight .hero-name.fly-name::before {
  content: ""; position: absolute; inset: auto; left: 50%; top: 50%; z-index: -1; width: 150%; height: 280%; translate: -50% -50%;
  border: 0; border-image: none; box-shadow: none; pointer-events: none;
  background: radial-gradient(closest-side, rgba(23, 21, 19, 0.6), rgba(23, 21, 19, 0.3) 55%, rgba(23, 21, 19, 0));
  opacity: var(--band, 1); }
/* Dec 1 (her note: "you can't see the ending of the y and also the g ... it's getting hidden by the fade"): the silver is
   a background clipped to the letters, and a background only paints inside the box. The line is 0.9em tall, so the
   tails of the y and g hung below it and came out blank. The letters' box now reaches past them (--hn-pt/-px/-pb) and
   gives the room straight back with negative margins, so nothing moves and the whole name shows at every size. The
   gradient stops are placed so the silver looks as it did on the shorter box. */
html.moonlight .hero-name { --hn-pt: 0.14em; --hn-px: 0.06em; --hn-pb: 0.3em; }
html.moonlight .hero-name .hn { position: relative; display: inline-block; color: #E6DFD2;
  padding: var(--hn-pt) var(--hn-px) var(--hn-pb); margin: calc(-1 * var(--hn-pt)) calc(-1 * var(--hn-px)) calc(-1 * var(--hn-pb));
  background: linear-gradient(178deg, #FBF8F1 9.4%, #E9E3D7 33.4%, #BDB5A8 50.3%, #DCD5C8 63%, #A79F93 80%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
html.moonlight .hero-name .hn::before { content: attr(data-t) / ""; position: absolute; inset: 0; z-index: -1; padding: inherit; -webkit-text-fill-color: transparent;
  text-shadow: 0 0 0.22em rgba(240, 232, 216, 0.24), 0 0 0.8em rgba(240, 232, 216, 0.12); pointer-events: none; }
html.moonlight .hero-name .hn::after { content: attr(data-t) / ""; position: absolute; inset: 0; padding: inherit; opacity: var(--lit, 0); -webkit-text-fill-color: transparent; pointer-events: none;
  background: radial-gradient(circle var(--sr, 1px) at var(--hx, -9999px) var(--hy, -9999px), rgba(255, 253, 246, 0.95), rgba(255, 250, 238, 0.45) 32%, rgba(255, 250, 238, 0) 72%);
  -webkit-background-clip: text; background-clip: text; }
html.moonlight .hero-name::after { content: ""; position: absolute; left: var(--mx, -999px); top: var(--my, 0); z-index: -1; width: 1.15em; height: 1.15em; translate: -50% -50%;
  border-radius: 50%; pointer-events: none; will-change: opacity;
  background: radial-gradient(closest-side, rgba(255, 248, 232, 0.7), rgba(255, 246, 226, 0.22) 38%, rgba(255, 246, 226, 0.06) 70%, rgba(255, 246, 226, 0));
  opacity: calc(0.14 + 0.86 * var(--glow, 0)); }
html.moonlight .hero-name .moon { position: relative; z-index: 1; }

/* the name arrives out of focus once the photos are in (the late one is the safety net). Filled backwards only: held
   at the end, the animation left a blur(0px) filter on the name that dimmed it a little, so the gliding copy (which has
   none) came up brighter on the first pixel of scrolling (Dec 1) */
html.moonlight.motion .hero-name { animation: name-in 1.2s var(--ease) 2.6s backwards; }
html.moonlight.motion .hero.moon-go .hero-name { animation: moon-name 1.7s cubic-bezier(0.2, 0.7, 0.2, 1) 0.1s backwards; }
html.moonlight.motion .hero.moon-still .hero-name { animation: none; }
@keyframes moon-name { from { opacity: 0; filter: blur(10px); scale: 0.98; } }

/* ---- the gliding copy (script.js clones the name into .fly-name and lands it on the bar's name to the pixel) ----
   Dec 1 (her note: "the name drawing from the beginning to the top corner is super funky"). It used to drop the light's
   sheen and the moon's halo on the first pixel of scrolling, dragged its dark halo over the bar, and turned grey and
   ghostly in the last stretch as the silver faded out over the bar. Now (script.js sets the variables):
   - it starts as an exact copy, and the sheen (--lit) and the moon's halo (--fade) fade over the first fifth;
   - the dark halo behind the letters (--halo) is gone before it reaches the bar;
   - the bar's bottom edge cuts cleanly through the letters (--cut, in the letters' own pixels): above it they are the
     bar's own ink (.fly-ink), below it moonlit silver (.fly-silver), so they never ghost, and what lands is exactly
     the bar's name in both themes. The cut sits on the bar's own edge, so it never shows as a line. */
html.moonlight .hero-name.fly-name::before { opacity: var(--halo, 1); }
html.moonlight .hero-name.fly-name::after { opacity: calc((0.14 + 0.86 * var(--glow, 0)) * var(--fade, 1)); }
/* the silver sits in its own wrapper, so the glow still paints behind the letters exactly as in the opening */
html.moonlight .fly-name .fly-silver { display: inline-block; clip-path: inset(calc(var(--cut, -9em) - var(--hn-pt)) -2em -2em -2em); }
html.moonlight .fly-name .fly-ink { position: absolute; margin: 0; padding: var(--hn-pt) var(--hn-px) var(--hn-pb); white-space: nowrap; pointer-events: none;
  color: var(--ink); -webkit-text-fill-color: var(--ink); clip-path: inset(-2em -2em calc(100% - var(--cut, -9em)) -2em); }
.fly-ink { display: none; }
html.moonlight .fly-name .fly-ink { display: block; }

/* ---- the scroll cue and Replay, in night glass ---- */
html.moonlight .hero .hero-cue, html.moonlight .hero .replay { background: rgba(21, 19, 15, 0.72); color: #ECE5D8; border-color: rgba(241, 235, 224, 0.18); }
html.moonlight .hero .hero-cue:hover, html.moonlight .hero .replay:hover { background: #ECE5D8; color: #171513; }

/* ---- the hint for first-time visitors (tiny and grey, gone after the first move) and, on phones, the tilt choice ---- */
.moon-cues { position: absolute; left: 0; right: 0; bottom: 74px; z-index: 4; display: grid; justify-items: center; gap: 10px; pointer-events: none;
  font: 500 12.5px/1.3 var(--sans); letter-spacing: 0.02em; }
.moon-hint { margin: 0; color: rgba(236, 229, 216, 0.6); opacity: 0; transition: opacity 0.9s ease; }
.moon-hint.on { opacity: calc(1 - var(--p, 0) * 3); }
.moon-tilt { padding: 7px 13px; border: 0; border-radius: 999px; background: rgba(236, 229, 216, 0.12); color: rgba(236, 229, 216, 0.78); font: inherit;
  opacity: 0; pointer-events: none; transition: opacity 0.9s ease; }
.moon-tilt.on { opacity: calc(1 - var(--p, 0) * 3); pointer-events: auto; }
.moon-cues.gone .moon-tilt { pointer-events: none; }
.moon-tilt[hidden] { display: none; }
.moon-tilt:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(140, 47, 57, 0.6); }

/* ---- tiles: her moon stays the cursor on the opening (the moon is the light), and keyboard focus shows on top ---- */
@media (hover: hover) and (pointer: fine) {
  html.moonlight .hero, html.moonlight .hero .hc.tap, html.moonlight .hero .hc.tap * {
    cursor: url("../images/cursor/moon.png") 16 16, auto;
    cursor: image-set(url("../images/cursor/moon.png") 1x, url("../images/cursor/moon@2x.png") 2x) 16 16, auto;
  }
}
/* the living tiles answer at once (her note, Dec 1: "when i go over something with my cursor it should play faster"):
   the clip comes up in 0.18 s and goes back to the photo in 0.35 s (the lean-in on hover is unchanged) */
html.moonlight .hc .hc-live { transition: opacity 0.35s ease, transform 0.9s var(--e-out, cubic-bezier(0.2, 0.8, 0.2, 1)); }
html.moonlight .hc .hc-live.on { transition-duration: 0.18s, 0.9s; }
html.moonlight .hc::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; }
html.moonlight .hc.tap:focus-visible::after { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.9), inset 0 0 0 5px rgba(140, 47, 57, 0.85); background: transparent; }

/* ---- reduced motion (and the local tools): no moving light, no clips. The photos sit softly dimmed and the name
   shows. A tile with keyboard focus comes up out of the dim. ---- */
html.moonlight .hero.moon-still .hc::after { background: rgba(23, 21, 19, 0.5); }
html.moonlight .hero.moon-still .hc.tap:focus-visible::after { background: transparent; }
