/* =========================================================
   BASE — token dei due temi, reset, tipografia, bottoni,
   top bar, header, drawer, hero, elementi fluttuanti
   ========================================================= */

/* Font di riserva dimensionati come quelli web: evitano salti di layout al caricamento */
@font-face { font-family: 'Newsreader Fallback'; src: local('Georgia'); size-adjust: 95.8%; }
@font-face { font-family: 'Newsreader Fallback'; font-style: italic; src: local('Georgia Italic'), local('Georgia-Italic'); size-adjust: 87.5%; }
@font-face { font-family: 'Public Sans Fallback'; src: local('Arial'), local('Helvetica'); size-adjust: 104.1%; }

:root {
  color-scheme: light;
  --bg: #FFFFFF;
  --bg-alt: #F3F6F9;
  --surface: #FFFFFF;
  --ink: #13202E;
  --text: #3A4654;
  --muted: #5B6875;
  --line: #DCE2E8;
  --line-strong: #B9C3CD;
  --accent: #1F5F99;
  --accent-hover: #174C7C;
  --accent-soft: #EAF2FA;
  --accent-tint: #D4E4F3;
  --on-accent: #FFFFFF;
  --hero-tint: #EEF4FA;
  --band: #13202E;
  --band-2: #1A2A3B;
  --band-text: #C3CEDA;
  --band-ink: #FFFFFF;
  --band-accent: #8CB8E6;
  --wa: #25D366;
  --wa-hover: #1EBE5D;
  --wa-ink: #0B3D20;
  --danger: #B42318;
  --header-bg: rgba(255, 255, 255, 0.9);
  --shadow-1: 0 1px 2px rgba(19, 32, 46, 0.04), 0 12px 30px -16px rgba(19, 32, 46, 0.2);
  --shadow-2: 0 2px 6px rgba(19, 32, 46, 0.06), 0 28px 56px -24px rgba(19, 32, 46, 0.32);

  --serif: 'Newsreader', 'Newsreader Fallback', Georgia, 'Times New Roman', serif;
  --sans: 'Public Sans', 'Public Sans Fallback', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs-base: 1.0625rem;
  --fs-lead: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  --fs-h2: clamp(1.95rem, 1.4rem + 2.1vw, 2.9rem);
  --fs-h1: clamp(2.4rem, 1.6rem + 3.4vw, 4.1rem);

  --space-section: clamp(4.5rem, 3.5rem + 4vw, 7.5rem);
  --radius: 6px;
  --radius-lg: 12px;
  --header-h: 72px;
  --container: 1240px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F1720;
  --bg-alt: #131E2A;
  --surface: #172331;
  --ink: #EEF2F6;
  --text: #C9D2DC;
  --muted: #A3B0BD;
  --line: #273544;
  --line-strong: #3A4A5B;
  --accent: #8CB8E6;
  --accent-hover: #A9CBEE;
  --accent-soft: #19293A;
  --accent-tint: #22384F;
  --on-accent: #0F1720;
  --hero-tint: #122030;
  --band: #0A1118;
  --band-2: #142231;
  --danger: #F28B82;
  --header-bg: rgba(15, 23, 32, 0.9);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 30px -14px rgba(0, 0, 0, 0.6);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.35), 0 30px 60px -24px rgba(0, 0, 0, 0.75);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0; font-family: var(--sans); font-size: var(--fs-base); line-height: 1.65;
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased;
}
body.is-locked { overflow: hidden; }
img, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { color: var(--ink); margin: 0 0 0.5em; }
h1, h2 { font-family: var(--serif); font-weight: 500; line-height: 1.12; letter-spacing: -0.01em; }
h1 em, h2 em { font-style: italic; color: var(--accent); }
h3, h4 { font-family: var(--sans); font-weight: 600; line-height: 1.3; }
p { margin: 0 0 1em; }
ul, ol, dl, dd { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.icon { width: 1.15em; height: 1.15em; flex-shrink: 0; }
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 20px; }
.visually-hidden { 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; left: 16px; top: -100px; z-index: 1000; background: var(--ink); color: var(--bg); padding: 10px 16px; }
.skip-link:focus { top: 12px; }

.only-dark { display: none !important; }
:root[data-theme="dark"] .only-dark { display: block !important; }
:root[data-theme="dark"] .only-light { display: none !important; }

/* Superficie con profondità, condivisa da card e modulo */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); }

/* Link con sottolineatura che si disegna */
.link { color: inherit; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; padding-bottom: 1px; transition: background-size 320ms var(--ease-out), color 160ms; }
.link:hover { background-size: 100% 1px; color: var(--accent); }

