/* ═══════════════════════════════════════════════════════════════════
   DASHBOARD
═══════════════════════════════════════════════════════════════════ */
/* REGOLA 0 — Dashboard welcome: sfondo piatto, nessun gradiente */
.dash-welcome {
  background: var(--bg-section);
  padding: calc(var(--nav-height) + 48px) 80px 56px;
  position: relative; overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.dash-welcome::before { display: none; }
.dash-welcome::after { display: none; }
.dash-welcome-inner {
  position: relative; z-index: 2;
  display: flex; align-items: flex-end;
  justify-content: space-between; gap: 40px; flex-wrap: wrap;
}
.dash-welcome-text { flex: 1; min-width: 220px; }
.dash-greeting {
  font-family: 'Inter', sans-serif;
  font-size: 12px; font-weight: 700;
  letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--gold); margin-bottom: 10px; opacity: .9;
}
.dash-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(26px, 3.5vw, 42px);
  font-weight: 700; color: #fff; line-height: 1.15; margin-bottom: 10px;
}
.dash-title em { font-style: italic; color: rgba(255,255,255,.8); }
.dash-sub {
  font-family: 'Inter', sans-serif;
  font-size: 14px; color: rgba(255,255,255,.5);
}
.dash-stats {
  display: flex; gap: 32px;
  align-items: flex-end; flex-shrink: 0;
}
.dash-stat { text-align: center; position: relative; }
.dash-stat + .dash-stat::before {
  content: ''; position: absolute;
  left: -16px; top: 20%; bottom: 20%;
  width: 1px; background: rgba(255,255,255,.1);
}
.dash-stat-value {
  font-family: 'Playfair Display', serif;
  font-size: 30px; font-weight: 700;
  color: var(--gold); display: block;
}
.dash-stat-label {
  font-family: 'Inter', sans-serif;
  font-size: 10px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: rgba(255,255,255,.4); margin-top: 4px; display: block;
}

