/* ============================================================
   MAGNISI AI ACADEMY — Design System
   Ibrido: piattaforma di learning moderna × gioco di simulazione
   Mobile-first, dark theme "night campus" con accenti energia.
   ============================================================ */

:root {
  /* Palette */
  --bg: #0b0e1a;
  --bg-2: #10142a;
  --surface: #171c36;
  --surface-2: #1f2547;
  --surface-3: #2a3160;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef0ff;
  --text-2: #a8aecf;
  --text-3: #6f76a3;

  --brand: #6c5ce7;
  --brand-2: #8e7bff;
  --brand-soft: rgba(108, 92, 231, 0.16);
  --xp: #ffce3a;
  --success: #35d49a;
  --success-soft: rgba(53, 212, 154, 0.14);
  --danger: #ff6b81;
  --danger-soft: rgba(255, 107, 129, 0.14);
  --info: #4dc3ff;
  --info-soft: rgba(77, 195, 255, 0.14);

  --grad-hero: linear-gradient(135deg, #6c5ce7 0%, #a55eea 45%, #4dc3ff 100%);
  --grad-xp: linear-gradient(90deg, #ffce3a, #ff9f43);
  --grad-card: linear-gradient(180deg, rgba(142, 123, 255, 0.10), rgba(142, 123, 255, 0) 60%);

  /* Tipografia */
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  /* Geometria */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-full: 999px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-brand: 0 8px 24px rgba(108, 92, 231, 0.35);

  --nav-h: 64px;
  --sidebar-w: 232px;
}

/* ---------- Tema chiaro ----------
   Stessa palette di accenti; cambiano solo i fondi e i testi. */
[data-theme='light'] {
  --bg: #f5f6fc;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f1fa;
  --surface-3: #e3e6f5;
  --line: rgba(20, 24, 60, 0.10);
  --text: #171c3a;
  --text-2: #464e7d;
  --text-3: #8a90b8;
  --shadow: 0 10px 30px rgba(40, 45, 90, 0.10);
  --shadow-brand: 0 8px 24px rgba(108, 92, 231, 0.25);
  --grad-card: linear-gradient(180deg, rgba(142, 123, 255, 0.07), rgba(142, 123, 255, 0) 60%);
}

[data-theme='light'] body::before {
  background:
    radial-gradient(60% 40% at 15% 0%, rgba(108, 92, 231, 0.08), transparent 60%),
    radial-gradient(50% 35% at 90% 10%, rgba(77, 195, 255, 0.06), transparent 60%);
}

[data-theme='light'] .topbar { background: rgba(245, 246, 252, 0.86); }
[data-theme='light'] .nav { background: rgba(255, 255, 255, 0.94); }
[data-theme='light'] .tutor-panel { background: #ffffff; }

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body::before {
  /* glow ambientale da "mondo di gioco" */
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(60% 40% at 15% 0%, rgba(108, 92, 231, 0.18), transparent 60%),
    radial-gradient(50% 35% at 90% 10%, rgba(77, 195, 255, 0.10), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

#app { position: relative; z-index: 1; }

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); font-weight: 800; }
h2 { font-size: clamp(1.25rem, 3vw, 1.7rem); font-weight: 700; }
h3 { font-size: 1.08rem; font-weight: 700; }
p { color: var(--text-2); }
a { color: var(--brand-2); text-decoration: none; }
strong { color: var(--text); }

img, svg { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  font-family: inherit; font-size: 1rem; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 12px 14px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: transparent; }
::placeholder { color: var(--text-3); }

/* ---------- Layout ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 24px 18px calc(var(--nav-h) + 88px); }
.page--narrow { max-width: 680px; }
.page--wide { max-width: 1200px; }

.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; }

/* Top bar (in-app) */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  background: rgba(11, 14, 26, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar__logo { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-weight: 800; font-size: 1.02rem; }
.topbar__spacer { flex: 1; }

.logo-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--grad-hero);
  display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 0.95rem;
}

/* Bottom nav (mobile) / side nav (desktop) */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-around;
  background: rgba(16, 20, 42, 0.94);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav__item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 0.66rem; color: var(--text-3); padding: 6px 10px;
  border-radius: var(--r-sm); min-width: 58px;
}
.nav__item .ico { font-size: 1.25rem; line-height: 1; }
.nav__item.is-active { color: var(--brand-2); background: var(--brand-soft); }
.nav__item:disabled { opacity: 0.35; cursor: not-allowed; }

@media (min-width: 900px) {
  .nav {
    top: 0; bottom: 0; left: 0; right: auto;
    width: var(--sidebar-w);
    flex-direction: column; justify-content: flex-start; gap: 4px;
    border-top: none; border-right: 1px solid var(--line);
    padding: 84px 12px 16px;
  }
  .nav__item {
    flex-direction: row; gap: 12px; width: 100%;
    font-size: 0.9rem; padding: 11px 14px; min-width: 0;
    justify-content: flex-start;
  }
  .with-nav .app-main { margin-left: var(--sidebar-w); }
  .with-nav .topbar { margin-left: var(--sidebar-w); }
  .page { padding-bottom: 120px; }
}

/* ---------- Componenti base ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; font-size: 0.95rem;
  padding: 13px 22px; border-radius: var(--r-full);
  background: var(--surface-2); color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s;
  border: 1px solid var(--line);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn--primary { background: var(--grad-hero); border: none; color: #fff; box-shadow: var(--shadow-brand); }
.btn--success { background: var(--success); border: none; color: #06281c; }
.btn--ghost { background: transparent; }
.btn--sm { padding: 8px 15px; font-size: 0.84rem; }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.card--glow { background: var(--surface) var(--grad-card); }
.card--clickable { cursor: pointer; transition: transform 0.15s, border-color 0.15s; }
.card--clickable:hover { transform: translateY(-2px); border-color: rgba(142, 123, 255, 0.45); }
.card--selected { border-color: var(--brand-2); outline: 2px solid var(--brand-2); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.74rem; font-weight: 600;
  padding: 4px 11px; border-radius: var(--r-full);
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--line);
}
.chip--brand { background: var(--brand-soft); color: var(--brand-2); border-color: transparent; }
.chip--success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.chip--warn { background: rgba(255, 206, 58, 0.14); color: var(--xp); border-color: transparent; }
.chip--danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip--info { background: var(--info-soft); color: var(--info); border-color: transparent; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
@media (min-width: 700px) {
  .grid--2 { grid-template-columns: 1fr 1fr; }
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
}

.muted { color: var(--text-3); font-size: 0.84rem; }
.small { font-size: 0.85rem; }
.tcenter { text-align: center; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 26px; } .mt-4 { margin-top: 40px; }

/* Barre di progresso */
.bar { height: 10px; border-radius: var(--r-full); background: var(--bg-2); overflow: hidden; }
.bar__fill { height: 100%; border-radius: var(--r-full); background: var(--grad-hero); transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
.bar__fill--xp { background: var(--grad-xp); }
.bar__fill--success { background: var(--success); }

/* Stat pill (XP, crediti, streak) */
.stat {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 6px 13px; border-radius: var(--r-full);
  font-weight: 700; font-size: 0.82rem;
}
.stat .ico { font-size: 1rem; }

/* Statistiche della topbar con descrittivo sotto l'icona */
.stat--tag {
  flex-direction: column; gap: 1px;
  padding: 4px 12px 5px; line-height: 1.1;
}
.stat--tag .stat__val { white-space: nowrap; }
.stat--tag .stat__label {
  font-size: 0.55rem; font-weight: 600; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--text-3);
}
@media (max-width: 560px) {
  .stat--tag .stat__label { display: none; } /* su schermi piccoli vince la compattezza */
}

/* Avatar */
.avatar {
  width: 40px; height: 40px; border-radius: var(--r-full);
  display: grid; place-items: center; flex-shrink: 0;
  font-weight: 800; font-size: 0.95rem; color: #fff;
  background: var(--surface-3);
}
.avatar--brand { background: var(--grad-hero); }
.avatar--lg { width: 60px; height: 60px; font-size: 1.4rem; }

/* ---------- Landing ---------- */
.hero { padding: 60px 18px 40px; text-align: center; max-width: 780px; margin: 0 auto; }
.hero h1 { margin: 18px 0 14px; }
.hero .grad-text { background: var(--grad-hero); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { font-size: 1.06rem; max-width: 560px; margin: 0 auto 26px; }

.steps-band { display: grid; gap: 14px; }
@media (min-width: 760px) { .steps-band { grid-template-columns: repeat(4, 1fr); } }
.step-card { text-align: left; }
.step-card .num {
  width: 34px; height: 34px; border-radius: var(--r-full);
  background: var(--brand-soft); color: var(--brand-2);
  display: grid; place-items: center; font-weight: 800; margin-bottom: 12px;
  font-family: var(--font-display);
}

/* ---------- Assessment ---------- */
.quiz-option {
  display: flex; align-items: center; gap: 14px; width: 100%;
  text-align: left; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); font-size: 0.97rem; color: var(--text);
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
}
.quiz-option:hover { border-color: var(--brand-2); transform: translateX(4px); }
.quiz-option.is-picked { background: var(--brand-soft); border-color: var(--brand-2); }
.quiz-option .emoji { font-size: 1.5rem; }

.tutor-bubble {
  display: flex; gap: 12px; align-items: flex-start;
  animation: rise 0.4s ease both;
}
.tutor-bubble__msg {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 4px var(--r-md) var(--r-md) var(--r-md);
  padding: 13px 16px; color: var(--text); max-width: 560px;
}

/* Trait bars nei risultati */
.trait { display: grid; grid-template-columns: 120px 1fr 40px; align-items: center; gap: 12px; font-size: 0.86rem; }
.trait b { font-weight: 600; color: var(--text-2); }
.trait .val { text-align: right; color: var(--text); font-weight: 700; }

/* ---------- Mappa livelli (percorso) ---------- */
.level-map { display: flex; flex-direction: column; gap: 0; position: relative; }
.level-node { display: flex; gap: 16px; position: relative; padding-bottom: 26px; }
.level-node::before {
  content: ''; position: absolute; left: 23px; top: 48px; bottom: 0;
  width: 3px; background: var(--surface-3); border-radius: 2px;
}
.level-node:last-child::before { display: none; }
.level-node.is-done::before { background: var(--success); }
.level-node__badge {
  width: 48px; height: 48px; border-radius: var(--r-full); flex-shrink: 0;
  display: grid; place-items: center; font-size: 1.3rem;
  background: var(--surface-2); border: 2px solid var(--surface-3);
  z-index: 1;
}
.level-node.is-done .level-node__badge { background: var(--success-soft); border-color: var(--success); }
.level-node.is-current .level-node__badge {
  background: var(--brand-soft); border-color: var(--brand-2);
  box-shadow: 0 0 0 6px rgba(108, 92, 231, 0.15);
  animation: pulse 2s infinite;
}
.level-node.is-locked { opacity: 0.5; }
.level-node__body { flex: 1; padding-top: 2px; }

/* ---------- Workspace simulazione ---------- */
.ws-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.ws-tabs::-webkit-scrollbar { display: none; }
.ws-tab {
  padding: 9px 16px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--line);
  font-size: 0.85rem; font-weight: 600; color: var(--text-2);
  white-space: nowrap; display: inline-flex; gap: 7px; align-items: center;
}
.ws-tab.is-active { background: var(--brand); color: #fff; border-color: transparent; }
.ws-tab .dot {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full);
  background: var(--danger); color: #fff; font-size: 0.68rem;
  display: grid; place-items: center; font-weight: 800;
}

