/* ============================================================
   TypingTestPro — Parchment & Rust Theme
   Background: #F5EDE4 (warm parchment)
   Accent:     #B85C38 (rust / burnt sienna)
   Fonts loaded via <link> in HTML head (non-render-blocking)
   ============================================================ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --accent:         #B85C38;
  --accent-dim:     rgba(184,92,56,.1);
  --accent-border:  rgba(184,92,56,.28);
  --accent-hover:   #A0502F;
  --accent-light:   #FBF0EA;

  --ok:             #4A8C6A;
  --ok-dim:         rgba(74,140,106,.1);
  --err:            #B84040;
  --err-dim:        rgba(184,64,64,.1);
  --warn:           #A8832A;
  --warn-dim:       rgba(168,131,42,.1);

  /* Backgrounds — warm parchment stack */
  --bg:             #F5EDE4;
  --bg-raised:      #EDE2D6;
  --surface:        #FBF6F0;
  --surface-2:      #F3EBE0;
  --surface-3:      #EAE0D4;

  /* Borders — warm tan */
  --border:         #E0D4C6;
  --border-2:       #CDBFAE;
  --border-focus:   rgba(184,92,56,.4);

  /* Text — warm dark brown, all pass WCAG AA 4.5:1 on --bg */
  --text:           #2A1F16;   /* contrast ~12:1 */
  --text-2:         #4A3A2C;   /* contrast ~8:1  */
  --text-3:         #6B5546;   /* contrast ~5:1  */
  --text-4:         #8A6F5C;   /* contrast ~4.6:1 — min for labels */

  --radius-xs:      4px;
  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      14px;
  --radius-xl:      20px;
  --radius-2xl:     28px;
  --radius-full:    9999px;

  --shadow-sm:  0 1px 2px rgba(60,30,10,.07);
  --shadow:     0 2px 8px rgba(60,30,10,.09);
  --shadow-md:  0 6px 20px rgba(60,30,10,.11);
  --shadow-lg:  0 12px 36px rgba(60,30,10,.13);
  --shadow-xl:  0 20px 56px rgba(60,30,10,.15);

  --font:       'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', 'Cascadia Code', monospace;

  --nav-height:     64px;
  --container:      1120px;
  --container-sm:   740px;

  --transition:     150ms ease;
  --transition-md:  240ms ease;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, video, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* ── Layout ─────────────────────────────────────────────── */
.container    { width: 100%; max-width: var(--container);    margin: 0 auto; padding: 0 24px; }
.container-sm { width: 100%; max-width: var(--container-sm); margin: 0 auto; padding: 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ============================================================
   NAVIGATION
   ============================================================ */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgba(245,237,228,.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; height: 100%; }
.nav-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
  white-space: nowrap;
  margin-right: 32px;
  flex-shrink: 0;
}
.nav-logo-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.nav-logo-icon svg { width: 16px; height: 16px; }
.nav-logo span { color: var(--text); }

.nav-links { display: flex; align-items: center; flex: 1; }
.nav-link {
  position: relative;
  padding: 0 14px;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-3);
  transition: color var(--transition);
}
.nav-link:hover { color: var(--text-2); }
.nav-link.active { color: var(--accent); font-weight: 600; }
.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 14px; right: 14px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}
.nav-icon { display: none; }

.nav-cta { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 8px;
  margin-left: 8px;
}
.nav-hamburger span { display: block; width: 20px; height: 1.5px; background: var(--text-3); border-radius: 2px; transition: all var(--transition-md); }