/* Subscription pill */
.sub-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--r-full);
  font-family: 'Inter', sans-serif;
  font-size: 11px; font-weight: 600; margin-top: 14px;
}
.sub-pill.active { background: rgba(13,148,136,.15); color: #0d9488; border: 1px solid rgba(13,148,136,.3); }
.sub-pill.expiring { background: rgba(255,140,0,.15); color: #ff8c00; border: 1px solid rgba(255,140,0,.3); }
.sub-pill.inactive { background: rgba(255,255,255,.08); color: rgba(255,255,255,.5); border: 1px solid rgba(255,255,255,.12); }

/* Hero "Continua" */
.dash-hero-continue { padding: 0 80px; }
.hero-continue-card {
  background: var(--bg-card);
  border-radius: var(--r-md);
  overflow: hidden; display: flex;
  min-height: 210px;
  box-shadow: var(--shadow-xl);
  transform: translateY(-28px);
  border: 1px solid var(--border);
}
.hero-continue-thumb {
  width: 280px; flex-shrink: 0;
  position: relative; overflow: hidden;
}
.hero-continue-thumb-bg { position: absolute; inset: 0; }
.hero-continue-thumb-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 60%, rgba(255,255,255,.04) 100%);
}
.hero-continue-thumb-inner {
  position: relative; z-index: 2;
  padding: 28px 22px; height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.hero-thumb-lang {
  font-family: 'Inter', sans-serif;
  font-size: 9px; font-weight: 700;
  letter-spacing: 2.5px; text-transform: uppercase;
  color: rgba(255,255,255,.65); margin-bottom: 6px;
}
.hero-thumb-title {
  font-family: 'Playfair Display', serif;
  font-size: 17px; font-weight: 700;
  color: #fff; line-height: 1.3;
}
.hero-continue-body {
  flex: 1; padding: 28px 36px;
  display: flex; flex-direction: column;
  justify-content: center; gap: 14px;
}
.hero-continue-eyebrow {
  font-family: 'Inter', sans-serif;
  font-size: 10px; font-weight: 800;
  letter-spacing: 2px; text-transform: uppercase;
  color: var(--primary); display: flex; align-items: center; gap: 8px;
}
.hero-continue-eyebrow::before {
  content: ''; width: 18px; height: 2px;
  background: var(--primary); border-radius: 1px;
}
.hero-continue-title {
  font-family: 'Playfair Display', serif;
  font-size: 20px; font-weight: 600;
  color: var(--text-primary); line-height: 1.3;
}

/* Progress bar premium */
.progress-premium { display: flex; flex-direction: column; gap: 6px; }
.progress-premium-head {
  display: flex; justify-content: space-between; align-items: baseline;
}
.progress-premium-info {
  font-family: 'Inter', sans-serif;
  font-size: 12px; color: var(--text-muted);
}
.progress-premium-pct {
  font-family: 'Playfair Display', serif;
  font-size: 22px; font-weight: 700; color: var(--primary);
}
.progress-premium-track {
  height: 8px; background: var(--bg-warm); border-radius: var(--r-full); overflow: hidden;
}
.progress-premium-bar {
  height: 100%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--primary) 0%, var(--gold) 100%);
  transition: width .8s cubic-bezier(.4,0,.2,1);
  position: relative; overflow: hidden;
}
.progress-premium-bar::after {
  content: ''; position: absolute; top: 0; left: -60%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.4), transparent);
  animation: shimmer 2.5s ease-in-out infinite;
}
@keyframes shimmer { to { left: 120%; } }
.progress-premium-note {
  font-family: 'Inter', sans-serif;
  font-size: 12px; color: var(--primary);
  font-style: italic; font-weight: 500;
}
.hero-continue-actions {
  display: flex; align-items: center; gap: 14px; margin-top: 4px;
}
.btn-resume {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 24px;
  background: var(--gold); color: #0a0a0a;
  border-radius: var(--r-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 700;
  transition: opacity var(--t-base), transform var(--t-fast);
}
.btn-resume:hover { opacity: .88; transform: translateY(-1px); }
.btn-resume-play {
  width: 20px; height: 20px;
  border-radius: 50%; background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center; font-size: 7px;
}
.btn-course-link {
  font-family: 'Inter', sans-serif;
  font-size: 13px; color: var(--text-muted);
  font-weight: 500; transition: color var(--t-fast);
}
.btn-course-link:hover { color: var(--text-primary); }

/* Sezioni dashboard */
.dash-section { padding: 0 80px 48px; }
.dash-section-header {
  display: flex; align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px; gap: 16px;
}
.dash-section-title {
  font-family: 'Playfair Display', serif;
  font-size: 22px; font-weight: 700; color: var(--text-primary);
}
.dash-section-link {
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 600; color: var(--gold-lt);
  white-space: nowrap; transition: opacity var(--t-fast);
}
.dash-section-link:hover { opacity: .75; text-decoration: underline; text-underline-offset: 2px; }

/* Card progressi griglia */
.progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 20px;
}
/* ── pcards-card: stile identico a fan-card (index.html) ── */
.pcards-card {
  background: #111111;                              /* = fan-card bg */
  border-radius: 14px;                              /* = fan-card */
  border: 1px solid rgba(255,255,255,.12);          /* = fan-card */
  box-shadow: 0 8px 32px rgba(0,0,0,.5);            /* = fan-card */
  overflow: hidden; cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  display: flex; flex-direction: column;
}
.pcards-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,.65);          /* = fan-card hover */
  border-color: rgba(255,255,255,.26);
  z-index: 2;
}
/* Thumb: altezza 90px = fan-card-header */
.pcards-thumb {
  height: 90px; position: relative;
  overflow: hidden; flex-shrink: 0;
}
.pcards-thumb-bg { position: absolute; inset: 0; }
.pcards-thumb-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,.3) 100%);
}
.pcards-thumb-footer { position: absolute; bottom: 0; left: 0; right: 0; }
/* Etichetta lingua: = fan-card-level */
.pcards-lang-tag {
  display: inline-block; padding: 0 1rem .75rem;
  font-family: 'Inter', sans-serif;
  font-size: .6rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255,255,255,.65);
}
/* Barra progresso: = fan-card-progress */
.pcards-track { height: 3px; background: rgba(255,255,255,.15); }
.pcards-bar {
  height: 100%;
  background: linear-gradient(90deg, rgba(255,255,255,.5), rgba(255,255,255,.9));
  transition: width .6s ease;
}
/* Body: padding = fan-card-body */
.pcards-body {
  padding: .9rem 1rem; flex: 1;
  display: flex; flex-direction: column; gap: 8px;
}
/* Titolo: = fan-card-title */
.pcards-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: .88rem; font-weight: 700;
  color: #f5f5f5; line-height: 1.35;
}
.pcards-progress-row { display: flex; align-items: center; gap: 10px; }
.pcards-progress-text { flex: 1; }
.pcards-main-track {
  height: 6px; background: rgba(255,255,255,.06);
  border-radius: var(--r-full); overflow: hidden; margin-bottom: 4px;
}
.pcards-main-bar {
  height: 100%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-lt) 100%);
  transition: width .6s ease;
}
.pcards-main-bar.complete { background: linear-gradient(90deg, #10b981, #34d399); }
.pcards-lessons { font-family: 'Inter', sans-serif; font-size: 11px; color: var(--text-muted); }
.pcards-pct {
  font-family: 'Playfair Display', serif;
  font-size: 18px; font-weight: 700;
  color: var(--primary); flex-shrink: 0;
}
.pcards-pct.complete { color: #0d9488; }
.pcards-next { font-family: 'Inter', sans-serif; font-size: 12px; color: var(--primary); font-style: italic; }
.pcards-next.done { color: #0d9488; font-style: normal; font-weight: 600; }
.pcards-last { font-family: 'Inter', sans-serif; font-size: 11px; color: var(--text-muted); }

/* Empty state */
.empty-state {
  text-align: center; padding: 56px 24px;
  background: var(--bg-card);
  border-radius: var(--r-md);
  border: 1px dashed var(--border-mid);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; opacity: .35; }
.empty-state h4 {
  font-family: 'Playfair Display', serif;
  font-size: 20px; font-weight: 700; margin-bottom: 8px;
}
.empty-state p {
  font-family: 'Inter', sans-serif;
  font-size: 14px; color: var(--text-muted);
  max-width: 360px; margin: 0 auto 24px; line-height: 1.65;
}

/* ═══════════════════════════════════════════════════════════════════
   CORSO PAGE — Hero + Sidebar (Coursera layout)
═══════════════════════════════════════════════════════════════════ */
/* REGOLA 0 — Corso hero: sfondo piatto */
.corso-hero-wrap {
  background: var(--bg-section);
  padding: calc(var(--nav-height) + 32px) 80px 40px;
  position: relative; overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.corso-hero-wrap::before { display: none; }
.corso-hero {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 1fr 340px;
  gap: 48px; align-items: start;
  max-width: var(--container); margin: 0 auto;
}
.corso-lang-badge {
  display: inline-flex; align-items: center;
  gap: 8px; margin-bottom: 16px;
}
.corso-lang-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.corso-lang-badge span {
  font-family: 'Inter', sans-serif;
  font-size: 12px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  color: rgba(255,255,255,.8);
}
.corso-hero h1 { color: #fff; margin-bottom: 16px; }
.corso-meta-row {
  display: flex; flex-wrap: wrap;
  gap: 20px; margin-bottom: 20px;
}
.corso-meta-item {
  display: flex; align-items: center; gap: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 13px; color: rgba(255,255,255,.75);
}
.corso-meta-item i { font-size: 12px; color: rgba(255,255,255,.5); }
.corso-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.corso-tag {
  font-family: 'Inter', sans-serif;
  font-size: 11px; font-weight: 600;
  padding: 4px 12px; border-radius: var(--r-full);
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.8);
  border: 1px solid rgba(255,255,255,.15);
}

/* CTA Card */
.corso-cta-card {
  background: var(--bg-white);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  position: sticky; top: calc(var(--nav-height) + 16px);
}
.corso-cta-thumb {
  position: relative; height: 180px;
  display: flex; align-items: center; justify-content: center;
}
.corso-cta-play {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
  backdrop-filter: blur(4px);
  border: 2px solid rgba(255,255,255,.4);
  cursor: pointer; transition: all var(--t-base);
}
.corso-cta-play:hover { background: rgba(255,255,255,.3); transform: scale(1.05); }
.corso-cta-body { padding: 24px; }
.corso-cta-price {
  font-family: 'Playfair Display', serif;
  font-size: 28px; font-weight: 700;
  color: var(--text-primary); margin-bottom: 16px;
}
.corso-cta-features {
  margin: 16px 0; display: flex;
  flex-direction: column; gap: 8px;
}
.corso-cta-features li {
  display: flex; align-items: center; gap: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 13px; color: var(--text-secondary);
}
.corso-cta-features li i { color: var(--success); font-size: 12px; flex-shrink: 0; }

/* Corpo corso */
.corso-body {
  display: grid; grid-template-columns: 1fr 340px;
  gap: 48px; padding: 40px 80px 80px;
  max-width: calc(var(--container) + 160px);
  margin: 0 auto; align-items: flex-start;
}
.corso-main { min-width: 0; }
.corso-sidebar { position: sticky; top: calc(var(--nav-height) + 16px); }

/* Video player */
.video-player-section {
  background: #000; border-radius: var(--r-lg);
  overflow: hidden; margin-bottom: 32px; position: relative;
}
#video-player-section { display: none; }
.video-wrapper { position: relative; aspect-ratio: 16/9; background: #111; }
#vimeo-iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }
.video-player-title {
  padding: 12px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 600;
  color: rgba(255,255,255,.85); background: #111;
}

/* Tabs corso */
.corso-tabs {
  display: flex; border-bottom: 2px solid var(--border);
  margin-bottom: 28px;
}
.corso-tab {
  font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 600;
  color: var(--text-muted); padding: 12px 20px;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  cursor: pointer; transition: color var(--t-fast), border-color var(--t-fast);
  border-top: none; border-left: none; border-right: none;
  background: none;
}
.corso-tab:hover { color: var(--text-primary); }
.corso-tab.active { color: var(--gold); border-bottom-color: var(--gold); font-weight: 700; }

/* Lista lezioni */
#lessons-list { display: flex; flex-direction: column; gap: 2px; }
.lesson-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--r-md);
  cursor: pointer; transition: background var(--t-fast);
}
.lesson-item:hover { background: var(--bg-card-2); }
.lesson-item.active { background: var(--gold-light); }
.lesson-num {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 50%; background: var(--bg-card-2);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Inter', sans-serif;
  font-size: 12px; font-weight: 700; color: var(--text-muted);
}
.lesson-item.completed .lesson-num { background: var(--success); color: #fff; }
.lesson-title {
  flex: 1; font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 500; color: var(--text-primary);
}
.lesson-duration {
  font-family: 'Inter', sans-serif;
  font-size: 12px; color: var(--text-muted);
}
.lesson-lock { color: var(--text-muted); font-size: 12px; }

/* ═══════════════════════════════════════════════════════════════════
   WCAG 2.3.3 — Prefers Reduced Motion
   Disabilita animazioni e transizioni per utenti sensibili al movimento.
═══════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ── Skip Link (WCAG 2.4.1) ─────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--gold, #c9962a);
  color: #0a0a0a;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 20px;
  text-decoration: none;
  z-index: 9999;
  border-radius: 0 0 6px 6px;
  border: 2px solid transparent;
  outline-offset: 0;
}
.skip-link:focus {
  top: 0;
  outline: 2px solid var(--gold-lt, #e8c875);
}

/* ═══════════════════════════════════════════════════════════════════
   VISTA CORSO — SPA in-page
   Animazione: catalogo scende fuori schermo → mazzetto sale dal basso.
═══════════════════════════════════════════════════════════════════ */

/* ── Contenitori vista catalogo / corso ─────────────────────────── */
.catalog-view,
.course-view {
  position: absolute;
  top: 0; left: 0; right: 0;
  /* NO bottom:0 — altezza dal contenuto, non vincolata al wrapper */
  will-change: transform, opacity;
  /* Transizione di base — sovrascritta case-by-case via Web Animations API */
  transition: transform 0.52s cubic-bezier(0.32, 0.72, 0, 1),
              opacity   0.42s cubic-bezier(0.32, 0.72, 0, 1);
}

/* Stato riposo catalogo: piena visibilità */
.catalog-view {
  transform: translateY(0);
  opacity: 1;
  min-height: 100%;
  pointer-events: auto;
}

/* Catalogo esce in basso */
.catalog-view.stack-below {
  transform: translateY(110%);
  opacity: 0;
  pointer-events: none;
  /* height:0 + min-height:0 + overflow:hidden CRITICI:
     transform non rimuove il layout box dal flusso — senza di essi
     il catalogo (migliaia di px di card) contribuisce allo scrollHeight
     del wrapper causando scroll enormi sulla pagina corso.
     min-height:0 è necessario perché la regola base .catalog-view imposta
     min-height:100%, che vince su height:0 nella cascata CSS — quindi senza
     questo override il catalogo rimane alto nel layout e genera spazio nero
     scrollabile sotto il contenuto del corso. */
  height: 0;
  min-height: 0;
  overflow: hidden;
}

/* Corso fuori schermo in ALTO (stato iniziale) */
.course-view.offscreen-bottom {
  transform: translateY(-110%);
  opacity: 0;
  pointer-events: none;
}

/* Corso visibile — scivola giù dal top */
.course-view.slide-in-up {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Corso torna in ALTO */
.course-view.slide-out-down {
  transform: translateY(-110%);
  opacity: 0;
  pointer-events: none;
}

/* ── Mazzetto catalogo — bottom-right, sale dal fondo ─────────── */
.catalog-corner-deck {
  position: fixed;
  bottom: 28px;
  right: 72px;
  z-index: 450;
  /* nascosto di default — sale dal basso via JS */
  transform: translateY(120px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.55s cubic-bezier(0.34, 1.32, 0.64, 1),
              opacity   0.40s ease;
}
.catalog-corner-deck.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Il bottone è completamente trasparente — nessuna cornicetta */
.catalog-corner-deck-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: block;
}
.catalog-corner-deck-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 6px;
  border-radius: 6px;
}
.catalog-corner-deck-btn:active {
  transform: scale(0.93);
  transition: transform 0.1s ease;
}

/* ── Mini-card identiche alle fan-card, scalate al 32% ────────── */
/*
  Ogni .corner-mini-card è una fan-card vera (stesse classi CSS)
  scalate con transform: scale(0.45). Le tre carte si sovrappongono
  in un ventaglio. transform-origin: bottom center.
*/
/*
  Il ventaglio riproduce la disposizione della home page:
  transform-origin al centro-basso (come 50% 115% in index.html),
  rotazioni: -11° -4° +3°, le stesse della sezione catalog-preview.
  A scale(0.45) ogni carta diventa ~90×118px.
  Le carte sono centrate orizzontalmente nel container.
*/
.corner-mini-stack {
  position: relative;
  width: 120px;   /* aumentato da 88px — scala 0.45 invece di 0.32 */
  height: 122px;
}

.corner-mini-card {
  position: absolute;
  bottom: 0;
  left: 50%;
  margin-left: -100px;  /* centra la carta da 200px sull'asse del container */
  width: 200px;
  height: 263px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
  transform-origin: 50% 100%;  /* centro del bordo inferiore — uguale a home */
}

/* Le tre carte a ventaglio — rotazioni identiche a home, scala aumentata a 0.45 */
.corner-mini-card--1 {
  transform: scale(0.45) rotate(-11deg);
  z-index: 1;
  opacity: 0.65;
}
.corner-mini-card--2 {
  transform: scale(0.45) rotate(-4deg);
  z-index: 2;
  opacity: 0.85;
}
.corner-mini-card--3 {
  transform: scale(0.45) rotate(3deg);
  z-index: 3;
}

/* ── Layout wrapper vista corso ─────────────────────────────────── */
.course-view-inner {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  /* padding-top: 0 — il gap sotto la navbar è gestito da
     #glv-dashboard.glv-course-open { padding-top: var(--nav-height) }.
     Non serve aggiungere altro. */
  padding: 0 24px 80px;
}

@media (max-width: 900px) {
  .course-view-inner {
    max-width: 860px;
    padding: 0 16px 56px;
  }
}

/* ── Pellicola lezioni — fixed top-left, speculare al mazzetto bottom-right ── */
.course-sidebar {
  position: fixed;
  top: calc(var(--nav-height) + 28px);
  left: 0;
  width: 260px;
  z-index: 450;
  /* Altezza fissa + scroll indipendente — comportamento tipo YouTube */
  height: calc(100vh - var(--nav-height) - 28px - 24px);
  overflow-y: auto;
  overflow-x: hidden;
  /* Scrollbar sottile */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
  /* entra dall'esterno sinistro — durata identica alla course-view (0.50s) */
  transform: translateX(-120%);
  opacity: 0;
  transition: transform 0.50s cubic-bezier(0, 0, 0.2, 1),
              opacity  0.40s ease;
}
/* Scrollbar WebKit */
.course-sidebar::-webkit-scrollbar { width: 4px; }
.course-sidebar::-webkit-scrollbar-track { background: transparent; }
.course-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
.course-sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }
.course-sidebar.strip-visible {
  transform: translateX(0);
  opacity: 1;
}

/* ── Skeleton pellicola — visibile durante il caricamento dei dati ── */
.film-strip--skeleton {
  padding: 8px 0;
}
.film-frame-skeleton {
  height: 58px;
  background: rgba(255,255,255,0.06);
  border-radius: 6px;
  margin: 4px 10px;
  animation: film-skeleton-pulse 1.5s ease-in-out infinite;
}
.film-frame-skeleton:nth-child(2n)   { animation-delay: .2s;  opacity: .85; }
.film-frame-skeleton:nth-child(3n)   { animation-delay: .4s;  }
.film-frame-skeleton:nth-child(4n)   { animation-delay: .15s; opacity: .7;  }
@keyframes film-skeleton-pulse {
  0%, 100% { opacity: .35; }
  50%       { opacity: .75; }
}

/* ── Risorse da scaricare ─────────────────────────────────────────── */
/* Stile gestito da .lesson-below-section */
#lesson-resources-section {
  margin-top: 0;
  background: none;
  border: none;
  border-radius: 0;
  overflow: visible;
}
.lesson-resources-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.lesson-resources-header svg {
  flex-shrink: 0;
  opacity: 0.7;
}
.lesson-resources-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
}
.lesson-resource-item {
  display: block;
}
.lesson-resource-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  font-size: 0.78rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.18s;
  line-height: 1.35;
}
.lesson-resource-link:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}
.lesson-resource-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.lesson-resource-icon {
  flex-shrink: 0;
  color: var(--accent);
  opacity: 0.85;
}
.lesson-resource-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lesson-resource-ext {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── ESERCIZI SOTTO VIDEO (ora in main area, stile gestito da .lesson-below-section) ── */
#lesson-exercises-section {
  margin-top: 0;
  background: none;
  border: none;
  border-radius: 0;
  overflow: visible;
}
.lesson-exercises-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.lesson-exercises-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
}
.lesson-exercise-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.18s;
}
.lesson-exercise-item:hover {
  background: rgba(255,255,255,0.07);
}
.lesson-exercise-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.lesson-exercise-icon {
  flex-shrink: 0;
  font-size: 0.9rem;
  opacity: 0.7;
}
.lesson-exercise-name {
  flex: 1;
  font-size: 0.78rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.35;
}
.lesson-exercise-btn {
  background: rgba(160,26,54,0.18);
  color: #e8b4be;
  border: 1px solid rgba(160,26,54,0.35);
  border-radius: 12px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.18s, color 0.18s;
  min-height: 24px;
}
.lesson-exercise-btn:hover {
  background: rgba(160,26,54,0.4);
  color: #fff;
}

