/* ============================================================
   I AM — Design System
   Unico punto in cui vivono colori, font, spaziature, raggi.
   Cambiare il "look" del sito significa modificare solo questo file.
   ============================================================ */

:root {
  /* --- Colori: solo due, tutto il resto è un'opacità di questi due --- */
  --ink: #222222;
  --paper: #fdfdfd;

  --color-bg: var(--paper);
  --color-surface: var(--paper);
  --color-surface-alt: rgba(34, 34, 34, 0.05);
  --color-text: var(--ink);
  --color-text-muted: rgba(34, 34, 34, 0.6);
  --color-border: rgba(34, 34, 34, 0.15);

  --color-primary: var(--ink);
  --color-primary-dark: var(--ink);
  --color-primary-contrast: var(--paper);

  /* Terracotta: unico colore "di carattere", solo per i dettagli
     (pallino live, marker, risposta giusta, primo posto, focus).
     Mai su superfici grandi o pulsanti: quelli restano neri. */
  --accent: #b8502e;        /* su chiaro — contrasto 4.9:1 */
  --accent-on-dark: #e07a55; /* su #222 — contrasto 4.6:1 */
  --color-accent: var(--accent);
  --color-accent-dark: #a8452a;

  --color-success: var(--ink);
  --color-danger: var(--ink);
  --color-warning: var(--ink);

  /* --- Tipografia ---
     Serif solo per il marchio "I am"; tutto il resto è Inter. */
  --font-logo: 'Times New Roman', Times, serif;
  --font-display: 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2rem;
  --fs-3xl: clamp(2.25rem, 5vw, 3.5rem);
  --fs-4xl: clamp(2.75rem, 7vw, 5.5rem);

  --lh-tight: 1.08;
  --lh-normal: 1.6;

  /* --- Spaziatura (scala 4px) --- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;
  --space-10: clamp(6rem, 14vw, 11rem);

  /* --- Movimento: curva morbida "alla Apple" --- */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* --- Raggi --- */
  --radius-sm: 2px;
  --radius-md: 2px;
  --radius-lg: 2px;
  --radius-full: 999px;

  /* --- Ombre (usate con moderazione) --- */
  --shadow-sm: 0 1px 2px rgba(34, 34, 34, 0.06);
  --shadow-md: 0 4px 16px rgba(34, 34, 34, 0.08);

  /* --- Dimensioni componenti touch-friendly --- */
  --tap-target-min: 44px;
  --header-height: 64px;
  --gutter: clamp(1rem, 4vw, 2.5rem);

  /* --- Breakpoint di riferimento (documentativi: usarli nei commenti
     dei media query, le custom property non funzionano dentro @media) ---
     sm: 480px | md: 768px | lg: 1024px | xl: 1280px */
}

/* Il brand è fissato a questi due colori di proposito: niente inversione
   automatica in modalità scura del sistema, per restare coerenti ovunque. */

/* ============================================================
   Reset minimale
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
}
html { scroll-behavior: smooth; }
/* pulsanti e campi prendono il carattere della pagina (Inter), non quello del browser */
button, input, select, textarea { font-family: inherit; }
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: var(--lh-tight);
  margin: 0 0 var(--space-3) 0;
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-xl); }
p { margin: 0 0 var(--space-4) 0; }
a { color: var(--color-primary); }
::selection { background: var(--accent); color: var(--paper); }
/* contorno ben visibile per chi naviga con la tastiera */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
img { max-width: 100%; display: block; }

/* Nasconde visivamente ma resta leggibile da screen reader (es. h1 sostituito da un logo) */
.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;
}

/* Campo trappola anti-robot: fuori dallo schermo per le persone (e per gli screen reader) */
.field-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ============================================================
   Layout base
   ============================================================ */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ============================================================
   Componenti
   ============================================================ */

/* Bottoni: area minima 44px per essere touch-friendly */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-target-min);
  padding: 0 var(--space-5);
  border-radius: var(--radius-full);
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-base);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { opacity: 0.85; }
.btn-accent { background: var(--ink); color: var(--paper); }
.btn-accent:hover { opacity: 0.85; }
.btn-secondary { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.btn-secondary:hover { background: var(--ink); color: var(--paper); }
/* Su fondo scuro: bottone chiaro con scritta scura */
.btn-light { background: var(--paper); color: var(--ink); }
.btn-light:hover { opacity: 0.88; }
.btn-pill { min-height: 36px; padding: 0 var(--space-4); font-size: var(--fs-sm); }
.btn { transition: transform 0.1s ease, opacity 0.15s ease, background-color 0.25s ease, color 0.25s ease; }

/* Card */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

/* Input */
.field { margin-bottom: var(--space-4); }
.field label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}
.input, select.input {
  width: 100%;
  min-height: var(--tap-target-min);
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--fs-base);
  font-family: var(--font-body);
}
.input:focus, select.input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(34, 34, 34, 0.08);
}
.input { transition: border-color 0.2s, box-shadow 0.2s; }
.input[aria-invalid="true"] { border-color: var(--ink); border-width: 2px; }
textarea.input { padding: var(--space-3) var(--space-4); min-height: 110px; resize: vertical; }
.field__error { margin: var(--space-2) 0 0; font-size: var(--fs-sm); font-weight: 600; }
.field__error::before { content: '↑ '; }
.field-row { display: grid; gap: var(--space-4); }
@media (min-width: 480px) { .field-row { grid-template-columns: 1fr 1fr; } }
@media (min-width: 600px) { .field-row--three { grid-template-columns: 1.3fr 1fr 0.7fr; } }
.btn-block { width: 100%; }

/* Classifica */
.leaderboard {
  list-style: none;
  margin: var(--space-5) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.leaderboard__item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.leaderboard__rank {
  font-weight: 700;
  font-size: var(--fs-lg);
  color: var(--color-text-muted);
  width: 2.5em;
}
.leaderboard__item:first-child .leaderboard__rank { color: var(--color-accent); }
.leaderboard__name { flex: 1; font-weight: 600; }
.leaderboard__points { color: var(--color-primary); font-weight: 600; }

/* Badge (stati: pending / approved / revoked, ecc.) — un solo stile neutro */
.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-text);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.badge-warning, .badge-success, .badge-danger { background: transparent; color: var(--color-text); }

/* Modal (base, usata per popup domande/quiz durante gli eventi) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(34, 34, 34, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-4);
  z-index: 50;
}
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-6);
  width: 100%;
  max-width: 480px;
}

/* A schermi più larghi il modal si comporta da dialog centrato, non da sheet */
@media (min-width: 768px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--radius-lg); }
}
