/* =============================================================
   Base — Design tokens, reset, typography, buttons, utilities
   ============================================================= */

/* ---------- Design Tokens (Gobid brand-compliant) ---------- */
:root {
  /* Colori brand */
  --color-primary: #007377;        /* Verde Gobid — Pantone 322 C */
  --color-primary-dark: #004F52;   /* tono scuro derivato */
  --color-primary-soft: #E6F2F2;   /* tinta leggera per sfondi */
  --color-primary-tint: rgba(0,115,119,0.08);
  --color-black: #000000;

  /* Scala neutrali */
  --color-bg: #F7F7F4;
  --color-surface: #FFFFFF;
  --color-text: #111111;
  --color-text-muted: #555555;
  --color-border: #E4E4E0;

  /* Stati informativi (non brand, uso solo per feedback funzionale) */
  --color-success: #2E7D32;
  --color-warning: #B45309;
  --color-error: #B00020;

  /* Radius */
  --radius-card: 12px;
  --radius-btn: 8px;
  --radius-pill: 999px;

  /* Ombre */
  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  --shadow-md: 0 8px 24px rgba(0,0,0,.10);

  /* Typography (allineata a matrix-shop) */
  --font-family: "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body:    "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: "Bricolage Grotesque", "Nunito Sans", sans-serif;
  --font-display: "Bricolage Grotesque", "Nunito Sans", sans-serif;
  --font-mono:    "JetBrains Mono", "SF Mono", "Consolas", monospace;

  /* Spacing */
  --section-py-desktop: 96px;
  --section-py-mobile: 56px;
  --container: 1280px;

  /* Logo clearspace (brand manual: 20px digital) */
  --logo-clearspace: 20px;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 70px; }
body {
  margin: 0;
  font-family: var(--font-family);
  font-size: 1.0625rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; height: auto; }
a { color: var(--color-primary); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--color-primary-dark); }
button { font: inherit; cursor: pointer; border: none; background: none; }

/* Screen reader only */
.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 */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 10000;
  background: var(--color-primary); color: #fff; padding: 12px 20px;
  border-radius: 0 0 8px 0; text-decoration: none; font-weight: 700;
}
.skip-link:focus { left: 0; }

/* Focus visible */
:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--color-black);
  margin: 0 0 0.4em;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(36px, 5.5vw, 60px); font-weight: 900; letter-spacing: -0.02em; }
h2 { font-size: clamp(28px, 3.5vw, 42px); font-weight: 800; }
h3 { font-size: clamp(20px, 2vw, 26px); font-weight: 700; }
h4 { font-size: clamp(17px, 1.4vw, 20px); font-weight: 700; }
p { margin: 0 0 1em; }
.eyebrow {
  font-family: var(--font-family); font-size: 0.75rem; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase; color: var(--color-primary);
  margin-bottom: 16px; display: inline-block;
}
.deck { font-size: 1.1875rem; color: var(--color-text-muted); max-width: 720px; }

