/* Stili dell'app. Token in tokens.css, font in fonts.css. Mobile first. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--font-ui); font-size: 1rem; line-height: 1.55;
  background: var(--paper); color: var(--ink-soft);
  -webkit-font-smoothing: antialiased;
}
img, svg, video { max-width: 100%; }
a { color: var(--brand-ink); text-underline-offset: .18em; }
a:hover { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
/* Blazor sposta il focus sull'h1 a ogni pagina (per i lettori di schermo): niente riquadro visibile. */
h1:focus, h1:focus-visible { outline: none; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; color: var(--ink); letter-spacing: -.02em; line-height: 1.12; margin: 0; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.6rem); }
h2 { font-size: clamp(1.25rem, 1.1rem + .8vw, 1.6rem); }
h3 { font-size: 1.05rem; letter-spacing: -.01em; }
p { margin: 0 0 1em; max-width: 68ch; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }

/* ---------- struttura ---------- */
.shell { display: flex; flex-direction: column; min-height: 100vh; }
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.page { flex: 1; padding: 32px 0 64px; }
.page.wide .container { max-width: 1280px; }

/* ---------- barra in alto ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .container { display: flex; align-items: center; gap: 20px; min-height: 60px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; color: var(--ink); text-decoration: none; letter-spacing: -.01em; margin-right: auto; }
.brand:hover { color: var(--ink); }
/* Il marchio GECO è scuro: su sfondi scuri sta in una piastrella bianca, ovunque uguale. */
.brand-logo { height: 38px; width: auto; display: block; padding: 4px 6px; background: #fff; border-radius: 9px; box-shadow: 0 0 0 1px rgba(14, 26, 46, .12); }
.topbar nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav-link { color: var(--ink-soft); text-decoration: none; font-size: .95rem; padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 500; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active { color: var(--brand-ink); background: var(--brand-soft); }
.logout-form { display: inline; margin: 0; margin-left: 4px; }
.linkish { background: none; border: 0; font: inherit; font-size: .95rem; font-weight: 500; color: var(--muted); padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer; }
.linkish:hover { background: var(--surface-2); color: var(--ink); }
.admin-badge { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--saffron-soft); color: var(--saffron-ink); }

.footer { border-top: 1px solid var(--line); padding: 20px 0 28px; color: var(--muted); font-size: .875rem; }
.footer .container { display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
.footer a { color: var(--muted); }

/* ---------- bottoni e form ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; min-height: 44px; border-radius: var(--radius-sm);
  border: 1px solid var(--brand); background: var(--brand); color: var(--on-brand); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--on-brand); }
.btn.secondary { background: transparent; color: var(--brand-ink); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-2); color: var(--brand-ink); border-color: var(--line-strong); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: .875rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.on-night { background: var(--saffron); border-color: var(--saffron); color: #2B1E00; }
.btn.on-night:hover { background: #F7C554; border-color: #F7C554; color: #2B1E00; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: .9rem; font-weight: 600; color: var(--ink); }
input[type=text], input[type=email], input[type=password], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); width: 100%;
  padding: 11px 13px; min-height: 44px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
input::placeholder { color: var(--muted); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
select { padding-right: 8px; }
.validation-message, .validation-errors { color: var(--danger-ink); font-size: .875rem; margin: 0 0 12px; padding: 0; list-style: none; }
.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .95rem; }
.alert.error { background: var(--danger-soft); color: var(--danger-ink); }
.alert.ok { background: var(--done-soft); color: var(--done-ink); }
.alert.info { background: var(--info-soft); color: var(--info-ink); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--ink-soft); white-space: nowrap; }
.chip.ok { background: var(--done-soft); color: var(--done-ink); }
.chip.warn { background: var(--warning-soft); color: var(--warning-ink); }
.chip.off { background: var(--danger-soft); color: var(--danger-ink); }
.chip.info { background: var(--info-soft); color: var(--info-ink); }

.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; width: var(--p, 0%); background: var(--saffron); border-radius: 999px; }
.progress.done > span { background: var(--done); }
.on-night .progress, .resume .progress { background: rgba(255,255,255,.16); }

/* ---------- accesso (pannello diviso) ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.auth-side { background: var(--night); color: var(--on-night); padding: 28px 24px 32px; display: flex; flex-direction: column; gap: 20px; }
.auth-side .brand { color: var(--on-night); margin-right: 0; }
.auth-side h2 { color: var(--on-night); font-size: clamp(1.5rem, 1.1rem + 2vw, 2.4rem); max-width: 16ch; }
.auth-side p { color: var(--on-night-muted); margin: 0; max-width: 38ch; }
.auth-copy { display: flex; flex-direction: column; gap: 14px; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px 56px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.9rem; margin-bottom: 8px; }
.auth-card .lead { color: var(--muted); margin-bottom: 24px; }
.auth-card .btn { width: 100%; }
.auth-foot { margin-top: 20px; font-size: .95rem; }
@media (min-width: 900px) {
  .auth { grid-template-columns: minmax(360px, 5fr) 6fr; }
  .auth-side { padding: 44px 48px; justify-content: space-between; }
  .auth-side h2 { margin-top: auto; }
  .auth-side .auth-copy { margin-bottom: 8px; display: flex; flex-direction: column; gap: 16px; }
}

/* ---------- home ---------- */
/* "Riprendi da qui": un fotogramma vero della lezione, non un riquadro decorativo. */
.resume { display: grid; grid-template-columns: 1fr; gap: 20px; margin-bottom: 48px; align-items: center; }
@media (min-width: 760px) { .resume { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 36px; } }
.resume-media { position: relative; display: block; border-radius: var(--radius-md); overflow: hidden; background: var(--night); aspect-ratio: 16 / 9; box-shadow: var(--shadow-md); }
.resume-media img, .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph { display: grid; place-items: center; width: 100%; height: 100%; font-family: var(--font-display); font-weight: 600; font-size: 2rem; color: var(--on-night-muted); background: var(--night); }
.resume-media .play { position: absolute; inset: 0; margin: auto; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: rgba(11, 31, 63, .78); color: #fff; transition: transform .15s, background .15s; }
.resume-media .play svg { width: 26px; height: 26px; margin-left: 3px; }
.resume-media:hover .play { transform: scale(1.06); background: rgba(11, 31, 63, .92); }
.edge { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(255, 255, 255, .28); }
.edge::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--p, 0%); background: var(--saffron); animation: fill .9s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes fill { from { width: 0; } }
.resume-text h1 { font-size: clamp(1.7rem, 1.2rem + 2.2vw, 2.6rem); margin: 4px 0 12px; }
.resume-text .where { color: var(--muted); margin: 0; font-size: .95rem; }
.meta { color: var(--muted); margin: 0 0 20px; }
.resume.done-all { display: block; }
.btn.on-night { background: var(--saffron); border-color: var(--saffron); color: #2B1E00; }
.btn.on-night:hover { background: #F7C554; border-color: #F7C554; color: #2B1E00; }

/* Indice dei moduli, come l'indice di un libro: numero, titolo, una tacca per lezione. */
.index-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 2px solid var(--ink); }
.index-head h2 { font-size: 1.25rem; }
.index { list-style: none; margin: 0; padding: 0; }
.index li { border-bottom: 1px solid var(--line); }
.entry { display: grid; grid-template-columns: 3.4rem minmax(0, 1fr) auto; gap: 8px 16px; align-items: center; padding: 18px 4px; text-decoration: none; color: inherit; }
.entry:hover { background: var(--surface); }
.entry:hover .entry-title { color: var(--brand-ink); }
.entry-num { font-family: var(--font-display); font-weight: 600; font-size: 2.1rem; line-height: 1; color: var(--brand-ink); font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.entry-title { display: block; font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; color: var(--ink); letter-spacing: -.01em; }
.entry-sub { display: block; font-size: .9rem; color: var(--muted); margin-top: 2px; }
.entry.locked .entry-num, .entry.locked .entry-title { color: var(--muted); }
.entry-lock { color: var(--muted); }
@media (max-width: 560px) { .entry { grid-template-columns: 2.6rem minmax(0, 1fr); } .entry .ticks, .entry-lock { grid-column: 2; } .entry-num { font-size: 1.7rem; } }

.ticks { display: inline-flex; gap: 3px; vertical-align: middle; flex-wrap: wrap; }
.ticks i { width: 14px; height: 7px; border-radius: 2px; background: var(--line-strong); }
.ticks i.done { background: var(--done); }
.ticks i.now { background: var(--saffron); }
.ticks i.lock { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }

.empty { text-align: center; padding: 64px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius-md); }
.empty h1 { font-size: 1.6rem; margin-bottom: 8px; }
.empty p { margin: 0 auto; color: var(--muted); }

/* ---------- pagina modulo ---------- */
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: .95rem; margin-bottom: 18px; }
.crumb:hover { color: var(--ink); }
.module-head { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; margin-bottom: 28px; padding-bottom: 20px; border-bottom: 2px solid var(--ink); }
.module-head .entry-num { font-size: 3.6rem; }
.module-head .meta { margin: 10px 0 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .95rem; }
.lessons { list-style: none; margin: 0; padding: 0; }
.lessons li { border-bottom: 1px solid var(--line); }
.lesson-row { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 18px; align-items: center; padding: 16px 4px; text-decoration: none; color: inherit; }
a.lesson-row:hover { background: var(--surface); }
a.lesson-row:hover .title { color: var(--brand-ink); }
.thumb { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); overflow: hidden; background: var(--night); }
.thumb .ph { font-size: 1.15rem; }
.badge { position: absolute; right: 6px; top: 6px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: rgba(11, 31, 63, .8); color: #fff; }
.badge.done { background: var(--done); }
.badge svg { width: 14px; height: 14px; }
.lesson-text .title { display: block; color: var(--ink); font-weight: 600; font-size: 1.05rem; }
.lesson-text .num { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; margin-right: 6px; }
.lesson-text .sub { display: block; color: var(--muted); font-size: .9rem; margin-top: 4px; }
.lessons li.locked .thumb img { filter: grayscale(1); opacity: .45; }
.lessons li.locked .title { color: var(--muted); }
.state { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line-strong); color: transparent; flex: none; }
.state svg { width: 14px; height: 14px; }
.state.done { background: var(--done); border-color: var(--done); color: #fff; }
.state.now { border-color: var(--saffron); background: var(--saffron-soft); color: var(--saffron-ink); }
.state.lock { border-style: dashed; color: var(--muted); }
@media (max-width: 560px) { .lesson-row { grid-template-columns: 112px minmax(0, 1fr); gap: 14px; } }

/* ---------- pagina lezione ---------- */
.lesson-layout { display: grid; grid-template-columns: 1fr; gap: 32px; align-items: start; }
@media (min-width: 1040px) { .lesson-layout { grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; } }
.lesson-no { color: var(--muted); font-size: .95rem; margin: 0 0 6px; }
.lesson-main h1 { margin-bottom: 20px; }
.player-wrap { background: #000; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-md); }
.player-wrap video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.player-bar { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; padding: 14px 0 6px; }
.player-bar .ctl { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); }
.player-bar select { width: auto; min-height: 36px; padding: 4px 8px; font-size: .9rem; }
.player-bar .group { display: flex; gap: 18px; flex-wrap: wrap; }
.lesson-body { margin-top: 24px; }
.lesson-body h2 { font-size: 1.2rem; margin: 28px 0 12px; }
.files { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.file { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); text-decoration: none; color: var(--ink); font-weight: 500; }
.file:hover { border-color: var(--brand); color: var(--brand-ink); }
.file .icon { color: var(--brand-ink); width: 1.4em; height: 1.4em; }
.file .size { margin-left: auto; color: var(--muted); font-weight: 400; font-size: .875rem; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 36px; padding-top: 24px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager a { display: inline-flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink); max-width: 46%; padding: 6px 4px; }
.pager a span.k { color: var(--muted); font-size: .85rem; display: inline-flex; align-items: center; gap: 6px; }
.pager a:hover { color: var(--brand-ink); }
.pager .next { text-align: right; align-items: flex-end; margin-left: auto; }

.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
@media (min-width: 1040px) { .side-card { position: sticky; top: 84px; max-height: calc(100vh - 108px); overflow: auto; } }
.side-card h2 { font-size: 1.1rem; margin-bottom: 4px; }
.side-card .progress { margin: 12px 0 14px; }
.side-list { list-style: none; margin: 0; padding: 0; }
.side-list a { display: grid; grid-template-columns: 24px 1fr; gap: 12px; align-items: center; padding: 10px 8px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink-soft); font-size: .95rem; }
.side-list a:hover { background: var(--surface-2); }
.side-list a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.side-list .n { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; }
.lock-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 48px 28px; text-align: center; }
.lock-panel .state { margin: 0 auto 16px; width: 52px; height: 52px; }
.lock-panel .state svg { width: 22px; height: 22px; }
.lock-panel h2 { margin-bottom: 10px; }
.lock-panel p { margin: 0 auto 20px; color: var(--muted); }

/* ---------- profilo e pagine di servizio ---------- */
.narrow { max-width: 560px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 16px; }
.profile-id { display: flex; align-items: center; gap: 16px; margin: 20px 0 8px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; flex: none; }
.service { max-width: 520px; margin: 12vh auto 0; text-align: center; }
.service h1 { margin-bottom: 12px; }
.service p { margin-left: auto; margin-right: auto; }

/* ---------- admin ---------- */
.page.wide h1 { margin-bottom: 20px; }
.page.wide h2 { margin: 32px 0 12px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 24px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 16px; }
.kpi .v { font-family: var(--font-display); font-weight: 600; font-size: 1.9rem; color: var(--ink); line-height: 1.1; margin-top: 4px; }
.label-geco { font-size: .875rem; color: var(--muted); }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data th { color: var(--muted); font-weight: 600; font-size: .85rem; background: var(--surface-2); white-space: nowrap; }
table.data td input[type=text] { min-width: 150px; }
.mono { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.filters { display: flex; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 14px; align-items: end; }
.filters .field { margin: 0; min-width: 170px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
