/* ============================================================
   SigmaDojo — Design System
   Brand palette from logo: hinomaru red + sumi-ink black + gold,
   on warm paper tones. Avoids ERB's lightblue / orange / green.
   ============================================================ */

/* --- Tokens --- */
:root {
  /* Core palette — sumi ink black + warm paper neutrals */
  --color-ink:        #0F0F10;   /* sumi black, for wordmark + nav */
  --color-ink-soft:   #1F1B24;
  --color-navy:       #1F1B24;   /* alias for legacy uses */
  --color-navy-light: #2E2A34;
  --color-slate:      #4A4550;
  --color-grey:       #6B6570;
  --color-grey-light: #9A9299;
  --color-grey-pale:  #CFC7C2;
  --color-cloud:      #E8E0D4;   /* warm cloud */
  --color-fog:        #F3EDE2;   /* warm paper light */
  --color-snow:       #FAF7F0;   /* book-page off-white */
  --color-white:      #FFFFFF;

  /* Accent — rose/mauve (matches the lightened logo) */
  --color-accent:       #BD6B6E;
  --color-accent-hover: #9E5053;
  --color-accent-light: #F4DADC;
  --color-accent-soft:  #FBF3F3;

  /* Gold — secondary accent (page-edges in the logo) */
  --color-gold:         #C9A24A;
  --color-gold-hover:   #A8842E;
  --color-gold-light:   #F6EED9;

  /* Feedback — avoid competing with brand red + ERB palette */
  --color-correct:      #0E7490;   /* deep cyan-teal */
  --color-correct-bg:   #ECFEFF;
  --color-wrong:        #7A1212;   /* oxblood, distinct from brand red */
  --color-wrong-bg:     #FBE9EB;
  --color-warning:      #B7791F;   /* dark honey, not orange */
  --color-warning-bg:   #FEF7E6;

  /* Semantic */
  --bg:         var(--color-snow);
  --bg-surface: var(--color-white);
  --text:       var(--color-navy);
  --text-secondary: var(--color-slate);
  --text-muted: var(--color-grey);
  --border:     var(--color-cloud);
  --border-light: var(--color-fog);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --space-4xl: 96px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 200ms;

  /* Layout */
  --max-width: 1120px;
  --max-width-narrow: 720px;
}

/* --- 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-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-hover); }
button { font-family: inherit; cursor: pointer; }
ul, ol { list-style: none; }

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text);
}
h1 { font-size: clamp(2rem, 4vw, 3rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.5rem); }
h4 { font-size: 1.125rem; }
p { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-center { text-align: center; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

/* --- Layout --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}
.container-narrow {
  width: 100%;
  max-width: var(--max-width-narrow);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
}
a.btn-primary,
button.btn-primary,
.btn-primary {
  background: var(--color-accent);
  color: var(--color-ink);
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-sm);
}
a.btn-primary:hover,
button.btn-primary:hover,
.btn-primary:hover {
  background: var(--color-accent-hover) !important;
  color: var(--color-white) !important;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--color-white);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-soft);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
}
.btn-ghost:hover {
  background: var(--color-fog);
  color: var(--text);
}
.btn-lg { padding: 16px 36px; font-size: 1.05rem; border-radius: var(--radius-lg); }
.btn-sm { padding: 8px 18px; font-size: 0.85rem; }
.btn-icon {
  width: 40px; height: 40px; padding: 0;
  border-radius: var(--radius-md);
}

/* --- Cards --- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.card-flat {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-accent {
  background: var(--color-accent-light);
  color: var(--color-accent-hover);
}
.badge-grey {
  background: var(--color-fog);
  color: var(--color-grey);
}

/* --- Navbar --- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 247, 240, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: var(--space-md) 0;
}
.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1;
}
.navbar-logo span { color: var(--color-accent); }
.navbar-logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(189, 107, 110, 0.22);
}
.navbar-links {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}
.navbar-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--duration) var(--ease);
}
.navbar-links a:hover { color: var(--text); }

/* --- Section spacing --- */
.section {
  padding: var(--space-4xl) 0;
}
.section-sm {
  padding: var(--space-3xl) 0;
}
.section-header {
  text-align: center;
  max-width: 640px;
  margin: 0 auto var(--space-2xl);
}
.section-header p {
  margin-top: var(--space-sm);
  font-size: 1.1rem;
}

