/* Animated CTA button (site-coherent card style) */
.btn-cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px; /* slightly larger for prominence */
  border-radius: 14px; /* match site cards */
  text-decoration: none;
  color: #111;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.08); /* subtle border like cards */
  box-shadow: 0 6px 18px rgba(0,0,0,0.08); /* soft shadow like cards */
  font-weight: 600;
  font-size: clamp(0.95rem, 1.4vw, 1.05rem);
  letter-spacing: 0.02em;
  transition: transform 220ms cubic-bezier(.22,1,.36,1), box-shadow 220ms ease, background 220ms ease, color 220ms ease, border-color 220ms ease;
  will-change: transform, box-shadow;
}

/* =========================================================
   Final heading scale normalizer (unifies titles across pages)
   ========================================================= */
:root {
  --display: clamp(4rem, 12vw, 16rem);
  --h1: clamp(2.2rem, 6vw, 3.6rem);
  --h2: clamp(1.8rem, 4.8vw, 2.6rem);
  --h3: clamp(1.3rem, 3.2vw, 1.8rem);
  --subtitle: clamp(1.05rem, 2.6vw, 1.25rem);
  /* Hero avatar crop focus (tweak these to nudge the image inside the circle) */
  --avatar-x: 50%;
  --avatar-y: 1%;
}

/* ===== Fullscreen Loader Overlay ===== */
body.loading { cursor: none; }
#loader {
  position: fixed;
  inset: 0;
  z-index: 1000002;
  background: #0f0f0f; /* dark backdrop */
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 420ms ease;
}
#loader.is-hidden { opacity: 0; pointer-events: none; }
#loader .loader-logo img { display:block; width: clamp(64px, 10vw, 120px); height: auto; filter: drop-shadow(0 6px 20px rgba(0,0,0,.35)); }

/* Cursor replacement text */
#loading-cursor {
  position: fixed;
  top: 0; left: 0;
  transform: translate(-50%, -50%);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #f2f2f2;
  background: transparent;
  pointer-events: none;
  mix-blend-mode: normal;
}
body:not(.loading) #loading-cursor { display: none; }

/* Percent indicator */
#loading-progress {
  font-family: var(--font-heading);
  font-size: clamp(1.2rem, 4vw, 2rem);
  font-weight: 600;
  letter-spacing: 0.06em;
}

/* Hero display title */
.hero-name {
  /* further reduced scale for a more compact hero title */
  font-size: clamp(2.2rem, 7.5vw, 9rem) !important;
  line-height: .9;
  letter-spacing: -0.015em;
}
/* Make last name use the same font as section titles (About/Projects) */
.hero-name .last-name {
  font-family: var(--font-heading);
  font-weight: 400;
}

/* Primary section titles */
.main-title,
.footer-title { font-size: var(--h1) !important; line-height: 1.05; }

/* Secondary titles and large captions */
.subtitle,
.info-title,
.intro-title,
.about-caption-1 { font-size: var(--h2) !important; line-height: 1.15; }

/* Make About caption (h2) larger than default secondary titles */
.about-caption-1 { font-size: clamp(2.1rem, 6.4vw, 3.2rem) !important; }

/* Mobile: ensure About caption remains prominent */
@media (max-width: 576px) {
  .about-caption-1 { font-size: clamp(2.6rem, 12vw, 3.8rem) !important; }
}

/* ===== Hero subtitle (UX/UI Designer) animated & interactive ===== */
.subtitle.interactive {
  position: relative;
  display: inline-block;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, #fff, #ffd166, #ff8a00, #ffe29a, #fff);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradientFlow 6s linear infinite;
  cursor: pointer; /* indicates interactivity */
}

.subtitle.interactive::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 2px;
  background: currentColor;
  opacity: 0.12;
  transition: opacity .25s ease, transform .25s ease;
  transform: scaleX(.5);
  transform-origin: center;
}
.subtitle.interactive:hover::after { opacity: .35; transform: scaleX(1); }

@keyframes gradientFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

/* Subtle glow on hover */
.subtitle.interactive:hover { filter: drop-shadow(0 4px 14px rgba(255, 138, 0, .25)); }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .subtitle.interactive { animation: none; }
}

/* ===== Hero layout adjustments (home) ===== */
.hero-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
}
.hero-section .row { width: 100%; }

/* Hero avatar above the title */
.hero-avatar-wrap {
  position: relative;
  display: inline-block;
}
.hero-avatar {
  width: clamp(96px, 18vw, 160px);
  height: clamp(96px, 18vw, 160px);
  border-radius: 50%;
  object-fit: cover;
  object-position: var(--avatar-x) var(--avatar-y);
  border: 3px solid rgba(255,255,255,0.9);
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  display: block;
  margin-inline: auto;
  margin-bottom: clamp(12px, 3vw, 20px);
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 300ms cubic-bezier(.2,.9,.2,1), box-shadow 300ms ease;
  z-index: 2;
}
body.dark-mode .hero-avatar { border-color: rgba(255,255,255,0.92); }
@media (hover: hover) and (pointer: fine) {
  .hero-avatar:hover { transform: scale(1.03); box-shadow: 0 14px 48px rgba(0,0,0,0.32); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-avatar { transition: box-shadow 180ms ease; }
}

/* Smaller dog avatar: offset to the side and slightly lower */
.hero-avatar-dog {
  position: absolute;
  bottom: clamp(-12px, -2vw, -6px);
  left: clamp(-48px, -6vw, -24px);
  width: clamp(56px, 9vw, 96px);
  height: clamp(56px, 9vw, 96px);
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,0.92);
  box-shadow: 0 8px 28px rgba(0,0,0,0.28);
  background: #fff;
  z-index: 3; /* above main avatar border */
}
body.dark-mode .hero-avatar-dog { border-color: rgba(255,255,255,0.96); }
@media (max-width: 480px) {
  .hero-avatar-dog { left: clamp(-32px, -8vw, -16px); bottom: clamp(-10px, -3vw, -6px); }
}

/* ===== Mobile-specific hero tweaks ===== */
@media (max-width: 576px) {
  /* Raise the avatar slightly higher in the hero */
  .hero-avatar-wrap { transform: translateY(-64px); }
  
  /* Make the hero subtitle smaller on mobile */
  .subtitle,
  .subtitle.interactive { font-size: clamp(0.9rem, 3.8vw, 1.05rem) !important; }

  /* Enlarge the main hero title on mobile for better hierarchy */
  .hero-name { font-size: clamp(2.8rem, 12vw, 4.6rem) !important; }
}

/* Site header title 'PORTFOLIO®' smaller */
.header .main-title {
  font-size: clamp(0.9rem, 1.6vw, 1.2rem) !important;
  letter-spacing: 0.12em;
}

/* Enlarge only the hero navbar items */
.hero-nav .nav-item {
  font-size: clamp(1.1rem, 2.6vw, 1.35rem) !important;
}
.hero-nav {
  display: flex;
  justify-content: center;
  text-align: center;
  width: 100%;
}
.hero-nav ul {
  gap: clamp(24px, 6vw, 96px) !important;
  flex-wrap: wrap;
  justify-content: center;
  margin-inline: auto;
  list-style: none;
  padding: 0;
  margin-top: 0;
  margin-bottom: 0;
  align-items: center;
}
.hero-nav ul li { margin: 0; }

/* Extra-large desktops: constrain width and distribute evenly */
@media (min-width: 1440px) {
  .hero-nav ul {
    width: fit-content;
    margin-inline: auto;
    flex-wrap: nowrap;
    justify-content: center;
    gap: clamp(72px, 10vw, 180px) !important;
  }
}
@media (min-width: 1920px) {
  .hero-nav ul {
    width: fit-content;
    justify-content: center;
    gap: clamp(96px, 12vw, 220px) !important;
  }
}

/* Tertiary titles */
.topic-title,
.resume-title { font-size: var(--h3) !important; }

/* Normalize quote styles moved from inline */
.about-quote { margin: 6px 0 8px; font-style: italic; opacity: .9; }
.about-quote cite { display:block; font-style: normal; opacity: .7; font-size: .95em; }
.project-detail .a11y-analysis .case-wrap > * {
  max-width: 920px;
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(12px, 3vw, 24px);
  padding-right: clamp(12px, 3vw, 24px);
}

/* Align About title spacing with Projects header */
#about { padding-top: clamp(48px, 7vw, 90px); }
#about .about-title-wrap { margin: clamp(24px, 4vw, 48px) 0; }

/* Utility buttons (dark mode, scroll top, language) */
/* Shared styles */
.btn-circle {
  position: fixed;
  z-index: 1000001;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.btn-rect {
  position: fixed;
  z-index: 1000001;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  background: #f4f4f4;
  color: #111;
  font-weight: 700;
}

/* Specific instances positioning */
#langToggle.btn-rect { top: 24px; right: 84px; }

/* Prevent overlap on very small screens: stack language button below */
@media (max-width: 480px) {
  #langToggle.btn-rect { top: 24px; right: 84px; }
}

/* Scroll-to-top button global placement and visibility */
#scrollTopBtn.btn-circle { bottom: 24px; right: 24px; z-index: 99999; background: #222; }
#scrollTopBtn { opacity: 0; pointer-events: none; transition: opacity 0.5s cubic-bezier(.77,0,.18,1), background 0.3s ease; }
#scrollTopBtn.visible { opacity: 1; pointer-events: auto; }

/* Dark mode: white button, dark icon */
body.dark-mode #scrollTopBtn { background: #fff; }
body.dark-mode #scrollTopBtn i,
body.dark-mode #scrollTopBtn * { color: #181818 !important; }
body.dark-mode #scrollTopBtn svg { fill: #181818 !important; stroke: #181818 !important; }

/* Skip to content link (visible on focus) */
.skip-link {
  position: absolute;
  top: -1000px;
  left: 0;
  background: #fff;
  color: #000;
  padding: 10px 14px;
  border: 2px solid #000;
  border-radius: 6px;
  z-index: 100000;
}
.skip-link:focus { top: 10px; left: 10px; outline: none; }

/* Global focus-visible styles for interactive elements */
a:focus-visible,
button:focus-visible,
.btn-cta:focus-visible,
.nav-item:focus-visible,
.project-topic-block:focus-visible,
.topic-download:focus-visible,
.primary-cta:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
  box-shadow: none;
}

