/* ==========================================================================
   Sasha Fratini — style.css
   CSS puro, mobile-first, senza framework.
   Struttura, geometrie e ritmo verticale ricalcati da albemiglio.it,
   palette adattata a un profilo di ingegneria elettronica.
   Indice:
     1. Token di design (:root)
     2. Reset moderno
     3. Base e utility
     4. Pulsanti
     5. Header, navigazione e selettore lingua
     6. Hero e anello 3D
     7. Sezioni e titoli
     8. Card (competenze e repository)
     9. Progetti: capitoli, schermo, livelli, stepbar
    10. Pannelli: codice, scheda, consumi, app, specifiche
    11. Timeline (esperienze e formazione)
    12. Contatti
    13. Footer
    14. Animazioni di comparsa
    15. Breakpoint (min-width)
    16. Movimento ridotto
   ========================================================================== */


/* 1. Token di design
   ========================================================================== */
:root {
  /* Palette di base (dark) */
  --bg: #0a1214;
  --surface: #101b1e;
  --surface-2: #142225;
  --screen-bg: #0d171a;
  --text: #ffffff;
  --muted: #a8c4c2;
  --faint: #7b9694;
  --border: #1c2c30;
  --border-strong: #2b3f43;

  /* Accenti: ambra (azioni) e verde acqua (dettagli) */
  --accent: #ff9f1c;
  --accent-hover: #ffbf69;
  --copper: #2ec4b6;

  /* Colori dei capitoli progetto */
  --c-ecobin: #2ec4b6;
  --c-poc: #cbf3f0;
  --c-stm32: #ff9f1c;
  --c-esd: #ffbf69;

  /* Tipografia */
  --font-sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* Layout e spaziature */
  --maxw: 1120px;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --nav-h: 64px;
  --section-pad: clamp(4rem, 10vh, 7rem);
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Raggi di curvatura */
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  /* Ombre */
  --shadow-screen: 0 32px 64px -24px rgba(0, 0, 0, .75), 0 2px 8px rgba(0, 0, 0, .3);
  --shadow-panel: 0 24px 60px rgba(0, 0, 0, .45);

  /* Movimento */
  --ease: cubic-bezier(.22, 1, .36, 1);
  --dur-fast: .15s;
  --dur-slow: .6s;

  color-scheme: dark;
}


/* 2. Reset moderno
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
h1, h2, h3, h4,
p,
figure,
blockquote,
dl, dd,
ul, ol,
pre {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 1rem);
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

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

img {
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

::selection {
  background: rgba(255, 159, 28, .45);
  color: #fff;
}


/* 3. Base e utility
   ========================================================================== */
.rail {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 100;
  padding: .6rem 1rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: .85rem;
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
}

main {
  position: relative;
  z-index: 1;
}


/* 4. Pulsanti
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 44px;
  padding: 0 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: .9rem;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition:
    border-color var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    transform .1s ease-out;
}

.btn:hover {
  border-color: var(--accent);
}

.btn:active {
  transform: scale(.97);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

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

.btn--static {
  color: var(--muted);
  cursor: default;
}

.btn--static:hover {
  border-color: var(--border);
}

.btn--static:active {
  transform: none;
}

.btn--sm {
  min-height: 38px;
  padding: 0 .95rem;
  font-size: .82rem;
}


/* 5. Header, navigazione e selettore lingua
   ========================================================================== */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: var(--nav-h);
  border-bottom: 1px solid transparent;
  transition:
    background-color .25s var(--ease),
    border-color .25s var(--ease),
    backdrop-filter .25s var(--ease);
}

.site-header.is-scrolled,
.site-header.is-open {
  background: rgba(10, 18, 20, .72);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom-color: var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  height: 100%;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  min-height: 44px;
  font-weight: 600;
  letter-spacing: -.01em;
  text-decoration: none;
}

.brand__logo {
  width: 30px;
  height: 30px;
}

.nav__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  transition: border-color var(--dur-fast) var(--ease);
}

.nav__toggle:hover {
  border-color: var(--accent);
}

.nav__toggle-bars {
  position: relative;
  width: 18px;
  height: 12px;
}