.mobile-nav {
  display: none;
  position: fixed;
  top: var(--nav-height); left: 0; right: 0;
  background: rgba(245,237,228,.97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px 16px;
  z-index: 99;
  box-shadow: var(--shadow-md);
}
.mobile-nav.open { display: block; }
.mobile-nav .nav-link { display: block; height: auto; padding: 11px 12px; border-radius: var(--radius); }
.mobile-nav .nav-link::after { display: none; }
.mobile-nav .nav-link.active { background: var(--accent-dim); color: var(--accent); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 18px;
  height: 38px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
  white-space: nowrap;
  line-height: 1;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(184,92,56,.3); }
.btn-outline { background: transparent; color: var(--accent); border: 1px solid var(--accent-border); }
.btn-outline:hover { background: var(--accent-dim); }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-lg { height: 46px; padding: 0 26px; font-size: 15px; border-radius: var(--radius-lg); }
.btn-sm { height: 32px; padding: 0 14px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-full { width: 100%; }
.btn-success { background: var(--ok); color: #fff; }
.btn-success:hover { background: #3A7558; transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  padding: 64px 0 56px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-full);
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 24px;
}
.hero h1 {
  font-size: clamp(30px, 5.5vw, 52px);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -.035em;
  color: var(--text);
  margin-bottom: 18px;
}
.hero h1 span { color: var(--accent); }
.hero p {
  font-size: clamp(15px, 1.8vw, 17px);
  color: var(--text-3);
  max-width: 520px;
  margin: 0 auto 36px;
  line-height: 1.7;
}
.hero-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  margin-top: 36px;
  flex-wrap: wrap;
}
.hero-stat { text-align: center; }
.hero-stat-value { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.hero-stat-label { font-size: 11px; color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: .07em; margin-top: 3px; }

/* ============================================================
   TYPING TEST WIDGET
   ============================================================ */
.test-section { padding: 32px 0 40px; }
.test-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color var(--transition-md), box-shadow var(--transition-md);
}
.test-card:focus-within { border-color: var(--border-focus); box-shadow: var(--shadow-md); }

.test-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  gap: 16px;
  flex-wrap: wrap;
}
.test-duration-selector {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 3px;
  border: 1px solid var(--border);
}
.duration-btn {
  padding: 5px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-3);
  transition: color var(--transition), background var(--transition);
}
.duration-btn.active { background: var(--accent); color: #fff; }
.duration-btn:not(.active):hover { color: var(--text); background: var(--surface-3); }

.test-stats-bar { display: flex; align-items: center; gap: 28px; }
.stat-item { display: flex; flex-direction: column; align-items: center; min-width: 48px; }
.stat-value { font-size: 18px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1; }
.stat-label { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--text-4); margin-top: 3px; }
.stat-item.timer .stat-value { color: var(--accent); }
.stat-item.timer.warning .stat-value { color: var(--warn); }
.stat-item.timer.danger  .stat-value { color: var(--err); }

.test-body { padding: 36px 28px 24px; }
.test-start-overlay { text-align: center; padding: 60px 24px; }
.test-start-overlay h3 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.test-start-overlay p  { color: var(--text-3); margin-bottom: 28px; font-size: 14px; }

.words-display {
  font-family: var(--font-mono);
  font-size: 20px;
  line-height: 2;
  height: 150px;
  overflow: hidden;
  position: relative;
  user-select: none;
  cursor: text;
  display: none;
}
.words-display.active { display: block; }
.words-display::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 56px;
  background: linear-gradient(transparent, var(--surface));
  pointer-events: none;
}
.word {
  display: inline-block;
  margin: 0 3px;
  padding: 1px 3px;
  border-radius: 4px;
  transition: background var(--transition);
}
/* Active word — soft warm highlight so position is always visible */
.word.current {
  background: rgba(184,92,56,.1);
  outline: 1px solid rgba(184,92,56,.2);
  outline-offset: 1px;
}
/* Completed words */
.word.word-incorrect {
  background: rgba(184,64,64,.07);
  border-radius: 4px;
}

.char { color: var(--text-4); position: relative; }
.char.correct   { color: var(--ok); }
.char.incorrect { color: var(--err); text-decoration: underline wavy var(--err); }

/* Cursor — placed before the next character to type */
.char.cursor::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 12%;
  height: 78%;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
  animation: blink .85s step-end infinite;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