/* ---------- Container ---------- */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 24px; }
@media (max-width: 640px) { .container { padding: 0 16px; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 16px 32px; min-height: 48px;
  border-radius: var(--radius-btn); font-weight: 700; font-size: 1rem;
  text-decoration: none; cursor: pointer; transition: all .2s ease;
  border: 2px solid transparent;
  letter-spacing: 0.01em;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); color: #fff; }
.btn-secondary { border-color: var(--color-primary); color: var(--color-primary); background: #fff; }
.btn-secondary:hover { background: var(--color-primary); color: #fff; }
.btn-outline-light { border-color: #fff; color: #fff; background: transparent; }
.btn-outline-light:hover { background: #fff; color: var(--color-primary-dark); }
.btn-dark { background: var(--color-black); color: #fff; }
.btn-dark:hover { background: #222; color: #fff; }
.btn-sm { padding: 10px 20px; min-height: 40px; font-size: 0.875rem; }
.btn-xl { padding: 20px 44px; font-size: 1.125rem; }
.btn i { margin-right: 8px; }
.btn i:last-child:not(:first-child) { margin-right: 0; margin-left: 8px; }

/* ---------- Sections ---------- */
section { padding: var(--section-py-desktop) 0; }
@media (max-width: 768px) { section { padding: var(--section-py-mobile) 0; } }
.section-header { text-align: center; max-width: 820px; margin: 0 auto 56px; }
.section-header.left { text-align: left; margin-left: 0; }

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-2 { margin-top: 32px; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .scroll-indicator svg { animation: none; }
}

/* ============== Back to Top ============== */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: var(--color-primary);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0,115,119,0.35), 0 2px 8px rgba(0,0,0,0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity .25s ease, transform .25s ease, visibility .25s, background .4s ease, color .4s ease, box-shadow .4s ease;
  z-index: 90;
}
.back-to-top:hover { background: var(--color-primary-dark); }
.back-to-top.is-on-dark {
  background: #fff;
  color: var(--color-primary-dark);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.2);
}
.back-to-top.is-on-dark:hover { background: var(--color-primary-soft, #e6f2f3); }
.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
@media (max-width: 640px) {
  .back-to-top { bottom: 16px; right: 16px; width: 44px; height: 44px; }
}

/* ============== Mobile bottom nav (immersive edge-to-edge + hex FAB) ============== */
.mobile-nav { display: none; }

@media (max-width: 768px) {
  .mobile-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 110;
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 0 8px env(safe-area-inset-bottom);
    background: #ffffff;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -8px 26px rgba(15, 23, 42, .08);
    align-items: center;
    justify-content: space-around;
  }

  .mnav-item,
  .mnav-item:link,
  .mnav-item:visited,
  .mnav-item:hover,
  .mnav-item:focus {
    position: relative;
    flex: 1 1 0;
    display: inline-flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px;
    height: 52px;
    border-radius: 12px;
    text-decoration: none;
    color: #4b5563;
    -webkit-tap-highlight-color: transparent;
    transition: color .2s ease, transform .15s cubic-bezier(.34, 1.56, .64, 1);
  }
  .mnav-item i {
    font-size: 1.25rem;
    line-height: 1;
    color: inherit;
    transition: color .2s ease, transform .2s ease;
  }
  .mnav-item-label {
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: .2px;
    line-height: 1;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .mnav-item:hover { color: var(--color-primary, #007377); }
  .mnav-item:hover i { transform: translateY(-1px); }
  .mnav-item:active { transform: scale(.92); }
  .mnav-item:focus-visible {
    color: var(--color-primary, #007377);
    outline: 2px solid var(--color-primary, #007377);
    outline-offset: -2px;
  }

  .mnav-spacer {
    flex: 0 0 64px;
    pointer-events: none;
  }

  .mnav-fab {
    position: absolute;
    left: 50%;
    bottom: calc(8px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: 60px; height: 60px;
    background: linear-gradient(160deg, #4dc1c5 0%, var(--color-primary, #007377) 50%, var(--color-primary-dark, #004F52) 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    color: #ffffff;
    z-index: 3;
    -webkit-tap-highlight-color: transparent;
    filter: drop-shadow(0 8px 18px rgba(0, 79, 82, .45)) drop-shadow(0 3px 6px rgba(0, 0, 0, .15));
    transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), filter .25s ease;
  }
  .mnav-fab i {
    font-size: 1.375rem;
    color: #ffffff;
    transition: transform .4s cubic-bezier(.34, 1.56, .64, 1);
  }
  .mnav-fab-logo {
    width: 24px; height: 24px;
    color: #ffffff;
    fill: currentColor;
    transition: transform .4s cubic-bezier(.34, 1.56, .64, 1);
  }
  .mnav-fab:hover {
    transform: translateX(-50%) translateY(-2px);
    filter: drop-shadow(0 12px 22px rgba(0, 79, 82, .55)) drop-shadow(0 5px 10px rgba(0, 0, 0, .18));
  }
  .mnav-fab:active { transform: translateX(-50%) scale(.94); }
  .mnav-fab:focus-visible {
    outline: 2px solid var(--color-primary, #007377);
    outline-offset: 4px;
  }
  .mobile-nav.is-open .mnav-fab i { transform: rotate(135deg); }
  .mobile-nav.is-open .mnav-fab-logo { transform: scale(.92); }

  .mnav-speeddial {
    position: absolute;
    left: 50%;
    bottom: calc(100px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: 240px; height: 64px;
    pointer-events: none;
    z-index: 2;
  }
  .mnav-speeddial-bg {
    position: absolute;
    inset: 0;
    filter:
      drop-shadow(0 10px 28px rgba(0, 50, 53, .45))
      drop-shadow(0 2px 6px rgba(0, 0, 0, .25));
    pointer-events: none;
  }
  .mnav-blob {
    position: absolute;
    top: 50%; left: 50%;
    width: 0; height: 0;
    border-radius: 50%;
    background:
      radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .22) 0%, rgba(255, 255, 255, 0) 50%),
      radial-gradient(circle at 50% 115%, rgba(0, 0, 0, .35) 0%, rgba(0, 0, 0, 0) 62%),
      linear-gradient(160deg, #007074 0%, #004f52 50%, #00383b 100%);
    transform: translate(-50%, 90%) scale(.4);
    transition:
      width .5s cubic-bezier(.34, 1.56, .64, 1),
      height .5s cubic-bezier(.34, 1.56, .64, 1),
      transform .55s cubic-bezier(.34, 1.56, .64, 1);
  }
  /* Pill rettangolare orizzontale — elemento singolo */
  .mnav-blob-pill {
    border-radius: 28px;
  }
  .mobile-nav.is-open .mnav-blob-pill {
    width: 240px; height: 50px;
    transform: translate(-50%, -50%);
    transition-delay: .08s;
  }
  /* Divider verticale al centro della pill */
  .mnav-blob-pill::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1px;
    height: 24px;
    transform: translate(-50%, -50%);
    background: linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0) 0%,
      rgba(255, 255, 255, .32) 50%,
      rgba(255, 255, 255, 0) 100%
    );
    opacity: 0;
    transition: opacity .35s ease .4s;
    pointer-events: none;
  }
  .mobile-nav.is-open .mnav-blob-pill::after {
    opacity: 1;
  }

  .mnav-speeddial-content {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 2;
    pointer-events: none;
  }

  .mnav-action,
  .mnav-action:link,
  .mnav-action:visited {
    position: relative;
    display: inline-flex; flex-direction: row;
    align-items: center; justify-content: center;
    gap: 10px;
    color: #ffffff;
    text-decoration: none;
    pointer-events: none;
    opacity: 0;
    transform: translate(0, 60px) scale(.4) rotate(-90deg);
    -webkit-tap-highlight-color: transparent;
    transition:
      opacity .35s ease,
      transform .55s cubic-bezier(.34, 1.56, .64, 1),
      color .25s ease;
  }
  /* secondo chip in mirror: label sx, icona dx (simmetria della pill) */
  .mnav-speeddial-content .mnav-action:last-child {
    flex-direction: row-reverse;
  }
  .mnav-action-icon {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, .35);
    background:
      radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .18) 0%, rgba(255, 255, 255, 0) 55%),
      linear-gradient(160deg, rgba(255, 255, 255, .10) 0%, rgba(255, 255, 255, .02) 100%);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, .18),
      inset 0 -1px 0 rgba(0, 0, 0, .25),
      0 2px 8px rgba(0, 0, 0, .2);
    transition: background-color .25s ease, border-color .25s ease, box-shadow .25s ease;
  }
  .mnav-action-icon::before {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 1px solid rgba(77, 208, 211, .35);
    opacity: 0;
    transform: scale(.5);
    transition: opacity .3s ease, transform .4s cubic-bezier(.34, 1.56, .64, 1);
    pointer-events: none;
  }
  .mnav-action-icon::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(77, 208, 211, .3) 0%, transparent 70%);
    opacity: 0;
    transition: opacity .3s ease;
    pointer-events: none;
  }
  .mnav-action i {
    font-size: 0.9375rem;
    transition: transform .3s cubic-bezier(.34, 1.56, .64, 1);
  }
  .mnav-action-label {
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: .3px;
    line-height: 1;
    color: rgba(255, 255, 255, .92);
    white-space: nowrap;
    opacity: 0;
    transition: color .25s ease, opacity .12s ease;
  }
  .mobile-nav.is-open .mnav-action .mnav-action-label { opacity: 1; }
  .mnav-action:hover { color: #4dd0d3; }
  .mnav-action:hover .mnav-action-icon {
    background-color: rgba(77, 208, 211, .12);
    border-color: rgba(77, 208, 211, .55);
    box-shadow: 0 0 14px rgba(77, 208, 211, .3);
  }
  .mnav-action:hover .mnav-action-icon::before { opacity: 1; transform: scale(1); }
  .mnav-action:hover .mnav-action-icon::after { opacity: 1; }
  .mnav-action:hover i { transform: scale(1.12) rotate(-6deg); }
  .mnav-action:hover .mnav-action-label { color: #4dd0d3; }
  .mnav-action:active { transform: scale(.92) !important; }

  .mobile-nav.is-open .mnav-action {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
    pointer-events: auto;
  }
  .mobile-nav.is-open .mnav-action .mnav-action-icon {
    animation: mnavActionPulse 2.4s ease-in-out infinite;
  }
  .mobile-nav.is-open .mnav-action:nth-child(1) { transition-delay: .38s; }
  .mobile-nav.is-open .mnav-action:nth-child(2) { transition-delay: .48s; }
  .mobile-nav.is-open .mnav-action:nth-child(3) { transition-delay: .58s; }
  .mobile-nav.is-open .mnav-action:nth-child(1) .mnav-action-label { transition-delay: .85s; }
  .mobile-nav.is-open .mnav-action:nth-child(2) .mnav-action-label { transition-delay: .95s; }
  .mobile-nav.is-open .mnav-action:nth-child(3) .mnav-action-label { transition-delay: 1.05s; }
  .mobile-nav.is-open .mnav-action:nth-child(1) .mnav-action-icon { animation-delay: 0s; }
  .mobile-nav.is-open .mnav-action:nth-child(2) .mnav-action-icon { animation-delay: .3s; }
  .mobile-nav.is-open .mnav-action:nth-child(3) .mnav-action-icon { animation-delay: .6s; }

  @keyframes mnavActionPulse {
    0%, 100% {
      border-color: rgba(255, 255, 255, .35);
      box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .18),
        inset 0 -1px 0 rgba(0, 0, 0, .25),
        0 2px 8px rgba(0, 0, 0, .2),
        0 0 0 0 rgba(77, 208, 211, 0);
    }
    50% {
      border-color: rgba(255, 255, 255, .65);
      box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .28),
        inset 0 -1px 0 rgba(0, 0, 0, .25),
        0 2px 10px rgba(0, 0, 0, .25),
        0 0 12px 0 rgba(77, 208, 211, .35);
    }
  }

  .mnav-fab::after {
    content: "";
    position: absolute;
    left: 50%; top: 50%;
    width: 60px; height: 60px;
    border-radius: 50%;
    border: 2px solid var(--color-primary, #007377);
    transform: translate(-50%, -50%) scale(.5);
    opacity: 0;
    pointer-events: none;
  }
  .mobile-nav.is-open .mnav-fab::after {
    animation: mnavFabRipple .8s cubic-bezier(.22, 1, .36, 1);
  }
  @keyframes mnavFabRipple {
    0%   { opacity: .8; transform: translate(-50%, -50%) scale(.5); }
    100% { opacity: 0;  transform: translate(-50%, -50%) scale(2.4); }
  }

  body { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .back-to-top { bottom: calc(82px + env(safe-area-inset-bottom)) !important; }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-nav, .mnav-item, .mnav-item i,
  .mnav-fab, .mnav-fab i, .mnav-fab::after, .mnav-speeddial,
  .mnav-blob, .mnav-action, .mnav-action::before, .mnav-action::after {
    transition: none !important;
    animation: none !important;
  }
}
