/* ============================================================
   Parquet — Modern UI Design System
   Light + Soft-dark themes, per-exam accents
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;450;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Type */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-feature-settings: "cv11", "ss01", "ss03", "calt", "tnum";

  /* Radii */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* Per-exam accents (HSL-friendly so we can derive hover) */
  --dp600-h: 245; --dp600-s: 78%; --dp600-l: 60%;   /* indigo */
  --dp700-h: 24;  --dp700-s: 92%; --dp700-l: 56%;   /* amber-rust */
  --dp800-h: 174; --dp800-s: 70%; --dp800-l: 42%;   /* teal */

  /* Default brand accent (used on the index page) */
  --brand-h: 245; --brand-s: 78%; --brand-l: 60%;

  /* Status hues (semantic — same in both themes) */
  --success-h: 152; --success-s: 60%;
  --danger-h:  6;   --danger-s:  78%;
  --warn-h:    38;  --warn-s:   92%;

  /* Motion */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --t-fast: 120ms;
  --t-base: 220ms;
  --t-slow: 380ms;
}

/* ============================================================
   LIGHT THEME (default)
   Clean, bright, high-contrast — modern app feel
   ============================================================ */
:root,
[data-theme="light"] {
  --bg:           #f6f7fb;
  --bg-elevated:  #ffffff;
  --surface:      #ffffff;
  --surface-2:    #f1f3f9;
  --surface-3:    #e7eaf3;
  --surface-hover:#f4f6fb;

  --border:       #e3e6ef;
  --border-strong:#d0d5e2;
  --divider:      #eef0f6;

  --text:         #0f1424;
  --text-2:       #353b51;
  --text-muted:   #5b6178;
  --text-faint:   #8b91a6;
  --text-onAccent:#ffffff;

  --accent:       hsl(var(--brand-h) var(--brand-s) var(--brand-l));
  --accent-hover: hsl(var(--brand-h) var(--brand-s) calc(var(--brand-l) - 6%));
  --accent-soft:  hsl(var(--brand-h) var(--brand-s) 96%);
  --accent-soft-2:hsl(var(--brand-h) var(--brand-s) 92%);
  --accent-text:  hsl(var(--brand-h) calc(var(--brand-s) - 12%) 38%);
  --ring:         hsl(var(--brand-h) var(--brand-s) var(--brand-l) / .35);

  --success:      hsl(var(--success-h) var(--success-s) 38%);
  --success-soft: hsl(var(--success-h) var(--success-s) 94%);
  --success-text: hsl(var(--success-h) var(--success-s) 30%);

  --danger:       hsl(var(--danger-h) var(--danger-s) 52%);
  --danger-soft:  hsl(var(--danger-h) var(--danger-s) 96%);
  --danger-text:  hsl(var(--danger-h) var(--danger-s) 44%);

  --warn:         hsl(var(--warn-h) var(--warn-s) 50%);
  --warn-soft:    hsl(var(--warn-h) var(--warn-s) 96%);
  --warn-text:    hsl(var(--warn-h) calc(var(--warn-s) - 10%) 38%);

  --shadow-sm:    0 1px 2px rgba(15, 20, 36, .04), 0 1px 1px rgba(15, 20, 36, .03);
  --shadow-md:    0 4px 12px -2px rgba(15, 20, 36, .06), 0 2px 4px -1px rgba(15, 20, 36, .04);
  --shadow-lg:    0 12px 32px -8px rgba(15, 20, 36, .12), 0 4px 12px -3px rgba(15, 20, 36, .06);
  --shadow-glow:  0 0 0 4px var(--ring);
}

/* ============================================================
   SOFT DARK THEME — slate / blue-gray, gentle contrast
   ============================================================ */
[data-theme="dark"] {
  --bg:           #0d1320;
  --bg-elevated:  #141b2c;
  --surface:      #1a2335;
  --surface-2:    #222d44;
  --surface-3:    #2c3954;
  --surface-hover:#212c43;

  --border:       #2a3550;
  --border-strong:#3a4768;
  --divider:      #1f2942;

  --text:         #e6ebf6;
  --text-2:       #c2cadd;
  --text-muted:   #8c95ad;
  --text-faint:   #5e6884;
  --text-onAccent:#0d1320;

  --accent:       hsl(var(--brand-h) calc(var(--brand-s) - 10%) 68%);
  --accent-hover: hsl(var(--brand-h) calc(var(--brand-s) - 10%) 74%);
  --accent-soft:  hsl(var(--brand-h) 40% 22% / .55);
  --accent-soft-2:hsl(var(--brand-h) 45% 28% / .8);
  --accent-text:  hsl(var(--brand-h) 60% 78%);
  --ring:         hsl(var(--brand-h) 60% 70% / .40);

  --success:      hsl(var(--success-h) 50% 58%);
  --success-soft: hsl(var(--success-h) 40% 22% / .55);
  --success-text: hsl(var(--success-h) 55% 72%);

  --danger:       hsl(var(--danger-h) 70% 65%);
  --danger-soft:  hsl(var(--danger-h) 50% 24% / .55);
  --danger-text:  hsl(var(--danger-h) 70% 78%);

  --warn:         hsl(var(--warn-h) 80% 62%);
  --warn-soft:    hsl(var(--warn-h) 50% 22% / .55);
  --warn-text:    hsl(var(--warn-h) 75% 75%);

  --shadow-sm:    0 1px 2px rgba(0, 0, 0, .25);
  --shadow-md:    0 6px 16px -4px rgba(0, 0, 0, .35), 0 2px 6px -2px rgba(0, 0, 0, .25);
  --shadow-lg:    0 16px 40px -10px rgba(0, 0, 0, .55), 0 6px 16px -4px rgba(0, 0, 0, .35);
  --shadow-glow:  0 0 0 4px var(--ring);
}

