/* ═══════════════════════════════════════════════
   DESIGN TOKENS — light theme
════════════════════════════════════════════════ */
:root {
  /* Colors */
  --color-bg:          #F4F3EE;
  --color-surface:     #FFFFFF;
  --color-surface-2:   #EBEAE4;
  --color-border:      rgba(23, 23, 28, 0.09);
  --color-accent:      #4A5BE0;
  --color-accent-deep: #3A49C9;
  --color-accent-dim:  rgba(74, 91, 224, 0.08);
  --color-accent-glow: rgba(74, 91, 224, 0.16);
  --color-text-primary:   #17171C;
  --color-text-secondary: #5A5A64;
  --color-text-muted:     #9B9BA3;

  /* Typography */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-serif:   'Instrument Serif', Georgia, serif;

  /* Type scale */
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  2rem;
  --text-4xl:  2.75rem;
  --text-5xl:  3.75rem;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-24: 6rem;

  /* Layout */
  --container-max: 1100px;
  --container-pad: clamp(1.25rem, 5vw, 2.5rem);

  /* Misc */
  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  20px;
  --radius-xl:  28px;
  --transition: 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══════════════════════════════════════════════
   RESET & BASE
════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overflow-x: clip;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  overflow-x: hidden;
  overflow-x: clip;
}

/* Texture: grana filmica sopra tutto il layout */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

/* Su mobile la grana non paga: è un layer fisso a tutto viewport che va
   ricomposto a ogni frame di scroll. Resta sul desktop, dove si vede. */
@media (max-width: 1023px) {
  body::after { content: none; }
}

img, svg { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }

ul { list-style: none; }

::selection { background: var(--color-accent); color: #fff; }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb { background: #D6D5CE; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #C2C1BA; }

/* ═══════════════════════════════════════════════
   ACCESSIBILITY
════════════════════════════════════════════════ */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ═══════════════════════════════════════════════
   LAYOUT UTILITIES
════════════════════════════════════════════════ */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

.section {
  padding-block: var(--space-24);
}

.section + .section {
  border-top: 1px solid var(--color-border);
}

/* ═══════════════════════════════════════════════
   SECTION LABEL & HEADING
════════════════════════════════════════════════ */
.section-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-8);
}

.section-label::before {
  content: '';
  display: block;
  width: 20px;
  height: 1px;
  background: var(--color-accent);
}

.section-label--centered::after {
  content: '';
  display: block;
  width: 20px;
  height: 1px;
  background: var(--color-accent);
}

.section-heading {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

/* Accento serif italic editoriale */
.accent-serif {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
  background: linear-gradient(120deg, #6B7CF7 10%, var(--color-accent-deep) 75%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ═══════════════════════════════════════════════
   TOPBAR
════════════════════════════════════════════════ */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding-block: var(--space-4);
  transition: transform 320ms cubic-bezier(0.4, 0, 0.2, 1),
              background var(--transition),
              border-color var(--transition);
  border-bottom: 1px solid transparent;
}

.topbar--scrolled {
  background: rgba(244, 243, 238, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom-color: var(--color-border);
}

.topbar--hidden {
  transform: translateY(-100%);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar__logo {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}

.topbar__logo span {
  color: var(--color-accent);
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar__iconlink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  transition: var(--transition);
}

.topbar__iconlink:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  transform: translateY(-1px);
}

.topbar__iconlink svg {
  width: 15px;
  height: 15px;
}

@media (max-width: 640px) {
  .topbar__iconlink { display: none; }
}

/* ═══════════════════════════════════════════════
   LANGUAGE TOGGLE
════════════════════════════════════════════════ */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.lang-toggle:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.lang-toggle svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════
   DOCK — navigazione flottante (scroll-spy)
════════════════════════════════════════════════ */
.dock {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: calc(100vw - 1.5rem);
  overflow-x: auto;
  scrollbar-width: none;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-border);
  box-shadow: 0 12px 40px rgba(30, 30, 80, 0.12);
  opacity: 0;
  animation: dock-in 0.7s 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.dock::-webkit-scrollbar { display: none; }

@keyframes dock-in {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.dock__link {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.03em;
  white-space: nowrap;
  color: var(--color-text-secondary);
  padding: var(--space-2) var(--space-4);
  border-radius: 999px;
  transition: var(--transition);
}

.dock__link:hover {
  color: var(--color-text-primary);
  background: rgba(23, 23, 28, 0.05);
}

.dock__link.is-active {
  color: var(--color-accent);
  background: var(--color-accent-dim);
}

.dock__link--cta {
  color: var(--color-accent);
  font-weight: 600;
}

.dock__link--cta.is-active,
.dock__link--cta:hover {
  color: #fff;
  background: var(--color-accent);
}

@media (max-width: 480px) {
  .dock__link {
    font-size: 0.7rem;
    padding: var(--space-2) 0.6rem;
  }
}

/* ═══════════════════════════════════════════════
   HERO — finestra chiara con tilt 3D
════════════════════════════════════════════════ */
.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(var(--space-16) + 52px) var(--container-pad) var(--space-12);
  position: relative;
  overflow: hidden;
}

.hero__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hero__glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 720px;
  height: 720px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--color-accent-glow) 0%, transparent 62%);
  opacity: 0.7;
  pointer-events: none;
}

