/* ============================================================
   DAVDESIGN — Site stylesheet · DARK CINEMATIC EDITION
   Implements the official DAVDESIGN Design System
   (source: "DAVDESIGN Design System/" — tokens v1.0, June 2026)
   on the brand's inverse surface (#131415).

   Language: near-black stage, the work carries the color.
   Blue #0B84FC rationed · red #EC4C48 for ONE action per view
   (the "Professional Experience" pattern).
   Radius two-tier: containers & media SHARP (0) · controls 10px.
   Motion: 100→600ms grid · five named easings only.
   ============================================================ */

/* ---------- TOKENS (from tokens/*.css — dark semantic mapping) ---------- */
:root {
  /* Brand blue */
  --blue-400: #0099FF;
  --blue-500: #0B84FC;
  --blue-900: #023164;
  /* Secondary accent (red/coral) — one differentiated CTA per view */
  --red-400: #F26A67;
  --red-500: #EC4C48;
  --red-700: #C73A36;
  /* Neutral ramp */
  --neutral-0:   #FFFFFF;
  --neutral-50:  #F4F4F4;
  --neutral-100: #EBEBEB;
  --neutral-200: #E8E8E8;
  --neutral-300: #C9C9C9;
  --neutral-500: #999999;
  --neutral-600: #666666;
  --neutral-700: #333333;
  --neutral-800: #1A1A1A;
  --neutral-900: #131415;
  /* Semantic — surfaces (inverse stage) */
  --color-bg:          var(--neutral-900);
  --color-bg-elevated: var(--neutral-800);
  --color-bg-subtle:   var(--neutral-800);
  /* Semantic — text */
  --color-text:         var(--neutral-50);
  --color-text-subtle:  var(--neutral-300);
  --color-text-muted:   var(--neutral-500);
  --color-text-inverse: var(--neutral-900);
  /* Semantic — accent */
  --color-accent:         var(--blue-500);
  --color-accent-hover:   var(--blue-400);
  --color-accent-pressed: var(--blue-900);
  --color-accent-secondary:         var(--red-500);
  --color-accent-secondary-hover:   var(--red-400);
  --color-accent-secondary-pressed: var(--red-700);
  /* Semantic — lines & focus */
  --color-border:        rgba(255, 255, 255, 0.10);
  --color-border-strong: rgba(255, 255, 255, 0.20);
  --color-focus-ring:    var(--blue-400);
  --color-scrim:         rgba(19, 20, 21, 0.55);

  /* Type */
  --font-display: "Poppins", sans-serif;
  --font-body:    "Inter", sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, monospace;
  --fw-extralight: 200; --fw-light: 300; --fw-regular: 400;
  --fw-medium: 500; --fw-semibold: 600;
  --text-2xs: 0.75rem;  --text-xs: 0.875rem; --text-sm: 0.9375rem;
  --text-base: 1rem;    --text-md: 1.125rem; --text-lg: 1.375rem;
  --text-xl: 1.75rem;   --text-2xl: 2.25rem; --text-3xl: 3rem;
  --text-4xl: 4rem;     --text-display: 5rem;
  --lh-tight: 1.05; --lh-snug: 1.15; --lh-normal: 1.5; --lh-relaxed: 1.65;
  --ls-display: -0.02em; --ls-heading: -0.01em; --ls-eyebrow: 0.08em; --ls-mono: 0.06em;

  /* Spacing · radius · elevation · layout */
  --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem; --space-5: 1.5rem;
  --space-6: 2rem;   --space-7: 3rem;    --space-8: 4rem; --space-9: 6rem; --space-10: 8rem;
  --radius-none: 0; --radius-sm: 10px; --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.20);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.50);
  --container-max: 1200px;
  --nav-h: 64px;

  /* Motion — the differentiator */
  --duration-instant: 100ms; --duration-fast: 200ms; --duration-base: 300ms;
  --duration-slow: 450ms;    --duration-slower: 600ms;
  --ease-standard:   cubic-bezier(0.22, 1, 0.36, 1);
  --ease-decelerate: cubic-bezier(0, 0, 0.2, 1);
  --ease-accelerate: cubic-bezier(0.4, 0, 1, 1);
  --ease-emphasized: cubic-bezier(0.83, 0, 0.17, 1);
  --ease-overshoot:  cubic-bezier(0.34, 1.56, 0.64, 1);
  --stagger-base: 80ms;
  /* z-scale: 10 nav, 20 mobile menu, 30 skip link, 50 lightbox, 60 grain, 70 sting */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
