/*
 * Teaching Workspace Shared Stylesheet
 * Tufte-inspired, clean typography for lessons and reference documents.
 * Link this from every HTML lesson: <link rel="stylesheet" href="../assets/style.css">
 */

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

:root {
  --font-serif: "ET Book", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;

  --color-text: #111;
  --color-text-secondary: #555;
  --color-text-tertiary: #888;
  --color-bg: #fffff8;
  --color-bg-alt: #f5f5f0;
  --color-accent: #b35806;
  --color-accent-light: #e6ab02;
  --color-border: #ccc;
  --color-border-light: #e5e5e5;

  --max-width: 700px;
  --line-height: 1.6;
  --margin-sidenote: 275px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-text: #e0e0e0;
    --color-text-secondary: #aaa;
    --color-text-tertiary: #777;
    --color-bg: #1a1a1a;
    --color-bg-alt: #252525;
    --color-accent: #e6ab02;
    --color-accent-light: #f4d03f;
    --color-border: #444;
    --color-border-light: #333;
  }
}

html {
  font-size: 17px;
}

body {
  font-family: var(--font-serif);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: var(--line-height);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  text-rendering: optimizeLegibility;
}

/* ── Typography ── */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.2;
  color: var(--color-text);
  margin-top: 2rem;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2.2rem;
  margin-top: 0;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-accent);
}

h2 {
  font-size: 1.6rem;
  color: var(--color-accent);
}

h3 {
  font-size: 1.25rem;
  font-style: italic;
}

h4 {
  font-size: 1.1rem;
  font-weight: 600;
}

p {
  margin: 0 0 1rem 0;
}

/* ── Links ── */
a {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

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

/* ── Lists ── */
ul, ol {
  padding-left: 1.5rem;
  margin: 0 0 1rem 0;
}

li {
  margin-bottom: 0.4rem;
}

/* ── Code & Pre ── */
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--color-bg-alt);
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  color: var(--color-accent);
}

pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--color-bg-alt);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.5;
  border-left: 3px solid var(--color-accent);
  margin: 1rem 0;
}

pre code {
  background: none;
  padding: 0;
  color: var(--color-text);
}

/* ── Blockquotes ── */
blockquote {
  margin: 1.5rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--color-accent-light);
  background: var(--color-bg-alt);
  font-style: italic;
  color: var(--color-text-secondary);
}

/* ── Figures & Images ── */
figure {
  margin: 1.5rem 0;
  text-align: center;
}

figure img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

figcaption {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  margin-top: 0.5rem;
  font-style: italic;
}

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

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

th {
  font-weight: 600;
  border-bottom: 2px solid var(--color-border);
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr:hover {
  background: var(--color-bg-alt);
}

/* ── Sidenotes (Tufte-style) ── */
.sidenote {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

@media (min-width: 1100px) {
  body {
    max-width: 55%;
    margin-left: 5%;
  }
  .sidenote {
    float: right;
    clear: right;
    width: 35%;
    margin-right: -40%;
    margin-top: 0;
    vertical-align: baseline;
    position: relative;
  }
}

/* ── Callout Boxes ── */
.callout {
  padding: 1rem 1.2rem;
  margin: 1.5rem 0;
  border-radius: 6px;
  border-left: 4px solid var(--color-accent);
  background: var(--color-bg-alt);
}

.callout-title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.5rem;
  color: var(--color-accent);
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout.warning {
  border-left-color: #e6ab02;
}
.callout.warning .callout-title {
  color: #e6ab02;
}

.callout.info {
  border-left-color: #4a90d9;
}
.callout.info .callout-title {
  color: #4a90d9;
}

/* ── Quiz Component ── */
.quiz {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.2rem;
  margin: 1.5rem 0;
}

.quiz-question {
  font-weight: 600;
  margin-bottom: 1rem;
  font-size: 1.05rem;
}

.quiz-options {
  list-style: none;
  padding: 0;
  margin: 0;
}

.quiz-options li {
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--color-bg);
}

.quiz-options li:hover {
  border-color: var(--color-accent);
  background: rgba(179, 88, 6, 0.05);
}

.quiz-options li.correct {
  border-color: #2ecc71;
  background: rgba(46, 204, 113, 0.1);
}

.quiz-options li.incorrect {
  border-color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
}

.quiz-feedback {
  margin-top: 1rem;
  padding: 0.8rem;
  border-radius: 4px;
  display: none;
}

.quiz-feedback.show {
  display: block;
}

/* ── Lesson Meta ── */
.lesson-meta {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-text-tertiary);
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border-light);
}

.lesson-meta span {
  margin-right: 1.5rem;
}

/* ── Navigation ── */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.lesson-nav a {
  color: var(--color-text-secondary);
}

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

/* ── Print ── */
@media print {
  body {
    max-width: none;
    margin: 0;
    padding: 0;
    color: #000;
    background: #fff;
  }
  .sidenote {
    float: none;
    width: auto;
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    background: #f5f5f5;
  }
}
