/* ============================================================
   THE AUTHORITY CODE: Design System
   Near-black canvas, champagne gold, serif display + sans body.
   Quiet authority. Premium and calm. Never bouncy.
   ============================================================ */

:root {
  /* Canvas */
  --bg-0: #0a0a0b;
  --bg-1: #0e0e10;
  --bg-2: #141417;
  --bg-3: #1b1b1f;
  --line: rgba(201, 165, 92, 0.16);
  --line-soft: rgba(255, 255, 255, 0.07);

  /* Gold */
  --gold: #c9a55c;
  --gold-bright: #e6c87e;
  --gold-deep: #9a7c3e;
  --gold-glow: rgba(201, 165, 92, 0.14);

  /* Ink */
  --ink: #f2ece0;
  --ink-soft: #d4ccbd;
  --ink-mute: #9c9588;
  --ink-faint: #6b6659;

  /* Accents */
  --red: #c0463b;
  --red-soft: rgba(192, 70, 59, 0.14);
  --green: #6f9a5e;

  /* Type */
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Manrope", system-ui, sans-serif;

  /* Layout */
  --col: 760px;
  --col-wide: 1080px;
  --radius: 14px;
  --radius-sm: 9px;
  --bar-h: 64px;

  /* Motion */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --t-fast: 0.18s;
  --t: 0.32s;
  --t-slow: 0.6s;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background: var(--bg-0);
  color: var(--ink);
  line-height: 1.65;
  font-size: 17px;
  letter-spacing: 0.005em;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
a { color: var(--gold-bright); text-decoration: none; }

/* ---------- Background atmosphere ---------- */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(900px 600px at 70% -10%, var(--gold-glow), transparent 60%),
    radial-gradient(700px 500px at 10% 110%, rgba(201,165,92,0.06), transparent 60%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
}
/* fine grain */
.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 500; line-height: 1.15; color: var(--ink); }
.display {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  letter-spacing: -0.01em;
}
.display em { font-style: italic; color: var(--gold-bright); }
.eyebrow {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.32em;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gold);
}
.lead { color: var(--ink-soft); font-size: 1.08rem; }
.muted { color: var(--ink-mute); }
.serif { font-family: var(--serif); }

/* ---------- Shell / layout ---------- */
.shell {
  max-width: var(--col);
  margin: 0 auto;
  padding: 0 24px;
}
.shell-wide { max-width: var(--col-wide); margin: 0 auto; padding: 0 24px; }
.page {
  padding-top: calc(var(--bar-h) + 40px);
  padding-bottom: 120px;
}

/* ---------- Top bar ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--bar-h);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  background: rgba(10, 10, 11, 0.72);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__logo { height: 30px; width: auto; display: block; }
.topbar__wordmark {
  font-family: var(--serif);
  font-size: 0.96rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
}
.topbar__title {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar__spacer { flex: 1; }
.topbar__right { display: flex; align-items: center; gap: 16px; }

/* topbar progress group (player pages) */
.topbar__progress {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 360px;
}
.topbar__progress-label {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  white-space: nowrap;
}