/* ── TRIGGER CARD TEST ───────────────────────────────────────────────── */
/* La lista viene usata come container flex, non più come <ul> visiva */
.lesson-exercises-list {
  list-style: none;
  margin: 0;
  padding: 8px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Card test — sostituisce il vecchio lesson-exercise-item */
.ex-test-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  text-align: left;
  width: 100%;
}
.ex-test-card:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(201,150,42,0.35);
  transform: translateY(-1px);
}
.ex-test-card:focus-visible {
  outline: 2px solid var(--gold, #c9962a);
  outline-offset: 2px;
}
.ex-test-card-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  line-height: 1;
}
.ex-test-card-content {
  flex: 1;
  min-width: 0;
}
.ex-test-card-title {
  font-family: var(--font-heading, 'Playfair Display', serif);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text, #f5f5f5);
  line-height: 1.3;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ex-test-card-meta {
  font-size: 0.75rem;
  color: rgba(245,245,245,0.5);
  line-height: 1.4;
}
.ex-test-card-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}
/* Badge lingua / livello */
.ex-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  line-height: 1.5;
}
.ex-badge-lingua {
  background: rgba(201,150,42,0.15);
  color: var(--gold-lt, #e8c875);
  border: 1px solid rgba(201,150,42,0.3);
}
.ex-badge-livello {
  background: rgba(255,255,255,0.08);
  color: rgba(245,245,245,0.65);
  border: 1px solid rgba(255,255,255,0.12);
}
/* Bottone start nella card */
.ex-test-start-btn {
  background: var(--gold, #c9962a);
  color: #0a0a0a;
  border: none;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 8px 16px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background 0.2s, transform 0.15s;
  min-height: 36px;
}
.ex-test-start-btn:hover { background: var(--gold-lt, #e8c875); transform: translateY(-1px); }
.ex-test-card:hover .ex-test-start-btn { background: var(--gold-lt, #e8c875); }

/* ── TEASER LOCKED (Cultura → upgrade Linguae) ───────────────────────── */
.ex-locked-teaser {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(201,150,42,.07);
  border: 1px solid rgba(201,150,42,.22);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 4px 0;
}
.ex-locked-icon {
  font-size: 22px;
  flex-shrink: 0;
  opacity: .6;
}
.ex-locked-text {
  flex: 1;
  font-size: 13px;
  color: rgba(245,245,245,.7);
  line-height: 1.5;
}
.ex-locked-text strong { color: rgba(245,245,245,.9); }
.ex-locked-upgrade {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid rgba(201,150,42,.55);
  color: #c9962a;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background .2s, border-color .2s;
}
.ex-locked-upgrade:hover {
  background: rgba(201,150,42,.12);
  border-color: rgba(201,150,42,.8);
}

/* ── INTRO SCREEN ────────────────────────────────────────────────────── */
.ex-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 0 16px;
  max-width: 560px;
  margin: 0 auto;
}
.ex-intro-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  line-height: 1;
}
.ex-intro-title {
  font-family: var(--font-heading, 'Playfair Display', serif);
  font-size: clamp(1.3rem, 4vw, 2rem);
  font-weight: 700;
  color: var(--text, #f5f5f5);
  line-height: 1.25;
  margin: 0 0 10px;
}
.ex-intro-desc {
  font-size: 0.9rem;
  color: rgba(245,245,245,0.6);
  line-height: 1.6;
  margin: 0 0 20px;
  max-width: 440px;
}
/* Stats row */
.ex-intro-stats {
  display: flex;
  gap: 28px;
  justify-content: center;
  margin-bottom: 24px;
}
.ex-intro-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.ex-intro-stat strong {
  font-family: var(--font-heading, 'Playfair Display', serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--gold, #c9962a);
  line-height: 1;
}
.ex-intro-stat span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(245,245,245,0.45);
}
/* Sezioni list nella intro */
.ex-intro-sections {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}
.ex-intro-section-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 14px;
  text-align: left;
}
.ex-intro-sec-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(201,150,42,0.15);
  border: 1px solid rgba(201,150,42,0.3);
  color: var(--gold, #c9962a);
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ex-intro-sec-info { flex: 1; min-width: 0; }
.ex-intro-sec-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text, #f5f5f5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ex-intro-sec-meta {
  font-size: 0.72rem;
  color: rgba(245,245,245,0.45);
  margin-top: 2px;
}
/* Badges nella intro */
.ex-intro-badges {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}
/* Start button nella intro */
.ex-intro-start {
  font-size: 1rem;
  padding: 14px 40px;
  border-radius: 2rem;
}

/* ── TRANSIZIONE DI SEZIONE ──────────────────────────────────────────── */
.ex-section-transition {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 240px;
  gap: 10px;
  padding: 24px 0;
}
.ex-section-transition-num {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold, #c9962a);
  margin-bottom: 4px;
}
.ex-section-transition-name {
  font-family: var(--font-heading, 'Playfair Display', serif);
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  font-weight: 700;
  color: var(--text, #f5f5f5);
  margin: 0 0 6px;
  line-height: 1.2;
}
.ex-section-transition-meta {
  font-size: 0.85rem;
  color: rgba(245,245,245,0.5);
  margin-bottom: 28px;
}

/* ── RISULTATI — estensioni ──────────────────────────────────────────── */
.ex-results-emoji {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 12px;
}
.ex-results-score {
  font-family: var(--font-heading, 'Playfair Display', serif);
  font-size: clamp(3.5rem, 12vw, 5.5rem);
  font-weight: 700;
  color: var(--gold, #c9962a);
  line-height: 1;
  margin-bottom: 0;
}
.ex-results-pct {
  font-size: 0.5em;
  vertical-align: super;
  opacity: 0.7;
}
.ex-results-grade {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text, #f5f5f5);
  margin: 6px 0 4px;
}
.ex-results-msg {
  font-size: 0.9rem;
  color: rgba(245,245,245,0.6);
  margin: 0 0 24px;
}
.ex-results-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* ── EXERCISE RUNNER OVERLAY ─────────────────────────────────────────── */
#glv-exercise-runner {
  position: fixed;
  inset: 0;
  background: var(--dark, #0a0a0a);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#glv-exercise-runner.hidden { display: none; }

.ex-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.ex-close-btn {
  background: none;
  border: none;
  color: rgba(245,245,245,0.55);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  min-width: 32px;
  min-height: 32px;
  transition: color 0.2s;
}
.ex-close-btn:hover { color: #fff; }
.ex-title {
  flex: 1;
  font-family: var(--font-heading, 'Playfair Display', serif);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text, #f5f5f5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ex-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.ex-progress-bar {
  width: 100px;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}
.ex-progress-fill {
  height: 100%;
  background: var(--gold, #c9962a);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.ex-progress-label {
  font-size: 0.72rem;
  color: rgba(245,245,245,0.45);
  white-space: nowrap;
}

.ex-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 24px 24px;
}
.ex-card {
  width: 100%;
  max-width: 680px;
}

/* Sezione/titolo esercizio */
.ex-section-name {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold, #c9962a);
  margin-bottom: 8px;
}
.ex-q-number {
  font-size: 0.75rem;
  color: rgba(245,245,245,0.45);
  margin-bottom: 6px;
}
.ex-instruction {
  font-size: 0.88rem;
  color: rgba(245,245,245,0.7);
  line-height: 1.6;
  margin-bottom: 12px;
  font-style: italic;
}
.ex-context {
  background: rgba(255,255,255,0.05);
  border-left: 3px solid rgba(201,150,42,0.4);
  border-radius: 0 8px 8px 0;
  padding: 14px 18px;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text, #f5f5f5);
  margin-bottom: 20px;
}
.ex-q-text {
  font-family: var(--font-heading, 'Playfair Display', serif);
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 700;
  color: var(--text, #f5f5f5);
  line-height: 1.35;
  margin-bottom: 24px;
}

/* Scelta multipla */
.ex-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.ex-opt {
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 14px 18px;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--text, #f5f5f5);
  text-align: left;
  transition: border-color 0.2s, background 0.2s;
  line-height: 1.4;
}
.ex-opt:hover:not(:disabled) { border-color: rgba(201,150,42,0.4); background: rgba(255,255,255,0.08); }
.ex-opt.correct  { border-color: #3db05b; background: rgba(61,176,91,0.12); color: #6ee48a; }
.ex-opt.wrong    { border-color: #e05050; background: rgba(224,80,80,0.1); color: #f08080; }
.ex-opt:disabled { cursor: default; }

/* Vero / Falso */
.ex-vf-btns { display: flex; gap: 12px; margin-bottom: 24px; }
.ex-vf-btn {
  flex: 1;
  padding: 18px;
  border-radius: 10px;
  border: 1.5px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: var(--text, #f5f5f5);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.ex-vf-btn:hover:not(:disabled) { border-color: rgba(201,150,42,0.4); }
.ex-vf-btn.correct  { border-color: #3db05b; background: rgba(61,176,91,0.15); color: #6ee48a; }
.ex-vf-btn.wrong    { border-color: #e05050; background: rgba(224,80,80,0.12); color: #f08080; }

/* Feedback inline */
.ex-feedback {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 20px;
  display: none;
}
.ex-feedback.show { display: block; }
.ex-feedback.correct { background: rgba(61,176,91,0.12); color: #6ee48a; border: 1px solid rgba(61,176,91,0.3); }
.ex-feedback.wrong   { background: rgba(224,80,80,0.1);  color: #f08080; border: 1px solid rgba(224,80,80,0.25); }

/* Completamento / Cloze fill-in */
.ex-cloze-text {
  font-size: 1rem;
  line-height: 2.2;
  color: var(--text, #f5f5f5);
  margin-bottom: 20px;
}
.ex-cloze-text input.ex-blank {
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(201,150,42,0.5);
  border-radius: 4px;
  color: #fff;
  font-size: 0.92rem;
  padding: 2px 8px;
  width: 120px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.ex-cloze-text input.ex-blank:focus { border-color: var(--gold, #c9962a); }
.ex-cloze-text input.ex-blank.correct { border-color: #3db05b; background: rgba(61,176,91,0.12); }
.ex-cloze-text input.ex-blank.wrong   { border-color: #e05050; background: rgba(224,80,80,0.1); }

/* Cloze scelta multipla — inline select-style */
.ex-cloze-text .ex-inline-select {
  display: inline-block;
  position: relative;
}
.ex-cloze-text .ex-inline-select select {
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(201,150,42,0.5);
  border-radius: 4px;
  color: #fff;
  font-size: 0.88rem;
  padding: 2px 6px;
  cursor: pointer;
  outline: none;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 18px;
}
.ex-cloze-text .ex-inline-select::after {
  content: '▾';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  color: rgba(201,150,42,0.8);
  pointer-events: none;
}
.ex-cloze-text .ex-inline-select select.correct { border-color: #3db05b; background: rgba(61,176,91,0.12); }
.ex-cloze-text .ex-inline-select select.wrong   { border-color: #e05050; background: rgba(224,80,80,0.1); }

/* Drag-and-drop word bank */
.ex-word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  border: 1px dashed rgba(255,255,255,0.12);
  min-height: 42px;
}
.ex-word-chip {
  background: rgba(201,150,42,0.15);
  border: 1px solid rgba(201,150,42,0.35);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.82rem;
  color: var(--gold-lt, #e8b84b);
  cursor: pointer;
  user-select: none;
  transition: background 0.18s, opacity 0.18s;
}
.ex-word-chip:hover { background: rgba(201,150,42,0.28); }
.ex-word-chip.used  { opacity: 0.3; pointer-events: none; }
.ex-drop-target {
  display: inline-block;
  min-width: 90px;
  height: 26px;
  background: rgba(255,255,255,0.07);
  border: 1.5px dashed rgba(201,150,42,0.4);
  border-radius: 4px;
  vertical-align: middle;
  text-align: center;
  line-height: 24px;
  font-size: 0.85rem;
  color: rgba(201,150,42,0.7);
  cursor: pointer;
  transition: background 0.18s;
  padding: 0 6px;
}
.ex-drop-target.filled {
  border-style: solid;
  border-color: rgba(201,150,42,0.6);
  color: var(--gold-lt, #e8b84b);
  background: rgba(201,150,42,0.1);
}
.ex-drop-target.correct { border-color: #3db05b; background: rgba(61,176,91,0.12); color: #6ee48a; }
.ex-drop-target.wrong   { border-color: #e05050; background: rgba(224,80,80,0.1);  color: #f08080; }

/* Abbinamento */
.ex-match-grid { display: flex; gap: 16px; margin-bottom: 24px; }
.ex-match-col  { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.ex-match-item {
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.88rem;
  color: var(--text, #f5f5f5);
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ex-match-item:hover:not(:disabled) { border-color: rgba(201,150,42,0.45); background: rgba(255,255,255,0.08); }
.ex-match-item.selected { border-color: var(--gold, #c9962a); background: rgba(201,150,42,0.1); color: var(--gold-lt, #e8b84b); }
.ex-match-item.matched-correct { border-color: #3db05b; background: rgba(61,176,91,0.12); color: #6ee48a; cursor: default; }
.ex-match-item.matched-wrong   { border-color: #e05050; background: rgba(224,80,80,0.1);  color: #f08080; cursor: default; }

/* Riordino testo */
.ex-reorder-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.ex-reorder-item {
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.88rem;
  color: var(--text, #f5f5f5);
  cursor: grab;
  user-select: none;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  transition: border-color 0.2s, background 0.2s;
  line-height: 1.5;
}
.ex-reorder-item:hover { border-color: rgba(201,150,42,0.35); }
.ex-reorder-item.dragging { opacity: 0.4; cursor: grabbing; }
.ex-reorder-handle { color: rgba(255,255,255,0.25); font-size: 0.9rem; padding-top: 1px; flex-shrink: 0; }
.ex-reorder-item.correct { border-color: #3db05b; background: rgba(61,176,91,0.1); }
.ex-reorder-item.wrong   { border-color: #e05050; background: rgba(224,80,80,0.08); }

/* Risposta aperta */
.ex-open-textarea {
  width: 100%;
  min-height: 140px;
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: var(--text, #f5f5f5);
  font-family: inherit;
  font-size: 0.92rem;
  padding: 12px 16px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.6;
  margin-bottom: 12px;
}
.ex-open-textarea:focus { border-color: rgba(201,150,42,0.6); }

/* Pulsanti azione */
.ex-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.ex-btn-primary {
  background: var(--gold, #c9962a);
  color: #0a0a0a;
  border: none;
  border-radius: 2rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 12px 32px;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.2s, transform 0.15s;
}
.ex-btn-primary:hover { background: var(--gold-lt, #e8b84b); transform: translateY(-1px); }
.ex-btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.ex-btn-secondary {
  background: none;
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: 2rem;
  color: rgba(245,245,245,0.6);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 22px;
  cursor: pointer;
  min-height: 44px;
  transition: border-color 0.2s, color 0.2s;
}
.ex-btn-secondary:hover { border-color: rgba(255,255,255,0.3); color: var(--text, #f5f5f5); }

/* Schermata risultato finale */
.ex-results {
  text-align: center;
  padding: 24px 0;
}
.ex-results-score {
  font-family: var(--font-heading, 'Playfair Display', serif);
  font-size: clamp(3rem, 10vw, 5rem);
  font-weight: 700;
  color: var(--gold, #c9962a);
  line-height: 1;
  margin-bottom: 8px;
}
.ex-results-label {
  font-size: 1rem;
  color: rgba(245,245,245,0.7);
  margin-bottom: 24px;
}
.ex-results-breakdown {
  display: inline-flex;
  gap: 24px;
  padding: 16px 32px;
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  margin-bottom: 32px;
}
.ex-results-stat { text-align: center; }
.ex-results-stat-n { font-size: 1.6rem; font-weight: 700; }
.ex-results-stat-n.c { color: #3db05b; }
.ex-results-stat-n.w { color: #e05050; }
.ex-results-stat-n.s { color: rgba(245,245,245,0.35); }
.ex-results-stat-l { font-size: 0.72rem; color: rgba(245,245,245,0.45); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }



/* ── Tab laterale pellicola — handle per tablet 768-1024px ─────── */
.sidebar-tab {
  display: none; /* nascosta su mobile e desktop */
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 80px;
  background: var(--bg-card, #1c1c1c);
  border: 1px solid rgba(255,255,255,.12);
  border-left: none;
  border-radius: 0 8px 8px 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 4px;
  z-index: 460;
  transition: left 0.50s cubic-bezier(0, 0, 0.2, 1), background 0.2s;
  padding-bottom: 4px;
}
.sidebar-tab:hover,
.sidebar-tab:focus-visible {
  background: #242424;
  outline: none;
}
.sidebar-tab-bar {
  width: 12px;
  height: 2px;
  border-radius: 1px;
  background: rgba(255,255,255,.5);
}
.sidebar-tab-label {
  font-family: 'Inter', sans-serif;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  writing-mode: horizontal-tb;
  margin-top: 2px;
}

/* ── Tablet: 768–1024px ─────────────────────────────────────────── */
@media (min-width: 768px) and (max-width: 1024px) {
  /* Sidebar: side-drawer dal lato sinistro */
  .course-sidebar {
    top: var(--nav-height, 64px) !important;
    left: 0 !important;
    width: 260px !important;
    height: calc(100vh - var(--nav-height, 64px)) !important;
    border-radius: 0 12px 12px 0 !important;
    transform: translateX(-260px) !important;
    opacity: 1 !important;
    bottom: auto !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    flex-direction: column !important;
    z-index: 455 !important;
  }
  .course-sidebar.strip-visible {
    transform: translateX(0) !important;
    opacity: 1 !important;
  }
  /* Backdrop semi-trasparente quando la sidebar è aperta su tablet */
  .course-sidebar.strip-visible::before {
    content: '';
    position: fixed;
    inset: 0;
    left: 260px;
    background: rgba(0,0,0,.35);
    z-index: -1;
    pointer-events: none;
  }
  /* Handle bottom-sheet: nascosto su tablet */
  .course-sheet-handle {
    display: none !important;
  }
  /* Tab laterale: visibile su tablet */
  .sidebar-tab {
    display: flex;
  }
}

/* ── Desktop: >1024px ─────────────────────────────────────────────
   Tab laterale pellicola visibile durante la vista corso,
   speculare al ai-panel-tab sul lato destro.                      */
@media (min-width: 1025px) {
  #glv-dashboard.glv-course-open .sidebar-tab {
    display: flex;
  }
}

/* ── Mobile: <768px ─────────────────────────────────────────────── */
/* Pellicola sotto il video: bottom-sheet gestita dal CSS inline di dashboard.html */

/* .course-back-btn rimosso — navigazione affidata al mazzetto in basso a destra */

/* ── Header corso ───────────────────────────────────────────────── */
.course-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  padding: 24px;
  margin-bottom: 32px;
  transition: background 0.3s ease;
  /* position:sticky rimosso — incompatibile con genitore position:absolute + overflow-x:clip
     (causa sfondamento del layout e sovrapposizione delle viste) */
}

/* Header con gradiente lingua — testo bianco su sfondo scuro */
.course-header--colored {
  border-color: transparent;
}
.course-header--colored .course-title {
  color: #fff;
}
.course-header--colored .course-description {
  color: rgba(255,255,255,0.78);
}
.course-header--colored .course-progress-label span {
  color: rgba(255,255,255,0.70);
}
.course-header--colored .course-progress-bar {
  background: rgba(255,255,255,0.20);
}
.course-header--colored .course-progress-bar__fill {
  background: rgba(255,255,255,0.85);
}
.course-header--colored .streak-badge {
  color: rgba(255,255,255,0.80);
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.20);
}
.course-header--colored .badge--level {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.90);
  border-color: rgba(255,255,255,0.25);
}
.course-header--colored .badge--lang {
  background: rgba(255,255,255,0.20);
  color: #fff;
}

.course-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.course-badges .badge--lang {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--r-full);
  background: var(--primary);
  color: var(--text-primary);
}
.course-badges .badge--level {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--r-full);
  background: var(--bg-card-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-mid);
}

.course-title {
  font-family: var(--font-body);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  margin-bottom: 10px;
}
@media (max-width: 768px) {
  .course-title {
    font-size: 22px;
  }
}

.course-description {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}
@media (max-width: 768px) {
  .course-description {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

.course-meta-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* ── Barra progresso corso ──────────────────────────────────────── */
.course-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 160px;
}

.course-progress-label {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.course-progress-bar {
  height: 4px;
  background: var(--border-mid);
  border-radius: 2px;
  overflow: hidden;
}

.course-progress-bar__fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* ── Streak badge ───────────────────────────────────────────────── */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  border: 1px solid var(--gold-border);
  border-radius: var(--r-full);
  padding: 4px 12px;
  background: var(--gold-light);
  white-space: nowrap;
}

/* Player: spazio sopra rispetto alla card, stesso colonna */
.course-player-section {
  margin-top: 20px;
}

/* ── Barra info lezione sotto il player ────────────────────────── */
.player-meta-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--r-md) var(--r-md);
  min-height: 48px;
  position: relative; /* anchor per pmb-tooltip */
}

.pmb-title {
  flex: 1;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  /* Non troncato */
  white-space: normal;
  word-break: break-word;
}

.pmb-duration {
  flex-shrink: 0;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 0 8px;
}

/* ── Cerchio progresso ─────────────────────────────────────────── */
.pmb-ring-wrap {
  flex-shrink: 0;
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pmb-ring {
  width: 40px;
  height: 40px;
  overflow: visible;
}
.pmb-ring-bg {
  stroke: rgba(255,255,255,0.08);
}
.pmb-ring-fill {
  stroke: var(--gold);
  transition: stroke-dashoffset 0.4s ease, stroke 0.3s ease;
}
/* Verde quando completata */
.pmb-ring-wrap.completed .pmb-ring-fill {
  stroke: #3db05b;
}
.pmb-ring-pct {
  position: absolute;
  font-family: 'Inter', sans-serif;
  font-size: 8.5px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.3px;
  user-select: none;
}

/* ── Pulsante "?" info progresso ──────────────────────────────── */
.pmb-info-btn {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.25);
  background: transparent;
  color: rgba(255,255,255,0.45);
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  align-self: center;
  margin-left: -4px;
}
.pmb-info-btn:hover,
.pmb-info-btn:focus-visible {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(212,175,55,0.08);
  outline: none;
}

/* ── Wrapper pulsante+tooltip ──────────────────────────────────── */
.pmb-info-wrap {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

/* ── Tooltip progresso ─────────────────────────────────────────── */
.pmb-tooltip {
  display: none;
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: min(320px, calc(100vw - 28px));
  background: #1a1a1a;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 16px 16px 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.55);
  z-index: 1200;
  animation: tooltip-in 0.18s ease;
}
.pmb-tooltip.is-open {
  display: block;
}
@keyframes tooltip-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.pmb-tooltip-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.35);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  transition: color 0.15s;
}
.pmb-tooltip-close:hover { color: rgba(255,255,255,0.75); }
.pmb-tooltip-title {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  margin: 0 0 10px;
  padding-right: 20px;
  letter-spacing: 0.01em;
}
.pmb-tooltip-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.pmb-tooltip-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  line-height: 1.45;
}
.pmb-tooltip-list li strong {
  color: rgba(255,255,255,0.85);
  font-weight: 600;
}
.pmb-tooltip-icon {
  flex-shrink: 0;
  font-size: 13px;
  margin-top: 0px;
}
/* Su mobile — evita fuoriuscita a destra */
@media (max-width: 640px) {
  .pmb-tooltip {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(100% + 6px);
    width: calc(100vw - 32px);
  }
  @keyframes tooltip-in {
    from { opacity: 0; transform: translateX(-50%) translateY(6px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
  }
}

/* ── Sezioni sotto il player (materiali + esercizi) ────────────── */
.lesson-below-section {
  margin-top: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  animation: fadeInUp 0.22s ease both;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.lesson-below-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px 9px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.lesson-below-header svg {
  flex-shrink: 0;
  opacity: 0.65;
}

/* ── Pellicola Kodak ────────────────────────────────────────────── */
@keyframes filmStripFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.film-strip {
  background: #0d0d0d;
  border-radius: 8px;
  overflow: hidden;
  margin: 0 0 32px;
  border: 1px solid #1e1e1e;
  animation: filmStripFadeIn 0.25s ease forwards;
}

/* Riga fori superiore/inferiore */
.film-perf-row {
  height: 20px;
  background: #060606;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
  overflow: hidden;
}
.film-hole {
  width: 13px;
  height: 9px;
  border-radius: 2px;
  background: #141414;
  border: 1px solid #1e1e1e;
  flex-shrink: 0;
}

/* Zona frame */
.film-frames {
  padding: 0;
}

/* Singolo fotogramma — bottone cliccabile */
.film-frame-btn {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 100%;
  text-align: left;
  position: relative;
  /* Animazione di entrata stagger */
  opacity: 0;
  transform: translateY(8px);
  transition: background 0.15s ease, opacity 0s, transform 0s;
}
.film-frame-btn.film-frame--revealed {
  opacity: 1;
  transform: translateY(0);
  transition: background 0.15s ease,
              opacity  0.28s ease,
              transform 0.28s cubic-bezier(0, 0, 0.2, 1);
}
.film-frame-btn:hover:not(.film-frame--locked) {
  background: rgba(255,255,255,0.04);
}
.film-frame-btn:hover:not(.film-frame--locked) .film-perf-col {
  border-right-color: var(--gold);
  transition: border-right-color 0.15s ease;
}
.film-frame-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

/* Fori laterali di ogni fotogramma */
.film-perf-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 0 7px;
  background: #060606;
  border-right: 1px solid #161616;
  flex-shrink: 0;
  align-self: stretch;
  transition: border-right-color 0.15s ease;
}
.film-perf-col .film-hole {
  width: 9px;
  height: 6px;
}

/* Numero fotogramma */
.film-frame-num {
  font-family: 'Courier New', 'Courier', monospace;
  font-size: 9px;
  color: #2e2e2e;
  width: 26px;
  text-align: right;
  padding-right: 8px;
  flex-shrink: 0;
  user-select: none;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* Thumbnail con gradiente lingua */
.film-thumb {
  width: 72px;
  height: 46px;
  border-radius: 3px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  margin: 9px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}
.film-thumb-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.18);
}

/* Info testo del fotogramma */
.film-frame-info {
  flex: 1;
  padding: 10px 14px 10px 12px;
  min-width: 0;
}
.film-frame-title {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: rgba(245,245,245,0.88);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
}
.film-frame-meta {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: rgba(245,245,245,0.35);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Badge FREE nella pellicola */
.film-frame-free-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--gold-light);
  border: 1px solid var(--gold-border);
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
  align-self: center;
  margin-right: 14px;
}

/* Varianti di stato fotogramma */
.film-frame-btn.film-frame--locked {
  cursor: default;
}
.film-frame-btn.film-frame--locked .film-frame-title {
  color: rgba(245,245,245,0.28);
}
.film-frame-btn.film-frame--locked .film-thumb {
  opacity: 0.3;
}
.film-frame-btn.film-frame--locked .film-thumb-overlay {
  background: rgba(0,0,0,0.45);
}
.film-frame-btn.film-frame--completed .film-frame-title {
  color: rgba(245,245,245,0.55);
}
/* Checkmark completata: overlay con sfondo verde tenue ben visibile */
.film-frame-btn.film-frame--completed .film-thumb-overlay {
  background: rgba(30, 90, 50, 0.55);
}
.film-frame-btn.film-frame--completed .film-thumb-overlay svg circle {
  fill: rgba(61,176,91,0.35);
}
.film-frame-btn.film-frame--completed .film-thumb-overlay svg path {
  stroke: #5de07a;
  stroke-width: 2.2px;
}
.film-frame-btn.film-frame--selected {
  background: rgba(255,255,255,0.055);
}
.film-frame-btn.film-frame--selected .film-frame-title {
  color: rgba(245,245,245,1);
  font-weight: 600;
}
.film-frame-btn.film-frame--selected .film-thumb {
  transform: scale(1.04);
}

/* Divisore tra fotogrammi */
.film-frame-divider {
  height: 1px;
  background: #161616;
  margin-left: 116px; /* allineato dopo thumb */
}

/* ── Banner lezione bloccata ────────────────────────────────────── */
.locked-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--primary-light);
  border: 1px solid rgba(160,26,54,0.2);
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 12px 2px 116px; /* rientro: allineato con il testo del frame */
  flex-wrap: wrap;
}
.locked-banner__cta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-size: 12px;
  color: var(--gold);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--t-fast);
}
.locked-banner__cta:hover { color: var(--gold-lt); }

/* ── Player Vimeo ───────────────────────────────────────────────── */
.course-player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0d0d0d;
  border-radius: var(--r-md);
  overflow: hidden;
}
/* iframe creato dinamicamente da renderPlayer() */
#vimeo-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ── Wrapper posizionamento relativo per catalog+course ─────────── */
/*
  overflow: clip — come overflow:hidden ma NON crea un nuovo BFC
  né un nuovo scroll container, quindi non blocca lo scroll della pagina.
  Taglia comunque le viste animate che escono dai bordi laterali.
*/
.dash-spa-wrapper {
  position: relative;
  /* NOTA: overflow-x:clip e overflow-x:hidden su questo wrapper creano un nuovo
     containing block per position:fixed in Chrome 120+ (CSS Overflow L3 spec aggiornata).
     Questo rompe navbar, sidebar, modali e qualsiasi fixed element figlio.
     Le animazioni translateY non causano overflow orizzontale, quindi non serve clipping. */
  min-height: calc(100vh - var(--nav-height));
}
/* Quando il corso è aperto il min-height non serve — il contenuto della vista corso
   (position:absolute) determina da solo lo scroll. Senza questo override, il wrapper
   manterrebbe min-height:100vh anche se il corso è più corto, lasciando spazio nero. */
.dash-spa-wrapper.course-open {
  min-height: 0;
  /* Il gap tra navbar e corso è gestito da #glv-dashboard.glv-course-open
     (padding-top ridotto a var(--nav-height)) — nessun margin-top necessario. */
}

/* ── prefers-reduced-motion: disabilita tutte le animazioni ────── */
@media (prefers-reduced-motion: reduce) {
  .catalog-view,
  .course-view,
  .catalog-corner-deck,
  .course-sidebar,
  .film-frame-btn,
  .film-strip {
    transition: none !important;
    animation: none !important;
  }
  /* Mostra subito pellicola e fotogrammi senza animazioni */
  .course-sidebar { opacity: 1 !important; transform: translateX(0) !important; }
  .film-frame-btn { opacity: 1 !important; transform: none !important; }
  .course-progress-bar__fill { transition: none !important; }
}

/* ══ RIPRENDI CARD ════════════════════════════════════════════════ */
.riprendi-section {
  /* Sfondo oro + bordo — identifica visivamente la sezione "Continua" */
  background: rgba(201,150,42,0.10);
  border: 1px solid rgba(201,150,42,0.22);
  border-radius: var(--r-lg);
  padding: 20px 32px 24px;
  max-width: 1200px;
  margin: 0 auto 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.riprendi-section.hidden { display: none; }

/* Header titolo */
.riprendi-section-header {
  display: flex;
  align-items: center;
}
.riprendi-section-title {
  font-family: var(--font-heading, 'Playfair Display', serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gold-lt, #e8c875);
  margin: 0;
  letter-spacing: .01em;
}

/* Body: row con skeleton + card + progress widget */
.riprendi-section-body {
  display: flex;
  gap: 16px;
  align-items: stretch;
  min-width: 0;
}

/* Stato scheletro mentre i dati si caricano — riserva lo spazio
   evitando il layout shift quando la card appare */
.riprendi-section.riprendi-loading {
  display: flex;   /* visibile subito, ma contenuto trasparente */
}
.riprendi-section.riprendi-loading .riprendi-card {
  pointer-events: none;
}
.riprendi-skeleton {
  flex: 1;
  min-height: 90px;
  border-radius: var(--r-lg);
  background: var(--dark-2);
  border: 1px solid rgba(255,255,255,.06);
  overflow: hidden;
  position: relative;
}
.riprendi-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,.04) 50%,
    transparent 100%
  );
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%);  }
}

.riprendi-card {
  position: relative;
  flex: 0 0 260px;   /* larghezza fissa — non cresce, non si restringe */
  min-width: 260px;
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--dark-2);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .2s ease, transform .15s ease;
  min-height: 90px;
  scroll-snap-align: start;
}
.riprendi-card:hover {
  border-color: rgba(255,255,255,.18);
  transform: translateY(-1px);
}
.riprendi-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.riprendi-gradient {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  border-radius: var(--r-lg) 0 0 var(--r-lg);
}

.riprendi-body {
  flex: 1;
  min-width: 0;
  padding-left: 10px;
}
.riprendi-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}
.riprendi-course {
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.riprendi-lesson {
  font-size: .97rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}
.riprendi-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.riprendi-progress-bar {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,.1);
  border-radius: 2px;
  overflow: hidden;
}
.riprendi-progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  transition: width .4s ease;
}
.riprendi-progress-pct {
  font-size: .72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.riprendi-cta {
  font-size: 1.3rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color .15s, transform .15s;
}
.riprendi-card:hover .riprendi-cta {
  color: var(--gold);
  transform: translateX(3px);
}

/* ── Global Progress Widget ────────────────────────────────── */
.global-progress-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--dark-2);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--r-lg);
  padding: 18px 28px;
  min-width: 180px;
  flex-shrink: 0;
}
.global-progress-widget.hidden { display: none; }

.gp-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.gp-num {
  font-size: 1.3rem;
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--text);
}
.gp-label {
  font-size: .72rem;
  color: var(--text-muted);
  letter-spacing: .04em;
  text-align: center;
}
.gp-divider {
  width: 32px;
  height: 1px;
  background: rgba(255,255,255,.08);
}

/* ══ FILTRO/RICERCA CATALOGO ══════════════════════════════════════ */
.course-filter-bar {
  padding: 0 48px;
  max-width: 1200px;
  margin: 0 auto 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.course-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.course-search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}
.course-search-input {
  width: 100%;
  max-width: 420px;
  padding: 10px 36px 10px 38px;
  background: var(--dark-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .9rem;
  outline: none;
  transition: border-color .2s;
}
.course-search-input:focus {
  border-color: rgba(255,255,255,.25);
}
.course-search-input::placeholder { color: var(--text-muted); }
.course-search-clear {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.course-search-clear:hover { color: var(--text); }
.course-search-clear.hidden { display: none; }

.course-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.filter-chip {
  padding: 5px 14px;
  background: var(--dark-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: .8rem;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.filter-chip:hover {
  border-color: rgba(255,255,255,.2);
  color: var(--text);
}
.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.filter-chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ══ OVERLAY PROSSIMA LEZIONE ════════════════════════════════════ */
.next-lesson-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10,10,10,.88);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--r-md);
  animation: nlo-in .25s ease;
}
.next-lesson-overlay.hidden { display: none; }

@keyframes nlo-in {
  from { opacity: 0; transform: scale(.97); }
  to   { opacity: 1; transform: scale(1); }
}

.nlo-inner {
  text-align: center;
  padding: 24px 32px;
  max-width: 320px;
}
.nlo-check {
  margin-bottom: 12px;
}
.nlo-label {
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #3db05b;
  margin-bottom: 10px;
}
.nlo-next-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.4;
}
.nlo-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.nlo-btn-next {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.nlo-btn-next:hover { background: #c02040; }
.nlo-countdown {
  font-size: .78rem;
  opacity: .7;
}
.nlo-btn-dismiss {
  background: none;
  border: 1px solid rgba(255,255,255,.15);
  color: var(--text-muted);
  border-radius: var(--r-sm);
  width: 36px; height: 36px;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nlo-btn-dismiss:hover {
  border-color: rgba(255,255,255,.3);
  color: var(--text);
}

/* Nascondi scrollbar del container riprendi-cards */
#riprendi-cards::-webkit-scrollbar { display: none; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .riprendi-section { padding: 0 16px; flex-direction: column; }
  .riprendi-card { flex: 0 0 220px; min-width: 220px; } /* più strette su tablet */
  .global-progress-widget {
    flex-direction: row;
    min-width: auto;
    padding: 14px 20px;
    justify-content: space-around;
  }
  .gp-divider { width: 1px; height: 32px; }
  .course-filter-bar { padding: 0 16px; }
  .course-search-input { max-width: 100%; }
}
@media (max-width: 480px) {
  .riprendi-card { flex: 0 0 200px; min-width: 200px; } /* mobile stretto */
}

/* ══ COURSE TITLE ROW ════════════════════════════════════════════ */
.course-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.course-title-row .course-title { margin-bottom: 0; }


/* ══════════════════════════════════════════════════════════════════
   AI PANEL — Tutor + Quiz  (v1.0)
   Desktop: sidebar fissa a destra speculare al film strip
   Mobile: FAB + bottom-drawer
══════════════════════════════════════════════════════════════════ */

/* ── Pannello principale ─────────────────────────────────────────── */
.ai-panel {
  position: fixed;
  top: calc(var(--nav-height) + 28px);
  right: max(16px, env(safe-area-inset-right, 0px) + 16px);
  width: 300px;
  height: calc(100vh - var(--nav-height) - 28px - 24px);
  z-index: 450;
  background: #141414;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Slide in da destra */
  transform: translateX(calc(100% + 40px));
  opacity: 0;
  transition: transform 0.44s cubic-bezier(0, 0, 0.2, 1),
              opacity  0.30s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}
.ai-panel.ai-panel--visible {
  transform: translateX(0);
  opacity: 1;
}

/* ── Toggle tab (speculare al sidebar-tab, incollato al lato sinistro del pannello) */
.ai-panel-tab {
  display: none; /* mostrato via media query */
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 80px;
  background: var(--bg-card, #1c1c1c);
  border: 1px solid rgba(255,255,255,.12);
  border-right: none;
  border-radius: 8px 0 0 8px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 4px;
  z-index: 460;
  transition: right 0.35s cubic-bezier(0, 0, 0.2, 1), background 0.2s;
  padding-bottom: 4px;
}
.ai-panel-tab:hover,
.ai-panel-tab:focus-visible {
  background: #242424;
  outline: none;
}
.ai-panel-tab-bar {
  width: 12px; height: 2px; border-radius: 1px;
  background: rgba(255,255,255,.5);
}
.ai-panel-tab-label {
  font-family: 'Inter', sans-serif;
  font-size: 7px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: rgba(255,255,255,.35);
  writing-mode: horizontal-tb;
  margin-top: 2px;
}

/* ── Tab bar interna (Tutor / Quiz) ─────────────────────────────── */
.ai-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.ai-tab-btn {
  flex: 1;
  padding: 12px 8px;
  font-family: 'Inter', sans-serif;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: rgba(245,245,245,.45);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color .2s, background .2s;
  position: relative;
}
.ai-tab-btn::after {
  content: '';
  position: absolute;
  bottom: 0; left: 20%; right: 20%; height: 2px;
  background: var(--gold);
  border-radius: 2px 2px 0 0;
  opacity: 0;
  transition: opacity .2s;
}
.ai-tab-btn.ai-tab-btn--active {
  color: var(--gold);
}
.ai-tab-btn.ai-tab-btn--active::after { opacity: 1; }
.ai-tab-btn:hover { background: rgba(255,255,255,.04); }

/* ── Context bar — mostra lezione corrente ────────────────────── */
.ai-context-bar {
  padding: 8px 12px;
  font-family: 'Inter', sans-serif;
  font-size: .68rem;
  color: rgba(245,245,245,.38);
  border-bottom: 1px solid rgba(255,255,255,.05);
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(255,255,255,.02);
}
.ai-context-bar strong {
  color: rgba(245,245,245,.65);
  font-weight: 500;
}

/* ── Tab content ─────────────────────────────────────────────────── */
.ai-tab-content { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.ai-tab-content.ai-tab-content--active { display: flex; }

/* ── TUTOR: area messaggi ────────────────────────────────────────── */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.ai-messages::-webkit-scrollbar { width: 3px; }
.ai-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

/* Messaggi */
.ai-msg {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: .8rem;
  line-height: 1.5;
}
.ai-msg--user {
  background: var(--primary-mid);
  color: #f5f5f5;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.ai-msg--ai {
  background: rgba(255,255,255,.06);
  color: rgba(245,245,245,.88);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.ai-msg--ai .ai-msg-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}
.ai-msg--typing {
  background: rgba(255,255,255,.06);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
}
.ai-typing-dots {
  display: flex; gap: 5px; align-items: center;
}
.ai-typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold);
  animation: ai-dot-bounce 1.2s ease-in-out infinite;
}
.ai-typing-dots span:nth-child(2) { animation-delay: .2s; }
.ai-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes ai-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

/* Messaggio benvenuto */
.ai-welcome {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px;
  padding: 24px 16px; text-align: center;
  color: rgba(245,245,245,.45);
  font-family: 'Inter', sans-serif; font-size: .78rem; line-height: 1.6;
}
.ai-welcome-icon { font-size: 2rem; }
.ai-welcome strong { color: rgba(245,245,245,.75); font-size: .85rem; }

/* ── TUTOR: input area ────────────────────────────────────────────── */
.ai-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
  background: rgba(255,255,255,.02);
}
.ai-input {
  flex: 1;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: 'Inter', sans-serif;
  font-size: .8rem;
  color: #f5f5f5;
  resize: none;
  max-height: 100px;
  min-height: 36px;
  outline: none;
  transition: border-color .2s;
  line-height: 1.4;
}
.ai-input::placeholder { color: rgba(245,245,245,.3); }
.ai-input:focus { border-color: rgba(201,150,42,.4); }
.ai-send-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--gold);
  border: none; border-radius: 8px;
  color: #0a0a0a; font-size: 1rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .1s;
}
.ai-send-btn:hover { background: var(--gold-lt); }
.ai-send-btn:active { transform: scale(0.92); }
.ai-send-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── QUIZ: area principale ───────────────────────────────────────── */
.ai-quiz-area {
  flex: 1; overflow-y: auto; padding: 16px 12px;
  display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.ai-quiz-area::-webkit-scrollbar { width: 3px; }
.ai-quiz-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

.ai-quiz-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px;
  text-align: center; color: rgba(245,245,245,.45);
  font-family: 'Inter', sans-serif; font-size: .78rem; line-height: 1.6;
  padding: 24px 8px;
}
.ai-quiz-empty-icon { font-size: 2rem; }
.ai-quiz-empty strong { color: rgba(245,245,245,.75); font-size: .85rem; }

.ai-generate-btn {
  width: 100%; padding: 10px 16px;
  background: var(--gold);
  color: #0a0a0a; font-family: 'Inter', sans-serif;
  font-size: .8rem; font-weight: 700;
  border: none; border-radius: 8px; cursor: pointer;
  transition: background .2s, transform .1s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.ai-generate-btn:hover { background: var(--gold-lt); }
.ai-generate-btn:active { transform: scale(0.97); }
.ai-generate-btn:disabled { opacity: .45; cursor: not-allowed; }

/* Singola domanda quiz */
.ai-quiz-question {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 10px;
  padding: 12px;
  font-family: 'Inter', sans-serif;
}
.ai-quiz-q-text {
  font-size: .82rem; font-weight: 600;
  color: rgba(245,245,245,.9);
  margin-bottom: 10px; line-height: 1.45;
}
.ai-quiz-q-num {
  font-size: .65rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 6px;
}
.ai-quiz-options { display: flex; flex-direction: column; gap: 6px; }
.ai-quiz-opt {
  padding: 8px 10px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 7px; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: .78rem;
  color: rgba(245,245,245,.75);
  text-align: left; transition: border-color .2s, background .2s;
}
.ai-quiz-opt:hover:not(:disabled) { border-color: rgba(201,150,42,.35); background: rgba(201,150,42,.06); }
.ai-quiz-opt--correct { border-color: #3db05b !important; background: rgba(61,176,91,.1) !important; color: #5dd882 !important; }
.ai-quiz-opt--wrong   { border-color: #e05050 !important; background: rgba(224,80,80,.1)  !important; color: #f08080 !important; }
.ai-quiz-opt:disabled { cursor: default; }

.ai-quiz-explanation {
  margin-top: 8px; padding: 8px 10px;
  background: rgba(201,150,42,.08);
  border-left: 2px solid var(--gold);
  border-radius: 0 6px 6px 0;
  font-size: .75rem; color: rgba(245,245,245,.7); line-height: 1.5;
}
.ai-quiz-score {
  text-align: center; padding: 12px;
  font-family: 'Inter', sans-serif; font-size: .85rem;
  font-weight: 700; color: var(--gold-lt);
  border-top: 1px solid rgba(255,255,255,.07);
  margin-top: 4px;
}

/* ── Mobile FAB + drawer ─────────────────────────────────────────── */
/* FAB: hidden by default, shown only when in course view on mobile via .ai-in-course */
.ai-fab {
  position: fixed;
  bottom: 90px;
  right: 16px;
  width: 48px; height: 48px;
  background: var(--primary);
  border: none; border-radius: 50%;
  color: #fff; font-size: 1.2rem;
  cursor: pointer; z-index: 452;
  box-shadow: 0 4px 20px rgba(160,26,54,.5);
  align-items: center; justify-content: center;
  transition: transform .2s, box-shadow .2s;
  display: none; /* default nascosto — JS aggiunge .ai-in-course al body */
}
.ai-fab:hover { transform: scale(1.07); box-shadow: 0 6px 24px rgba(160,26,54,.6); }
.ai-fab:active { transform: scale(0.93); }

/* Backdrop (mobile + tablet) */
.ai-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 449;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}
.ai-backdrop.ai-backdrop--visible { display: block; }

/* ── Visibilità controlli AI: guidata da .ai-in-course sul #glv-dashboard ── */

/* Default: tutti i toggle AI nascosti */
.ai-panel-tab { display: none; }
.ai-fab       { display: none; }

/* Desktop (>1024px): solo tab laterale visibile nella vista corso */
@media (min-width: 1025px) {
  #glv-dashboard.ai-in-course .ai-panel-tab { display: flex; }
  #glv-dashboard.ai-in-course .ai-fab       { display: none; }
  /* Tab si sposta a sinistra quando il pannello è aperto */
  .ai-panel-tab.ai-tab--open { right: 300px; }
}

/* Tablet (768–1024px): tab laterale visibile, FAB nascosto */
@media (min-width: 768px) and (max-width: 1024px) {
  #glv-dashboard.ai-in-course .ai-panel-tab { display: flex; }
  #glv-dashboard.ai-in-course .ai-fab       { display: none; }
  .ai-panel-tab.ai-tab--open { right: 300px; }

  .ai-panel {
    top: var(--nav-height, 64px) !important;
    right: 0 !important;
    width: 300px !important;
    height: calc(100vh - var(--nav-height, 64px)) !important;
    border-radius: 12px 0 0 12px !important;
    transform: translateX(300px) !important;
    opacity: 1 !important;
  }
  .ai-panel.ai-panel--visible {
    transform: translateX(0) !important;
    opacity: 1 !important;
  }
}

/* Mobile (<768px): FAB visibile, tab laterale nascosta */
@media (max-width: 767px) {
  #glv-dashboard.ai-in-course .ai-panel-tab { display: none; }
  #glv-dashboard.ai-in-course .ai-fab       { display: flex; }

  .ai-panel {
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important; right: 0 !important;
    width: 100% !important;
    height: 75vh !important;
    max-height: 75vh !important;
    border-radius: 16px 16px 0 0 !important;
    transform: translateY(110%) !important;
    opacity: 1 !important;
    z-index: 453 !important;
  }
  .ai-panel.ai-panel--visible {
    transform: translateY(0) !important;
  }
}

/* ── Reduce motion ───────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ai-panel { transition: none !important; }
  .ai-typing-dots span { animation: none !important; opacity: 1 !important; }
}

/* ══════════════════════════════════════════════════════════════════
   AI PANEL — Raffinamento v2 (UX + Neuro spec)
══════════════════════════════════════════════════════════════════ */

/* ── Bubble utente: oro invece di rosso (rosso = errore/brand) ─── */
.ai-msg--user {
  background: rgba(201,150,42,.15) !important;
  border: 1px solid rgba(201,150,42,.2);
}

/* ── Label Magistro nelle risposte AI ───────────────────────────── */
.ai-msg--ai .ai-msg-label {
  color: var(--gold);
  letter-spacing: .07em;
}

/* ── Close button interno al pannello ───────────────────────────── */
.ai-close-btn {
  margin-left: auto;
  width: 26px; height: 26px;
  background: transparent;
  border: none; border-radius: 6px;
  color: rgba(245,245,245,.35);
  font-size: .9rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.ai-close-btn:hover { background: rgba(255,255,255,.07); color: rgba(245,245,245,.8); }

/* Tab bar ridisegnata per ospitare il close button */
.ai-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
  padding-right: 8px;
}

/* ── Chip domande suggerite ─────────────────────────────────────── */
.ai-chips-wrap {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 14px;
}
.ai-chips-label {
  font-family: 'Inter', sans-serif;
  font-size: .65rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: rgba(245,245,245,.35);
  margin-bottom: 2px;
}
.ai-suggested-chip {
  padding: 8px 10px;
  background: rgba(201,150,42,.07);
  border: 1px solid rgba(201,150,42,.18);
  border-radius: 7px;
  font-family: 'Inter', sans-serif;
  font-size: .75rem; color: rgba(245,245,245,.7);
  cursor: pointer; text-align: left; width: 100%;
  transition: background .15s, border-color .15s, color .15s;
  line-height: 1.4;
}
.ai-suggested-chip:hover {
  background: rgba(201,150,42,.14);
  border-color: rgba(201,150,42,.38);
  color: rgba(245,245,245,.92);
}
.ai-chips-wrap.ai-chips--hidden { display: none; }

/* ── Dot indicatore "lezione attiva" sul toggle tab ────────────── */
.ai-panel-tab {
  position: fixed; /* già impostato — aggiungiamo il dot */
}
.ai-ready-dot {
  position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px; border-radius: 50%;
  background: #3db05b;
  border: 1.5px solid #141414; /* stesso sfondo del pannello */
  opacity: 0; transition: opacity .3s;
  pointer-events: none;
  animation: ai-dot-pulse 2.2s ease-in-out infinite;
}
.ai-panel-tab.ai-has-lesson .ai-ready-dot { opacity: 1; }
@keyframes ai-dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(61,176,91,.5); }
  50%       { box-shadow: 0 0 0 4px rgba(61,176,91,0); }
}

/* Il toggle deve avere position:relative per il dot assoluto */
.ai-panel-tab { position: fixed !important; }

/* ── FAB dot indicatore (mobile) ────────────────────────────────── */
.ai-fab {
  position: relative;
}
.ai-fab .ai-ready-dot {
  top: 3px; right: 3px;
  border-color: var(--bg, #0a0a0a);
}

/* ── Quiz opzioni — stagger fade-in ─────────────────────────────── */
.ai-quiz-opt {
  opacity: 0;
  animation: ai-opt-appear .3s ease forwards;
}
@keyframes ai-opt-appear {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Risposta corretta: micro-bounce ──────────────────────────────── */
.ai-quiz-opt--correct {
  animation: ai-correct-bounce .35s cubic-bezier(.36,.07,.19,.97) both !important;
}
@keyframes ai-correct-bounce {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.03); }
  60%  { transform: scale(.98); }
  100% { transform: scale(1); }
}

/* ── Score finale ───────────────────────────────────────────────── */
.ai-quiz-score {
  background: rgba(201,150,42,.08);
  border: 1px solid rgba(201,150,42,.2);
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 8px;
}
.ai-quiz-score-main {
  font-family: 'Inter', sans-serif;
  font-size: .9rem; font-weight: 700;
  color: var(--gold-lt);
  margin-bottom: 4px;
}
.ai-quiz-score-sub {
  font-family: 'Inter', sans-serif;
  font-size: .75rem;
  color: rgba(245,245,245,.55);
  line-height: 1.5;
}
.ai-quiz-score-counter {
  font-size: 1.6rem; font-weight: 800;
  font-family: 'Inter', sans-serif;
  color: var(--gold);
  display: block; margin-bottom: 6px;
}

/* ── Context bar con dot lingua ─────────────────────────────────── */
.ai-lang-dot {
  display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  margin-right: 6px; flex-shrink: 0;
  vertical-align: middle;
  position: relative; top: -1px;
}

/* ── Reduce motion — override delle nuove animazioni ───────────── */
@media (prefers-reduced-motion: reduce) {
  .ai-quiz-opt { animation: none !important; opacity: 1 !important; }
  .ai-ready-dot { animation: none !important; }
  .ai-quiz-opt--correct { animation: none !important; }
}