/* ============================================================
   PER-EXAM ACCENT OVERRIDES
   Set data-exam="dp600|dp700|dp800" on <html> to swap accent
   ============================================================ */
[data-exam="dp600"] { --brand-h: var(--dp600-h); --brand-s: var(--dp600-s); --brand-l: var(--dp600-l); }
[data-exam="dp700"] { --brand-h: var(--dp700-h); --brand-s: var(--dp700-s); --brand-l: var(--dp700-l); }
[data-exam="dp800"] { --brand-h: var(--dp800-h); --brand-s: var(--dp800-s); --brand-l: var(--dp800-l); }

/* ============================================================
   GLOBAL RESETS
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-feature-settings: var(--font-feature-settings);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  transition: background-color var(--t-base) var(--ease-out),
              color var(--t-base) var(--ease-out);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img, svg { display: block; max-width: 100%; }

::selection { background: var(--accent); color: var(--text-onAccent); }

/* Accessible focus */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  border-radius: var(--r-sm);
}

/* ============================================================
   TYPOGRAPHY UTILITIES
   ============================================================ */
.t-display {
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.05;
}
.t-h1 { font-size: clamp(36px, 5vw, 56px); font-weight: 700; letter-spacing: -0.025em; line-height: 1.05; }
.t-h2 { font-size: clamp(26px, 3vw, 34px); font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.t-h3 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.t-body-lg { font-size: 17px; line-height: 1.6; color: var(--text-2); }
.t-body { font-size: 15px; line-height: 1.55; color: var(--text-2); }
.t-small { font-size: 13px; line-height: 1.5; color: var(--text-muted); }
.t-mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em; }
.t-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.t-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.container-sm { max-width: 880px; margin: 0 auto; padding: 0 24px; }

/* ============================================================
   COMPONENTS — buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 550;
  letter-spacing: -0.005em;
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  transition:
    background-color var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out),
    color var(--t-fast) var(--ease-out),
    transform var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out);
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--text-onAccent);
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: transparent; box-shadow: var(--shadow-md); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }

.btn-soft {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: transparent;
}
.btn-soft:hover:not(:disabled) { background: var(--accent-soft-2); }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: var(--r-md); }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }

/* ============================================================
   COMPONENTS — card
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--t-base) var(--ease-out),
    box-shadow var(--t-base) var(--ease-out),
    transform var(--t-base) var(--ease-out),
    background-color var(--t-base) var(--ease-out);
}
.card-hover:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* ============================================================
   COMPONENTS — chips / badges
   ============================================================ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border);
}
.chip-accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.chip-success { background: var(--success-soft); color: var(--success-text); border-color: transparent; }
.chip-danger { background: var(--danger-soft); color: var(--danger-text); border-color: transparent; }
.chip-warn { background: var(--warn-soft); color: var(--warn-text); border-color: transparent; }

/* ============================================================
   COMPONENTS — Top bar / brand
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  padding: 0 24px;
  max-width: 1200px;
  margin: 0 auto;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 65%, var(--text)));
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 4px 10px -2px var(--ring);
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 4px;
  background: var(--bg);
  clip-path: polygon(0 100%, 0 60%, 33% 60%, 33% 30%, 66% 30%, 66% 0, 100% 0, 100% 100%);
  opacity: .92;
}
.brand-name { font-family: var(--font-sans); }
.brand-name em { font-style: normal; color: var(--accent); font-weight: 800; }

/* ============================================================
   COMPONENTS — Theme toggle
   ============================================================ */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  width: 56px;
  height: 32px;
  padding: 3px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background-color var(--t-base) var(--ease-out);
  position: relative;
  flex-shrink: 0;
}
.theme-toggle .knob {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  transition: transform var(--t-base) var(--ease-out);
  color: var(--text-2);
  position: relative;
  z-index: 2;
}
.theme-toggle .knob svg { width: 14px; height: 14px; }
.theme-toggle .knob .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .knob { transform: translateX(24px); color: var(--accent); }
[data-theme="dark"] .theme-toggle .knob .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .knob .icon-moon { display: block; }

/* ============================================================
   COMPONENTS — progress bar
   ============================================================ */
.progress {
  position: relative;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.progress > .bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--accent) 80%, transparent),
    var(--accent));
  width: 0%;
  transition: width var(--t-slow) var(--ease-out);
  position: relative;
}
.progress > .bar::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  animation: shimmer 2.4s linear infinite;
  border-radius: inherit;
}
@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ============================================================
   ANIMATION HELPERS
   ============================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-3px); }
  40%, 60% { transform: translateX(3px); }
}
@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 var(--ring); }
  70%  { box-shadow: 0 0 0 12px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.fade-up { animation: fadeUp .55s var(--ease-out) backwards; }
.fade-in { animation: fadeIn .4s var(--ease-out) backwards; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid var(--bg);
  border-radius: var(--r-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* Footer GitHub star + author link */
.author-link {
  color: var(--text); text-decoration: none;
  border-bottom: 1px dotted color-mix(in oklab, var(--accent) 50%, transparent);
  transition: color var(--t-fast), border-color var(--t-fast);
}
.author-link:hover { color: var(--accent); border-color: var(--accent); }
.qfooter > span:first-child,
.landing-footer > span:first-child,
.footer > span:first-child {
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px;
}
.gh-star {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 8px;
  padding: 5px 11px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 12px; font-weight: 600;
  text-decoration: none;
  transition: all var(--t-fast);
  line-height: 1;
}
.gh-star:hover {
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 50%, var(--border));
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.gh-star svg { transition: transform var(--t-fast); }
.gh-star:hover svg { transform: rotate(72deg) scale(1.15); fill: var(--accent); }
