:root {
  /* Sfondo: verde petrolio molto scuro */
  --bg: #061a1c;
  --page-bg: radial-gradient(1100px 620px at 8% -8%, rgba(50, 114, 110, 0.28), transparent 62%),
    radial-gradient(900px 600px at 105% 105%, rgba(24, 80, 57, 0.3), transparent 60%),
    linear-gradient(160deg, #0d2e30 0%, #082022 45%, #04141500 100%), #041415;

  /* Contrasto 1: la sfumatura verde originale (pulsanti, accenti) */
  --accent-1: #32726e;
  --accent-2: #185039;
  --accent: linear-gradient(90deg, var(--accent-1) 0%, var(--accent-2) 100%);
  --accent-soft: rgba(50, 114, 110, 0.22);

  /* Contrasto 2: il beige (testi, titoli) */
  --beige: #f4efe2;
  --beige-strong: #fffdf8;
  --text: var(--beige);
  --text-soft: rgba(244, 239, 226, 0.72);
  --text-mute: rgba(244, 239, 226, 0.5);

  /* Superfici e linee sottili */
  --line: rgba(244, 239, 226, 0.12);
  --line-strong: rgba(244, 239, 226, 0.24);
  --surface: rgba(244, 239, 226, 0.035);
  --surface-2: rgba(244, 239, 226, 0.06);
  --field: rgba(0, 0, 0, 0.22);
  --danger: #e59a8a;

  --font-display: 'Fraunces', 'Georgia', serif;
  --font-body: 'Poppins', system-ui, -apple-system, sans-serif;

  --radius: 16px;
  --container: 1080px;
  --header-h: 68px;

  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  background: var(--page-bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
}

::selection {
  background: var(--accent-1);
  color: var(--beige-strong);
}

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

.display,
.section-title,
.card-title,
.highlight-title,
.skill-title {
  font-family: var(--font-display);
  font-variation-settings: 'SOFT' 50, 'WONK' 0, 'opsz' 144;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.05;
  margin: 0;
  color: var(--beige-strong);
}

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  padding: 0.7em 1.4em;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--beige-strong);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease, filter 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary,
.btn-solid {
  background: var(--accent);
  border-color: rgba(244, 239, 226, 0.14);
  white-space: nowrap;
}

.btn-primary:hover,
.btn-solid:hover {
  filter: brightness(1.15);
}

.btn-primary:disabled,
.btn-solid:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
  filter: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}

.btn-ghost:hover {
  border-color: var(--beige);
  background: var(--surface-2);
}

.btn-sm {
  padding: 0.4em 1em;
  font-size: 0.82rem;
}

.btn-xs {
  padding: 0.3em 0.85em;
  font-size: 0.78rem;
}

/* ---------- Header e menu ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(6, 26, 28, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  color: var(--beige);
  text-decoration: none;
}

.brand svg {
  height: 18px;
  width: auto;
}

.main-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.main-nav > ul {
  display: flex;
  align-items: center;
  gap: 4px;
}

.main-nav a {
  display: block;
  padding: 0.4em 0.9em;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 400;
  font-size: 0.88rem;
  color: var(--text-soft);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.main-nav a:hover,
.main-nav a.is-active {
  color: var(--beige-strong);
  background: var(--surface-2);
}

.has-sub {
  position: relative;
  display: flex;
  align-items: center;
}

.has-sub > a {
  padding-right: 0.3em;
}

.sub-toggle {
  background: none;
  border: 0;
  color: var(--text-soft);
  padding: 6px;
  cursor: pointer;
  display: inline-flex;
}

.sub-toggle svg {
  width: 11px;
  height: 7px;
  transition: transform 0.2s ease;
}

.submenu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 210px;
  padding: 6px !important;
  background: rgba(8, 32, 34, 0.96);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}

/* ponte invisibile per non perdere l'hover tra voce e sottomenu */
.submenu::before {
  content: '';
  position: absolute;
  inset: -10px 0 auto 0;
  height: 10px;
}

