/* jaketorgerson.com: a professional contact card with some life in it.
 * Headshot, name and role, Save my contact, LinkedIn, bio, contact details, "leave your name".
 *
 * Colour comes from three hues (--h1..3). Everything coloured is derived from them, so the
 * colour button in the corner only has to swap three numbers. The hues are registered with
 * @property so the whole page fades from one set to the next.
 * One typeface (Schibsted Grotesk), light and dark, one file. Motion stops under reduced motion. */

@property --h1 { syntax: "<number>"; inherits: true; initial-value: 285; }
@property --h2 { syntax: "<number>"; inherits: true; initial-value: 225; }
@property --h3 { syntax: "<number>"; inherits: true; initial-value: 350; }
@property --spin { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

:root {
  color-scheme: light dark;

  --h1: 285; --h2: 225; --h3: 350;                 /* violet, blue, pink */
  transition: --h1 900ms ease, --h2 900ms ease, --h3 900ms ease;

  /* bright: glows, rings, the background */
  --c1: oklch(68% 0.2 var(--h1));
  --c2: oklch(72% 0.17 var(--h2));
  --c3: oklch(70% 0.2 var(--h3));
  /* text-safe on this scheme's background */
  --t1: oklch(46% 0.21 var(--h1));
  --t2: oklch(48% 0.17 var(--h2));
  --t3: oklch(48% 0.2 var(--h3));

  --bg: #f4f6f8;
  --panel: rgb(255 255 255 / 0.74);
  --panel-edge: rgb(255 255 255 / 0.95);
  --panel-shadow: rgb(30 40 80 / 0.28);
  --sheet: #ffffff;
  --ink: #0e1a2b;
  --ink-2: #3f4b5b;
  --muted: #5a6677;
  --rule: #d4dae2;
  --tint: #e6eaef;
  --accent: var(--t1);
  --btn: #0e1a2b;
  --btn-ink: #ffffff;
  --error: #b3261e;
  --ok: #17703a;
  --aurora: 0.5;

  --font: "Schibsted Grotesk", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --gutter: 12px;
  --spring: cubic-bezier(0.2, 0.8, 0.2, 1);
}
:root[data-palette="sunset"] { --h1: 40; --h2: 5; --h3: 320; }     /* orange, red, magenta */
:root[data-palette="lagoon"] { --h1: 175; --h2: 240; --h3: 295; }   /* teal, blue, violet */
:root[data-palette="spring"] { --h1: 150; --h2: 205; --h3: 95; }    /* green, cyan, lime */

@media (prefers-color-scheme: dark) {
  :root {
    --t1: oklch(82% 0.13 var(--h1));
    --t2: oklch(84% 0.11 var(--h2));
    --t3: oklch(82% 0.13 var(--h3));
    --bg: #0a0f18;
    --panel: rgb(16 23 36 / 0.7);
    --panel-edge: rgb(255 255 255 / 0.09);
    --panel-shadow: rgb(0 0 0 / 0.6);
    --sheet: #121b2a;
    --ink: #edf1f6;
    --ink-2: #c3ccd8;
    --muted: #98a4b4;
    --rule: #2a3547;
    --tint: #18212f;
    --btn: #edf1f6;
    --btn-ink: #0a0f18;
    --error: #ff9a8c;
    --ok: #6fd698;
    --aurora: 0.42;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
::selection { background: color-mix(in oklch, var(--c1) 35%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }

h1, h2, p, dl, dd { margin: 0; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- moving colour behind the card ---------- */
.aurora {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  opacity: var(--aurora);
  translate: calc(var(--mx, 0) * -28px) calc(var(--my, 0) * -28px);
  transition: translate 700ms ease-out;
}
.aurora i { position: absolute; width: 95vmax; height: 95vmax; border-radius: 50%; will-change: transform; }
.aurora i:nth-child(1) { left: -42vmax; top: -48vmax; background: radial-gradient(closest-side, var(--c1), transparent); animation: drift-a 19s ease-in-out infinite alternate; }
.aurora i:nth-child(2) { right: -50vmax; top: -18vmax; background: radial-gradient(closest-side, var(--c2), transparent); animation: drift-b 23s ease-in-out infinite alternate; }
.aurora i:nth-child(3) { left: -20vmax; bottom: -60vmax; background: radial-gradient(closest-side, var(--c3), transparent); animation: drift-c 27s ease-in-out infinite alternate; }
@keyframes drift-a { to { transform: translate3d(14vmax, 10vmax, 0) scale(1.15); } }
@keyframes drift-b { to { transform: translate3d(-16vmax, 14vmax, 0) scale(0.9); } }
@keyframes drift-c { to { transform: translate3d(12vmax, -14vmax, 0) scale(1.1); } }

/* ---------- opening: a business card that flips over as you scroll ----------
 * boot.js adds .intro-on to <html> (never under reduced motion). The section is three screens
 * tall with a stage pinned inside it; intro.js turns the scroll position into the --bc-* values
 * below. Their defaults here are the resting pose, so the first paint is already right. */
.intro { display: none; }
:root.intro-on body { display: block; }
:root.intro-on .intro { display: block; height: 330svh; }
.intro__stage {
  position: sticky; top: 0; height: 100svh; overflow: hidden;
  display: grid; grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr); justify-items: center;
}

/* two lines that swap as the card turns */
.intro__say { grid-row: 1; align-self: end; display: grid; padding-inline: 20px; text-align: center; }
.intro__say p {
  grid-area: 1 / 1;
  font-size: clamp(1.875rem, 8vw, 3.5rem); font-weight: 700; line-height: 1.05; letter-spacing: -0.035em;
  text-wrap: balance;
}
.intro__say p:nth-child(1) { opacity: var(--say-a, 1); translate: 0 calc((1 - var(--say-a, 1)) * -18px); }
.intro__say p:nth-child(2) { opacity: var(--say-b, 0); translate: 0 calc((1 - var(--say-b, 0)) * 18px); }

.bc-scene {
  --w: min(88vw, 40rem, 92svh);       /* card width; every size on the card is a fraction of it */
  --t: 6px;                           /* card thickness */
  grid-row: 2; position: relative;
  width: var(--w); aspect-ratio: 7 / 4;
  margin-block: clamp(30px, 6.5svh, 68px);
  perspective: calc(var(--w) * 2.4);
  opacity: calc(1 - var(--bc-out, 0)); scale: calc(1 - var(--bc-out, 0) * 0.1); filter: blur(calc(var(--bc-out, 0) * 10px));   /* steps back as the details fade in over it */
}
/* colour glowing out from behind the card */
.bc-scene::before {
  content: ""; position: absolute; inset: -14% -9%; z-index: -1; border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in oklch, var(--c1) 55%, var(--c3)), transparent);
  filter: blur(calc(var(--w) * 0.05)); opacity: 0.38;
}
.bc-float { position: absolute; inset: 0; transform-style: preserve-3d; animation: bc-float 7s ease-in-out infinite; }
@keyframes bc-float {
  0%, 100% { transform: translate3d(0, -1.6%, 0) rotateZ(-0.5deg); }
  50% { transform: translate3d(0, 2%, 0) rotateZ(0.5deg); }
}
.bc {
  --lean-x: 0; --lean-y: 0;
  position: absolute; inset: 0; transform-style: preserve-3d; will-change: transform;
  transform:
    rotateX(calc(var(--bc-rx, 14deg) - var(--lean-y) * 12deg))
    rotateY(calc(var(--bc-ry, -24deg) + var(--lean-x) * 16deg))
    rotateZ(var(--bc-rz, -5deg))
    scale(var(--bc-sc, 0.92));
}
/* with a mouse, the card also leans toward the pointer */
@media (hover: hover) and (pointer: fine) { .bc { --lean-x: var(--mx, 0); --lean-y: var(--my, 0); } }

.bc__face, .bc__edge { position: absolute; inset: 0; border-radius: calc(var(--w) * 0.032); }
.bc__face { overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
/* painted edge: thin slices between the two faces, so the card has a side when it turns */
.bc__edge { background: linear-gradient(90deg, var(--c1), var(--c3), var(--c2)); }
.bc__edge:nth-of-type(1) { transform: translateZ(-2px); }
.bc__edge:nth-of-type(2) { transform: translateZ(-1px); }
.bc__edge:nth-of-type(4) { transform: translateZ(1px); }
.bc__edge:nth-of-type(5) { transform: translateZ(2px); }
/* light that crosses each face as it turns */
.bc__face::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(108deg, transparent 38%, rgb(255 255 255 / 0.2) 50%, transparent 62%) no-repeat;
  background-size: 250% 100%;
}

/* front: dark stock, black-and-white headshot on a colour block, name set large */
.bc__front {
  transform: translateZ(calc(var(--t) / 2));
  background: linear-gradient(135deg, #15161d, #0a0b10 70%);
  color: #f4efe6;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.07);
}
.bc__front::after { background-position: calc(var(--bc-sheen, 0) * 220% - 5%) 0; }
.bc__frame {
  position: absolute; left: 6%; top: 24%; width: 31%; bottom: 8%;
  background: linear-gradient(170deg, var(--c2), var(--c1) 45%, var(--c3));
}
.bc__photo {
  position: absolute; left: 10.5%; top: 11%; height: 70%; width: auto; aspect-ratio: 1;
  object-fit: cover; background: #23252e;
  filter: grayscale(1) contrast(1.1) brightness(0.92);
}
.bc__photo--empty { display: grid; place-items: center; color: #8c92a0; font-size: calc(var(--w) * 0.11); font-weight: 700; }
.bc__org {
  position: absolute; top: 9.5%; right: 7%;
  font-size: calc(var(--w) * 0.025); font-weight: 500; line-height: 1; letter-spacing: 0.16em; text-transform: uppercase;
  color: rgb(244 239 230 / 0.6);
}
.bc__logo { position: absolute; top: 9%; right: 7%; width: 25%; height: auto; }
.bc__name {
  position: absolute; right: 7%; bottom: 18.5%;
  font-size: calc(var(--w) * 0.108); font-weight: 700; line-height: 0.96; letter-spacing: -0.035em; text-align: right;
  text-shadow: 0 calc(var(--w) * 0.004) calc(var(--w) * 0.03) rgb(0 0 0 / 0.55);
}
.bc__title {
  position: absolute; right: 7%; bottom: 8.5%;
  font-size: calc(var(--w) * 0.034); font-weight: 500; line-height: 1.2; letter-spacing: 0.01em;
  color: rgb(244 239 230 / 0.72);
}

/* back: the colour wash, with the contact details */
.bc__back {
  transform: rotateY(180deg) translateZ(calc(var(--t) / 2));
  background:
    radial-gradient(95% 135% at 0% 0%, oklch(82% 0.13 var(--h2)), transparent 66%),
    radial-gradient(85% 120% at 48% 112%, oklch(64% 0.26 var(--h3)), transparent 68%),
    radial-gradient(60% 100% at 0% 100%, oklch(76% 0.18 var(--h1)), transparent 66%),
    linear-gradient(100deg, oklch(34% 0.12 var(--h1)), oklch(15% 0.05 var(--h1)) 92%);
  color: #fff;
}
.bc__back::after { background-position: calc((var(--bc-sheen, 0) - 0.5) * 220% - 5%) 0; }
.bc__details {
  position: absolute; left: 23%; right: 6%; top: 50%; translate: 0 -50%;
  display: grid; gap: calc(var(--w) * 0.03);
  font-size: calc(var(--w) * 0.036); line-height: 1.2;
  text-shadow: 0 1px calc(var(--w) * 0.012) rgb(0 0 0 / 0.4);
}
.bc__who { font-size: calc(var(--w) * 0.044); font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; }
.bc__details ul { display: grid; gap: calc(var(--w) * 0.014); margin: 0; padding: 0; list-style: none; }
.bc__details li { display: flex; align-items: center; gap: calc(var(--w) * 0.018); min-width: 0; }
.bc__details li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc__details svg { flex: none; width: calc(var(--w) * 0.04); height: calc(var(--w) * 0.04); }
.bc__site { font-weight: 500; }
/* the details settle in once the back has come round */
.bc__who, .bc__details li, .bc__site { opacity: 0; translate: 0 calc(var(--w) * 0.03); transition: opacity 420ms ease-out, translate 620ms var(--spring); }
.intro.is-back :is(.bc__who, .bc__details li, .bc__site) { opacity: 1; translate: none; }
.intro.is-back .bc__details li:nth-child(1) { transition-delay: 70ms; }
.intro.is-back .bc__details li:nth-child(2) { transition-delay: 140ms; }
.intro.is-back .bc__details li:nth-child(3) { transition-delay: 210ms; }
.intro.is-back .bc__details li:nth-child(4) { transition-delay: 280ms; }
.intro.is-back .bc__site { transition-delay: 350ms; }

/* soft shadow on the "table"; narrows as the card turns edge-on */
.bc-shadow {
  position: absolute; left: 6%; right: 6%; top: 100%; height: 16%; z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--panel-shadow), transparent);
  filter: blur(calc(var(--w) * 0.02));
  opacity: var(--bc-so, 0.9);
  transform: translateY(40%) scaleX(var(--bc-sx, 0.93));
}

/* the cue: says what to do, and plays the whole flip if you click it instead */
.cue {
  grid-row: 3; align-self: end;
  display: grid; justify-items: center; gap: 10px;
  padding: 12px 20px max(22px, env(safe-area-inset-bottom));
  color: var(--ink); font-size: 1rem; font-weight: 500; line-height: 1.2; text-decoration: none;
  opacity: var(--cue, 1); translate: 0 calc((1 - var(--cue, 1)) * 14px);
}
.cue.is-gone { visibility: hidden; }
.cue__mouse {
  display: block; width: 28px; height: 44px; padding-top: 7px;
  border: 2px solid currentColor; border-radius: 16px;
}
.cue__mouse i {
  display: block; width: 4px; height: 9px; margin-inline: auto; border-radius: 2px;
  background: linear-gradient(var(--t1), var(--t3));
  animation: cue-wheel 1.7s cubic-bezier(0.3, 0, 0.2, 1) infinite;
}
@keyframes cue-wheel { 0% { translate: 0 0; opacity: 0; } 20% { opacity: 1; } 70% { translate: 0 15px; opacity: 1; } 100% { translate: 0 15px; opacity: 0; } }
.cue__chev { color: var(--t1); animation: cue-nudge 1.7s ease-in-out infinite; }
@keyframes cue-nudge { 0%, 100% { translate: 0 -3px; opacity: 0.45; } 55% { translate: 0 4px; opacity: 1; } }
.cue__label--touch { display: none; }
@media (pointer: coarse) {
  .cue__label--wheel { display: none; }
  .cue__label--touch { display: inline; }
}

/* ---------- colour button ---------- */
.card > .swatch {
  position: absolute; top: 22px; right: 22px; z-index: 5;
  width: 44px; height: 44px; padding: 0;
  border: 3px solid var(--bg); border-radius: 50%;
  background: conic-gradient(var(--c1), var(--c2), var(--c3), var(--c1));
  box-shadow: 0 6px 18px -6px var(--panel-shadow);
  cursor: pointer;
  transition: rotate 500ms var(--spring), scale 160ms ease-out;
}
.swatch:hover { rotate: 120deg; }
.swatch:active { scale: 0.9; }
.swatch:focus-visible { border-radius: 50%; }
.swatch.is-turning { rotate: 360deg; }

/* ---------- the card ---------- */
.card {
  position: relative;
  display: grid; gap: 26px;
  width: min(100% - 2 * var(--gutter), 35rem);
  margin: 0 auto;
  padding: 26px 22px 34px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 30px;
  box-shadow: 0 40px 70px -40px var(--panel-shadow);
}
/* a soft light that follows the pointer or finger across the card */
.card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(26rem circle at var(--px, 50%) var(--py, 0%), color-mix(in oklch, var(--c2) 26%, transparent), transparent 62%);
  opacity: 0; transition: opacity 400ms ease-out;
}
.card.is-lit::before { opacity: 1; }
.card > * { position: relative; }
.card__body { display: grid; gap: 26px; min-width: 0; }

/* headshot: spinning colour ring, glow, tilts toward the pointer */
.card__photo { width: 7.75rem; }
.tilt {
  position: relative; display: block; aspect-ratio: 1; padding: 4px;
  border-radius: 28px;
  transform: perspective(640px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 600ms var(--spring);
  touch-action: pan-y;
  animation: float 6s ease-in-out infinite;
}
.tilt.is-active { transition-duration: 80ms; animation-play-state: paused; }
.tilt::before, .tilt::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: -1;
  background: conic-gradient(from var(--spin), var(--c1), var(--c2), var(--c3), var(--c1));
  animation: spin 7s linear infinite;
}
.tilt::after { inset: 6px; z-index: -2; filter: blur(18px); opacity: 0.75; }
@keyframes spin { to { --spin: 360deg; } }
@keyframes float { 50% { translate: 0 -5px; } }
.photo {
  display: block; width: 100%; height: 100%;
  border-radius: 24px; object-fit: cover; background: var(--tint);
}
.photo--empty { display: grid; place-items: center; color: var(--muted); font-size: 2.25rem; font-weight: 700; letter-spacing: -0.02em; }
.tilt__glare {
  position: absolute; inset: 4px; border-radius: 24px; pointer-events: none;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 0%), rgb(255 255 255 / 0.5), transparent 58%);
  opacity: 0; transition: opacity 300ms ease-out;
}
.tilt.is-active .tilt__glare { opacity: 1; }

