/* home-wow — three homepage "wow" moments, layered on index.html.

   A. .vp-drag   — drag the live demo's edge; the sample site reflows under the finger.
   B. .hero-water — pool-light caustics behind the hero + ripples from the pointer.
   C. [data-build] — the hero's studio card assembles a website, then goes phone-size.
      Its CSS, and F/I/J (the build reel), live in build-reel.css: the reel is
      shared with /websites.html. Their JS is build-reel.js (reel) and C below.

   Every effect is additive: with no JS the page is exactly index.html, and with
   prefers-reduced-motion each one settles on a still, finished state. */

/* ============================== B. water ============================== */

.hero-water {
    position: absolute; inset: 0; z-index: -1;
    overflow: hidden; pointer-events: none;
    /* Full strength at the sides and down among the cards; faint behind the
       eyebrow, headline and lede. Measured: at full strength the eyebrow fell to
       3.04:1 and the lede to 4.12:1 over the deepest tint. Two mask layers,
       unioned: a vertical ramp (faint top) and a side band (clear centre). */
    -webkit-mask-image:
        linear-gradient(to bottom, rgba(0,0,0,.12) 0, rgba(0,0,0,.12) 330px, #000 430px),
        linear-gradient(to right, #000 0, #000 14%, transparent 24%, transparent 76%, #000 86%, #000 100%);
    -webkit-mask-composite: source-over;
            mask-image:
        linear-gradient(to bottom, rgba(0,0,0,.12) 0, rgba(0,0,0,.12) 330px, #000 430px),
        linear-gradient(to right, #000 0, #000 14%, transparent 24%, transparent 76%, #000 86%, #000 100%);
            mask-composite: add;
    opacity: 0;
    transition: opacity 1.2s ease;
}
.hero-water.is-ready { opacity: 1; }
/* A phone's text runs edge to edge, so there are no free sides: faint over the
   whole text block (eyebrow to lede ends ~430px at 390 wide), full below it. */
@media (max-width: 700px) {
    .hero-water {
        -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,.12) 0, rgba(0,0,0,.12) 440px, #000 540px);
                mask-image: linear-gradient(to bottom, rgba(0,0,0,.12) 0, rgba(0,0,0,.12) 440px, #000 540px);
    }
}

/* The eyebrow is 12px teal: the one hero line with no headroom over moving
   light (4.35:1 at the faint tint). One step deeper on the brand ramp. */
.hero .eyebrow { color: #095A6B; }

.hero-water .cw {
    position: absolute;
    background-image: var(--caustic);
    will-change: transform;
}
/* Each layer is one tile larger than the hero on the side it drifts from and
   moves exactly one tile per cycle, so the repeat hides the seam. */
.hero-water .cw-1 {
    top: -320px; left: -320px; right: 0; bottom: 0;
    background-size: 320px 320px;
    opacity: .38;
    animation: kmsCw1 38s linear infinite;
}
.hero-water .cw-2 {
    top: 0; left: 0; right: -480px; bottom: -480px;
    background-size: 480px 480px;
    opacity: .26;
    animation: kmsCw2 57s linear infinite;
}
@keyframes kmsCw1 { to { transform: translate3d(320px, 320px, 0); } }
@keyframes kmsCw2 { to { transform: translate3d(-480px, -480px, 0); } }

.hero-water canvas {
    position: absolute; inset: 0; width: 100%; height: 100%;
}

.hero-water.is-paused .cw { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
    html:not(.motion-on) .hero-water .cw { animation: none; }
}

/* ========================= A. drag to resize ========================= */

.vp-drag { position: relative; }
.vp-drag .vp-frame { position: relative; }
.vp-drag.is-dragging .vp-frame { transition: none; }
.vp-drag.is-dragging { cursor: ew-resize; user-select: none; -webkit-user-select: none; }

.vp-handle {
    position: absolute; top: 50%; left: 0;
    width: 28px; height: 72px; margin: -36px 0 0 -14px;
    display: grid; place-items: center;
    background: var(--deep, #0B6E82); color: #fff;
    border: 2px solid #fff; border-radius: 999px;
    box-shadow: 0 6px 18px rgba(12, 32, 39, .25);
    cursor: ew-resize; touch-action: none;
    z-index: 2;
}
.vp-handle:focus-visible { outline: 3px solid var(--gold, #E39B2E); outline-offset: 3px; }
.vp-handle .grip { display: flex; gap: 3px; }
.vp-handle .grip i { width: 2px; height: 22px; border-radius: 2px; background: currentColor; opacity: .9; }
.vp-handle:hover, .vp-drag.is-dragging .vp-handle { background: #095A6B; }

/* "Drag me" — shown until the first drag, so the affordance is never a mystery. */
.vp-handle .tip {
    position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%);
    white-space: nowrap;
    font: 600 .8rem/1 var(--display, system-ui);
    color: #fff; background: #0C2027;
    padding: .5rem .7rem; border-radius: 8px;
    pointer-events: none;
    transition: opacity .3s ease;
}
.vp-handle .tip::after {
    content: ""; position: absolute; left: 100%; top: 50%; margin-top: -5px;
    border: 5px solid transparent; border-left-color: #0C2027;
}
.vp-drag.is-used .vp-handle .tip { opacity: 0; }

.vp-drag.is-hint .vp-handle { animation: kmsNudge 1.1s cubic-bezier(.37, 0, .63, 1) 2; }
@keyframes kmsNudge {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(-10px); }
}

/* The live ruler under the frame: where each layout takes over. */
.vp-ruler {
    position: relative; height: 26px; margin: .55rem 0 0;
    font: 600 .72rem/1 var(--display, system-ui); color: var(--muted, #5D757E);
}
.vp-ruler span {
    position: absolute; top: 0; transform: translateX(-50%);
    padding-top: 9px; white-space: nowrap;
    transition: color .2s ease;
}
.vp-ruler span::before {
    content: ""; position: absolute; left: 50%; top: 0; width: 1px; height: 6px; background: currentColor;
}
.vp-ruler span.is-on { color: var(--deep, #0B6E82); }

@media (prefers-reduced-motion: reduce) {
    html:not(.motion-on) .vp-drag.is-hint .vp-handle { animation: none; }
}

/* ===================== D. the opening: the hero surfaces =====================
   html.kms-intro is set by home-wow-intro.js before first paint (once per session,
   never under reduced motion). Timeline, from first paint:
     0–0.9s   submerged: deep water, moving light, bubbles, a white headline
     0.9–2.5s the water drains; each text line turns to ink as the surface passes
     ~1.7–2.7s the cards surface, springing up from below
     ~2.6–3.4s the books drop into place, each with a splash
   home-wow.js sets the exact per-element times (--surf, --drop). The var() fallbacks
   are a complete, later timeline: if home-wow.js never runs, the page still drains
   and resolves to the finished hero instead of sticking underwater.
   Any click, key or scroll ends it at once (html.kms-intro-done). */

html.kms-intro:not(.kms-intro-done) .hero .wrap { position: relative; z-index: 3; }

/* The body of water. A pseudo-element so it exists from the very first paint. */
html.kms-intro:not(.kms-intro-done) .hero::after {
    content: ""; position: absolute; inset: 0; z-index: 1;
    background:
        radial-gradient(80% 60% at 70% 10%, rgba(120, 225, 240, .35), transparent 70%),
        linear-gradient(180deg, #0E7C92 0%, #0A6378 55%, #075169 100%);
    animation: kmsDrain var(--drain-dur, 1.6s) cubic-bezier(.7, 0, .3, 1) var(--drain-at, 3.4s) forwards;
    pointer-events: none;
}
/* Its moving parts (surface, light, bubbles) — inserted by home-wow.js, drained in step. */
.hero-flood {
    /* z 2, above the ::after base: ::after is the LAST child, so at an equal
       z-index it painted over the light and bubbles and hid them. */
    position: absolute; inset: 0; z-index: 2; pointer-events: none;
    animation: kmsDrain var(--drain-dur, 1.6s) cubic-bezier(.7, 0, .3, 1) var(--drain-at, 3.4s) forwards;
}
html:not(.kms-intro) .hero-flood, html.kms-intro-done .hero-flood { display: none; }
@keyframes kmsDrain { to { transform: translate3d(0, calc(100% + 70px), 0); } }

/* The surface: a crest with a foam line, rolling sideways. 1200px = 2 periods. */
.hero-flood .edge {
    position: absolute; left: 0; top: -46px; height: 48px; width: calc(100% + 600px);
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='48' viewBox='0 0 600 48'%3E%3Cpath d='M0 24 Q75 6 150 24 T300 24 T450 24 T600 24 V48 H0Z' fill='%230E7C92'/%3E%3Cpath d='M0 24 Q75 6 150 24 T300 24 T450 24 T600 24' fill='none' stroke='%23C9F6FC' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x 0 0 / 600px 48px;
    animation: kmsRoll 2.4s linear infinite;
    will-change: transform;
}
.hero-flood .edge.e2 {
    top: -38px; opacity: .55; animation-duration: 3.7s; animation-direction: reverse;
    filter: brightness(1.15);
}
@keyframes kmsRoll { to { transform: translate3d(-600px, 0, 0); } }

/* Sunlight from above: the same caustic net, as light on deep water this time. */
.hero-flood .light {
    position: absolute; inset: -320px 0 0 -320px;
    background-image: var(--caustic-light);
    background-size: 320px 320px;
    mix-blend-mode: screen; opacity: .55;
    animation: kmsCw1 9s linear infinite;
    will-change: transform;
}
.hero-flood .bubble {
    position: absolute; bottom: -20px;
    border-radius: 50%;
    border: 1.5px solid rgba(220, 250, 255, .75);
    background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.75) 0 18%, rgba(255,255,255,.08) 40%, transparent 70%);
    animation: kmsBubble var(--b-dur, 2.6s) cubic-bezier(.3, 0, .7, 1) var(--b-at, 0s) infinite;
    will-change: transform;
}
@keyframes kmsBubble {
    0%   { transform: translate3d(0, 0, 0); opacity: 0; }
    12%  { opacity: 1; }
    50%  { transform: translate3d(var(--b-sway, 12px), -55vh, 0); }
    100% { transform: translate3d(0, -110vh, 0); opacity: .2; }
}

/* Text: white underwater, ink once the surface has passed it. Animations, not
   transitions, so the fallback times run even if home-wow.js does not. */
html.kms-intro:not(.kms-intro-done) .hero .eyebrow {
    color: #A9EEF7;
    animation: kmsRise .8s cubic-bezier(.2, .8, .2, 1) .1s both, kmsInkEyebrow .16s linear var(--surf, 3.6s) forwards;
}
html.kms-intro:not(.kms-intro-done) .hero h1 .clause {
    color: #FFFFFF;
    animation: kmsRise .95s cubic-bezier(.2, .8, .2, 1) var(--rise, .2s) both, kmsInkH1 .16s linear var(--surf, 3.8s) forwards;
}
html.kms-intro:not(.kms-intro-done) .hero .lede {
    color: rgba(255, 255, 255, .92);
    animation: kmsRise .9s cubic-bezier(.2, .8, .2, 1) .5s both, kmsInkLede .16s linear var(--surf, 4s) forwards;
}
/* Rising through water: up from below, out of a refraction blur. No fade
   from opacity 0: this text is the page's LCP element, and Chrome does not
   count invisible text as painted. Fading it in pushed LCP from ~0.3s to
   ~1.9s on every first visit. Blurred-but-present from the first frame keeps
   the look, and the words really are on screen sooner. */
@keyframes kmsRise {
    from { transform: translate3d(0, 46px, 0); filter: blur(9px); }
    60%  { filter: blur(1.5px); }
    to   { transform: none; filter: none; }
}
html.kms-intro:not(.kms-intro-done) .hero h1 .clause + .clause { --rise: .38s; }
@keyframes kmsInkEyebrow { to { color: #095A6B; } }
@keyframes kmsInkH1      { to { color: #0C2027; } }
@keyframes kmsInkLede    { to { color: #3D5560; } }

/* The cards come up from below once the water has gone past them. The
   Animations button rides with the rail: parked 70px low and invisible, the
   rail's link would otherwise sit over the button and take its taps. */
html.kms-intro:not(.kms-intro-done) .hero .wing,
html.kms-intro:not(.kms-intro-done) .hero .gate-rail,
html.kms-intro:not(.kms-intro-done) .hero .motion-toggle-row {
    opacity: 0; transform: translate3d(0, 70px, 0) scale(.94);
    animation: kmsSurface .95s cubic-bezier(.2, 1.35, .4, 1) var(--surf, 4.4s) forwards;
}
@keyframes kmsSurface { to { opacity: 1; transform: none; } }

/* The books drop in. Listed FIRST so the bob below (listed second) wins once it
   starts; before its delay the bob does not apply and the drop shows. */
html.kms-intro:not(.kms-intro-done) .hero .cover img {
    animation:
        kmsDrop .85s cubic-bezier(.3, 1.45, .55, 1) var(--drop, 5s) both,
        kmsBob 4.6s ease-in-out calc(var(--drop, 5s) + .9s + var(--bob-at, 0s)) infinite alternate;
}
@keyframes kmsDrop {
    from { transform: translate3d(0, -190px, 0) rotate(-14deg) scale(.9); opacity: 0; }
    35%  { opacity: 1; }
    to   { transform: none; opacity: 1; }
}

/* ============================ E. floating books ============================
   After the opening (or without one), the covers ride the water: a slow bob and
   sway, each on its own phase so the fan never moves as one block. */
.hero .cover img { animation: kmsBob 4.6s ease-in-out var(--bob-at, 0s) infinite alternate; }
.hero .cover-1 img { --bob-at: -1.4s; }
.hero .cover-3 img { --bob-at: -2.9s; }
@keyframes kmsBob {
    from { transform: translate3d(0, 0, 0) rotate(-.8deg); }
    to   { transform: translate3d(0, -7px, 0) rotate(.8deg); }
}

@media (prefers-reduced-motion: reduce) {
    html:not(.motion-on) .hero .cover img { animation: none; }
}

/* ======================= G. the Animations button =======================
   The visitor's choice beats the OS (home-wow-intro.js sets the class before
   first paint). html.motion-on is the escape hatch written into every
   reduced-motion block above and in index.html. html.motion-off below is
   those same blocks, applied regardless of the OS: keep the two in step. */
html.motion-off *, html.motion-off *::before, html.motion-off *::after {
    animation: none !important; transition: none !important; scroll-behavior: auto !important;
}
html.motion-off::view-transition-group(*),
html.motion-off::view-transition-old(*),
html.motion-off::view-transition-new(*) { animation: none !important; }
html.motion-off .hero-route a:hover,
html.motion-off .card:hover { transform: none; }
html.motion-off .hero .waterline { transform: none; }
html.motion-off.kms-js .reveal > * { opacity: 1; transform: none; }
html.motion-off .covers-in { transform: none; }
html.motion-off .cover { transform: translate(0, var(--ty0)) rotate(var(--rot0)) scale(var(--sc0)); }
html.motion-off .cover-2 { --ty0: 10px;  --rot0: -7deg; --sc0: 1; }
html.motion-off .cover-1 { --ty0: -14px; --rot0: 0deg;  --sc0: 1.1; }
html.motion-off .cover-3 { --ty0: 10px;  --rot0: 7deg;  --sc0: 1; }

/* In flow under the coaching rail, never a fixed overlay (a fixed control sat
   under the mobile bar once and could not be tapped). Hidden without JS: it
   would be a button that does nothing. */
.motion-toggle-row { display: flex; justify-content: flex-end; margin: .6rem 0 0; }
.motion-toggle-row[hidden] { display: none; }
.motion-toggle {
    display: inline-flex; align-items: center; gap: .45rem; min-height: 40px; padding: 0 .9rem;
    font-family: inherit; font-size: .85rem; font-weight: 600; line-height: 1; color: var(--deep-2, #095A6B);
    background: #EFF6F8; border: 1px solid var(--rule, #D5E3E8); border-radius: 999px; cursor: pointer;
}
.motion-toggle:hover { background: #E2EFF3; }
.motion-toggle:focus-visible { outline: 2px solid var(--deep, #0B6E82); outline-offset: 2px; }
.motion-toggle .mt-dot { width: .55rem; height: .55rem; border-radius: 50%; background: #8A9BA3; }
.motion-toggle[aria-pressed="true"] .mt-dot { background: var(--deep, #0B6E82); }

/* ===================== H. gentle (reduced motion, no choice) =====================
   The OS asked for reduced motion and the visitor has not pressed the button.
   Rather than a frozen page: the water light drifts at a third of its speed
   and blocks fade in place. Opacity and a slow ambient drift only; nothing
   slides, scales, bobs, pins or floods. The !important rules out-rank the
   blanket reduced-motion kill on specificity, not on order. */
html.motion-gentle .hero-water .cw-1 { animation: kmsCw1 120s linear infinite !important; }
html.motion-gentle .hero-water .cw-2 { animation: kmsCw2 180s linear infinite !important; }
html.motion-gentle .hero-water.is-paused .cw { animation-play-state: paused !important; }
html.motion-gentle.kms-js .reveal:not(.in) > * { opacity: 0; transform: none; }
html.motion-gentle.kms-js .reveal.in > * {
    opacity: 1; transform: none;
    transition: opacity .7s ease !important;
    transition-delay: calc(var(--i, 0) * 70ms) !important;
}