.hero__tilt {
  perspective: 1400px;
  width: 100%;
  max-width: 900px;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.window {
  position: relative;
  border-radius: var(--radius-xl);
  background: linear-gradient(165deg, #FFFFFF 0%, #FAFAFC 55%, #F6F6FA 100%);
  border: 1px solid rgba(23, 23, 28, 0.1);
  box-shadow:
    0 1px 2px rgba(30, 30, 80, 0.05),
    0 30px 80px rgba(30, 30, 80, 0.13),
    0 0 120px rgba(74, 91, 224, 0.05);
  transform-style: preserve-3d;
  will-change: transform;
  opacity: 0;
  animation: window-in 0.9s 0.15s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes window-in {
  from { opacity: 0; transform: translateY(28px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.window__chrome {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  position: relative;
}

.window__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

.window__dot--r { background: #FF5F57; }
.window__dot--y { background: #FEBC2E; }
.window__dot--g { background: #28C840; }

.window__title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  user-select: none;
  white-space: nowrap;
}

.window__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: clamp(1.75rem, 4.5vw, 2.75rem) clamp(1.5rem, 5vw, 3.5rem) var(--space-4);
}

.window__body > * {
  min-width: 0;
  max-width: 100%;
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 100%;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
  opacity: 0;
  animation: fade-up 0.7s 0.5s forwards;
}

.hero__eyebrow-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 10px var(--color-accent-glow);
  animation: pulse-dot 2.4s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

.hero__avatar {
  position: relative;
  width: clamp(80px, 10vw, 96px);
  height: clamp(80px, 10vw, 96px);
  flex-shrink: 0;
  margin-bottom: var(--space-6);
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(135deg, var(--color-accent), transparent 65%);
  opacity: 0;
  animation: fade-up 0.7s 0.62s forwards;
}

.hero__avatar::after {
  content: '';
  position: absolute;
  inset: -35%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--color-accent-glow) 0%, transparent 65%);
  opacity: 0.6;
  pointer-events: none;
}

.hero__avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 20%;
  background: var(--color-surface-2);
  transition: transform var(--transition);
}

.hero__avatar:hover img {
  transform: scale(1.05);
}

.hero__title {
  font-family: var(--font-display);
  font-size: clamp(2.35rem, 5.8vw, 3.6rem);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -0.03em;
  color: var(--color-text-primary);
  margin-bottom: var(--space-6);
  opacity: 0;
  animation: fade-up 0.7s 0.74s forwards;
}

.hero__title-accent {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.015em;
  background: linear-gradient(120deg, #6B7CF7 5%, var(--color-accent-deep) 80%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero__subtitle {
  font-size: var(--text-lg);
  font-weight: 300;
  color: var(--color-text-secondary);
  line-height: 1.7;
  max-width: 580px;
  margin-bottom: var(--space-8);
  opacity: 0;
  animation: fade-up 0.7s 0.86s forwards;
}

.hero__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  opacity: 0;
  animation: fade-up 0.7s 0.98s forwards;
}

.hero__tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  max-width: 620px;
  margin-top: var(--space-8);
  opacity: 0;
  animation: fade-up 0.7s 1.1s forwards;
}

.tag {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  background: var(--color-accent-dim);
  color: var(--color-accent-deep);
  border: 1px solid rgba(74, 91, 224, 0.16);
  transition: var(--transition);
}

.tag:hover {
  border-color: rgba(74, 91, 224, 0.45);
  transform: translateY(-1px);
}

.hero__scroll {
  display: inline-flex;
  margin-top: var(--space-6);
  color: var(--color-text-muted);
  opacity: 0;
  animation: fade-up 0.7s 1.25s forwards;
  transition: color var(--transition);
}

.hero__scroll:hover { color: var(--color-accent); }

.hero__scroll svg {
  width: 18px;
  height: 18px;
  animation: bob 2.2s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(5px); }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════
   BUTTONS
════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--space-3) var(--space-6);
  border-radius: 999px;
  transition: transform var(--transition), box-shadow var(--transition),
              background var(--transition), border-color var(--transition),
              color var(--transition);
  cursor: pointer;
  border: none;
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn--primary {
  background: linear-gradient(135deg, #5B6EF5, #4353D9);
  color: #fff;
  box-shadow: 0 6px 20px rgba(74, 91, 224, 0.25);
}

.btn--primary:hover {
  box-shadow: 0 10px 30px rgba(74, 91, 224, 0.4);
}

.btn--outline {
  background: var(--color-surface);
  color: var(--color-text-primary);
  border: 1px solid rgba(23, 23, 28, 0.16);
}

.btn--outline:hover {
  border-color: var(--color-text-primary);
  transform: translateY(-1px);
}

/* ═══════════════════════════════════════════════
   ABOUT
════════════════════════════════════════════════ */
.about__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-16);
  align-items: start;
}

.about__heading {
  margin-bottom: var(--space-6);
}

.about__text {
  color: var(--color-text-secondary);
  font-size: var(--text-base);
  line-height: 1.8;
  margin-bottom: var(--space-4);
}

/* Metriche tipografiche — nessun box */
.about__stats {
  display: flex;
  flex-direction: column;
}

.stat {
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: baseline;
  gap: var(--space-4);
  padding-block: var(--space-6);
  border-top: 1px solid var(--color-border);
}

.stat:last-child {
  border-bottom: 1px solid var(--color-border);
}

.stat__value {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: -0.03em;
  line-height: 1;
  white-space: nowrap;
}

.stat__suffix {
  font-size: var(--text-xl);
}

.stat__label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.6;
}