.who { display: grid; gap: 8px; }
h1 {
  width: fit-content; max-width: 100%;
  padding-bottom: 0.08em;
  font-size: clamp(2.5rem, 11vw, 3.25rem); font-weight: 700; line-height: 1.02; letter-spacing: -0.035em;
  color: var(--t1);
  background: linear-gradient(100deg, var(--t1), var(--t2), var(--t3), var(--t1)) 0 0 / 300% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: slide 10s linear infinite;
}
@keyframes slide { to { background-position: 150% 0; } }
.who__role { font-size: 1.1875rem; line-height: 1.35; color: var(--muted); text-wrap: balance; }

.bio { display: grid; gap: 14px; max-width: 34rem; color: var(--ink-2); }
.bio p { text-wrap: pretty; }

/* ---------- buttons ---------- */
.actions { display: grid; gap: 12px; }
.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 24px;
  border: 2px solid transparent; border-radius: 14px;
  background: var(--btn); color: var(--btn-ink);
  font-size: 1.0625rem; font-weight: 500; line-height: 1; text-decoration: none; white-space: nowrap;
  cursor: pointer;
  transition: translate 180ms var(--spring), box-shadow 220ms ease-out, border-color 180ms ease-out;
}
.btn:hover { translate: 0 -2px; }
.btn:active { translate: 0 1px; }
.btn:focus-visible { border-radius: 14px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; translate: none; }
/* Save my contact: moving colour border, coloured glow, a shine that sweeps across */
.btn--glow {
  background:
    linear-gradient(var(--btn), var(--btn)) padding-box,
    linear-gradient(100deg, var(--c1), var(--c2), var(--c3), var(--c1)) 0 0 / 300% 100% border-box;
  box-shadow: 0 10px 26px -10px var(--c1), 0 10px 30px -12px var(--c3);
  animation: slide-border 6s linear infinite;
}
@keyframes slide-border { to { background-position: 0 0, 150% 0; } }
.btn--glow:hover { box-shadow: 0 14px 34px -10px var(--c1), 0 14px 38px -10px var(--c3); }
.btn--glow::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 38%, rgb(255 255 255 / 0.32) 50%, transparent 62%) no-repeat 180% 0 / 250% 100%;
  animation: shine 4.5s ease-in-out infinite;
}
@keyframes shine { 0% { background-position: 180% 0; } 32%, 100% { background-position: -80% 0; } }
.btn--line { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn--line:hover { border-color: var(--c1); box-shadow: 0 10px 24px -14px var(--c1); }

/* ---------- contact details ---------- */
.contact { max-width: 34rem; border-top: 1px solid var(--rule); }
.contact__row {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 16px; align-items: center;
  min-height: 56px; padding-block: 10px;
  border-bottom: 1px solid var(--rule);
}
.contact__row::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--c1), var(--c2), var(--c3));
  transform: scaleX(0); transform-origin: left; transition: transform 380ms var(--spring);
}
.contact__row:hover::after, .contact__row:focus-within::after { transform: scaleX(1); }
.contact dt { color: var(--muted); font-size: 0.875rem; line-height: 1.3; }
.contact dd { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-weight: 500; overflow-wrap: anywhere; }
.contact a { text-decoration: none; }
.contact a:hover { color: var(--accent); }
.copy {
  margin-left: auto; min-height: 40px; padding: 0 14px;
  border: 1.5px solid var(--rule); border-radius: 999px; background: transparent;
  font-size: 0.875rem; font-weight: 500; cursor: pointer;
  transition: border-color 160ms ease-out, color 160ms ease-out, scale 160ms ease-out;
}
.copy:hover { border-color: var(--c1); }
.copy:active { scale: 0.94; }
.copy:focus-visible { border-radius: 999px; }
.copy.is-done { border-color: var(--ok); color: var(--ok); }