/* ---------- Etichette e titoli ---------- */
.label { font-size: 0.95rem; font-weight: 600; color: var(--accent); margin: 0 0 14px; }
.byline { font-size: 0.95rem; color: var(--muted); margin: 0 0 22px; }
.title { font-size: var(--fs-h2); max-width: 21ch; }

/* ---------- Bottoni ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; padding: 13px 24px; border: 1px solid transparent; border-radius: var(--radius);
  font-weight: 600; font-size: 0.95rem; line-height: 1.2; text-align: center;
  transition: background-color 200ms, color 200ms, border-color 200ms, box-shadow 260ms var(--ease), translate 260ms var(--ease);
}
.btn:hover { translate: 0 -2px; }
.btn:active { translate: 0 0; }
.btn--sm { min-height: 42px; padding: 9px 16px; font-size: 0.9rem; }
.btn--block { width: 100%; }
.btn--primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 10px 22px -12px rgba(31, 95, 153, 0.75); }
.btn--primary:hover { background: var(--accent-hover); box-shadow: 0 16px 28px -14px rgba(31, 95, 153, 0.85); }
.btn--outline { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn--outline:hover { border-color: var(--ink); box-shadow: var(--shadow-1); }
.btn--outline .icon--wa { color: #1A9E4B; }
.btn--light { background: #FFFFFF; color: #13202E; box-shadow: 0 12px 26px -14px rgba(0, 0, 0, 0.6); }
.btn--light:hover { background: #EEF3F8; }
.btn--ghost-light { color: #FFFFFF; border-color: rgba(255, 255, 255, 0.35); }
.btn--ghost-light:hover { border-color: #FFFFFF; background: rgba(255, 255, 255, 0.06); }
.btn--wa { background: var(--wa); color: var(--wa-ink); }
.btn--wa:hover { background: var(--wa-hover); }
.btn .icon--wa { width: 18px; height: 18px; }
.btn--arrow .icon { transition: transform 260ms var(--ease-out); }
.btn--arrow:hover .icon { transform: translateX(4px); }

/* ---------- Top bar ---------- */
.topbar { background: var(--band); color: var(--band-text); font-size: 0.82rem; }
.topbar__inner { display: flex; align-items: center; gap: 4px 24px; min-height: 38px; flex-wrap: wrap; }
.topbar a { display: inline-flex; align-items: center; gap: 7px; color: #E3E9EF; padding: 6px 0; transition: color 160ms; }
.topbar a .icon { width: 14px; height: 14px; color: var(--band-accent); }
.topbar a:hover { color: #FFFFFF; }
.topbar__social { display: inline-flex; gap: 16px; }
.topbar__social a .icon { width: 15px; height: 15px; transition: color 160ms; }
.topbar__social a:hover .icon { color: #FFFFFF; }
.topbar__oam { margin-left: auto; }

/* ---------- Header ---------- */
.header {
  position: sticky; top: 0; z-index: 90; background: var(--header-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line); transition: box-shadow 300ms var(--ease);
}
.header.is-scrolled { box-shadow: 0 10px 30px -18px rgba(19, 32, 46, 0.35); }
.header__inner { display: flex; align-items: center; gap: 12px; height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); min-height: 48px; margin-right: auto; }
.brand__logo { height: 38px; width: auto; transition: transform 300ms var(--ease); }
.header.is-scrolled .brand__logo { transform: scale(0.9); }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; white-space: nowrap; }
.brand__text strong { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
.brand__text small { font-size: 0.75rem; color: var(--muted); }

.nav { display: none; position: relative; }
.nav__list { display: flex; }
.nav__link { position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 0 11px; white-space: nowrap; font-size: 0.9rem; font-weight: 500; color: var(--text); transition: color 160ms; }
.nav__link > span { position: relative; }
.nav__link > span::after { content: ''; position: absolute; left: 0; right: 0; bottom: -7px; height: 2px; border-radius: 2px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform 360ms var(--ease-out); }
.nav.has-indicator .nav__link > span::after { display: none; }
.nav__indicator { position: absolute; left: 0; bottom: 7px; height: 2px; width: 0; border-radius: 2px; background: var(--accent); opacity: 0; pointer-events: none; transition: transform 420ms var(--ease-out), width 420ms var(--ease-out), opacity 240ms; }
.nav__indicator.is-visible { opacity: 1; }
.nav__link:hover { color: var(--ink); }
.nav__link:hover > span::after, .nav__link.is-active > span::after { transform: scaleX(1); }
.nav__link.is-active { color: var(--ink); }
.header__cta { display: none; white-space: nowrap; flex-shrink: 0; }


.theme-toggle { display: inline-grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); transition: border-color 160ms; }
.theme-toggle:hover { border-color: var(--line-strong); }
.theme-toggle .icon { width: 19px; height: 19px; grid-area: 1 / 1; transition: transform 400ms var(--ease-out); }
.theme-toggle:hover .icon { transform: rotate(-20deg); }
.theme-toggle .icon--sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon--sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon--moon { display: none; }
.theme-toggle--labelled { display: inline-flex; gap: 8px; width: auto; padding: 0 14px; font-size: 0.9rem; font-weight: 600; }

.burger { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.burger span { width: 20px; height: 1.5px; background: var(--ink); transition: transform 240ms var(--ease); }
.burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(3.75px) rotate(45deg); }
.burger[aria-expanded="true"] span:nth-child(2) { transform: translateY(-3.75px) rotate(-45deg); }

/* ---------- Drawer mobile ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 110; background: rgba(10, 16, 24, 0.5); opacity: 0; transition: opacity 280ms; }
.drawer-backdrop.is-open { opacity: 1; }
.drawer-layer { position: fixed; inset: 0; z-index: 120; overflow: hidden; pointer-events: none; }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(86vw, 360px); pointer-events: auto;
  background: var(--bg); border-left: 1px solid var(--line); padding: 16px 24px 28px; display: flex; flex-direction: column; overflow-y: auto;
  transform: translateX(100%); visibility: hidden; transition: transform 420ms var(--ease-out), visibility 0s linear 420ms;
}
.drawer.is-open { transform: none; visibility: visible; transition: transform 420ms var(--ease-out); }
.drawer__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.drawer__title { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.drawer__close { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: var(--radius); background: transparent; display: grid; place-items: center; color: var(--ink); }
.drawer__link { display: flex; align-items: center; min-height: 54px; font-family: var(--serif); font-size: 1.35rem; color: var(--ink); border-bottom: 1px solid var(--line); }
.drawer__link::before { content: ''; width: 0; height: 2px; margin-right: 0; background: var(--accent); transition: width 360ms var(--ease-out), margin-right 360ms var(--ease-out); }
.drawer__link.is-active { color: var(--accent); }
.drawer__link.is-active::before { width: 18px; margin-right: 12px; }
.drawer__theme { display: flex; align-items: center; justify-content: space-between; padding: 18px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
.drawer__cta { margin-top: auto; padding-top: 24px; display: grid; gap: 10px; }

/* ---------- Hero ---------- */
.hero { position: relative; padding: clamp(2.5rem, 2rem + 3vw, 5rem) 0 clamp(3rem, 2rem + 3vw, 4.5rem); background: linear-gradient(180deg, var(--hero-tint) 0%, var(--bg) 85%); overflow-x: clip; }
.hero::before { content: ''; position: absolute; right: 0; top: 0; width: 42%; height: 78%; background: linear-gradient(180deg, var(--accent-soft), transparent); border-bottom-left-radius: 120px; pointer-events: none; }
.hero__grid { position: relative; display: grid; gap: 48px; align-items: center; }
.hero__grid > * { min-width: 0; }
.hero__title { font-size: var(--fs-h1); font-weight: 400; letter-spacing: -0.022em; line-height: 1.06; margin-bottom: 18px; }
.hero__title .line { display: block; overflow: hidden; padding-bottom: 0.1em; margin-bottom: -0.1em; }
.hero__title .line > span { display: block; text-wrap: balance; }
.hero__sub { font-family: var(--serif); font-style: italic; font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.55rem); color: var(--ink); line-height: 1.35; margin-bottom: 24px; }
.hero__lead { font-size: var(--fs-lead); max-width: 56ch; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.hero__facts { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 0; margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--line); }
.hero__facts div { padding-right: 28px; }
.hero__facts div + div { padding-left: 28px; border-left: 1px solid var(--line); }
.hero__facts dt { font-family: var(--serif); font-size: 2rem; line-height: 1; color: var(--ink); }
.hero__facts dd { font-size: 0.85rem; color: var(--muted); margin-top: 6px; max-width: 16ch; line-height: 1.4; }