/* Accessibility analysis layout: alternate text and images */
.project-detail .a11y-analysis .analysis-head {
  padding: clamp(12px, 3vh, 24px) 0;
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: clamp(14px, 3vw, 28px);
  align-items: center;
}
.project-detail .a11y-analysis .analysis-head-copy { display: block; }
.project-detail .a11y-analysis .analysis-hero-media img {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0,0,0,.14);
  transform: translateZ(0);
}
@media (max-width: 992px) {
  .project-detail .a11y-analysis .analysis-head { grid-template-columns: 1fr; }
  .project-detail .a11y-analysis .analysis-hero-media img { box-shadow: 0 12px 26px rgba(0,0,0,.12); }
}
.project-detail .a11y-analysis .analysis-title {
  font-family: var(--font-heading);
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  line-height: 1.05;
  margin: 0 0 8px;
}
.project-detail .a11y-analysis .meta-inline {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: #444;
  opacity: .9;
  margin: 0 0 clamp(14px, 2.2vh, 22px);
}
.project-detail .a11y-analysis .analysis-intro {
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  line-height: 1.6;
  color: #333;
  margin: 4px 0 clamp(12px, 2vh, 18px);
}
.project-detail .a11y-analysis .analysis-tags { margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.project-detail .a11y-analysis .analysis-tags .tag {
  font-size: .9rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: #111;
}
.project-detail .a11y-analysis .meta-inline span + span::before { content: " · "; margin: 0 8px; color: #777; }

.project-detail .a11y-analysis .analysis-block {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  align-items: center;
  gap: clamp(14px, 2.6vw, 28px);
  padding: clamp(10px, 2vh, 18px) 0;
  /* Entry animation base (will run on overlay open) */
  opacity: 0;
  transform: translateY(12px);
  animation: a11yFadeUp 560ms cubic-bezier(.22,1,.36,1) both;
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 14px;
  background: #fff;
}
.project-detail .a11y-analysis .analysis-block:nth-of-type(even) { background: #fafafa; }
@media (prefers-color-scheme: dark) {
  .project-detail .a11y-analysis .analysis-block { background: #151515; border-color: rgba(255,255,255,.12); }
  .project-detail .a11y-analysis .analysis-block:nth-of-type(even) { background: #111; }
}
.project-detail .a11y-analysis .analysis-block .analysis-text { order: 1; }
.project-detail .a11y-analysis .analysis-block .analysis-media { order: 2; margin: 0; }
.project-detail .a11y-analysis .analysis-block:nth-of-type(even) .analysis-text { order: 2; }
.project-detail .a11y-analysis .analysis-block:nth-of-type(even) .analysis-media { order: 1; }
.project-detail .a11y-analysis .analysis-block .analysis-text h3 {
  margin: 0 0 6px;
  font-size: clamp(1.2rem, 2.6vw, 1.6rem);
  letter-spacing: .2px;
}
.project-detail .a11y-analysis .analysis-block .analysis-text p {
  margin: 0;
  color: #555;
  font-size: clamp(1.05rem, 2.1vw, 1.2rem);
  line-height: 1.6;
}
.project-detail .a11y-analysis .analysis-block .analysis-text ul { margin: 6px 0 0 18px; }
.project-detail .a11y-analysis .analysis-block .analysis-text ul li {
  font-size: clamp(1rem, 2vw, 1.1rem);
  margin: 4px 0;
}

/* Issues snapshot table */
.project-detail .a11y-analysis .issues-table { display: grid; gap: 6px; margin-top: 6px; }
.project-detail .a11y-analysis .issues-row { display: grid; grid-template-columns: 2fr .6fr .6fr; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid rgba(0,0,0,.08); border-radius: 10px; background: #fff; }
.project-detail .a11y-analysis .issues-head { background: #111; color: #fff; border-color: transparent; font-weight: 700; }
.project-detail .a11y-analysis .sev { padding: 4px 8px; border-radius: 999px; font-weight: 700; font-size: .9rem; }
.project-detail .a11y-analysis .sev-high { background: #e53935; color: #fff; }
.project-detail .a11y-analysis .sev-med { background: #f9a825; color: #111; }

@media (prefers-color-scheme: dark) {
  .project-detail .a11y-analysis .issues-row { background: #151515; border-color: rgba(255,255,255,.12); }
  .project-detail .a11y-analysis .issues-head { background: #eaeaea; color: #111; }
}

/* Keyshots mini-gallery */
.project-detail .a11y-analysis .keyshots { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 8px; }
.project-detail .a11y-analysis .keyshots figure { margin: 0; }
.project-detail .a11y-analysis .keyshots figcaption { font-size: .9rem; opacity: .8; margin-top: 6px; text-align: center; }
@media (max-width: 768px) { .project-detail .a11y-analysis .keyshots { grid-template-columns: 1fr; } }
.project-detail .a11y-analysis .analysis-block .analysis-media img {
  display: block;
  width: min(100%, 1920px);
  aspect-ratio: 16 / 9; /* 1920x1080 */
  height: auto;
  object-fit: cover;
  border-radius: 8px;
  margin: 0 auto;
  transition: transform 360ms cubic-bezier(.22,1,.36,1), box-shadow 360ms ease;
}

/* Metrics row (hero KPIs) */
.project-detail .a11y-analysis .analysis-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 10px 0 4px; }
.project-detail .a11y-analysis .metric { background: #fff; border: 1px solid rgba(0,0,0,.08); border-radius: 14px; padding: 12px 14px; display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; }
.project-detail .a11y-analysis .metric-emoji { font-size: 1.4rem; }
.project-detail .a11y-analysis .metric strong { display: block; font-size: clamp(1.2rem, 2.6vw, 1.6rem); line-height: 1; }
.project-detail .a11y-analysis .metric span { font-size: .95rem; opacity: .8; }
@media (prefers-color-scheme: dark) {
  .project-detail .a11y-analysis .metric { background: #151515; border-color: rgba(255,255,255,.12); }
}
@media (max-width: 768px) { .project-detail .a11y-analysis .analysis-metrics { grid-template-columns: 1fr; } }

@media (max-width: 992px) {
  .project-detail .a11y-analysis .analysis-block {
    grid-template-columns: 1fr;
  }
  .project-detail .a11y-analysis .analysis-block .analysis-text,
  .project-detail .a11y-analysis .analysis-block .analysis-media { order: initial; }
  .project-detail .a11y-analysis .analysis-block .analysis-media img {
    width: 100%;
  }
}

/* =========================================================
   Global reset & fluid media
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, picture, svg, video, canvas { display: block; max-width: 100%; height: auto; }
/* Avoid stretched icons */
svg { height: auto; }
/* Balance text wrapping for better legibility */
@supports (text-wrap: balance) {
  h1, h2, h3, h4 { text-wrap: balance; }
}

/* Base typography scale */
body {
  font-size: clamp(15px, 1.6vw, 18px);
  line-height: 1.6;
}
h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); line-height: 1.12; margin: 0 0 .4em; }
h2 { font-size: clamp(1.8rem, 4.6vw, 2.6rem); line-height: 1.18; margin: 0 0 .5em; }
h3 { font-size: clamp(1.3rem, 3vw, 1.8rem); line-height: 1.22; margin: 0 0 .5em; }
p, li { font-size: clamp(1rem, 2.2vw, 1.1rem); }

/* Tablet refinements */
@media (min-width: 768px) and (max-width: 1200px) {
  .info-section .skills-slider { margin-top: clamp(48px, 10vw, 120px); }
  .projects-scroller { gap: clamp(12px, 3vw, 24px); }
}

/* Stagger the entry of analysis blocks for a pleasing cadence */
.project-detail .a11y-analysis .analysis-block:nth-of-type(1) { animation-delay: 40ms; }
.project-detail .a11y-analysis .analysis-block:nth-of-type(2) { animation-delay: 120ms; }
.project-detail .a11y-analysis .analysis-block:nth-of-type(3) { animation-delay: 200ms; }
.project-detail .a11y-analysis .analysis-block:nth-of-type(4) { animation-delay: 280ms; }

@keyframes a11yFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Subtle decorative underline on section headings */
.project-detail .a11y-analysis .analysis-block .analysis-text h3 {
  position: relative;
}
.project-detail .a11y-analysis .analysis-block .analysis-text h3::after {
  content: "";
  position: absolute;
  left: 0; bottom: -6px;
  width: 28px; height: 2px;
  background: currentColor;
  opacity: .18;
  transition: width 360ms cubic-bezier(.22,1,.36,1), opacity 240ms ease;
}

/* Fine pointer: hover polish for images and heading underline */
@media (hover: hover) and (pointer: fine) {
  .project-detail .a11y-analysis .analysis-block .analysis-media img:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 10px 28px rgba(0,0,0,.14);
  }
  .project-detail .a11y-analysis .analysis-block .analysis-text h3:hover::after {
    width: 46px;
    opacity: .35;
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .project-detail .a11y-analysis .analysis-block,
  .project-detail .a11y-analysis .analysis-block .analysis-media img,
  .project-detail .a11y-analysis .analysis-block .analysis-text h3::after {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}
/* Include hamburger and overlay controls */
.hamburger-menu:focus-visible,
.project-detail-close:focus-visible,
.download-btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}
/* Remove focus outlines when not keyboard-focused */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
.btn-cta:focus:not(:focus-visible),
.nav-item:focus:not(:focus-visible),
.project-topic-block:focus:not(:focus-visible),
.topic-download:focus:not(:focus-visible),
.primary-cta:focus:not(:focus-visible) {
  outline: none;
}

/* Ensure minimum touch target sizes (WCAG 2.5.5 AAA advisable; we aim >=44px) */
.nav-item,
.btn-cta,
.topic-download,
.primary-cta {
  min-height: 44px;
  min-width: 44px;
}
/* Ensure hamburger meets target size */
.hamburger-menu { min-width: 48px; min-height: 48px; }

/* Underline links on focus-visible for clarity */
a:focus-visible { text-decoration: underline; text-decoration-thickness: 2px; }

/* Respect reduced motion everywhere */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .info-section .skills-track { animation: none !important; }
}

/* Container-wide (not full-bleed) case study sections */
.project-detail .case-wrap > * {
  width: 100%;
  max-width: none; /* full-bleed */
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
  padding-right: 0;
  box-sizing: border-box;
}
.project-detail .case-wrap .gallery,
.project-detail .case-wrap .case-meta,
.project-detail .case-wrap .phase-nav { width: 100%; }

/* Header inside project-detail uses normal container width */
.project-detail-header { width: 100%; margin-left: 0; margin-right: 0; padding: 0 clamp(16px, 5vw, 80px); box-sizing: border-box; }
.btn-cta::after {
  content: "";
  position: absolute;
  inset: 0; /* full button */
  border-radius: inherit;
  background: radial-gradient(120% 120% at 10% 0%, rgba(255,255,255,0.6), rgba(255,255,255,0) 40%);
  opacity: 0;
  transition: opacity 220ms ease;
  pointer-events: none;
}
.btn-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0,0,0,0.12);
  background: #111; /* site dark text color */
  color: #fff;
  border-color: rgba(0,0,0,0.25);
}
.btn-cta:hover::after { opacity: 0.25; }
.btn-cta i { font-size: 1rem; transition: transform 220ms cubic-bezier(.22,1,.36,1), color 220ms ease; }
.btn-cta:hover i { transform: translate(2px, -1px); }
.btn-cta:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(17,17,17,0.12), 0 8px 22px rgba(0,0,0,0.16);
}
.btn-cta:active { transform: translateY(-1px); }

/* Variant positioning in About */
.about-cta { margin-top: 18px; display: inline-flex; }

/* Dark mode variants */
body.dark-mode .btn-cta {
  background: #151515;
  color: #f2f2f2;
  border-color: rgba(255,255,255,0.14);
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
body.dark-mode .btn-cta:hover {
  background: #fff;
  color: #111;
  border-color: rgba(255,255,255,0.18);
}
@media (prefers-reduced-motion: reduce) {
  .btn-cta,
  .btn-cta i { transition: none !important; }
}
.main-content {
    flex: 1 0 auto; /* fill remaining space so footer can be pushed to bottom */
}

/* Smooth scroll for anchor links */
html { scroll-behavior: smooth; }



/* Keep simple nowrap behavior at >=992px; sizes are unified via CSS variables */
@media (min-width: 992px) and (max-width: 1200px) {
  .hero-name { white-space: nowrap !important; }
}

@media (min-width: 1200px) and (max-width: 1440px) {
  .hero-name { white-space: nowrap !important; }
}

/* =========================================================
   Projects scroller containment
   ========================================================= */
.projects-section {
  overflow-x: clip; /* prevent section content from creating page-wide scroll */
}

.projects-scroller {
  display: flex;
  flex-direction: row;
  gap: clamp(12px, 3.5vw, 28px);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  padding: 8px clamp(12px, 4vw, 32px);
  box-sizing: border-box;
  /* Allow vertical panning gestures to bubble and avoid scroll lock on mobile */
  touch-action: pan-y;
  overscroll-behavior-x: contain; /* contain horizontal rubber-banding */
}

.projects-scroller::-webkit-scrollbar { height: 10px; }
.projects-scroller::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 6px; }
.projects-scroller::-webkit-scrollbar-track { background: transparent; }

/* Mobile: allow native swipe and hide helper text */
@media (max-width: 768px) {
  .projects-scroller { touch-action: pan-x pinch-zoom; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
  .projects-subtitle { display: none; }
}

/* Touch devices (regardless of width): enable horizontal pan */
@media (hover: none), (pointer: coarse) {
  .projects-scroller { touch-action: pan-x pinch-zoom; -webkit-overflow-scrolling: touch; }
  .projects-scroller * { touch-action: pan-x pinch-zoom; }
}

.project-topic-block {
  flex: 0 0 auto;
  width: clamp(280px, 55vw, 640px); /* larger cards for bigger images */
  scroll-snap-align: start;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
}

.project-topic-block .topic-media img {
  display: block;
  width: 100%;
  height: clamp(220px, 34vw, 440px); /* smaller to reduce page height */
  object-fit: cover;
  /* Prevent native drag/selection so vertical scrolling remains smooth over images */
  -webkit-user-drag: none;
  user-select: none;
  touch-action: pan-x pinch-zoom; /* allow horizontal swipe on images in scroller */
}

.project-topic-block .topic-info { padding: 10px 12px; }
.project-topic-block .topic-title { margin: 6px 0 4px; font-size: 1.05rem; }
.project-topic-block .topic-meta { margin: 0; opacity: 0.8; font-size: 0.95rem; }

/* =========================================================
   Skills slider (scoped to Info section)
   ========================================================= */
.info-section .skills-slider { 
  overflow: hidden; 
  padding: clamp(14px, 2.4vw, 22px) clamp(18px, 3vw, 28px);
  background: #ffffff; /* card-like like about-section */
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px; /* same radius of cards */
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  width: 100%;
  max-width: none;
  margin-inline: 0;
  margin-top: clamp(120px, 22vw, 280px); /* push well below projects */
  margin-bottom: clamp(6px, 1.2vw, 14px);
}
.info-section .skills-track {
  display: flex; 
  align-items: center;
  gap: clamp(64px, 10vw, 140px); /* even larger spacing like reference */
  width: max-content; 
  will-change: transform; 
  animation: skillsLoop 30s linear infinite;
}
.info-section .skill { 
  display: inline-flex; 
  align-items: center; 
  gap: 12px; 
  font-size: clamp(0.85rem, 1.8vw, 1rem); /* keep label small */
  color: #222; 
  opacity: 0.85;
}
.info-section .skill i { font-size: clamp(2rem, 5.6vw, 3.2rem); color: inherit; }
.info-section .skill img {
  height: clamp(56px, 8.5vw, 80px);
  width: auto;
  display: block;
  filter: none; /* brand colors visible */
  background: transparent; /* no individual badge */
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}
.info-section .skill span { display: none; }
@keyframes skillsLoop { 
  from { transform: translateX(0); } 
  to { transform: translateX(-50%); } 
}
@media (hover: hover) and (pointer: fine) {
  .info-section .skill:hover { opacity: 1; transform: translateY(-1px); }
}
body.dark-mode .info-section .skills-slider { background: #151515; border-color: rgba(255,255,255,0.14); box-shadow: 0 6px 18px rgba(0,0,0,0.35); }
body.dark-mode .info-section .skill { color: #eaeaea; }
/* High-contrast badge behind skill logos for dark mode */
body.dark-mode .info-section .skill img {
  background: #ffffff; /* light tile to maximize contrast */
  border: 1px solid rgba(0,0,0,0.2);
  border-radius: 10px;
  padding: 6px; /* breathing room around the logo */
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
  filter: none; /* keep brand colors vivid on light background */
}
/* Focus color adapts in dark mode */
:root {
  --focus-ring: #6aa9ff;
  --accent: #ff8a00;
}

/* =========================================================
   Footer CTA containment
   ========================================================= */
.footer-cta { overflow-x: clip; }
.footer-illustration { display: flex; justify-content: center; }
.footer-illustration img { display: block; max-width: min(92vw, 520px); height: auto; }

/* About avatar: remove any background/border/shadow so it blends with the page */
.about-title-wrap img.img-fluid {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

/* About stats logo: responsive and non-clipping */
.about-stats-logo { 
  display: flex; 
  justify-content: center; 
  align-items: center; 
  overflow: visible; 
}
.about-stats-logo .stats-logo {
  display: block;
  max-width: min(60vw, 380px);
  width: 100%;
  height: auto;
  object-fit: contain;
}
@media (max-width: 768px) {
  .about-stats-logo .stats-logo { max-width: min(80vw, 340px); }
}

/* Home About section: ensure nothing gets clipped and give bottom space */
#about { overflow: visible; padding-bottom: clamp(16px, 4vh, 40px); }
#about .row { overflow: visible; }
#about .col-12 { overflow: visible; }

/* Playground (home About section under stats): prevent clipping and add bottom space */
#playground { overflow: visible !important; padding-bottom: clamp(64px, 12vh, 140px); }
#playground .container-fluid { overflow: visible !important; }
#playground .row { overflow: visible !important; }
#playground .col-12 { overflow: visible !important; }
.about-section.is-dark { overflow: visible !important; }

/* Extra safety: ensure the stats logo block itself adds margin at the bottom */
.about-stats-logo { margin: clamp(12px, 4vh, 40px) 0 clamp(20px, 6vh, 64px); }

/* Reduce spacing between About title and the first caption */
#about .about-title-wrap { margin-bottom: 8px; }
#about .about-title-wrap .main-title { margin: 0 0 6px; }
#about .about-caption-1 { margin-top: 0; }
#about .about-caption-1 .lead { margin-top: 0; }
@media (max-width: 768px) {
  #about .about-title-wrap { margin-bottom: 6px; }
  #about .about-title-wrap .main-title { margin-bottom: 4px; }
}

/* Arrange About title area: title + quote on the left, avatar on the right */
#about .about-title-wrap { 
  display: grid; 
  /* Make the title column flexible so long quotes wrap within viewport */
  grid-template-columns: 1fr max-content; 
  grid-template-rows: auto auto; 
  grid-template-areas:
    "title avatar"
    "quote quote"; /* quote spans both columns so it doesn't push avatar away */
  justify-content: start; /* keep columns hugging the left, side-by-side */
  align-items: start; 
  column-gap: clamp(6px, 1.2vw, 12px); /* small gap between title and avatar */
  /* Match Projects header spacing */
  margin: 0 16px clamp(16px, 3vw, 28px);
}
#about .about-title-wrap .main-title { grid-area: title; margin: 0 0 4px; }
#about .about-title-wrap .about-quote { grid-area: quote; margin: 4px 0 0 !important; }
#about .about-title-wrap .about-quote {
  font-size: clamp(1.8rem, 4.4vw, 3.2rem);
  line-height: 1.12;
  font-weight: 600;
  margin-top: 10px !important;
  /* Ensure the quote wraps instead of overflowing on desktop */
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}
#about .about-title-wrap .about-quote cite {
  font-size: clamp(1rem, 1.8vw, 1.2rem) !important;
  opacity: .8 !important;
  margin-top: 4px;
}
#about .about-title-wrap .img-fluid {
  grid-area: avatar;
  justify-self: start;
  align-self: start;
  max-width: min(16vw, 120px); /* reduced size */
  height: auto;
  /* Pull slightly into the title area to visually reduce the gap */
  margin-left: 0; /* align immediately to the right of title */
  margin-top: 2px;
}
@media (max-width: 768px) {
  /* Previous layout: stack, image below title, larger */
  #about .about-title-wrap { grid-template-columns: 1fr; }
  #about .about-title-wrap .img-fluid {
    grid-column: 1;
    justify-self: start;
    max-width: min(60vw, 280px);
    margin-top: 0;
  }
}

/* =========================================================
   Project Detail overlay: vertically scrolling presentation
   ========================================================= */
#project-detail { overflow-x: clip; }
.project-detail-scroller {
  display: block; /* stack slides vertically */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  max-height: 100vh; /* keep header visible and content scrollable */
  scroll-snap-type: y proximity;
}

/* Uniform image treatment across all project detail slides */
.project-detail .detail-slide img {
  display: block;
  width: min(100%, 1920px);
  aspect-ratio: 16 / 9; /* 1920x1080 */
  height: auto;
  object-fit: cover;
  border-radius: 8px;
  margin: 0 auto;
}

/* Brief timeline layout (scoped to project detail overlay) */
.project-detail .brief-timeline .brief-head { padding: clamp(12px, 3vh, 24px) 0; }
.project-detail .brief-timeline .brief-title {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 4.6vw, 2.6rem);
  line-height: 1.05;
  margin: 0 0 6px;
}
.project-detail .brief-timeline .meta-inline {
  font-size: clamp(0.95rem, 1.8vw, 1.05rem);
  color: #444;
  opacity: .9;
  margin: 0 0 clamp(12px, 2vh, 18px);
}
.project-detail .brief-timeline .meta-inline span + span::before { content: " · "; margin: 0 8px; color: #777; }
.project-detail .brief-timeline .brief-steps { padding: 0 0 clamp(8px, 2vh, 14px); }
.project-detail .brief-timeline .steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: clamp(14px, 3vh, 22px);
}
.project-detail .brief-timeline .steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: minmax(40px, 72px) 1fr;
  align-items: start;
  column-gap: clamp(10px, 2.5vw, 22px);
}
.project-detail .brief-timeline .steps li::before {
  content: counter(step);
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1;
  color: #111;
  text-align: right;
  padding-top: 2px;
}
.project-detail .brief-timeline .step-title {
  font-weight: 700;
  font-size: clamp(1.05rem, 2.2vw, 1.3rem);
  margin: 0 0 2px;
}
.project-detail .brief-timeline .step-desc {
  margin: 0;
  color: #555;
  font-size: clamp(0.95rem, 1.8vw, 1.05rem);
}

/* Card-like slide container */
.detail-slide {
  scroll-snap-align: start;
  width: 100%;
  max-width: none; /* allow full viewport width */
  margin: 0 auto clamp(24px, 5vh, 56px);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* Split hero inside each slide */
.detail-slide.split {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: clamp(16px, 3vw, 48px);
  align-items: center;
  /* full width: no horizontal padding */
  padding: clamp(16px, 2.5vh, 40px) 0;
}
.detail-slide .split-right img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  max-width: 90%; /* visually smaller */
  margin: 0 auto; /* center inside column */
}

/* Hero headline and kicker */
.detail-slide .hero-headline {
  font-family: var(--font-heading);
  font-size: clamp(24px, 3.2vw, 34px);
  line-height: 1.2;
  margin: 0;
}
.detail-slide .hero-kicker {
  font-size: clamp(14px, 1.4vw, 16px);
  color: #555;
  margin: 8px 0 0;
}

/* Process steps (Meta, Goals, Results) */
.process-steps { padding: 0 0 clamp(20px, 3vw, 40px); }
.process-step {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: clamp(16px, 3vw, 40px);
  align-items: start;
  background: transparent; /* inherit overlay bg */
  border: 0;
  border-radius: 0;
  padding: clamp(10px, 1.5vw, 16px) 0;
}
.process-step + .process-step { margin-top: clamp(12px, 2vw, 18px); }
.process-step .step-media img { display: block; width: 100%; height: auto; border-radius: 0; }
.process-step .step-title { font-size: clamp(16px, 1.8vw, 20px); margin: 0 0 6px; }
.process-step .step-index {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 24px; padding: 0 8px; margin-right: 6px;
  font-size: 0.85em; line-height: 1; border-radius: 999px; background: #111; color: #fff;
}
.process-step .step-text { color: #333; }
.process-step ul.step-text { margin: 0; }
.process-step ul.step-text li { margin: 6px 0; }

@media (max-width: 992px) {
  .detail-slide.split { grid-template-columns: 1fr; padding: clamp(14px, 3.5vh, 24px) 0; }
  .process-steps { padding: 0 0 clamp(18px, 4vw, 36px); }
  .process-step { grid-template-columns: 1fr; gap: clamp(10px, 3vw, 18px); }
}

/* Dark mode variants for the overlay */
body.dark-mode .detail-slide { background: transparent; border-color: transparent; box-shadow: none; }
body.dark-mode .process-step { background: transparent; border-color: transparent; }
body.dark-mode .process-step .step-text { color: #eaeaea; }
body.dark-mode .detail-slide .hero-kicker { color: #c9c9c9; }

/* =========================================================
   Alternative Case Study Layout (UI Design slide)
   ========================================================= */
.case-wrap { padding: 0; }
.case-hero { display: grid; grid-template-columns: 1.3fr 1fr; align-items: center; gap: clamp(16px, 3vw, 48px); padding: clamp(12px, 3vh, 48px) 0; }
.case-hero-media img { width: 100%; height: auto; border-radius: 8px; display: block; max-width: 90%; margin: 0 auto; }
.case-title { font-family: var(--font-heading); font-size: clamp(26px, 3.6vw, 44px); line-height: 1.15; margin: 0 0 10px; }
.case-lead { font-size: clamp(16px, 1.6vw, 18px); opacity: .9; margin: 0; }

.case-meta { padding: 0; margin-top: clamp(8px, 1.6vw, 16px); }
.meta-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(10px, 1.8vw, 24px); }
.meta-item { background: rgba(255,255,255,.75); border: 1px solid rgba(0,0,0,0.08); border-radius: 10px; padding: 12px 14px; }
.meta-item h4 { font-size: 0.9rem; margin: 0 0 4px; opacity: .7; }
.meta-item p { margin: 0; font-weight: 600; }

.kpi-cards { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(10px, 1.8vw, 24px); padding: 0; margin: clamp(12px, 2vw, 24px) 0 0; }
.kpi-cards li { background: #111; color: #fff; border-radius: 12px; padding: clamp(12px, 2vw, 18px); display: flex; align-items: center; gap: 12px; }
.kpi-cards li strong { font-size: clamp(20px, 3vw, 28px); line-height: 1; }
.kpi-cards li span { opacity: .9; }

.phase-section { display: grid; grid-template-columns: 220px 1fr; gap: clamp(16px, 3vw, 48px); align-items: start; padding: clamp(20px, 4vh, 80px) 0; }
.phase-aside { position: sticky; top: 0; align-self: start; }
.section-title { font-size: clamp(14px, 1.4vw, 16px); letter-spacing: .04em; text-transform: uppercase; opacity: .7; margin: 0; }
.phase-body { max-width: 100%; }
.phase-body .bullets { padding-left: 18px; }

.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(10px, 2vw, 20px); margin-top: 12px; }
.gallery img { display: block; width: 100%; height: auto; border-radius: 8px; max-width: 90%; margin: 0 auto; }
.gallery figcaption { font-size: .9rem; opacity: .75; margin-top: 6px; }

.cta-row { margin-top: clamp(12px, 2vw, 20px); }

/* Dark mode for case study blocks */
body.dark-mode .meta-item { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12); }
body.dark-mode .kpi-cards li { background: #fff; color: #111; }
body.dark-mode .section-title { opacity: .85; }

/* Phase navigation */
.phase-nav {
  display: flex;
  gap: clamp(10px, 2vw, 22px);
  flex-wrap: wrap;
  padding: 0;
  margin-top: clamp(8px, 1.5vw, 16px);
}
.phase-nav a {
  text-decoration: none;
  color: #111;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: .95rem;
}
.phase-nav a:hover { background: #111; color: #fff; border-color: #111; }
body.dark-mode .phase-nav a { background: #151515; color: #f1f1f1; border-color: rgba(255,255,255,0.16); }
body.dark-mode .phase-nav a:hover { background: #fff; color: #111; border-color: #fff; }

/* Anchor offsets for sticky headers */
.phase-section { scroll-margin-top: 72px; }

@media (max-width: 992px) {
  .case-hero { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-cards { grid-template-columns: 1fr; }
  .phase-section { grid-template-columns: 1fr; }
  .phase-aside { position: static; }
  .gallery { grid-template-columns: 1fr; }
}

/* =========================================================
   About carousel containment
   ========================================================= */
.carousel-container { overflow-x: clip; touch-action: pan-y; }
.carousel-track { display: flex; gap: 16px; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.carousel-slide { flex: 0 0 auto; width: clamp(220px, 70vw, 560px); border-radius: 10px; overflow: hidden; }
.carousel-slide img { display: block; width: 100%; height: auto; object-fit: cover; -webkit-user-drag: none; user-select: none; }

/* Disable hover effects on touch devices for carousel and project cards */
@media (hover: none), (pointer: coarse) {
  /* Generic cards used in projects list/carousel */
  .project-item:hover,
  .project-year-block:hover,
  .project-topic-block:hover,
  .projects-scroller .project-topic-block .topic-download:hover,
  .detail-slide.split .download-btn:hover {
    transform: none !important;
    box-shadow: none !important;
    background: inherit !important;
    color: inherit !important;
    opacity: 1 !important;
  }
  /* Topic image scale on hover */
  .project-topic-block:hover .topic-image { transform: none !important; }
  /* Remove hover glow overlay */
  .project-topic-block:hover::after { opacity: 0 !important; }
  /* Carousel slide specific */
  .carousel-slide:hover { transform: none !important; box-shadow: none !important; }
  /* Also disable all transitions on project-topic-blocks to avoid jank during touch drags */
  .project-topic-block,
  .project-topic-block * { transition: none !important; }
}

/* Additionally disable hover effects on small viewports regardless of pointer type */
@media (max-width: 768px) {
  /* Neutralize hover states for project-topic blocks and media */
  /* Allow horizontal gestures on entire card in mobile */
  .project-topic-block,
  .project-topic-block * { touch-action: pan-x pinch-zoom; }
  .project-topic-block:hover,
  .project-topic-block:hover .topic-media,
  .project-topic-block:hover .topic-image,
  .topic-media:hover,
  .topic-media:hover .topic-image,
  .project-topic-block:hover::after {
    transform: none !important;
    box-shadow: none !important;
    filter: none !important;
    opacity: 1 !important;
    transition: none !important;
  }
}

/* Removed blanket hover-disable at <=1024px to allow desktop hover effects.
   Touch and coarse pointers are already handled above via (hover:none)/(pointer:coarse). */

/* Home-only overrides to keep hero exactly the viewport height */
body.home { overflow-x: hidden; overflow-y: auto; padding-top: 0; }
body.home .header { position: absolute; top: 0; left: 0; right: 0; padding: 30px 0; z-index: 2; }
body.home .main-content { padding: 0; margin: 0; min-height: 0; }

/* Keep the big title on one line on desktop; allow wrap on small screens */
@media (min-width: 992px) {
  .hero-name { white-space: nowrap; }
  .hero-name span { white-space: nowrap; }
}

/* Keep hero title on a single line on mid/large desktops */
@media (min-width: 992px) and (max-width: 1440px) { /* sizes unified; keep only nowrap */ }

/* Keep hero content in natural flow position (no vertical offset) */
.hero-section > .row { transform: none; }
@media (min-width: 992px) {
  .hero-section > .row { transform: none; }
}
/* =========================================================
   Base & Variables
   ========================================================= */
:root {
    --bg-color: #e9e8d9;
    --text-color: #1a1a1a;
    --font-heading: 'Playfair Display', sans-serif;
    --font-body: 'Poppins', sans-serif;
    --accent-color: #1a1a1a;
    --focus-ring: #0a84ff; /* accessible focus color */
}

.jacques-francois-shadow-regular {
  font-family: "Jacques Francois Shadow", serif;
  font-weight: 400;
  font-style: normal;
}
html { overflow-x: hidden; }
body {
    background-color: var(--bg-color) !important;
    color: var(--text-color);
    font-family: var(--font-body);
    margin: 0;
    padding-top: 80px; /* Spazio per la navbar fissa */
    overflow-x: hidden; /* prevent horizontal scroll, keep vertical scrolling */
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh; /* allow footer to stick to bottom */
}

/* Global box-sizing reset to avoid width overflow due to padding/border */
*, *::before, *::after { box-sizing: border-box; }

/* Clip horizontal overflow from common wrappers (Bootstrap containers/rows) */
.container-fluid { overflow-x: clip; }
.main-content > section { overflow-x: clip; }
.works-content { overflow-x: clip; }
.footer, .footer-bottom { overflow-x: clip; }

.header,
.main-content,
.footer-bottom {
    width: 100%;
    margin: 0 auto;
}

/* =========================================================
   Header
   ========================================================= */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 30px 0;
}

.logo-container {
    position: absolute;
    top: 30px;
    right: 10rem;
    left: auto;
    gap: 50px;
    display: flex;
    align-items: center;
    font-size: 20px;
    text-transform: uppercase;
    z-index: 100;
}

.site-title {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
}



.subtitle {
    font-size: 4.9rem;
    font-weight: 200;
    margin-top: 5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #555;
}

/* Subtitle under large title: center and constrain width */
.hero-section .subtitle {
    text-align: center;
    font-size: clamp(1.15rem, 2.6vw, 1.8rem); /* bigger subtitle */
    font-weight: 300;
    letter-spacing: 0.08em;
    color: #666;
    max-width: min(92vw, 1100px);
    margin: clamp(2.4rem, 5vw, 6rem) auto 0; /* further down */
}

.folio-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-align: right;
    font-size: 14px;
}



.folio-link {
    text-decoration: none;
    color: var(--text-color);
    transition: opacity 0.3s;
}

.folio-link:hover {
    opacity: 0.7;
}

/* Sezione Eroe */
.hero-section {
    text-align: center;
    height: 75vh; /* exact viewport height incl. mobile UI */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* vertically center content in all viewports */
    padding: 0 15px; /* remove vertical padding to avoid overflow */
    box-sizing: border-box;
    position: relative;
    overflow: visible; /* allow nav to extend below the hero */
}

/* Top-left badge and top controls positions inside hero */
.hero-section .hero-topbar {
    position: absolute;
    top: 16px;
    left: 24px;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 12px;
}

.hero-section .disney-badge {
    display: inline-block;
    font-family: var(--font-body);
    font-weight: 700;
    text-transform: lowercase;
    letter-spacing: 0.5px;
    padding: 6px 10px;
    border: 2px solid currentColor;
    border-radius: 999px;
    line-height: 1;
}

/* Horizontal nav under the hero titles */
.hero-section .hero-nav {
  position: absolute;
  left: 0;
  right: 0;
  transform: none;
  width: 100%;
  bottom: -96px; /* much further below the bottom edge */
  margin-top: 0;
  z-index: 3; /* keep above following content for clickability */
  box-sizing: border-box; /* include padding in width to avoid horizontal overflow */
  overflow-x: clip; /* prevent sub-pixel overflow from inner content */
}
/* Prevent the overlaid hero-nav from blocking pointer events on sections below.
   Re-enable pointer events only on the interactive links inside. */
.hero-section .hero-nav { pointer-events: none; }
.hero-section .hero-nav a { pointer-events: auto; }
@media (min-width: 992px) {
  /* Keep hero content in place and give space for the nav */
  .hero-section { padding-bottom: clamp(100px, 14vh, 220px); }
  .hero-section .hero-nav {
    position: static; /* place nav in normal flow under the title */
    bottom: auto;
    left: auto;
    right: auto;
    transform: none;
    width: 100%;
    max-width: 100%;
    margin-top: clamp(72px, 9vh, 160px);
    padding-left: clamp(12px, 4vw, 40px);
    padding-right: clamp(12px, 4vw, 40px);
    box-sizing: border-box; /* keep padding inside 100vw */
    pointer-events: auto; /* ensure links are clickable */
    z-index: 5;
  }
}
.hero-section .hero-nav ul {
    list-style: none;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: clamp(88px, 30vw, 200px); /* much larger spacing */
    flex-wrap: nowrap; /* keep on one line */
    padding: 0;
    margin: 0;
}
.hero-section .hero-nav a {
    color: inherit;
    text-decoration: none;
    font-size: clamp(0.9rem, 1.1vw, 1.1rem); /* smaller to fit more spacing */
    opacity: 0.9;
    transition: color 360ms ease-in-out, border-color 360ms ease-in-out, background-color 360ms ease-in-out,
                opacity 260ms ease-in-out, transform 260ms ease-in-out;
    letter-spacing: 0.03em;
    padding: 8px 14px; /* slightly slimmer pill */
    border-width: 2px;
}
.hero-section .hero-nav a:hover,
.hero-section .hero-nav a:focus-visible,
.hero-section .hero-nav a[aria-current="page"] {
    opacity: 1;
    transform: translateY(-1px);
    color: #fff;
    border-color: #fff;
}
@media (max-width: 576px) {
  .hero-section .hero-nav ul { gap: 18px; flex-wrap: wrap; }
}

/* Scroll to Top button behavior */
#scrollTopBtn {
  /* Inline position is already set in HTML; here we control visibility and look */
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 320ms ease, transform 320ms ease, background-color 220ms ease, color 220ms ease;
  background: #222;
  color: #fff;
  z-index: 100000; /* ensure above overlays */
  border: 1px solid rgba(255,255,255,0.18);
  /* Ensure not clipped by mobile safe areas; override inline with !important */
  bottom: calc(24px + env(safe-area-inset-bottom)) !important;
  right: calc(24px + env(safe-area-inset-right)) !important;
}
#scrollTopBtn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
#scrollTopBtn:hover { background: #000; }
body.dark-mode #scrollTopBtn { background: #fff; color: #111; }
body.dark-mode #scrollTopBtn:hover { background: #e9e9e9; }

/* Legacy hero-name block removed; sizes handled by variable scale */

/* =========================================================
   Navigation
   ========================================================= */
.main-nav {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    transform: translateY(-50%);
    z-index: 1000;
    padding: 20px 0;
    background-color: transparent;
    box-shadow: none;
}

.main-nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    padding: 0;
    margin: 0;
}

.nav-item {
    position: relative;
    overflow: visible;
    text-decoration: none;
    color: var(--text-color);
    font-size: 1rem;
    padding: 8px 15px;
    border-radius: 4px;
    transition: all 0.3s ease, transform 0.7s ease-in-out, opacity 0.6s ease-in-out;
    will-change: transform, color, background-color, opacity;
    opacity: 1;
}

.nav-item:hover {
    transform: scale(1.15);
    color: #fff;
    background-color: #1a1a1a;
    opacity: 0.85;
}

/* Ensure hovering the LI also triggers the same smooth effect */
.main-nav ul li:hover .nav-item {
    transform: scale(1.15);
    color: #fff;
    background-color: #1a1a1a;
    opacity: 0.85;
}

.main-nav ul li:hover .nav-animated {
    display: inline-block;
    animation: letterGrow 0.6s forwards;
}

.nav-item .nav-animated {
    display: inline-block;
    transition: transform 0.4s cubic-bezier(.77,0,.18,1), color 0.3s;
    transform: scale(1);
}

.nav-item:hover .nav-animated {
    animation: letterGrow 0.6s forwards;
}

@keyframes letterGrow {
    0% { transform: scale(1); }
    60% { transform: scale(1.4); }
    100% { transform: scale(1.15); }
}

.nav-number {
    font-size: 0.8em;
    margin-right: 5px;
}

/* =========================================================
   Footer
   ========================================================= */
/* Projects header (title + helper text) — restored responsive sizing */
.projects-header { display: flex; justify-content: flex-start; align-items: flex-end; flex-wrap: wrap; column-gap: clamp(8px, 2vw, 20px); row-gap: 6px; }
.projects-header .main-title {
  margin: 0;
  line-height: .85;
  font-size: clamp(3rem, 18vw, 20rem);
  text-align: left;
  align-self: flex-start;
}
@media (min-width: 992px) {
  .projects-header .main-title { font-size: clamp(8rem, 15vw, 20rem); }
}
.footer-bottom {
    display: flex;
    justify-content: center;
    flex-direction: column;
    font-size: 20px;
    text-align: center;
    margin-top: auto; /* stick to bottom when content is short */
}

.social-icons {
    display: flex;
    gap: 2rem;
}

/* =========================================================
   Loader overlay
   ========================================================= */
#loader {
    position: fixed;
    z-index: 9999;
    inset: 0;
    pointer-events: none; /* never block interactions; body.loading handles blocking */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: none;
    transition: all 1s cubic-bezier(.77,0,.18,1);
}

/* Loader children default state (full-screen) */
#loader .loader-logo { display: inline-flex; }
#loader .loader-badge { display: none; }

#loader.loader-bottom {
    height: 100px;
    top: 16px;
    left: 24px;
    right: auto;
    width: auto;
    background: none;
    align-items: flex-start;
    justify-content: center;
    transform: none;
    padding-bottom: 0;
    pointer-events: none;
}

/* Minimized state: show small badge, hide big logo */
#loader.loader-bottom .loader-logo { display: none; }
#loader.loader-bottom .loader-badge {
    display: inline-flex;
    align-items: flex-start;
    gap: 8px;
    font-family: var(--font-body);
    font-size: 12px;
    line-height: 1.2;
    color: var(--text-color);
    opacity: 0.9;
    background: transparent;
    padding: 0;
    border: 0;
}
#loader.loader-bottom .loader-badge::before {
    content: "✳"; /* small star-like glyph */
    display: inline-block;
    font-size: 14px;
    line-height: 1;
    transform: translateY(1px);
    opacity: 0.9;
}

.loader-text {
    font-family: var(--font-body);
    font-size: 2rem;
    color: var(--text-color);
    padding: 0.5em 1.5em;
    border-radius: 8px;
    transition: box-shadow 0.5s;
}

/* Fade-in animazione per il contenuto */
body:not(.loading) .header,
body:not(.loading) .main-content,
body:not(.loading) .footer-bottom {
    animation: fadeIn 1.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(30px);}
    to { opacity: 1; transform: translateY(0);}
}

/* Nascondi contenuto finché loading */
body.loading .header,
body.loading .main-content,
body.loading .footer-bottom {
    opacity: 0;
    pointer-events: none;
}

a,
button,
.nav-item,
.folio-link {
    cursor: url('./img/mickey-cursor.png'), pointer;
}

#loading-cursor {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: 10001;
    font-family: var(--font-body);
    font-size: 1.2rem;
    color: #fff;
    background: #1a1a1a;
    padding: 0.3em 1em;
    border-radius: 6px;
    border: 1px solid #555;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: opacity 0.2s;
}

