/* Learn (GLOSSARY.md "Learn"): a sidebar of every Topic beside one Topic's text. Builds on styles.css and landing.css. */

body.learn-page { -webkit-user-select: text; user-select: text; }

.learn {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}
.learn > main { max-width: none; margin: 0; padding: 0; min-width: 0; }

/* ---------- the sidebar ---------- */
.learn-side {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 88px);
  overflow: auto;
  padding: 16px 0 24px;
  font-size: 14px;
}
.learn-side summary { display: none; }
.learn-side h3 { font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 18px 0 6px; }
.learn-side ol { list-style: none; margin: 0; padding: 0; }
.learn-side a {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 5px 10px;
  border-radius: 8px;
  color: var(--body);
  text-decoration: none;
}
.learn-side a:hover { background: var(--panel-2); color: var(--text); }
.learn-side a[aria-current="page"] { background: var(--panel); color: var(--accent); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.learn-side .tp-pos { flex: none; width: 3.6em; line-height: 1.3; font-size: 11px; font-weight: 700; color: var(--muted); }
.learn-home { font-weight: 700; }

/* ---------- a Topic ---------- */
.topic { max-width: 760px; padding: 32px 0 56px; color: var(--body); line-height: 1.7; font-size: 16px; }
.topic h1 { font-size: 34px; line-height: 1.2; margin: 4px 0 8px; color: var(--text); }
.topic h2 { font-size: 22px; margin: 40px 0 10px; color: var(--text); }
.topic h3 { font-size: 17px; margin: 24px 0 6px; color: var(--text); }
.topic .eyebrow { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.tp-idea { font-size: 19px; color: var(--muted); margin: 0 0 10px; line-height: 1.5; }
.tp-try { margin: 0; font-size: 14px; }
.tp-try:empty { display: none; }
.topic code { font-family: var(--mono); font-size: 0.9em; background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }
.topic .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.topic .katex { color: var(--text); }
.topic table { border-collapse: collapse; margin: 12px 0; font-size: 14px; }
.topic th, .topic td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; }
.topic th { background: var(--panel-2); color: var(--text); }
.topic .worked { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-inner); padding: 4px 18px; margin: 16px 0; }
.tp-links { padding-left: 18px; }
.tp-links li { margin: 8px 0; }
.tp-links .note { display: block; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ---------- Topic animations (src/learn/player.js) ---------- */
.topic figure { margin: 22px 0; }
.anim-stage {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-inner);
  overflow: hidden;
  cursor: pointer;
}
.anim-stage > svg:first-child { display: block; width: 100%; height: auto; font-family: var(--sans); }
.anim-toggle {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  opacity: 0.75;
}
.anim-stage:hover .anim-toggle, .anim-toggle:focus-visible, figure.paused .anim-toggle { opacity: 1; }
.anim-toggle:hover { color: var(--accent); border-color: var(--accent); }
.anim-toggle svg { width: 14px; height: 14px; fill: currentColor; }
.topic figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; line-height: 1.5; }

/* ---------- the Topic map ---------- */
.map-note { color: var(--muted); }
.map-wrap { overflow-x: auto; padding: 8px 0; }
.map-svg { display: block; font-family: var(--sans); }
.map-edge { fill: none; stroke: var(--border); stroke-width: 1.5; }
.map-node rect { fill: var(--panel); stroke: var(--g, var(--border)); stroke-width: 1.5; }
.map-node text { fill: var(--text); font-size: 12.5px; font-weight: 600; dominant-baseline: central; }
.map-node .map-pos { fill: var(--muted); font-size: 10.5px; font-weight: 700; text-anchor: end; }
.map-node:hover rect, .map-node:focus-visible rect { fill: var(--panel-2); stroke-width: 2.5; }
.g-A { --g: var(--brand); }
.g-B { --g: var(--pos); }
.g-C { --g: var(--num); }
.g-D { --g: var(--warn); }
.map-list { display: none; }
.map-list, .map-list ul { list-style: none; padding: 0; }
.map-step { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin-top: 14px; }
.map-list a { display: inline-flex; align-items: center; gap: 8px; margin: 3px 0; }
.map-list a::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--g); flex: none; }

/* ---------- phones: the sidebar folds above the text, the map becomes a list ---------- */
@media (max-width: 899px) {
  .learn { grid-template-columns: 1fr; gap: 0; padding: 0 16px; }
  .learn-side { position: static; max-height: none; padding: 12px 0 0; border-bottom: 1px solid var(--border); }
  .learn-side summary { display: list-item; cursor: pointer; font-weight: 700; padding: 6px 0 10px; color: var(--text); }
  .topic { padding-top: 16px; font-size: 15.5px; }
  .topic h1 { font-size: 28px; }
}
@media (max-width: 760px) {
  .map-wrap { display: none; }
  .map-list { display: block; }
}
