/* =========================================================
   Marco Verrengia Caporossi — Portfolio 2026
   Design system: dark mode editorial
   ========================================================= */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; }
ul { list-style: none; }

/* ---------- Tokens ---------- */
:root {
  --bg-base: #161618;
  --bg-elevated: #242426;
  --text-primary: #FAFAFA;
  --text-secondary: #9A9A9A;
  --red: #CE0000;
  --border: #333336;

  --font-title: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;

  --container: 1280px;
  --gutter: clamp(1.25rem, 4vw, 4rem);
  --section-gap: clamp(3.5rem, 7vw, 6.5rem);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Base ---------- */
body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 { font-family: var(--font-title); font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; }

.h-hero   { font-size: clamp(2.6rem, 8vw, 6rem); }
.h-section{ font-size: clamp(2rem, 5vw, 3.4rem); }
.h-card   { font-size: clamp(1.3rem, 2.4vw, 1.7rem); font-weight: 500; }
.h-quote  { font-family: var(--font-title); font-weight: 500;
            font-size: clamp(1.6rem, 4vw, 2.7rem); line-height: 1.25; letter-spacing: -0.02em; }

.caption {
  font-size: 0.8rem; font-weight: 500; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-secondary);
}
h1.caption, h2.caption, h3.caption, h4.caption {
  font-family: inherit; font-weight: 500;
  letter-spacing: 0.14em; line-height: 1.4; margin: 0;
}
.lead { font-size: clamp(1.05rem, 1.6vw, 1.3rem); color: var(--text-secondary); }
.text-red { color: var(--red); }
strong { font-weight: 600; color: var(--text-primary); }

/* ---------- Navbar ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem var(--gutter);
  transition: background 0.4s var(--ease), border-color 0.4s var(--ease), padding 0.3s var(--ease);
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  background: rgba(22, 22, 24, 0.82);
  backdrop-filter: blur(14px);
  border-bottom-color: var(--border);
  padding-top: 0.8rem; padding-bottom: 0.8rem;
}
.nav__logo {
  display: flex; align-items: center; gap: 0.55rem;
  font-family: var(--font-title); font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em;
}
.nav__logo-mark { width: 30px; height: 30px; display: block; flex-shrink: 0; }
.nav__logo .dot { color: var(--red); }
.nav__links { display: flex; gap: 2rem; align-items: center; }
.nav__links a {
  font-size: 0.95rem; color: var(--text-secondary);
  transition: color 0.25s var(--ease); position: relative;
}
.nav__links a:hover { color: var(--text-primary); }
.nav__links a.is-active { color: var(--text-primary); }
.nav__links a.is-active::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -6px;
  height: 2px; background: var(--red);
}
.nav__links a.cta {
  color: var(--text-primary); border: 1px solid var(--border);
  padding: 0.5rem 1.1rem; border-radius: 100px;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.nav__links a.cta:hover { border-color: var(--red); background: var(--red); }
.nav__toggle { display: none; width: 28px; height: 18px; position: relative; }
.nav__toggle span {
  position: absolute; left: 0; width: 100%; height: 2px; background: var(--text-primary);
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}
.nav__toggle span:nth-child(1) { top: 0; }
.nav__toggle span:nth-child(2) { top: 8px; }
.nav__toggle span:nth-child(3) { top: 16px; }
.nav.open .nav__toggle span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.nav.open .nav__toggle span:nth-child(2) { opacity: 0; }
.nav.open .nav__toggle span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* ---------- Buttons / links ---------- */
.btn-text {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-title); font-weight: 500; font-size: 1rem;
  color: var(--text-primary);
}
.btn-text .arrow { transition: transform 0.3s var(--ease); }
.btn-text:hover .arrow { transform: translateX(6px); }
.btn-text:hover { color: var(--red); }