.nav__toggle-bars::before,
.nav__toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 1.5px;
  border-radius: 2px;
  background: currentColor;
  transition: transform .25s var(--ease), top .25s var(--ease);
}

.nav__toggle-bars::before {
  top: 2px;
}

.nav__toggle-bars::after {
  top: 8.5px;
}

.nav__toggle[aria-expanded="true"] .nav__toggle-bars::before {
  top: 5.25px;
  transform: rotate(45deg);
}

.nav__toggle[aria-expanded="true"] .nav__toggle-bars::after {
  top: 5.25px;
  transform: rotate(-45deg);
}

/* Menu mobile: pannello a tendina sotto la barra */
.nav__menu {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  display: grid;
  gap: var(--space-4);
  max-height: calc(100svh - var(--nav-h));
  padding: var(--space-2) var(--gutter) var(--space-6);
  overflow-y: auto;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition:
    opacity .25s var(--ease),
    transform .25s var(--ease),
    visibility 0s linear .25s;
}

.site-header.is-open .nav__menu {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity .25s var(--ease),
    transform .25s var(--ease),
    visibility 0s;
}

.nav__links {
  display: grid;
}

.nav__link {
  display: flex;
  align-items: center;
  min-height: 52px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -.01em;
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}

.nav__link:hover,
.nav__link.is-active {
  color: var(--accent);
}

.nav__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
}

.lang {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: .78rem;
}

.lang__item {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 38px;
  padding: 0 .6rem;
  border-radius: var(--radius-pill);
  color: var(--muted);
  text-decoration: none;
  transition:
    color var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease);
}

a.lang__item:hover {
  color: var(--text);
}

.lang__item.is-current {
  background: var(--surface-2);
  color: var(--text);
}

body.nav-open {
  overflow: hidden;
}


/* 6. Hero e anello 3D
   ========================================================================== */
.hero {
  display: grid;
  align-items: center;
  padding: calc(var(--nav-h) + clamp(2rem, 8vh, 4rem)) 0 .5rem;
}

.hero__grid {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: .5rem;
}

.hero__name {
  font-size: clamp(2.6rem, 7vw, 5.5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.03em;
}

.hero__title {
  margin: 1rem 0 .5rem;
  font-size: clamp(1.15rem, 2.2vw, 1.5rem);
  line-height: 1.3;
  letter-spacing: -.01em;
}

.hero__sub {
  max-width: 40ch;
  margin: 0 0 1.75rem;
  color: var(--muted);
  line-height: 1.55;
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
}

.hero__stage {
  width: 100%;
}

.hero__sculpture {
  width: 100%;
  margin: .75rem 0 0;
  container-type: inline-size;
}

.hero__caption {
  margin: .6rem 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .78rem;
  text-align: left;
}

/* Versione statica (mobile): primo pannello, senza 3D */
.hero__still {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-panel);
}

.hero__still img {
  width: 100%;
  height: 100%;
  padding: 3%;
  object-fit: contain;
}

/* Anello 3D (desktop) */
.hero__ring-stage {
  display: none;
  position: relative;
  width: 100%;
  aspect-ratio: 1.35;
  perspective: 265cqw;
}

.hero__tilt {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateX(var(--tilt-x, -4.6deg)) rotateY(var(--tilt-y, 0deg));
  will-change: transform;
}

.hero__ring {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 1.2s cubic-bezier(.45, 0, .55, 1);
}

.hero__panel {
  position: absolute;
  inset: 0;
  width: 68cqw;
  height: 44cqw;
  margin: auto;
  overflow: hidden;
  border-radius: 1.2cqw;
  background: #233538;
  box-shadow: var(--shadow-panel);
  backface-visibility: hidden;
  opacity: 0;
  transform: rotateY(calc(var(--i) * 120deg)) translateZ(16.5cqw);
  transition: opacity 1.2s ease-in-out;
}

.hero__panel.is-front {
  opacity: 1;
}

.hero__panel--plot {
  width: 62cqw;
  height: 46.5cqw;
}

.hero__panel--app {
  width: 64cqw;
  height: 44cqw;
}