/* autosave indicator */
.autosave {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.76rem;
  color: var(--ink-mute);
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.autosave__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-faint);
  transition: background var(--t-fast);
}
.autosave.is-saving .autosave__dot { background: var(--gold); animation: pulse 1s infinite; }
.autosave.is-saved .autosave__dot { background: var(--green); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- Progress bar ---------- */
.progress {
  position: relative;
  height: 6px;
  background: var(--bg-3);
  border-radius: 99px;
  overflow: hidden;
  flex: 1;
  max-width: 320px;
  box-shadow: inset 0 0 0 1px var(--line-soft);
}
.progress__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-bright));
  border-radius: 99px;
  transition: width var(--t-slow) var(--ease);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 13px 24px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: transform var(--t-fast) var(--ease), background var(--t), border-color var(--t), color var(--t), box-shadow var(--t);
  background: var(--bg-2);
  color: var(--ink);
  border-color: var(--line-soft);
}
.btn:hover { border-color: var(--line); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn--gold {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #20180a;
  border-color: transparent;
  box-shadow: 0 6px 24px -10px rgba(201,165,92,0.6);
}
.btn--gold:hover { box-shadow: 0 10px 30px -10px rgba(201,165,92,0.8); border-color: transparent; }
.btn--ghost { background: transparent; }
.btn--block { width: 100%; }
.btn--lg { padding: 16px 30px; font-size: 1rem; }

/* ---------- Forms ---------- */
.field { margin-bottom: 22px; }
.field__label {
  display: block;
  font-size: 0.98rem;
  color: var(--ink);
  margin-bottom: 10px;
  font-weight: 500;
  font-family: var(--serif);
  line-height: 1.4;
}
.input, .textarea, select.input {
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  color: var(--ink);
  padding: 13px 15px;
  font-size: 1rem;
  line-height: 1.6;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
  resize: vertical;
}
.textarea { min-height: 110px; }
.input::placeholder, .textarea::placeholder { color: var(--ink-faint); }
.input:focus, .textarea:focus, select.input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
  background: var(--bg-2);
}
/* B4: force dark styling on browser autofill (no light-blue boxes).
   The inset shadow paints over the user-agent yellow/blue fill. */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus,
.input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-1) inset;
  box-shadow: 0 0 0 1000px var(--bg-1) inset;
  caret-color: var(--ink);
  transition: background-color 9999s ease-in-out 0s;
}
.input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-2) inset, 0 0 0 3px var(--gold-glow);
  box-shadow: 0 0 0 1000px var(--bg-2) inset, 0 0 0 3px var(--gold-glow);
}

/* Nice-to-have: hide the visible drag corner on textareas. They keep a
   comfortable min-height and the player auto-sizes them as you write. */
.textarea { resize: none; }

/* B5: invalid-field affordance on pages that only load style.css (login). */
.field.is-invalid .input,
.field.is-invalid .textarea,
.field.is-invalid select.input { border-color: var(--red); }

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 26px;
  transition: border-color var(--t), transform var(--t-fast) var(--ease), box-shadow var(--t);
}
.card--hover:hover { border-color: var(--line); transform: translateY(-2px); box-shadow: 0 18px 50px -30px rgba(0,0,0,0.9); }

/* ---------- Blueprint cards (dashboard) ---------- */
.bp-card { position: relative; cursor: pointer; }
.bp-card__row { display: flex; gap: 18px; align-items: flex-start; }
.bp-card__icon {
  font-size: 2rem; line-height: 0; flex-shrink: 0;
  color: var(--gold);
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--gold-glow), transparent);
}
.bp-card.is-locked .bp-card__icon { color: var(--ink-mute); }
.bp-card__body { flex: 1; min-width: 0; }
.bp-card__head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-right: 34px; /* room for the lock/arrow top-right */
}
.bp-card__title { font-size: 1.4rem; }
.bp-card__desc { color: var(--ink-mute); margin-top: 6px; }
.bp-card__progress {
  display: flex; align-items: center; gap: 14px; margin-top: 16px;
}
.bp-card__progress .progress { max-width: none; }
.bp-card__progress-label { font-size: 0.82rem; color: var(--ink-mute); white-space: nowrap; }
.bp-card__note { color: var(--ink-mute); margin-top: 14px; font-size: 0.84rem; }
.bp-card__corner {
  position: absolute; top: 18px; right: 18px;
  color: var(--ink-mute); font-size: 1.2rem; line-height: 1;
}
.bp-card.is-locked { opacity: 0.78; }
.bp-card.is-locked .bp-card__icon,
.bp-card.is-locked .bp-card__title,
.bp-card.is-locked .bp-card__desc { opacity: 0.8; }

/* ---------- Callouts ---------- */
.callout {
  border-left: 2px solid var(--gold);
  background: linear-gradient(90deg, var(--gold-glow), transparent 70%);
  padding: 18px 22px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 26px 0;
}
.callout p { color: var(--ink); font-family: var(--serif); font-size: 1.12rem; line-height: 1.5; }
.callout p + p { margin-top: 8px; color: var(--ink-soft); }