/* when Lenis drives the scroll, native smoothing must stand down */
html.lenis-on { scroll-behavior: auto; }

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-weight: var(--fw-regular);
  font-size: var(--text-base);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Cinematic film grain — fixed, non-scrolling, zero interaction cost */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

img, video { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }

::selection { background: var(--color-accent); color: var(--neutral-0); }

:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

/* Page transitions (fade fallback) */
body { opacity: 1; transition: opacity var(--duration-fast) var(--ease-accelerate); }
body.page-exit { opacity: 0; }

/* Curtain page transition — one continuous upward sweep across pages:
   exit: rises from the bottom and covers · next page: continues up and away */
.curtain {
  position: fixed;
  inset: -1% 0;
  z-index: 65;
  background: var(--neutral-800);
  transform: translateY(102%);
  pointer-events: none;
}
.curtain.curtain-in {
  transform: translateY(0);
  transition: transform 350ms var(--ease-emphasized);
}
.curtain.curtain-cover { transform: translateY(0); transition: none; }
.curtain.curtain-cover.curtain-out {
  transform: translateY(-102%);
  transition: transform var(--duration-slow) var(--ease-emphasized) 60ms;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: fixed; top: -60px; left: 16px; z-index: 30;
  background: var(--color-accent); color: var(--neutral-0);
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-family: var(--font-display); font-weight: var(--fw-semibold);
  transition: top var(--duration-fast) var(--ease-standard);
}
.skip-link:focus { top: 12px; }

/* ---------- Layout primitives ---------- */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 56px);
}

.section { padding: clamp(48px, 8vw, 96px) 0; }
.section-tight { padding: clamp(40px, 6vw, 64px) 0; }

/* ---------- Type ---------- */
.h-display, .h-1, .h-2, .h-3 { font-family: var(--font-display); color: inherit; }

/* ---------- Kinetic type (split-text masked reveals) ----------
   JS wraps words/chars in .sw (mask) > .sc (glyph). The padding/margin
   pair reserves descender room so g y p j never clip after settling. */
.sw {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding-bottom: 0.14em;
  margin-bottom: -0.14em;
}
/* pre-states are keyed on html.js so content never hides without JS.
   Motion runs for everyone: this is a motion designer's portfolio.
   (Scroll-tied effects — parallax, skew, smooth scroll — do honor
   prefers-reduced-motion in the JS engine.) */
html.js [data-split] .sc {
  display: inline-block;
  transform: translateY(118%);
  transition: transform var(--duration-slower) var(--ease-emphasized);
  transition-delay: var(--sd, 0ms);
  will-change: transform;
}
html.js [data-split].split-in .sc { transform: none; }
/* hard settle: guarantees glyphs on renderers that freeze transitions */
html.js [data-split].split-settled .sc { transform: none; transition: none; }
.h-display {
  font-weight: var(--fw-extralight);
  font-size: clamp(2.5rem, 7.5vw, 5.75rem);
  letter-spacing: var(--ls-display);
  line-height: var(--lh-tight);
}
.h-1 {
  font-weight: var(--fw-extralight);
  font-size: clamp(2.25rem, 5.5vw, var(--text-4xl));
  letter-spacing: var(--ls-display);
  line-height: var(--lh-tight);
}
.h-2 {
  font-weight: var(--fw-light);
  font-size: clamp(1.75rem, 3.6vw, var(--text-3xl));
  letter-spacing: var(--ls-heading);
  line-height: var(--lh-snug);
}
.h-3 {
  font-weight: var(--fw-medium);
  font-size: var(--text-lg);
  letter-spacing: var(--ls-heading);
  line-height: var(--lh-snug);
}

