/* KYMA Estates: the opening screen, measured from video F (see SPEC-video-F-exact.md).
   Every number in a calc() with --u is a pixel of the video's 1440 x 945 page; --u scales that page to the hero. */

.hero {
  /* desktop stage: 1440 x 945 */
  --word-size: 384;     /* Inter Tight 600: cap height 279 */
  --word-x: -540;       /* left edge of the word's box, from the centre line */
  --word-b: 446;        /* bottom of the word's box above the hero's bottom: its baseline lands on y 447 */
  --kick-size: 40;
  --kick-x: -31;
  --kick-b: 727;
  --wm-w: 386;          /* width of the woman's 3:4 box (the picture is fitted into it, feet at the bottom) */
  --wm-b: 45;           /* its bottom edge above the hero's bottom */
  --wm-x: 2;            /* nudge right of centre */
  --wm-hands: 0.819;    /* the underside of her hands is this many box-widths above the box's bottom: the rail goes there */
  --rail-h: 13;
  --sill-h: 23;
  --floor-h: 77;
  --under: 70;          /* extra floor below the fold, so nothing shows when the balcony overshoots */
  --joint: 286;         /* glass panels are this wide */
  position: sticky;
  top: 0;
  top: min(0px, calc(100vh - var(--hero-h)));    /* taller than the window (a phone on its side): its foot stays on the window's foot, so her rise is in view */
  top: min(0px, calc(100svh - var(--hero-h)));
  height: var(--hero-h);
  overflow: hidden;
  background: #2f84a8;
  isolation: isolate;
}

/* The scroll stretch (the owner's touch, 17/11/2026). The page scrolls through .hero-track while the screen inside it
   stays put; intro.js turns that scroll into the balcony and the woman rising. --pin is how long the stretch is, in
   screens. Without scripts, or with reduced motion, there is no stretch and she is simply there. */
.hero-track { position: relative; background: var(--paper); }
html.js .hero-track { --pin: 1.15; height: calc(var(--hero-h) * (1 + var(--pin))); }


/* the picture layers are a little bigger than the hero, so they can drift without showing an edge */
.layer { position: absolute; inset: -4% -3% -8%; will-change: transform; }
.layer img, .layer canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; display: block; }
.layer canvas { transition: opacity .35s linear, visibility 0s .35s; }
.hero.is-still .layer canvas { opacity: 0; visibility: hidden; }
#layer-back { z-index: 0; }
#layer-front { z-index: 2; pointer-events: none; }
html.intro-play .hero:not(.is-still) #layer-front { visibility: hidden; }