/* ---------- Hero ---------- */
.hero {
  position: relative; min-height: 100svh;
  display: flex; align-items: center; overflow: hidden;
}
.hero__bgs { position: absolute; inset: 0; z-index: 0; }
.hero__bg {
  position: absolute; inset: -28px;
  background-size: cover; background-position: 60% center;
  opacity: 0; transition: opacity 0.7s var(--ease);
}
.hero__bg.is-active { opacity: 1; z-index: 1; }
.hero__bg.is-glitching {
  z-index: 2; opacity: 1;
  will-change: transform, clip-path, filter;
  animation: heroGlitch 0.6s steps(1, end) both;
}
.hero__bg.is-glitching::before {
  content: ''; position: absolute; inset: 0;
  background: inherit; mix-blend-mode: screen; pointer-events: none;
  animation: heroGlitchRGB 0.6s steps(1, end) both;
}
@keyframes heroGlitch {
  0%   { opacity: 0; clip-path: inset(0 0 100% 0); transform: translate3d(0,0,0); filter: none; }
  9%   { opacity: 1; clip-path: inset(46% 0 33% 0); transform: translate3d(-24px,0,0); filter: contrast(1.4) saturate(1.5); }
  18%  { clip-path: inset(7% 0 81% 0);  transform: translate3d(21px,0,0);  filter: none; }
  27%  { clip-path: inset(73% 0 8% 0);  transform: translate3d(-15px,0,0); filter: hue-rotate(35deg) contrast(1.2); }
  36%  { clip-path: inset(30% 0 47% 0); transform: translate3d(26px,0,0);  filter: none; }
  45%  { clip-path: inset(85% 0 3% 0);  transform: translate3d(-12px,0,0); filter: invert(0.14); }
  54%  { clip-path: inset(13% 0 63% 0); transform: translate3d(19px,0,0);  filter: none; }
  63%  { clip-path: inset(53% 0 25% 0); transform: translate3d(-23px,0,0); filter: hue-rotate(-28deg) saturate(1.4); }
  72%  { clip-path: inset(3% 0 76% 0);  transform: translate3d(11px,0,0);  filter: none; }
  82%  { clip-path: inset(0 0 0 0);     transform: translate3d(-7px,0,0);  filter: contrast(1.25); }
  91%  { clip-path: inset(0 0 0 0);     transform: translate3d(4px,0,0);   filter: none; }
  100% { opacity: 1; clip-path: inset(0 0 0 0); transform: translate3d(0,0,0); filter: none; }
}
@keyframes heroGlitchRGB {
  0%, 27%, 45%, 72%, 100% { opacity: 0; }
  9%   { opacity: 0.6;  transform: translate3d(17px,0,0);  filter: hue-rotate(90deg);   clip-path: inset(40% 0 39% 0); }
  36%  { opacity: 0.5;  transform: translate3d(-19px,0,0); filter: hue-rotate(-120deg); clip-path: inset(19% 0 56% 0); }
  63%  { opacity: 0.55; transform: translate3d(15px,0,0);  filter: hue-rotate(150deg);  clip-path: inset(58% 0 19% 0); }
}
.hero__overlay {
  position: absolute; inset: 0; z-index: 1;
  background:
    linear-gradient(100deg, rgba(22,22,24,0.97) 0%, rgba(22,22,24,0.88) 44%, rgba(22,22,24,0.52) 100%),
    linear-gradient(to top, rgba(22,22,24,0.9) 0%, rgba(22,22,24,0) 58%);
}
.hero__content {
  position: relative; z-index: 2; width: 100%;
  padding-top: 7rem; padding-bottom: 6rem;
}
.hero__role { margin-bottom: 1.5rem; }
.hero__title { margin-bottom: 1.8rem; max-width: 28ch; }
.hero__tagline { max-width: 46ch; margin-bottom: 2.4rem; color: var(--text-secondary); }
.hero__scroll {
  display: inline-flex; align-items: center; gap: 0.6rem;
  color: var(--text-secondary); font-size: 0.85rem; letter-spacing: 0.1em; text-transform: uppercase;
  transition: color 0.25s var(--ease);
}
.hero__scroll:hover { color: var(--red); }
.hero__scroll .dash { width: 40px; height: 1px; background: currentColor; display: inline-block; }
.hero__dots {
  position: absolute; z-index: 3; left: 0; right: 0; bottom: 2.2rem;
  display: flex; gap: 0.55rem; justify-content: center;
}
.hero__dot {
  width: 8px; height: 8px; border-radius: 50%; padding: 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.28);
  transition: background 0.25s var(--ease), transform 0.25s var(--ease);
}
.hero__dot:hover { background: rgba(255, 255, 255, 0.6); }
.hero__dot.is-active { background: var(--red); transform: scale(1.3); }