.typing-input-hidden { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; left: -9999px; }
.typing-input-visible {
  display: none;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  font-family: var(--font-mono);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  margin-top: 14px;
}
.typing-input-visible:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(184,92,56,.1); }

.test-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px 22px;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
}
.test-footer-left { display: flex; align-items: center; gap: 8px; }
.test-hint { font-size: 12px; color: var(--text-4); display: flex; align-items: center; gap: 5px; }
.kbd {
  display: inline-flex;
  align-items: center;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xs);
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  color: var(--text-3);
}

/* ============================================================
   RESULTS OVERLAY
   ============================================================ */
.results-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(42,31,22,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(6px);
}
.results-overlay.show { display: flex; }
.results-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  padding: 44px 40px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: slideUp .22s ease;
  text-align: center;
  position: relative;
}
.results-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.results-close:hover {
  background: var(--err-dim);
  color: var(--err);
  border-color: rgba(184,64,64,.3);
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.results-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--text-4); margin-bottom: 8px; }
.results-wpm { font-size: 84px; font-weight: 900; color: var(--accent); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.results-wpm-label { font-size: 14px; color: var(--text-3); font-weight: 500; margin-bottom: 28px; }
.results-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.results-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 8px;
}
.results-stat-value { font-size: 20px; font-weight: 700; color: var(--text); }
.results-stat-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-4); margin-top: 4px; }
.results-perf { font-size: 13px; color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px; margin-bottom: 20px; }
.results-perf strong { color: var(--accent); font-weight: 600; }
.results-actions { display: flex; flex-direction: column; gap: 8px; }
.results-divider { text-align: center; font-size: 12px; color: var(--text-4); margin: 4px 0; }

/* ============================================================
   DIFFICULTY / MODE SELECTOR
   ============================================================ */
.test-difficulty-selector {
  padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: var(--surface-2);
}
.selector-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.selector-label { font-size: 10px; font-weight: 600; color: var(--text-4); text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; min-width: 38px; }
.diff-btn, .mode-btn {
  padding: 3px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-2);
  background: transparent;
  font-size: 12px; font-weight: 500;
  cursor: pointer; color: var(--text-3);
  transition: all var(--transition);
  line-height: 1.6;
}
.diff-btn:hover, .mode-btn:hover { border-color: var(--accent-border); color: var(--accent); }
.diff-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.mode-btn.active { background: var(--ok); border-color: var(--ok); color: #fff; }
#passageInfo { font-size: 11px; color: var(--accent); background: var(--accent-dim); border-radius: var(--radius-full); padding: 2px 10px; display: none; }

/* ============================================================
   CONTENT CARDS
   ============================================================ */
.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 12px;
  transition: border-color var(--transition-md), box-shadow var(--transition-md);
}
.info-card:hover { border-color: var(--border-2); box-shadow: var(--shadow-sm); }
.info-card-title { font-weight: 600; color: var(--text); font-size: 14px; margin-bottom: 6px; display: flex; align-items: center; gap: 10px; }
.info-card-num { width: 24px; height: 24px; background: var(--accent); color: #fff; border-radius: 50%; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.info-card p { color: var(--text-3); font-size: 13.5px; line-height: 1.7; margin: 0; }

.cards-grid   { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin: 12px 0; }
.cards-grid-2 { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }

.tip-card { background: var(--accent-light); border-left: 2px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; padding: 14px 18px; }
.tip-card-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: 4px; }
.tip-card p { color: var(--text-2); font-size: 13.5px; line-height: 1.65; margin: 0; }

.content-list { list-style: none; padding: 0; margin: 10px 0; }
.content-list li { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-2); line-height: 1.6; text-align: justify; }
.content-list li:last-child { border-bottom: none; }
.content-list li::before { content: '–'; color: var(--accent); font-weight: 700; flex-shrink: 0; }
.content-list li strong { color: var(--text); font-weight: 600; }
.mistake-list li::before { content: '→'; color: var(--accent); }
.warning-list li::before { content: '!'; color: var(--warn); }