/* ---------- the page: panels that fade in, in place, as you scroll ----------
 * After the card has flipped, the details card fades in over it; keep scrolling and the
 * "leave your name" sheet fades in over the details. Neither slides: each sits in a "hold",
 * a box taller than the panel by the length of its fade (--f1, --f2). The panel is sticky
 * inside its hold, so it stays put on screen for exactly that much scrolling, then scrolls on
 * as normal. JS only sets how far each fade has got (--in, --cover), never a position.
 *   intro-on (boot.js): the details card's hold starts under the pinned opening.
 *   flow-on (app.js, needs --card-h and --sheet-h): the card pins once it has been read
 *   and the sheet gets its own hold. */
.page { --card-top: 20px; --f1: 0px; --f2: 0px; --dwell: 0px; position: relative; z-index: 1; }
.hold--card { padding-top: var(--card-top); }
.hold::after { content: ""; display: block; }
.hold--card::after { height: var(--f1); }
.hold--sheet { margin-top: 26px; }
.hold--sheet::after { height: var(--f2); }

:root.intro-on .page { --f1: 70svh; margin-top: calc(-100svh - var(--f1)); }
:root.intro-on .card { position: sticky; top: var(--card-top); }
/* --in: the card's own fade in. --cover: the sheet fading in over it; the card dims and softens ahead of the sheet so the two never fight. */
.card {
  opacity: calc(var(--in, 1) * (1 - min(1, var(--cover, 0) * 1.7) * 0.68));
  scale: calc(1 - var(--cover, 0) * 0.05); transform-origin: 50% 0;
  filter: blur(calc(min(1, var(--cover, 0) * 1.7) * 7px));
}
.card.is-off { pointer-events: none; }