/* --- Grid --- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
}

/* --- Divider --- */
.divider {
  height: 1px;
  background: var(--border);
  border: none;
  margin: var(--space-2xl) 0;
}

/* --- Footer --- */
.footer {
  background: var(--color-navy);
  color: var(--color-grey-pale);
  padding: var(--space-3xl) 0 var(--space-xl);
}
.footer a { color: var(--color-grey-pale); }
.footer a:hover { color: var(--color-white); }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: var(--space-lg);
  margin-top: var(--space-2xl);
  font-size: 0.85rem;
  color: var(--color-grey);
}

/* --- Mobile nav --- */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  color: var(--text);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
  .section { padding: var(--space-3xl) 0; }
  .container, .container-narrow { padding: 0 var(--space-md); }
  .mobile-menu-btn { display: block; }
  .navbar-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: var(--space-md) var(--space-lg);
    gap: var(--space-md);
    box-shadow: var(--shadow-lg);
  }
  .navbar-links.open { display: flex; }
  .hero-grid { grid-template-columns: 1fr !important; text-align: center; }
  .hero-actions { justify-content: center; }
  .pricing-grid { grid-template-columns: 1fr !important; max-width: 400px; margin: 0 auto; }
}
@media (max-width: 480px) {
  .btn-lg { padding: 14px 28px; font-size: 0.95rem; }
  h1 { font-size: 1.75rem; }
}

/* Section-timer warning states.
   The .warning (<=5 min) and .danger (<=60 s) classes are toggled in
   test-engine.js updateTimerDisplay(); without these rules they styled nothing,
   so the countdown gave no cue before the hard cut at 0:00. */
.test-timer.warning {
  color: #d97706; /* amber */
  font-weight: 700;
}
.test-timer.danger {
  color: #dc2626; /* red */
  font-weight: 700;
  animation: timer-flash 1s steps(1, end) infinite;
}
.test-timer.overtime {
  color: #d97706; /* steady amber — time is spent, no longer flashing */
  font-weight: 700;
}
@keyframes timer-flash {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}
@media (prefers-reduced-motion: reduce) {
  .test-timer.danger { animation: none; }
}

/* Persistent time warning / overtime banner (below the top bar). */
.time-warn-banner {
  display: none;
  text-align: center;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
}
.time-warn-banner.show { display: block; }
.time-warn-banner .twb-over { display: none; }
.time-warn-banner.overtime .twb-timed { display: none; }
.time-warn-banner.overtime .twb-over { display: inline; }
/* Last-60s state: red + flashing. Overtime state: steady amber. */
.time-warn-banner.show:not(.overtime) {
  background: #dc2626;
  animation: timer-flash 1s steps(1, end) infinite;
}
.time-warn-banner.overtime { background: #d97706; }
@media (prefers-reduced-motion: reduce) {
  .time-warn-banner.show:not(.overtime) { animation: none; }
}

/* Results: ISEE (timed) vs untimed dual score + speed feedback. */
.score-ring-label {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted, #6b7280);
  margin: 6px 0 0;
}
.dual-score {
  max-width: 640px;
  margin: 20px auto 8px;
}
.dual-score-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.dual-score-item {
  flex: 1 1 220px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
}
.dual-score-item:first-child { border-color: #c0392b; }
.dual-score-label { font-size: 0.8rem; color: var(--muted, #6b7280); }
.dual-score-val { font-size: 1.3rem; font-weight: 700; }
.speed-note {
  margin: 12px 2px 0;
  padding: 12px 14px;
  background: #fdf6ec;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.5;
}
.score-over-note {
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #d97706;
}
