/* The home page: the tower above a sea of clouds, the M drawn over it and filled with it,
 * the clouds rising into the page, then the statement, the photos and the building.
 * Scroll state comes from assets/js/home.js as custom properties on .arrival, each 0..1:
 *   --a  the lift: the line leaves, the tower rises, the clouds part
 *   --d  the M's strokes drawing
 *   --f  the M filling with the tower
 *   --r  the clouds rising over everything
 * plus --mx, --my, --mw, --mh, the M's box in the stage, for its mask.
 * Their values here are the opening at rest, which is also the page without scripts. */

/* ── Header: floats over the sky, solid once the opening has passed ── */
.home-header { background: transparent; color: var(--ink); border-bottom-color: transparent; }
.home-header .btn-tour { background: var(--ink); color: #fff; }
.home-header .btn-tour:hover { background: var(--ink-2); }
body.is-departed .home-header { background: var(--paper); border-bottom-color: var(--line); }

/* ── The opening ── */
.arrival {
  --a: 0; --d: 0; --f: 0; --r: 0;
  --mx: 0px; --my: 0px; --mw: 0px; --mh: 0px;
  position: relative; height: 520svh; margin-top: calc(-1 * var(--header-h)); background: var(--paper);
}
.arrival-stage {
  position: sticky; top: 0; height: 100svh; overflow: hidden; isolation: isolate;
  background: linear-gradient(#a9c6e2, #e9d5cc);
}
.arrival-stage img { max-width: none; user-select: none; -webkit-user-drag: none; }

.sky-layer {
  position: absolute; inset: -4svh 0 auto; width: 100%; height: 112svh; object-fit: cover; object-position: 50% 60%;
  transform: translate3d(0, calc(var(--a) * -3svh), 0) scale(calc(1.02 + var(--a) * 0.05));
}

/* The tower: top floors above the clouds, rising and growing as the page scrolls. */
.tower-layer { position: absolute; inset: 0; pointer-events: none; }
.arrival-image, .m-fill-image {
  position: absolute; left: 50%; top: 29svh; height: 150svh; width: auto;
  transform-origin: 50% 0;
  transform: translate3d(-50%, calc(var(--a) * -15svh), 0) scale(calc(1 + var(--a) * 0.14));
  will-change: transform;
}
.arrival > .arrival-stage > .tower-layer { opacity: calc(1 - var(--f)); }

/* Clouds: back puffs part sideways, the banks sink and the front one leaves fastest. */
.cloud-layer { position: absolute; inset: 0; pointer-events: none; }
.cloud { position: absolute; height: auto; will-change: transform; }
.puff-a { left: -8vw; top: 38svh; width: 48vw; opacity: 0.92; transform: translate3d(calc(var(--a) * -20vw), calc(var(--a) * 6svh), 0); }
.puff-b { right: -10vw; top: 30svh; width: 46vw; opacity: 0.9; transform: translate3d(calc(var(--a) * 22vw), calc(var(--a) * 4svh), 0); }
.bank-a { left: 50%; bottom: -17svh; width: 150vw; transform: translate3d(-50%, calc(var(--a) * 10svh), 0); }
.bank-b { left: 50%; bottom: -33svh; width: 185vw; transform: translate3d(-46%, calc(var(--a) * 34svh), 0); }

/* The line: one short headline over the sky, leaving first. */
.arrival-copy {
  position: absolute; left: 0; right: 0; top: calc(var(--header-h) + 6.5svh); z-index: 2;
  display: grid; justify-items: center; padding: 0 var(--opening-gutter); text-align: center;
  opacity: clamp(0, calc(1 - var(--a) * 1.8), 1);
  transform: translate3d(0, calc(var(--a) * -9svh), 0);
}
.arrival-claim {
  font-family: var(--font-display); font-weight: 600; letter-spacing: -0.05em; line-height: 0.92;
  font-size: clamp(54px, 9vw, 168px); color: var(--ink); max-width: 11ch;
}

/* The M: strokes drawn over the tower, then the tower shows only through the M. */
.m-lockup {
  position: absolute; left: 50%; top: 52%; z-index: 3; height: min(74svh, 132vw); width: auto; overflow: visible;
  transform: translate(-50%, -50%); pointer-events: none;
}
.m-stroke {
  fill: none; stroke: #fff; stroke-width: 1.4px; vector-effect: non-scaling-stroke;
  stroke-dasharray: 1 1; stroke-dashoffset: calc(1 - var(--d));
  opacity: calc(min(1, var(--d) * 8) * (1 - var(--f) * 0.55));
  filter: drop-shadow(0 1px 6px rgba(5, 28, 44, 0.35));
}
.m-words { fill: var(--ink); opacity: var(--f); }
.m-fill {
  position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: var(--f);
  -webkit-mask: var(--m-mask) var(--mx) var(--my) / var(--mw) var(--mh) no-repeat;
  mask: var(--m-mask) var(--mx) var(--my) / var(--mw) var(--mh) no-repeat;
}
.m-fill .m-fill-image {
  /* Inside the M the tower is closer, so every stroke shows glass and stone, never sky. */
  filter: saturate(1.08) contrast(1.06);
  transform: translate3d(-50%, -88svh, 0) scale(calc(1.32 + var(--f) * 0.1));
}

/* The clouds rise and the page turns white beneath them. */
.cloud-rise {
  --bank-h: 39vw;
  position: absolute; left: -8vw; right: -8vw; top: 100%; z-index: 4; pointer-events: none;
  transform: translate3d(0, calc(var(--r) * (-100svh - var(--bank-h) - 2vw)), 0); will-change: transform;
}
.bank-c { position: relative; display: block; width: 100%; }
.cloud-rise-white { position: relative; height: 210svh; margin-top: -19vw; background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--paper) 85%, transparent) 9vw, var(--paper) 15vw); }