.eyebrow {
  font-family: var(--font-body);
  font-weight: var(--fw-medium);
  font-size: var(--text-2xs);
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.eyebrow.accent { color: var(--color-accent); }

.lead {
  font-size: var(--text-md);
  line-height: var(--lh-normal);
  color: var(--color-text-subtle);
  max-width: 60ch;
}

.mono-caption {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  letter-spacing: var(--ls-mono);
  color: var(--color-text-muted);
}

/* ---------- Buttons (controls: rounded 10px) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--text-base);
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
  padding: 16px 32px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  will-change: transform;
  transition: background var(--duration-fast) var(--ease-standard),
              border-color var(--duration-fast) var(--ease-standard),
              color var(--duration-fast) var(--ease-standard),
              transform var(--duration-base) var(--ease-standard);
}

.btn-primary {
  background: var(--color-accent);
  color: var(--neutral-0);
  border-color: var(--color-accent);
}
.btn-primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.btn-primary:active { background: var(--color-accent-pressed); border-color: var(--color-accent-pressed); }

/* Secondary (red) — ONE differentiated action per view */
.btn-secondary {
  background: var(--color-accent-secondary);
  color: var(--neutral-0);
  border-color: var(--color-accent-secondary);
}
.btn-secondary:hover { background: var(--color-accent-secondary-hover); border-color: var(--color-accent-secondary-hover); }
.btn-secondary:active { background: var(--color-accent-secondary-pressed); border-color: var(--color-accent-secondary-pressed); }

.btn-outline {
  background: rgba(255, 255, 255, 0.02);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.btn-outline:hover { border-color: var(--color-accent); color: var(--color-accent); }
.btn-outline:active { color: var(--color-accent-hover); border-color: var(--color-accent-hover); }

/* ---------- Enhanced buttons (JS adds structure on hover devices) ----------
   1) directional fill: a circle grows from the cursor's entry point
   2) label swap: the text rolls up, its twin rolls in from below
   3) magnetic pull toward the cursor (transform set inline by JS) */
.btn-enhanced { position: relative; overflow: hidden; }
.btn-enhanced .btn-fill {
  position: absolute;
  left: var(--fx, 50%);
  top: var(--fy, 50%);
  width: max(240%, 260px);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform var(--duration-slow) var(--ease-standard);
  pointer-events: none;
}
.btn-enhanced:hover .btn-fill { transform: translate(-50%, -50%) scale(1); }
.btn-primary .btn-fill,
.btn-secondary .btn-fill { background: rgba(255, 255, 255, 0.16); }
/* outline: white flood, ink text — the editorial flip */
.btn-outline .btn-fill { background: var(--neutral-0); }
.btn-outline.btn-enhanced:hover { color: var(--neutral-800); border-color: var(--neutral-0); }
.btn-outline.btn-enhanced:active { color: var(--neutral-800); border-color: var(--neutral-0); }

.btn-enhanced .btn-text {
  position: relative;
  z-index: 1;
  display: block;
  height: 1.05em;
  overflow: hidden;
}
.btn-enhanced .btn-text-inner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 1.05em;
  transition: transform var(--duration-base) var(--ease-emphasized);
}
.btn-enhanced .btn-text-inner + .btn-text-inner {
  position: absolute;
  top: 105%;
  left: 0;
  width: 100%;
}
.btn-enhanced:hover .btn-text-inner { transform: translateY(-105%); }

/* Inline text link (running copy) */
.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-weight: var(--fw-medium);
  font-size: var(--text-sm);
  color: var(--color-text);
  padding-bottom: 3px;
  border-bottom: 1px solid var(--color-border-strong);
  transition: color var(--duration-fast) var(--ease-standard),
              border-color var(--duration-fast) var(--ease-standard);
}
.link-arrow:hover { color: var(--color-accent); border-color: var(--color-accent); }

/* ---------- Navigation ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  transition: transform var(--duration-base) var(--ease-standard);
}
/* blur e sfondo vivono su uno pseudo-elemento: un backdrop-filter sul .nav
   stesso lo renderebbe containing-block dei figli position:fixed (WebKit/iOS)
   e il menu mobile resterebbe imprigionato nella barra da 64px */