.email-item {
  display: flex; gap: 13px; padding: 15px; width: 100%; text-align: left;
  border-radius: var(--r-md); background: var(--surface);
  border: 1px solid var(--line); transition: border-color 0.12s;
}
.email-item:hover { border-color: var(--brand-2); }
.email-item.is-unread { border-left: 3px solid var(--brand-2); }
.email-item.is-unread .email-item__subject { font-weight: 700; color: var(--text); }
.email-item__subject { color: var(--text-2); }

.chat-log { display: flex; flex-direction: column; gap: 12px; }
.chat-msg { display: flex; gap: 10px; align-items: flex-end; animation: rise 0.3s ease both; }
.chat-msg__bubble {
  background: var(--surface-2); border-radius: 4px var(--r-md) var(--r-md) var(--r-md);
  padding: 11px 15px; max-width: 78%; font-size: 0.93rem;
}
.chat-msg--me { flex-direction: row-reverse; }
.chat-msg--me .chat-msg__bubble { background: var(--brand); color: #fff; border-radius: var(--r-md) 4px var(--r-md) var(--r-md); }

.task-item {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 15px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
}
.task-item.is-done { opacity: 0.55; }
.task-item.is-done .task-item__title { text-decoration: line-through; }
.deadline { font-size: 0.75rem; font-weight: 700; }
.deadline--soon { color: var(--danger); }
.deadline--ok { color: var(--xp); }

/* ---------- Tutor dock (chat flottante) ---------- */
#tutor-dock { position: fixed; right: 16px; bottom: calc(var(--nav-h) + 18px); z-index: 60; }
@media (min-width: 900px) { #tutor-dock { bottom: 22px; } }

.tutor-fab {
  width: 58px; height: 58px; border-radius: var(--r-full);
  background: var(--grad-hero); box-shadow: var(--shadow-brand);
  display: grid; place-items: center; font-size: 1.6rem;
  transition: transform 0.15s;
  position: relative;
}
.tutor-fab:hover { transform: scale(1.06); }
.tutor-fab .ping {
  position: absolute; top: 0; right: 0;
  width: 15px; height: 15px; border-radius: var(--r-full);
  background: var(--danger); border: 2px solid var(--bg);
  animation: pulse 1.6s infinite;
}

.tutor-panel {
  position: fixed; right: 12px; bottom: calc(var(--nav-h) + 14px);
  width: min(400px, calc(100vw - 24px));
  height: min(560px, calc(100vh - var(--nav-h) - 40px));
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
  animation: rise 0.25s ease both;
  z-index: 70;
}
@media (min-width: 900px) { .tutor-panel { bottom: 18px; } }
.tutor-panel__head {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 16px; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.tutor-panel__log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.tutor-panel__input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--surface); }
.tutor-panel__input input { flex: 1; }
.tutor-quick { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px 10px; background: var(--surface); }

/* ---------- Toast & modal ---------- */
#toast-root { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 28px)); }
.toast {
  display: flex; gap: 11px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 13px 16px;
  box-shadow: var(--shadow); animation: drop 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
  font-size: 0.9rem;
}
.toast--xp { border-color: rgba(255, 206, 58, 0.5); }
.toast .ico { font-size: 1.3rem; }

#modal-root:not(:empty) {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(5, 7, 16, 0.7); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 18px;
}
.modal {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 26px;
  width: min(520px, 100%); max-height: 88vh; overflow-y: auto;
  animation: rise 0.3s ease both;
}

