/* =============================================================================
   1M Novel Understanding Bench — Light Editorial Theme
   Warm ivory paper · Ink typography · Vermillion accent · Serif + Grotesque
   ============================================================================= */

/* ---- Design Tokens ---- */
:root {
  /* Paper */
  --paper: #FAF8F3;
  --paper-alt: #F4F1EA;
  --paper-card: #FEFDF9;
  --paper-muted: #EDEAE2;

  /* Ink */
  --ink: #16161A;
  --ink-heading: #121215;
  --ink-body: #3D3A35;
  --ink-muted: #8A857C;
  --ink-faint: #B5B0A6;

  /* Accent — vermillion ember */
  --accent: #D2492A;
  --accent-soft: rgba(210, 73, 42, 0.08);
  --accent-glow: rgba(210, 73, 42, 0.15);

  /* Rules & Borders */
  --rule: #E5E0D8;
  --rule-light: #EDE9E1;
  --border-card: #E5E0D8;

  /* Outdated veil */
  --outdated-veil: #E8E4DB;
  --outdated-text: #9E988E;

  /* Layout */
  --nav-h: 56px;
  --max-w: 1040px;
  --section-gap: 72px;

  /* Typography */
  --font-display: "Newsreader", "Noto Serif CJK SC", Georgia, "STSong", "Times New Roman", serif;
  --font-ui: "Inter", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", "Menlo", monospace;

  /* Transitions */
  --ease: 280ms cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out: 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 24px);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--paper);
  color: var(--ink-body);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.7;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; transition: color var(--ease); }
a:hover { color: #B83D22; }

/* ---- Navigation ---- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: rgba(250, 248, 243, 0.88);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  border-bottom: 1px solid var(--rule);
}

.nav-inner {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-heading);
  white-space: nowrap;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-links {
  display: flex;
  gap: 2px;
}

.nav-links a {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-ui);
  color: var(--ink-muted);
  transition: all var(--ease);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.nav-links a:hover { color: var(--ink-body); background: var(--paper-muted); }

.lang-btn {
  padding: 6px 13px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-ui);
  letter-spacing: 0.03em;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid var(--rule);
  cursor: pointer;
  transition: all var(--ease);
  white-space: nowrap;
}
.lang-btn:hover { color: var(--ink-body); border-color: var(--ink-faint); }
.lang-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ---- Section Base ---- */
.section {
  position: relative;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--section-gap) 24px;
}

.section-alt {
  background: var(--paper-alt);
  padding: var(--section-gap) 0;
}
.section-alt .section-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-heading);
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-title::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 1px;
}

/* ---- Hero ---- */
.hero {
  padding: 80px 24px 64px;
  text-align: center;
  border-bottom: 1px solid var(--rule);
}

.hero-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(210, 73, 42, 0.2);
  margin-bottom: 28px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(34px, 5.5vw, 52px);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.18;
  color: var(--ink-heading);
  margin-bottom: 18px;
}

.hero-tagline {
  font-size: 16px;
  color: var(--ink-body);
  max-width: 620px;
  margin: 0 auto 8px;
  line-height: 1.7;
}

.hero-repo-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 32px;
  padding: 8px 18px;
  border-radius: 6px;
  border: 1px solid rgba(210, 73, 42, 0.2);
  background: var(--accent-soft);
  transition: all var(--ease);
}
.hero-repo-link:hover {
  background: rgba(210, 73, 42, 0.14);
  border-color: rgba(210, 73, 42, 0.35);
  color: #B83D22;
  transform: translateY(-1px);
}
.hero-repo-arrow {
  font-family: var(--font-ui);
  font-weight: 400;
  transition: transform var(--ease);
}
.hero-repo-link:hover .hero-repo-arrow {
  transform: translate(2px, -2px);
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 6px;
  background: var(--paper-card);
  border: 1px solid var(--border-card);
  font-size: 13px;
  color: var(--ink-muted);
  transition: all var(--ease);
}
.stat-chip:hover {
  border-color: var(--ink-faint);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  transform: translateY(-1px);
}
.stat-chip .stat-label { font-size: 11px; letter-spacing: 0.02em; text-transform: uppercase; }
.stat-chip .stat-value { color: var(--ink-body); font-weight: 600; font-family: var(--font-mono); }

/* ---- Card ---- */
.card {
  background: var(--paper-card);
  border: 1px solid var(--border-card);
  border-radius: 8px;
  transition: all var(--ease);
}
.card:hover { border-color: var(--ink-faint); box-shadow: 0 2px 16px rgba(0, 0, 0, 0.04); }