.nav::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(19, 20, 21, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
/* hides on scroll down, returns on scroll up (JS-driven) */
.nav.nav-hidden { transform: translateY(-101%); }
@media (prefers-reduced-transparency: reduce) {
  .nav::before { background: var(--color-bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

.nav-inner {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand { display: flex; align-items: center; gap: 12px; }
.nav-brand img { height: 26px; width: auto; }
.nav-brand span {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: 15px;
  letter-spacing: 0.26em;
  color: var(--color-text);
}

.nav-links { display: flex; align-items: center; gap: 28px; list-style: none; }
.nav-links a {
  font-family: var(--font-body);
  font-weight: var(--fw-medium);
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
  padding-bottom: 3px;
  border-bottom: 1px solid transparent;
  transition: color var(--duration-fast) var(--ease-standard);
}
.nav-links a:hover { color: var(--color-text); }
.nav-links a[aria-current="page"] {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.nav-toggle {
  display: none;
  background: none;
  border: 0;
  cursor: pointer;
  width: 44px; height: 44px;
  position: relative;
  z-index: 21;
}
.nav-toggle span {
  display: block;
  width: 22px; height: 2px;
  background: var(--color-text);
  margin: 5px auto;
  transition: transform var(--duration-base) var(--ease-standard),
              opacity var(--duration-base) var(--ease-standard);
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- BRAND STING (intro, once per session) ----------
   "Construction build" (estende HANDOFF §7): il monogramma viene costruito
   come su un tavolo da disegno. Guide tratteggiate in marcia lenta (lineare:
   metafora meccanica) · la A cresce dalla sua base 260-700 overshoot · la D
   si apre dalla spina diagonale 640-1060 overshoot · le guide si ritirano
   1050/1120 · settle 1120-1360 · wordmark 1220-1380 · hold · out 2150+300
   accelerate. Beat volutamente non metronomici. */
.sting {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--color-bg);
  display: grid;
  place-items: center;
  pointer-events: none;
  animation: sting-exit var(--duration-base) var(--ease-accelerate) 2150ms forwards;
}
.sting-lockup { display: flex; flex-direction: column; align-items: center; gap: 26px; }
.sting-mark {
  width: clamp(112px, 16vw, 172px);
  height: auto;
  animation: sting-settle 240ms var(--ease-overshoot) 1120ms both;
}
.sting-tri {
  transform-box: fill-box;
  transform-origin: 50% 100%; /* la A cresce dalla base */
  animation: sting-grow 440ms var(--ease-overshoot) 260ms both;
}
.sting-d-wrap {
  transform-box: fill-box;
  transform-origin: 0% 50%; /* la D si apre dalla spina diagonale */
  animation: sting-grow 420ms var(--ease-overshoot) 640ms both;
}
.sting-guides * {
  fill: none;
  stroke: rgba(244, 244, 244, 0.3);
  stroke-width: 1;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.sting-guides .g-dash { stroke-dasharray: 26 30; animation: sting-dash 1.4s linear infinite; }
.sting-guides .g-circle { stroke: rgba(11, 132, 252, 0.5); } /* l'unico accento blu */
.sting-guides .g-tick { stroke: rgba(244, 244, 244, 0.55); }
.sting-guides-a { animation: sting-guide-in 220ms var(--ease-decelerate) 40ms both,
                             sting-guide-out 260ms var(--ease-standard) 1050ms forwards; }
.sting-guides-d { animation: sting-guide-in 220ms var(--ease-decelerate) 520ms both,
                             sting-guide-out 260ms var(--ease-standard) 1120ms forwards; }
.sting-wordmark {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: 15px;
  letter-spacing: 0.26em;
  color: var(--color-text);
  animation: sting-word 160ms var(--ease-standard) 1220ms both;
}
/* tap/scroll/tasto durante lo sting: il JS aggiunge .sting-skip e si esce subito */
.sting.sting-skip { animation: sting-exit 240ms var(--ease-accelerate) forwards; }
@keyframes sting-grow { from { opacity: 0; transform: scale(0.3); } to { opacity: 1; transform: scale(1); } }
@keyframes sting-guide-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sting-guide-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes sting-dash { to { stroke-dashoffset: -56; } }
@keyframes sting-settle { from { transform: scale(0.985); } to { transform: scale(1); } }
@keyframes sting-word { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sting-exit { to { transform: translateY(-100%); } }
body.sting-active { overflow: hidden; }
@media (prefers-reduced-motion: reduce) {
  /* niente scala, niente guide: il logo resta visibile con una dissolvenza calma */
  .sting { animation: sting-fade-in 300ms var(--ease-standard) both,
                      sting-exit-calm 500ms var(--ease-standard) 1900ms forwards; }
  .sting.sting-skip { animation: sting-exit-calm 200ms var(--ease-standard) forwards; }
  .sting-guides { display: none; }
  .sting-tri, .sting-d-wrap, .sting-mark, .sting-wordmark { animation: none; }
}
@keyframes sting-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sting-exit-calm { to { opacity: 0; } }

/* ---------- Hero (home) — full-stage showreel ---------- */
.hero {
  position: relative;
  min-height: 100dvh;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.hero-media { position: absolute; inset: 0; }
.hero-media video {
  width: 100%; height: 100%;
  object-fit: cover;
}
/* Organic slow "breathing" zoom on the reel */
.hero-media video { animation: hero-breathe 26s ease-in-out infinite alternate; }
@keyframes hero-breathe { from { transform: scale(1); } to { transform: scale(1.06); } }
.hero-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 110%, rgba(19,20,21,0.92) 20%, rgba(19,20,21,0.30) 60%, rgba(19,20,21,0.25) 100%),
    linear-gradient(180deg, rgba(19,20,21,0.62) 0%, rgba(19,20,21,0.10) 40%);
}
.hero-content {
  position: relative;
  width: 100%;
  padding-bottom: clamp(48px, 9vh, 88px);
}
.hero-role { margin-bottom: 18px; }
.hero-name { max-width: 16ch; text-shadow: 0 2px 24px rgba(19, 20, 21, 0.6); }
.hero-ctas { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 34px; }

/* Hero entrance — fade + rise on the motion grid, 80ms stagger */
.hero-rise {
  opacity: 0;
  transform: translateY(14px);
  animation: dav-rise var(--duration-slow) var(--ease-standard) forwards;
}
.hero-rise:nth-child(2) { animation-delay: var(--stagger-base); }
.hero-rise:nth-child(3) { animation-delay: calc(var(--stagger-base) * 2); }
@keyframes dav-rise { to { opacity: 1; transform: none; } }

/* ---------- Clients marquee (the one kinetic strip) ---------- */
.clients-strip {
  overflow: hidden;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: clamp(18px, 3vw, 30px) 0;
}
.marquee-track {
  display: flex;
  width: max-content;
  gap: 3rem;
}
/* linear by necessity: a marquee must not pulse */
.marquee-track { animation: marquee 30s linear infinite; }
@keyframes marquee { to { transform: translateX(-50%); } }
/* when the rAF engine drives it (velocity-reactive), CSS stands down */
.marquee-track.js-drive { animation: none; }
.marquee-seq {
  display: flex;
  align-items: center;
  gap: 3rem;
  white-space: nowrap;
  font-family: var(--font-display);
  font-weight: var(--fw-extralight);
  font-size: clamp(26px, 3.6vw, 42px);
  letter-spacing: var(--ls-display);
  /* fill pieno, neutro di brand: presente ma silenzioso */
  color: var(--neutral-600);
}
.marquee-seq .dot { color: var(--color-accent); }

/* ---------- Intro (home) ---------- */
.intro-grid {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
}
.intro-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  align-items: flex-start;
  position: sticky;
  top: calc(var(--nav-h) + 32px);
}
.intro-body p { color: var(--color-text-subtle); }
.intro-body p + p { margin-top: var(--space-5); }

/* ---------- Works (home) ---------- */
.works-head { margin-bottom: 36px; }

.works-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

/* WorkCard — sharp media tile · 3D tilt · label on scrim · opens lightbox */
.work-card {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-none);
  background: var(--color-bg-elevated);
  cursor: pointer;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform var(--duration-base) var(--ease-standard),
              box-shadow var(--duration-base) var(--ease-standard);
}
.work-card:hover { box-shadow: var(--shadow-lg); }
.work-card video {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform var(--duration-base) var(--ease-standard);
}
.work-card:hover video { transform: scale(1.03); }

/* Cinematic media reveal: the frame wipes open while the shot settles */
html.js .work-card.reveal {
  clip-path: inset(10% 6% 10% 6%);
  transition: opacity var(--duration-slow) var(--ease-decelerate),
              transform var(--duration-slow) var(--ease-standard),
              clip-path var(--duration-slower) var(--ease-emphasized),
              box-shadow var(--duration-base) var(--ease-standard);
}
html.js .work-card.reveal.in { clip-path: inset(0 0 0 0); }
html.js .work-card.reveal video {
  transform: scale(1.14);
  transition: transform var(--duration-slower) var(--ease-emphasized);
}
html.js .work-card.reveal.in video { transform: scale(1); }
html.js .work-card.reveal.in:hover video {
  transform: scale(1.04);
  transition-duration: var(--duration-base);
}
/* settle: reopen the frame and hand transitions back to hover */
html.js .work-card.reveal.settled {
  clip-path: none;
  transition: transform var(--duration-base) var(--ease-standard),
              box-shadow var(--duration-base) var(--ease-standard);
}
html.js .work-card.reveal.settled video {
  transform: scale(1);
  transition: transform var(--duration-base) var(--ease-standard);
}
html.js .work-card.reveal.settled:hover video { transform: scale(1.04); }

html.js .about-photos .media-reveal {
  clip-path: inset(8% 5% 8% 5%);
  transition: clip-path var(--duration-slower) var(--ease-emphasized);
}
html.js .about-photos .media-reveal + .media-reveal { transition-delay: 120ms; }
html.js .about-photos.reveal.in .media-reveal { clip-path: inset(0 0 0 0); }
html.js .about-photos.reveal.settled .media-reveal { clip-path: none; transition: none; }
.work-scrim {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 6px;
  padding: var(--space-4);
  background: linear-gradient(to top, var(--color-scrim), transparent 55%);
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-standard);
  pointer-events: none;
}
.work-card:hover .work-scrim,
.work-card:focus-visible .work-scrim { opacity: 1; }
@media (hover: none) { .work-scrim { opacity: 1; } }
.work-title {
  font-family: var(--font-display);
  font-weight: var(--fw-medium);
  font-size: var(--text-lg);
  letter-spacing: var(--ls-heading);
  color: var(--neutral-0);
  border-left: 3px solid var(--color-accent);
  padding-left: 12px;
}
.work-client {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--ls-mono);
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
  padding-left: 15px;
}
.work-play {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--ls-mono);
  color: rgba(255, 255, 255, 0.75);
  padding-left: 15px;
}

/* type filters — chips are the one pill-radius element (design system rule) */
.works-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.filter-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--ls-mono);
  text-transform: uppercase;
  color: var(--color-text-subtle);
  background: transparent;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-standard),
              border-color var(--duration-fast) var(--ease-standard);
}
.filter-pill:hover { color: var(--color-text); }
.filter-pill.active { color: var(--color-accent); border-color: var(--color-accent); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 56px);
  background: rgba(19, 20, 21, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.lightbox { animation: lb-fade var(--duration-fast) var(--ease-decelerate) both; }
.lightbox-panel { animation: lb-rise var(--duration-base) var(--ease-standard) both; }
@keyframes lb-fade { from { opacity: 0; } }
@keyframes lb-rise { from { opacity: 0; transform: translateY(14px) scale(0.99); } }
.lightbox[hidden] { display: none; }
.lightbox-panel {
  width: min(960px, 100%);
  background: var(--color-bg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
}
.lightbox-panel video {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--color-bg);
}
.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 16px 20px;
}
.lightbox-title {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--text-base);
  border-left: 4px solid var(--color-accent);
  padding-left: 12px;
}
.lightbox-info {
  padding: 0 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lightbox-info[hidden] { display: none; }
.lightbox-overview {
  font-size: var(--text-xs);
  line-height: var(--lh-normal);
  color: var(--color-text-subtle);
  white-space: pre-line;
  max-width: 70ch;
}
.lightbox-close {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard),
              border-color var(--duration-fast) var(--ease-standard);
}
.lightbox-close:hover { border-color: var(--color-accent); }