.highlight-box { background: var(--accent-light); border: 1px solid var(--accent-border); border-radius: var(--radius-lg); padding: 14px 18px; margin: 12px 0; }
.highlight-box p { color: var(--text-2); font-size: 14px; margin: 0; line-height: 1.7; text-align: justify; }

/* ============================================================
   CONTENT SECTIONS
   ============================================================ */
.section { padding: 40px 0; }
.section-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-sm { padding: 24px 0; }
.section p, .content-block p { color: var(--text-2); font-size: 14.5px; line-height: 1.75; margin-bottom: 10px; text-align: justify; }
.section p:last-child, .content-block p:last-child { margin-bottom: 0; }
.section h2 { font-size: clamp(19px, 2.8vw, 26px); font-weight: 700; color: var(--text); margin-bottom: 8px; letter-spacing: -.02em; }
.section h3 { font-size: 16px; font-weight: 600; color: var(--text); margin: 16px 0 6px; padding-left: 10px; border-left: 2px solid var(--accent); }
.section h4 { font-size: 14px; font-weight: 600; color: var(--text); margin: 14px 0 5px; }

.prose-wrap { max-width: 780px; margin: 0 auto; }
.prose-wrap p, .prose-wrap li { font-size: 15px; line-height: 1.75; color: var(--text-2); margin-bottom: 10px; text-align: justify; }
.prose-wrap p:last-child { margin-bottom: 0; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 14px 0; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:nth-child(even) td { background: var(--surface-2); }
.data-table tbody tr:hover td { background: var(--accent-light); }
.data-table .highlight { font-weight: 600; color: var(--accent); }

.section-header { text-align: center; margin-bottom: 24px; }
.section-tag { display: inline-block; background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-border); border-radius: var(--radius-full); padding: 3px 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.section-title { font-size: clamp(20px, 3vw, 28px); font-weight: 800; letter-spacing: -.025em; color: var(--text); line-height: 1.2; margin-bottom: 8px; }
.section-subtitle { font-size: 14.5px; color: var(--text-3); max-width: 520px; margin: 0 auto; line-height: 1.65; }

/* Feature Grid */
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.feature-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; transition: border-color var(--transition-md), box-shadow var(--transition-md); }
.feature-card:hover { border-color: var(--accent-border); box-shadow: var(--shadow); }
.feature-icon { width: 40px; height: 40px; background: var(--accent-dim); border: 1px solid var(--accent-border); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 14px; }
.feature-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.feature-desc { font-size: 13.5px; color: var(--text-3); line-height: 1.65; }

/* Stats Cards */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 36px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px 20px; text-align: center; }
.stat-card-value { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1; margin-bottom: 6px; letter-spacing: -.02em; }
.stat-card-label { font-size: 12px; color: var(--text-3); font-weight: 500; }

/* ============================================================
   ARTICLE STYLES
   ============================================================ */