.has-sub:hover > .submenu,
.has-sub:focus-within > .submenu,
.has-sub.is-open > .submenu {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.has-sub:hover .sub-toggle svg,
.has-sub.is-open .sub-toggle svg {
  transform: rotate(180deg);
}

.menu-toggle {
  display: none;
  background: none;
  border: 0;
  padding: 10px;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
}

.menu-toggle span {
  display: block;
  width: 22px;
  height: 1.5px;
  background: var(--beige);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.menu-toggle[aria-expanded='true'] span:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}
.menu-toggle[aria-expanded='true'] span:nth-child(2) {
  opacity: 0;
}
.menu-toggle[aria-expanded='true'] span:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

@media (max-width: 760px) {
  .menu-toggle {
    display: flex;
  }

  .main-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(6, 26, 28, 0.97);
    border-bottom: 1px solid var(--line);
    padding: 8px 16px 16px;
    display: none;
  }

  .main-nav.is-open {
    display: block;
  }

  .main-nav > ul {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }

  .has-sub {
    flex-wrap: wrap;
  }

  .has-sub > a {
    flex: 1;
  }

  .submenu {
    position: static;
    flex-basis: 100%;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0 0 0 16px !important;
    display: none;
    opacity: 1;
    visibility: visible;
    transform: none;
  }

  .has-sub.is-open > .submenu {
    display: block;
  }
}

/* ---------- Hero ---------- */
.hero-inner {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  align-items: center;
  gap: 56px;
  padding-top: 96px;
  padding-bottom: 96px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-mute);
  margin: 0 0 22px;
}

.hero .display {
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 1;
}

.payoff {
  margin: 32px 0 0;
  padding-left: 18px;
  border-left: 1px solid var(--accent-1);
  max-width: 34ch;
}

.payoff p {
  margin: 0;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1rem, 1.6vw, 1.15rem);
  line-height: 1.6;
  color: var(--text-soft);
}

.hero-portrait {
  margin: 0;
  justify-self: end;
  width: min(100%, 340px);
}

@media (max-width: 860px) {
  .hero-inner {
    grid-template-columns: 1fr;
    padding-top: 56px;
    padding-bottom: 64px;
    gap: 32px;
  }

  .hero-portrait {
    order: -1;
    width: min(60%, 240px);
    justify-self: center;
  }

  .hero-text {
    text-align: center;
  }

  .payoff {
    margin-left: auto;
    margin-right: auto;
    border-left: 0;
    padding-left: 0;
  }
}

/* ---------- Sezioni ---------- */
.section-title {
  font-size: clamp(1.5rem, 2.6vw, 1.9rem);
  margin-bottom: 22px;
}

.about,
.skills,
.affiliations {
  padding: 72px 0;
  border-top: 1px solid var(--line);
}

.about-inner {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 56px;
  align-items: start;
}

.lead {
  font-size: 1.12rem;
  line-height: 1.65;
  font-weight: 300;
  margin-top: 0;
  color: var(--beige);
}

.lead strong {
  font-weight: 500;
  color: var(--beige-strong);
}

.about-text p:not(.lead) {
  color: var(--text-soft);
}

/* Riquadro con bordo nella sfumatura verde originale */
.highlight {
  border-radius: var(--radius);
  padding: 30px;
  border: 1px solid transparent;
  background: linear-gradient(rgba(8, 32, 34, 0.92), rgba(8, 32, 34, 0.92)) padding-box, var(--accent) border-box;
}

.highlight-label {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.68rem;
  font-weight: 400;
  margin: 0 0 12px;
  color: var(--text-mute);
}

.highlight-title {
  font-size: 1.45rem;
  line-height: 1.15;
  margin-bottom: 14px;
}

.highlight p:not(.highlight-label):not(.highlight-title) {
  font-size: 0.92rem;
  margin: 0 0 22px;
  color: var(--text-soft);
}