/* ---------- Section heading ---------- */
.section { padding-block: var(--section-gap); }
.section__head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 2rem; margin-bottom: 3.5rem; flex-wrap: wrap;
}
.section__head .caption { margin-bottom: 0.8rem; }

/* ---------- Work grid ---------- */
.work-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: clamp(2.5rem, 5vw, 4.5rem) clamp(1.5rem, 3vw, 3rem);
}
.work-card a { display: block; }

/* head: titolo + anno SOPRA l'immagine */
.work-card__head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 1.2rem; margin-bottom: 1rem;
}
.work-card__index { font-family: var(--font-title); font-size: 0.85rem; color: var(--red); margin-right: 0.55rem; }
.work-card__title {
  font-family: var(--font-title); font-weight: 500;
  font-size: clamp(1.15rem, 2vw, 1.5rem); letter-spacing: -0.02em;
  transition: color 0.25s var(--ease);
}
.work-card:hover .work-card__title { color: var(--red); }
.work-card__year {
  color: var(--text-secondary); font-family: var(--font-title);
  font-size: 0.9rem; white-space: nowrap;
}

.work-card__media {
  position: relative; overflow: hidden; background: var(--bg-elevated);
  border-radius: 4px; aspect-ratio: 4 / 5;
}
.work-card__media img {
  width: 100%; height: 100%; object-fit: cover; object-position: center;
  transition: transform 0.8s var(--ease);
}
.work-card:hover .work-card__media img { transform: scale(1.03); }

.work-card__desc { color: var(--text-secondary); font-size: 0.98rem; margin-top: 1.05rem; }
.work-card .tag {
  display: inline-block; margin-top: 0.85rem;
  font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-secondary);
}

/* Placeholder media (Psicopatici, no image yet) */
.work-card__media.is-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #242426, #1b1b1d);
  border: 1px solid var(--border);
}
.work-card__media.is-placeholder span {
  font-family: var(--font-title); font-weight: 700;
  font-size: clamp(1.8rem, 4.5vw, 3rem); color: var(--border);
  letter-spacing: -0.02em; text-align: center; padding: 1rem; line-height: 1.1;
}

/* CTA card — riempie la 6a cella della griglia */
.work-card--cta {
  border: 1px solid var(--border); border-radius: 4px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 2rem; transition: border-color 0.3s var(--ease);
}
.work-card--cta:hover { border-color: var(--red); }
.work-card--cta .cta-big {
  display: block; font-family: var(--font-title); font-weight: 500;
  font-size: clamp(1.3rem, 2.4vw, 1.9rem); letter-spacing: -0.02em; margin-bottom: 0.5rem;
}
.work-card--cta .cta-small { color: var(--text-secondary); font-size: 0.95rem; }
.work-card--cta:hover .cta-big { color: var(--red); }

/* ---------- Teaser blocks (Approach / About) ---------- */
.teaser { border-top: 1px solid var(--border); }
.teaser__grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 6vw, 6rem); align-items: center; }
.teaser__quote { font-family: var(--font-title); font-weight: 500;
  font-size: clamp(1.8rem, 3.6vw, 3rem); line-height: 1.18; letter-spacing: -0.02em; }
.teaser__body p { color: var(--text-secondary); margin-bottom: 1.5rem; }

/* ---------- Quote band ---------- */
.quote-band { padding-block: clamp(4rem, 9vw, 8rem); border-block: 1px solid var(--border); }
.quote-band .h-quote { max-width: 24ch; }
.quote-band .h-quote .text-red { display: inline; }

