/* =========================================================
   Evening — the hero.
   One photograph, shot as if on a fast lens (Elly, her chair, the
   chest and the lamp sharp, the room soft), and rigged for depth:
   evening-hero.js draws it on two canvases, the scene and Elly, and
   shifts every pixel by how near it is, so she has volume and the
   room falls away behind her. Her name and the thread of light are
   ordinary elements between the two canvases, so they pass behind
   her. The flat photograph underneath shows until the rig is ready,
   and stays if WebGL is missing or motion is reduced.
   The scroll move (card, marquee, fade) is CSS, read from variables
   the script writes.

   Variations (data-variant on the section):
     a  "Depth"    the camera pushes in, her name rises behind her
     b  "Window"   the scene closes into a portrait card over her words
     c  "Turning"  her name is solid, and turns as you scroll
   ========================================================= */

.hero3d {
  --P: 1200;                                   /* camera distance, px */
  --oy: 0.42;                                  /* her face, as a share of the plate's height */
  --pw: max(104vw, 139svh);                    /* the 4:3 picture always covers the screen, with room for the camera to move */
  --ph: calc(var(--pw) * 0.75);
  --ptop: calc((100svh - var(--ph)) * 0.3);
  --focus-y: calc(var(--ptop) + var(--ph) * var(--oy));

  /* written by evening-hero.js */
  --dolly: 0; --rx: 0; --ry: 0;
  --hud: 1; --dim: 0; --fade: 0; --draw: 1;
  --title-y: 0; --title-o: 1; --yaw: 0;
  --ct: 0px; --cr: 0px; --cb: 0px; --cl: 0px; --crad: 0px;
  --mq: 0; --mx: 0; --cap: 0;
  --tx: 0; --ty: 0; --thx: 0; --thy: 0;

  display: block;
  height: 260vh;
  min-height: 0;
  padding: 0;
  overflow: visible;
  background: var(--night-deep);
  color: #efe8d8;
  --ink: #efe8d8;
  --soft: #b9c8c4;
  --rule: rgba(239, 232, 216, 0.22);
}
.hero3d[data-variant="b"] { height: 330vh; }
.hero3d[data-variant="c"] { height: 290vh; }

.h3-sticky { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; background: radial-gradient(80% 70% at 50% 45%, #12303a 0%, var(--night-deep) 70%); }
.h3-card { position: absolute; inset: 0; clip-path: inset(var(--ct) var(--cr) var(--cb) var(--cl) round var(--crad)); background: var(--night-deep); }
.h3-stage { position: absolute; inset: 0; perspective: calc(var(--P) * 1px); perspective-origin: 50% var(--focus-y); }
.h3-world {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: 50% var(--focus-y) 0;
  transform: translateZ(calc(var(--dolly) * 1px)) rotateX(calc(var(--rx) * 1deg)) rotateY(calc(var(--ry) * 1deg));
  will-change: transform;
}
.h3-plate { position: absolute; left: 50%; top: var(--ptop); width: var(--pw); height: var(--ph); margin-left: calc(var(--pw) / -2); transform-style: preserve-3d; }

/* Layers are stacked a pixel or so apart, only to fix their order; the depth you
   see comes from the rig, not from these. */
.h3-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  transform-origin: 50% calc(var(--oy) * 100%);
  transform: translateZ(calc(var(--z) * 1px)) scale(calc((var(--P) - var(--z)) / var(--P) * var(--over, 1)));
  backface-visibility: hidden;
}
.h3-room { --z: -9; object-fit: cover; }
.h3-gl { opacity: 0; pointer-events: none; }
.hero3d.is-rigged .h3-gl { opacity: 1; }
.hero3d.is-rigged img.h3-elly { opacity: 0; }
.h3-gl-bg { --z: -8; }
.h3-gl-elly { --z: 0; }
.h3-dim {
  --z: -7;
  --over: 1.5;
  opacity: var(--dim);
  background: radial-gradient(ellipse 30% 44% at 50% 46%, rgba(6, 17, 22, 0.35) 0%, rgba(6, 17, 22, 0.94) 100%);
}
.h3-thread { --z: -4; overflow: visible; filter: var(--glow); translate: calc(var(--thx) * 1px) calc(var(--thy) * 1px); }
.h3-thread path { fill: none; stroke-width: 3; stroke-linecap: round; vector-effect: non-scaling-stroke; stroke-dasharray: 1 1; stroke-dashoffset: calc(1 - var(--draw)); }
.h3-elly { --z: -1; object-fit: cover; }

/* Her name, standing between the room and her. */
.h3-title {
  --z: -6;
  margin: 0;
  padding-top: calc(var(--ph) * 0.112);
  text-align: center;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: min(calc(var(--pw) * 0.137), 25vw);
  padding-right: calc(var(--pw) * 0.06);   /* sits a little left of her, clear of the lamp */
  line-height: 0.9;
  letter-spacing: -0.025em;
  white-space: nowrap;
  transform-style: preserve-3d;
  backface-visibility: visible;
}
.t3d { position: relative; display: inline-block; transform-style: preserve-3d; transform: translate(calc(var(--tx) * 1px), calc((var(--title-y) + var(--ty)) * 1px)) rotateY(calc(var(--yaw) * 1deg)); }
.t3-front {
  display: block;
  padding: 0 0.04em 0.1em;
  color: #fff6dc;
  background: var(--pastel);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 28px rgba(255, 232, 196, 0.3)) drop-shadow(0 0 2px rgba(255, 246, 220, 0.5));
  opacity: var(--title-o);
}
/* variation c: the name's thickness, built from copies set back one behind the next */
.t3-side { position: absolute; left: 0; top: 0; display: block; padding: 0 0.04em 0.1em; -webkit-text-fill-color: currentColor; pointer-events: none; }

