/* ============================================================
   ApoioLabs marketing site · site-specific styles
   Builds on /styles.css (tokens). All values reference tokens —
   no hard-coded hex. Component CSS is ported from the design-
   system component specs in components/.
   ============================================================ */

/* ---- Page chrome --------------------------------------------- */
/* Make the document background match the first section (the black hero)
   so the nav's progressive blur picks up black behind it instead of the
   token paper-white. Sections all have their own opaque backgrounds, so
   this only ever shows above the hero (i.e. directly behind the nav). */
html, body { background: var(--surface-stage); }

/* Smooth in-page anchor scrolling. Offset section anchors so they don't
   land tucked under the sticky nav (72px desktop, 64px mobile). */
html { scroll-behavior: smooth; }
.section, .hero { scroll-margin-top: 72px; }
@media (max-width: 720px) {
  .section, .hero { scroll-margin-top: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ---- Layout primitives --------------------------------------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 var(--space-6); }

@media (max-width: 720px) {
  .wrap { padding: 0 var(--space-5); }
}

/* ---- Adaptive blur tints (registered for smooth interpolation) -
   Driven by site.js: on scroll we sample what's under each blur
   strip and push (r,g,b) onto these properties so the strip melts
   into whatever section is behind it. */
/* Initial values match the first section on the page (the black hero),
   so the strip renders dark on first paint — no white-flash before the
   JS runs its first sample. */
@property --nav-tint-r { syntax: '<number>'; initial-value: 0; inherits: false; }
@property --nav-tint-g { syntax: '<number>'; initial-value: 0; inherits: false; }
@property --nav-tint-b { syntax: '<number>'; initial-value: 0; inherits: false; }
@property --bot-tint-r { syntax: '<number>'; initial-value: 0; inherits: false; }
@property --bot-tint-g { syntax: '<number>'; initial-value: 0; inherits: false; }
@property --bot-tint-b { syntax: '<number>'; initial-value: 0; inherits: false; }

/* ---- DotMark (2×4 dot logomark) ----------------------------- */
/* Register the dot colors as typed <color> so that when the nav crosses
   between dark and light sections, the dots interpolate smoothly
   instead of snapping. Unregistered custom properties don't interpolate
   through transitions; @property fixes that. */
@property --dm-n { syntax: '<color>'; initial-value: #000000; inherits: true; }
@property --dm-a { syntax: '<color>'; initial-value: #F43F5E; inherits: true; }
@property --dm-c { syntax: '<color>'; initial-value: #FDA4AF; inherits: true; }

.apl-dotmark {
  --dm-n: #000000;
  --dm-a: #F43F5E;
  --dm-c: #FDA4AF;
  --dm-size: 48px;
  --dm-cell: calc((var(--dm-size) / 4) - (var(--dm-size) / 4) * 0.18);
  --dm-gap: calc(var(--dm-size) * 0.06);
  display: inline-grid;
  grid-template-columns: repeat(4, var(--dm-cell));
  grid-auto-rows: var(--dm-cell);
  gap: var(--dm-gap);
  flex-shrink: 0;
}
.apl-dotmark > i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transition: background var(--dur-base) var(--ease-out);
}
.apl-dm-n { background: var(--dm-n); }
.apl-dm-a { background: var(--dm-a); }
.apl-dm-c { background: var(--dm-c); }

.apl-dotmark[data-mode="dark"]  { --dm-n: #FFFFFF; --dm-a: #F43F5E; --dm-c: #BE123C; }
.apl-dotmark[data-mode="light"] { --dm-n: #000000; --dm-a: #F43F5E; --dm-c: #FDA4AF; }

@media (prefers-color-scheme: dark) {
  .apl-dotmark:not([data-mode]) { --dm-n: #FFFFFF; --dm-a: #F43F5E; --dm-c: #BE123C; }
}

/* ---- Logo lockup -------------------------------------------- */
.apl-logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
}
.apl-logo-word {
  font-family: var(--font-sans);
  font-weight: var(--weight-bold);
  font-size: 22px;
  letter-spacing: var(--tracking-tight);
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
}
.apl-logo[data-mode="dark"] .apl-logo-word { color: #fff; }
.apl-logo-word-labs { font-weight: var(--weight-medium); }
.apl-logo[data-accent] .apl-logo-word-labs { color: var(--rose-500); }

/* ---- Button (port of components/core/Button.md) ------------- */
@property --chrome-angle {
  syntax: '<angle>';
  initial-value: 45deg;
  inherits: true;
}
.apl-btn {
  --_bg: var(--rose-500);
  --_fg: var(--white);
  --_bd: transparent;
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
  border: 1px solid var(--_bd);
  background: var(--_bg);
  color: var(--_fg);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
  letter-spacing: var(--tracking-snug);
  transition: var(--transition-colors), var(--transition-transform), var(--transition-shadow);
}
/* Chrome ring: conic-gradient masked to the 2px border zone. The
   gradient angle is driven by --chrome-angle (mouse + scroll). */
.apl-btn::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  padding: 4px;
  background: conic-gradient(
    from var(--chrome-angle, 45deg),
    rgba(255,255,255,0.92) 0%,
    rgba(245,245,245,0.78) 6%,
    rgba(210,210,210,0.4) 14%,
    rgba(180,180,180,0.35) 22%,
    rgba(230,230,230,0.55) 32%,
    rgba(255,255,255,0.95) 40%,
    rgba(240,240,240,0.7) 50%,
    rgba(180,180,180,0.4) 60%,
    rgba(160,160,160,0.4) 68%,
    rgba(220,220,220,0.55) 78%,
    rgba(250,250,250,0.85) 88%,
    rgba(255,255,255,0.92) 100%
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: -1;
  opacity: 0.85;
  /* Smooth angle interpolation: JS sets --chrome-angle each rAF, the
     transition damps each step so the highlight glides instead of
     snapping between mouse-driven values. */
  transition:
    --chrome-angle 360ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity var(--dur-base) var(--ease-out);
}
.apl-btn:hover::before { opacity: 0.95; }
/* Pause the slot-machine word cycle on hover so the button text is
   easy to read while the user is reading the burst sentence. */
.apl-btn:hover .word-cycle,
.apl-btn:hover .word-cycle-track,
.work-card-cta:hover .word-cycle,
.work-card-cta:hover .word-cycle-track {
  animation-play-state: paused;
}
.apl-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.apl-btn:active { transform: scale(0.98); }
.apl-btn[disabled] { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }

.apl-btn[data-size="sm"] { height: var(--control-sm); padding: 0 var(--space-3); font-size: var(--text-sm); }
.apl-btn[data-size="md"] { height: var(--control-md); padding: 0 var(--space-5); font-size: var(--text-base); }
.apl-btn[data-size="lg"] { height: var(--control-lg); padding: 0 var(--space-6); font-size: var(--text-md); }
.apl-btn[data-full="true"] { width: 100%; }

.apl-btn[data-variant="primary"]:hover:not([disabled]) { --_bg: var(--rose-600); box-shadow: var(--shadow-sm); }
.apl-btn[data-variant="primary"]:active:not([disabled]) { --_bg: var(--rose-700); }

.apl-btn[data-variant="secondary"] { --_bg: var(--white); --_fg: var(--text-strong); --_bd: var(--border-default); }
.apl-btn[data-variant="secondary"]:hover:not([disabled]) { --_bg: var(--sand-50); --_bd: var(--border-strong); }

.apl-btn[data-variant="ghost"] { --_bg: transparent; --_fg: var(--text-strong); }
.apl-btn[data-variant="ghost"]:hover:not([disabled]) { --_bg: var(--sand-100); }

.apl-btn[data-variant="stage"] {
  --_bg: rgba(255,255,255,0.10);
  --_fg: #fff;
  --_bd: rgba(255,255,255,0.18);
  backdrop-filter: blur(6px);
}
.apl-btn[data-variant="stage"]:hover:not([disabled]) { --_bg: rgba(255,255,255,0.18); }

.apl-btn[data-variant="glow"] { box-shadow: var(--shadow-glow); }
.apl-btn[data-variant="glow"]:hover:not([disabled]) { --_bg: var(--rose-600); box-shadow: var(--shadow-glow-strong); }

.apl-btn svg { width: 18px; height: 18px; stroke-width: 1.75; }

/* ---- Slot-machine word cycler (for CTA verb) ---------------- */
/* Container width animates to fit the current word; inner track
   slides vertically so the words spin like a slot reel.
   vertical-align: text-bottom aligns the inline-block so the inner
   word's baseline matches the surrounding text baseline. */
.word-cycle {
  display: inline-block;
  height: 1em;
  line-height: 1;
  overflow: hidden;
  vertical-align: -0.13em;
  margin: 0 0.05em;
  animation: word-cycle-w 10s infinite cubic-bezier(0.65, 0, 0.35, 1);
}
.word-cycle-track {
  display: block;
  animation: word-cycle-y 10s infinite cubic-bezier(0.65, 0, 0.35, 1);
}
.word-cycle-track > span {
  display: block;
  line-height: 1;
  white-space: nowrap;
}
@keyframes word-cycle-y {
  0%, 20%   { transform: translateY(0);    }   /* scale     */
  25%, 45%  { transform: translateY(-1em); }   /* start     */
  50%, 70%  { transform: translateY(-2em); }   /* build     */
  75%, 95%  { transform: translateY(-3em); }   /* transform */
  100%      { transform: translateY(-4em); }   /* scale loop */
}
@keyframes word-cycle-w {
  0%, 20%   { width: 2.5em; }   /* scale     */
  25%, 45%  { width: 2.4em; }   /* start     */
  50%, 70%  { width: 2.4em; }   /* build     */
  75%, 95%  { width: 5em;   }   /* transform */
  100%      { width: 2.5em; }   /* scale loop */
}
@media (prefers-reduced-motion: reduce) {
  .word-cycle { animation: none; width: 2.5em; }
  .word-cycle-track { animation: none; }
}

/* ---- Card (port of components/core/Card.md) ----------------- */
.apl-card {
  display: block;
  background: var(--surface-card);
  color: var(--text-body);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition-transform), var(--transition-shadow), var(--transition-colors);
}
.apl-card[data-pad="sm"] { padding: var(--space-4); }
.apl-card[data-pad="md"] { padding: var(--space-6); }
.apl-card[data-pad="lg"] { padding: var(--space-8); }
.apl-card[data-variant="sunken"] { background: var(--surface-sunken); box-shadow: none; }
.apl-card[data-variant="flat"] { box-shadow: none; }
.apl-card[data-variant="stage"] {
  background: var(--surface-stage);
  color: var(--text-on-stage);
  border-color: var(--border-on-stage);
  box-shadow: none;
}
.apl-card[data-variant="glow"] {
  background: var(--surface-stage);
  color: var(--text-on-stage);
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}
.apl-card[data-interactive="true"] { cursor: pointer; }
.apl-card[data-interactive="true"]:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.apl-card[data-interactive="true"]:active { transform: translateY(0); }
.apl-card[data-interactive="true"]:focus-visible { outline: none; box-shadow: var(--ring); }
.apl-card a { color: inherit; text-decoration: none; }

/* ---- Nav with progressive blur strip ------------------------ */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: transparent;
}
.site-nav .wrap {
  position: relative;   /* sits above the absolute .nav-blur below */
  z-index: 1;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Section label nestled under the logo lockup. Hidden by default; fades
   in when the nav has data-section set (IntersectionObserver on #work). */
.nav-section-label {
  position: absolute;
  top: calc(50% + 18px);   /* tucked just below the dotmark's bottom edge */
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity var(--dur-slow) var(--ease-soft);
}
.site-nav[data-section] .nav-section-label { opacity: 1; }
.site-nav nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}
.site-nav nav a {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-body);
  transition: color 500ms ease;
}

/* Logo morph — scroll-driven via the --morph custom property
   (set by JS in index.html based on scrollY). 0 = full hero
   position, 1 = nav position. No transition: transforms track
   scroll 1:1, so the logo moves at the user's scroll speed. */
@property --morph {
  syntax: '<number>';
  initial-value: 0;
  inherits: true;
}
.site-nav .apl-logo {
  /* Anchor translation to viewport center so the logo sits a fixed gap
     above the vertically-centered eyebrow regardless of viewport size.
     The trailing rotateZ adds a tiny tilt wobble on mobile when device
     orientation is enabled (--tilt-rot is set from JS, defaults to 0). */
  transform:
    translateY(calc((1 - var(--morph, 0)) * (50svh - 215px)))
    scale(calc(1.2 - 0.2 * var(--morph, 0)))
    rotateZ(var(--tilt-rot, 0deg));
  transform-origin: center;
  will-change: transform;
}
@supports not (height: 100svh) {
  .site-nav .apl-logo {
    transform:
      translateY(calc((1 - var(--morph, 0)) * (50vh - 215px)))
      scale(calc(1.2 - 0.2 * var(--morph, 0)))
      rotateZ(var(--tilt-rot, 0deg));
  }
}
.site-nav nav a:not(.apl-btn):hover { color: var(--text-strong); }

/* Brand wordmark transitions smoothly when the nav crosses a dark section. */
.site-nav .apl-logo-word { transition: color 500ms ease; }
.site-nav .apl-dotmark > i { transition: background 500ms ease; }

/* Progressive 4-layer blur strip: each layer's backdrop includes prior
   layers, so blur COMPOUNDS heavily at the top edge and ramps down to
   clear ~64px below the nav. Pinned via the sticky parent. */
.nav-blur {
  position: absolute;
  left: 0; right: 0; top: 0; bottom: -64px;
  pointer-events: none;
  z-index: -1;
  transition: opacity var(--dur-slow) var(--ease-soft);
}
.site-nav[data-at-top] .nav-blur { opacity: 0; }
.nav-blur > div { position: absolute; inset: 0; }

.nav-blur-1 {
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 85%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 0%, #000 85%, transparent 100%);
}
.nav-blur-2 {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 65%, transparent 82%);
          mask-image: linear-gradient(to bottom, #000 0%, #000 65%, transparent 82%);
}
.nav-blur-3 {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 45%, transparent 65%);
          mask-image: linear-gradient(to bottom, #000 0%, #000 45%, transparent 65%);
}
.nav-blur-4 {
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 28%, transparent 48%);
          mask-image: linear-gradient(to bottom, #000 0%, #000 28%, transparent 48%);
}
/* Soft adaptive tint — color driven by --nav-tint-{r,g,b} so the strip
   melts into the section currently under it. */
.nav-blur-tint {
  background: linear-gradient(
    to bottom,
    rgba(var(--nav-tint-r), var(--nav-tint-g), var(--nav-tint-b), 0.78) 0%,
    rgba(var(--nav-tint-r), var(--nav-tint-g), var(--nav-tint-b), 0.45) 50%,
    rgba(var(--nav-tint-r), var(--nav-tint-g), var(--nav-tint-b), 0) 100%
  );
  transition:
    --nav-tint-r 700ms cubic-bezier(.4,0,.2,1),
    --nav-tint-g 700ms cubic-bezier(.4,0,.2,1),
    --nav-tint-b 700ms cubic-bezier(.4,0,.2,1);
}

/* The nav logo follows the SECTION it's over (per the brand spec) — not
   the OS color scheme. Explicit light-mode palette wins over the
   prefers-color-scheme:dark fallback in the base .apl-dotmark rules. */
.site-nav:not([data-on-dark]) .apl-dotmark {
  --dm-n: #000000; --dm-a: #F43F5E; --dm-c: #FDA4AF;
}
.site-nav:not([data-on-dark]) .apl-logo-word { color: var(--ink); }
.site-nav:not([data-on-dark]) .apl-logo-word-labs { color: var(--rose-500); }

/* When the strip is over a dark section, flip to the dark-mode palette —
   exact values per IMPLEMENTATION_GUIDE.md §6 ("the dot motif & logo"). */
.site-nav[data-on-dark] .apl-dotmark {
  --dm-n: #FFFFFF; --dm-a: #F43F5E; --dm-c: #BE123C;
}
.site-nav[data-on-dark] .apl-logo-word { color: #FFFFFF; }
.site-nav[data-on-dark] .apl-logo-word-labs { color: var(--rose-500); }
.site-nav[data-on-dark] nav a:not(.apl-btn) { color: rgba(245,245,247,0.72); }
.site-nav[data-on-dark] nav a:not(.apl-btn):hover { color: #fff; }

@media (max-width: 720px) {
  .site-nav .wrap { height: 64px; }
  .site-nav nav { gap: var(--space-4); }
  .site-nav .nav-links a:not(.apl-btn) { display: none; }
}

/* ---- Fixed bottom blur strip (mirrors the nav blur) --------- */
.page-blur-bottom {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 96px;
  pointer-events: none;
  z-index: 99;
}
.page-blur-bottom > div { position: absolute; inset: 0; }

.page-blur-bottom .nb-1 {
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  -webkit-mask-image: linear-gradient(to top, #000 0%, #000 85%, transparent 100%);
          mask-image: linear-gradient(to top, #000 0%, #000 85%, transparent 100%);
}
.page-blur-bottom .nb-2 {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  -webkit-mask-image: linear-gradient(to top, #000 0%, #000 65%, transparent 82%);
          mask-image: linear-gradient(to top, #000 0%, #000 65%, transparent 82%);
}
.page-blur-bottom .nb-3 {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  -webkit-mask-image: linear-gradient(to top, #000 0%, #000 45%, transparent 65%);
          mask-image: linear-gradient(to top, #000 0%, #000 45%, transparent 65%);
}
.page-blur-bottom .nb-4 {
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  -webkit-mask-image: linear-gradient(to top, #000 0%, #000 28%, transparent 48%);
          mask-image: linear-gradient(to top, #000 0%, #000 28%, transparent 48%);
}
.page-blur-bottom .nb-tint {
  background: linear-gradient(
    to top,
    rgba(var(--bot-tint-r), var(--bot-tint-g), var(--bot-tint-b), 0.78) 0%,
    rgba(var(--bot-tint-r), var(--bot-tint-g), var(--bot-tint-b), 0.45) 50%,
    rgba(var(--bot-tint-r), var(--bot-tint-g), var(--bot-tint-b), 0) 100%
  );
  transition:
    --bot-tint-r 700ms cubic-bezier(.4,0,.2,1),
    --bot-tint-g 700ms cubic-bezier(.4,0,.2,1),
    --bot-tint-b 700ms cubic-bezier(.4,0,.2,1);
}

/* ---- Hero (black stage) ------------------------------------- */
/* The hero box is pulled up under the sticky nav (margin-top: -72px)
   and the same amount is added as padding-top, so the centered content
   stays visually anchored. This lets the rose glow extend all the way
   to the top of the viewport — under the nav strip — instead of being
   clipped at the nav's bottom edge. */
.hero {
  position: relative;
  overflow: hidden;
  background: var(--gradient-stage);
  margin-top: -72px;
  padding-top: 72px;
  min-height: 100svh;
  display: flex;
}
@media (max-width: 720px) {
  .hero { margin-top: -64px; padding-top: 64px; }
}
/* Fallback for browsers without svh support. */
@supports not (height: 100svh) {
  .hero { min-height: 100vh; }
}
.hero .wrap {
  position: relative;
  padding: 120px var(--space-6) 128px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
}
.hero .eyebrow { color: var(--rose-400); }
.hero h1 {
  color: #fff;
  font-size: clamp(2.75rem, 11vw, 8rem);
  font-weight: var(--weight-bold);
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 18px 0 0;
  max-width: none;
  white-space: nowrap;
}
.hero .own-wrap {
  position: relative;
  display: inline-block;
  white-space: nowrap;
}
.hero .own { color: var(--rose-500); }
.hero .own-circle {
  position: absolute;
  inset: -16% -14%;
  width: 128%;
  height: 132%;
  color: var(--rose-400);
  opacity: 0.9;
  pointer-events: none;
  overflow: visible;
}
.hero .own-circle path {
  stroke: currentColor;
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.hero .own-note {
  position: absolute;
  font-family: "Caveat", cursive;
  font-weight: 600;
  font-size: clamp(1.125rem, 2.2vw, 1.875rem);
  color: var(--rose-300);
  white-space: nowrap;
  top: 102%;
  left: 50%;
  transform: translateX(-30%) rotate(-4deg);
  letter-spacing: 0.01em;
  line-height: 1;
}
.hero .own-note .own-note-br { display: none; }
.hero p.lead {
  color: rgba(255,255,255,0.66);
  font-size: var(--text-md);
  line-height: 1.5;
  max-width: 600px;
  margin: 64px 0 0;   /* extra room for the handwritten note below h1 */
}
.hero .cta-row {
  display: flex;
  gap: 14px;
  margin-top: 38px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---- Hero scroll indicator ---------------------------------- */
.hero-scroll {
  position: absolute;
  bottom: clamp(48px, 7vh, 88px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;   /* above the fixed page-blur-bottom (z-index 99) */
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 1;
  transition:
    opacity var(--dur-slow) var(--ease-soft),
    color   var(--dur-base) var(--ease-out);
}
/* Only visible at the very top of the page. Once scrolled, fades out
   so it doesn't bleed into the nav-blur zone as it scrolls past. */
body:not([data-at-top]) .hero-scroll {
  opacity: 0;
  pointer-events: none;
}
.hero-scroll:hover { color: rgba(255,255,255,0.85); }
.hero-scroll:focus-visible {
  outline: none;
  color: rgba(255,255,255,0.85);
  box-shadow: var(--ring);
  border-radius: 6px;
}
.hero-scroll svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  animation: hero-scroll-bounce 2.4s ease-in-out infinite;
}
@keyframes hero-scroll-bounce {
  0%, 100% { transform: translateY(0);   opacity: 0.6; }
  50%      { transform: translateY(5px); opacity: 1;   }
}
@media (prefers-reduced-motion: reduce) {
  .hero-scroll svg { animation: none; }
}

@media (max-width: 720px) {
  .hero .wrap { padding: 80px var(--space-5) 88px; }
  .hero h1 {
    white-space: normal;
    font-size: clamp(2.25rem, 11vw, 4.5rem);
  }
  .hero p.lead { font-size: var(--text-sm); margin-top: 64px; }
  .hero .own-note {
    font-size: 1.05rem;
    white-space: normal;
    width: 9em;
    max-width: none;
    line-height: 1.1;
    text-align: center;
    /* Re-center against the explicit width instead of inheriting the
       desktop -30% offset, which would push the wider box off to the
       side on phones. */
    transform: translateX(-50%) rotate(-4deg);
  }
  .hero .own-note .own-note-br { display: inline; }
  /* CTA full-width inside the hero on phones — easier touch target,
     more breathing room for the chrome ring + word cycler. */
  .hero .cta-row { width: 100%; }
  .hero .cta-row .apl-btn { width: 100%; justify-content: center; }

  /* Tighter logo morph: less translation and a smaller hero scale so
     the logo + eyebrow read as one tighter unit on small viewports.
     Logo sits close above the eyebrow, then morphs up into the nav. */
  .site-nav .apl-logo {
    transform:
      translateY(calc((1 - var(--morph, 0)) * (50svh - 175px)))
      scale(calc(1.1 - 0.1 * var(--morph, 0)));
  }
  @supports not (height: 100svh) {
    .site-nav .apl-logo {
      transform:
        translateY(calc((1 - var(--morph, 0)) * (50vh - 175px)))
        scale(calc(1.1 - 0.1 * var(--morph, 0)));
    }
  }

  /* Cheaper chrome gradient (5 stops) so mobile GPUs don't stutter
     while interpolating --chrome-angle. */
  .apl-btn::before,
  .work-card-cta::before {
    background: conic-gradient(
      from var(--chrome-angle, 45deg),
      rgba(255,255,255,0.88) 0%,
      rgba(200,200,200,0.4) 25%,
      rgba(255,255,255,0.95) 50%,
      rgba(180,180,180,0.4) 75%,
      rgba(255,255,255,0.88) 100%
    );
  }
}

/* Scroll-snap the work cards on phones so each takes a viewport.
   Proximity snap with hero + each card as snap points: a small flick
   off the hero naturally lands on the first project instead of leaving
   the user floating between them. Sections after work don't register
   snap points so they scroll freely. */
@media (max-width: 900px) {
  html {
    scroll-snap-type: y proximity;
  }
  .hero { scroll-snap-align: start; }
  .work-card {
    min-height: 45svh;
    scroll-snap-align: start;
  }
  #work .wrap { padding-block: 0; }
}

/* ---- Section utilities -------------------------------------- */
.section { padding: 112px 0; background: var(--surface-stage); }

@media (max-width: 720px) {
  .section { padding: 72px 0; }
}

.section-eyebrow { margin-bottom: var(--space-3); display: inline-block; }

/* ---- Work section (full-viewport) --------------------------- */
#work {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
@supports not (height: 100svh) {
  #work { min-height: 100vh; }
}

/* ---- Work grid ---------------------------------------------- */
.work-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-5);
  margin: 0 auto;
  max-width: 820px;
}
.work-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.work-thumb {
  width: calc(100% + var(--space-6) * 2);
  margin: calc(var(--space-6) * -1) calc(var(--space-6) * -1) 4px;
  aspect-ratio: 16 / 9;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(244,63,94,0.18), transparent 60%),
    rgba(255,255,255,0.025);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.work-tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
}
.work-card h3 { font-size: var(--text-lg); margin: 0; color: var(--text-on-stage); }
.work-card p { font-size: var(--text-sm); color: rgba(255,255,255,0.6); line-height: 1.6; margin: 0; }
.work-card .work-link {
  margin-top: auto;
  color: var(--rose-400);
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
}

/* CTA card — replaces the standalone work-cta button at slot 4. Rose
   background + chrome ring like .apl-btn, with the slot-machine cycle
   centered in the card. overflow: visible so the chrome ring (inset:
   -4px) isn't clipped by the apl-card's default overflow: hidden. */
.work-card-cta {
  background: var(--rose-500);
  color: #fff;
  border-color: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-3);
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
  font-size: clamp(var(--text-xl), 3vw, var(--text-2xl));
  letter-spacing: var(--tracking-snug);
  position: relative;
  isolation: isolate;
  overflow: visible;
}
.work-card-cta:hover { background: var(--rose-600); }
.work-card-cta .work-cta-text {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 0.25em;
  line-height: 1.1;
}
.work-card-cta svg {
  width: 28px;
  height: 28px;
  stroke-width: 2;
}
/* Chrome ring (mirrors .apl-btn::before but radius follows the card). */
.work-card-cta::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  padding: 4px;
  background: conic-gradient(
    from var(--chrome-angle, 45deg),
    rgba(255,255,255,0.92) 0%,
    rgba(245,245,245,0.78) 6%,
    rgba(210,210,210,0.4) 14%,
    rgba(180,180,180,0.35) 22%,
    rgba(230,230,230,0.55) 32%,
    rgba(255,255,255,0.95) 40%,
    rgba(240,240,240,0.7) 50%,
    rgba(180,180,180,0.4) 60%,
    rgba(160,160,160,0.4) 68%,
    rgba(220,220,220,0.55) 78%,
    rgba(250,250,250,0.85) 88%,
    rgba(255,255,255,0.92) 100%
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: -1;
  opacity: 0.85;
  transition:
    --chrome-angle 360ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity var(--dur-base) var(--ease-out);
}
.work-card-cta:hover::before { opacity: 0.95; }

@media (max-width: 900px) {
  .work-grid { grid-template-columns: 1fr; }
}

/* ---- Smoke layer + scroll flashes + CTA hover burst --------- */
/* Body needs an explicit stacking context so the smoke layer's
   z-index: -1 paints between body's bg and the in-flow content
   (rather than escaping behind body entirely). */
body {
  position: relative;
  z-index: 0;
  isolation: isolate;
}

/* Sections become transparent so the smoke layer (z-index: -1) can show
   between body bg and the in-flow card/text elements. Cards keep their
   own opaque bg, so sentences are naturally hidden behind them and only
   visible in the empty page space. */
.hero, .section { background: transparent; }

.smoke-layer, .flash-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
  transition: opacity var(--dur-base) var(--ease-out);
}
/* While the user hovers a CTA, suppress the scattered/flashed sentences
   so only the CTA burst is visible. */
body[data-cta-hover] .smoke-layer,
body[data-cta-hover] .flash-layer { opacity: 0; }
/* Spotlight mask — circle around the cursor reveals the sentences.
   --smoke-x and --smoke-y are set in JS (page coordinates). */
.smoke-layer {
  -webkit-mask-image: radial-gradient(
    circle 260px at var(--smoke-x, -10000px) var(--smoke-y, -10000px),
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,0.55) 55%,
    rgba(0,0,0,0) 100%
  );
          mask-image: radial-gradient(
    circle 260px at var(--smoke-x, -10000px) var(--smoke-y, -10000px),
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,0.55) 55%,
    rgba(0,0,0,0) 100%
  );
}
.smoke-line, .flash-line {
  position: absolute;
  font-family: "Caveat", cursive;
  font-weight: 600;
  font-size: clamp(20px, 2.4vw, 36px);
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-align: center;
  user-select: none;
}
.flash-line { white-space: nowrap; }
/* Smoke lines get their per-element rotation as --rot so a shared tilt
   parallax (--tilt-x, --tilt-y) can compose into the same transform. */
.smoke-line {
  transform:
    translate(
      calc(-50% + var(--tilt-x, 0px)),
      calc(-50% + var(--tilt-y, 0px))
    )
    rotate(var(--rot, 0deg));
}
/* Scroll-triggered flashes live in a separate, un-masked layer so they
   pulse independently of the mouse spotlight. */
.flash-line {
  font-size: clamp(24px, 3vw, 42px);
  color: rgba(255, 255, 255, 0.86);
  animation: flash-pulse 1.6s ease-out forwards;
}
@keyframes flash-pulse {
  0%   { opacity: 0; }
  18%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Mobile: shrink the handwritten sentences and let them wrap so long
   ones don't get clipped off-screen. */
@media (max-width: 720px) {
  .smoke-line, .flash-line {
    font-size: 15px;
    max-width: 78vw;
    line-height: 1.15;
  }
  .flash-line {
    font-size: 17px;
    white-space: normal;
  }
  /* Until the user opts into tilt, there's no way to reveal the smoke
     spotlight on a phone — so hide the whole sentence layer. The CTA
     burst is unaffected (it lives outside these layers). */
  body:not([data-tilt-on]) .smoke-layer,
  body:not([data-tilt-on]) .flash-layer { display: none; }
}

/* CTA hover burst — handwritten sentence with an arrow pointing at it.
   One of four corners is picked at random per hover. */
.cta-burst {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "Caveat", cursive;
  font-weight: 600;
  font-size: clamp(18px, 2.2vw, 28px);
  color: rgba(255, 255, 255, 0.95);
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
  animation: cta-burst-in 280ms cubic-bezier(0.34, 1.3, 0.64, 1) forwards;
}
.cta-burst.leaving { animation: cta-burst-out 220ms ease-in forwards; }
.cta-burst-arrow { width: 64px; height: 48px; flex-shrink: 0; }

.cta-burst[data-corner="tl"] {
  bottom: calc(100% + 14px);
  right: calc(100% - 28px);
  flex-direction: row-reverse;
}
.cta-burst[data-corner="tr"] {
  bottom: calc(100% + 14px);
  left: calc(100% - 28px);
}
.cta-burst[data-corner="tr"] .cta-burst-arrow { transform: scaleX(-1); }
.cta-burst[data-corner="bl"] {
  top: calc(100% + 14px);
  right: calc(100% - 28px);
  flex-direction: row-reverse;
}
.cta-burst[data-corner="bl"] .cta-burst-arrow { transform: scaleY(-1); }
.cta-burst[data-corner="br"] {
  top: calc(100% + 14px);
  left: calc(100% - 28px);
}
.cta-burst[data-corner="br"] .cta-burst-arrow { transform: scale(-1, -1); }

@keyframes cta-burst-in {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes cta-burst-out {
  to { opacity: 0; }
}

/* Mobile: ignore the random corner and always pin the burst centered
   below the button, with the arrow pointing up at it. The CTA is
   full-width on phones, so the corner offsets push the text off-screen. */
@media (max-width: 720px) {
  .cta-burst,
  .cta-burst[data-corner="tl"],
  .cta-burst[data-corner="tr"],
  .cta-burst[data-corner="bl"],
  .cta-burst[data-corner="br"] {
    top: calc(100% + 10px);
    bottom: auto;
    left: 50%;
    right: auto;
    flex-direction: column;
    align-items: center;
    transform: translateX(-50%);
    white-space: normal;
    text-align: center;
    max-width: 78vw;
    gap: 2px;
  }
  .cta-burst .cta-burst-arrow,
  .cta-burst[data-corner="tl"] .cta-burst-arrow,
  .cta-burst[data-corner="tr"] .cta-burst-arrow,
  .cta-burst[data-corner="bl"] .cta-burst-arrow,
  .cta-burst[data-corner="br"] .cta-burst-arrow {
    width: 36px;
    height: 28px;
    transform: scaleY(-1) rotate(-25deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .smoke-layer { -webkit-mask-image: none; mask-image: none; }
  .smoke-line  { opacity: 0.25; }
  .flash-line  { animation: none; opacity: 0.6; }
  .cta-burst   { animation: none; opacity: 1; }
}

/* Tilt toggle — only visible on touch viewports (mobile). Pops a small
   pill at bottom-right so the user can opt-in to deviceorientation. */
.tilt-toggle {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 101;
  padding: 9px 14px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.78);
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  transition: opacity var(--dur-base) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.tilt-toggle:hover { background: rgba(255,255,255,0.12); }
@media (max-width: 720px) {
  .tilt-toggle { display: inline-flex; }
}
body[data-tilt-on] .tilt-toggle { display: none; }

/* "tilt to reveal" hint — shows in the hero on phones only, auto-fades
   after 5s or when user interacts (script removes .tilt-hint-show). */
.tilt-hint {
  position: absolute;
  bottom: clamp(140px, 18vh, 200px);
  left: 50%;
  transform: translateX(-50%);
  font-family: "Caveat", cursive;
  font-weight: 600;
  font-size: 24px;
  color: rgba(255,255,255,0.92);
  text-shadow: 0 1px 8px rgba(0,0,0,0.55);
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  display: none;
  white-space: nowrap;
  text-align: center;
}
@media (max-width: 720px) {
  .tilt-hint { display: block; }
  .tilt-hint.tilt-hint-show {
    animation: tilt-hint-fade 5.4s var(--ease-out) forwards;
  }
}
@keyframes tilt-hint-fade {
  0%   { opacity: 0;   transform: translate(-50%, 8px); }
  18%  { opacity: 1;   transform: translate(-50%, 0); }
  80%  { opacity: 1;   transform: translate(-50%, 0); }
  100% { opacity: 0;   transform: translate(-50%, -4px); }
}

/* ---- Footer ------------------------------------------------- */
.site-footer {
  margin-top: 0;
  background: var(--surface-stage);
  color: rgba(255,255,255,0.6);
}
.site-footer > .wrap {
  padding: 48px var(--space-6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-5);
}
.site-footer .footer-email {
  color: rgba(255,255,255,0.7);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: color var(--dur-base) var(--ease-out);
}
.site-footer .footer-email:hover { color: #fff; }
.site-footer .baseline {
  border-top: 1px solid var(--border-on-stage);
}
.site-footer .baseline .wrap {
  padding: 20px var(--space-6);
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.4);
}
