/* ==========================================================================
   LIMITLESS DESIGN SYSTEM — foundation.css  (v1.0)
   Paper & Ink: the interface is a beautiful exam booklet.
   One source of truth for Limitless Learning (mytutorjeremy.com),
   Manifold, the graphing tools, and the practice-test platform.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. TOKENS — Light theme ("Paper")
   -------------------------------------------------------------------------- */
:root {
  /* Paper (surfaces) — warm cream ramp */
  --paper:        #F6F1E4;   /* default page */
  --paper-tint:   #EFE7D2;   /* slightly toasted — cards, headers */
  --paper-deep:   #E6DCC3;   /* sunken wells, code blocks */
  --paper-white:  #FBF8F0;   /* raised cards, inputs */

  /* Ink (text & lines) — five-step ramp, doubles as text + rules */
  --ink:          #14202E;   /* almost-black navy — primary text */
  --ink-2:        #2E3C50;   /* secondary text */
  --ink-3:        #5A6776;   /* tertiary, captions */
  --ink-4:        #94A0AE;   /* placeholder, disabled */
  --ink-line:     #C7BFAA;   /* hairlines on paper */
  --ink-rule:     #D9D2BD;   /* graph-paper ruling */

  /* Indigo — primary action colour (midnight) */
  --indigo:       #1E2856;
  --indigo-soft:  #3A4A82;
  --indigo-wash:  #E2E4EF;

  /* Gold / antique brass — the brand accent ramp.
     500 is decorative (large text, rules, icons);
     700 is the text-safe brass. */
  --gold-100:     #EAE0CB;   /* parchment wash */
  --gold-300:     #C8AC78;   /* faded brass */
  --gold-500:     #B8804A;   /* bright gold — decorative */
  --gold-700:     #7A5A2A;   /* deep brass — text-safe */
  --gold-900:     #4F3815;   /* walnut — press/hover */

  /* Semantic — grading colours */
  --correct:        #5A6B4D; /* sage */
  --correct-wash:   #E7EBDD;
  --incorrect:      #8A3A24; /* rust */
  --incorrect-wash: #F0DFD6;
  --flag:           #B8804A; /* gold — flagged for review */
  --flag-wash:      #F2E8D5;
  --info:           #3A4A82;
  --info-wash:      #E2E4EF;

  /* Aliases (back-compat with site + Manifold) */
  --bg: var(--paper);
  --accent: var(--indigo);
  --gold: var(--gold-500);
  --brass: var(--gold-700);
  --sage: var(--correct);
  --rust: var(--incorrect);

  /* Typography */
  --font-display: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --font-body:    'Geist', -apple-system, system-ui, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Type scale — 1.25 ratio on a 16px base */
  --text-xs:   0.75rem;    /* 12 — marginalia, keyboard hints */
  --text-sm:   0.8125rem;  /* 13 — captions, meta */
  --text-base: 0.9375rem;  /* 15 — UI body */
  --text-md:   1.0625rem;  /* 17 — reading body, question stems */
  --text-lg:   1.1875rem;  /* 19 — lead paragraphs */
  --text-xl:   1.5rem;     /* 24 — section titles */
  --text-2xl:  1.875rem;   /* 30 — page titles */
  --text-3xl:  2.375rem;   /* 38 — display */
  --text-4xl:  3rem;       /* 48 — hero */
  --text-5xl:  3.75rem;    /* 60 — score hero */

  --leading-tight: 1.15;
  --leading-snug:  1.35;
  --leading-body:  1.6;

  /* Spacing — 4px base */
  --space-1: 4px;  --space-2: 8px;   --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px;  --space-7: 48px; --space-8: 64px;
  --space-9: 96px;

  /* Radius */
  --radius-sm: 6px;   /* chips, kbd */
  --radius-md: 10px;  /* buttons, inputs */
  --radius-lg: 14px;  /* cards */
  --radius-xl: 20px;  /* modals, hero panels */
  --radius-pill: 999px;

  /* Elevation — warm, soft, paper-like */
  --shadow-sm: 0 1px 2px rgba(20, 32, 46, 0.06);
  --shadow-md: 0 2px 8px rgba(20, 32, 46, 0.08), 0 1px 2px rgba(20, 32, 46, 0.05);
  --shadow-lg: 0 12px 32px rgba(20, 32, 46, 0.12), 0 2px 8px rgba(20, 32, 46, 0.06);
  --shadow-inset-paper: inset 0 1px 0 rgba(255, 255, 255, 0.6);

  /* Rules & grid — the "exam paper" texture */
  --rule-gold: linear-gradient(90deg, var(--gold-500), var(--gold-300) 60%, transparent);
  --grid-paper:
    linear-gradient(var(--ink-rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--ink-rule) 1px, transparent 1px);
  --grid-size: 24px 24px;

  /* Motion */
  --ease-out:  cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast:  120ms;
  --dur-base:  200ms;
  --dur-slow:  320ms;

  /* Focus ring */
  --focus-ring: 0 0 0 3px rgba(58, 74, 130, 0.35);
}

