/* ─── TOKENS ─────────────────────────────────────────────────── */
:root {
  --navy:     #050e2b;
  --navy2:    #0a1640;
  --navy3:    #0f1f50;
  --blue:     #2352e8;
  --blue-lt:  #3d6bff;
  --blue-dim: rgba(35,82,232,0.12);
  --gold:     #f0b429;
  --gold-lt:  #ffd166;
  --gold-dim: rgba(240,180,41,0.12);
  --cream:    #f7f4ef;
  --cream2:   #ede9e2;
  --cream3:   #e0dbd2;
  --ink:      #0d0d14;
  --ink2:     #1e2330;
  --muted:    #8892a4;
  --green:    #22c55e;
  --green-dim:rgba(34,197,94,0.12);
  --red:      #ef4444;
  --red-dim:  rgba(239,68,68,0.12);
  --serif:    'Instrument Serif', Georgia, serif;
  --sans:     'DM Sans', sans-serif;
  --mono:     'DM Mono', monospace;
  --r:        12px;
  --r-lg:     18px;
  --r-xl:     24px;
  --nav-h:    56px;
  --shadow:   0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg:0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
}

/* ─── BASE ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--cream);
  font-family: var(--sans);
  color: var(--ink);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  zoom: 1.08;
}

/* ─── NAV ────────────────────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--nav-h);
  background: var(--navy);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  backdrop-filter: blur(12px);
}
.nav-left  { display: flex; align-items: center; gap: 28px; }
.nav-logo  { display: flex; align-items: center; gap: 9px; text-decoration: none; }
.nav-mark  {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--blue);
  display: flex; align-items: center; justify-content: center;
}
.nav-mark svg { width: 15px; height: 15px; stroke: #fff; stroke-width: 2; fill: none; stroke-linecap: round; }
.nav-name  { font-size: 14px; font-weight: 600; color: #fff; letter-spacing: -0.01em; }
.nav-name em { color: var(--gold); font-style: normal; }

.nav-links { display: flex; gap: 2px; }
.nav-link  {
  padding: 6px 14px; border-radius: 7px;
  font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.45);
  text-decoration: none; transition: all .2s; white-space: nowrap;
}
.nav-link:hover  { color: rgba(255,255,255,0.85); background: rgba(255,255,255,0.06); }
.nav-link.active { color: #fff; background: rgba(255,255,255,0.1); }

.nav-right  { display: flex; align-items: center; gap: 12px; }
.nav-badge  {
  font-size: 10px; font-weight: 700; color: var(--gold);
  background: var(--gold-dim); border: 1px solid rgba(240,180,41,0.25);
  padding: 4px 12px; border-radius: 20px; letter-spacing: .06em;
}
.nav-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--blue); display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; cursor: pointer;
  border: 2px solid rgba(255,255,255,0.1);
}

/* ─── PAGE WRAPPER ───────────────────────────────────────────── */
.page { padding-top: var(--nav-h); min-height: 100vh; }

/* ─── SECTION ────────────────────────────────────────────────── */
.section {
  max-width: 1600px; margin: 0 auto;
  padding: 0 28px;
}

/* ─── CARDS ──────────────────────────────────────────────────── */
.card {
  background: #fff; border-radius: var(--r);
  border: 1px solid var(--cream2);
  box-shadow: var(--shadow);
}
.card-dark {
  background: var(--navy); border-radius: var(--r);
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: var(--shadow);
}
.card-navy2 {
  background: var(--navy2); border-radius: var(--r);
  border: 1px solid rgba(255,255,255,0.06);
}

/* ─── EYEBROW ────────────────────────────────────────────────── */
.eyebrow {
  font-size: 10px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--gold);
  display: flex; align-items: center; gap: 6px;
}
.eyebrow-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.eyebrow-blue { color: var(--blue); }
.eyebrow-muted { color: var(--muted); }

/* ─── BADGE ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
}
.badge-gold   { background: var(--gold-dim); color: var(--gold); border: 1px solid rgba(240,180,41,0.25); }
.badge-blue   { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(35,82,232,0.2); }
.badge-green  { background: var(--green-dim); color: #16a34a; border: 1px solid rgba(34,197,94,0.25); }
.badge-red    { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.badge-cream  { background: var(--cream); color: var(--muted); border: 1px solid var(--cream2); }

/* ─── BUTTONS ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-weight: 600; font-size: 13px;
  padding: 10px 20px; border-radius: 9px;
  border: none; cursor: pointer; transition: all .2s;
  text-decoration: none; white-space: nowrap;
}
.btn-primary {
  background: var(--blue); color: #fff;
}
.btn-primary:hover { background: var(--blue-lt); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(35,82,232,0.3); }
.btn-gold {
  background: var(--gold); color: var(--ink);
}
.btn-gold:hover { background: var(--gold-lt); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(240,180,41,0.3); }
.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--cream2);
}
.btn-ghost:hover { background: var(--cream); color: var(--ink); }
.btn-ghost-dark {
  background: transparent; color: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-ghost-dark:hover { background: rgba(255,255,255,0.07); color: #fff; }
.btn-lg { padding: 14px 28px; font-size: 15px; border-radius: 11px; }
.btn-sm { padding: 7px 14px; font-size: 11px; border-radius: 7px; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }

/* ─── PROGRESS BAR ───────────────────────────────────────────── */
.progress-bar {
  height: 4px; background: rgba(255,255,255,0.08);
  border-radius: 2px; overflow: hidden;
}
.progress-bar.light { background: var(--cream2); }
.progress-fill {
  height: 100%; border-radius: 2px;
  transition: width .6s cubic-bezier(.16,1,.3,1);
}