/* ---------- Case study page ---------- */
.case-hero { padding-top: 8rem; }
.case-hero__meta { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.case-hero__title { margin-bottom: 1.2rem; }
.case-hero__block { width: fit-content; max-width: 100%; }
.case-hero__headline {
  display: flex; align-items: flex-end; flex-wrap: wrap;
  gap: 1.2rem 2.6rem; margin-bottom: 1.2rem;
}
.case-hero__headline .case-hero__title { margin-bottom: 0; }
.case-hero__gallery-btn { flex-shrink: 0; margin-bottom: 1.6rem; }
.case-hero__sub { width: 0; min-width: 100%; color: var(--text-secondary); }
.case-hero__image {
  margin-top: 3rem; border-radius: 4px; overflow: hidden; background: var(--bg-elevated);
  display: flex; justify-content: center;
}
.case-hero__image img {
  width: auto; max-width: 100%; max-height: 84vh; object-fit: contain;
}
.case-hero__image .video-embed { width: 100%; }

.case-section { padding-block: clamp(3rem, 7vw, 6rem); }
.case-section + .case-section { border-top: 1px solid var(--border); }
.case-grid { display: grid; grid-template-columns: 280px 1fr; gap: clamp(2rem, 5vw, 5rem); }
.case-grid__label .caption { position: sticky; top: 6rem; }
.case-body p { margin-bottom: 1.3rem; }
.case-body p:last-child { margin-bottom: 0; }
.case-body ul.ticks { margin: 1.3rem 0; }
.case-body ul.ticks li { position: relative; padding-left: 1.6rem; margin-bottom: 0.7rem; color: var(--text-secondary); }
.case-body ul.ticks li::before {
  content: ''; position: absolute; left: 0; top: 0.6em;
  width: 7px; height: 7px; background: var(--red); border-radius: 50%;
}
.case-body h3 { font-size: 1.3rem; margin: 2rem 0 0.9rem; }

/* data table */
.data-table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; }
.data-table th, .data-table td {
  text-align: left; padding: 0.85rem 1rem; border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.data-table th { font-family: var(--font-title); color: var(--text-secondary); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; }
.data-table td.num { font-family: var(--font-title); }
.data-table tr:last-child td { border-bottom: none; }
.data-table .row-strong td { color: var(--text-primary); font-weight: 600; }

/* stat row */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin: 2rem 0; }
.stat { border: 1px solid var(--border); border-radius: 4px; padding: 1.6rem; }
.stat__num { font-family: var(--font-title); font-weight: 700; font-size: clamp(1.8rem, 4vw, 2.8rem);
  color: var(--red); line-height: 1; margin-bottom: 0.5rem; }
.stat__label { font-size: 0.9rem; color: var(--text-secondary); }

/* diptych — due frame di un carosello che combaciano */
.diptych {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px;
  border-radius: 4px; overflow: hidden; background: var(--bg-base);
}
.diptych img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 880px) {
  .diptych { grid-template-columns: 1fr; }
}

/* video embed */
.video-embed {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border-radius: 4px; overflow: hidden; background: var(--bg-elevated);
}
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-embed.vertical { aspect-ratio: 9 / 16; max-width: 360px; }
.reel-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: clamp(0.6rem, 1.5vw, 1rem);
}
.reel-grid .video-embed.vertical { max-width: none; }
@media (max-width: 880px) {
  .reel-grid { grid-template-columns: repeat(2, 1fr); }
}

/* case gallery */
.case-gallery { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(1rem, 2.5vw, 2rem); }
.case-gallery figure { margin: 0; }
.case-gallery .full { grid-column: span 2; }
.case-gallery img { width: 100%; border-radius: 4px; background: var(--bg-elevated); }
.case-gallery figcaption { margin-top: 0.7rem; font-size: 0.85rem; color: var(--text-secondary); }

/* case nav */
.case-nav { display: flex; justify-content: space-between; border-top: 1px solid var(--border); padding-block: 2.5rem; gap: 1rem; }
.case-nav a { display: flex; flex-direction: column; gap: 0.3rem; }
.case-nav a:hover .case-nav__title { color: var(--red); }
.case-nav .next { text-align: right; margin-left: auto; }
.case-nav__title { font-family: var(--font-title); font-weight: 500; font-size: 1.2rem; transition: color 0.25s var(--ease); }

/* ---------- About page ---------- */
.about-grid { display: grid; grid-template-columns: 360px 1fr; gap: clamp(2rem, 6vw, 5rem); }
.about-photo { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 4px;
  aspect-ratio: 3 / 4; overflow: hidden; }
.about-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.skill-block { margin-bottom: 1.8rem; }
.skill-block .caption { margin-bottom: 0.6rem; }
.skill-block p { color: var(--text-secondary); }
.timeline { margin-top: 1rem; }
.timeline__row { display: grid; grid-template-columns: 130px 1fr; gap: 1.5rem;
  padding-block: 1rem; border-bottom: 1px solid var(--border); }
