/* ── Reset & Base ─────────────────────────────────────────── */

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

:root {
  /* Warm, muted palette */
  --bg: #faf9f6;
  --bg-grid: #e8e6e1;
  --surface: #ffffff;
  --text: #2c2c2c;
  --text-muted: #6b6660;
  --accent: #b85c38;
  --accent-hover: #a04e2f;
  --border: #d4d0ca;
  --code-bg: #f0eee9;

  --font-body: 'Georgia', 'Times New Roman', serif;
  --font-heading: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;

  --max-width: 48rem;
  --grid-size: 24px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1917;
    --bg-grid: #2a2825;
    --surface: #232220;
    --text: #e0ddd5;
    --text-muted: #9a9590;
    --accent: #d4845a;
    --accent-hover: #e09568;
    --border: #3a3835;
    --code-bg: #2a2825;
  }
}

/* ── Graph Paper Background ──────────────────────────────── */

body {
  font-family: var(--font-body);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Typography ──────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.17rem; }

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

/* ── Layout ──────────────────────────────────────────────── */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Header / Nav ────────────────────────────────────────── */

header {
  border-bottom: 2px solid var(--border);
  background: var(--surface);
  padding: 1rem 0;
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.03em;
}

.site-title:hover {
  color: var(--accent);
  text-decoration: none;
}

nav {
  display: flex;
  gap: 1.5rem;
}

nav a {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: lowercase;
}

nav a:hover {
  color: var(--accent);
}

/* ── Main Content ────────────────────────────────────────── */

main {
  padding: 3rem 0;
}

/* ── Footer ──────────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: 4rem;
}

footer p {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Hero (Homepage) ─────────────────────────────────────── */

.hero {
  text-align: center;
  padding: 4rem 0 2rem;
}

.hero-compact {
  padding: 2rem 0 1rem;
}

.hero h1 {
  font-size: 2.75rem;
  letter-spacing: -0.04em;
  margin-bottom: 0.25rem;
}

.hero .subtitle {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.hero-description {
  font-size: 1.1rem;
  max-width: 36rem;
  margin: 0 auto 2rem;
  color: var(--text);
  line-height: 1.6;
}

/* ── Features ───────────────────────────────────────────── */

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem;
}

.feature h3 {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.feature p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Grade Tabs ─────────────────────────────────────────── */

.grade-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.grade-tab {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.grade-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.grade-tab.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}


/* ── Standards Tree ─────────────────────────────────────── */

.standards-tree {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tree-domain {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.tree-domain-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  padding: 1rem 1.25rem;
  margin: 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.tree-domain-id {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  white-space: nowrap;
}

.tree-domain-title {
  flex: 1;
}

.tree-domain-toggle {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--text-muted);
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.tree-domain-header:hover {
  background: var(--code-bg);
}

.tree-domain-body {
  padding: 0.75rem 1.25rem 1.25rem;
}

/* Clusters */

.cluster {
  margin-top: 1rem;
}

.cluster-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.cluster-id {
  font-family: var(--font-mono);
  color: var(--accent);
  margin-right: 0.5rem;
}

/* Standards */

.standards-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.standard {
  padding: 0.6rem 0.75rem;
  border-radius: 3px;
  border-left: 3px solid var(--border);
}

.standard.has-generator {
  border-left-color: var(--accent);
}

.standard.coming-soon {
  opacity: 0.6;
}

.standard-link {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  flex-wrap: wrap;
}

.standard-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.standard-link:hover .standard-description {
  color: var(--accent);
}

.standard-id {
  font-size: 0.75rem;
  background: var(--code-bg);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  flex-shrink: 0;
}

.standard-description {
  font-size: 0.85rem;
  line-height: 1.4;
  flex: 1;
}

.standard-arrow {
  font-family: var(--font-mono);
  color: var(--accent);
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s ease;
}

.standard-link:hover .standard-arrow {
  opacity: 1;
}

.standard-skills ul {
  margin-top: 0.35rem;
  padding-left: 1.25rem;
  list-style: disc;
}

.standard-skills li {
  margin-bottom: 0.25rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Worksheet Config ────────────────────────────────────── */

.config-header {
  margin-bottom: 2rem;
}

.config-breadcrumb {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.config-breadcrumb a {
  color: var(--text-muted);
}

.config-breadcrumb a:hover {
  color: var(--accent);
}

.config-description {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.config-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 48rem) {
  .config-layout {
    grid-template-columns: 1fr;
  }
}

.config-form fieldset {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.config-form legend {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0 0.5rem;
}

.config-form label {
  font-size: 0.85rem;
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

.radio-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.radio-pill {
  margin: 0;
}

.radio-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-pill span {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.1s ease;
  color: var(--text-muted);
  background: var(--surface);
}

.radio-pill input:checked + span {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.radio-pill span:hover {
  border-color: var(--accent);
}

.checkbox-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.checkbox-pill {
  margin: 0;
}

.checkbox-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.checkbox-pill span {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.1s ease;
  color: var(--text-muted);
  background: var(--surface);
}

.checkbox-pill input:checked + span {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.checkbox-pill span:hover {
  border-color: var(--accent);
}

.config-standard-id {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pdf-status {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  align-self: center;
}

.pdf-status.success {
  color: var(--accent);
}

.pdf-status.error {
  color: #c44;
}

.config-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.btn {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  padding: 0.55rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

/* Preview panel */

.preview-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem;
}

.preview-panel h2 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.preview-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.preview-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

.problem-list {
  padding-left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.problem-item {
  font-size: 0.95rem;
  line-height: 1.6;
}

.problem-context {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.problem-diagram-alt {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.problem-display {
  margin-bottom: 0.25rem;
}

.problem-answer {
  font-size: 0.8rem;
}

.problem-answer summary {
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* ── Print ───────────────────────────────────────────────── */

/* ── Error Pages ─────────────────────────────────────────── */

.error-page {
  text-align: center;
  padding: 4rem 0;
}

.error-page h1 {
  font-size: 4rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.error-page p {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* ── Print ───────────────────────────────────────────────── */

@media print {
  body {
    background: white;
    background-image: none;
  }
  header, footer, nav {
    display: none;
  }
}