body.loading #loading-cursor {
    display: block;
    opacity: 1;
}

/* =========================================================
   Dark Mode
   ========================================================= */
body.dark-mode {
    --bg-color: #181818;
    --text-color: #f7f7f7;
    --accent-color: #f7f7f7;
    background-color: var(--bg-color);
    color: var(--text-color);
}

/* Dark mode: scuri e separati tra loro */
body.dark-mode .main-content section {
    background: #121212;
    position: relative;
    border-top: 1px solid rgba(255,255,255,0.06);
}
body.dark-mode .main-content section:nth-of-type(even) {
    background: #161616;
}
/* Divisore superiore sottile con gradiente per evidenziare la separazione */
body.dark-mode .main-content section::before {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 1px;
    background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.28), rgba(255,255,255,0));
    pointer-events: none;
}

/* Contenitori non <section> (es. works) */
body.dark-mode .works-content {
    background: #121212;
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* Light mode: chiaro con separatori evidenti ma delicati */
body:not(.dark-mode) .main-content section {
    background: #f7f6ef; /* chiaro caldo tenue */
    position: relative;
    border-top: 1px solid rgba(0,0,0,0.06);
}
body:not(.dark-mode) .main-content section:nth-of-type(even) {
    background: #ffffff; /* alternanza a pieno bianco */
}
body:not(.dark-mode) .main-content section::before {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 1px;
    background: linear-gradient(90deg, rgba(0,0,0,0), rgba(0,0,0,0.25), rgba(0,0,0,0));
    pointer-events: none;
}

/* Contenitori non <section> (es. works) in light mode */
body:not(.dark-mode) .works-content {
    background: #ffffff;
    border-top: 1px solid rgba(0,0,0,0.06);
    position: relative;
}
body:not(.dark-mode) .works-content::before {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 1px;
    background: linear-gradient(90deg, rgba(0,0,0,0), rgba(0,0,0,0.25), rgba(0,0,0,0));
    pointer-events: none;
}

body.dark-mode .header,
body.dark-mode .main-content,
body.dark-mode .footer-bottom,
body.dark-mode .logo-container,
body.dark-mode .site-title,
body.dark-mode .main-title,
body.dark-mode .subtitle,
body.dark-mode .nav-item,
body.dark-mode .hero-name,
body.dark-mode .social-icon{
    color: var(--text-color);
}

body.dark-mode .nav-item:hover {
    background-color: var(--accent-color);
    color: var(--bg-color);
}

body.dark-mode .main-nav ul li:hover .nav-item {
    background-color: var(--accent-color);
    color: var(--bg-color);
}

body.dark-mode .loader-text {
    color: var(--text-color);
    border-color: var(--text-color);
}

body.dark-mode #loading-cursor {
    background: var(--accent-color);
    color: var(--bg-color);
    border-color: var(--bg-color);
}

