/* =========================================================================
   base.css — reset, tipografia, layout di base, utility
   ========================================================================= */

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

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

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3, h4 {
  line-height: 1.25;
  font-weight: 650;
  color: var(--text);
}

h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-base); }

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

a {
  color: var(--primary-strong);
  text-decoration: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: var(--fs-base);
}

ul { list-style: none; }

img, svg { display: block; max-width: 100%; }

/* --- Layout principale --------------------------------------------------- */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-4);
  padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px) + var(--sp-6) + 28px);
}

/* --- Tipografia di servizio --------------------------------------------- */

.view-title {
  font-size: var(--fs-xl);
  margin-bottom: var(--sp-1);
}

.view-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-soft);
  margin-bottom: var(--sp-4);
}

.section-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: var(--sp-2);
}

.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); }
.text-sm { font-size: var(--fs-sm); }
.text-center { text-align: center; }
.strong { font-weight: 650; color: var(--text); }

/* --- Utility ------------------------------------------------------------- */

.stack > * + * { margin-top: var(--sp-4); }
.stack-sm > * + * { margin-top: var(--sp-2); }
.stack-lg > * + * { margin-top: var(--sp-5); }

.row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.row-wrap { flex-wrap: wrap; }
.grow { flex: 1; }

.hidden { display: none !important; }

.spacer { height: var(--sp-4); }

/* --- Stato di caricamento ----------------------------------------------- */

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-6) var(--sp-4);
  color: var(--text-faint);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Stato vuoto --------------------------------------------------------- */

.empty-state {
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  color: var(--text-faint);
}
.empty-state .empty-icon {
  font-size: 2.4rem;
  margin-bottom: var(--sp-2);
}

/* Accessibilita: focus visibile */
:focus-visible {
  outline: 3px solid var(--primary-soft);
  outline-offset: 2px;
}