/* the giant word sits between the two picture layers: in front of the sea and sky, behind the trees */
.headline { position: absolute; z-index: 1; left: 50%; bottom: 0; width: 0; height: 0; margin: 0; color: #fff; will-change: transform, opacity; }
.headline span { position: absolute; display: block; white-space: nowrap; line-height: 1; }
.headline .word {
  left: calc(var(--u) * var(--word-x)); bottom: calc(var(--u) * var(--word-b));
  font-family: "Inter Tight", "Inter", system-ui, sans-serif; font-weight: 600;
  font-size: calc(var(--u) * var(--word-size)); letter-spacing: -.008em;
  text-shadow: 0 0 calc(var(--u) * 30) rgba(255, 255, 255, .18);
}
.headline .kicker {
  left: calc(var(--u) * var(--kick-x)); bottom: calc(var(--u) * var(--kick-b));
  font-weight: 400; font-size: calc(var(--u) * var(--kick-size)); letter-spacing: -.005em;
  text-shadow: 0 1px 14px rgba(0, 60, 90, .25);
}

/* the glass balustrade and the woman rise together */
.balcony {
  position: absolute; z-index: 3; left: -4%; right: -4%;
  bottom: calc(var(--u) * var(--under) * -1);
  height: calc(var(--u) * (var(--wm-b) + var(--wm-w) * var(--wm-hands) + var(--under)));
  will-change: transform; pointer-events: none;
}
.balcony > * { position: absolute; left: 0; right: 0; }
.glass {
  top: calc(var(--u) * var(--rail-h));
  bottom: calc(var(--u) * (var(--floor-h) + var(--sill-h) + var(--under)));
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, .5)) calc(50% + var(--u) * 11) 0 / 1px 100% no-repeat,
    linear-gradient(90deg, rgba(255, 255, 255, .34) 0 1px, transparent 1px) calc(50% + var(--u) * 11) 0 / calc(var(--u) * var(--joint)) 100% repeat-x,
    linear-gradient(180deg, rgba(232, 244, 236, .38), rgba(214, 233, 221, .28));
  -webkit-backdrop-filter: blur(.9px) saturate(.88) brightness(1.05);
  backdrop-filter: blur(.9px) saturate(.88) brightness(1.05);
}
.rail {
  top: 0; height: calc(var(--u) * var(--rail-h));
  background: linear-gradient(180deg, #e3ece6 0%, #c9d5cd 30%, #c4d0ce 78%, #9fada3 100%);
  box-shadow: 0 calc(var(--u) * 5) calc(var(--u) * 12) rgba(30, 55, 40, .22);
}
.sill {
  bottom: calc(var(--u) * (var(--floor-h) + var(--under))); height: calc(var(--u) * var(--sill-h));
  background: linear-gradient(180deg, #d3e5d5 0 14%, #7d8e7e 22%, #65735f 55%, #435849 100%);
}
.floor {
  bottom: 0; height: calc(var(--u) * (var(--floor-h) + var(--under))); overflow: hidden;
  background:
    linear-gradient(100deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, .26) 78%, rgba(255, 255, 255, .1) 100%),
    linear-gradient(180deg, #6a867a 0, #a7c2b3 16%, #b0c8b8 42%, #b6ccbc 100%);
}
/* a soft patch on the floor where she stands */
.floor::after {
  content: ""; position: absolute; left: 50%; top: calc(var(--u) * (var(--floor-h) - var(--wm-b) - 24));
  width: calc(var(--u) * var(--wm-w) * .4); height: calc(var(--u) * 40);
  transform: translateX(calc(-50% + var(--u) * var(--wm-x)));
  background: radial-gradient(closest-side, rgba(28, 74, 56, .34), rgba(28, 74, 56, 0));
  filter: blur(calc(var(--u) * 4));
}
/* her reflection in the polished floor: the same cut-out, upside down under her feet (2% of the box is under them) */
.floor .mirror {
  position: absolute; left: 50%; width: calc(var(--u) * var(--wm-w)); height: auto; aspect-ratio: 3 / 4;
  top: calc(var(--u) * (var(--floor-h) - var(--wm-b) - var(--wm-w) * .053));
  transform: translateX(calc(-50% + var(--u) * var(--wm-x))) scaleY(-1);
  object-fit: contain; object-position: 50% 100%;
  opacity: .3; filter: blur(calc(var(--u) * 3.5));
  -webkit-mask-image: linear-gradient(to top, #000 0, transparent 34%); mask-image: linear-gradient(to top, #000 0, transparent 34%);
}
.balcony .woman {
  left: 50%; right: auto; width: calc(var(--u) * var(--wm-w)); height: auto; aspect-ratio: 3 / 4;
  bottom: calc(var(--u) * (var(--wm-b) + var(--under)));
  transform: translateX(calc(-50% + var(--u) * var(--wm-x)));
  object-fit: contain; object-position: 50% 100%;
}

/* ---------- the doors ---------- */
.doors { display: none; position: fixed; inset: 0; z-index: 90; overflow: hidden; --d: var(--u); }
html.intro-play .doors { display: block; animation: doors-bail 0s 9s forwards; }
html.intro-play .doors.is-live { animation: none; }
.doors[hidden] { display: none !important; }
@keyframes doors-bail { to { visibility: hidden; } }   /* if the script never runs, the doors do not stay shut */
.leaf { position: absolute; top: 0; bottom: 0; width: 50%; will-change: transform; }
/* each leaf shows its edge as a lighter strip (18) beside the seam; the left one is shaded before it, the right one after */
.leaf-l {
  left: 0;
  background: linear-gradient(270deg, #cbcfd2 0 calc(var(--d) * 18), #a1a5a8 calc(var(--d) * 18) calc(var(--d) * 20),
    #aeb2b5 calc(var(--d) * 27), #bbbfc2 calc(var(--d) * 35), #c5c9cc calc(var(--d) * 50), #c9cdd0 calc(var(--d) * 62));
}
.leaf-r {
  right: 0;
  background: linear-gradient(90deg, #cbcfd2 0 calc(var(--d) * 18), #999da0 calc(var(--d) * 18) calc(var(--d) * 22),
    #aaaeb1 calc(var(--d) * 23), #b7bbbe calc(var(--d) * 32), #bdc1c4 calc(var(--d) * 40), #c5c9cc calc(var(--d) * 55), #c9cdd0 calc(var(--d) * 80));
}
.handle, .keyhole { position: absolute; left: calc(var(--d) * 55); top: 58.2%; width: 0; height: 0; }
.keyhole { margin-top: calc(var(--d) * 77); }
.handle::before, .keyhole::before {      /* the round plates, 52 across */
  content: ""; position: absolute; left: calc(var(--d) * -26); top: calc(var(--d) * -26);
  width: calc(var(--d) * 52); height: calc(var(--d) * 52); border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #3a3f43, #26292c 62%, #1c1f21);
  box-shadow: calc(var(--d) * 3) calc(var(--d) * 6) calc(var(--d) * 10) rgba(70, 76, 82, .45);
}
.handle::after {                         /* the lever: 127 long from the plate's centre, 18 thick */
  content: ""; position: absolute; left: 0; top: calc(var(--d) * -9);
  width: calc(var(--d) * 127); height: calc(var(--d) * 18); border-radius: 0 calc(var(--d) * 9) calc(var(--d) * 9) 0;
  background: linear-gradient(180deg, #34383c, #26292c 55%, #1e2123);
  box-shadow: calc(var(--d) * 6) calc(var(--d) * 22) calc(var(--d) * 18) rgba(90, 96, 102, .5);
}
.keyhole::after {                        /* the slot: a round top and a short stem */
  content: ""; position: absolute; left: calc(var(--d) * -6); top: calc(var(--d) * -15);
  width: calc(var(--d) * 12); height: calc(var(--d) * 29);
  background:
    radial-gradient(circle calc(var(--d) * 6) at 50% calc(var(--d) * 6), #c3c6c7 0, #9a9ea0 96%, transparent 100%),
    linear-gradient(180deg, #8a8e90, #6f7374) 50% 100% / calc(var(--d) * 7) calc(var(--d) * 21) no-repeat;
}

/* ---------- phone stage: 390 x 760 ---------- */
@media (max-width: 700px) {
  .hero {
    --word-size: 112; --word-x: -162; --word-b: 425; --kick-size: 17; --kick-x: -12; --kick-b: 507;   /* raised 40 on 17/11/2026: the pines of the Cyprus picture stand higher than the palms did */
    --wm-w: 304; --wm-b: 12; --wm-x: 1; --rail-h: 8; --sill-h: 11; --floor-h: 56; --under: 50; --joint: 150;
  }
  .doors { --d: calc(var(--u) * .58); }
}

@media (max-width: 700px) {
  html.js .hero-track { --pin: 1; }
}
/* a window taller than 5:4 (a tablet held upright): the screen cannot fill it, so nothing is pinned and she rises while
   the first screen scrolls away (intro.js, UNPINNED_SHARE) */
@media (min-width: 701px) and (max-aspect-ratio: 124/100) {
  html.js .hero-track { height: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .layer canvas { transition: none; }
  html.js .hero-track { height: auto; }
}