/* (SVG icon rules removed previously) */

/* Social icons */
.logo-container .social-icon {
    color: black;
    transition: color 0.3s;
}
.social-icon {
    position: relative;
    display: inline-block;
    padding-bottom:1px; /* Per lasciare spazio al bordo */
}

.social-icon::before {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: #555;
    transition: width 0.5s ease, left 0.5s ease;
}

.social-icon:hover::before {
    width: 100%; /* Espande la larghezza */
    left: 0; /* Muove il bordo verso il lato sinistro */
}

/* Spin orizzontale + leggero zoom sull'icona */
.social-icon i,
.social-icon svg {
    display: inline-block;
    transform-origin: center center;
    transform: translateZ(0);
    transition: transform 520ms cubic-bezier(.22,1,.36,1);
    backface-visibility: hidden; /* evita flicker durante rotateX */
    will-change: transform;
}

.social-icon:hover i,
.social-icon:hover svg {
    transform: perspective(600px) rotateX(360deg) scale(1.12);
}

@media (prefers-reduced-motion: reduce) {
  .social-icon i,
  .social-icon svg { transition: none; }
  .social-icon:hover i,
  .social-icon:hover svg { transform: scale(1.06); }
}

/* =========================================================
   Reveal on Scroll
   ========================================================= */