/* ---------- Page hero (inner pages) ---------- */
.page-hero {
  position: relative;
  padding: calc(var(--nav-h) + clamp(48px, 9vw, 112px)) 0 clamp(32px, 5vw, 56px);
}
.page-hero .eyebrow { margin-bottom: 14px; }
.page-hero .lead { margin-top: 20px; }

/* Ambient studio glow (rationed brand-blue light, hero + final CTA only) */
.glow::before {
  content: "";
  position: absolute;
  top: -20%;
  left: -10%;
  width: 55vw; height: 55vw;
  max-width: 720px; max-height: 720px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(11, 132, 252, 0.13), transparent 65%);
  pointer-events: none;
}
.glow::before { animation: glow-drift 22s ease-in-out infinite alternate; }
@keyframes glow-drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(12vw, 8vh) scale(1.15); }
}

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
}
.about-body p { color: var(--color-text-subtle); }
.about-body p + p { margin-top: var(--space-5); }
.about-body strong { color: var(--color-text); font-weight: var(--fw-semibold); }
.about-photos {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: calc(var(--nav-h) + 32px);
}
.about-photos img {
  width: 100%;
  border-radius: var(--radius-none);   /* media never rounds */
  box-shadow: var(--shadow-md);
}
.about-photos .photo-tall { aspect-ratio: 4 / 5; object-fit: cover; }
.about-photos .photo-wide { aspect-ratio: 16 / 9; object-fit: cover; }
.about-ctas { display: flex; flex-wrap: wrap; gap: 14px; margin-top: var(--space-7); }