/* --------------------------------------------------------------------------
   2. TOKENS — Focus Mode (dark) — "Midnight paper"
   Inverted booklet: cream ink on midnight navy. Used for evening study,
   the graphing tools, and distraction-free test taking.
   Apply with  <html data-theme="focus">  or  .theme-focus  on a container.
   -------------------------------------------------------------------------- */
[data-theme="focus"], .theme-focus {
  --paper:        #131722;
  --paper-tint:   #1A2030;
  --paper-deep:   #0E1119;
  --paper-white:  #202839;

  --ink:          #EDE8DB;
  --ink-2:        #C8C4B6;
  --ink-3:        #99938A;   /* AA on paper-tint for 13px+ */
  --ink-4:        #5D6470;
  --ink-line:     #313A4D;
  --ink-rule:     #232B3C;

  --indigo:       #8DA2E3;   /* actions flip to a luminous indigo */
  --indigo-soft:  #6E84C8;
  --indigo-wash:  #222B45;

  --gold-100:     #2C2618;
  --gold-300:     #C8AC78;
  --gold-500:     #D9B87E;
  --gold-700:     #C8AC78;
  --gold-900:     #EAD9AE;

  --correct:        #9DB48A;
  --correct-wash:   #223024;
  --incorrect:      #D98E70;
  --incorrect-wash: #3A241C;
  --flag:           #C8AC78;
  --flag-wash:      #322B1C;
  --info:           #8DA2E3;
  --info-wash:      #222B45;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-inset-paper: inset 0 1px 0 rgba(255, 255, 255, 0.04);

  --focus-ring: 0 0 0 3px rgba(141, 162, 227, 0.4);
}

/* --------------------------------------------------------------------------
   3. BASE
   -------------------------------------------------------------------------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--leading-tight);
  color: var(--ink);
  margin: 0 0 var(--space-3);
  letter-spacing: 0.01em;
}
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4, h5 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-base);
  margin: 0 0 var(--space-2);
}

p { margin: 0 0 var(--space-4); color: var(--ink-2); }
a { color: var(--indigo); text-decoration-color: var(--gold-300); text-underline-offset: 3px; }
a:hover { color: var(--indigo-soft); }
code, kbd, .mono { font-family: var(--font-mono); }
::selection { background: var(--gold-100); color: var(--ink); }

/* Overline — small-caps section label with a gold rule, a house signature */
.overline {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-700);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.overline::after { content: ""; height: 1px; flex: 0 0 48px; background: var(--rule-gold); }

/* Gold rule divider */
.rule-gold { border: 0; height: 1px; background: var(--rule-gold); margin: var(--space-5) 0; }

/* Keyboard hint */
kbd {
  font-size: var(--text-xs);
  color: var(--ink-2);
  background: var(--paper-white);
  border: 1px solid var(--ink-line);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  padding: 1px 6px;
}

/* --------------------------------------------------------------------------
   4. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  text-decoration: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--indigo); color: var(--paper-white); }
.btn-primary:hover { background: var(--indigo-soft); }

.btn-gold { background: var(--gold-700); color: var(--paper-white); }
.btn-gold:hover { background: var(--gold-900); }

.btn-secondary { background: transparent; color: var(--ink); border-color: var(--ink-line); }
.btn-secondary:hover { border-color: var(--ink-3); background: var(--paper-white); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--paper-tint); color: var(--ink); }

.btn-danger { background: var(--incorrect); color: var(--paper-white); }

.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.45; cursor: not-allowed; transform: none;
}

.btn-sm { padding: 8px 14px; font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn-lg { padding: 16px 28px; font-size: var(--text-md); border-radius: var(--radius-lg); }

/* --------------------------------------------------------------------------
   5. INPUTS
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field-label { font-size: var(--text-sm); font-weight: 600; color: var(--ink); }
.field-help  { font-size: var(--text-sm); color: var(--ink-3); }
.field-error { font-size: var(--text-sm); color: var(--incorrect); }

.input, .select, .textarea {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--paper-white);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.input::placeholder { color: var(--ink-4); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--indigo-soft); box-shadow: var(--focus-ring);
}
.input.is-error { border-color: var(--incorrect); }
.input-mono { font-family: var(--font-mono); }  /* numeric answers */

/* --------------------------------------------------------------------------
   6. CARDS & SURFACES
   -------------------------------------------------------------------------- */
.card {
  background: var(--paper-white);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm), var(--shadow-inset-paper);
  padding: var(--space-5);
}
.card-aged { background: var(--paper-tint); }
.card-well {
  background: var(--paper-deep);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-md);
  box-shadow: none;
  padding: var(--space-4);
}
.card-hover { transition: box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out); }
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