.timeline__row:last-child { border-bottom: none; }
.timeline__year { font-family: var(--font-title); color: var(--red); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); padding-block: clamp(4rem, 9vw, 7rem); }
.footer__cta { margin-bottom: 3.5rem; }
.footer__cta .h-section { max-width: 16ch; }
.footer__links { display: flex; flex-wrap: wrap; gap: 2rem 3rem; }
.footer__links a { color: var(--text-secondary); transition: color 0.25s var(--ease); font-size: 1.05rem; }
.footer__links a:hover { color: var(--red); }
.footer__bottom { margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  color: var(--text-secondary); font-size: 0.85rem; }

/* ---------- Code block ---------- */
.code-block {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 4px; padding: 1.2rem 1.4rem; margin: 1.5rem 0;
  overflow-x: auto; font-family: 'Courier New', Courier, monospace;
  font-size: 0.82rem; line-height: 1.7; color: var(--text-secondary);
  white-space: pre;
}
.code-block .c-com { color: #5f5f63; }
.code-block .c-hl { color: var(--text-primary); }
.code-caption { font-size: 0.8rem; color: var(--text-secondary); margin-top: -0.6rem; }

/* ---------- Gallery grid + lightbox ---------- */
.gallery-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: clamp(0.5rem, 1.2vw, 0.9rem);
  scroll-margin-top: 100px;
}
.btn-ghost {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-title); font-weight: 500; font-size: 0.95rem;
  color: var(--text-primary); border: 1px solid var(--border);
  padding: 0.7rem 1.3rem; border-radius: 100px;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.btn-ghost:hover { border-color: var(--red); background: var(--red); }
.btn-ghost .arrow { transition: transform 0.3s var(--ease); }
.btn-ghost:hover .arrow { transform: translateY(3px); }
.gallery-item {
  display: block; padding: 0; overflow: hidden; border-radius: 3px;
  background: var(--bg-elevated); cursor: pointer; aspect-ratio: 1 / 1;
}
.gallery-item img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.6s var(--ease);
}
.gallery-item:hover img { transform: scale(1.06); }
.gallery-item:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.gallery-wrap { position: relative; }
.gallery-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px;
  font-family: var(--font-title); font-size: 1.9rem; line-height: 1;
  color: #fff; background: rgba(36, 36, 38, 0.72);
  border-radius: 50%; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  padding-bottom: 3px;
  transition: background 0.25s var(--ease), opacity 0.25s var(--ease);
}
.gallery-arrow:hover { background: var(--red); }
.gallery-arrow:disabled { opacity: 0.3; cursor: default; }
.gallery-arrow:disabled:hover { background: rgba(36, 36, 38, 0.72); }
.gallery-arrow--prev { left: 12px; }
.gallery-arrow--next { right: 12px; }
@media (max-width: 600px) {
  .gallery-arrow { width: 40px; height: 40px; font-size: 1.6rem; }
  .gallery-arrow--prev { left: 6px; }
  .gallery-arrow--next { right: 6px; }
}

.gallery-dots {
  display: flex; justify-content: center; gap: 0.65rem;
  margin-top: 1.9rem; flex-wrap: wrap;
}
.gallery-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--border); padding: 0; cursor: pointer;
  transition: background 0.25s var(--ease), transform 0.25s var(--ease);
}
.gallery-dot:hover { background: var(--text-secondary); }
.gallery-dot.active { background: var(--red); transform: scale(1.25); }

/* variante a riga singola (es. Psicopatici): 4 desktop, 1 mobile */
.gallery-grid.gallery-grid--row { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 880px) {
  .gallery-grid.gallery-grid--row { grid-template-columns: 1fr; }
}