.reveal {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
    transition: opacity 520ms cubic-bezier(.22,1,.36,1), transform 620ms cubic-bezier(.22,1,.36,1);
    will-change: opacity, transform;
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Reduced motion: show content immediately */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
}

/* Dark mode: le icone diventano bianche */
body.dark-mode .social-icon {
    color: white !important;
}

body.dark-mode .social-icon i {
    color: #fff !important;
}

/* Smooth transitions for common elements */
body,
.header,
.main-content,
.footer-bottom,
.logo-container,
.site-title,
.main-title,
.subtitle,
.nav-item,
.nav-number,
.hero-name,
.logo-container .social-icon,
.logo-container .social-icon i {
    transition: color 0.5s cubic-bezier(.77,0,.18,1), background-color 0.5s cubic-bezier(.77,0,.18,1);
}

#scrollTopBtn {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s cubic-bezier(.77,0,.18,1);
}

#scrollTopBtn.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Hover states */
.folio-link:hover,
button:hover {
    color: #fff;
    background: #1a1a1a;
    opacity: 0.85;
    transition:
        color 0.4s ease-in-out,
        background 0.4s ease-in-out,
        opacity 0.7s cubic-bezier(.77,0,.18,1);
}

body.dark-mode .folio-link:hover,
body.dark-mode button:hover {
    color: #181818;
    background: #fff;
}

