/* sir.gg · the 3D hero (hero3d.js draws the scene; the hero block in home.js runs the page side).
 * The top of the landing page: the headline and the glass mark are drawn in WebGL behind the words, the name bar
 * sits centred under them, and the featured spots are two small decks of cards either side (a row to swipe on
 * narrow screens). As you scroll, the hero holds still and lets go: the words fade where they stand and the scene
 * fades onto the page's own background. Loaded after home.css, which still styles the name bar and the buttons. */

:root { --out: cubic-bezier(.16, 1, .3, 1); }

/* ---------------------------------------------------------------- the track and the scene
 * The track is the hero plus the stretch of scroll it lets go over. home.js writes --h (0 → 1 over that stretch),
 * --px / --py (pointer, -1..1) and --stick (how far a hero taller than the window scrolls before it holds);
 * hero3d.js writes --clear (where the drawn headline ends, so the words always start below it).
 * The scene is one window-sized picture at the top of the hero and pins with it. */
.hero-track { position: relative; isolation: isolate; --h: 0; --px: 0; --py: 0; }
.hero-track::after { content: ''; display: block; block-size: 55svh; }      /* the stretch of scroll the hero lets go over (padding would not do: a sticky box only travels inside the content box) */
/* the next section (the tablet film) starts rising the moment you scroll, over the hero while it lets go, so there is no
   empty stretch between them: it is pulled up by exactly the stretch above */