/* Mirror block: quiet, recessed, italic */
.mirror {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin: 24px 0;
}
.mirror p {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1.08rem;
  line-height: 1.55;
}
.mirror p + p { margin-top: 10px; }

.after-text { color: var(--ink-soft); margin: 18px 0; }
.after-text p + p { margin-top: 10px; }

/* ---------- Expandable panels (systems / archetypes) ---------- */
.panel {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-1);
  margin: 14px 0;
  overflow: hidden;
  transition: border-color var(--t);
}
.panel.is-open { border-color: var(--line); }
.panel__head {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--ink);
  padding: 18px 20px;
}
.panel__icon { color: var(--gold); font-size: 1rem; }
.panel__title { font-family: var(--serif); font-size: 1.1rem; flex: 1; }
.panel__chev { color: var(--ink-mute); transition: transform var(--t) var(--ease); }
.panel.is-open .panel__chev { transform: rotate(180deg); }
.panel__body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--t) var(--ease);
}
.panel.is-open .panel__body { grid-template-rows: 1fr; }
.panel__body > div { overflow: hidden; }
.panel__inner { padding: 0 20px 20px; color: var(--ink-soft); }
.panel__inner p + p { margin-top: 10px; }

/* Archetype score row */
.score-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 16px 0 18px;
}
.score-row__label { width: 100%; font-size: 0.82rem; color: var(--ink-mute); letter-spacing: 0.04em; margin-bottom: 2px; }
.score {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--bg-2);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--t-fast) var(--ease);
}
.score:hover { border-color: var(--gold); color: var(--ink); }
.score.is-active {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #20180a;
  border-color: transparent;
  box-shadow: 0 4px 14px -6px rgba(201,165,92,0.7);
}

/* ---------- Section / step containers ---------- */
.section-head { margin-bottom: 26px; }
.section-num {
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--gold);
  letter-spacing: 0.1em;
}
/* B3: blueprint-header line icon in place of the old emoji. */
.section-num--icon { line-height: 0; margin-bottom: 6px; }
.section-title {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  margin-top: 4px;
}
.intro-text { color: var(--ink-soft); margin: 16px 0; }
.intro-text p + p { margin-top: 10px; }

.divider { height: 1px; background: var(--line-soft); margin: 34px 0; border: none; }

/* ---------- Reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity var(--t-slow) var(--ease), transform var(--t-slow) var(--ease); }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  * { scroll-behavior: auto; }
}

/* ---------- Modal / overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6,6,7,0.74);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity var(--t) var(--ease);
}
.overlay.is-open { display: flex; opacity: 1; }
.modal {
  width: 100%;
  max-width: 480px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  transform: translateY(12px) scale(0.98);
  transition: transform var(--t) var(--ease);
  box-shadow: 0 40px 90px -40px rgba(0,0,0,0.9);
}
.overlay.is-open .modal { transform: none; }
.modal__icon { font-size: 1.8rem; line-height: 0; margin-bottom: 14px; color: var(--gold); }
.modal__title { font-family: var(--serif); font-size: 1.5rem; margin-bottom: 12px; }
.modal__body { color: var(--ink-soft); margin-bottom: 22px; }
.modal__body p + p { margin-top: 10px; }
.modal__actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- Completion overlay ---------- */
.completion {
  text-align: center;
  max-width: 540px;
}
.completion__seal {
  width: 84px; height: 84px;
  margin: 0 auto 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 2rem;
  background: radial-gradient(circle at 35% 30%, var(--gold-bright), var(--gold-deep));
  color: #20180a;
  box-shadow: 0 0 50px -8px var(--gold-glow);
}

/* ---------- Utilities ---------- */
.stack > * + * { margin-top: 16px; }
.center { text-align: center; }
.flex { display: flex; }
.gap { gap: 12px; }
.hidden { display: none !important; }
.full { width: 100%; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--line-soft); color: var(--ink-mute);
}
.chip--gold { color: var(--gold); border-color: var(--line); }
.chip--green { color: var(--green); border-color: rgba(111,154,94,0.4); }
.chip--locked { color: var(--ink-faint); }
.chip--mute { color: var(--ink-mute); }
/* A6: clickable filter chip (Drills Library). */
.chip--filter {
  cursor: pointer; background: transparent;
  transition: color var(--t), border-color var(--t), background var(--t);
}
.chip--filter:hover { color: var(--ink-soft); border-color: var(--line); }
.chip--filter.is-active {
  color: var(--gold); border-color: var(--gold);
  background: var(--gold-glow);
}