/* Foto con cornice sfalsata */
.framed { position: relative; margin: 0; }
.framed::before { content: ''; position: absolute; inset: 22px -18px 64px 22px; border-radius: var(--radius-lg); background: var(--accent); opacity: 0.9; }
.framed--left::before { inset: 22px 22px 64px -18px; }
.framed__img { position: relative; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-2); background: var(--accent-soft); }
.framed__img img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 22%; }
.framed__img--board img { object-position: 50% 0%; }
.framed figcaption { position: relative; margin-top: 14px; font-size: 0.85rem; color: var(--muted); }
.framed figcaption strong { color: var(--ink); font-weight: 600; }

.hero__media { position: relative; max-width: 500px; width: 100%; justify-self: center; }

.service-index { display: grid; gap: 14px; margin-top: clamp(3rem, 2rem + 3vw, 4.5rem); }
.service-index a {
  position: relative; display: grid; grid-template-columns: 44px 1fr 24px; gap: 2px 12px; align-items: start;
  padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1); color: var(--ink); overflow: hidden;
  transition: translate 300ms var(--ease), box-shadow 300ms var(--ease), border-color 300ms;
}
.service-index a::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform 420ms var(--ease-out); }
.service-index a:hover { translate: 0 -4px; box-shadow: var(--shadow-2); border-color: var(--accent-tint); }
.service-index a:hover::after { transform: scaleX(1); }
.service-index__n { font-family: var(--serif); color: var(--accent); font-size: 1.05rem; grid-row: span 2; padding-top: 4px; }
.service-index__t { font-family: var(--serif); font-size: 1.45rem; line-height: 1.2; }
.service-index__d { font-size: 0.9rem; color: var(--muted); grid-column: 2; }
.service-index__go { grid-row: 1 / span 2; grid-column: 3; align-self: center; color: var(--accent); transition: transform 300ms var(--ease-out); }
.service-index a:hover .service-index__go { transform: translateX(4px); }