:root.flow-on .page {
  --f2: 55svh; --dwell: 25svh;
  --card-pin: min(var(--card-top), 100svh - var(--card-h) - var(--card-top));   /* where the card rests: at the top, or bottom edge on screen if it is taller than the screen */
  --sheet-rest: max(100svh - var(--sheet-h), 6svh);                             /* where the sheet rests: docked to the bottom, or near the top if it is taller */
}
:root.flow-on .hold--card { position: sticky; top: calc(var(--card-pin) - var(--card-top) - var(--f1)); }
:root.flow-on .hold--sheet {
  margin-top: calc(var(--sheet-rest) + var(--dwell) - var(--card-h) - var(--card-pin));
  pointer-events: none;
}
:root.flow-on .sheet {
  position: sticky; top: var(--sheet-rest); pointer-events: auto;
  opacity: var(--in, 1); scale: calc(0.985 + var(--in, 1) * 0.015); transform-origin: 50% 100%;
}
:root.flow-on .sheet.is-off { pointer-events: none; }
.sheet {
  position: relative; z-index: 2;
  width: min(100%, 46rem); margin-inline: auto;
  padding: 12px 22px max(36px, env(safe-area-inset-bottom));
  background: var(--sheet);
  border: 1px solid var(--panel-edge); border-bottom: 0;
  border-radius: 30px 30px 0 0;
  box-shadow: 0 -34px 70px -36px var(--panel-shadow), 0 -1px 0 0 color-mix(in oklch, var(--c1) 30%, transparent);
}
.sheet__grip {
  display: block; width: 46px; height: 5px; margin: 0 auto 24px; border-radius: 3px;
  background: linear-gradient(90deg, var(--c1), var(--c2), var(--c3));
}
.leave { display: grid; gap: 22px; max-width: 34rem; margin-inline: auto; }
.leave__head { display: grid; gap: 8px; }
h2 { font-size: 1.625rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.025em; text-wrap: balance; }
.leave__head p { color: var(--ink-2); }
.leave__form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px 14px; }
.field { display: grid; align-content: start; gap: 6px; min-width: 0; }
.field label { font-size: 0.9375rem; font-weight: 500; }
.field input, .field textarea {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border: 1.5px solid var(--rule); border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 55%, transparent); color: var(--ink);
  line-height: 1.4;
  transition: border-color 160ms ease-out, box-shadow 220ms ease-out;
}
.field textarea { min-height: 108px; resize: vertical; }
.field input:hover, .field textarea:hover { border-color: var(--muted); }
.field input:focus-visible, .field textarea:focus-visible {
  outline: 0; border-color: var(--c1); border-radius: 12px;
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--c1) 28%, transparent), 0 10px 24px -14px var(--c2);
}
.field input:disabled, .field textarea:disabled { opacity: 0.55; }
.field [aria-invalid="true"] { border-color: var(--error); }
.field__hint { font-size: 0.9375rem; color: var(--muted); }
.field__error { font-size: 0.9375rem; font-weight: 500; color: var(--error); }
.field__error:empty { display: none; }
.hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.leave__submit { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.leave__status.is-ok { color: var(--ok); font-weight: 500; }
.leave__status.is-error { color: var(--error); font-weight: 500; }

/* ---------- arrival: the card's pieces rise in, once ---------- */
.rise { animation: rise 720ms var(--spring) both; }
.d1 { animation-delay: 70ms; } .d2 { animation-delay: 140ms; } .d3 { animation-delay: 210ms; } .d4 { animation-delay: 280ms; } .d5 { animation-delay: 350ms; }
@keyframes rise { from { opacity: 0; translate: 0 18px; } }
/* behind the opening, hold the arrival until the card has flipped and this comes into view */
:root.intro-on .card:not(.is-in) .rise { animation-play-state: paused; }
.card:focus { outline: 0; }

/* ---------- confetti from Save my contact and a sent form ---------- */
.fx { position: fixed; inset: 0; z-index: 20; overflow: hidden; pointer-events: none; }
.fx i { position: absolute; width: 8px; height: 13px; border-radius: 2px; }

/* ---------- thanks page (plain form-post fallback) ---------- */
.sent { display: grid; align-content: center; justify-items: start; gap: 24px; min-height: 100svh; width: min(100% - 48px, 34rem); margin-inline: auto; }
.sent h1 { animation: none; }

/* ---------- wider screens ---------- */
@media (min-width: 30rem) {
  :root { --gutter: 20px; }
  .card { padding: 34px 34px 40px; }
  .actions { display: flex; flex-wrap: wrap; }
  .contact__row { grid-template-columns: 5.5rem minmax(0, 1fr); padding-block: 8px; }
  .contact dt { font-size: inherit; }
  .leave__form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field--wide, .leave__submit { grid-column: 1 / -1; }
}
@media (min-width: 56rem) {
  body { display: grid; align-items: center; }
  .page { --card-top: 56px; }
  .sheet { padding: 14px 40px 48px; border-radius: 40px 40px 0 0; }
  .card > .swatch { top: 32px; right: 32px; }
  .card {
    grid-template-columns: 17rem minmax(0, 1fr);
    column-gap: 64px;
    align-items: start;
    width: min(100% - 96px, 61.5rem);
    padding: 56px 60px 64px;
    border-radius: 40px;
  }
  .card__photo { position: sticky; top: 56px; width: 100%; }
  .card__body { gap: 30px; padding-top: 6px; }
  .tilt { padding: 5px; border-radius: 38px; }
  .photo, .tilt__glare { border-radius: 33px; }
  .tilt__glare { inset: 5px; }
  .photo--empty { font-size: 5rem; }
  h1 { font-size: 4.25rem; }
  .who__role { font-size: 1.375rem; }
  .bio { font-size: 1.125rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
  .btn:hover, .btn:active { translate: none; }
}