/* Level-up celebration */
.celebrate { text-align: center; padding: 10px 0; }
.celebrate .big { font-size: 4rem; animation: bounceIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* Badge grid */
.badge-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 10px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: 0.75rem; color: var(--text-2);
}
.badge-tile .ico { font-size: 2rem; }
.badge-tile.is-locked { opacity: 0.35; filter: grayscale(1); }

/* Ring progress (dashboard) */
.ring { position: relative; width: 118px; height: 118px; }
.ring svg { transform: rotate(-90deg); }
.ring__label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }

/* Match score */
.match-ring {
  width: 52px; height: 52px; border-radius: var(--r-full); flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: 0.82rem;
  background: conic-gradient(var(--success) calc(var(--pct) * 1%), var(--surface-3) 0);
  position: relative;
}
.match-ring::before { content: ''; position: absolute; inset: 5px; border-radius: var(--r-full); background: var(--surface); }
.match-ring span { position: relative; }

/* Tabelle dati (vista azienda) */
.dtable { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.dtable th { text-align: left; color: var(--text-3); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; }
.dtable td { padding: 13px 12px; border-bottom: 1px solid var(--line); }

/* ---------- Animazioni ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(108, 92, 231, 0.45); } 50% { box-shadow: 0 0 0 9px rgba(108, 92, 231, 0); } }
@keyframes bounceIn { 0% { transform: scale(0.2); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.anim-rise { animation: rise 0.4s ease both; }

/* Typing indicator */
.typing { display: inline-flex; gap: 4px; padding: 12px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

/* Focus visibile per accessibilità */
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

/* ---------- Brand Talentico ---------- */
.brand-word {
  font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em;
  color: var(--text); display: inline-block; line-height: 1;
}
.brand-word__t { position: relative; display: inline-block; }
.brand-word__star {
  position: absolute; top: -0.34em; right: -0.3em;
  width: 0.42em; height: 0.42em; color: currentColor;
}
.brand-word__star svg { width: 100%; height: 100%; }
.brand-tagline {
  margin-top: 8px; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.28em; color: var(--text-3); text-transform: uppercase;
}

/* ---------- Materiali di lavoro nei task ---------- */
.materials {
  background: var(--bg-2); border: 1px dashed var(--line);
  border-radius: var(--r-md); padding: 14px 16px;
  font-size: 0.85rem; color: var(--text-2);
  white-space: pre-wrap; line-height: 1.65;
  max-height: 300px; overflow-y: auto;
}

/* ---------- Scala di carriera (job ladder) ---------- */
.ladder { display: flex; align-items: center; gap: 4px; }
.ladder__step { flex: 1; height: 8px; border-radius: var(--r-full); background: var(--surface-3); }
.ladder__step.is-done { background: var(--grad-xp); }
.ladder__step.is-current { background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- Card ruolo (onboarding) ---------- */
.role-card {
  display: block; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 22px;
  transition: transform 0.15s, border-color 0.15s;
}
.role-card:hover { transform: translateY(-2px); border-color: var(--brand-2); }
.role-card--primary { background: var(--surface) var(--grad-card); border-color: rgba(142, 123, 255, 0.4); }

/* ---------- Lista funzionalità nei pacchetti ---------- */
.feat { display: flex; gap: 9px; align-items: flex-start; font-size: 0.86rem; color: var(--text-2); }
.feat::before { content: '✓'; color: var(--success); font-weight: 800; flex-shrink: 0; }
.feat--no { opacity: 0.45; }
.feat--no::before { content: '—'; color: var(--text-3); }

/* ---------- Hero: mappa talento × aspirazione ---------- */
.tal-map { max-width: 420px; margin: 26px auto 0; }
.tal-map svg { width: 100%; height: auto; }
.tal-map .pulse-star { animation: starPulse 2.6s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes starPulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.25); opacity: 0.85; } }

/* Glifi disegnati per gli step della landing */
.glyph { width: 44px; height: 44px; margin-bottom: 12px; }
.glyph path, .glyph circle, .glyph rect, .glyph line, .glyph polyline {
  fill: none; stroke: var(--brand-2); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.glyph .accent { stroke: var(--xp); }

/* ---------- Admin ---------- */
.admin-kpi { text-align: center; padding: 18px 10px; }
.admin-kpi .big { font-size: 1.8rem; font-weight: 800; font-family: var(--font-display); }
.report-bar { display: grid; grid-template-columns: 170px 1fr 46px; gap: 10px; align-items: center; font-size: 0.84rem; }

/* ---------- Paywall ---------- */
.pay-badge {
  position: absolute; top: 14px; right: -34px; transform: rotate(38deg);
  background: var(--grad-xp); color: #3d2c00; font-size: 0.68rem; font-weight: 800;
  padding: 4px 38px; letter-spacing: 0.04em;
}

/* Riduzione animazioni */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============ ATTESTATO (schermo + stampa PDF) ============ */
.certificate {
  --cert-ink: #1a1d2e; --cert-muted: #5a6078; --cert-line: #d8dbe8;
  background: #fdfdfc; color: var(--cert-ink);
  width: min(210mm, 100%); padding: 15mm 16mm; border-radius: 14px;
  border: 1px solid var(--cert-line);
  box-shadow: 0 18px 60px rgba(10, 12, 30, 0.35);
  font-size: 0.86rem; line-height: 1.45;
}
.certificate .brand-word { color: var(--cert-ink); }
.cert__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cert__sub { font-size: 0.66rem; color: var(--cert-muted); letter-spacing: 0.4px; }
.cert__id { font-size: 0.7rem; color: var(--cert-muted); white-space: nowrap; padding-top: 6px; }
.cert__rule { height: 3px; margin-top: 12px; border-radius: 2px; background: linear-gradient(135deg, #6c5ce7 0%, #a55eea 45%, #4dc3ff 100%); }
.cert__kicker { font-size: 0.72rem; font-weight: 700; letter-spacing: 3px; color: var(--cert-muted); }
.cert__name { font-size: 2rem; margin: 10px 0 2px; color: var(--cert-ink); }
.cert__line { color: var(--cert-muted); font-size: 0.86rem; }
.cert__title { font-size: 1.35rem; margin: 6px 0; color: var(--cert-ink); }
.cert__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0 6px; }
.cert__cell { border: 1px solid var(--cert-line); border-radius: 10px; padding: 12px 14px; }
.cert__cell-label { font-size: 0.62rem; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; color: var(--cert-muted); }
.cert__cell-val { font-weight: 800; margin-top: 3px; }
.cert__cell-sub { font-size: 0.74rem; color: var(--cert-muted); margin-top: 3px; }
.cert__section { margin-top: 14px; }
.cert__section h3 { font-size: 0.8rem; letter-spacing: 0.6px; text-transform: uppercase; color: var(--cert-ink); margin-bottom: 8px; }
.cert__skill { border: 1px solid var(--cert-line); border-radius: 999px; padding: 4px 11px; font-size: 0.74rem; font-weight: 600; color: var(--cert-ink); background: #f4f5fa; }
.cert__ind-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.cert__ind { border: 1px solid var(--cert-line); border-radius: 10px; padding: 8px 6px; text-align: center; }
.cert__ind-val { font-size: 1.25rem; font-weight: 800; background: linear-gradient(135deg, #6c5ce7, #4dc3ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.cert__ind-label { font-size: 0.62rem; color: var(--cert-muted); margin-top: 2px; }
.cert__note { font-size: 0.65rem; color: var(--cert-muted); margin-top: 6px; }
.cert__foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--cert-line); }
.cert__foot-line { font-size: 0.74rem; font-weight: 700; }
.cert__sign { font-size: 1.5rem; background: linear-gradient(135deg, #6c5ce7, #4dc3ff); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: 2px; }

@media print {
  body, html { background: #fff !important; }
  body * { visibility: hidden; }
  .certificate, .certificate * { visibility: visible; }
  .certificate {
    position: absolute; inset: 0 auto auto 0; width: 100%;
    margin: 0; border: none; border-radius: 0; box-shadow: none;
    padding: 10mm 12mm;
  }
  .no-print, .nav, .topbar, #tutor-dock, #toast-root { display: none !important; }
}

/* ============ MATURAZIONE UI: juice, registro business, inbox ============ */

/* Coriandoli */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 400; overflow: hidden; }
.confetti i {
  position: absolute; top: -14px; height: 13px; border-radius: 2px; opacity: 0.95;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(108vh) rotate(660deg); opacity: 0.85; }
}

/* Statistiche topbar: bump quando il valore cambia, fiamma che pulsa */
.stat--tag.bump .stat__val { animation: statbump 0.4s ease; }
@keyframes statbump { 45% { transform: scale(1.18); } }
.stat--fire .stat__val { animation: firepulse 1.9s ease-in-out infinite; }
@keyframes firepulse { 50% { transform: scale(1.07); filter: brightness(1.15); } }

/* Inbox in stile client di posta */
.mail-row { display: flex; gap: 12px; align-items: flex-start; }
.mail-row__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand-2); margin-top: 7px; flex-shrink: 0; }
.mail-row__dot--read { background: transparent; border: 1px solid var(--line); }
.mail-row__body { flex: 1; min-width: 0; }
.mail-row__subject { font-weight: 800; }
.mail-row--read .mail-row__subject { font-weight: 600; color: var(--text-2); }
.mail-row__preview { font-size: 0.78rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.mail-row__time { font-size: 0.68rem; color: var(--text-3); flex-shrink: 0; padding-top: 3px; }

/* Registro business: sobrio, denso, professionale (aziende e admin) */
body[data-register='business']::before { opacity: 0.25; }
body[data-register='business'] .card { border-radius: 14px; }
body[data-register='business'] .card--glow { background: var(--surface); }
body[data-register='business'] .btn { border-radius: 10px; }
body[data-register='business'] .chip { border-radius: 7px; }
body[data-register='business'] .dtable th, body[data-register='business'] .dtable td { padding: 8px 10px; font-size: 0.8rem; }
body[data-register='business'] h1 { font-size: clamp(1.4rem, 3.5vw, 1.9rem); }
