/* ==========================================================================
   Calendario Corsi AI7 - pagina pubblica
   Progettata partendo dal mobile: il desktop e' un miglioramento progressivo.
   ========================================================================== */

@font-face {
  font-family: 'DM Sans';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('../webfonts/dm-sans-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal; font-weight: 500; font-display: swap;
  src: url('../webfonts/dm-sans-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal; font-weight: 600; font-display: swap;
  src: url('../webfonts/dm-sans-latin-600-normal.woff2') format('woff2');
}

:root {
  --brand: #c8102e;
  --brand-scuro: #a50d26;
  --testo: #1b1b26;
  --testo-soft: #6a6a7d;
  --bordo: #e6e6ee;
  --sfondo: #f6f6f9;
  --bianco: #fff;
  --ok: #17996b;
  --ok-soft: #e7f6ef;
  --ambra: #a86b00;
  --ambra-soft: #fdf2dd;
  --rosso-soft: #fdeaee;
  --raggio: 16px;
  --ombra: 0 8px 24px rgba(20,20,40,.06);
  --ombra-hover: 0 16px 36px rgba(20,20,40,.12);
  --ombra-testata: 0 4px 20px rgba(0,0,0,.08);
  --gutter: 16px;
  --tocco: 44px; /* area minima toccabile */
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--testo);
  background: var(--sfondo);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--brand); }

img { max-width: 100%; height: auto; }

.wrap {
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* ---------- Intestazione ---------- */
.testata {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-scuro) 100%);
  color: #fff;
  padding-block: 16px 14px;
  padding-top: max(16px, env(safe-area-inset-top));
}
.testata h1 {
  margin: 0;
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 600;
  letter-spacing: -.01em;
}
.testata .occhiello {
  margin: 0 0 5px;
  font-size: 11.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .82;
}
.testata .intro {
  margin: 7px 0 0;
  font-size: 14.5px;
  opacity: .93;
  max-width: 52ch;
}

/* Riga dell'intestazione: testo a sinistra, accesso riservato a destra */
.testata-riga {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.testata-testo { min-width: 0; flex: 1; }

.btn-admin {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 15px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.4);
  background: rgba(255,255,255,.14);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: transform .15s, background .15s, border-color .15s;
}
.btn-admin:hover { background: rgba(255,255,255,.26); border-color: rgba(255,255,255,.6); color: #fff; }
.btn-admin:active { transform: scale(.96); }

/* Su telefono resta solo l'icona, per non rubare spazio al titolo */
@media (max-width: 560px) {
  .btn-admin { min-width: var(--tocco); padding: 0 12px; }
  .btn-admin span { display: none; }
}

/* ---------- Barra dei filtri ---------- */
.filtri {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid rgba(230,230,238,.6);
  box-shadow: 0 4px 16px rgba(0,0,0,.03);
}

.filtri-scorri {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-block: 11px;
  scroll-snap-type: x proximity;
}
.filtri-scorri::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: var(--tocco);
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid var(--bordo);
  background: var(--bianco);
  color: var(--testo);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  scroll-snap-align: start;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:active { transform: scale(.98); }
.chip .pallino { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.chip.attivo {
  background: var(--chip-colore, var(--brand));
  border-color: var(--chip-colore, var(--brand));
  color: #fff;
}
.chip.attivo .pallino { background: rgba(255,255,255,.85) !important; }

/* Selettore di vista */
.viste {
  display: flex;
  gap: 6px;
  padding-bottom: 11px;
}
.vista-btn {
  flex: 1;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 10px;
  border: 1px solid var(--bordo);
  background: var(--bianco);
  color: var(--testo-soft);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  text-decoration: none;
}
.vista-btn.attivo { background: var(--testo); border-color: var(--testo); color: #fff; }

/* ---------- Navigazione a due mesi ---------- */
.periodo-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}
.periodo-nav .vista-btn { flex: none; min-width: 52px; font-size: 17px; }
.periodo-nav .vista-btn.is-spento {
  opacity: .35;
  pointer-events: none;
}
.periodo-etichetta {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--testo);
}

/* ---------- Contenuto ---------- */
main { padding-block: 20px 40px; padding-bottom: max(40px, env(safe-area-inset-bottom)); }

.sezione-titolo {
  margin: 26px 0 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--testo-soft);
}
.sezione-titolo:first-child { margin-top: 0; }

/* ---------- Scheda lezione ---------- */
.lezioni { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.lezione {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--bianco);
  border: 1px solid transparent; /* Sostituito con un bordo trasparente per bilanciare l'ombra */
  border-left: 5px solid var(--corso-colore, var(--brand));
  border-radius: var(--raggio);
  padding: 14px 15px;
  box-shadow: var(--ombra);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (hover: hover) {
  .lezione:hover {
    transform: translateY(-4px);
    box-shadow: var(--ombra-hover);
  }
}
.lezione.prossima {
  box-shadow: 0 4px 12px rgba(20,20,40,.08), 0 16px 40px rgba(200,16,46,.15);
  border-color: var(--corso-colore, var(--brand));
}
.lezione.annullata { opacity: .62; }
.lezione.annullata .lezione-titolo { text-decoration: line-through; }

.data-blocco {
  flex: none;
  width: 52px;
  text-align: center;
  line-height: 1.1;
  padding-top: 2px;
}
.data-blocco .giorno-num {
  display: block;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -.02em;
}
.data-blocco .giorno-nome {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--testo-soft);
  margin-top: 1px;
}
.data-blocco .mese-nome {
  display: block;
  font-size: 11px;
  color: var(--testo-soft);
  text-transform: uppercase;
}