.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(10, 10, 11, 0.97);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: opacity 0.3s var(--ease), visibility 0.3s var(--ease);
}
.lightbox.open { opacity: 1; visibility: visible; }
.lightbox__img {
  max-width: 90vw; max-height: 86vh; object-fit: contain;
  border-radius: 4px; user-select: none;
}
.lightbox__btn {
  position: absolute; color: var(--text-primary);
  width: 52px; height: 52px; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-title); font-size: 1.7rem; line-height: 1;
  background: rgba(36, 36, 38, 0.72); border-radius: 50%;
  transition: background 0.25s var(--ease);
}
.lightbox__btn:hover { background: var(--red); }
.lightbox__close { top: 1.4rem; right: 1.4rem; }
.lightbox__prev { left: 1.4rem; top: 50%; transform: translateY(-50%); }
.lightbox__next { right: 1.4rem; top: 50%; transform: translateY(-50%); }
.lightbox__counter {
  position: absolute; bottom: 1.4rem; left: 50%; transform: translateX(-50%);
  font-family: var(--font-title); font-size: 0.85rem; color: var(--text-secondary);
}

/* ---------- Galleria caroselli stile Instagram (SS26) ---------- */
.ig-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px; scroll-margin-top: 100px;
}
.ig-cover {
  position: relative; display: block; padding: 0; border: 0;
  aspect-ratio: 4 / 5; overflow: hidden; cursor: pointer;
  background: var(--bg-elevated);
}
.ig-cover img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.6s var(--ease);
}
.ig-cover:hover img { transform: scale(1.05); }
.ig-cover:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.ig-cover__icon {
  position: absolute; top: 9px; right: 9px;
  width: 22px; height: 22px; pointer-events: none;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
}
.ig-cover__caption {
  position: absolute; inset: 0; display: flex; align-items: flex-end;
  padding: 0.9rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0) 62%);
  opacity: 0; transition: opacity 0.3s var(--ease);
}
.ig-cover:hover .ig-cover__caption { opacity: 1; }
.ig-cover__caption span {
  font-family: var(--font-title); font-weight: 500;
  font-size: 0.9rem; line-height: 1.25; color: #fff;
}

.ig-lightbox {
  position: fixed; inset: 0; z-index: 210;
  background: rgba(10, 10, 11, 0.97);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: opacity 0.3s var(--ease), visibility 0.3s var(--ease);
}
.ig-lightbox.open { opacity: 1; visibility: visible; }
.ig-lightbox__stage {
  display: flex; flex-direction: column; align-items: center; gap: 1.1rem;
}
.ig-lightbox__frame {
  position: relative; aspect-ratio: 4 / 5;
  height: 76vh; max-height: 760px; max-width: 92vw;
  background: var(--bg-elevated); border-radius: 4px; overflow: hidden;
}
.ig-lightbox__frame { cursor: grab; }
.ig-lightbox__frame:active { cursor: grabbing; }
.ig-track {
  display: flex; flex-wrap: nowrap; width: 100%; height: 100%;
  transition: transform 0.42s cubic-bezier(0.65, 0, 0.35, 1);
  will-change: transform;
}
.ig-slide { flex: 0 0 100%; width: 100%; height: 100%; }
.ig-slide img {
  width: 100%; height: 100%; object-fit: cover;
  user-select: none; -webkit-user-drag: none;
}
.ig-lightbox__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-title); font-size: 1.5rem; line-height: 1; color: #fff;
  background: rgba(16, 16, 18, 0.62); border-radius: 50%;
  transition: background 0.25s var(--ease);
}
.ig-lightbox__nav:hover { background: var(--red); }
.ig-lightbox__nav--prev { left: 12px; }
.ig-lightbox__nav--next { right: 12px; }
.ig-lightbox__nav[hidden] { display: none; }
.ig-lightbox__close {
  position: absolute; top: 1.4rem; right: 1.4rem;
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-title); font-size: 1.7rem; line-height: 1; color: #fff;
  background: rgba(36, 36, 38, 0.72); border-radius: 50%;
  transition: background 0.25s var(--ease);
}
.ig-lightbox__close:hover { background: var(--red); }
.ig-lightbox__dots {
  display: flex; justify-content: center; gap: 0.5rem; flex-wrap: wrap;
  max-width: 92vw;
}
.ig-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); padding: 0; cursor: pointer;
  transition: background 0.25s var(--ease), transform 0.25s var(--ease);
}
.ig-dot:hover { background: var(--text-secondary); }
.ig-dot.active { background: var(--red); transform: scale(1.3); }
.ig-lightbox__bar {
  display: flex; align-items: baseline; justify-content: center;
  gap: 1rem; width: 100%;
}
.ig-lightbox__title {
  font-family: var(--font-title); font-weight: 500; font-size: 0.95rem; color: #fff;
}
.ig-lightbox__count {
  font-family: var(--font-title); font-size: 0.82rem; color: var(--text-secondary);
}