/* ---- Methodology ---- */
.methodology-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.methodology-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 24px;
  border-radius: 8px;
  background: var(--paper-card);
  border: 1px solid var(--border-card);
  transition: all var(--ease);
}
.methodology-item:hover { border-color: var(--ink-faint); transform: translateY(-2px); }

.methodology-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--paper-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
}

.methodology-item p {
  font-size: 14px;
  color: var(--ink-body);
  line-height: 1.7;
}

/* ---- Leaderboard ---- */
.lb-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.season-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-heading);
}

.current-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.filter-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  padding: 5px 14px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-ui);
  letter-spacing: 0.01em;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all var(--ease);
  white-space: nowrap;
}
.filter-chip:hover { color: var(--ink-body); border-color: var(--ink-faint); }
.filter-chip.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

/* Leaderboard groups */
.lb-groups {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.lb-group {
  background: var(--paper-card);
  border: 1px solid var(--border-card);
  border-radius: 8px;
  overflow: hidden;
  transition: opacity 0.35s ease;
}

.lb-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule-light);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-body);
  background: var(--paper);
  text-transform: uppercase;
}

.lb-group-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  flex-shrink: 0;
  background: var(--accent);
}

.lb-group-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 400;
  text-transform: none;
}

.lb-rows { padding: 6px; }

.lb-row {
  display: grid;
  grid-template-columns: 32px 1fr auto 52px;
  align-items: center;
  gap: 16px;
  padding: 13px 18px;
  border-radius: 6px;
  transition: all var(--ease);
}
.lb-row:hover { background: rgba(0, 0, 0, 0.02); }

.lb-rank {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  text-align: center;
}

.lb-rank.top { color: var(--accent); font-weight: 700; }

.lb-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-body);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-bar-wrap {
  height: 4px;
  background: var(--paper-muted);
  border-radius: 2px;
  overflow: hidden;
  min-width: 60px;
}

.lb-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 1s var(--ease-out);
  background: var(--ink-faint);
}

.lb-bar.top { background: var(--accent); }

.lb-score {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  color: var(--ink-body);
  white-space: nowrap;
}

.lb-score-max {
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-muted);
}

/* Season subtitle */
.lb-season-subtitle {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-muted);
  margin-bottom: 16px;
}

/* ---- Outdated Section ---- */
.outdated-section {
  border-top: 1px solid var(--rule);
  margin-top: 32px;
  padding-top: 24px;
}

.outdated-strip {
  background: var(--paper-alt);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 20px 24px;
  cursor: pointer;
  user-select: none;
  transition: all var(--ease);
  display: flex;
  align-items: center;
  gap: 14px;
}
.outdated-strip:hover {
  background: #EDEAE2;
  border-color: var(--ink-faint);
}

.outdated-strip.open {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.outdated-badge {
  flex-shrink: 0;
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--outdated-text);
  background: var(--outdated-veil);
  border: 1px solid var(--rule);
}

.outdated-strip-text {
  flex: 1;
  font-size: 14px;
  color: var(--outdated-text);
}

.outdated-strip-action {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color var(--ease);
}
.outdated-strip:hover .outdated-strip-action { color: var(--ink-body); }

.outdated-strip-chevron {
  width: 14px;
  height: 14px;
  transition: transform var(--ease);
}
.outdated-strip.open .outdated-strip-chevron {
  transform: rotate(180deg);
}

.outdated-content {
  display: none;
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 6px 24px 24px;
}

.outdated-content.visible {
  display: block;
  animation: fadeInDown 0.35s ease;
}

.outdated-content .lb-group-header {
  opacity: 0.8;
}

.outdated-content .lb-group,
.outdated-content .problem-card {
  opacity: 0.78;
  transition: opacity var(--ease);
}
.outdated-content .lb-group:hover,
.outdated-content .problem-card:hover {
  opacity: 0.95;
}

.outdated-content .lb-bar { background: var(--outdated-text); opacity: 0.6; }

/* ---- Problems ---- */
.problems-note {
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 20px;
  font-style: italic;
}

.problems-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.problem-card {
  background: var(--paper-card);
  border: 1px solid var(--border-card);
  border-radius: 8px;
  overflow: hidden;
  transition: all var(--ease);
}
.problem-card:hover { border-color: var(--ink-faint); }

.problem-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  cursor: pointer;
}

.problem-num {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--paper-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
}

.problem-q {
  flex: 1;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-body);
  padding-top: 3px;
}

.problem-chevron {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 5px;
  color: var(--ink-faint);
  transition: transform var(--ease);
}
.problem-card.open .problem-chevron { transform: rotate(180deg); }