/* =========================================================
   Hamburger Menu
   ========================================================= */
.hamburger-menu {
    position: fixed;
    top: 24px;
    right: 24px; /* posizione originale a destra */
    width: 48px;  /* dimensione originale */
    height: 48px; /* dimensione originale */
    z-index: 1000003; /* above loader after fade and above language toggle */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    /* Stilizzato come il toggle lingua (btn-rect) */
    border-radius: 8px;
    background: #f4f4f4;
    border: 1px solid rgba(0,0,0,0.12);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    /* Default bar colors (assume light background unless classes applied) */
    --bar-color: #111; /* come il testo del toggle lingua */
    --bar-stroke: transparent;
    color: var(--bar-color);
    opacity: 0; /* hidden until allowed */
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 260ms ease, transform 260ms ease;
}

.hamburger-menu span {
    display: block;
    width: 28px;
    height: 2px;
    margin: 0; /* managed via absolute positioning */
    background: var(--bar-color);
    border: 1.5px solid var(--bar-stroke);
    border-radius: 2px;
    box-sizing: border-box; /* include border in width so X arms match */
    position: absolute;
    left: 50%;
    transition: top 220ms ease, transform 260ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease-out, width 220ms cubic-bezier(0.22, 1, 0.36, 1), background-color 150ms linear, border-color 150ms linear;
    transform-origin: center center;
    transform: translateX(-50%);
    will-change: top, transform, opacity, width;
    backface-visibility: hidden;
}

.span-1 { top: calc(50% - 12px); } /* sposta leggermente più in alto in stato chiuso */
.span-2 { top: 48%; }             /* alza di poco la barra centrale */
.span-3 { top: calc(50% + 8px); } /* riduce il gap e alza il gruppo visivamente */

/* Remove hard-coded dark-mode bar override; we drive via currentColor */

/* Deprecated: .on-dark/.on-light removed; hamburger follows theme only */

/* Accessibility focus */
.hamburger-menu:focus-visible { outline: 2px solid #ffcc00; outline-offset: 2px; }

/* Hamburger to X transformation (fluid center morph) */
.hamburger-menu.open { position: relative; }
.hamburger-menu.open span {
  top: 50%;
  width: 28px !important; /* larghezza originale per la X */
  transform-origin: center center; /* rotate around center */
  left: 50%; /* centratura orizzontale della X */
}
.hamburger-menu.open .span-1,
.hamburger-menu.open .span-3 {
  top: 50% !important;
  left: 50% !important;
  margin: 0 !important;
}
.hamburger-menu.open { z-index: 100003; }
.hamburger-menu.open .span-1 {
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) rotate(45deg) !important;
}
.hamburger-menu.open .span-2 {
  top: 50% !important;
  left: 50% !important;
  opacity: 0 !important;
  transform: translate(-50%, -50%) scaleX(0.2) !important;
  transition: top 220ms ease, opacity 220ms ease-out 60ms, transform 260ms cubic-bezier(0.22, 1, 0.36, 1), width 220ms cubic-bezier(0.22, 1, 0.36, 1), background-color 150ms linear, border-color 150ms linear;
}
.hamburger-menu.open .span-3 {
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) rotate(-45deg) !important;
}

/* Keep bars black when menu is open (X), regardless of background */
/* Keep bar contrast consistent when open */
.hamburger-menu.open { color: var(--bar-color); }
.hamburger-menu.open span { background: var(--bar-color) !important; border-color: var(--bar-stroke) !important; }
.hamburger-menu.open.on-dark span,
.hamburger-menu.open.on-light span { background: var(--bar-color) !important; border-color: var(--bar-stroke) !important; }

body.dark-mode .hamburger-menu span { background: #000 !important; border-color: transparent !important; }
body.dark-mode .hamburger-menu.open span { background: #000 !important; border: 0 !important; }
body.dark-mode .hamburger-menu { border-radius: 8px !important; }

/* When menu is open, the side panel background is light; force black X for contrast */
.hamburger-menu.open span { background: #000 !important; border-color: transparent !important; }

/* Make it interactable/visible when allowed or when menu is open */
.hamburger-menu.visible,
.hamburger-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Hide hero-nav on tablet/phone; always show hamburger */
@media (max-width: 768px) {
  .hero-section .hero-nav { display: none !important; }
  .hamburger-menu {
    display: flex;
    opacity: 1;            /* ensure visible on small devices */
    pointer-events: auto;  /* ensure clickable on small devices */
    transform: translateY(0);
  }
}

/* Contrast inversion in dark mode: chip becomes light, bars dark */
body.dark-mode .hamburger-menu {
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(0,0,0,0.12);
  box-shadow: 0 2px 8px rgba(0,0,0,0.22);
  --bar-color: #000;
  --bar-stroke: transparent;
}

/* Hover and focus states for chip */
@media (hover: hover) and (pointer: fine) {
  .hamburger-menu:hover { filter: brightness(1.05); }
}
.hamburger-menu:focus-visible { outline: 2px solid #ffcc00; outline-offset: 2px; }

/* Also ensure visibility on devices up to 992px (many mobile/tablet widths) */
@media (max-width: 992px) {
  .hero-section .hero-nav { display: none !important; }
  .hamburger-menu {
    display: flex;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
}

/* Appear-from-left hover animation (desktop only, not when open) */
@keyframes hamburgerAppear {
  0%   { transform: translateX(-50%) scaleX(0); opacity: 0; }
  60%  { opacity: 1; }
  100% { transform: translateX(-50%) scaleX(1); opacity: 1; }
}

@media (hover: hover) and (pointer: fine) {
  .hamburger-menu:not(.open):hover .span-1 { animation: hamburgerAppear 180ms ease-out 0ms both; }
  .hamburger-menu:not(.open):hover .span-2 { animation: hamburgerAppear 180ms ease-out 90ms both; }
  .hamburger-menu:not(.open):hover .span-3 { animation: hamburgerAppear 180ms ease-out 180ms both; }
  .hamburger-menu span { will-change: transform, opacity; }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .hamburger-menu span { animation: none !important; transition: background-color 0.2s, border-color 0.2s; }
}


/* =========================================================
   Final safeguards (override any stray rules)
   ========================================================= */
/* Guarantee maximum contrast of the X above the light side panel */
body .hamburger-menu.open span {
  background: #000 !important;
  border-color: transparent !important;
  box-shadow: 0 0 0 0.5px rgba(0,0,0,0.65);
}

/* Mobile Navigation (scoped to #mainNav so index main-nav stays visible) */
#mainNav {
    position: fixed;
    top: 0;
    right: 0;
    width: 260px;
    height: 100vh;
    background: rgba(247,247,247,0.97);
    box-shadow: -2px 0 12px rgba(30,30,30,0.08);
    z-index: 100002; /* above page content and equal/above hamburger when open */
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(.77,0,.18,1), opacity 0.4s cubic-bezier(.77,0,.18,1);
    padding-top: 80px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    pointer-events: none;
    opacity: 0;
}

#mainNav.open {
    transform: translateX(0);
    pointer-events: auto;
    opacity: 1;
}

#mainNav ul {
    list-style: none;
    flex-direction: column;
    gap: 200px; /* much more vertical spacing between items */
    padding-left: 32px;
}

#mainNav a.nav-item {
    display: block;
    font-size: clamp(1.05rem, 1.6vw, 1.4rem); /* smaller than before */
    font-weight: 500;
    letter-spacing: 0.02em;
    padding: 6px 2px;
    text-decoration: none;
}

#mainNav a.nav-item:hover,
#mainNav a.nav-item:focus-visible {
  text-decoration: none;
}

body.dark-mode #mainNav a.nav-item {
    color: var(--text-color);
}

body.dark-mode #mainNav {
    background: rgba(24,24,24,0.97);
}