/* ---------- Lista format (case study) ---------- */
.format {
  padding-left: 1.5rem; border-left: 2px solid var(--border);
  margin-bottom: 2.4rem; transition: border-color 0.3s var(--ease);
}
.format:last-child { margin-bottom: 0; }
.format:hover { border-left-color: var(--red); }
.format h3 { margin-bottom: 0.7rem; }
.format p { color: var(--text-secondary); max-width: 60ch; }
.format__meta {
  margin-top: 0.8rem; font-family: var(--font-title);
  font-size: 0.84rem; color: var(--text-secondary); letter-spacing: 0.01em;
}
.format__meta b { color: var(--text-primary); font-weight: 500; }

/* ---------- Griglia asset (materiale di lavorazione, bassa enfasi) ---------- */
.asset-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px;
}
.asset-grid img {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 3px;
  opacity: 0.6; filter: grayscale(0.2);
  transition: opacity 0.3s var(--ease), filter 0.3s var(--ease);
}
.asset-grid img:hover { opacity: 1; filter: none; }
@media (max-width: 880px) { .asset-grid { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Riga risultato (carosello finale) ---------- */
.result-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.result-row img {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 4px;
}

/* ---------- Video nella galleria IG ---------- */
.ig-cover video { display: block; width: 100%; height: 100%; object-fit: cover; }
.ig-lightbox.is-video .ig-lightbox__frame { aspect-ratio: 9 / 16; }
.ig-lightbox.is-video .ig-lightbox__nav,
.ig-lightbox.is-video .ig-lightbox__dots { display: none; }
.ig-slide video { width: 100%; height: 100%; object-fit: contain; background: #000; }

@media (max-width: 880px) {
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
  .ig-cover__caption { display: none; }
  .ig-cover__icon { width: 18px; height: 18px; top: 6px; right: 6px; }
  .ig-lightbox__close { width: 44px; height: 44px; font-size: 1.4rem; top: 0.9rem; right: 0.9rem; }
  .ig-lightbox__frame { height: auto; width: 92vw; max-height: 74vh; }
  .lightbox__btn { width: 44px; height: 44px; font-size: 1.4rem; }
  .lightbox__prev { left: 0.5rem; }
  .lightbox__next { right: 0.5rem; }
  .lightbox__close { top: 0.8rem; right: 0.8rem; }
}
@media (max-width: 520px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity 0.8s var(--ease), transform 0.8s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: 0.08s; }
.reveal.d2 { transition-delay: 0.16s; }
.reveal.d3 { transition-delay: 0.24s; }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .nav__links {
    position: fixed; inset: 0 0 0 auto; width: min(78vw, 320px);
    background: var(--bg-elevated); flex-direction: column; align-items: flex-start;
    justify-content: center; gap: 1.8rem; padding: 3rem;
    transform: translateX(100%); transition: transform 0.4s var(--ease);
    border-left: 1px solid var(--border);
  }
  .nav.open .nav__links { transform: none; }
  .nav__links a { font-size: 1.3rem; }
  .nav__toggle { display: block; z-index: 110; }

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

  .teaser__grid { grid-template-columns: 1fr; }
  .case-grid { grid-template-columns: 1fr; gap: 1rem; }
  .case-grid__label .caption { position: static; }
  .case-gallery { grid-template-columns: 1fr; }
  .case-gallery .full { grid-column: span 1; }
  .stats { grid-template-columns: 1fr; }
  .about-grid { grid-template-columns: 1fr; }
  .timeline__row { grid-template-columns: 100px 1fr; gap: 1rem; }
  .case-hero__image { aspect-ratio: 4 / 5; }
  .case-hero__gallery-btn { margin-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Categorie progetti: tendina menu, filtri, Video & Motion ---------- */
#work { scroll-margin-top: 80px; }

/* dropdown nel menu */
.nav__has-sub { position: relative; }
.nav__sub {
  position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%) translateY(6px);
  display: flex; flex-direction: column;
  min-width: 190px; padding: 0.5rem;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px;
  opacity: 0; visibility: hidden; z-index: 120;
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease), visibility 0.22s;
}
.nav__has-sub:hover .nav__sub,
.nav__has-sub:focus-within .nav__sub {
  opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0);
}
.nav__sub a {
  display: block; white-space: nowrap; border-radius: 4px;
  padding: 0.5rem 0.7rem; font-size: 0.95rem; color: var(--text-secondary);
}
.nav__sub a:hover { color: var(--text-primary); background: var(--bg-base); }

/* filtri categoria */
.work-filters {
  display: flex; flex-wrap: wrap; gap: 0.6rem;
  margin-bottom: clamp(1.8rem, 3.5vw, 2.8rem);
}
.work-filter {
  font-family: var(--font-title); font-weight: 500; font-size: 0.88rem;
  color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 100px;
  padding: 0.5rem 1.15rem; cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.work-filter:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.work-filter.active { color: #fff; background: var(--red); border-color: var(--red); }

/* griglia Video & Motion */
.video-motion-grid { display: flex; flex-direction: column; gap: clamp(1.6rem, 3.5vw, 3rem); }
.video-motion-grid[hidden] { display: none; }
.video-card { display: flex; gap: clamp(1.4rem, 3vw, 2.6rem); align-items: center; }
.video-card__media { flex: 0 0 300px; width: 300px; }
.video-embed.video-cover iframe {
  inset: auto; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 316.1%; height: 100%;
}
.video-card__body { flex: 1; }
.video-card__body h3 { margin-bottom: 0.7rem; }
.video-card__body p { color: var(--text-secondary); max-width: 52ch; margin-bottom: 1.4rem; }
.video-embed video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 880px) {
  .nav__links { overflow-y: auto; }
  .nav__sub {
    position: static; transform: none; opacity: 1; visibility: visible;
    min-width: 0; padding: 0.4rem 0 0.2rem 1rem;
    background: none; border: 0;
  }
  .nav__sub a { font-size: 1.05rem; padding: 0.35rem 0; }
  .video-card { flex-direction: column; align-items: stretch; }
  .video-card__media { flex: none; width: 100%; max-width: 320px; }
}

/* ---------- Intro animata (home) ---------- */
.intro-seen .intro { display: none; }
.intro {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg-base);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  animation: introOut 0.7s var(--ease) 5.7s both;
}
.intro__text { width: fit-content; max-width: 100%; }
.intro__name {
  font-family: var(--font-title); font-weight: 700;
  font-size: clamp(2rem, 5.5vw, 3rem); line-height: 1.1; letter-spacing: -0.02em;
  color: var(--text-primary); margin-bottom: 0.5rem;
  min-height: 1.2em;
  opacity: 0;
}
.intro__tag {
  font-size: 0.78rem; letter-spacing: 0.1em; line-height: 1.7; text-align: center;
  white-space: pre-line; min-height: 3.4em;
  opacity: 0;
}
.intro__mark { width: clamp(118px, 30vw, 156px); height: auto; display: block; margin-bottom: 1.3rem; }
.intro__shape {
  fill: transparent;
  stroke: #dcdce0; stroke-width: 2;
  stroke-dasharray: 1; stroke-dashoffset: 1;
}
.intro__shape--top {
  animation: introTrace 0.9s var(--ease) 0.15s both,
             introFillTop 0.5s var(--ease) 1.1s both;
}
.intro__shape--bottom {
  animation: introTrace 0.9s var(--ease) 0.45s both,
             introFillBottom 0.5s var(--ease) 1.3s both;
}
@keyframes introTrace { to { stroke-dashoffset: 0; } }
@keyframes introFillTop {
  from { fill: rgba(206, 0, 0, 0); stroke-opacity: 1; }
  to   { fill: rgba(206, 0, 0, 1); stroke-opacity: 0; }
}
@keyframes introFillBottom {
  from { fill: rgba(250, 250, 250, 0); stroke-opacity: 1; }
  to   { fill: rgba(250, 250, 250, 1); stroke-opacity: 0; }
}
@keyframes introUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes introOut {
  to { opacity: 0; visibility: hidden; pointer-events: none; }
}