.hero-track + .film { margin-block-start: -55svh; }
.h3d { position: absolute; inset: 0 0 auto 0; z-index: -1; display: block; inline-size: 100%; block-size: 100svh; pointer-events: none; opacity: 0; transition: opacity 1.1s ease-out; }
.h3d.on { opacity: calc(1 - var(--h)); }
.hero-track.settled .h3d { transition: none; }                                   /* after the fade-in, it follows the scroll directly */
.hero-track.gone .h3d, .hero-track.flat .h3d { visibility: hidden; }
/* a hero taller than the window (small phones): the picture ends before the hero does, so it fades out instead of stopping at an edge */
.hero-track.over .h3d { -webkit-mask-image: linear-gradient(#000 80%, transparent); mask-image: linear-gradient(#000 80%, transparent); }

.hero3d { position: sticky; inset-block-start: var(--stick, 0px); min-block-size: 100svh; display: grid; grid-template-columns: minmax(0, 1fr); align-content: end; justify-items: center; padding: 0 var(--gutter) clamp(5.4rem, 12vh, 7.5rem); overflow-x: clip; }
.hero-track.gone .hero3d { visibility: hidden; }
.hero-track.is3d .hero3d { padding-block-start: var(--clear, 0px); }

/* the headline is drawn in 3D; this is still the page's h1, and the one you see when there is no 3D (.flat) */
.hero3d .hero-h { position: absolute; inline-size: 1px; block-size: 1px; max-inline-size: none; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.hero-track.flat .hero3d { align-content: center; padding-block-start: 6.5rem; }
.hero-track.flat .hero-h { position: static; inline-size: auto; block-size: auto; overflow: visible; clip-path: none; white-space: normal; margin-block-end: 2.2rem; text-align: center; font-size: clamp(2.8rem, 1rem + 7vw, 5.4rem); opacity: calc(1 - var(--h) * 1.35); }

/* ---------------------------------------------------------------- the words under the headline */
.hero-foot { position: relative; inline-size: min(100%, 37rem); display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.1rem; justify-items: center; text-align: center; opacity: calc(1 - var(--h) * 1.35); translate: 0 calc(var(--h) * -26px); }
.hero-track.leaving .hero-foot { filter: blur(calc(var(--h) * 7px)); }
/* a quiet pool behind them, so the big type in the scene never fights the words */
.hero-foot::before { content: ''; position: absolute; z-index: -1; inset: -2.2rem -7rem -1.5rem; pointer-events: none; background: radial-gradient(closest-side, rgb(0 0 0 / .78), rgb(0 0 0 / .5) 60%, transparent); }
.hero-foot > * { animation: rise .8s var(--out) .45s both; }
.hero-foot > :nth-child(2) { animation-delay: .53s; } .hero-foot > :nth-child(3) { animation-delay: .61s; }
.hero-foot > :nth-child(4) { animation-delay: .69s; } .hero-foot > :nth-child(5) { animation-delay: .77s; } .hero-foot > :nth-child(6) { animation-delay: .85s; }

.hero3d .sub { margin: 0; max-inline-size: 30rem; font-size: clamp(1rem, 1.5vw, 1.14rem); font-weight: 400; letter-spacing: 0; line-height: 1.55; text-shadow: none; }
/* the word that changes: a dark chip, each word rolling up through it */
.hero3d .sticker { vertical-align: -.5em; block-size: 1.9em; margin-inline: .12em; padding: .25em .55em; border: 1px solid var(--line-2); border-radius: 9px; background: var(--raised-3); color: var(--fg); rotate: none; overflow: hidden; letter-spacing: 0; transition: inline-size .5s var(--out); }
.hero3d .sticker span { line-height: 1.3em; transition: translate .5s var(--out), opacity .35s; }
.hero3d .sticker span:not(.on) { inset-block-start: .25em; inset-inline-start: .55em; translate: 0 135%; }
.hero3d .sticker span.was { translate: 0 -135%; }

.hero3d .namebar { --nb-h: 4rem; inline-size: 100%; padding-inline: 1.15rem .5rem; border-radius: 16px; background: rgb(12 12 13 / .78); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); font-size: 1.32rem; font-weight: 700; text-align: start; transition: border-color .25s, background-color .25s; }
.hero3d .namebar:focus-within { background: rgb(16 16 18 / .9); }
.hero3d .nb-go { min-block-size: 3rem; padding-inline: 1.25rem; border-radius: 11px; font-size: 1rem; }
.hero3d .nb-status { font-size: .86rem; font-weight: 500; }

.hero3d .try { justify-content: center; margin: 0; font-size: .88rem; }
.hero3d .chip { min-block-size: 0; padding: .28rem .6rem; background: var(--raised-2); font: 600 .84rem/1.2 var(--sans); transition: color .18s, border-color .18s, background-color .18s, translate .2s var(--out); }
.hero3d .chip:hover { background: var(--raised-3); translate: 0 -1px; }
.hero3d .trust { justify-content: center; gap: .35rem 1.3rem; margin: 0; }
.hero3d .trust li { font-size: .88rem; font-weight: 400; color: var(--muted); }
.hero3d .trust svg { inline-size: .9rem; block-size: .9rem; }
.hero3d .fineprint-hero { margin: 0; font-size: .84rem; }

/* "Scroll" only where there is room for it above the chapter dock */
.hero3d .scroll-hint { display: none; inset-block-end: 4.7rem; opacity: calc(1 - var(--h) * 3); }
.hero3d .scroll-hint i { block-size: 1.4rem; }
@media (min-width: 861px) and (min-height: 900px) { .hero3d { padding-block-end: 10rem; } .hero3d .scroll-hint { display: grid; } }

/* ---------------------------------------------------------------- featured spots
 * A spot is one card: picture, who it is, one line, where it goes. On a wide screen there are two small decks,
 * one either side of the glass mark, leaning in toward it; they follow the pointer, shuffle between spots,
 * and drift outward as the hero lets go. (No ad-ish class names here: ad blockers hide those.) */
.hcard { display: grid; grid-template-rows: auto 1fr; inline-size: 100%; overflow: hidden; border: 1px solid var(--line-2); border-radius: 16px; background: rgb(9 9 10 / .86); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); color: var(--body); font: inherit; text-align: start; text-decoration: none; cursor: pointer; }
.hc-media { position: relative; aspect-ratio: 16 / 9.4; overflow: hidden; background: var(--raised-2); }
.hc-media img { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; object-fit: cover; transition: scale .9s var(--out); }
.hcard:hover .hc-media img { scale: 1.05; }
.hc-open { display: grid; place-items: center; align-content: center; gap: .5rem; block-size: 100%; text-align: center; background: radial-gradient(120% 90% at 50% 0%, #19191c, #0c0c0d 70%); }
.hc-open img, .hcard:hover .hc-open img { position: static; inline-size: 34px; block-size: 34px; object-fit: contain; filter: var(--logo-glow); opacity: .9; scale: 1; }
.hc-open b { font: 700 1.02rem/1.2 var(--display); }
.hc-tag { position: absolute; inset: .55rem auto auto .6rem; padding: .22rem .5rem; border: 1px solid var(--line-2); border-radius: 7px; background: rgb(0 0 0 / .6); font-size: .7rem; font-weight: 600; color: var(--body); }
.hc-body { display: grid; align-content: start; gap: .22rem; padding: .8rem .9rem .9rem; }
.hc-k { font-size: .74rem; color: var(--muted); }
.hc-t { font: 700 1.04rem/1.22 var(--display); color: var(--fg); letter-spacing: -.01em; overflow-wrap: anywhere; }
.hc-s { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .84rem; line-height: 1.4; color: var(--muted); }
.hc-foot { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-block-start: .55rem; }
.hc-u { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8rem; color: var(--muted); }
.hc-cta { flex-shrink: 0; min-block-size: 2rem; padding-inline: .8rem; border-radius: 9px; font-size: .84rem; pointer-events: none; }

.hdeck { position: absolute; z-index: 3; inset-block-end: clamp(5.6rem, 14vh, 8.5rem); inline-size: 15.5rem; perspective: 900px; display: none; opacity: calc(1 - var(--h) * 1.6); animation: deal 1.2s var(--out) .9s both; }
.hdeck-l { inset-inline-start: max(var(--gutter), 50% - 39.5rem); }
.hdeck-r { inset-inline-end: max(var(--gutter), 50% - 39.5rem); animation-delay: 1.07s; }
@keyframes deal { from { opacity: 0; translate: 0 54px; rotate: x 22deg; } }
.hdeck-in { display: grid; transform-style: preserve-3d; animation: hdrift 8s ease-in-out infinite alternate; }
.hdeck-l .hdeck-in { transform: translate3d(calc(var(--h) * -90px), calc(var(--h) * -34px), 0) rotateY(calc(15deg + var(--px) * 6deg + var(--h) * 30deg)) rotateX(calc(var(--py) * -5deg)); }
.hdeck-r .hdeck-in { transform: translate3d(calc(var(--h) * 90px), calc(var(--h) * -34px), 0) rotateY(calc(-15deg + var(--px) * 6deg - var(--h) * 30deg)) rotateX(calc(var(--py) * -5deg)); animation-delay: -4s; }
@keyframes hdrift { from { translate: 0 -5px; } to { translate: 0 6px; } }
.hdeck .hcard { grid-area: 1 / 1; transition: transform .9s var(--out), opacity .6s, filter .6s; }
.hdeck .hcard[data-pos="1"] { transform: translate3d(0, -17px, -80px) scale(.93); opacity: .5; filter: brightness(.55); pointer-events: none; }
.hdeck .hcard[data-pos="2"] { transform: translate3d(0, -30px, -160px) scale(.86); opacity: 0; pointer-events: none; }
.hdeck .hcard[data-pos="out"] { transform: translate3d(0, 26px, 60px) scale(1.03); opacity: 0; pointer-events: none; }
.hdeck-dots { display: flex; justify-content: center; gap: 6px; margin-block-start: .8rem; }
.hdeck-dots button { inline-size: 18px; block-size: 6px; padding: 0; border-radius: 3px; background: var(--line-2); transition: background-color .25s, inline-size .35s var(--out); }
.hdeck-dots button[aria-current="true"] { inline-size: 26px; background: var(--fg); }

/* narrow screens: the same cards, compact, in a row you can swipe */
.hrow { display: none; inline-size: 100%; gap: .6rem; padding-block: .2rem; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.hrow::-webkit-scrollbar { display: none; }
.hrow .hcard { flex: 0 0 min(84%, 20rem); scroll-snap-align: center; grid-template-rows: none; grid-template-columns: 5.4rem minmax(0, 1fr); }
.hrow .hc-media { aspect-ratio: auto; block-size: 100%; min-block-size: 5.4rem; }
.hrow .hc-body { padding: .6rem .75rem .65rem; }
.hrow .hc-s, .hrow .hc-tag, .hrow .hc-open b { display: none; }
.hrow .hc-foot { margin-block-start: .3rem; }

@media (min-width: 1180px) and (min-height: 680px) { .hdeck { display: block; } }
@media (max-width: 1179px), (max-height: 679px) { .hrow:not(:empty) { display: flex; } }
/* shorter windows: smaller cards, so the decks stay clear of the headline */
@media (min-width: 1180px) and (max-height: 790px) { .hdeck { inline-size: 13.6rem; inset-block-end: 5.2rem; } .hdeck .hc-media { aspect-ratio: 16 / 8; } .hdeck .hc-s { -webkit-line-clamp: 1; } .hdeck .hc-body { padding: .65rem .8rem .75rem; } }
/* phones: the chapter dock sits over the bottom of the screen, so the hero ends above it */
@media (max-width: 860px) { .hero3d { padding-block-end: calc(5.2rem + env(safe-area-inset-bottom)); } .hero-foot { gap: .8rem; } .hero-foot::before { inset-inline: -1rem; } .hero3d .fineprint-hero { display: none; } }

/* ---------------------------------------------------------------- the contact sheet an open spot opens: it eases in and out, and the page holds still behind it */
dialog.sheet { opacity: 0; translate: 0 12px; scale: .975; transition: opacity .2s ease-out, translate .32s var(--out), scale .32s var(--out), overlay .32s allow-discrete, display .32s allow-discrete; }
dialog.sheet[open] { opacity: 1; translate: 0 0; scale: 1; }
@starting-style { dialog.sheet[open] { opacity: 0; translate: 0 12px; scale: .975; } }
dialog.sheet::backdrop { opacity: 0; transition: opacity .32s ease-out, overlay .32s allow-discrete, display .32s allow-discrete; }
dialog.sheet[open]::backdrop { opacity: 1; }
@starting-style { dialog.sheet[open]::backdrop { opacity: 0; } }
html:has(dialog.sheet[open]) { overflow: hidden; scrollbar-gutter: stable; }

@media (prefers-reduced-motion: reduce) {
  /* no pinning and no fade: the hero is an ordinary first screen, and the scene is one still picture that scrolls with it */
  .hero-track::after { display: none; }
  .hero-track + .film { margin-block-start: 0; }
  .hero3d { position: relative; inset-block-start: auto; }
  .h3d { transition: none; }
  .hero-foot > *, .hdeck, .hdeck-in { animation: none; }
  .hero3d .sticker, .hero3d .sticker span, .hdeck .hcard, dialog.sheet, dialog.sheet::backdrop { transition: none; }
}

/* narrow phones: the longest example names still fit beside the button */
@media (max-width: 420px) { .hero3d .namebar { padding-inline-start: .9rem; font-size: 1.14rem; } .hero3d .nb-go { padding-inline: .95rem; } }