@media (max-width: 768px) {
  .about__grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stat { grid-template-columns: 1fr; gap: var(--space-2); }
}

/* ═══════════════════════════════════════════════
   PROJECTS — griglie: consegnati / personali
════════════════════════════════════════════════ */
.projects__head {
  text-align: center;
  margin-bottom: var(--space-12);
}

.projects__head .section-heading {
  max-width: 560px;
  margin-inline: auto;
}

.projects__group + .projects__group {
  margin-top: var(--space-16);
}

.projects__grouptitle {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-8);
  border-bottom: 1px solid var(--color-border);
}

/* Tre colonne fisse: un gruppo con una sola card occupa un terzo,
   non si allarga a tutta la riga. */
.project-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
}

.project-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  overflow: hidden;
  padding-bottom: var(--space-6);
  transition: transform var(--transition), border-color var(--transition),
              box-shadow var(--transition);
  position: relative;
}

.project-card:hover {
  transform: translateY(-2px);
  border-color: rgba(74, 91, 224, 0.4);
  box-shadow: 0 18px 44px rgba(30, 30, 80, 0.12);
}

.project-card__visual {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--color-border);
  background:
    radial-gradient(ellipse 70% 90% at 50% 110%, rgba(74, 91, 224, 0.1), transparent 70%),
    #FBFBFD;
  overflow: hidden;
}

.project-card__visual svg {
  width: 78%;
  height: auto;
  transition: transform 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

.project-card:hover .project-card__visual svg {
  transform: translateY(-4px) scale(1.03);
}

.project-card__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.01em;
  padding-inline: var(--space-6);
}

.project-card__description {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.7;
  flex: 1;
  padding-inline: var(--space-6);
}

.project-card__metric {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-accent);
  letter-spacing: 0.04em;
  margin-inline: var(--space-6);
}

.project-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-inline: var(--space-6);
}

.project-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-4);
  margin-inline: var(--space-6);
  border-top: 1px solid var(--color-border);
}

.project-card__link {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: color var(--transition);
}

.project-card__link:hover {
  color: var(--color-accent);
}