.article-hero { padding: 48px 0 36px; border-bottom: 1px solid var(--border); background: var(--surface); }
.article-meta { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.article-tag { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-border); border-radius: var(--radius-full); padding: 3px 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.article-date { font-size: 12px; color: var(--text-4); }
.article-hero h1 { font-size: clamp(26px, 4vw, 42px); font-weight: 800; letter-spacing: -.03em; line-height: 1.15; color: var(--text); margin-bottom: 16px; }
.article-hero .lead { font-size: 16px; color: var(--text-2); line-height: 1.75; max-width: 640px; }

.answer-block { background: var(--accent-light); border-left: 2px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; padding: 16px 20px; margin: 28px 0; font-size: 14.5px; line-height: 1.75; color: var(--text-2); }
.answer-block strong { color: var(--accent); font-weight: 600; }

.article-body { padding: 36px 0 48px; }
.article-content { max-width: 700px; }
.article-content h2 { font-size: clamp(18px, 2.8vw, 24px); font-weight: 700; letter-spacing: -.02em; color: var(--text); margin: 48px 0 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.article-content h2:first-child { margin-top: 0; }
.article-content h3 { font-size: 16px; font-weight: 600; color: var(--text); margin: 28px 0 8px; }
.article-content p { font-size: 15.5px; line-height: 1.8; color: var(--text-2); margin-bottom: 16px; }
.article-content ul, .article-content ol { padding-left: 20px; margin-bottom: 20px; }
.article-content li { font-size: 15.5px; line-height: 1.75; color: var(--text-2); margin-bottom: 8px; list-style: disc; }
.article-content ol li { list-style: decimal; }
.article-content strong { color: var(--text); font-weight: 600; }

.article-layout { display: grid; grid-template-columns: 1fr 280px; gap: 56px; align-items: start; }
.article-sidebar { position: sticky; top: calc(var(--nav-height) + 24px); }
.sidebar-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 16px; }
.sidebar-card-header { background: var(--surface-2); padding: 10px 14px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--text-4); border-bottom: 1px solid var(--border); }
.sidebar-toc { padding: 8px 6px; }
.toc-link { display: block; padding: 5px 10px; border-radius: var(--radius-xs); font-size: 13px; color: var(--text-3); transition: color var(--transition), background var(--transition); border-left: 2px solid transparent; margin-bottom: 1px; }
.toc-link:hover { color: var(--text); background: var(--surface-2); }
.toc-link.active { color: var(--accent); background: var(--accent-dim); border-left-color: var(--accent); }
.toc-link.sub { padding-left: 20px; font-size: 12px; }
.sidebar-cta { padding: 16px; text-align: center; }
.sidebar-cta p { font-size: 13px; color: var(--text-3); margin-bottom: 10px; }

/* ============================================================
   FAQ
   ============================================================ */
.faq-section { padding: 40px 0; }
.faq-list { max-width: 700px; margin: 0 auto; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 8px; overflow: hidden; background: var(--surface); transition: border-color var(--transition-md); }
.faq-item.open { border-color: var(--accent-border); }
.faq-question { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; cursor: pointer; font-size: 14.5px; font-weight: 600; color: var(--text); background: transparent; border: none; width: 100%; text-align: left; gap: 12px; transition: background var(--transition); }
.faq-question:hover { background: var(--surface-2); }
.faq-icon { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border-2); color: var(--text-3); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 14px; font-style: normal; transition: transform var(--transition-md), border-color var(--transition-md), color var(--transition-md); line-height: 1; }
.faq-item.open .faq-icon { transform: rotate(45deg); border-color: var(--accent-border); color: var(--accent); }
.faq-answer { max-height: 0; overflow: hidden; transition: max-height .35s cubic-bezier(0,1,.5,1); }
.faq-item.open .faq-answer { max-height: 4000px; transition: max-height .5s ease-in-out; }
.faq-answer-inner { padding: 14px 20px 18px; font-size: 14.5px; line-height: 1.75; color: var(--text-3); border-top: 1px solid var(--border); text-align: justify; }
.faq-answer-inner p { margin: 0 0 8px; text-align: justify; }
.faq-answer-inner p:last-child { margin-bottom: 0; }
.faq-answer-inner ul, .faq-answer-inner ol { margin: 0 0 8px 18px; padding: 0; }
.faq-answer-inner li { margin-bottom: 4px; }