/* ─── STAT RING ──────────────────────────────────────────────── */
.stat-ring { position: relative; flex-shrink: 0; }
.stat-ring svg { transform: rotate(-90deg); }
.stat-ring-n {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif);
}

/* ─── TUTOR BUBBLE ───────────────────────────────────────────── */
.tutor-bubble {
  background: rgba(255,255,255,0.05);
  border-left: 2px solid var(--blue);
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
  font-size: 12px; color: rgba(255,255,255,0.65);
  line-height: 1.75;
}
.tutor-bubble strong { color: #fff; }
.tutor-bubble em { color: var(--gold-lt); font-style: italic; }

/* ─── QUIZ OPTION ────────────────────────────────────────────── */
.m-opt {
  background: var(--cream); border: 1.5px solid var(--cream2);
  border-radius: 9px; padding: 11px 16px;
  font-size: 13px; color: var(--ink); cursor: pointer;
  display: flex; gap: 12px; align-items: flex-start;
  transition: all .15s; font-family: var(--sans); text-align: left; width: 100%;
}
.m-opt:hover:not(:disabled) { background: var(--cream2); border-color: var(--cream3); }
.m-opt:disabled { cursor: default; }
.m-opt.correct { background: #f0fdf4; border-color: #86efac; color: #15803d; }
.m-opt.wrong   { background: #fff1f2; border-color: #fca5a5; color: #be123c; }
.m-let { font-family: var(--mono); font-size: 11px; color: var(--muted); flex-shrink: 0; margin-top: 2px; }

/* ─── MODAL ──────────────────────────────────────────────────── */
.modal-bg {
  display: none; position: fixed; inset: 0;
  background: rgba(5,14,43,0.7); backdrop-filter: blur(4px);
  z-index: 3000; align-items: center; justify-content: center; padding: 20px;
}
.modal-bg.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--r-lg);
  padding: 28px; max-width: 540px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s cubic-bezier(.16,1,.3,1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ─── EXPLANATION BOX ────────────────────────────────────────── */
.explanation {
  display: none; padding: 14px 16px; margin-top: 8px;
  background: rgba(35,82,232,0.05); border-left: 3px solid var(--blue);
  border-radius: 0 9px 9px 0;
  font-size: 12px; color: #334155; line-height: 1.75;
}
.explanation.show { display: block; }
.explanation strong { color: var(--ink); }

/* ─── DIFFICULTY BADGE ───────────────────────────────────────── */
.diff-easy { font-size: 9px; font-weight: 700; color: #16a34a; }
.diff-med  { font-size: 9px; font-weight: 700; color: #ca8a04; }
.diff-hard { font-size: 9px; font-weight: 700; color: #dc2626; }

/* ─── STATUS DOT ─────────────────────────────────────────────── */
.status-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.status-dot.online  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.loading { background: var(--gold); animation: pulse 1s infinite; }

/* ─── SKELETON ───────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--cream2) 25%, var(--cream3) 50%, var(--cream2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── ANIMATIONS ─────────────────────────────────────────────── */
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.4; } }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp .4s cubic-bezier(.16,1,.3,1) both; }
.fade-up-d1 { animation-delay: .05s; }
.fade-up-d2 { animation-delay: .1s; }
.fade-up-d3 { animation-delay: .15s; }
.fade-up-d4 { animation-delay: .2s; }

/* ─── SCROLLBAR ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--cream3); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .section { padding: 0 16px; }
}

/* ═══════════════════════════════════════════════════════════════
   CARD QUIZ — componente sequenziale riusabile (card_quiz.js)
   Due modalità:
   - LEARN: feedback immediato + spiegazione, no back (quiz lezione + ripasso SM-2)
   - EXAM:  feedback differito, timer, nav libera (mini-sim + simulazione)
   ═══════════════════════════════════════════════════════════════ */
.cq-shell { background: #fff; border-radius: 14px; padding: 4px 0 0; }
.cq-topbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px; font-size: 11px; color: var(--muted);
  font-family: var(--mono); letter-spacing: .04em;
}
.cq-progress-txt { flex-shrink: 0; text-transform: uppercase; font-weight: 600; }
.cq-dots { display: flex; gap: 4px; flex: 1; }
.cq-dot {
  height: 4px; flex: 1; background: var(--cream2); border-radius: 2px;
  transition: background .2s; cursor: default;
}
.cq-dot.active   { background: var(--ink); }
.cq-dot.done     { background: #16a34a; }
.cq-dot.wrong    { background: #dc2626; }
.cq-dot.answered { background: var(--blue); }  /* EXAM mode: risposta data, no giudizio */

.cq-timer {
  font-family: var(--mono); font-size: 14px; font-weight: 700;
  color: var(--ink); flex-shrink: 0;
}
.cq-timer.warning { color: #b91c1c; animation: cq-pulse .6s infinite; }
@keyframes cq-pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

.cq-question {
  font-family: var(--serif); font-size: 20px; color: var(--ink);
  line-height: 1.4; margin-bottom: 18px; font-weight: 500;
}
.cq-opts { display: flex; flex-direction: column; gap: 8px; }
.cq-opt {
  padding: 12px 14px; border: 1.5px solid var(--cream2); border-radius: 10px;
  background: #fff; cursor: pointer; text-align: left;
  font-family: var(--sans); font-size: 14px; color: var(--ink);
  display: flex; align-items: flex-start; gap: 10px;
  transition: background .12s, border-color .12s, color .12s;
}
.cq-opt:hover:not(.locked) { background: var(--cream); border-color: var(--ink); }
.cq-opt.locked { cursor: default; }
.cq-opt.selected                 { background: var(--blue-dim); border-color: var(--blue); }
.cq-opt.selected-correct         { background: rgba(34,197,94,0.10); border-color: #16a34a; color: #14532d; }
.cq-opt.selected-wrong           { background: rgba(239,68,68,0.08); border-color: #dc2626; color: #7f1d1d; }
.cq-opt.correct-reveal           { background: rgba(34,197,94,0.05); border-color: rgba(22,163,74,0.5); color: #14532d; }
.cq-opt-letter {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid currentColor; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; opacity: .8;
}

.cq-feedback {
  margin-top: 14px; padding: 14px 16px; border-radius: 10px;
  font-size: 13px; color: var(--ink); line-height: 1.55;
  animation: cq-fadeInUp .2s ease;
}
@keyframes cq-fadeInUp {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.cq-feedback.correct { background: rgba(34,197,94,0.08); }
.cq-feedback.wrong   { background: rgba(239,68,68,0.06); }
.cq-feedback-label {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em;
  margin-bottom: 6px;
}
.cq-feedback.correct .cq-feedback-label { color: #15803d; }
.cq-feedback.wrong   .cq-feedback-label { color: #b91c1c; }

.cq-extras { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

.cq-nav {
  margin-top: 18px; display: flex; gap: 10px; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
}
.cq-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--cream2);
  background: #fff; cursor: pointer; font-size: 13px; font-weight: 500;
  font-family: var(--sans); color: var(--ink);
  transition: background .12s, border-color .12s, opacity .2s;
}
.cq-btn:hover:not(:disabled) { background: var(--cream); border-color: var(--ink); }
.cq-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.cq-btn.primary {
  background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600;
}
.cq-btn.primary:hover { background: #000; }
.cq-btn.hidden { display: none; }
/* ─── TOAST (gold milestone / generic) ───────────────────────── */
.tf-toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  max-width: 340px; min-width: 260px;
  background: var(--navy2); color: #fff;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 14px 14px 14px 16px;
  display: flex; align-items: flex-start; gap: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
  transform: translateY(16px) scale(.97); opacity: 0;
  transition: transform .32s cubic-bezier(.16,1,.3,1), opacity .25s;
  font-family: var(--sans);
}
.tf-toast.show { transform: translateY(0) scale(1); opacity: 1; }
.tf-toast-gold { border-color: rgba(240,180,41,0.45); background: linear-gradient(135deg, #0a1640, #1e2548); }
.tf-toast-emoji { font-size: 26px; line-height: 1; flex-shrink: 0; }
.tf-toast-body { flex: 1; min-width: 0; }
.tf-toast-title {
  font-family: var(--serif); font-size: 17px; color: var(--gold-lt);
  line-height: 1.2; margin-bottom: 3px;
}
.tf-toast-desc {
  font-size: 12px; color: rgba(255,255,255,0.7); line-height: 1.5;
}
.tf-toast-close {
  background: none; border: none; color: rgba(255,255,255,0.35);
  font-size: 13px; cursor: pointer; padding: 2px 6px;
  flex-shrink: 0; min-width: 28px; min-height: 28px;
  transition: color .15s;
}
.tf-toast-close:hover { color: #fff; }
@media (max-width: 520px) {
  .tf-toast { right: 12px; left: 12px; bottom: 12px; max-width: none; min-width: 0; }
}

/* Auto-advance hint (LEARN) */
.cq-btn.cq-auto { position: relative; }
.cq-btn.cq-auto::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(90deg, rgba(255,255,255,0.12), rgba(255,255,255,0));
  animation: cqAutoPulse 1s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes cqAutoPulse { from { opacity: 0.3; } to { opacity: 0.7; } }
.cq-auto-hint {
  flex-basis: 100%;
  font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 8px;
}
.cq-auto-hint button {
  background: transparent; border: 1px solid var(--cream2); color: var(--ink);
  padding: 4px 10px; border-radius: 6px; cursor: pointer; font-family: var(--sans);
  font-size: 11px; font-weight: 500;
}
.cq-auto-hint button:hover { background: var(--cream); }