/* ── After the opening ── */
.statement {
  position: relative; z-index: 1; padding: clamp(72px, 12svh, 140px) var(--gutter) clamp(64px, 10svh, 120px);
  display: grid; justify-items: end; gap: 36px;
}
.statement-text {
  max-width: 24ch; font-family: var(--font-display); font-weight: 500; letter-spacing: -0.035em; line-height: 1.12;
  font-size: clamp(30px, 3.6vw, 58px); color: var(--ink);
}
.statement-text span { color: color-mix(in srgb, var(--ink) 52%, var(--paper)); }

/* The wide photo opens from an inset frame to the full width as it scrolls in. */
.reveal-wide { --reveal: 1; margin: 0 0 clamp(72px, 12svh, 140px); overflow: hidden; }
.reveal-wide img {
  width: 100%; height: min(92svh, 920px); object-fit: cover;
  clip-path: inset(calc((1 - var(--reveal)) * 14%) calc((1 - var(--reveal)) * var(--gutter-pct, 12%)));
  transform: scale(calc(1.12 - var(--reveal) * 0.12));
}

/* Slats: photos in tall strips, the M's parallel lines turned into windows. */
.slats {
  display: grid; grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr)); gap: clamp(10px, 1.6vw, 28px);
  padding: 0 var(--gutter); margin: clamp(40px, 8svh, 96px) 0 clamp(80px, 14svh, 160px); align-items: start;
}
.slat { margin: 0; overflow: hidden; transform: translate3d(0, calc((var(--i) - 2) * var(--slat-shift, 0px)), 0); }
.slat img { width: 100%; aspect-ratio: 1 / 3.1; object-fit: cover; }
.slat:nth-child(even) { margin-top: clamp(40px, 9svh, 120px); }

/* The building: the explorer builds itself floor by floor as it scrolls in. */
.home-building { padding: clamp(24px, 6svh, 72px) 0 clamp(64px, 10svh, 120px); background: var(--paper); }
.home-building .explorer-head h2 { font-size: clamp(36px, 5vw, 84px); letter-spacing: -0.05em; }

/* ── Boot cover: holds the page until the tower is ready ── */
.hero-boot { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: var(--paper); transition: opacity 0.6s ease 0.1s; }
.hero-boot[data-state="leaving"] { opacity: 0; pointer-events: none; }
.hero-boot-mark { font-size: clamp(56px, 9vw, 96px); color: var(--accent); }
.hero-boot[data-state="loading"] .hero-boot-mark { animation: boot-beat 1.6s ease-in-out infinite; }
@keyframes boot-beat { 0%, 100% { transform: scale(1); opacity: 0.8; } 50% { transform: scale(1.04); opacity: 1; } }

@media (max-width: 760px) {
  .arrival { height: 430svh; }
  .arrival-image, .m-fill-image { top: 38svh; height: auto; width: 128vw; }
  .arrival-copy { top: calc(var(--header-h) + 5svh); }
  .arrival-claim { font-size: clamp(48px, 15vw, 76px); }
  .puff-a { width: 80vw; top: 46svh; left: -30vw; }
  .puff-b { width: 76vw; top: 36svh; right: -34vw; }
  .bank-a { width: 260vw; bottom: -4svh; }
  .bank-b { width: 300vw; bottom: -14svh; }
  .m-lockup { height: 62svh; }
  .cloud-rise { left: -40vw; right: -40vw; --bank-h: 60vw; }
  .statement { justify-items: start; }
  .statement-text { font-size: clamp(26px, 7.4vw, 34px); }
  .reveal-wide img { height: 64svh; }
  .slats { --n: 3; padding: 0 22px; }
  .slat:nth-child(n + 4) { display: none; }
}

/* Reduced motion (after the phone rules, so its height wins there too): the opening holds at rest
 * and the page scrolls straight past it; the M and the rising clouds are left out. */
@media (prefers-reduced-motion: reduce) {
  .hero-boot[data-state="loading"] .hero-boot-mark { animation: none; }
  .arrival { height: auto; }
  /* Not sticky here, so the stage also covers the header's height it starts under. */
  .arrival-stage { position: relative; height: calc(100svh + var(--header-h)); }
  .m-lockup, .m-fill, .cloud-rise { display: none; }
  .reveal-wide img { clip-path: none; transform: none; }
  .slat { transform: none; }
}