/* ---------- Experience timeline ---------- */
.xp-band { padding: clamp(24px, 4vw, 48px) 0 clamp(56px, 9vw, 112px); }
.timeline { display: flex; flex-direction: column; }
.xp-item {
  display: grid;
  grid-template-columns: 150px 56px 1fr;
  gap: clamp(16px, 3vw, 28px);
  padding: var(--space-6) clamp(8px, 1vw, 16px);
  border-top: 1px solid var(--color-border);
  transition: background var(--duration-fast) var(--ease-standard);
}
.xp-item:hover { background: rgba(255, 255, 255, 0.03); }
.xp-item:first-child { border-top: none; }
.xp-date {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  letter-spacing: var(--ls-mono);
  text-transform: uppercase;
  color: var(--color-accent);
  padding-top: 6px;
}
.xp-logo {
  width: 56px; height: 56px;
  background: var(--neutral-0);
  border-radius: var(--radius-none);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.xp-logo img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.xp-company {
  font-family: var(--font-display);
  font-weight: var(--fw-medium);
  font-size: var(--text-lg);
  letter-spacing: var(--ls-heading);
  line-height: var(--lh-snug);
}
.xp-role {
  font-family: var(--font-body);
  font-weight: var(--fw-medium);
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.75);
  margin-top: 4px;
}
.xp-desc {
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
  max-width: 58ch;
  margin-top: 10px;
}