/* ---------- Drills Library controls (A6) ---------- */
.drill-controls {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 26px;
}
.drill-search { margin-bottom: 16px; }
.drill-filter { display: flex; align-items: baseline; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.drill-filter__label {
  flex: 0 0 86px;
  font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-faint); padding-top: 4px;
}
.drill-filter__chips { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 0; }
.drill-controls__foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.drill-count { font-size: 0.84rem; }
.drill-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
@media (max-width: 640px) {
  .drill-filter { flex-direction: column; gap: 6px; }
  .drill-filter__label { flex-basis: auto; padding-top: 0; }
}

/* ---------- Custom line icons (B3) ---------- */
.ic { display: inline-block; vertical-align: middle; color: var(--gold); }
.ic--lock { color: var(--ink-mute); }

/* spinner */
.spinner {
  width: 26px; height: 26px;
  border: 2px solid var(--line-soft);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loading-screen { min-height: 70vh; display: grid; place-items: center; }
@keyframes spin { to { transform: rotate(360deg); } }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-3); border: 1px solid var(--line);
  color: var(--ink); padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 0.9rem; z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity var(--t), transform var(--t) var(--ease);
}
.toast.is-show { opacity: 1; transform: translateX(-50%); }
.toast--err { border-color: rgba(192,70,59,0.5); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .page { padding-top: calc(var(--bar-h) + 28px); padding-bottom: 80px; }

  /* A4: compact, breathing header */
  .topbar { gap: 10px; padding: 0 16px; }
  .topbar__title { display: none; }
  .topbar__right { gap: 10px; }
  .topbar__wordmark { font-size: 0.86rem; letter-spacing: 0.14em; }
  .topbar__progress { max-width: none; gap: 8px; }
  .topbar__progress-label { font-size: 0.66rem; letter-spacing: 0.1em; }

  /* A7: wider, even side margins; no horizontal overflow.
     Use logical left/right only so the .page top offset (which clears the
     fixed header) is never reset by this shorthand. */
  .shell, .shell-wide { padding-left: 20px; padding-right: 20px; }
  .card { padding: 20px; }
  .modal { padding: 24px; }

  /* B8: the 1-10 rating buttons form two even rows of five, each a
     comfortable tap target instead of cramped wrapping. */
  .score-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }
  .score-row__label { grid-column: 1 / -1; }
  .score { width: 100%; height: 46px; font-size: 1rem; }

  /* A7: comfortable tap targets */
  .btn { min-height: 44px; padding: 12px 20px; }
  .nav-item { min-height: 44px; }
  .panel__head { padding: 16px; min-height: 44px; }

  /* A5: callouts and long serif body sit smaller and tighter on a phone */
  .callout { padding: 16px 18px; margin: 22px 0; }
  .callout p { font-size: 1rem; line-height: 1.45; }
  .callout p + p { font-size: 0.96rem; }
  .mirror { padding: 18px 18px; }
  .mirror p { font-size: 1rem; line-height: 1.5; }
  .video-gate__body p { font-size: 1rem; line-height: 1.55; }
  .profile__lead { font-size: 1rem; }

  /* A6: shorter textareas (JS auto-grows them as the student writes) */
  .textarea { min-height: 84px; }

  /* A3: dashboard cards stack fully vertically on a phone */
  .bp-card__row { flex-direction: column; gap: 14px; }
  .bp-card__icon { font-size: 1.8rem; }
  .bp-card__head { flex-direction: column; align-items: flex-start; gap: 8px; padding-right: 28px; }
  .bp-card__progress { flex-direction: column; align-items: stretch; gap: 8px; }
  .bp-card__progress-label { white-space: normal; }
}