/* ---------- Flottanti ---------- */
.wa-float {
  position: fixed; right: 22px; bottom: 22px; z-index: 99; width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center; background: var(--wa); color: #fff;
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.35); transition: background-color 160ms, translate 260ms var(--ease);
}
.wa-float:hover { background: var(--wa-hover); translate: 0 -3px; }
.wa-float .icon { width: 28px; height: 28px; }
.wa-float__tip { position: absolute; right: calc(100% + 12px); top: 50%; transform: translate(6px, -50%); white-space: nowrap; background: var(--ink); color: var(--bg); font-size: 0.85rem; padding: 7px 12px; border-radius: var(--radius); opacity: 0; pointer-events: none; transition: opacity 200ms, transform 300ms var(--ease-out); }
.wa-float:hover .wa-float__tip, .wa-float:focus-visible .wa-float__tip { opacity: 1; transform: translate(0, -50%); }

.to-top { position: fixed; right: 26px; bottom: 92px; z-index: 98; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); display: grid; place-items: center; box-shadow: var(--shadow-1); opacity: 0; visibility: hidden; transform: translateY(10px); transition: opacity 260ms, transform 360ms var(--ease-out), visibility 0s linear 260ms; }
.to-top.is-visible { opacity: 1; visibility: visible; transform: none; transition: opacity 260ms, transform 360ms var(--ease-out); }
.to-top:hover { border-color: var(--ink); }

.mobile-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 97; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--header-bg); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.mobile-bar__btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; border-radius: var(--radius); font-weight: 600; font-size: 0.95rem; }
.mobile-bar__btn--call { background: var(--accent); color: var(--on-accent); }
.mobile-bar__btn--wa { background: var(--wa); color: var(--wa-ink); }

/* ---------- Responsive ---------- */
@media (max-width: 767px) {
  body { padding-bottom: 72px; }
  .wa-float { bottom: 84px; right: 14px; width: 52px; height: 52px; }
  .wa-float__tip { display: none; }
  .to-top { right: 17px; bottom: 146px; }
  .topbar .topbar__hide-sm, .topbar__oam { display: none; }
  .brand__text small { display: none; }
  .hero__actions .btn { width: 100%; }
  .hero__facts { grid-template-columns: repeat(3, 1fr); }
  .hero__facts div { padding-right: 12px; }
  .hero__facts div + div { padding-left: 12px; }
  .hero__facts dt { font-size: 1.6rem; }
  .hero::before { width: 70%; height: 40%; }
  .framed::before { inset: 16px -10px 64px 16px; }
  .framed--left::before { inset: 16px 16px 64px -10px; }
}
@media (min-width: 768px) {
  .container { padding-inline: 32px; }
  .mobile-bar { display: none; }
  .service-index { grid-template-columns: repeat(3, 1fr); gap: 18px; }
}
@media (min-width: 1000px) {
  .hero__grid { grid-template-columns: 7fr 5fr; gap: 80px; }
  .hero__media { justify-self: end; }
}
@media (min-width: 1240px) {
  .nav { display: block; }
  .header__cta { display: inline-flex; }
  .burger { display: none; }
}