.lezione-corpo { min-width: 0; flex: 1; }

.lezione-titolo {
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.3;
}
.lezione-eta {
  font-weight: 400;
  color: var(--testo-soft);
  font-size: 14px;
}

.lezione-righe { margin-top: 7px; display: grid; gap: 4px; }
.lezione-riga {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14.5px;
  color: var(--testo-soft);
}
.lezione-riga .ic { width: 15px; flex: none; text-align: center; margin-top: 2px; opacity: .75; }
.lezione-riga a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.lezione-riga strong { color: var(--testo); font-weight: 500; }

.etichette { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.etichetta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: #f0f0f5;
  color: var(--testo-soft);
}
.etichetta.verde { background: var(--ok-soft); color: var(--ok); }
.etichetta.ambra { background: var(--ambra-soft); color: var(--ambra); }
.etichetta.rossa { background: var(--rosso-soft); color: var(--brand); }
.etichetta.oggi  { background: var(--brand); color: #fff; }

.nota {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  background: #f7f7fb;
  font-size: 14px;
  color: var(--testo-soft);
}

/* ---------- Separatore di mese ---------- */
.mese-sep {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 24px 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--testo-soft);
}
.mese-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--bordo);
}

/* ---------- Riquadro pausa ---------- */
.pausa {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--ambra-soft);
  border-radius: var(--raggio);
  padding: 13px 15px;
  font-size: 14.5px;
  color: var(--ambra);
}
.pausa .ic { font-size: 17px; flex: none; }
.pausa strong { display: block; color: #7a4d00; }

/* ---------- Riepilogo orari settimanali ---------- */
.orari { display: grid; gap: 14px; }
.orario-card {
  background: var(--bianco);
  border: 1px solid transparent;
  border-radius: var(--raggio);
  padding: 18px;
  border-top: 4px solid var(--corso-colore, var(--brand));
  box-shadow: var(--ombra);
  transition: transform 0.2s, box-shadow 0.2s;
}
@media (hover: hover) {
  .orario-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ombra-hover);
  }
}
.orario-card h3 { margin: 0 0 3px; font-size: 16.5px; font-weight: 600; }
.orario-card .eta { font-size: 13.5px; color: var(--testo-soft); }
.orario-card .righe { margin-top: 10px; display: grid; gap: 5px; }

.testo-piccolo { font-size: 13px; opacity: .85; }

/* ---------- Stato vuoto ---------- */
.vuoto {
  text-align: center;
  padding: 48px 20px;
  color: var(--testo-soft);
  background: var(--bianco);
  border: 1px solid var(--bordo);
  border-radius: var(--raggio);
}
.vuoto .ic { font-size: 32px; opacity: .4; display: block; margin-bottom: 12px; }

/* ---------- Bottoni ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tocco);
  padding: 0 18px;
  border-radius: 11px;
  border: 1px solid var(--bordo);
  background: var(--bianco);
  color: var(--testo);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-blocco { width: 100%; }

.azioni-fondo { margin-top: 26px; display: grid; gap: 10px; }

/* ---------- Piè di pagina ---------- */
.chiusura {
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--bordo);
  font-size: 14px;
  color: var(--testo-soft);
  text-align: center;
}
.chiusura a { color: var(--brand); }

/* ---------- Vista mensile (solo da tablet in su) ---------- */
.mese-griglia { display: none; }

@media (min-width: 768px) {
  :root { --gutter: 24px; }

  .lezioni { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .orari { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .viste { justify-content: flex-start; padding-bottom: 12px; }
  .vista-btn { flex: none; min-width: 140px; }
  .azioni-fondo { grid-auto-flow: column; justify-content: center; }
  .azioni-fondo .btn { min-width: 220px; }

  .mese-griglia { display: block; }
  .mese-tabella {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: var(--bianco);
    border-radius: var(--raggio);
    overflow: hidden;
    border: 1px solid var(--bordo);
  }
  .mese-tabella th {
    padding: 10px 6px;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--testo-soft);
    border-bottom: 1px solid var(--bordo);
  }
  .mese-tabella td {
    border: 1px solid var(--bordo);
    height: 104px;
    vertical-align: top;
    padding: 6px;
  }
  .mese-tabella td.fuori { background: #fafafc; color: #b9b9c6; }
  .mese-tabella td.oggi { background: #fff7f8; }
  .mese-num { font-size: 12.5px; color: var(--testo-soft); font-weight: 600; }
  .mese-ev {
    display: block;
    margin-top: 4px;
    padding: 3px 6px;
    border-radius: 6px;
    font-size: 11.5px;
    line-height: 1.3;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mese-ev.annullata { text-decoration: line-through; opacity: .6; }
  .mese-pausa {
    display: block;
    font-size: 10.5px;
    font-style: italic;
    color: var(--ambra);
    padding: 2px 4px;
  }
}

@media (min-width: 1000px) {
  .lezioni { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Stampa ---------- */
@media print {
  .filtri, .azioni-fondo { display: none; }
  body { background: #fff; }
  .lezione { break-inside: avoid; }
}