/* Controlli centrati: frecce + dots */

@media (max-width: 900px) {
  .project-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .project-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════
   SKILLS — spec sheet, nessun rettangolo
════════════════════════════════════════════════ */
.skills__list {
  margin-top: var(--space-12);
}

.skill-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: var(--space-8);
  padding-block: var(--space-6);
  border-top: 1px solid var(--color-border);
  transition: background var(--transition);
}

.skill-row:last-child {
  border-bottom: 1px solid var(--color-border);
}

.skill-row:hover {
  background: rgba(255, 255, 255, 0.55);
}

.skill-row__title {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-primary);
  padding-top: 2px;
}

.skill-row__items {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.skill-item {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.7;
}

@media (max-width: 640px) {
  .skill-row {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
}

/* ═══════════════════════════════════════════════
   EXPERIENCE / TIMELINE
════════════════════════════════════════════════ */
.timeline {
  display: flex;
  flex-direction: column;
  position: relative;
  margin-top: var(--space-12);
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 0;
  width: 1px;
  background: var(--color-border);
}

.timeline-item {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: var(--space-6);
  padding-bottom: var(--space-10);
  position: relative;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item__dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--color-bg);
  border: 2px solid var(--color-accent);
  margin-top: 3px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transition: box-shadow var(--transition);
}

.timeline-item:hover .timeline-item__dot {
  box-shadow: 0 0 12px rgba(74, 91, 224, 0.4);
}

.timeline-item__period {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.timeline-item__role {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-1);
}

.timeline-item__company {
  font-size: var(--text-sm);
  color: var(--color-accent);
  margin-bottom: var(--space-4);
}

.timeline-item__description {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.7;
}

/* ═══════════════════════════════════════════════
   CONTACT
════════════════════════════════════════════════ */
.contact {
  text-align: center;
}

.contact__heading {
  font-family: var(--font-display);
  font-size: clamp(var(--text-3xl), 5vw, var(--text-4xl));
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-4);
}

.contact__sub {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  max-width: 480px;
  margin-inline: auto;
  margin-bottom: var(--space-12);
}

.contact__links {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.contact__social {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  margin-top: var(--space-12);
}

.contact__social a {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  transition: color var(--transition);
}

.contact__social a:hover {
  color: var(--color-text-primary);
}

/* ═══════════════════════════════════════════════
   FOOTER
════════════════════════════════════════════════ */
.footer {
  padding-block: var(--space-8) calc(var(--space-8) + 84px);
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.footer__text {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
}

.footer__contacts {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  font-size: var(--text-xs);
  flex-wrap: wrap;
}

.footer__contacts a {
  color: var(--color-text-secondary);
  transition: color var(--transition);
}

.footer__contacts a:hover {
  color: var(--color-accent);
}

.footer__sep {
  color: var(--color-text-muted);
}

/* ═══════════════════════════════════════════════
   CUSTOM CURSOR
════════════════════════════════════════════════ */
.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  pointer-events: none;
  border-radius: 50%;
  transform: translate3d(-100px, -100px, 0);
}

.cursor-dot {
  width: 6px;
  height: 6px;
  background: var(--color-accent);
}

.cursor-ring {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(74, 91, 224, 0.5);
  transition: width 0.25s ease, height 0.25s ease, border-color 0.25s ease;
}

.cursor-ring.is-active {
  width: 58px;
  height: 58px;
  border-color: rgba(23, 23, 28, 0.55);
}

body.has-cursor,
body.has-cursor a,
body.has-cursor button {
  cursor: none;
}


@media (pointer: coarse) {
  .cursor-dot, .cursor-ring { display: none; }
}

/* ═══════════════════════════════════════════════
   SCROLL REVEAL
════════════════════════════════════════════════ */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ═══════════════════════════════════════════════
   CASE STUDY — pagine progetto
   Riusa i token e i componenti di base; aggiunge solo
   ciò che una pagina di dettaglio richiede.
════════════════════════════════════════════════ */

/* Back link nella topbar ──────────────────────── */
.topbar__left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.topbar__back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: color var(--transition);
}

.topbar__back::before {
  content: '';
  display: block;
  width: 1px;
  height: 16px;
  background: var(--color-border);
  margin-right: var(--space-2);
}

.topbar__back:hover { color: var(--color-accent); }