/* ========== Stacked Scrolling (sticky sections) ========== */
.stack-section {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1200px) { /* sizes unified via variables */ }
  /* Project detail content blocks laid out horizontally across the wide slide */
  .split-details {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(320px, 520px);
    gap: clamp(16px, 2.5vw, 32px);
    margin-top: 24px;
    align-items: start;
  }
  .detail-block {
    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 12px;
    padding: clamp(14px, 2vw, 20px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.06);
  }
  .detail-block h4 {
    margin: 0 0 8px;
    font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  }
  .detail-block p { margin: 0; color: #333; line-height: 1.55; }
  .detail-list { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
  .detail-chip { display: inline-block; padding: 6px 10px; border-radius: 999px; background: #f1f1f1; font-size: 0.9rem; }
  /* Media block */
  .detail-block.media { padding: 0; overflow: hidden; }
  .detail-block.media figure { margin: 0; }
  .detail-block.media img { display: block; width: 100%; height: clamp(180px, 28vw, 380px); object-fit: cover; }
  .detail-block.media figcaption { padding: 10px 14px; font-size: 0.95rem; color: #555; background: #fff; }

  /* === Typography Spec block (reference-style layout) === */
  .detail-block.typo-spec { padding: clamp(20px, 3.2vw, 32px); }
  .typo-spec .typo-head {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: clamp(16px, 3vw, 36px);
    align-items: start;
  }
  .typo-spec .title-xl {
    font-weight: 800;
    font-size: clamp(1.6rem, 4.8vw, 3rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0 0 12px;
  }
  .hl-underline { 
    background: linear-gradient(transparent calc(100% - 8px), rgba(52,118,246,0.22) 0) no-repeat;
    background-size: 100% 100%;
    padding: 0 3px;
  }
  .typo-spec .cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(14px, 2.4vw, 28px);
  }
  .typo-spec .chevron-art {
    min-height: clamp(120px, 22vw, 260px);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 300'%3E%3Cg fill='none' stroke='%239bb8ff' stroke-opacity='0.35' stroke-width='18'%3E%3Cpath d='M60 30 L180 150 L60 270'/%3E%3Cpath d='M220 30 L340 150 L220 270'/%3E%3Cpath d='M380 30 L500 150 L380 270'/%3E%3C/g%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center right;
    filter: saturate(0.9);
    opacity: 0.8;
  }
  .typo-spec .muted { color: #555; }
  .typo-spec .font-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 24px;
    margin-top: clamp(12px, 2vw, 18px);
  }
  .typo-spec .font-item { font-weight: 700; }
  .typo-spec .font-item .chip {
    display: inline-block;
    background: #e8f0ff;
    color: #1f5fe0;
    padding: 6px 10px;
    border-radius: 8px;
    font-weight: 800;
    letter-spacing: 0.02em;
  }
  .typo-spec a.mark {
    color: #0b57d0;
    background: linear-gradient(transparent calc(100% - 10px), rgba(52,118,246,0.25) 0) no-repeat;
    background-size: 100% 100%;
    text-decoration: none;
    padding: 0 4px;
    border-radius: 2px;
  }
  .detail-block.span-2 { grid-column: span 2; }
  .detail-block.span-3 { grid-column: span 3; }


/* Tablet and down */
@media (max-width: 992px) {
  /* Hide hero-nav on tablet/phone; show hamburger */
  .hero-section .hero-nav { display: none !important; }
  .hamburger-menu { display: flex; }
  .header nav { display: none; }
  /* Allow wrap for large title */
  .hero-name { white-space: normal; }
  .social-icon { font-size: 1.2rem; }
}

/* Phones */
@media (max-width: 576px) {
  .subtitle { font-size: clamp(0.8rem, 2vw, 1rem); }
  .hamburger-menu { top: 20px; right: 20px; width: 40px; height: 40px; }
  .hamburger-menu span { width: 24px; }
  #mainNav { width: 100%; }
}

/* =========================================================
   Works Page
   ========================================================= */
.main-content {
    min-height: 100vh;
    padding-top: 80px; /* Spazio per la navbar fissa */
    padding: 80px 0 40px;
}

.works-content {
    min-height: 100vh;
    padding: 80px 0 40px;
}

.works-heading {
    font-family: var(--font-heading);
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 400;
    margin-bottom: 60px;
    text-align: center;
}

.project-list {
    padding: 40px 0;
}

.project-item {
    display: block;
    padding: 40px 30px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    height: 100%;
}

.project-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border-color: #000;
    color: inherit;
    text-decoration: none;
}

.project-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 10px;
    color: #000;
}

.project-category {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
}

/* Dark mode styles for works page */
body.dark-mode .project-item {
    border-color: #444;
    background: rgba(255,255,255,0.05);
}

body.dark-mode .project-item:hover {
    border-color: #fff;
    background: rgba(255,255,255,0.1);
}

body.dark-mode .project-title {
    color: #fff;
}

body.dark-mode .project-category {
    color: #ccc;
}

/* Works page responsive design */
@media (max-width: 768px) {
    .works-content {
        padding: 60px 0 30px;
    }
    
    .works-heading {
        margin-bottom: 40px;
    }
    
    .project-item {
        padding: 30px 20px;
        margin-bottom: 20px;
    }
    
    .project-title {
        font-size: 1.3rem;
    }
    
    .project-category {
        font-size: 0.85rem;
    }
}

@media (max-width: 576px) {
    .works-content {
        padding: 50px 0 20px;
    }
    
    .project-item {
        padding: 25px 15px;
    }
    
    .project-title {
        font-size: 1.2rem;
    }
}

/* =========================================================
   Projects Section (Horizontal Draggable Timeline)
   ========================================================= */
.projects-section {
  padding: clamp(48px, 7vw, 90px) 0;
}

.projects-header {
  margin: 0 16px clamp(16px, 3vw, 28px);
}

.projects-title {
  font-family: var(--font-heading);
  font-size: clamp(2.6rem, 7.5vw, 5.2rem); /* restored larger size */
  margin: 0;
}

.projects-subtitle {
  margin: 0;
  opacity: 0.7;
  font-size: 0.95rem;
}

.projects-scroller {
  display: flex;
  align-items: stretch;
  gap: clamp(14px, 2vw, 24px);
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 16px 6px;
  /* disable snap to avoid stutter during manual drag */
  scroll-snap-type: none;
  -webkit-overflow-scrolling: touch;
  /* hide scrollbar but preserve scrollability for JS */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge legacy */
  cursor: grab;
  user-select: none; /* avoid text selection while dragging */
  /* Allow vertical page scroll; we handle horizontal drag via JS */
  touch-action: pan-y; 
  overscroll-behavior-x: contain; /* avoid parent scroll interference */
  position: relative; /* ensure above any overlapping elements */
  z-index: 2;
}
.projects-scroller.dragging { cursor: grabbing; }
.projects-scroller.dragging .topic-info { pointer-events: none; }

/* each year block acts like a card */
.project-year-block {
  flex: 0 0 auto;
  min-width: clamp(240px, 48vw, 420px);
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 14px;
  padding: 18px 16px;
  background: #fff;
  scroll-snap-align: start;
  transition: transform 260ms cubic-bezier(.22,1,.36,1), box-shadow 260ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .project-year-block:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,0.08); }
}

.year-label {
  font-weight: 600;
  letter-spacing: 0.06em;
  font-size: 0.95rem;
}
.year-meta { font-size: 0.85rem; color: #555; margin-bottom: 10px; }

.thumbs { display: flex; gap: 10px; }
.thumbs .thumb {
  width: 100px;
  height: 70px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.08);
  background: #f4f4f4;
  -webkit-user-drag: none; /* prevent image drag ghost */
  user-select: none;
  pointer-events: none; /* improve drag hit area */
}

@media (min-width: 992px) {
  .project-year-block { min-width: clamp(340px, 32vw, 520px); padding: 22px 18px; }
  .thumbs .thumb { width: 120px; height: 84px; }
}

/* hide scrollbar in webkit/blink */
.projects-scroller::-webkit-scrollbar { display: none; }

/* Dark mode adjustments */
body.dark-mode .project-year-block {
  background: #141414;
  border-color: rgba(255,255,255,0.14);
}
body.dark-mode .year-meta { color: #c9c9c9; }
body.dark-mode .thumbs .thumb { border-color: rgba(255,255,255,0.12); background: #1d1d1d; }
body.dark-mode .projects-scroller::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); }

