/* Shared stylesheet for chesslearning2 — Tufte-ish, readable, prints well */

:root {
  --bg: #faf8f4;
  --ink: #1f1b16;
  --muted: #6b6255;
  --rule: #ddd3c4;
  --accent: #7a3b2e;
  --accent-light: #f1e3da;
  --board-light: #f0d9b5;
  --board-dark: #b58863;
  --good: #2f6f4f;
  --bad: #a83232;
  --max-width: 680px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130f;
    --ink: #ece5d8;
    --muted: #a89b86;
    --rule: #3a332a;
    --accent: #d98a70;
    --accent-light: #2a2019;
    --board-light: #e8d3a8;
    --board-dark: #8a6640;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 3rem 1.5rem 6rem;
  background: var(--bg);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  line-height: 1.6;
  font-size: 1.125rem;
}

.page {
  max-width: var(--max-width);
  margin: 0 auto;
}

h1, h2, h3 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h1 { font-size: 2rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.3rem; margin: 2.5rem 0 0.75rem; border-bottom: 1px solid var(--rule); padding-bottom: 0.3rem; }
h3 { font-size: 1.05rem; margin: 1.5rem 0 0.5rem; color: var(--accent); }

.kicker {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

p { margin: 0 0 1rem; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

.lede {
  font-size: 1.2rem;
  color: var(--muted);
  margin-bottom: 2rem;
}

.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
  padding: 0.9rem 1.1rem;
  border-radius: 0 6px 6px 0;
  margin: 1.5rem 0;
  font-size: 1rem;
}

.callout strong { color: var(--accent); }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1.5rem 0;
}

@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.card {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  background: rgba(0,0,0,0.015);
}

.card h3 { margin-top: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--rule);
}

th { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

code, .moves {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95em;
  background: var(--accent-light);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* Mini chess board diagram, built from a div grid — no images/JS needed */
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: min(100%, 340px);
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  margin: 1.5rem auto;
  font-family: serif;
}

.board .sq {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1rem, 4.2vw, 1.6rem);
  user-select: none;
}

.board .light { background: var(--board-light); }
.board .dark { background: var(--board-dark); }
.board .mark { box-shadow: inset 0 0 0 3px var(--accent); }

figcaption, .caption {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  margin-top: -0.75rem;
  margin-bottom: 1.5rem;
}

/* Quiz widget */
.quiz {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.2rem;
  margin: 1.5rem 0;
  background: rgba(0,0,0,0.015);
}

.quiz .q { font-weight: 600; margin-bottom: 0.75rem; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; }

.quiz .choices { display: flex; flex-direction: column; gap: 0.5rem; }

.quiz button.choice {
  text-align: left;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.quiz button.choice:hover { border-color: var(--accent); }
.quiz button.choice.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 15%, var(--bg)); }
.quiz button.choice.incorrect { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 15%, var(--bg)); }
.quiz .feedback { margin-top: 0.75rem; font-size: 0.9rem; min-height: 1.2em; }
.quiz .feedback.correct { color: var(--good); }
.quiz .feedback.incorrect { color: var(--bad); }

nav.lesson-nav {
  display: flex;
  justify-content: space-between;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.9rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.ask-agent {
  margin: 2.5rem 0 0;
  padding: 1rem 1.2rem;
  border: 1px dashed var(--rule);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--muted);
}

.source {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

ul, ol { padding-left: 1.3rem; }
li { margin-bottom: 0.4rem; }

@media print {
  body { background: white; color: black; font-size: 11pt; }
  .ask-agent, nav.lesson-nav { display: none; }
  a { color: black; }
}