.problem-answer {
  display: none;
  padding: 0 20px 20px 64px;
}
.problem-card.open .problem-answer {
  display: block;
  animation: fadeInDown 0.3s ease;
}

.problem-answer-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.problem-answer-text {
  font-size: 14px;
  color: var(--ink-body);
  line-height: 1.7;
}

.problem-locked {
  display: none;
  padding: 0 20px 20px 64px;
  font-size: 13px;
  color: var(--ink-muted);
  font-style: italic;
  align-items: center;
  gap: 8px;
}
.problem-card.open .problem-locked { display: flex; animation: fadeInDown 0.3s ease; }

.locked-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  font-style: normal;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(210, 73, 42, 0.2);
}

/* ---- Repo CTA Card ---- */
.repo-cta {
  background: var(--paper-card);
  border: 1px solid var(--border-card);
  border-radius: 8px;
  padding: 28px 32px;
  text-align: center;
  transition: all var(--ease);
}
.repo-cta:hover { border-color: var(--ink-faint); }

.repo-cta-text {
  font-size: 14px;
  color: var(--ink-muted);
  margin-bottom: 20px;
  line-height: 1.6;
}

.repo-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-ui);
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--accent);
  border: none;
  cursor: pointer;
  transition: all var(--ease);
}
.repo-cta-btn:hover {
  background: #B83D22;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(210, 73, 42, 0.2);
}

/* ---- Visit Counter ---- */
.visit-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 8px;
}
.visit-counter .count-num {
  font-weight: 600;
  color: var(--ink-body);
}
.visit-counter.loading .count-num {
  opacity: 0.5;
}

/* ---- Footer ---- */
.footer {
  text-align: center;
  padding: 48px 24px;
  border-top: 1px solid var(--rule);
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.9;
}

.footer a { color: var(--ink-body); font-weight: 500; }

/* ---- Animations ---- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-in {
  animation: fadeInUp 0.45s ease both;
}

/* ---- Hidden ---- */
.lb-group.hidden { display: none; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  :root { --section-gap: 48px; }
  .section { padding: var(--section-gap) 16px; }
  .section-alt .section-inner { padding: 0 16px; }
  .hero { padding: 56px 16px 40px; }
  .hero h1 { font-size: 28px; }
  .hero-tagline { font-size: 14px; }

  .nav-inner { padding: 0 16px; }
  .nav-brand { font-size: 14px; }
  .nav-links a { padding: 5px 9px; font-size: 12px; }
  .lang-btn { padding: 5px 10px; font-size: 11px; }

  .lb-row {
    grid-template-columns: 24px 1fr auto 44px;
    gap: 10px;
    padding: 10px 12px;
  }
  .lb-rank { font-size: 12px; }
  .lb-name { font-size: 13px; }
  .lb-score { font-size: 13px; }
  .lb-bar-wrap { min-width: 40px; }

  .problem-header { padding: 14px 16px; gap: 10px; }
  .problem-answer { padding: 0 16px 16px 52px; }
  .problem-locked { padding: 0 16px 16px 52px; }

  .methodology-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 6px; }
  .stat-chip { padding: 8px 14px; font-size: 12px; }

  .lb-controls { gap: 10px; flex-direction: column; align-items: flex-start; }
  .outdated-strip { padding: 16px 18px; gap: 10px; flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 24px; }
  .section-title { font-size: 20px; }
  .lb-row { grid-template-columns: 20px 1fr auto 40px; gap: 6px; padding: 8px 10px; }
}

/* ---- Homepage → Season 1 history link ---- */
.history-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 28px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: transparent;
  transition: all var(--ease);
}
.history-link:hover {
  color: var(--accent);
  border-color: rgba(210, 73, 42, 0.3);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.history-link-arrow {
  font-weight: 400;
  transition: transform var(--ease);
}
.history-link:hover .history-link-arrow {
  transform: translateX(3px);
}

/* ---- Season 1 subpage ---- */
.subpage-hero {
  padding-top: 96px;
  padding-bottom: 40px;
}
.subpage-hero .outdated-badge {
  margin-bottom: 18px;
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(210, 73, 42, 0.2);
}
.subpage-hero h1 {
  font-size: 32px;
  margin-bottom: 10px;
}
.subpage-hero .hero-repo-link {
  margin-top: 18px;
  margin-bottom: 0;
}

.back-link {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 8px;
  transition: transform var(--ease);
}
.back-link:hover {
  transform: translateX(-3px);
}

@media (max-width: 480px) {
  .subpage-hero { padding-top: 80px; }
  .subpage-hero h1 { font-size: 24px; }
}