.hero__panel-inner {
  position: absolute;
  inset: 1.45cqw;
  overflow: hidden;
  border-radius: .8cqw;
  background: var(--screen-bg);
  container-type: inline-size;
}

.hero__panel-inner--paper {
  background: #fff;
}

.hero__panel-inner > img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.hero__panel .code__body {
  font-size: 2.35cqw;
  overflow: hidden;
}

.hero__panel .code__bar {
  font-size: 2.1cqw;
}


/* 7. Sezioni e titoli
   ========================================================================== */
.section {
  padding: var(--section-pad) 0;
}

.section-title {
  margin: 0 0 1.5rem;
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
  font-weight: 600;
  letter-spacing: -.01em;
}

.section-lead {
  max-width: 58ch;
  margin: -.5rem 0 2rem;
  color: var(--muted);
  line-height: 1.6;
}

.subsection-title {
  margin: 3rem 0 1.25rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: .8rem;
  font-weight: 500;
  letter-spacing: .02em;
}


/* 8. Card (competenze e repository)
   ========================================================================== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: .7rem;
}

.cards > li {
  display: flex;
}

.card {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  width: 100%;
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease);
}

.card--link:hover {
  border-color: var(--accent);
}

.card--skill:hover {
  border-color: var(--border-strong);
}

.card__icon {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: .35rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--copper);
}

.card__icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.card__name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -.01em;
}

.card--link .card__name {
  overflow-wrap: anywhere;
}

.card__arrow {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.card--link:hover .card__arrow {
  stroke: var(--accent);
  transform: translate(2px, -2px);
}

.card__desc {
  margin: 0;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.5;
}

.card__tags {
  margin-top: auto;
  padding-top: .35rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: .78rem;
  line-height: 1.5;
}


/* 9. Progetti: capitoli, schermo, livelli, stepbar
   ========================================================================== */
.section--work .section-lead {
  margin-bottom: 0;
}

.chapter {
  display: block;
  padding: 3rem 0 3.5rem;
  scroll-margin-top: calc(var(--nav-h) + 1rem);
}

.chapter:last-of-type {
  padding-bottom: 1rem;
}

.chapter__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

/* Su mobile il testo "si scioglie" nella griglia per riordinare i blocchi */
.chapter__text {
  display: contents;
}

.chapter__kicker {
  order: 1;
  margin: 0 0 .5rem;
  color: var(--chapter-color);
  font-family: var(--font-mono);
  font-size: .78rem;
  letter-spacing: .02em;
}

.chapter__title {
  order: 2;
  margin: 0 0 1.25rem;
  font-size: 1.6rem;
  line-height: 1.12;
  letter-spacing: -.025em;
  text-wrap: balance;
}

.chapter__stage {
  order: 3;
  min-width: 0;
}

.chapter__blurb {
  order: 4;
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.55;
}

.chapter__fact {
  order: 5;
  margin: .6rem 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .8rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.chapter__fact a {
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.chapter__fact a:hover {
  color: var(--chapter-color);
  text-decoration-color: currentColor;
}

/* Schermo che contiene i livelli (immagini, codice, schemi) */
.screen {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid rgba(28, 44, 48, .9);
  border-radius: var(--radius);
  background: var(--screen-bg);
  box-shadow: var(--shadow-screen);
  container-type: inline-size;
}

.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: inherit;
  box-shadow: inset 0 1px rgba(255, 255, 255, .06);
  pointer-events: none;
}

.shot__layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  opacity: 0;
}

.shot__layer.is-active {
  z-index: 2;
  opacity: 1;
  transition: opacity var(--dur-slow) ease-in-out;
}

.shot__layer.is-prev {
  z-index: 1;
  opacity: 1;
}

.shot__layer--paper {
  background: #fff;
}

