/* Tarocchi in 22 Giorni — Academy */

:root {
  --bg: #0c0a13;
  --bg-elev: #171224;
  --bg-elev-2: #1e1830;
  --gold: #c9a44c;
  --gold-soft: #e8d5a9;
  --purple: #7c5cff;
  --purple-dim: #4a3a8a;
  --text: #ece6f2;
  --text-dim: #a89bb8;
  --border: rgba(201, 164, 76, 0.22);
  --border-soft: rgba(236, 230, 242, 0.08);
  --success: #7fcf9e;
  --danger: #d97a72;
  --radius: 14px;
  --shadow: 0 20px 60px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
}

h1, h2, h3, .display {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

a { color: var(--gold-soft); }

#stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border-soft);
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.3rem;
  color: var(--gold-soft);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand .glyph {
  color: var(--purple);
  font-size: 1.1rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  transition: border-color .2s, color .2s;
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-soft); }

/* ── Buttons ───────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 999px;
  border: none;
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  color: #201406;
  box-shadow: 0 8px 24px rgba(201,164,76,0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(201,164,76,0.35); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-full { width: 100%; }

/* ── Login ─────────────────────────────────────────────────────────── */

.login-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 34px;
  box-shadow: var(--shadow);
  animation: riseIn .7s ease both;
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.8rem;
  color: var(--gold-soft);
}
.login-card .subtitle {
  margin: 0 0 28px;
  color: var(--text-dim);
  font-size: 0.92rem;
}

.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 7px;
}
.form-input {
  width: 100%;
  padding: 13px 15px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color .2s;
}
.form-input:focus {
  outline: none;
  border-color: var(--gold);
}

.forgot-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--text-dim);
  text-decoration: none;
}
.forgot-link:hover { color: var(--gold-soft); }

.alert {
  display: none;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 18px;
}
.alert.show { display: block; }
.alert.error { background: rgba(217,122,114,0.12); color: var(--danger); border: 1px solid rgba(217,122,114,0.3); }
.alert.success { background: rgba(127,207,158,0.12); color: var(--success); border: 1px solid rgba(127,207,158,0.3); }

.login-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ── Dashboard ─────────────────────────────────────────────────────── */

.dashboard-main {
  flex: 1;
  padding: 36px 28px 70px;
  max-width: 1080px;
  margin: 0 auto;
  width: 100%;
}

.dash-header {
  margin-bottom: 32px;
  animation: riseIn .6s ease both;
}
.dash-header h1 { font-size: 2rem; margin: 0 0 8px; color: var(--gold-soft); }
.dash-header p { color: var(--text-dim); margin: 0; font-size: 0.95rem; }

.progress-track {
  margin-top: 20px;
  height: 6px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--gold));
  border-radius: 999px;
  transition: width .6s ease;
}

.lezioni-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.lezione-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px 18px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 150px;
  opacity: 0;
  animation: riseIn .5s ease forwards;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.lezione-card:hover:not(.is-locked) {
  transform: translateY(-3px);
  border-color: var(--border);
  box-shadow: 0 14px 30px rgba(0,0,0,0.4);
}

.lezione-card.is-unlocked-today {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 0 24px rgba(201,164,76,0.25);
  animation: riseIn .5s ease forwards, glowPulse 3s ease-in-out infinite 1s;
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(201,164,76,0.18); }
  50% { box-shadow: 0 0 0 1px var(--gold), 0 0 30px rgba(201,164,76,0.4); }
}

.lezione-card.is-locked {
  cursor: default;
  opacity: 0.55;
  filter: grayscale(0.4);
}
.lezione-card.is-locked:hover { transform: none; }

.lezione-giorno {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lezione-titolo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--gold-soft);
  margin: 0;
  line-height: 1.25;
}
.lezione-numerale { color: var(--text-dim); font-weight: 400; font-size: 1rem; }

.lezione-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.badge-completa {
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 5px;
}
.badge-lock {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* stagger animation delay applied inline via style="animation-delay:" */

/* ── Player ────────────────────────────────────────────────────────── */

.player-main {
  flex: 1;
  padding: 28px 24px 70px;
  max-width: 920px;
  margin: 0 auto;
  width: 100%;
}

.player-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 18px;
}
.player-back:hover { color: var(--gold-soft); }

.player-header {
  margin-bottom: 20px;
  animation: riseIn .6s ease both;
}
.player-header .eyebrow {
  color: var(--purple);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0 0 6px;
}
.player-header h1 {
  font-size: 2.1rem;
  margin: 0;
  color: var(--gold-soft);
}

.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: riseIn .7s ease both .1s;
}
.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-pending {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: var(--text-dim);
  text-align: center;
  padding: 20px;
}
.video-pending .glyph { font-size: 2rem; color: var(--gold); }

.player-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
  animation: riseIn .7s ease both .2s;
}

.btn-secondary {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border-soft);
}
.btn-secondary:hover { border-color: var(--border); }

.btn-complete.is-done {
  background: rgba(127,207,158,0.14);
  color: var(--success);
  border: 1px solid rgba(127,207,158,0.35);
}

/* ── Misc ──────────────────────────────────────────────────────────── */

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(236,230,242,0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state, .empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

@media (max-width: 640px) {
  .topbar { padding: 14px 18px; }
  .dashboard-main, .player-main { padding-left: 16px; padding-right: 16px; }
  .lezioni-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .player-header h1 { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