@media (max-width: 860px) {
  .about,
  .skills,
  .affiliations {
    padding: 56px 0;
  }
  .about-inner {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

/* ---------- Cosa faccio ---------- */
.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

/* Riquadri separati, come le schede delle realtà in cui lavoro */
.skill {
  padding: 26px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.skill:hover {
  border-color: var(--accent-1);
  background: var(--surface-2);
}

.skill-title {
  font-size: 1.15rem;
}

.skill-title::before {
  content: '';
  display: block;
  width: 22px;
  height: 2px;
  margin-bottom: 14px;
  background: var(--accent);
}

.skill p {
  margin: 8px 0 0;
  font-size: 0.88rem;
  color: var(--text-soft);
}

/* ---------- Le realtà in cui lavoro ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 26px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.card:hover {
  border-color: var(--accent-1);
  background: var(--surface-2);
  transform: translateY(-2px);
}

.card-title {
  font-size: 1.3rem;
}

.card-sub {
  font-size: 0.9rem;
  color: var(--text-soft);
}

.card-url {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-mute);
}

/* ---------- Pagine interne ---------- */
.page-hero {
  padding: 80px 0 40px;
}

/* Titolo allineato alla colonna del testo */
.page-hero .container {
  max-width: 760px;
}

.page-hero .display {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
}

.page-intro {
  font-size: 1.05rem;
  font-weight: 300;
  max-width: 46ch;
  margin: 16px 0 0;
  color: var(--text-soft);
}

.page-intro a {
  color: var(--beige-strong);
}

.prose {
  max-width: 760px;
  padding-top: 32px;
  padding-bottom: 96px;
  margin-left: 0;
  color: var(--text-soft);
}

.page-hero + .prose,
main > .prose {
  margin-left: auto;
  margin-right: auto;
}

.prose h2 {
  font-family: var(--font-display);
  font-variation-settings: 'SOFT' 50, 'WONK' 0, 'opsz' 144;
  font-weight: 500;
  font-size: 1.4rem;
  line-height: 1.2;
  color: var(--beige-strong);
  margin: 44px 0 12px;
}

.prose strong {
  font-weight: 500;
  color: var(--beige);
}

.prose ul {
  padding-left: 1.1em;
}

.prose li {
  margin-bottom: 6px;
}

.prose li::marker {
  color: var(--accent-1);
}

.preview-banner {
  position: relative;
  z-index: 1;
  background: var(--accent-soft);
  color: var(--beige);
  text-align: center;
  font-size: 0.85rem;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--text-mute);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 24px;
  padding-bottom: 24px;
}

.footer-inner p {
  margin: 0;
}

.footer-admin {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.footer-admin form {
  margin: 0;
}

/* ---------- Login ---------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 360px);
  background: rgba(8, 32, 34, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 30px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-card .brand {
  align-self: flex-start;
  margin-bottom: 8px;
}

.brand-lg svg {
  height: 26px;
}

.login-card h1 {
  font-family: var(--font-display);
  font-variation-settings: 'SOFT' 50, 'WONK' 0, 'opsz' 144;
  font-weight: 500;
  font-size: 1.5rem;
  margin: 0 0 8px;
  color: var(--beige-strong);
}

.login-card p {
  color: var(--text-soft);
}

.login-card label {
  font-size: 0.8rem;
  color: var(--text-soft);
}

.login-card input {
  font: inherit;
  padding: 0.65em 0.9em;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--field);
  color: var(--beige);
}

.login-card input:focus {
  outline: 1px solid var(--accent-1);
  border-color: var(--accent-1);
}

.login-card .btn-primary {
  margin-top: 8px;
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.88rem;
}

.form-error:empty {
  display: none;
}

:focus-visible {
  outline: 1px solid var(--beige);
  outline-offset: 3px;
}

/* ---------- Condivisi (admin e consegne) ---------- */
.icon-btn {
  flex-shrink: 0;
  background: none;
  border: 0;
  color: var(--text-mute);
  font-size: 1rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--beige);
}

.file-icon {
  flex-shrink: 0;
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  width: 38px;
  text-align: center;
  padding: 3px 0;
  border-radius: 5px;
  color: var(--beige-strong);
  background: var(--accent);
}

.file-icon[data-kind='pdf'] { background: #9c4434; }
.file-icon[data-kind='word'] { background: #2f5b8f; }
.file-icon[data-kind='excel'] { background: #2b7350; }
.file-icon[data-kind='keynote'] { background: #2a6aa6; }
.file-icon[data-kind='image'] { background: #7a5590; }

/* Footer da admin: scorciatoie raggruppate */
.footer-admin {
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.footer-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.footer-group form {
  margin: 0;
}

.footer-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-mute);
  margin-right: 4px;
}

.btn-hidden {
  border-style: dashed;
}

@media (max-width: 640px) {
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-admin,
  .footer-group {
    align-items: flex-start;
    justify-content: flex-start;
  }
}

/* ---------- Disegni tecnici in vista esplosa (home) ---------- */
.xp {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.xp path,
.xp circle {
  vector-effect: non-scaling-stroke;
}

/* Pezzi pieni con il colore dello sfondo: si coprono come in un disegno tecnico */
.xp-f {
  fill: rgba(6, 26, 28, 0.96);
  stroke: var(--beige);
  stroke-width: 1.1;
  stroke-linejoin: round;
}

.xp-l {
  fill: none;
  stroke: var(--beige);
  stroke-width: 0.9;
  stroke-linejoin: round;
}

.xp-t {
  fill: none;
  stroke: rgba(244, 239, 226, 0.5);
  stroke-width: 0.6;
}

.xp-dash {
  fill: none;
  stroke: rgba(244, 239, 226, 0.35);
  stroke-width: 0.8;
  stroke-dasharray: 3 4;
}

.xp-lead {
  stroke: rgba(244, 239, 226, 0.45);
  stroke-width: 0.7;
}

.xp-dot {
  fill: var(--beige);
}

.xp-co {
  fill: #08201f;
  stroke: var(--accent-1);
  stroke-width: 1.3;
}

.xp-n {
  fill: var(--beige);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: central;
}

/* I pezzi "respirano" lungo l'asse di montaggio */
.xp-part {
  animation: xp-breathe 5s ease-in-out infinite alternate;
}

@keyframes xp-breathe {
  from {
    transform: translateY(0);
  }
  to {
    transform: translate(calc(var(--k) * var(--ax, 0) * 4px), calc(var(--k) * var(--ay, -1) * 4px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .xp-part {
    animation: none;
  }
}

.xp-wrap {
  pointer-events: none;
}

/* La parte alta occupa lo schermo; il microfono sta tra il testo e la foto */
.hero {
  position: relative;
  overflow: hidden;
}

.hero-inner {
  position: relative;
  min-height: min(860px, calc(100vh - var(--header-h)));
  padding-top: 64px;
  padding-bottom: 64px;
}

.hero-text,
.hero-portrait {
  position: relative;
  z-index: 1;
}

.xp-mic {
  position: absolute;
  z-index: 0;
  top: 50%;
  left: 20%;
  width: min(580px, 54%);
  aspect-ratio: 471 / 465;
  transform: translateY(-46%);
}

/* «Cosa faccio»: riquadri 2×2 a sinistra, regia esplosa a destra */
.skills > .container {
  display: grid;
  grid-template-columns: 1fr minmax(300px, 0.8fr);
  column-gap: 48px;
  align-items: center;
}

.skills .section-title {
  grid-column: 1;
  align-self: end;
}

.skills .skill-grid {
  grid-column: 1;
  grid-template-columns: repeat(2, 1fr);
  align-self: start;
}

.xp-regia {
  grid-column: 2;
  grid-row: 1 / span 2;
  aspect-ratio: 384 / 482;
  width: 100%;
}

@media (max-width: 860px) {
  .hero-inner {
    min-height: 0;
  }

  .xp-mic {
    top: 130px;
    left: -24px;
    width: min(340px, 90%);
    transform: none;
    opacity: 0.5;
  }

  .skills > .container {
    grid-template-columns: 1fr;
  }

  .skills .section-title {
    order: -1;
  }

  .xp-regia {
    grid-column: 1;
    grid-row: auto;
    max-width: 420px;
    margin: 0 auto 28px;
  }
}

@media (max-width: 520px) {
  .skills .skill-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Pagine con disegni esplosi accanto al testo ---------- */
.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
  column-gap: 64px;
  align-items: start;
}

.page-grid .prose {
  padding-left: 0;
  padding-right: 0;
  padding-top: 0;
  margin: 0;
}

.page-art {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  display: flex;
  flex-direction: column;
  gap: 48px;
  padding: 72px 0 48px;
}

.page-art .xp-wrap {
  width: 100%;
}

@media (max-width: 860px) {
  .page-grid {
    grid-template-columns: 1fr;
  }

  .page-art {
    position: static;
    order: -1;
    flex-direction: row;
    justify-content: center;
    gap: 16px;
    padding: 32px 0 0;
  }

  .page-art .xp-wrap {
    max-width: 300px;
  }

  .page-grid .page-hero {
    padding-top: 32px;
  }
}

.page-art .xp {
  height: auto;
}