.shot {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.shot--plot {
  padding: 1.8cqw 2.4cqw;
  object-fit: contain;
}

/* Foto opzionali: compaiono solo se il file esiste (vedi script.js) */
.shot--photo {
  z-index: 3;
  opacity: 0;
  transition: opacity .4s ease;
}

.shot--photo.is-loaded {
  opacity: 1;
}

/* Stepbar a progressione automatica */
.stepbar {
  position: relative;
  display: flex;
  gap: 6px;
  margin-top: 16px;
  padding-bottom: 1.35rem;
}

.step {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-start;
  gap: 6px;
  min-width: 0;
  min-height: 44px;
  padding-top: 6px;
  text-align: left;
  transition: opacity .12s ease-out;
}

.step:active {
  opacity: .6;
}

.step__track {
  display: block;
  height: 3px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--border);
}

.step__fill {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--chapter-color);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.step__fill--done {
  transform: scaleX(1);
}

.step__fill--active {
  animation: stepfill var(--step-ms, 2600ms) linear forwards;
  animation-play-state: paused;
}

.stepbar.is-playing .step__fill--active {
  animation-play-state: running;
}

html.no-js .step[aria-current="step"] .step__fill {
  transform: scaleX(1);
}

@keyframes stepfill {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

.step__label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: .72rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  visibility: hidden;
  transition: color var(--dur-fast) var(--ease);
}

.step[aria-current="step"] .step__label {
  visibility: visible;
}


/* 10. Pannelli: codice, scheda, consumi, app, specifiche
   ========================================================================== */
.panel {
  position: absolute;
  inset: 0;
}

.panel__eyebrow {
  color: var(--chapter-color);
  font-family: var(--font-mono);
  font-size: max(10px, 1.5cqw);
  letter-spacing: .02em;
}

.panel__notes {
  display: grid;
  gap: 1cqw;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: max(10.5px, 1.55cqw);
  line-height: 1.45;
}

.panel__notes li::before {
  content: "→ ";
  color: var(--chapter-color);
}

/* --- Codice (evidenziazione sintassi applicata da script.js) --- */
.code {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--screen-bg);
}

.code__bar {
  display: flex;
  flex: none;
  align-items: center;
  gap: .75rem;
  height: clamp(28px, 6cqw, 40px);
  padding: 0 clamp(10px, 2.2cqw, 16px);
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: #0f1a1d;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: max(10px, 1.45cqw);
  white-space: nowrap;
}

.code__dots {
  display: inline-flex;
  flex: none;
  gap: 6px;
}

.code__dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #2b3f43;
}

