/* The 3D fly-through preview (page slug "fly"). Loaded only by page-fly.php.
   Top half: the page as it shows with no JavaScript or with reduced motion (a plain dark page).
   Bottom half (.is-3d): the fly-through. fly.js adds that class when motion is welcome. */

body.fly-page { --space: #0A1040; --glow: rgba(140, 160, 255, 0.22); background: var(--space); background-image: none; color: #fff; }
body.fly-page.palette-purple { --space: #1D0736; --glow: rgba(200, 150, 255, 0.22); }

/* Header and footer on the dark page */
.fly-page .site-header { position: absolute; inset: 0 0 auto; z-index: 40; background: transparent; }
.fly-page .header-inner { border-bottom-color: rgba(255, 255, 255, 0.3); transition: border-color 0.3s; }
.fly-page .site-name, .fly-page .site-name:hover, .fly-page .site-nav a, .fly-page .site-nav a:hover { color: #fff; transition: color 0.3s; }
.fly-page .site-nav a[aria-current="page"]::after { background: var(--yellow); }
.fly-page .idea-btn { box-shadow: 4px 4px 0 var(--pink); }
.fly-page .idea-btn:active { box-shadow: 1px 1px 0 var(--pink); }
.fly-page .wh-progress { background: var(--yellow); }
.fly-page :focus-visible { outline-color: var(--yellow); }
.fly-page .site-main { padding: 0; }
.fly-page .site-footer { margin-top: 0; background: var(--yellow); border-top: 2px solid var(--ink); color: var(--ink); }
body.fly-on-yellow .site-name, body.fly-on-yellow .site-name:hover, body.fly-on-yellow .site-nav a, body.fly-on-yellow .site-nav a:hover { color: var(--ink); }
body.fly-on-yellow .header-inner { border-bottom-color: var(--ink); }
body.fly-on-yellow .idea-btn { box-shadow: 4px 4px 0 var(--ink); }
body.fly-on-yellow .wh-progress { background: var(--pink); }
body.fly-on-yellow :focus-visible { outline-color: var(--ink); }

/* ---------- Shared pieces ---------- */
.fly { position: relative; color: #fff; --wl: clamp(300px, 52vw, 980px); --wp: clamp(180px, 22vw, 400px); }
@media (max-width: 819px) { .fly { --wl: 88vw; --wp: 50vw; } }
.fly h1, .fly h2 { margin: 0; color: #fff; font-family: var(--display); font-weight: 800; text-wrap: balance; }
.fly h1 { font-size: clamp(3.1rem, 1.2rem + 6.2vw, 7.2rem); line-height: 0.92; letter-spacing: -0.035em; }
.fly h2 { font-size: clamp(2rem, 1.2rem + 2.3vw, 3.3rem); line-height: 1.02; letter-spacing: -0.025em; }
.fly p { margin: 0; text-wrap: pretty; }
.fly-lead { margin-top: 1.1em !important; max-width: 27ch; font-size: clamp(1.2rem, 1rem + 0.8vw, 1.6rem); line-height: 1.4; color: rgba(255, 255, 255, 0.9); }
.fly-caption p { margin-top: 18px; font-size: 1.12rem; line-height: 1.55; color: rgba(255, 255, 255, 0.88); }

.fly-mark { position: relative; display: inline-block; padding: 0 0.1em; color: var(--ink); isolation: isolate; }
.fly-mark::before { content: ""; position: absolute; inset: 0.08em -0.03em 0.02em; z-index: -1; background: var(--yellow); rotate: -1.5deg; transform-origin: left; }
.fly-star { position: absolute; top: -0.16em; right: -0.5em; width: 0.42em; height: 0.42em; fill: none; stroke: var(--pink); stroke-width: 9; }

.fly-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 28px; margin-top: 32px; }
.fly-btn { display: inline-block; padding: 13px 22px; border: 2px solid var(--ink); background: var(--pink); box-shadow: 5px 5px 0 #fff; color: var(--ink); font-family: var(--display); font-weight: 800; font-size: 1.15rem; line-height: 1.15; text-decoration: none; transition: translate 0.15s, box-shadow 0.15s, background 0.2s; }
.fly-btn:hover { background: var(--yellow); color: var(--ink); }
.fly-btn:active { translate: 4px 4px; box-shadow: 1px 1px 0 #fff; }
.fly-link { color: #fff; font-weight: 600; font-size: 1.05rem; text-decoration: underline; text-decoration-color: var(--pink); text-decoration-thickness: 2px; text-underline-offset: 0.35em; }
.fly-link:hover { color: var(--yellow); text-decoration-color: var(--yellow); }

/* A screen: her window frame, lit against the dark */
.fly-screen { position: relative; display: block; margin: 0; overflow: hidden; border: 2px solid var(--ink); border-radius: 12px; background: #fff; box-shadow: 10px 10px 0 var(--pink), 0 0 110px var(--glow); }
.fly-stop:nth-of-type(even) .fly-screen, .fly-screen.shadow-alt { box-shadow: 10px 10px 0 var(--yellow), 0 0 110px var(--glow); }
.fly-bar { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-bottom: 2px solid var(--ink); background: #fff; color: var(--ink); font-family: var(--mono); font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.fly-bar i { flex: none; width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 50%; }
.fly-bar i:nth-child(1) { background: var(--pink); }
.fly-bar i:nth-child(2) { background: var(--yellow); }
.fly-bar b { margin-left: 6px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.fly-view { position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; background: #fff; }
.fly-screen.is-port .fly-view { aspect-ratio: 3 / 4; }
.fly-screen.is-wide .fly-view { aspect-ratio: 4 / 3; }
.fly-view img, .fly-view video { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 0%; }
.fly-dim { position: absolute; inset: 0; background: var(--space); opacity: 0; pointer-events: none; }
.fly-screen.is-panel { display: none; }

/* ---------- Plain page (no JavaScript, or reduced motion) ---------- */
.fly-stage { padding-top: 150px; }
.fly-hero { width: min(100% - 40px, 1240px); margin: 0 auto; padding: 32px 0 72px; }
.fly-stop { display: grid; gap: 36px; align-items: center; width: min(100% - 40px, 1240px); margin: 0 auto; padding: 64px 0; }
@media (min-width: 900px) {
	.fly-stop { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 72px; }
	.fly-stop:nth-of-type(even) .fly-screens { order: 2; }
}
.fly-screens { display: flex; align-items: flex-start; gap: 28px; }
.fly-screens .fly-screen { flex: 1; min-width: 0; }
.fly-stop.is-final { display: block; width: auto; margin-top: 64px; padding: 96px 20px; background: var(--yellow); color: var(--ink); text-align: center; }
.fly-stop.is-final h2 { color: var(--ink); font-size: clamp(2.6rem, 1.4rem + 5vw, 5.6rem); }
.fly-stop.is-final .fly-caption p { color: var(--ink); font-size: 1.3rem; }
.fly-stop.is-final .fly-actions { justify-content: center; }
.fly-stop.is-final .fly-btn { box-shadow: 5px 5px 0 var(--ink); }
.fly-stop.is-final .fly-btn:hover { background: #fff; }
.fly-stop.is-final .fly-btn:active { box-shadow: 1px 1px 0 var(--ink); }
.fly-stop.is-final .fly-link { color: var(--ink); text-decoration-color: var(--ink); }
.fly-stop.is-final .fly-link:hover { color: var(--ink); text-decoration-color: var(--pink); }
.fly-stop.is-final .fly-screens { display: none; }
.fly-dust, .fly-rail, .fly-video-toggle, .fly-hint { display: none; }
html.fly-pending .fly { visibility: hidden; }

/* ======================================================================
   The fly-through (added by fly.js)
   ====================================================================== */
html.fly-3d body.fly-page .site-header { position: fixed; background: var(--space); transition: background 0.3s; }
html.fly-3d body.fly-on-yellow .site-header { background: var(--yellow); }
.fly.is-3d { height: calc(var(--n) * var(--seg) + 100vh); height: calc(var(--n) * var(--seg) + 100dvh); --seg: 120vh; }
.is-3d .fly-stage { position: sticky; top: 0; height: 100vh; height: 100dvh; padding: 0; overflow: clip; perspective: 1100px; background: var(--space); }

.is-3d .fly-dust { display: block; position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.is-3d .fly-world { position: absolute; left: 50%; top: 50%; z-index: 1; width: 0; height: 0; transform-style: preserve-3d; will-change: transform; }
.is-3d .fly-screen { position: absolute; left: 0; top: 0; width: var(--wl); backface-visibility: hidden; cursor: pointer; }
.is-3d .fly-screen.is-port { width: var(--wp); }
.is-3d .fly-screen.is-port.is-wide { width: calc(var(--wp) * 1.45); }
.is-3d .fly-screen.is-panel { display: block; width: var(--wl); aspect-ratio: 16 / 10; border: 0; border-radius: 0; background: var(--yellow); box-shadow: none; cursor: default; }

/* Words sit on top of the 3D space and never block the screens behind them */
.is-3d .fly-hero { position: absolute; z-index: 2; top: 50%; left: max(5vw, calc((100vw - 1320px) / 2)); width: min(46vw, 640px); margin: 0; padding: 0; translate: 0 -50%; transform-origin: 20% 50%; pointer-events: none; }
.is-3d .fly-stop { position: absolute; inset: 0; z-index: 2; display: block; width: auto; margin: 0; padding: 0; background: none; text-align: left; pointer-events: none; }
.is-3d .fly-screens { display: none; }
.is-3d .fly-caption { position: absolute; top: 50%; width: min(30vw, 430px); translate: 0 -50%; }
.is-3d .fly-stop.cap-left .fly-caption { left: max(5vw, calc((100vw - 1320px) / 2)); }
.is-3d .fly-stop.cap-right .fly-caption { right: max(6vw, calc((100vw - 1320px) / 2)); }
.is-3d .fly-hero a, .is-3d .fly-caption a { pointer-events: auto; }
.is-3d .fly-stop.is-final .fly-caption { left: 50%; right: auto; width: min(88vw, 820px); translate: -50% -50%; text-align: center; }

@media (max-width: 819px) {
	.is-3d .fly-hero { top: calc(var(--head, 122px) + 22px); left: 20px; right: 20px; width: auto; translate: none; transform-origin: 10% 30%; }
	.is-3d .fly h1 { font-size: clamp(2.9rem, 13vw, 4.2rem); }
	.is-3d .fly-lead { font-size: 1.15rem; }
	.is-3d .fly-hero .fly-actions { margin-top: 22px; }
	.is-3d .fly-caption, .is-3d .fly-stop.cap-left .fly-caption, .is-3d .fly-stop.cap-right .fly-caption { top: auto; bottom: max(28px, 5vh); left: 20px; right: 20px; width: auto; translate: none; }
	.is-3d .fly h2 { font-size: clamp(1.7rem, 7.4vw, 2.3rem); }
	.is-3d .fly-caption p { margin-top: 12px; font-size: 1rem; line-height: 1.45; }
	.is-3d .fly-caption .fly-actions { margin-top: 18px; gap: 12px 20px; }
	.is-3d .fly-btn { padding: 11px 16px; font-size: 1.02rem; }
	.is-3d .fly-stop.is-final .fly-caption { top: 50%; bottom: auto; left: 20px; right: 20px; width: auto; translate: 0 -50%; }
	.is-3d .fly-stop.is-final h2 { font-size: clamp(2.4rem, 11vw, 3.4rem); }
}

/* Stops rail (wide screens) */
.is-3d .fly-rail { position: absolute; z-index: 3; top: 50%; right: 22px; display: flex; flex-direction: column; gap: 16px; translate: 0 -50%; }
.fly-rail a { position: relative; display: block; width: 12px; height: 12px; border: 2px solid #fff; transition: background 0.25s, scale 0.25s, border-color 0.3s; }
.fly-rail a:hover { background: #fff; }
.fly-rail a[aria-current="true"] { background: var(--yellow); border-color: var(--yellow); scale: 1.35; }
.fly-rail a::after { content: attr(data-label); position: absolute; top: 50%; right: 24px; translate: 0 -50%; padding: 4px 9px; background: #fff; color: var(--ink); font-family: var(--mono); font-size: 0.78rem; font-weight: 600; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.fly-rail a:hover::after, .fly-rail a:focus-visible::after { opacity: 1; }
body.fly-on-yellow .fly-rail a { border-color: var(--ink); }
body.fly-on-yellow .fly-rail a[aria-current="true"] { background: var(--ink); }
@media (max-width: 819px) { .is-3d .fly-rail { display: none; } }

.is-3d .fly-video-toggle { display: block; position: absolute; z-index: 3; left: 20px; bottom: 18px; padding: 6px 11px; border: 2px solid #fff; background: transparent; color: #fff; font-family: var(--mono); font-size: 0.78rem; font-weight: 600; cursor: pointer; transition: opacity 0.3s; }
.is-3d .fly-video-toggle:hover { background: #fff; color: var(--ink); }
.is-3d .fly-video-toggle[hidden] { display: none; }
@media (max-width: 819px) { .is-3d .fly-video-toggle { left: auto; right: 14px; bottom: auto; top: calc(var(--head, 122px) + 22px + 37vh); top: calc(var(--head, 122px) + 22px + 37dvh); } }
@media (max-width: 819px) { .is-3d.fly-at-start .fly-video-toggle { top: auto; right: auto; left: 14px; bottom: 16px; } }

.is-3d .fly-hint { display: flex; position: absolute; z-index: 3; left: 50%; bottom: 22px; flex-direction: column; align-items: center; gap: 8px; translate: -50% 0; color: #fff; font-family: var(--mono); font-size: 0.82rem; text-decoration: none; transition: opacity 0.3s; }
.fly-hint svg { width: 16px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; animation: fly-nudge 1.5s ease-in-out 1.6s 4; }
@keyframes fly-nudge { 50% { translate: 0 7px; } }

/* The words arrive after the screens have flown in */
.is-3d .fly-hero > * { animation: fly-arrive 0.9s cubic-bezier(0.2, 0.7, 0.1, 1) both; }
.is-3d .fly-hero > h1 { animation-delay: 0.35s; }
.is-3d .fly-hero > .fly-lead { animation-delay: 0.6s; }
.is-3d .fly-hero > .fly-actions { animation-delay: 0.75s; }
.is-3d .fly-mark::before { animation: fly-swipe 0.6s cubic-bezier(0.2, 0.7, 0.1, 1) 1.1s both; }
@keyframes fly-arrive { from { opacity: 0; translate: 0 34px; } }
@keyframes fly-swipe { from { scale: 0 1; } }

@media (forced-colors: active) {
	.fly-rail a[aria-current="true"] { background: CanvasText; }
	.is-3d .fly-dust { display: none; }
}

/* ======================================================================
   The new look (add ?look=lotus): lotus colors, floating doodles and pattern shapes
   ====================================================================== */
body.fly-page.fly-lotus { --space: #013B45; --glow: rgba(160, 229, 229, 0.2); --pink: #E9409B; --yellow: #A0E5E5; --ink: #1B1220; --fly-dust-a: #E9409B; --fly-dust-b: #A0E5E5; }
.fly-prop { display: none; }
.is-3d .fly-prop { display: block; position: absolute; left: 0; top: 0; width: var(--w, clamp(150px, 17vw, 280px)); pointer-events: none; backface-visibility: hidden; }
.is-3d .fly-prop .doodle { display: block; width: 100%; height: auto; overflow: visible; fill: none; stroke: var(--c, #fff); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.is-3d .fly-prop.is-plane { width: clamp(190px, 22vw, 340px); aspect-ratio: 1; border: 3px solid var(--ink); border-radius: 47% 53% 44% 56% / 52% 46% 54% 48%; background-size: cover; background-position: center; box-shadow: 10px 10px 0 var(--pink); }
/* On phones each stop fills the screen, so the floating pieces would sit on top of it. */
@media (max-width: 819px) { .is-3d .fly-prop { display: none; } }
