/* Shared stylesheet for Stock Education Plan lessons and reference docs.
   Tufte-influenced: generous margins, restrained color, print-friendly. */

:root {
  --ink: #1a1a1a;
  --ink-soft: #4a4a4a;
  --paper: #fdfcfa;
  --paper-shade: #f4f1ea;
  --rule: #d8d2c4;
  --accent: #8a3324;
  --accent-soft: #b85c4a;
  --good: #2f6f4e;
  --bad: #a83c2f;
  --sidenote: #6b6b6b;
  --muted: #898781;
  --baseline: #c3c2b7;
  --chart-border: rgba(11,11,11,0.10);
  --serif: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --measure: 42em;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8e4da;
    --ink-soft: #b8b2a4;
    --paper: #1c1a17;
    --paper-shade: #262319;
    --rule: #3a362c;
    --accent: #d98a6f;
    --accent-soft: #c97e5f;
    --good: #6fbf8f;
    --bad: #e08070;
    --sidenote: #948d7c;
    --muted: #948d7c;
    --baseline: #4a463a;
    --chart-border: rgba(255,255,255,0.12);
  }
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  font-family: var(--serif);
  color: var(--ink);
  background: var(--paper);
  max-width: var(--measure);
  margin: 3rem auto 6rem;
  padding: 0 1.5rem;
  font-size: 19px;
  line-height: 1.55;
}

h1, h2, h3 {
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
}

h1 {
  font-size: 2rem;
  margin-bottom: 0.2rem;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.5rem;
}

.kicker {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

h2 {
  font-size: 1.35rem;
  margin-top: 2.5rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.3rem;
}

h3 {
  font-size: 1.05rem;
  margin-top: 1.6rem;
  color: var(--accent);
}

p { margin: 0.9rem 0; }

a { color: var(--accent); text-decoration-thickness: 1px; }
a:hover { color: var(--accent-soft); }

.ticker {
  font-family: var(--mono);
  font-weight: 600;
  background: var(--paper-shade);
  padding: 0.05em 0.35em;
  border-radius: 3px;
  font-size: 0.92em;
}

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

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

th {
  font-family: var(--mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  border-bottom: 2px solid var(--ink);
}

tr:hover td { background: var(--paper-shade); }

.asof {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--sidenote);
}

/* Short inline date/quarter tags inside table cells, where nowrap is actually wanted */
td .asof, th .asof {
  white-space: nowrap;
}

blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.2rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  color: var(--ink-soft);
  font-style: italic;
}

.callout {
  background: var(--paper-shade);
  border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0;
  padding: 0.9rem 1.1rem;
  margin: 1.3rem 0;
  font-size: 0.95rem;
}

.callout-title {
  font-family: var(--mono);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.3rem;
  display: block;
}

.go-check {
  border-left-color: var(--good);
}
.go-check .callout-title { color: var(--good); }

.caveat {
  border-left-color: var(--bad);
}
.caveat .callout-title { color: var(--bad); }