.topbar__back svg { width: 14px; height: 14px; }

/* Hero del case study ─────────────────────────── */
.case-hero {
  padding-block: calc(var(--space-24) + var(--space-8)) var(--space-16);
}

.case-hero__title {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 4.8vw, 3.1rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  max-width: 18ch;
  margin-bottom: var(--space-6);
}

.case-hero__lede {
  font-size: var(--text-lg);
  font-weight: 300;
  color: var(--color-text-secondary);
  line-height: 1.7;
  max-width: 62ch;
  margin-bottom: var(--space-10);
}

/* Striscia metadati: replica la barra d'intestazione del prodotto */
.casemeta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.casemeta__cell {
  padding: var(--space-4) var(--space-6);
  border-left: 1px solid var(--color-border);
}

.casemeta__cell:first-child { border-left: none; }

.casemeta__key {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.casemeta__value {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text-primary);
  line-height: 1.4;
}

/* Corpo: rail sticky + colonna contenuti ──────── */
.case-body {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--space-12);
  align-items: start;
  padding-bottom: var(--space-16);
}

/* Il filo che separa le sezioni vale anche fra il case study e i contatti */
.case-body + .section { border-top: 1px solid var(--color-border); }

.railnav { position: sticky; top: 104px; }

.railnav__label {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.railnav__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.railnav__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-block: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.3;
  color: var(--color-text-muted);
  transition: color var(--transition);
}

/* Il trattino cresce come quello di .section-label, senza spostare il testo */
.railnav__link::before {
  content: '';
  flex: none;
  width: 20px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0.4);
  transform-origin: left center;
  transition: transform var(--transition);
}

.railnav__link:hover { color: var(--color-text-secondary); }

.railnav__link.is-active { color: var(--color-accent); }

.railnav__link.is-active::before { transform: scaleX(1); }

.railnav__num {
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  transition: color var(--transition);
}

.railnav__link.is-active .railnav__num { color: var(--color-accent); }

/* Sezioni della colonna contenuti ─────────────── */
.case-section { padding-block: var(--space-16); }

.case-section:first-child { padding-top: 0; }

.case-section + .case-section { border-top: 1px solid var(--color-border); }

/* Prosa del case study */
.case-prose {
  max-width: 62ch;
  margin-top: var(--space-6);
}

.case-prose p {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  line-height: 1.8;
}

.case-prose p + p { margin-top: var(--space-4); }

/* Il primo periodo di "Cosa fa il sistema" regge la sezione */
.case-prose p.case-prose__lead {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.5;
  color: var(--color-text-primary);
}

/* Blocco schermata ────────────────────────────── */
.screen { padding-block: var(--space-16); }

.screen:first-of-type { padding-top: var(--space-10); }

.screen + .screen { border-top: 1px solid var(--color-border); }

.screen__head {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.screen__num {
  flex: none;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
  color: var(--color-accent);
}

.screen__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.screen__text {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  line-height: 1.8;
  max-width: 62ch;
}

.screen__text + .screen__text { margin-top: var(--space-4); }

.screen .shot { margin-top: var(--space-8); }

/* La frase-chiave che chiude ogni schermata */
.screen__take + .screen__text { margin-top: var(--space-10); }

.screen__take {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  margin-top: var(--space-6);
  max-width: 62ch;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.5;
  color: var(--color-text-primary);
}

.screen__take::before {
  content: '';
  flex: none;
  width: 20px;
  height: 1px;
  background: var(--color-accent);
  margin-top: 0.75em;
}

/* Cornice screenshot ──────────────────────────── */
.shot {
  display: block;
  width: 100%;
  padding: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 18px 44px rgba(30, 30, 80, 0.10);
  cursor: zoom-in;
  transition: transform var(--transition), box-shadow var(--transition),
              border-color var(--transition);
}

.shot:hover {
  transform: translateY(-2px);
  border-color: rgba(74, 91, 224, 0.4);
  box-shadow: 0 26px 60px rgba(30, 30, 80, 0.16);
}

.shot__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
}

