/* Reset moderno e regole di base */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh);
  font-weight: var(--fw-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg, picture { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; }
a { color: var(--primary); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.2; font-weight: var(--fw-bold); letter-spacing: -0.015em; text-wrap: balance; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { text-wrap: pretty; }
::selection { background: var(--primary-soft); color: var(--text); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
/* Titoli che ricevono il focus al cambio di rotta: niente anello */
h1[tabindex="-1"]:focus { outline: none; }

button, a { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

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

#app { min-height: 100dvh; }

.screen {
  width: 100%;
  max-width: var(--col);
  margin-inline: auto;
  min-height: 100dvh;
  padding:
    calc(var(--sp-4) + env(safe-area-inset-top))
    calc(var(--sp-4) + env(safe-area-inset-right))
    calc(var(--sp-4) + env(safe-area-inset-bottom))
    calc(var(--sp-4) + env(safe-area-inset-left));
  animation: screen-in var(--dur) var(--ease-out) backwards;
}
/* Spazio per la .bottom-bar fissa: 48px pulsante + 2 x 12px padding + bordo + margine */
.screen.has-bar { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes fade-in { from { opacity: 0; } }

@media (min-width: 640px) {
  .screen { padding-top: calc(var(--sp-6) + env(safe-area-inset-top)); }
}
@media (prefers-reduced-motion: reduce) {
  .screen { animation-name: fade-in; }
}
