/* ==========================================================================
   Base: reset, elementi comuni, pulsanti, accessibilità
   ========================================================================== */

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--desk);
  color: var(--text);
  font-family: var(--font-brand);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

h1, h2, h3, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, picture { display: block; max-width: 100%; }
.icon { flex: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; }
a { color: var(--gold); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--gold-strong); }
code { font-family: var(--font-mono); font-size: 0.92em; }
strong { font-weight: 600; color: var(--text); }

::selection { background: var(--gold); color: var(--on-gold); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
}

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

.skip-link {
  position: fixed;
  top: 8px; left: 8px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  background: var(--gold);
  color: var(--on-gold);
  font-weight: 600;
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; color: var(--on-gold); }

/* ---------- Pulsanti ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn--sm { min-height: 32px; padding: 6px 12px; font-size: var(--fs-xs); }

.btn--gold { background: var(--gold); color: var(--on-gold); }
.btn--gold:hover { background: var(--gold-strong); color: var(--on-gold); }

.btn--ghost { border: 1px solid var(--line-strong); color: var(--text); }
.btn--ghost:hover { border-color: var(--gold-line); background: var(--gold-soft); color: var(--text); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }
.icon-btn--sm { width: 30px; height: 30px; }
.icon-btn[aria-pressed='true'] { color: var(--gold); }

/* ---------- Chip ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-2);
  line-height: 1.5;
}
.chip--action {
  padding: 7px 14px;
  font-size: var(--fs-sm);
  color: var(--text);
  text-align: left;
  transition: border-color 0.15s, background-color 0.15s;
}
.chip--action:hover { border-color: var(--gold-line); background: var(--gold-soft); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  z-index: 90;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  background: var(--text);
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Fallback senza JavaScript ---------- */

.noscript {
  position: fixed; inset: 0;
  z-index: 200;
  overflow: auto;
  padding: 48px 24px;
  background: var(--ink);
}
.noscript__inner { max-width: 62ch; margin: 0 auto; display: grid; gap: 16px; }
.noscript h2 { font-size: var(--fs-lg); color: var(--gold); margin-top: 16px; }
.noscript li { list-style: disc; margin-left: 1.2em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Chip con sotto-voci (es. Server Side Tracking → Cloud Run, App Engine) */
.chip--group { gap: 8px; padding: 3px 4px 3px 11px; border-color: var(--gold-line); color: var(--text); }
.chips--nested { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chip--sub {
  padding: 1px 8px;
  border: 0;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 11px;
}