/* ---------- Get in touch band ---------- */
.cta-band {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-none);
  box-shadow: var(--shadow-md);
  padding: clamp(32px, 6vw, 64px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}
.cta-band .lead { max-width: 46ch; }
.cta-band-actions { display: flex; flex-wrap: wrap; gap: 14px; }

/* ---------- Final CTA (home end-card moment) ---------- */
.cta-final {
  position: relative;
  overflow: hidden;
  border-top: 1px solid var(--color-border);
  padding: clamp(72px, 12vw, 140px) 0;
  text-align: left;
}
.cta-final .h-display { max-width: 18ch; margin-bottom: 36px; }

/* ---------- Contact ---------- */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
}
.contact-side { display: flex; flex-direction: column; gap: var(--space-7); }
.socials {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-none);
  box-shadow: var(--shadow-md);
  padding: clamp(20px, 4vw, 36px);
}
.form-field { display: flex; flex-direction: column; gap: var(--space-2); }
.form-field label {
  font-family: var(--font-body);
  font-weight: var(--fw-medium);
  font-size: var(--text-xs);
  color: var(--color-text);
}
.form-field input,
.form-field textarea {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-bg);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  transition: border-color var(--duration-fast) var(--ease-standard);
}
.form-field input::placeholder,
.form-field textarea::placeholder { color: var(--color-text-muted); }
.form-field input:focus,
.form-field textarea:focus { border-color: var(--color-accent); outline: none; }
.form-field textarea { min-height: 160px; resize: vertical; }
.form-note { color: var(--color-text-subtle); font-size: var(--text-xs); display: none; }
.form-note.visible { display: block; }
.form-note--ok { color: var(--color-accent-hover); }
.form-note--error { color: var(--red-400); }
/* honeypot: invisible to humans, tasty for bots */
.hidden-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Calcolatore (hidden utility page) ---------- */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.calc-panel {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-none);
  box-shadow: var(--shadow-md);
  padding: clamp(24px, 4vw, 40px);
}
.calc-title { margin-bottom: var(--space-5); }
.calc-results {
  margin-top: var(--space-5);
  display: flex;
  flex-direction: column;
}
.calc-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 14px 0;
  border-top: 1px solid var(--color-border);
}
.calc-label {
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}
.calc-tip {
  cursor: help;
  margin-left: 6px;
}
.calc-value {
  font-family: var(--font-display);
  font-weight: var(--fw-light);
  font-size: var(--text-xl);
  letter-spacing: var(--ls-heading);
  color: var(--color-text);
  white-space: nowrap;
}
.calc-coeffs {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}
.calc-coeffs strong { color: var(--color-text); font-weight: var(--fw-semibold); }
.calc-coeff {
  font-family: var(--font-mono);
  color: var(--color-accent);
  letter-spacing: var(--ls-mono);
}
.calc-note {
  margin-top: var(--space-5);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
@media (max-width: 900px) {
  .calc-grid { grid-template-columns: 1fr; }
}

/* ---------- 404 (Snake sopra il 404 in filigrana) ---------- */
.game-stage {
  position: relative;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
}
.game-ghost {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  user-select: none;
  z-index: 1;
}
.game-ghost-code {
  font-family: var(--font-display);
  font-weight: var(--fw-extralight);
  font-size: 24vw;
  line-height: 1;
  color: rgba(255, 255, 255, 0.05);
  text-shadow: 0 0 30px rgba(11, 132, 252, 0.2);
}
.game-ghost-text {
  font-family: var(--font-body);
  font-weight: var(--fw-light);
  font-size: clamp(14px, 2vw, 26px);
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.15);
  margin-top: -0.4em;
}
.game-score {
  position: absolute;
  top: calc(var(--nav-h) + 20px);
  left: 30px;
  z-index: 20;
  font-family: var(--font-mono);
  font-weight: var(--fw-medium);
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--color-accent);
}
#game404 {
  position: absolute;
  inset: 0;
  z-index: 10;
}
.game-hint {
  position: absolute;
  bottom: 24px;
  left: 30px;
  z-index: 20;
}
.game-home {
  position: absolute;
  bottom: 24px;
  right: 30px;
  z-index: 20;
}