/* Topic-based blocks: larger visuals */
.project-topic-block {
  position: relative;
  flex: 0 0 auto;
  width: clamp(280px, 66vw, 720px);
  border-radius: 16px;
  overflow: hidden;
  background: #f6f6f6;
  border: 1px solid rgba(0,0,0,0.08);
}
.project-topic-block .topic-media { position: relative; }
.project-topic-block .topic-image {
  display: block;
  width: 100%;
  height: clamp(180px, 44vw, 420px);
  object-fit: cover;
  transform: translateZ(0);
  transition: transform 0.35s ease;
  -webkit-user-drag: none; /* avoid native image drag ghost */
  user-select: none;
}
.project-topic-block:hover .topic-image {
  transform: scale(1.03);
}
.project-topic-block .topic-info {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  /* extra right padding to avoid overlap with topic-download button (fluid) */
  padding: 12px calc(clamp(28px, 5.2vw, 40px) + clamp(8px, 1.8vw, 12px) + 12px) 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.topic-title { margin: 0; font-size: clamp(1.05rem, 2.2vw, 1.6rem); font-weight: 700; }
.topic-meta { margin: 4px 0 0; font-size: clamp(0.8rem, 1.6vw, 0.95rem); color: #555; }

/* Download button on project cards */
.projects-scroller .project-topic-block .topic-download {
  position: absolute;
  top: clamp(8px, 1.8vw, 12px);
  right: clamp(8px, 1.8vw, 12px);
  z-index: 5;
  width: clamp(28px, 5.2vw, 40px);
  height: clamp(28px, 5.2vw, 40px);
  border-radius: 999px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(0,0,0,0.12);
  color: #111;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.projects-scroller .project-topic-block .topic-download svg { width: 60%; height: 60%; }
.projects-scroller .project-topic-block .topic-download:hover,
.projects-scroller .project-topic-block .topic-download:focus-visible {
  background: #111;
  color: #fff;
  transform: translateY(-1px);
  outline: none;
}
body.dark-mode .projects-scroller .project-topic-block .topic-download {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.18);
  color: #fff;
}
body.dark-mode .projects-scroller .project-topic-block .topic-download:hover,
body.dark-mode .projects-scroller .project-topic-block .topic-download:focus-visible {
  background: #fff;
  color: #111;
}

@media (min-width: 992px) {
  .project-topic-block { width: clamp(420px, 54vw, 860px); }
  .project-topic-block .topic-image { height: clamp(280px, 36vw, 520px); }
}

/* Dark mode for topic blocks */
body.dark-mode .project-topic-block { background: #111; border-color: rgba(255,255,255,0.12); }
body.dark-mode .project-topic-block .topic-info {
  background: rgba(20,20,20,0.75);
  color: #eee;
}
body.dark-mode .topic-meta { color: #c9c9c9; }

/* Push Projects section further down from the hero */
.projects-section {
  margin-top: clamp(56px, 12vh, 220px);
}
@media (min-width: 992px) {
  .projects-section { margin-top: clamp(120px, 18vh, 340px); }
}

/* Project Detail Overlay */
.project-detail {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden; /* avoid overlay content causing page scrollbars */
  pointer-events: none; /* do not block page when closed */
  visibility: hidden; /* ensure it never captures events or hover when closed */
  background: rgba(255, 255, 255, 0.98); /* Colore di sfondo bianco con trasparenza */
  box-shadow: 0 -6px 30px rgba(0,0,0,0.2);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  opacity: 0;
  transition: opacity 520ms cubic-bezier(.22,1,.36,1);
  display: flex;
  flex-direction: column;
  min-height: 0; /* allow flex children to shrink and scroll */
}
.project-detail.open {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}
.project-detail-header,
.project-detail-scroller {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 560ms cubic-bezier(.22,1,.36,1),
              transform 560ms cubic-bezier(.22,1,.36,1);
}
.project-detail.open .project-detail-header,
.project-detail.open .project-detail-scroller {
  opacity: 1;
  transform: translateY(0);
}
.project-detail-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(16px, 2.5vw, 28px) clamp(16px, 3vw, 36px);
}
.project-detail-title { margin: 0; font-size: clamp(1.6rem, 4.6vw, 3rem); font-weight: 800; }
.project-detail-subtitle { margin: 0; color: #555; font-size: clamp(0.9rem, 1.8vw, 1.05rem); }

.project-detail-close {
  position: absolute;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  color: #111;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  z-index: 3;
  box-shadow: 0 6px 24px rgba(0,0,0,0.15);
  backdrop-filter: saturate(140%) blur(6px);
  transition: box-shadow 240ms ease;
}

.project-detail-close:hover { box-shadow: 0 10px 30px rgba(0,0,0,0.22); }

.project-detail-scroller {
  /* normalized to container; legacy horizontal styles removed */
  display: block;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0 clamp(20px, 3vw, 36px);
  scroll-snap-type: none;
}
.project-detail-scroller::-webkit-scrollbar { display: none; }

.detail-slide { /* container-centered version (defined above); keep here to override legacy */
  flex: initial;
  min-width: auto;
  border: 0;
  background: transparent;
  display: block;
}

  /* ==== Split fullscreen variant (left copy, right image) ==== */
  .detail-slide.split {
    /* Reference image: perfect 50/50 split */
    grid-template-columns: 1fr 1fr;
    height: calc(100vh - 120px); /* viewport minus header area */
    background: transparent;
    border: none;
    border-radius: 0;
  }
  .detail-slide.split .split-left,
  .detail-slide.split .split-right { position: relative; }

  .detail-slide.split .split-left {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(20px, 5vw, 64px);
    background: #e6e6e6;
  }
  .detail-slide.split .split-right {
    overflow: hidden;
    width: auto; /* equal split */
  }
  .detail-slide.split .split-right img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  /* Download button (top-right of left hero panel) */
  .detail-slide.split .download-btn {
    position: absolute;
    top: clamp(12px, 4vh, 28px);
    right: clamp(12px, 4vw, 28px);
    z-index: 10;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: clamp(32px, 4.8vw, 44px);
    height: clamp(32px, 4.8vw, 44px);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    color: #111;
    border: 1px solid rgba(0,0,0,0.12);
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    text-decoration: none;
    transition: background .2s ease, color .2s ease, transform .2s ease, border-color .2s ease;
    backdrop-filter: saturate(140%) blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }
  .detail-slide.split .download-btn svg { width: 60%; height: 60%; }
  .detail-slide.split .download-btn:hover {
    background: #111;
    color: #fff;
    border-color: #111;
    transform: translateY(-1px);
  }
  .detail-slide.split .download-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
  }

  /* Dark mode for download button */
  body.dark-mode .detail-slide.split .download-btn {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border-color: rgba(255,255,255,0.2);
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
  }
  body.dark-mode .detail-slide.split .download-btn:hover {
    background: #fff;
    color: #111;
    border-color: #fff;
  }

  /* Decorative dot on the left panel */
  .split-dot {
    position: absolute;
    left: clamp(20px, 4vw, 60px);
    top: clamp(20px, 5vh, 60px);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #111;
  }

  .split-copy { max-width: 720px; }
  .hero .hero-section {
    position: relative;
    padding: 140px 5% 80px;
    text-align: left;
    overflow: visible;
    /* Clip any sub-pixel horizontal overflow within the hero context */
    overflow-x: hidden;
  }
  .hero .hero-headline {
    margin: 0 auto;
    max-width: 900px;
    text-align: center;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.15;
    font-size: clamp(2rem, 3.8vw, 3rem);
    color: #111;
  }
  .split-title {
    margin: 0 0 10px;
    font-family: var(--font-heading);
    font-size: clamp(2rem, 6vw, 4.2rem);
    letter-spacing: 0.04em;
  }
  .split-sub {
    margin: 0;
    font-size: clamp(1rem, 2vw, 1.2rem);
    color: #444;
    line-height: 1.55;
  }

  @media (max-width: 991.98px) {
    .detail-slide.split {
      grid-template-columns: 1fr;
      grid-template-rows: 52vh 1fr; /* image then copy */
      height: calc(100vh - 96px);
    }
    .detail-slide.split .split-right { order: -1; min-height: 52vh; }
    .detail-slide.split .split-left { padding: clamp(16px, 5vw, 36px); }
    /* On mobile, show detail blocks vertically for readability */
    .split-details {
      grid-auto-flow: row;
      grid-auto-rows: auto;
      grid-template-columns: 1fr;
    }
    .typo-spec .typo-head { grid-template-columns: 1fr; }
    .typo-spec .chevron-art { min-height: 120px; background-position: center; }
    .typo-spec .cols, .typo-spec .font-grid { grid-template-columns: 1fr; }
    .hero .hero-headline { font-size: clamp(1.6rem, 6vw, 2.2rem); padding: 0 6px; }
  }

  /* Dark mode adjustments for split */
  body.dark-mode .detail-slide.split .split-left { background: #121212; }
  body.dark-mode .detail-slide.split .split-left.hero { background: #161616; }
  body.dark-mode .hero .hero-headline { color: #eee; }
  body.dark-mode .hero .nav-item .label { color: #eee; }
  body.dark-mode .split-dot { background: #fff; }
  body.dark-mode .split-sub { color: #cfcfcf; }

/* Dark mode for detail overlay */
body.dark-mode .project-detail { background: rgba(8,8,8,0.98); color: #eee; }
body.dark-mode .project-detail-close { background: #151515; color: #eee; border-color: rgba(255,255,255,0.12); }
body.dark-mode .detail-slide { background: #121212; border-color: rgba(255,255,255,0.12); }
body.dark-mode .detail-slide .slide-content p { color: #cfcfcf; }
body.dark-mode .detail-block { background: #151515; border-color: rgba(255,255,255,0.12); box-shadow: 0 4px 14px rgba(0,0,0,0.4); }
body.dark-mode .detail-chip { background: #222; color: #eee; }
body.dark-mode .typo-spec .muted { color: #cfcfcf; }
body.dark-mode .typo-spec .font-item .chip { background: #1c2a47; color: #b5ccff; }
body.dark-mode .hl-underline, body.dark-mode .typo-spec a.mark { filter: brightness(1.05); }

/* Hide overlay header to match reference layout (no top title/subtitle) */
.project-detail-header { display: none; }

/* Prevent body scroll when detail is open (disabled to avoid blocking page globally) */
/* body.modal-open { overflow: hidden; } */

/* =======================
   Project Detail: Vertical Scrolling Overrides
   ======================= */
/* Safety: ensure site remains interactive when overlay is closed */
html, body { pointer-events: auto !important; }
body:not(.loading) .header,
body:not(.loading) .main-content,
body:not(.loading) .footer-bottom { pointer-events: auto !important; opacity: 1 !important; }
body .project-detail:not(.open) { pointer-events: none !important; }
/* Make overlay content scroll vertically instead of horizontally */
.project-detail .project-detail-scroller {
  display: block !important;
  flex: 1 1 auto;
  min-height: 0 !important; /* critical for scroll inside flex */
  height: 100%;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scroll-snap-type: none !important;
  padding: clamp(8px, 2.2vw, 20px) clamp(16px, 3vw, 36px) calc(clamp(20px, 4vw, 40px) + env(safe-area-inset-bottom)) !important;
  cursor: auto !important;
  user-select: auto !important;
  touch-action: auto !important;
  pointer-events: auto !important;
  -webkit-overflow-scrolling: touch; /* momentum scrolling on iOS */
}

/* Stack slides vertically and use full available width */
.project-detail .detail-slide {
  flex: initial !important;
  min-width: auto !important;
  width: 100% !important;
  scroll-snap-align: none !important;
}

/* Keep split layout within each slide, but allow vertical flow */
.project-detail .detail-slide.split {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  height: auto !important;
}

/* On small screens maintain single column for readability */
@media (max-width: 991.98px) {
  .project-detail .detail-slide.split { grid-template-columns: 1fr !important; grid-template-rows: auto !important; }
  .project-detail .detail-slide.split .split-right { order: -1; min-height: 50svh; }
}

/* Media within slide should adapt to content height */
.project-detail .detail-slide .split-right { position: relative; overflow: hidden; }
.project-detail .detail-slide .split-right img {
  position: relative !important;
  inset: auto !important;
  width: 100% !important;
  height: auto !important;
  max-height: 56dvh; /* use dynamic viewport to account for browser UI */
  object-fit: cover !important;
}

/* Ensure touch on media still scrolls vertically on mobile/tablet */
.project-detail .detail-slide .split-right,
.project-detail .process-step .step-media {
  touch-action: pan-y; /* allow vertical panning to scroll */
}
.project-detail .detail-slide .split-right img,
.project-detail .process-step .step-media img {
  -webkit-user-drag: none; /* prevent native image drag */
  user-select: none;
  touch-action: pan-y;
}

/* =========================================================
   Design Process: alternating media/text steps within slides
   ========================================================= */
.project-detail .process-steps {
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 2.4vw, 28px);
  margin-top: clamp(16px, 2vw, 24px);
}
.project-detail .process-step {
  display: grid;
  grid-template-columns: 1fr 1fr; /* side-by-side equal columns */
  gap: clamp(12px, 2vw, 24px);
  align-items: center;
}
.project-detail .process-step.reverse {
  grid-template-columns: 1fr 1fr; /* keep equal split, order handled below */
}
.project-detail .process-step .step-media {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.project-detail .process-step .step-media img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 50vh; /* half-screen cap */
  object-fit: cover;
}
.project-detail .process-step .step-content {
  padding: clamp(8px, 1.5vw, 14px) clamp(8px, 1.8vw, 16px);
}
.project-detail .step-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 8px 0;
  font-weight: 800;
  font-size: clamp(1.1rem, 2.2vw, 1.6rem);
}
.project-detail .step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 0.9em;
  line-height: 1;
}
.project-detail .step-text {
  margin: 0;
  color: #333;
  font-size: clamp(0.98rem, 1.6vw, 1.05rem);
  line-height: 1.5;
}

/* Reverse: swap visual order on wide screens */
@media (min-width: 992px) {
  .project-detail .process-step.reverse .step-media { order: 2; }
  .project-detail .process-step.reverse .step-content { order: 1; }
}

/* Stack on small screens */
@media (max-width: 1199.98px) { /* tablet */
  .project-detail .process-step .step-media img { max-height: 42dvh; }
}
@media (max-width: 991.98px) { /* mobile */
  .project-detail .process-step,
  .project-detail .process-step.reverse {
    grid-template-columns: 1fr;
  }
  .project-detail .process-step .step-media img { max-height: 36svh; }
}

/* Dark mode adjustments for process steps */
body.dark-mode .project-detail .step-text { color: #cfcfcf; }
body.dark-mode .project-detail .step-index { background: #f1f1f1; color: #111; }

/* Zoom animation ghost element */
.project-zoom-ghost {
  position: fixed;
  left: 0; top: 0;
  width: 100%; height: 100%; /* use percentages to avoid 100vw overflow with scrollbars */
  border-radius: 16px;
  overflow: hidden;
  z-index: 2000;
  pointer-events: none; /* never block clicks beneath */
  transform-origin: top left;
  will-change: transform, border-radius, box-shadow;
  box-shadow: 0 10px 30px rgba(0,0,0,0.22);
  transition: transform 560ms cubic-bezier(.22,1,.36,1),
              border-radius 560ms cubic-bezier(.22,1,.36,1),
              box-shadow 560ms ease;
}
.project-zoom-ghost img {
  width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none;
}

/* =========================================================
   Micro-interactions: Info columns and Tilt context
   ========================================================= */
/* Light 3D context for project cards */
.projects-scroller { perspective: 1000px; }
.tilt-card { transform-style: preserve-3d; will-change: transform; }

/* Subtle hover elevation for info blocks */
.info-column {
  transition: transform 320ms cubic-bezier(.22,1,.36,1), box-shadow 320ms ease, color 200ms ease;
  will-change: transform, box-shadow;
}
.info-column:hover,
.info-column:focus-within {
  transform: translateY(-4px);
}

/* Emphasize titles on hover for Direction/Design */
.direction-column:hover .info-title,
.direction-column:focus-within .info-title,
.design-column:hover .info-title,
.design-column:focus-within .info-title {
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

/* Reduced motion: disable movement */
@media (prefers-reduced-motion: reduce) {
  .info-column { transition: none; transform: none !important; }
  .tilt-card { transform: none !important; }
}

/* =========================================================
   Project cards: cursor spotlight and smooth image transform
   ========================================================= */
.project-topic-block {
  --hx: 50%;
  --hy: 50%;
  position: relative;
  overflow: hidden;
}
.project-topic-block .topic-image {
  transition: transform 300ms cubic-bezier(.22,1,.36,1);
  will-change: transform;
}
.project-topic-block::after {
  content: '';
  position: absolute;
  left: 0; top: 0; right: 0; bottom: 0;
  pointer-events: none;
  background: radial-gradient(380px 280px at var(--hx) var(--hy), rgba(255,255,255,0.30), rgba(255,255,255,0.0) 60%);
  opacity: 0;
  transition: opacity 260ms ease;
}
.project-topic-block:hover::after { opacity: 1; }
body.dark-mode .project-topic-block::after {
  background: radial-gradient(380px 280px at var(--hx) var(--hy), rgba(255,255,255,0.10), rgba(255,255,255,0.0) 60%);
}

/* =========================================================
   Nav item underline animation
   ========================================================= */
.hero-nav .nav-item {
  position: relative;
  text-decoration: none; /* remove underline from links */
}
.hero-nav .nav-item::after {
  content: none; /* underline disabled */
  display: none;
}
.hero-nav .nav-item:hover,
.hero-nav .nav-item:focus-visible { text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
  .project-topic-block .topic-image { transition: none; }
  .hero-nav .nav-item::after { transition: none; }
}
.hero-nav .nav-item:hover,
.hero-nav .nav-item:focus-visible { text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
  .project-topic-block .topic-image { transition: none; }
  .hero-nav .nav-item::after { transition: none; }
}

@media (prefers-reduced-motion: reduce) {
  .project-topic-block .topic-image { transition: none; }
  .hero-nav .nav-item::after { transition: none; }
}