/* ============================================================
   STEPS
   ============================================================ */
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.step-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; }
.step-number { width: 32px; height: 32px; background: var(--accent); color: #fff; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; margin-bottom: 12px; }
.step-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.step-desc { font-size: 13.5px; color: var(--text-3); line-height: 1.65; }

/* ============================================================
   CTA BANNER
   ============================================================ */
.cta-banner { background: var(--accent-light); border: 1px solid var(--accent-border); border-radius: var(--radius-xl); padding: 52px 40px; text-align: center; }
.cta-banner h2 { font-size: clamp(22px, 3vw, 30px); font-weight: 800; letter-spacing: -.025em; margin-bottom: 12px; color: var(--text); }
.cta-banner p { font-size: 15px; color: var(--text-3); max-width: 460px; margin: 0 auto 28px; line-height: 1.7; }

/* ============================================================
   RELATED LINKS / MISC
   ============================================================ */
.related-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.related-link-card { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); font-size: 14px; font-weight: 500; color: var(--text-2); transition: border-color var(--transition-md), color var(--transition-md); gap: 8px; }
.related-link-card:hover { border-color: var(--accent-border); color: var(--accent); }
.related-link-card svg { flex-shrink: 0; opacity: .35; transition: opacity var(--transition), transform var(--transition-md); }
.related-link-card:hover svg { opacity: .8; transform: translateX(3px); }

.progress-bar-wrap { background: var(--surface-3); border-radius: var(--radius-full); height: 4px; overflow: hidden; margin-top: 6px; }
.progress-bar { height: 100%; background: var(--accent); border-radius: var(--radius-full); transition: width .3s ease; }

.badge { display: inline-block; padding: 2px 8px; border-radius: var(--radius-full); font-size: 11px; font-weight: 600; }
.badge-green { background: var(--ok-dim);    color: var(--ok);   }
.badge-blue  { background: var(--accent-dim); color: var(--accent); }
.badge-amber { background: var(--warn-dim);  color: var(--warn); }
.badge-red   { background: var(--err-dim);   color: var(--err);  }

.toast { position: fixed; bottom: 24px; right: 24px; background: var(--surface); border: 1px solid var(--border-2); color: var(--text); padding: 11px 18px; border-radius: var(--radius-lg); font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg); z-index: 300; transform: translateY(70px); opacity: 0; transition: all .22s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: rgba(74,140,106,.3); color: var(--ok); }
.toast.error   { border-color: rgba(184,64,64,.3);  color: var(--err); }

/* ============================================================
   CERTIFICATE
   ============================================================ */
.cert-preview { background: var(--surface); border: 1px solid var(--accent-border); border-radius: var(--radius-xl); padding: 48px; text-align: center; position: relative; overflow: hidden; box-shadow: var(--shadow-md); }
.cert-preview::before { content: ''; position: absolute; inset: 10px; border: 1px solid var(--border); border-radius: var(--radius-lg); pointer-events: none; }
.cert-logo { font-size: 11px; font-weight: 600; color: var(--text-4); text-transform: uppercase; letter-spacing: .12em; margin-bottom: 8px; }
.cert-title { font-size: 24px; font-weight: 800; color: var(--accent); margin-bottom: 6px; letter-spacing: -.02em; }
.cert-subtitle { font-size: 13px; color: var(--text-3); margin-bottom: 32px; }
.cert-wpm { font-size: 72px; font-weight: 900; color: var(--text); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.cert-wpm-label { font-size: 15px; color: var(--text-3); margin-bottom: 24px; }
.cert-meta { display: flex; justify-content: center; gap: 40px; font-size: 14px; color: var(--text-3); margin-bottom: 28px; }
.cert-meta strong { display: block; font-size: 18px; color: var(--text); }
.cert-footer { font-size: 11px; color: var(--text-4); text-transform: uppercase; letter-spacing: .1em; }
.cert-placeholder .cert-wpm { font-size: 40px; color: var(--text-4); }

/* ============================================================
   FOOTER
   ============================================================ */
.footer { background: var(--surface-2); border-top: 1px solid var(--border); padding: 48px 0 28px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px; margin-bottom: 40px; }
.footer-brand-desc { font-size: 13px; color: var(--text-4); line-height: 1.75; margin: 10px 0 18px; max-width: 240px; }
.footer-logo { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; color: var(--text); display: flex; align-items: center; gap: 9px; }
.footer-logo-icon { width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--accent); }
.footer-logo-icon svg { width: 15px; height: 15px; }
.footer-col-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--text-4); margin-bottom: 14px; }
.footer-links { display: flex; flex-direction: column; gap: 9px; }
.footer-link { font-size: 13px; color: var(--text-4); transition: color var(--transition); display: flex; align-items: center; gap: 6px; }
.footer-link:hover { color: var(--accent); }
.footer-link-icon { font-size: 12px; display: inline-block; width: 16px; text-align: center; flex-shrink: 0; }
.footer-grid-5 { display: grid; grid-template-columns: 1.8fr 1fr 1.4fr 1.4fr; gap: 24px; margin-bottom: 20px; }
.footer-brand-col { max-width: 260px; }
.footer-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.footer-badge { font-size: 11px; font-weight: 500; color: var(--text-4); background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-full); padding: 3px 10px; }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 22px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.footer-copy { font-size: 12px; color: var(--text-4); }
.footer-legal { display: flex; gap: 20px; }
.footer-legal a { font-size: 12px; color: var(--text-4); transition: color var(--transition); }
.footer-legal a:hover { color: var(--accent); }