/* ---------- Footer (end-card) ---------- */
.footer {
  border-top: 1px solid var(--color-border);
  padding: clamp(40px, 7vw, 80px) 0 var(--space-6);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr auto auto;
  gap: clamp(32px, 6vw, 96px);
  margin-bottom: var(--space-7);
}
.footer-brand { display: flex; align-items: flex-start; gap: 14px; }
.footer-brand img { height: 40px; width: auto; }
.footer-wordmark {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: 15px;
  letter-spacing: 0.26em;
}
.footer-tagline {
  font-size: var(--text-xs);
  color: rgba(255, 255, 255, 0.5);
  margin-top: 4px;
}
.footer-col h4 {
  font-family: var(--font-body);
  font-weight: var(--fw-medium);
  font-size: var(--text-2xs);
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: var(--space-4);
}
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.footer-col a {
  font-size: var(--text-xs);
  color: rgba(255, 255, 255, 0.7);
  transition: color var(--duration-fast) var(--ease-standard);
}
.footer-col a:hover { color: var(--neutral-0); }
.footer-socials { font-family: var(--font-mono); font-size: var(--text-2xs); letter-spacing: var(--ls-mono); }
.footer-legal {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-5);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-2xs);
  color: rgba(255, 255, 255, 0.5);
}

/* ---------- Scroll reveal (450ms · standard/decelerate) ---------- */
.reveal { opacity: 1; }
html.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity var(--duration-slow) var(--ease-decelerate),
              transform var(--duration-slow) var(--ease-standard);
}
html.js .reveal.in { opacity: 1; transform: none; }
/* hard settle for renderers that freeze transitions */
html.js .reveal.settled { opacity: 1; transform: none; transition: none; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .section { padding: clamp(40px, 10vw, 64px) 0; }

  .nav-toggle { display: block; }
  .nav-links {
    position: fixed;
    inset: 0;
    z-index: 20;
    flex-direction: column;
    justify-content: center;
    gap: 28px;
    background: rgba(19, 20, 21, 0.97);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--duration-base) var(--ease-standard),
                visibility 0s linear var(--duration-base);
  }
  .nav-links.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity var(--duration-base) var(--ease-standard);
  }
  .nav-links a { font-size: var(--text-lg); color: var(--color-text); }

  .intro-grid, .about-grid, .contact-grid { grid-template-columns: 1fr; }
  .intro-side, .about-photos { position: static; }

  .works-grid { grid-template-columns: 1fr; }

  .xp-item { grid-template-columns: 56px 1fr; }
  .xp-date { grid-column: 1 / -1; padding-top: 0; }

  .footer-grid { grid-template-columns: 1fr; gap: var(--space-6); }
}