.shot__name {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.shot__hint {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  transition: color var(--transition);
}

.shot__hint svg { width: 13px; height: 13px; }

.shot:hover .shot__hint { color: var(--color-accent); }

.shot img {
  width: 100%;
  height: auto;
}

/* Risultato ───────────────────────────────────── */
.caseresult__stats {
  display: flex;
  flex-direction: column;
}

.caseresult__note {
  margin-top: var(--space-8);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.7;
  max-width: 62ch;
}

/* Nota di riservatezza ────────────────────────── */
.callout {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: var(--space-4);
  padding: var(--space-6);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.callout__icon {
  width: 20px;
  height: 20px;
  color: var(--color-accent);
  margin-top: 1px;
}

.callout__title {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.callout__text {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.7;
}

/* Ritorno ai progetti in coda alla pagina ─────── */
.case-backall {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-10);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: color var(--transition);
}

.case-backall:hover { color: var(--color-accent); }

.case-backall svg { width: 14px; height: 14px; }

/* ═══════════════════════════════════════════════
   LIGHTBOX — schermate a piena risoluzione
════════════════════════════════════════════════ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: none;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: rgba(23, 23, 28, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.lightbox.is-open { display: flex; }

body.lightbox-open { overflow: hidden; }

.lightbox__bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  color: #F4F3EE;
}

.lightbox__caption {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lightbox__counter {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  color: rgba(244, 243, 238, 0.6);
  margin-left: var(--space-3);
}

.lightbox__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.lightbox__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(244, 243, 238, 0.25);
  background: transparent;
  color: #F4F3EE;
  cursor: pointer;
  transition: var(--transition);
}

.lightbox__btn:hover {
  border-color: #F4F3EE;
  background: rgba(244, 243, 238, 0.12);
}

.lightbox__btn svg { width: 16px; height: 16px; }

.lightbox__stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

/* ═══════════════════════════════════════════════
   CASE STUDY — responsive
════════════════════════════════════════════════ */
@media (max-width: 1023px) {
  /* Il rail diventa una striscia di chip sotto la topbar: gli anchor devono
     scendere sotto topbar + striscia. Vale solo qui — sulla home c'è la sola
     topbar, e lo scroll-padding di base basta. */
  html:has(.page-case) { scroll-padding-top: 150px; }

  /* Qui la striscia dei capitoli si aggancia sotto la topbar: se la topbar
     si ritraesse, il contenuto scorrerebbe visibile nella fascia lasciata
     libera sopra le chip. Su questa pagina la topbar resta. */
  body.page-case .topbar--hidden { transform: none; }

  .case-body {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }

  /* Barre ancorate opache, senza backdrop-filter.
     Un backdrop sfocato su un elemento agganciato va ri-rasterizzato a ogni
     frame di scroll, su tutta la larghezza: qui erano due impilati (topbar +
     striscia) e bastavano a mangiarsi il frame budget di una GPU mobile.
     var(--color-bg) è lo stesso #F4F3EE di prima, solo pieno: cambia solo che
     il contenuto non traspare più mentre scorre sotto. */
  .railnav {
    top: 66px;
    z-index: 90;
    margin-inline: calc(-1 * var(--container-pad));
    padding: var(--space-3) var(--container-pad);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .topbar--scrolled {
    background: var(--color-bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .railnav::-webkit-scrollbar { display: none; }

  .railnav__label { display: none; }

  .railnav__list {
    flex-direction: row;
    gap: var(--space-2);
  }

  .railnav__link {
    flex: none;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    white-space: nowrap;
    color: var(--color-text-secondary);
  }

  .railnav__link::before { display: none; }

  .railnav__link.is-active {
    border-color: rgba(74, 91, 224, 0.45);
    background: var(--color-accent-dim);
  }
}

@media (max-width: 768px) {
  .casemeta { grid-template-columns: repeat(2, 1fr); }
  .casemeta__cell:nth-child(odd) { border-left: none; }
  .casemeta__cell:nth-child(n + 3) { border-top: 1px solid var(--color-border); }

  .caseblock {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .screen__head {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
}

@media (max-width: 720px) {
  /* Su schermo stretto il mockup si esplora scorrendo, non rimpicciolito */
  .lightbox__stage { align-items: flex-start; }
  .lightbox__img {
    max-width: none;
    max-height: none;
    width: 1100px;
  }
}

@media (max-width: 480px) {
  .casemeta { grid-template-columns: 1fr; }
  .casemeta__cell { border-left: none; }
  .casemeta__cell + .casemeta__cell { border-top: 1px solid var(--color-border); }

  .screen__take { font-size: var(--text-base); }
}