.nav-links {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.85rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.source-list {
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.source-list li { margin: 0.3rem 0; }

.ask-agent {
  margin-top: 2.5rem;
  padding: 1rem 1.2rem;
  background: var(--paper-shade);
  border-radius: 6px;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

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

.quiz-q {
  font-weight: 600;
  margin-bottom: 0.8rem;
}

.quiz-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.1em 0.5em;
  border-radius: 3px;
  margin-bottom: 0.5rem;
  background: var(--paper);
  color: var(--sidenote);
  border: 1px solid var(--rule);
}
.quiz-tag.review { color: var(--accent); border-color: var(--accent); }

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

.quiz-option {
  text-align: left;
  font-family: var(--serif);
  font-size: 1rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

.quiz-option:hover { border-color: var(--accent); }

.quiz-option.correct {
  background: color-mix(in srgb, var(--good) 18%, var(--paper));
  border-color: var(--good);
}

.quiz-option.incorrect {
  background: color-mix(in srgb, var(--bad) 18%, var(--paper));
  border-color: var(--bad);
}

.quiz-explain {
  margin-top: 0.7rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  display: none;
}

.quiz-explain.shown { display: block; }

/* Chart components — shared by every module's embedded valuation/return charts (see NOTES.md item 8).
   Ticker series colors (--t1..--t4 or similar) are declared per-lesson, scoped to that module's company set. */
.chart-card {
  background: var(--paper-shade);
  border: 1px solid var(--chart-border);
  border-radius: 6px;
  padding: 1.25rem 1.1rem 0.9rem;
  margin: 1.2rem 0;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1.25rem;
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
}
.chart-legend .item { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--ink-soft); }
.chart-legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chart-legend b { color: var(--ink); font-weight: 600; }

.chart-shell { position: relative; }
.chart-shell svg { display: block; width: 100%; height: auto; overflow: visible; }

.gridline { stroke: var(--rule); stroke-width: 1; }
.yearline { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-baseline { stroke: var(--baseline); stroke-width: 1; }
.baseline-100 { stroke: var(--ink-soft); stroke-width: 1.25; stroke-dasharray: 4 3; }
.axis-label { fill: var(--muted); font-family: var(--mono); font-size: 11px; }
.xcat-label { fill: var(--ink-soft); font-family: var(--mono); font-size: 11px; }
.xtick { stroke: var(--baseline); stroke-width: 1; }
.series-line { fill: none; stroke-width: 2px; stroke-linejoin: round; stroke-linecap: round; }
.series-dot { stroke: var(--paper-shade); stroke-width: 1.25px; }
.end-label { font-family: var(--mono); font-size: 12.5px; font-weight: 600; }
.end-sub { font-family: var(--mono); font-size: 10.5px; fill: var(--muted); }
.chart-hit { fill: transparent; cursor: crosshair; }
.crosshair { stroke: var(--ink-soft); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; pointer-events: none; }
.hoverdot { opacity: 0; pointer-events: none; }
.gap-band { fill: var(--muted); opacity: 0.07; }
.gap-note { fill: var(--muted); font-family: var(--mono); font-size: 9.5px; font-style: italic; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.08s;
  background: var(--paper);
  border: 1px solid var(--chart-border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  font-size: 0.8rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 160px;
  z-index: 5;
}
.chart-tooltip .t-year {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sidenote);
  margin-bottom: 0.4rem;
}
.chart-tooltip .t-row { display: flex; justify-content: space-between; gap: 0.9rem; align-items: center; padding: 0.1rem 0; }
.chart-tooltip .t-name { display: flex; align-items: center; gap: 0.4rem; color: var(--ink-soft); }
.chart-tooltip .t-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chart-tooltip .t-val { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.chart-tooltip .t-val.na { color: var(--sidenote); font-weight: 400; font-style: italic; }

.chart-toggle-row { display: flex; justify-content: flex-end; margin-top: 0.6rem; }
.chart-toggle {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  background: transparent;
  border: 1px solid var(--chart-border);
  border-radius: 4px;
  color: var(--ink-soft);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}
.chart-toggle:hover { border-color: var(--accent); color: var(--accent); }

.chart-table-scroll { overflow-x: auto; margin-top: 0.9rem; }
.chart-data-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.chart-data-table.toggled { display: none; }
.chart-data-table.toggled.shown { display: table; }
.chart-data-table th, .chart-data-table td {
  border-bottom: 1px solid var(--rule);
  padding: 0.35rem 0.45rem;
  text-align: right;
  white-space: nowrap;
}
.chart-data-table th:first-child, .chart-data-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--paper-shade);
}
.chart-data-table thead th {
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sidenote);
  border-bottom: 2px solid var(--ink-soft);
}
.chart-data-table td.na { color: var(--sidenote); font-style: italic; }
.chart-data-table td { font-variant-numeric: tabular-nums; }
.chart-data-table caption {
  caption-side: top;
  text-align: left;
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sidenote);
  margin-bottom: 0.5rem;
}

/* Phones: tighter gutters, and let wide tables scroll sideways instead of squeezing or overflowing */
@media (max-width: 700px) {
  body { font-size: 17px; margin: 1.5rem auto 4rem; padding: 0 1rem; }
  h1 { font-size: 1.6rem; }
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media print {
  body { max-width: none; font-size: 12pt; }
  .ask-agent, .quiz-option, .chart-toggle-row, .chart-tooltip { display: none; }
  a { color: var(--ink); }
}