.h3-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: calc(0.25 + 0.75 * var(--hud));
  background:
    linear-gradient(to top, var(--night-deep) 0%, rgba(10, 29, 35, 0.94) 16%, rgba(10, 29, 35, 0.6) 30%, transparent 50%),
    linear-gradient(to bottom, rgba(10, 29, 35, 0.66) 0%, transparent 15%);
}
.h3-fade { position: absolute; inset: 0; pointer-events: none; background: var(--night-deep); opacity: var(--fade); }

/* Words and buttons: flat, in the corners, in front of the scene. */
.h3-hud {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
  padding: 0 var(--pad) clamp(28px, 4.4vh, 46px);
  opacity: var(--hud);
  pointer-events: none;
}
.h3-hud.is-off { visibility: hidden; }
.h3-hud > * { pointer-events: auto; }
.h3-intro { max-width: 470px; }
.hero3d .hero-eyebrow { color: #cfdad6; }
.hero3d .hero-lede { margin-top: 12px; font-size: clamp(28px, 2.5vw, 38px); line-height: 1.08; }
.hero3d .hero-sub { margin-top: 12px; max-width: 40ch; font-size: 16px; line-height: 1.55; color: #c3d0cc; }
.hero3d .hero-actions { margin-top: 22px; }
.h3-side { display: flex; flex-direction: column; align-items: flex-end; gap: 18px; text-align: right; }
.hero3d .hero-facts { flex-direction: column; align-items: flex-end; gap: 3px; font-size: 14px; color: #c3d0cc; }
.h3-cue { display: inline-flex; align-items: center; gap: 12px; font-family: var(--font-label); font-size: 12px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: #cfdad6; }
.h3-cue::after { content: ""; width: 1px; height: 34px; background: linear-gradient(to bottom, currentColor, transparent); animation: cue 2.2s ease-in-out infinite; transform-origin: top; }
@keyframes cue { 0%, 100% { transform: scaleY(0.35); opacity: 0.5; } 50% { transform: scaleY(1); opacity: 1; } }

/* ---------- variation b: the card over her words ---------- */
.h3-marquee { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: 1vw; padding-bottom: 7svh; opacity: var(--mq); pointer-events: none; }
.mq { display: flex; width: max-content; font-family: var(--font-display); font-size: clamp(88px, 15.5vw, 250px); line-height: 0.98; letter-spacing: -0.02em; white-space: nowrap; will-change: transform; }
.mq-a { font-style: italic; color: #fff6dc; background: var(--pastel); background-size: 50% 100%; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; transform: translateX(calc(var(--mx) * -1vw - 8vw)); }
.mq-b { color: rgba(239, 232, 216, 0.92); transform: translateX(calc(var(--mx) * 1vw - 70vw)); }
.h3-caption {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100svh - var(--cb) + 20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  opacity: var(--cap);
  pointer-events: none;
}
.h3-caption strong { font-family: var(--font-display); font-weight: 400; font-size: 30px; line-height: 1; }
.h3-caption span { font-family: var(--font-label); font-size: 12px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: #b9c8c4; }
.hero3d:not([data-variant="b"]) .h3-marquee, .hero3d:not([data-variant="b"]) .h3-caption { display: none; }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .h3-title { padding-top: calc(var(--ph) * 0.158); padding-right: 0; }
  .h3-hud { flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 0; padding-bottom: 26px; }
  .h3-side { display: none; }
  .hero3d .hero-sub { display: none; }
  .hero3d .hero-lede { font-size: 27px; }
  .hero3d .hero-actions { margin-top: 18px; }
  .h3-scrim { background: linear-gradient(to top, rgba(10, 29, 35, 0.97) 0%, rgba(10, 29, 35, 0.78) 22%, transparent 50%), linear-gradient(to bottom, rgba(10, 29, 35, 0.7) 0%, transparent 14%); }
  .h3-caption strong { font-size: 26px; }
}

/* ---------- reduced motion: one still picture ---------- */
@media (prefers-reduced-motion: reduce) {
  .hero3d, .hero3d[data-variant] { height: auto; }
  .h3-sticky { position: relative; }
  .h3-cue { display: none; }
}