.code__file {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.code__tag {
  flex: none;
  margin-left: auto;
  padding: .1rem .5rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  color: var(--faint);
  font-size: .9em;
}

.code__tag--revised {
  border-color: color-mix(in srgb, var(--chapter-color) 45%, transparent);
  color: var(--chapter-color);
}

.code__body {
  flex: 1;
  min-height: 0;
  padding: max(12px, 2.4cqw) max(14px, 3cqw);
  overflow: auto;
  overscroll-behavior: contain;
  color: #cbf3f0;
  font-family: var(--font-mono);
  font-size: max(10px, 1.62cqw);
  font-variant-ligatures: none;
  line-height: 1.6;
  tab-size: 4;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.code__body code {
  font: inherit;
  white-space: pre;
}

.tok-c { color: #7b9694; font-style: italic; }
.tok-k { color: #ff9f1c; }
.tok-t { color: #2ec4b6; }
.tok-n { color: #ffbf69; }
.tok-s { color: #cbf3f0; }
.tok-m { color: #2ec4b6; }
.tok-f { color: #ffbf69; }

/* --- Scheda EcoBin (SVG inline) --- */
.panel--board {
  background: var(--screen-bg);
}

.board {
  width: 100%;
  height: 100%;
}

.board text {
  fill: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
}

.board .board__eyebrow {
  fill: var(--chapter-color);
  font-size: 14px;
  letter-spacing: .02em;
}

.board .board__title {
  fill: var(--text);
  font-family: var(--font-sans);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.board .board__sub {
  font-size: 12.5px;
}

.board .board__pin {
  fill: var(--text);
  font-size: 14px;
}

.board .board__label {
  font-size: 12.5px;
}

.board .board__bytetext {
  fill: var(--text);
  font-size: 13px;
}

.board__block {
  fill: var(--surface-2);
  stroke: var(--border-strong);
  stroke-width: 2;
}

.board__notch {
  fill: var(--border-strong);
}

.board__pad {
  fill: var(--copper);
}

.board__trace {
  fill: none;
  stroke: var(--copper);
  stroke-width: 3;
  stroke-linecap: round;
}

.board__trace--idle {
  stroke: #34494d;
  stroke-dasharray: 6 7;
}

.board__trace--gnd {
  stroke: #557074;
}

.board__transducer {
  fill: #0e181b;
  stroke: #34494d;
  stroke-width: 2;
}

.board__transducer--inner {
  fill: #1a2a2e;
  stroke: #466064;
}

.board__byte {
  fill: var(--surface-2);
  stroke: var(--border-strong);
  stroke-width: 1.5;
}

.board__byte--head {
  stroke: var(--chapter-color);
}

/* --- Elementi comuni agli schemi a blocchi --- */
.board .board__title--sm {
  font-size: 18px;
}

.board__block--accent {
  stroke: var(--chapter-color);
}

.board__arrow {
  fill: none;
  stroke: var(--copper);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.board__arrow--ctrl {
  stroke: #557074;
  stroke-width: 2;
  stroke-dasharray: 5 6;
}

/* --- Display a 7 segmenti e sequenza di stati (FSM HELLO) --- */
.hex__panel {
  fill: #060c0e;
  stroke: var(--border-strong);
  stroke-width: 1.5;
}

.hex__digit use {
  fill: #16262a;
}

.hex__digit use.on {
  fill: var(--chapter-color);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--chapter-color) 55%, transparent));
}

.fsm__chip {
  fill: var(--surface-2);
  stroke: var(--border-strong);
  stroke-width: 1.5;
}

.fsm__chip--start {
  stroke: var(--chapter-color);
}

.board .fsm__text {
  fill: var(--text);
  font-size: 15px;
}

/* --- Ciclo di consumo EcoBin --- */
.panel--power {
  --name-col: 19cqw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3.2cqw;
  padding: 5cqw 5.5cqw;
  background: var(--screen-bg);
}

.power {
  display: grid;
  gap: 1.6cqw;
}

.power__lane,
.power__axis {
  display: grid;
  grid-template-columns: var(--name-col) minmax(0, 1fr);
  align-items: center;
  gap: 2cqw;
}

.power__name {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: max(10px, 1.45cqw);
  line-height: 1.2;
}

.power__track {
  --track-h: max(24px, 5.2cqw);
  display: flex;
  height: var(--track-h);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 1cqw;
  background: var(--surface);
}

.seg {
  display: block;
  flex: var(--w) 1 0;
  min-width: 0;
  padding: 0 .4cqw;
  overflow: hidden;
  border-right: 1px solid rgba(0, 0, 0, .35);
  font-family: var(--font-mono);
  font-size: max(9px, 1.25cqw);
  line-height: calc(var(--track-h) - 2px);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seg:last-child {
  border-right: 0;
}

.seg--sleep {
  background: #132124;
  color: var(--faint);
}

.seg--on {
  background: #2ec4b6;
  color: #06110b;
  font-weight: 600;
}

.seg--sc {
  background: #cbf3f0;
  color: #0a1214;
}

.seg--vcc {
  background: #ff9f1c;
  color: #1a0f07;
  font-weight: 600;
}

.seg--off {
  background: var(--surface);
  color: #4d6a6e;
}

.power__ticks {
  position: relative;
  height: 1.5em;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: max(9px, 1.2cqw);
}

.power__ticks span {
  position: absolute;
  top: 0;
  white-space: nowrap;
}

.power__ticks span:nth-child(1) {
  left: 26.5%;
  transform: translateX(-50%);
}

.power__ticks span:nth-child(2) {
  left: 56%;
  transform: translateX(-50%);
}

.power__ticks span:nth-child(3) {
  right: 0;
}

@container (max-width: 520px) {
  .panel--power {
    gap: 2.6cqw;
    padding: 4.5cqw 5cqw;
  }

  .power__lane,
  .power__axis {
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
  }

  .power__axis > span:first-child,
  .panel--power .panel__notes {
    display: none;
  }
}

/* --- Anteprima app EcoBin (ricostruita dal codice Kotlin: colori e gauge) --- */
.app-mock {
  --u: 1cqw;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(6 * var(--u));
  padding: calc(4 * var(--u));
  background: radial-gradient(120% 90% at 30% 20%, #123033 0%, var(--screen-bg) 60%);
}

.phone {
  flex: none;
  width: calc(27 * var(--u));
  aspect-ratio: 9 / 18.5;
  padding: calc(1.1 * var(--u));
  border: 1px solid var(--border-strong);
  border-radius: calc(4.2 * var(--u));
  background: #040809;
  box-shadow: 0 calc(2 * var(--u)) calc(5 * var(--u)) rgba(0, 0, 0, .5);
}

.phone__screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: calc(2.8 * var(--u)) calc(2.4 * var(--u));
  overflow: hidden;
  border-radius: calc(3.2 * var(--u));
  background: #f8fafc;
  color: #0f172a;
  font-family: var(--font-sans);
}

.app__top {
  display: flex;
  align-items: center;
  gap: var(--u);
  width: 100%;
  font-size: calc(1.8 * var(--u));
  font-weight: 700;
}

.app__logo {
  width: calc(3.6 * var(--u));
  height: calc(3.6 * var(--u));
}

.app__chip {
  margin-left: auto;
  padding: calc(.25 * var(--u)) calc(.9 * var(--u));
  border-radius: var(--radius-pill);
  background: #dbeafe;
  color: #2563eb;
  font-family: var(--font-mono);
  font-size: calc(1.2 * var(--u));
  font-weight: 600;
}

.app__name {
  align-self: flex-start;
  margin-top: calc(2.8 * var(--u));
  font-size: calc(2.2 * var(--u));
  font-weight: 700;
  letter-spacing: -.01em;
}

.app__status {
  display: flex;
  align-items: center;
  align-self: flex-start;
  gap: calc(.8 * var(--u));
  color: #64748b;
  font-size: calc(1.35 * var(--u));
}

.app__dot {
  width: calc(1.1 * var(--u));
  height: calc(1.1 * var(--u));
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 calc(.5 * var(--u)) rgba(16, 185, 129, .2);
}

.gauge {
  position: relative;
  width: calc(17 * var(--u));
  aspect-ratio: 1;
  margin: calc(2.6 * var(--u)) 0 calc(2.2 * var(--u));
}

.gauge svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge__track,
.gauge__fill {
  fill: none;
  stroke-width: 11;
}

.gauge__track {
  stroke: #e5e7eb;
}

.gauge__fill {
  stroke: #10b981;
  stroke-linecap: round;
  stroke-dasharray: var(--p) 100;
}

.gauge__value {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #10b981;
  font-size: calc(4.2 * var(--u));
  font-weight: 700;
  letter-spacing: -.02em;
}

.app__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(1.1 * var(--u));
  width: 100%;
  margin-top: auto;
}

.app__stats div {
  padding: calc(1.1 * var(--u)) calc(1.3 * var(--u));
  border: 1px solid #e5e7eb;
  border-radius: calc(1.3 * var(--u));
  background: #fff;
}

.app__stats dt {
  color: #64748b;
  font-size: calc(1.15 * var(--u));
}

.app__stats dd {
  color: #0f172a;
  font-size: calc(1.9 * var(--u));
  font-weight: 700;
}

.app-mock__side {
  max-width: calc(36 * var(--u));
}

.app-mock__label {
  margin-bottom: calc(1.2 * var(--u));
  color: var(--c-ecobin);
  font-family: var(--font-mono);
  font-size: max(10px, calc(1.4 * var(--u)));
  letter-spacing: .02em;
}

.app-mock__formula {
  padding: calc(1.6 * var(--u)) calc(2 * var(--u));
  border: 1px solid var(--border);
  border-radius: calc(1.2 * var(--u));
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: max(11px, calc(1.9 * var(--u)));
  line-height: 1.5;
}

.app-mock__note {
  margin-top: calc(1.6 * var(--u));
  color: var(--muted);
  font-size: max(10px, calc(1.45 * var(--u)));
  line-height: 1.5;
}

@container (max-width: 520px) {
  .app-mock {
    --u: 1.3cqw;
  }

  .app-mock__side {
    display: none;
  }
}

/* Nell'anello dell'hero il pannello è più basso: telefono in scala ridotta */
.hero__panel .app-mock {
  --u: 1cqw;
}

/* --- Specifiche scheda STM32 --- */
.panel--spec {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  gap: 4cqw;
  padding: 5cqw 5.5cqw;
  background: radial-gradient(90% 90% at 15% 30%, color-mix(in srgb, var(--chapter-color) 7%, var(--screen-bg)) 0%, var(--screen-bg) 55%);
}

.chip-art {
  display: none;
  width: 100%;
  height: auto;
}

.chip-art__pins path {
  fill: none;
  stroke: #8aa6a4;
  stroke-width: 5;
  stroke-linecap: round;
}

.chip-art__body {
  fill: #182528;
  stroke: #34494d;
  stroke-width: 2;
}

.chip-art__dot {
  fill: var(--border-strong);
}

.chip-art .chip-art__name {
  fill: var(--text);
  font-family: var(--font-sans);
  font-size: 24px;
  font-weight: 700;
}

.chip-art .chip-art__part {
  fill: var(--chapter-color);
  font-family: var(--font-mono);
  font-size: 14px;
}

.spec {
  display: grid;
  gap: max(6px, 1.5cqw);
}

.spec__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .15rem;
}

.spec dt {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: max(10px, 1.4cqw);
}

.spec dd {
  color: var(--text);
  font-size: max(11px, 1.75cqw);
  line-height: 1.35;
}

@container (min-width: 521px) {
  .panel--spec {
    grid-template-columns: 30cqw minmax(0, 1fr);
    align-items: center;
  }

  .chip-art {
    display: block;
  }

  .spec__row {
    grid-template-columns: 15cqw minmax(0, 1fr);
    align-items: baseline;
    gap: 1.5cqw;
  }
}


/* 11. Timeline (esperienze e formazione)
   ========================================================================== */
.timeline {
  display: grid;
  gap: 1.75rem;
  margin: 0 0 1.75rem;
}

.timeline__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .35rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.timeline__when {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .82rem;
}

.timeline__role {
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1.4;
}

.timeline__role strong {
  font-weight: 600;
}

.timeline__meta {
  margin-top: .15rem;
  color: var(--muted);
  font-size: .9rem;
}

.timeline__points {
  display: grid;
  gap: .45rem;
  max-width: 70ch;
  margin-top: .9rem;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.55;
}

.timeline__points li {
  position: relative;
  padding-left: 1.1rem;
}

.timeline__points li::before {
  content: "";
  position: absolute;
  top: .78em;
  left: 0;
  width: 7px;
  height: 1.5px;
  border-radius: 1px;
  background: var(--copper);
}

.timeline__tags {
  margin-top: .9rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: .78rem;
  line-height: 1.5;
}

.timeline--compact {
  gap: 1.15rem;
  margin-bottom: 2.5rem;
}

.timeline--compact .timeline__item {
  padding-top: 0;
  border-top: 0;
}

.timeline--compact .timeline__role {
  font-size: 1rem;
}


/* 12. Contatti
   ========================================================================== */
.contact__lead {
  max-width: 58ch;
  margin: 0 0 1.25rem;
  color: var(--muted);
  line-height: 1.6;
}

.contact__primary {
  display: inline-block;
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: clamp(1.15rem, 3.2vw, 2.05rem);
  letter-spacing: -.01em;
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: color var(--dur-fast) var(--ease);
}

.contact__primary:hover {
  color: var(--accent);
}

.contact__rest {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-top: 1.25rem;
}


/* 13. Footer
   ========================================================================== */
.footer {
  padding: 2rem 0;
  background: var(--bg);
  color: var(--muted);
  font-size: .85rem;
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1.5rem;
}

.footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.1rem;
  font-family: var(--font-mono);
  font-size: .8rem;
}

.footer__links a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}

.footer__links a:hover {
  color: var(--text);
}


/* 14. Animazioni di comparsa (attive solo con JavaScript)
   ========================================================================== */
.js .reveal {
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity var(--dur-slow) var(--ease),
    transform var(--dur-slow) var(--ease);
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}


/* 15. Breakpoint (min-width)
   ========================================================================== */

/* ≥ 641px — tablet */
@media (min-width: 641px) {
  .cards {
    gap: .9rem;
  }

  .screen {
    aspect-ratio: 1512 / 982;
  }

  .stepbar {
    padding-bottom: 0;
  }

  .step__label {
    position: static;
    color: var(--muted);
    text-align: left;
    visibility: visible;
  }

  .step[aria-current="step"] .step__label {
    color: var(--text);
  }

  .timeline__item {
    grid-template-columns: 11rem minmax(0, 1fr);
    align-items: baseline;
    gap: 1rem;
  }
}

/* ≥ 901px — desktop: hero a due colonne, capitoli sticky */
@media (min-width: 901px) {
  .hero {
    min-height: 100svh;
    padding: var(--nav-h) 0 0;
  }

  .hero__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(1.5rem, 4vw, 4rem);
  }

  .hero__stage {
    justify-self: end;
    max-width: 540px;
  }

  .hero__sculpture {
    display: grid;
    align-content: center;
    aspect-ratio: 1.35;
    margin: 0;
  }

  .hero__ring-stage {
    display: block;
  }

  .hero__still {
    display: none;
  }

  .hero__caption {
    margin-top: .9rem;
    text-align: center;
  }

  .chapter {
    min-height: 150vh;
    padding: 0;
  }

  .chapter__grid {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    align-items: start;
    gap: clamp(1.5rem, 4vw, 4rem);
    min-height: 150vh;
    padding-top: 12vh;
  }

  .chapter:last-of-type,
  .chapter:last-of-type .chapter__grid {
    min-height: 94vh;
  }

  .chapter:last-of-type {
    padding-bottom: 0;
  }

  .chapter__text {
    display: block;
    position: sticky;
    top: max(12vh, calc(var(--nav-h) + 2rem));
  }

  .chapter__kicker {
    margin: 0 0 .75rem;
    font-size: .8rem;
  }

  .chapter__title {
    margin: 0 0 1rem;
    font-size: clamp(1.75rem, 4vw, 3rem);
    line-height: 1.06;
  }

  .chapter__blurb {
    max-width: 42ch;
    margin: 0 0 1rem;
    font-size: 1rem;
    line-height: 1.5;
  }

  .chapter__fact {
    margin: 0;
    color: var(--text);
    font-size: .85rem;
  }

  .chapter__stage {
    position: sticky;
    top: max(12vh, calc(var(--nav-h) + 2rem));
    margin-right: calc(-1 * (var(--gutter) + max(0px, (100vw - var(--maxw)) / 2)));
  }
}

/* ≥ 961px — navigazione orizzontale completa */
@media (min-width: 961px) {
  .nav__toggle {
    display: none;
  }

  .nav__menu {
    position: static;
    display: flex;
    align-items: center;
    gap: clamp(1rem, 2.2vw, 1.75rem);
    max-height: none;
    padding: 0;
    overflow: visible;
    background: none;
    border: 0;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: none;
  }

  .nav__links {
    display: flex;
    gap: clamp(.9rem, 1.8vw, 1.5rem);
  }

  .nav__link {
    min-height: 44px;
    border: 0;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: .78rem;
    font-weight: 400;
    letter-spacing: 0;
  }

  .nav__link:hover,
  .nav__link.is-active {
    color: var(--text);
  }

  .nav__actions {
    flex-wrap: nowrap;
    gap: .6rem;
  }

  .lang__item {
    min-width: 36px;
    min-height: 30px;
    padding: 0 .45rem;
  }

  body.nav-open {
    overflow: auto;
  }
}


/* 16. Movimento ridotto
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }

  .js .reveal {
    opacity: 1;
    transform: none;
  }

  .step__fill--active {
    animation: none;
    transform: scaleX(1);
  }
}
