/* ══════════════════════════════════════════════════════════════════
   TESTME · TEST BASE CSS
   Shared foundation for all cognitive performance tests.
   Each test imports this file and only sets --test-accent.
   ══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800;900&family=Lexend:wght@300;400;500;600&display=swap');

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── TOKENS ── */
:root {
  --test-accent: #3fa8be; /* Override per test */
  --test-accent-soft: color-mix(in srgb, var(--test-accent) 12%, transparent);
  --test-accent-border: color-mix(in srgb, var(--test-accent) 25%, transparent);

  --bg: #f2f6f9;
  --card-bg: #ffffff;
  --card-border: #e0eaee;
  --card-shadow: 0 24px 56px rgba(15, 40, 60, 0.09), 0 4px 12px rgba(15, 40, 60, 0.05);

  --text: #1a2e3b;
  --text-muted: #5a7285;
  --text-faint: #9eb0bc;

  --r-xl: 24px;
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;

  --font-h: 'Manrope', system-ui, sans-serif;
  --font-b: 'Lexend', system-ui, sans-serif;
}

/* ── BASE ── */
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
html.large-text { font-size: 115%; }
body {
  font-family: var(--font-b);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── FOCUS RING ── */
:focus-visible {
  outline: 3px solid var(--test-accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ── VISUALLY HIDDEN (for screen reader only text) ── */
.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;
}

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

/* ── DYSLEXIC FONT ── */
html.dyslexic-font *:not(.material-symbols-outlined):not(.material-symbols-rounded):not(.material-symbols-sharp):not(.material-icons) { font-family: "OpenDyslexic", "Comic Sans MS", sans-serif !important; }
html.dyslexic-font .material-symbols-outlined,
html.dyslexic-font .material-symbols-rounded,
html.dyslexic-font .material-symbols-sharp,
html.dyslexic-font .material-icons { font-family: 'Material Symbols Outlined', 'Material Icons' !important; }

/* ── HIGH CONTRAST ── */
html.high-contrast body { background: #fff !important; color: #000 !important; }
html.high-contrast .t-card { background: #fff !important; border: 2px solid #000 !important; }
html.high-contrast button { border: 2px solid currentColor !important; }

/* ── SHELL ── */
.t-shell {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* ── TOP NAV ── */
.t-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 12px;
}
.t-nav-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-b);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  border: 1.5px solid transparent;
  transition: all 0.15s;
}
.t-nav-back:hover { color: var(--test-accent); border-color: var(--test-accent-border); background: var(--test-accent-soft); }
.t-nav-back svg { flex-shrink: 0; }
.t-nav-label {
  font-family: var(--font-b);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.t-nav-acc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 8px;
  border: 1.5px solid transparent;
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  transition: all 0.15s;
  margin-left: auto;
}
.t-nav-acc:hover { color: var(--test-accent); border-color: var(--test-accent-border); background: var(--test-accent-soft); }

/* ── CARD ── */
.t-card {
  background: var(--card-bg);
  border-radius: var(--r-xl);
  border: 1.5px solid var(--card-border);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  position: relative;
}

/* ── PHASE PANELS (shown/hidden via .active class) ── */
.t-panel { display: none; }
.t-panel.active { display: flex; flex-direction: column; }

/* ── INTRO PANEL ── */
.t-intro {
  padding: 40px 36px;
  align-items: center;
  text-align: center;
  gap: 0;
}
@media (max-width: 480px) { .t-intro { padding: 28px 20px; } }

.t-intro-icon {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 20px;
  animation: iconBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes iconBounce { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.t-intro-title {
  font-family: var(--font-h);
  font-size: 34px;
  font-weight: 900;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}
.t-intro-title em { color: var(--test-accent); font-style: normal; }

.t-intro-sub {
  font-family: var(--font-b);
  font-size: 15px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 380px;
  margin: 0 auto 28px;
}

/* ── HOW IT WORKS — inline steps ── */
.t-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 400px;
  margin: 0 auto 28px;
  text-align: left;
}
.t-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: var(--test-accent-soft);
  border: 1.5px solid var(--test-accent-border);
  border-radius: var(--r-md);
}
.t-step-num {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 50%;
  background: var(--test-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.t-step-text {
  font-family: var(--font-b);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.5;
}
.t-step-text strong { font-weight: 800; color: #1a2e3b; }

/* ── START BUTTON ── */
.t-btn-start {
  width: 100%;
  max-width: 320px;
  padding: 18px 24px;
  background: var(--test-accent);
  color: #fff;
  border: none;
  border-radius: var(--r-lg);
  font-family: var(--font-b);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--test-accent) 40%, transparent);
  transition: transform 0.18s, box-shadow 0.18s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.t-btn-start:hover { transform: translateY(-2px); box-shadow: 0 14px 32px color-mix(in srgb, var(--test-accent) 50%, transparent); }
.t-btn-start:active { transform: scale(0.97); }
.t-btn-start svg { width: 18px; height: 18px; }

.t-meta {
  margin-top: 14px;
  font-family: var(--font-b);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
}

/* ── TASK PANEL ── */
.t-task {
  padding: 28px 28px 32px;
  gap: 20px;
}
@media (max-width: 480px) { .t-task { padding: 20px 16px 24px; } }

/* ── PROGRESS BAR ── */
.t-prog {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.t-prog-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.t-prog-title {
  font-family: var(--font-b);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.t-prog-count {
  font-family: var(--font-h);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.t-prog-track {
  height: 5px;
  background: #e8f0f4;
  border-radius: 10px;
  overflow: hidden;
}
.t-prog-fill {
  height: 100%;
  background: var(--test-accent);
  border-radius: 10px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── TRIAL DOTS ── */
.t-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.t-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dde8ed;
  transition: all 0.25s;
}
.t-dot.current { background: var(--test-accent); transform: scale(1.3); }
.t-dot.done { background: #2ecc71; }
.t-dot.error { background: #e74c3c; }

/* ── STIMULUS AREA ── */
.t-stimulus {
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  min-height: 200px;
  position: relative;
  overflow: hidden;
}

/* Stimulus states */
.t-stimulus[data-state="idle"] { background: #f0f4f7; border: 2px dashed #cdd8df; }
.t-stimulus[data-state="wait"] { background: #f8fafc; border: 2px solid #e0eaee; }
.t-stimulus[data-state="go"]   { background: #2ecc71; border: 2px solid #27ae60; box-shadow: 0 0 40px rgba(46,204,113,0.4); transform: scale(1.01); }
.t-stimulus[data-state="hit"]  { background: #eafaf1; border: 2px solid #2ecc71; }
.t-stimulus[data-state="miss"] { background: #fdf2f1; border: 2px solid #e74c3c; }

/* ── RESULT PANEL ── */
.t-result {
  padding: 36px 32px 40px;
  gap: 22px;
}
@media (max-width: 480px) { .t-result { padding: 24px 18px 28px; } }

.t-result-hero {
  text-align: center;
  padding: 36px 24px 32px;
  background: linear-gradient(135deg, var(--test-accent-soft) 0%, color-mix(in srgb, var(--test-accent) 6%, white) 100%);
  border: 1.5px solid var(--test-accent-border);
  border-radius: var(--r-xl);
  position: relative;
  overflow: hidden;
}
.t-result-hero::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: var(--test-accent);
  opacity: 0.04;
}
.t-score-big {
  font-family: var(--font-h);
  font-size: 76px;
  font-weight: 900;
  color: var(--test-accent);
  line-height: 1;
  letter-spacing: -0.03em;
}
.t-score-unit {
  font-family: var(--font-h);
  font-size: 24px;
  font-weight: 700;
  color: var(--test-accent);
  margin-left: 4px;
  opacity: 0.7;
}
.t-score-label {
  font-family: var(--font-b);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 10px;
}
.t-score-interp {
  font-family: var(--font-b);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin-top: 16px;
  line-height: 1.6;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

/* ── PERCENTILE BAR ── */
.t-pct-box {
  padding: 22px 24px;
  background: #f8fafb;
  border-radius: var(--r-xl);
  border: 1.5px solid var(--card-border);
}
.t-pct-label {
  font-family: var(--font-b);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.5;
}
.t-pct-label strong { color: var(--text); font-weight: 800; }
.t-pct-track {
  height: 10px;
  background: #e0eaee;
  border-radius: 10px;
  position: relative;
  margin-bottom: 10px;
}
.t-pct-fill {
  height: 100%;
  background: linear-gradient(90deg, #e0eaee 0%, var(--test-accent) 100%);
  border-radius: 10px;
  opacity: 0.5;
}
.t-pct-marker {
  position: absolute;
  top: -7px;
  width: 24px;
  height: 24px;
  background: var(--test-accent);
  border: 4px solid #fff;
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  transition: left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.t-pct-ends {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-b);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ── RESULT INFO CARDS ── */
.t-info-card {
  padding: 20px 22px;
  background: #f8fafb;
  border-radius: var(--r-lg);
  border: 1.5px solid var(--card-border);
}
.t-info-card-title {
  font-family: var(--font-h);
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.t-info-card-title .icon { font-size: 18px; }
.t-info-card p {
  font-family: var(--font-b);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.7;
}
.t-info-card p + p { margin-top: 10px; }
.t-info-card strong { color: var(--text); font-weight: 700; }

/* ── SCORE RANGE TABLE ── */
.rt-range-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.rt-range-row {
  display: grid;
  grid-template-columns: 10px 80px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-family: var(--font-b);
  font-size: 13px;
}
.rt-range-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.rt-range-label { font-weight: 700; color: var(--text); }
.rt-range-val   { color: var(--text-muted); }
.rt-range-pct   { font-weight: 700; text-align: right; }

.rt-range-row.elite  { background: #f0fdf4; } .rt-range-row.elite  .rt-range-dot { background: #2ecc71; } .rt-range-row.elite  .rt-range-pct { color: #2ecc71; }
.rt-range-row.fast   { background: #f0f9ff; } .rt-range-row.fast   .rt-range-dot { background: #0ea5e9; } .rt-range-row.fast   .rt-range-pct { color: #0ea5e9; }
.rt-range-row.avg    { background: #fafafa; } .rt-range-row.avg    .rt-range-dot { background: #f5a623; } .rt-range-row.avg    .rt-range-pct { color: #f5a623; }
.rt-range-row.slow   { background: #fef2f1; } .rt-range-row.slow   .rt-range-dot { background: #e74c3c; } .rt-range-row.slow   .rt-range-pct { color: #e74c3c; }

/* ── STATS GRID ── */
.t-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.t-stat {
  text-align: center;
  padding: 18px 10px;
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: var(--r-lg);
}
.t-stat-val {
  font-family: var(--font-h);
  font-size: 26px;
  font-weight: 900;
  color: var(--test-accent);
}
.t-stat-lbl {
  font-family: var(--font-b);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 4px;
}

/* ── FACTOR GRID ── */
.t-factors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}
.t-factor {
  text-align: center;
  padding: 16px 12px;
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: var(--r-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.t-factor:hover { border-color: var(--test-accent-border); box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.t-factor-icon { font-size: 24px; display: block; margin-bottom: 8px; }
.t-factor-label { font-family: var(--font-h); font-size: 13px; font-weight: 800; color: var(--text); }
.t-factor-desc { font-family: var(--font-b); font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }

/* ── ACTION BUTTONS ── */
.t-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.t-btn-primary {
  flex: 1;
  padding: 16px;
  background: var(--test-accent);
  color: #fff;
  border: none;
  border-radius: var(--r-lg);
  font-family: var(--font-b);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  touch-action: manipulation;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--test-accent) 30%, transparent);
}
.t-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px color-mix(in srgb, var(--test-accent) 40%, transparent); }
.t-btn-primary:active { transform: scale(0.97); }
.t-btn-secondary {
  flex: 1;
  padding: 14px;
  background: transparent;
  color: var(--text-muted);
  border: 2px solid var(--card-border);
  border-radius: var(--r-lg);
  font-family: var(--font-b);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.t-btn-secondary:hover { border-color: var(--test-accent); color: var(--test-accent); background: var(--test-accent-soft); }
@media (max-width: 480px) { .t-actions { flex-direction: column; } }

/* ── RESTART BUTTON (shared across all cognitive tests) ── */
.wm-restart-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  background: transparent;
  border: 1.5px solid var(--card-border);
  border-radius: var(--r-sm);
  font-family: var(--font-b);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  transition: all 0.15s;
}
.wm-restart-btn:hover  { border-color: var(--test-accent); color: var(--test-accent); }
.wm-restart-btn:active { transform: scale(0.95); }

/* ── ANIMATIONS ── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.08); }
}
@keyframes flashGreen {
  0%   { background: #2ecc71; }
  100% { background: #f0f4f7; }
}
@keyframes flashRed {
  0%   { background: #e74c3c; }
  100% { background: #f0f4f7; }
}

.anim-fadein { animation: fadeSlideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) both; }
.anim-scalein { animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* ══════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  /* Shell */
  .t-shell { padding: 0 12px 36px; }

  /* Intro */
  .t-intro-title { font-size: 26px; }
  .t-intro-sub { font-size: 14px; margin-bottom: 20px; }
  .t-intro-icon { font-size: 44px; margin-bottom: 14px; }
  .t-btn-start { max-width: 100%; padding: 16px 20px; font-size: 15px; }
  .t-steps { max-width: 100%; }
  .t-step { padding: 10px 12px; }
  .t-step-text { font-size: 12.5px; }

  /* Result hero score */
  .t-score-big { font-size: 52px; }
  .t-score-unit { font-size: 18px; }
  .t-score-label { font-size: 11px; }
  .t-score-interp { font-size: 13px; }
  .t-result-hero { padding: 24px 16px; }

  /* Percentile bar */
  .t-pct-box { padding: 16px 14px; }
  .t-pct-label { font-size: 13px; }
  .t-pct-ends { font-size: 10px; }

  /* Info cards */
  .t-info-card { padding: 16px 14px; }
  .t-info-card-title { font-size: 14px; }
  .t-info-card p { font-size: 13px; }

  /* Score range table */
  .rt-range-row { grid-template-columns: 8px 60px 1fr auto; gap: 6px; padding: 8px 10px; font-size: 12px; }
  .rt-range-dot { width: 8px; height: 8px; }

  /* Stats grid */
  .t-stats { gap: 8px; }
  .t-stat { padding: 14px 6px; }
  .t-stat-val { font-size: 20px; }
  .t-stat-lbl { font-size: 10px; }

  /* Factor grid */
  .t-factors { gap: 8px; }
  .t-factor { padding: 12px 8px; }
  .t-factor-icon { font-size: 20px; margin-bottom: 6px; }
  .t-factor-label { font-size: 12px; }
  .t-factor-desc { font-size: 11px; }

  /* Action buttons */
  .t-btn-primary { padding: 14px; font-size: 14px; }
  .t-btn-secondary { padding: 12px; font-size: 13px; }
}

@media (max-width: 360px) {
  .t-score-big { font-size: 44px; }
  .t-score-unit { font-size: 16px; }
  .t-intro-title { font-size: 22px; }
  .rt-range-row { grid-template-columns: 8px 50px 1fr auto; font-size: 11px; padding: 7px 8px; }
  .t-factors { grid-template-columns: 1fr; }
}