/* Graph-paper panel — for visuals and plots */
.panel-grid {
  background-color: var(--paper-white);
  background-image: var(--grid-paper);
  background-size: var(--grid-size);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-lg);
}

/* --------------------------------------------------------------------------
   7. BADGES & CHIPS
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-xs); font-weight: 600;
  font-family: var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase;
  padding: 4px 10px; border-radius: var(--radius-pill);
  border: 1px solid transparent;
}
.badge-correct   { background: var(--correct-wash);   color: var(--correct); }
.badge-incorrect { background: var(--incorrect-wash); color: var(--incorrect); }
.badge-flag      { background: var(--flag-wash);      color: var(--gold-700); }
.badge-info      { background: var(--info-wash);      color: var(--info); }
.badge-neutral   { background: var(--paper-deep);     color: var(--ink-2); }
.badge-outline   { background: transparent; border-color: var(--ink-line); color: var(--ink-2); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-sm); font-weight: 500;
  padding: 6px 14px; border-radius: var(--radius-pill);
  background: var(--paper-white); border: 1px solid var(--ink-line);
  color: var(--ink-2); cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.chip:hover { border-color: var(--ink-3); }
.chip.is-selected { background: var(--indigo); border-color: var(--indigo); color: var(--paper-white); }

/* --------------------------------------------------------------------------
   8. ANSWER OPTION — the heart of the test platform
   States: default → hover → selected → (submit) → correct / incorrect / revealed
   -------------------------------------------------------------------------- */
.answer {
  display: flex; align-items: flex-start; gap: var(--space-4);
  width: 100%; text-align: left;
  font-family: var(--font-body); font-size: var(--text-md); color: var(--ink);
  background: var(--paper-white);
  border: 1.5px solid var(--ink-line);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.answer:hover { border-color: var(--indigo-soft); box-shadow: var(--shadow-sm); }
.answer:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.answer-letter {
  font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 600;
  flex: 0 0 32px; height: 32px; display: grid; place-items: center;
  border: 1.5px solid var(--ink-line); border-radius: var(--radius-sm);
  color: var(--ink-3); background: var(--paper);
  transition: all var(--dur-fast) var(--ease-out);
}

.answer.is-selected { border-color: var(--indigo); background: var(--indigo-wash); }
.answer.is-selected .answer-letter { background: var(--indigo); border-color: var(--indigo); color: var(--paper-white); }

.answer.is-correct { border-color: var(--correct); background: var(--correct-wash); }
.answer.is-correct .answer-letter { background: var(--correct); border-color: var(--correct); color: var(--paper-white); }

.answer.is-incorrect { border-color: var(--incorrect); background: var(--incorrect-wash); }
.answer.is-incorrect .answer-letter { background: var(--incorrect); border-color: var(--incorrect); color: var(--paper-white); }

.answer.is-revealed { border-style: dashed; border-color: var(--correct); }
.answer.is-dimmed { opacity: 0.55; }

/* --------------------------------------------------------------------------
   9. QUESTION NAVIGATOR DOTS
   -------------------------------------------------------------------------- */
.qnav-dot {
  font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 500;
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--ink-line);
  background: var(--paper-white); color: var(--ink-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.qnav-dot:hover { border-color: var(--ink-3); }
.qnav-dot.is-answered { background: var(--indigo-wash); border-color: var(--indigo-soft); color: var(--indigo); }
.qnav-dot.is-current  { background: var(--indigo); border-color: var(--indigo); color: var(--paper-white); box-shadow: var(--shadow-sm); }
.qnav-dot.is-flagged  { border-color: var(--gold-500); background: var(--flag-wash); color: var(--gold-700); }
.qnav-dot.is-correct  { background: var(--correct-wash); border-color: var(--correct); color: var(--correct); }
.qnav-dot.is-incorrect{ background: var(--incorrect-wash); border-color: var(--incorrect); color: var(--incorrect); }

/* --------------------------------------------------------------------------
   10. PROGRESS
   -------------------------------------------------------------------------- */
.progress {
  height: 6px; border-radius: var(--radius-pill);
  background: var(--paper-deep); overflow: hidden;
}
.progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--indigo), var(--indigo-soft));
  border-radius: var(--radius-pill);
  transition: width var(--dur-slow) var(--ease-out);
}
.progress-gold > span { background: linear-gradient(90deg, var(--gold-700), var(--gold-500)); }

.timer {
  font-family: var(--font-mono); font-size: var(--text-md); font-weight: 500;
  color: var(--ink-2); display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 6px 14px; border-radius: var(--radius-pill);
  background: var(--paper-white); border: 1px solid var(--ink-line);
}
.timer.is-low { color: var(--incorrect); border-color: var(--incorrect); background: var(--incorrect-wash); }

/* --------------------------------------------------------------------------
   11. MOTION SAFETY
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
