/* ═══════════════════════════════════════════════════════════
   Quiz Atlas — fondations : jetons, reset, primitives
   Direction : « atlas de poche » — papier chaud, encre profonde,
   vermillon en accent, filets fins, numérotation à l'encre.
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Palette claire (papier) */
  --paper: #f6f2e9;
  --paper-raised: #fffdf7;
  --paper-sunken: #ece6d8;
  --ink: #16130e;
  --ink-soft: #5b554a;
  --ink-faint: #8b8375;
  --rule: #d9d1c0;
  --rule-strong: #b9af9a;
  --accent: #c8452f;
  --accent-ink: #ffffff;
  --good: #1d7a4f;
  --good-wash: #e2f2e8;
  --bad: #b4231f;
  --bad-wash: #fbe6e2;
  --focus: #1f5fd0;

  /* Typographie */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-ui: ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* Échelle */
  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: clamp(1.125rem, 0.9rem + 0.7vw, 1.375rem);
  --step-2: clamp(1.5rem, 1.1rem + 1.6vw, 2.125rem);
  --step-3: clamp(2.25rem, 1.4rem + 3.6vw, 4rem);
  --step-4: clamp(3rem, 1.6rem + 6vw, 6.5rem);

  /* Rythme */
  --space-1: 0.375rem;
  --space-2: 0.75rem;
  --space-3: 1.25rem;
  --space-4: 2rem;
  --space-5: 3.25rem;
  --radius: 4px;
  --radius-lg: 8px;
  --shadow: 0 1px 0 rgba(22, 19, 14, .06), 0 12px 32px -20px rgba(22, 19, 14, .45);

  --ease: cubic-bezier(.2, .7, .3, 1);
  --speed: 320ms;
}

[data-theme="dark"] {
  --paper: #101317;
  --paper-raised: #171b21;
  --paper-sunken: #0a0c0f;
  --ink: #ece7dc;
  --ink-soft: #a8a396;
  --ink-faint: #7d7a70;
  --rule: #262c34;
  --rule-strong: #3a424d;
  --accent: #ff6a4d;
  --accent-ink: #1a0d09;
  --good: #56d394;
  --good-wash: #102b21;
  --bad: #ff8a80;
  --bad-wash: #311513;
  --focus: #79b0ff;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04), 0 16px 40px -24px rgba(0, 0, 0, .9);
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--speed) var(--ease), color var(--speed) var(--ease);
}

h1, h2, h3, p, figure, dl, dd { margin: 0; }
fieldset { margin: 0; padding: 0; border: 0; }
button, input { font: inherit; color: inherit; }
img, svg { max-width: 100%; display: block; }

/* ── Accessibilité : focus, liens, lecteurs d'écran ───────── */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}
:focus:not(:focus-visible) { outline: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -4rem;
  z-index: 20;
  padding: var(--space-2) var(--space-3);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  text-decoration: none;
  transition: top 160ms var(--ease);
}
.skip-link:focus { top: var(--space-2); }

/* ── Barre supérieure ─────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) clamp(var(--space-3), 5vw, var(--space-5));
  border-bottom: 1px solid var(--rule);
}

.brand { display: flex; align-items: center; gap: var(--space-2); }

.brand__mark {
  display: grid;
  place-items: center;
  width: 2rem; height: 2rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-size: 1.125rem;
  border-radius: var(--radius);
}

.brand__name {
  font-family: var(--font-display);
  font-size: var(--step-1);
  letter-spacing: .01em;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.4rem 0.85rem;
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-size: var(--step--1);
  cursor: pointer;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease);
}
.theme-toggle:hover { background: var(--paper-sunken); border-color: var(--ink); }
.theme-toggle__icon { font-size: 1rem; line-height: 1; }

/* ── Boutons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.8rem 1.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: var(--step-0);
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  transition: transform 140ms var(--ease), background-color 160ms var(--ease),
              border-color 160ms var(--ease), color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn--primary {
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
}
.btn--primary:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); }

.btn--ghost {
  background: transparent;
  border-color: var(--rule-strong);
  color: var(--ink-soft);
}
.btn--ghost:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }

.btn__key {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  border: 1px solid currentColor;
  border-radius: 3px;
  opacity: .6;
}

/* ── Petits primitives typographiques ─────────────────────── */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--accent);
}

.display {
  font-family: var(--font-display);
  font-size: var(--step-4);
  font-weight: 600;
  line-height: .95;
  letter-spacing: -.02em;
  text-wrap: balance;
}
.display--sm { font-size: var(--step-3); }

.lede {
  max-width: 48ch;
  color: var(--ink-soft);
  font-size: var(--step-1);
}

.section-title {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--ink-faint);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--rule);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-soft);
}
.tag--score strong {
  font-family: var(--font-mono);
  font-size: .85em;
  color: var(--accent);
}

.tag--level[data-tone="easy"] { border-color: var(--good); color: var(--good); }
.tag--level[data-tone="medium"] { border-color: var(--accent); color: var(--accent); }
.tag--level[data-tone="hard"] { border-color: var(--bad); color: var(--bad); }

kbd {
  font-family: var(--font-mono);
  font-size: .75em;
  padding: .1em .4em;
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--paper-sunken);
}

/* ── Scène & écrans ───────────────────────────────────────── */
.stage {
  flex: 1;
  width: 100%;
  max-width: 62rem;
  margin: 0 auto;
  padding: clamp(var(--space-4), 6vw, var(--space-5)) clamp(var(--space-3), 5vw, var(--space-5));
}

.screen { display: none; }
.screen.is-active { display: block; animation: screen-in var(--speed) var(--ease) both; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.colophon {
  border-top: 1px solid var(--rule);
  padding: var(--space-3) clamp(var(--space-3), 5vw, var(--space-5));
  font-size: var(--step--1);
  color: var(--ink-faint);
}

/* ── Mouvement réduit ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