/* ============================================================
   QUICK-NAV SIDEBAR
   ============================================================ */
.tf-sidebar-toggle { position: fixed; left: 0; top: 50%; transform: translateY(-50%); z-index: 1100; width: 28px; height: 64px; background: var(--accent); border-radius: 0 8px 8px 0; border: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; transition: width var(--transition-md); }
.tf-sidebar-toggle:hover { width: 32px; }
.tf-sidebar-toggle span { display: block; width: 12px; height: 1.5px; background: #fff; border-radius: 2px; transition: transform var(--transition-md); }
.tf-sidebar-toggle.open span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.tf-sidebar-toggle.open span:nth-child(2) { opacity: 0; }
.tf-sidebar-toggle.open span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

.tf-sidebar { position: fixed; left: -256px; top: 0; height: 100%; width: 240px; background: var(--surface); border-right: 1px solid var(--border); z-index: 1099; overflow-y: auto; transition: left .24s cubic-bezier(.4,0,.2,1); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.tf-sidebar.open { left: 0; }
.tf-sidebar-overlay { position: fixed; inset: 0; background: rgba(42,31,22,.45); z-index: 1098; opacity: 0; pointer-events: none; transition: opacity .24s; }
.tf-sidebar-overlay.open { opacity: 1; pointer-events: auto; }

.tf-sidebar-head { padding: 18px 16px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.tf-sidebar-logo { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.tf-sidebar-logo-icon { width: 24px; height: 24px; background: var(--accent); border-radius: 7px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tf-sidebar-logo-icon svg { width: 14px; height: 14px; }
.tf-sidebar-tagline { font-size: 11px; color: var(--text-4); padding-left: 32px; }
.tf-sidebar-body { flex: 1; padding: 6px 8px 24px; overflow-y: auto; }
.tf-sidebar-section-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--text-4); padding: 14px 8px 6px; }
.tf-sidebar-divider { height: 1px; background: var(--border); margin: 6px 0; }
.tf-sidebar-link { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; color: var(--text-3); transition: color var(--transition), background var(--transition); }
.tf-sidebar-link:hover { color: var(--text); background: var(--surface-2); }
.tf-sidebar-link.active { color: var(--accent); background: var(--accent-dim); font-weight: 600; }
.tf-flag { font-size: 11px; font-weight: 600; color: var(--text-4); width: 22px; text-align: center; flex-shrink: 0; font-family: var(--font-mono); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .article-layout { grid-template-columns: 1fr; }
  .article-sidebar { position: static; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
}
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-hamburger { display: flex; }
  .hero { padding: 44px 0 36px; }
  .test-toolbar { padding: 12px 16px; gap: 10px; }
  .test-body { padding: 24px 16px 14px; }
  .words-display { font-size: 17px; height: 120px; }
  .test-footer { padding: 12px 16px 18px; }
  .results-card { padding: 28px 20px; }
  .results-wpm { font-size: 64px; }
  .features-grid { grid-template-columns: 1fr; }
  .steps-grid { grid-template-columns: 1fr; }
  .footer-grid, .footer-grid-5 { grid-template-columns: 1fr 1fr; gap: 24px; }
  .footer-brand-col, .footer-brand-desc { max-width: 100%; }
  .section { padding: 28px 0; }
  .cta-banner { padding: 36px 24px; }
  .cert-preview { padding: 32px 20px; }
  .cert-wpm { font-size: 56px; }
  .hero-stats { gap: 28px; }
  .test-stats-bar { gap: 18px; }
}
@media (max-width: 480px) {
  .container, .container-sm { padding: 0 16px; }
  .words-display { font-size: 15px; }
  .results-wpm { font-size: 54px; }
  .footer-grid, .footer-grid-5 { grid-template-columns: 1fr; }
}

/* ============================================================
   GOVERNMENT EXAM LINKS
   ============================================================ */
.gov-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
  margin: 16px 0 8px;
}
.gov-link-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: border-color var(--transition-md), box-shadow var(--transition-md), transform var(--transition-md);
}
.gov-link-card:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.gov-link-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
.gov-link-meta {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
}
.gov-link-url {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-top: 4px;
  letter-spacing: .01em;
}
.gov-link-card:hover .gov-link-url { text-decoration: underline; }

/* ============================================================
   GLOBAL JUSTIFY — applies to all body text across all pages
   ============================================================ */
p, li, td, .section-subtitle, .feature-desc,
.article-content p, .article-content li { text-align: justify; }

/* Elements that must stay left-aligned regardless */
h1, h2, h3, h4, h5, h6,
.section-tag, .section-title, .section-header,
.nav-link, .btn, label, input, button,
.results-label, .stat-value, .stat-label,
.gov-link-name, .gov-link-meta, .gov-link-url,
.related-link-card, .footer-link,
.word, .char { text-align: left; }

/* ============================================================
   ACCESSIBILITY & PERFORMANCE
   ============================================================ */

/* Skip-to-content link — visible on focus only */
.skip-link {
  position: fixed;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 10px 24px;
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 14px;
  font-weight: 600;
  z-index: 9999;
  transition: top .15s;
  white-space: nowrap;
}
.skip-link:focus { top: 0; outline: none; }

/* Focus-visible — clear keyboard focus ring on all interactive elements */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
:focus:not(:focus-visible) { outline: none; }

/* Minimum tap-target size on mobile (44×44px WCAG 2.5.5) */
@media (max-width: 768px) {
  .btn        { min-height: 44px; }
  .btn-sm     { min-height: 44px; }
  .nav-link   { min-height: 44px; }
  .dur-btn,
  .duration-btn { min-height: 36px; padding: 8px 16px; }
  .diff-btn,
  .mode-btn   { min-height: 36px; padding: 6px 14px; }
  .faq-question { min-height: 44px; }
  /* Hide sidebar toggle on mobile — hamburger nav covers it */
  .tf-sidebar-toggle { display: none; }
  .tf-sidebar { left: -256px; }
}

/* Ensure all font sizes are legible (no sub-11px on mobile) */
@media (max-width: 480px) {
  .stat-label,
  .selector-label,
  .footer-col-title,
  .section-tag,
  .article-tag,
  .results-title,
  .sidebar-card-header,
  .tf-sidebar-section-label { font-size: 11px; }
}

/* Reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  body { background: #fff; color: #000; }
  .nav, .footer, .test-card, .faq-section, .cta-banner { display: none; }
  .cert-preview { border: 2px solid #B85C38; box-shadow: none; background: #fff; }
}
