/* =========================================================================
   Magic & Math with Cards — course pages (home list, sections, lectures,
   introduction) and the course links added to trick pages. Tokens, type and
   components come from site.css; everything here uses new class names, so a
   trick page's own markup and trick.css are untouched by it.
   ========================================================================= */

/* ---------- Header at phone width: wordmark above, nav below ---------- */
@media (max-width: 600px) {
  .site-header { flex-wrap: wrap; row-gap: 0; }
  .site-nav { gap: var(--s3); width: 100%; }
}
.site-nav a[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--rule-strong); }

/* ---------- Breadcrumbs ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 4px 10px; padding-top: var(--s4); font-size: 0.92rem; color: var(--text-3); }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* ---------- Lecture marks: a paper card for performances, a numeral for mathematics ---------- */
.lec-card {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 45px; border-radius: 4px;
  background: var(--paper); color: var(--black-ink);
  border: 1px solid rgba(23, 33, 43, 0.18);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
  font-family: var(--font-display); font-size: 0.95rem; font-variant-numeric: tabular-nums lining-nums;
}
.lec-card::before { content: "♠"; position: absolute; left: 3px; top: 1px; font-family: var(--font-ui); font-size: 9px; line-height: 1; color: var(--black-ink); opacity: 0.7; }
.lec-card-sm { width: 24px; height: 34px; font-size: 0.75rem; }
.lec-card-sm::before { font-size: 7px; left: 2px; }
.lec-num { display: inline-block; width: 32px; text-align: center; font-family: var(--font-display); font-style: italic; font-size: 1.05rem; color: var(--text-3); font-variant-numeric: tabular-nums lining-nums; }
.lec-num-sm { width: 24px; font-size: 0.9rem; }

.lec-legend { display: flex; flex-wrap: wrap; gap: 10px 28px; align-items: center; color: var(--text-2); font-size: 0.92rem; margin-top: var(--s1); }
.lec-legend > span { display: inline-flex; align-items: center; gap: 10px; }

/* ---------- Lecture lists ---------- */
.lec-list { list-style: none; margin: 0; padding: 0; display: grid; }
.lec { display: grid; grid-template-columns: minmax(0, 1fr); border-bottom: 1px solid var(--rule); }
.lec:last-child { border-bottom: 0; }
.lec-link { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 4px 16px; align-items: start; padding: 14px 0; text-decoration: none; }
.lec-no { padding-top: 2px; }
.lec-math .lec-no { padding-top: 3px; }
.lec-body { display: grid; gap: 4px; min-width: 0; }
.lec-title { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 1.2rem; line-height: 1.28; letter-spacing: 0; text-wrap: pretty; }
.lec-hook, .lec-goal { color: var(--text-2); font-size: 0.98rem; line-height: 1.5; max-width: 64ch; }
.lec-goal { font-size: 0.95rem; }
.lec-play {
  justify-self: start; margin: -4px 0 14px 48px; padding: 6px 12px; min-height: 36px;
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--rule-strong); border-radius: 999px;
  font-size: 0.9rem; font-weight: 600; text-decoration: none; color: var(--text);
  transition: border-color 160ms ease, background-color 160ms ease;
}
.lec-play-name { font-weight: 400; color: var(--text-2); }
.lec-play-name::before { content: " "; }
@media (hover: hover) and (pointer: fine) {
  .lec-link:hover .lec-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; text-decoration-color: var(--rule-strong); }
  .lec-play:hover { border-color: var(--text-2); background: var(--page-raised); }
}
@media (pointer: coarse) { .lec-play { min-height: 44px; } }
@media (min-width: 760px) {
  .lec { grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s3); }
  .lec-play { margin: 14px 0 0; align-self: start; }
}

/* Home: the seven sections, set like the playbill (home.css .act) */
.course-list .programme-head { max-width: 64ch; }
.act-title a { text-decoration: none; }
.act-title a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; text-decoration-color: var(--rule-strong); }
.act-count { color: var(--text-3); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.course-list .act-head { position: relative; }
@media (min-width: 900px) { .course-list .act-head { position: sticky; top: var(--s3); align-self: start; } }

/* ---------- Section pages ---------- */
.page-hero { padding: var(--s3) 0 var(--s4); display: grid; gap: var(--s2); }
.page-hero .lede { margin-top: var(--s1); }
.page-intro { max-width: 66ch; color: var(--text-2); }
.page-section { border-top: 1px solid var(--rule-strong); padding-top: var(--s3); display: grid; gap: var(--s2); }

/* ---------- Lecture pages ---------- */
.lecture-hero { padding: var(--s3) 0 var(--s4); display: grid; gap: var(--s1); }
.lecture-hero .eyebrow { margin-bottom: var(--s1); }
.lecture-sub { font-family: var(--font-display); font-style: italic; font-size: clamp(1.3rem, 2.6vw, 1.75rem); line-height: 1.3; color: var(--text-2); max-width: 40ch; text-wrap: balance; }
.lecture-top { display: grid; gap: var(--s4); align-items: start; }
@media (min-width: 980px) { .lecture-top { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s5); } }

.video-slot { margin: 0; display: grid; gap: var(--s1); }
.video-frame { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: var(--stage); }
.video-frame iframe, .video-frame video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.video-caption { color: var(--text-3); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.video-pending { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--s4); padding: var(--s4); }
.pending-cards { display: flex; align-items: flex-end; --card-w: clamp(46px, 5.4vw, 70px); padding: 0 6px 0 4px; }
.pending-cards .card + .card { margin-left: calc(var(--card-w) * -0.5); }
.pending-cards .card:first-child { transform: rotate(-9deg) translateY(4px); }
.pending-cards .card:last-child { transform: rotate(8deg) translateY(4px); }
.pending-cards .card.is-lean { transform: translateY(calc(var(--card-w) * -0.12)); z-index: 1; }
.pending-text { display: grid; gap: var(--s1); justify-items: start; }
.pending-title { font-family: var(--font-display); font-size: clamp(1.35rem, 2.4vw, 1.75rem); line-height: 1.2; color: var(--paper); }
.pending-note { color: var(--secondary-on-stage); font-size: 1rem; line-height: 1.5; max-width: 40ch; }
.pending-text .btn { margin-top: var(--s1); }
@media (max-width: 640px) {
  .video-pending { aspect-ratio: auto; grid-template-columns: minmax(0, 1fr); justify-items: start; gap: var(--s3); padding: var(--s3) var(--s3) var(--s3); }
  .pending-cards { --card-w: 46px; padding-top: 8px; }
}

.lecture-side { display: grid; gap: var(--s4); align-content: start; }
.side-h { font-family: var(--font-ui); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-3); font-weight: 600; margin-bottom: var(--s1); }
.lecture-goal p { font-family: var(--font-display); font-size: clamp(1.15rem, 1.9vw, 1.32rem); line-height: 1.42; text-wrap: pretty; }

.play-card { display: grid; gap: 6px; justify-items: start; text-decoration: none; padding: var(--s3) !important; transition: transform 200ms var(--ease-out); }
.play-card-eyebrow { font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--secondary-on-stage); font-weight: 600; }
.play-card-title { font-family: var(--font-display); font-size: 1.55rem; line-height: 1.15; color: var(--paper); }
.play-card-hook { color: var(--secondary-on-stage); font-size: 0.98rem; line-height: 1.5; }
.play-card-btn { margin-top: var(--s1); }
@media (hover: hover) and (pointer: fine) { .play-card:hover { transform: translateY(-2px); } .play-card:hover .play-card-btn { --btn-bg: #FFFFFF; } }
@media (prefers-reduced-motion: reduce) { .play-card { transition: none; } .play-card:hover { transform: none; } }

.prereq-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.prereq-list a { display: grid; grid-template-columns: 2.2em minmax(0, 1fr); gap: 8px; padding: 6px 0; text-decoration: none; line-height: 1.35; font-size: 1rem; }
.prereq-list a:hover span:last-child { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule-strong); }
.prereq-no { font-family: var(--font-display); font-style: italic; color: var(--text-3); font-variant-numeric: tabular-nums lining-nums; }
.prereq-run { font-size: 1rem; color: var(--text-2); }
.prereq-ideas-h { margin-top: var(--s2); font-size: 0.92rem; color: var(--text-3); }
.prereq-ideas { margin: 4px 0 0; padding-left: 1.2em; color: var(--text-2); font-size: 0.98rem; }
.prereq-ideas li + li { margin-top: 4px; }

.lecture-section { padding-top: var(--s5); }
.lecture-section-head { display: grid; gap: var(--s1); margin-bottom: var(--s3); max-width: 66ch; }

/* The outline: one step per scene, statements from the screen as chips */
.outline { list-style: none; margin: 0; padding: 0; display: grid; max-width: 860px; }
.outline-item { position: relative; display: grid; gap: 10px; padding: 0 0 var(--s3) 52px; }
.outline-item::before { content: ""; position: absolute; left: 15px; top: 34px; bottom: 6px; border-left: 1px solid var(--rule-strong); }
.outline-item:last-child::before { display: none; }
.outline-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; min-height: 32px; }
.outline-n { position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--rule-strong); display: grid; place-items: center; font-family: var(--font-display); font-style: italic; font-size: 1rem; color: var(--text-2); background: var(--page); font-variant-numeric: lining-nums; }
.outline-head h3 { font-family: var(--font-ui); font-size: 1.08rem; font-weight: 650; line-height: 1.35; padding-top: 3px; text-wrap: pretty; }
.outline-tag { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; color: var(--text-3); border: 1px solid var(--rule-strong); border-radius: 999px; padding: 1px 9px; white-space: nowrap; }
.is-live .outline-n { background: var(--paper); color: var(--black-ink); border-color: rgba(23, 33, 43, 0.25); border-radius: 5px; width: 26px; left: 3px; }
.board { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.board li { font-family: var(--font-math); font-size: 1.02rem; line-height: 1.35; padding: 5px 12px; border-radius: 8px; background: var(--page-raised); border: 1px solid var(--rule); color: var(--text); max-width: 100%; overflow-wrap: anywhere; }

/* Companion interactive and notes: filled, or clearly marked as still to come */
.companion { display: grid; gap: var(--s2); max-width: 66ch; justify-items: start; }
.companion-goal { font-size: 1.12rem; line-height: 1.5; }
.slot-empty { border: 1.5px dashed var(--rule-strong); border-radius: 12px; padding: var(--s3); display: grid; gap: var(--s1); max-width: 66ch; }
.slot-label { font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); font-weight: 700; }
.lecture-notes { max-width: 66ch; }

/* Sources */
.sources { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-width: 72ch; }
.sources li { padding-left: 1.1em; text-indent: -1.1em; line-height: 1.5; }
.sources li::before { content: "·"; display: inline-block; width: 1.1em; text-indent: 0; color: var(--text-3); }
.src-loc, .src-links { color: var(--text-2); }
.lecture-section details.more { margin-top: var(--s3); }
.source-notes { list-style: none; padding: 0 !important; }
.source-notes .src-author { color: var(--text-2); }
.source-notes li { font-size: 0.98rem; }

/* ---------- Trick pages: link to the lecture, and the lectures around it ---------- */
.trick-hero .eyebrow a { color: inherit; text-decoration: none; }
.trick-hero .eyebrow a:hover { text-decoration: underline; }
.trick-lecture { margin-top: var(--s1); }
.lecture-link {
  display: inline-flex; align-items: center; gap: 14px; max-width: 100%;
  padding: 10px 18px 10px 12px; border: 1px solid var(--rule-strong); border-radius: 12px;
  text-decoration: none; background: var(--page-raised);
  transition: border-color 160ms ease;
}
.lecture-link:hover { border-color: var(--text-2); }
.lecture-link-icon { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--stage); position: relative; }
.lecture-link-icon::after { content: ""; position: absolute; left: 14px; top: 11px; border-left: 11px solid var(--paper); border-top: 7px solid transparent; border-bottom: 7px solid transparent; }
.lecture-link-text { display: grid; gap: 1px; min-width: 0; }
.lecture-link-label { font-weight: 650; font-size: 1rem; }
.lecture-link-title { color: var(--text-2); font-size: 0.92rem; line-height: 1.35; }

.trick-course { margin-top: var(--s6); }
.trick-course > .eyebrow { display: block; font-family: var(--font-ui); margin-bottom: var(--s2); }
.trick-course-list { list-style: none; margin: 0; padding: 0; display: grid; max-width: 860px; border-top: 1px solid var(--rule-strong); }
.trick-course-list a { display: grid; grid-template-columns: 2.4em minmax(0, 1fr); gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); text-decoration: none; }
.tc-no { font-family: var(--font-display); font-style: italic; color: var(--text-3); grid-row: span 2; font-variant-numeric: lining-nums; padding-top: 2px; }
.tc-title { font-family: var(--font-display); font-size: 1.15rem; line-height: 1.3; }
.tc-kind { font-size: 0.85rem; color: var(--text-3); }
.trick-course-list a:hover .tc-title { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule-strong); }
.trick-course + .trick-pager { margin-top: var(--s5); }

/* ---------- Introduction ---------- */
.intro-toc { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: var(--s2) 0; margin-bottom: var(--s4); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); font-size: 0.95rem; }
.intro-toc a { color: var(--text-2); text-decoration: none; padding: 6px 0; }
.intro-toc a:hover { color: var(--text); text-decoration: underline; }
.intro h3 { margin-top: var(--s3); }
.intro-table { width: 100%; }
.intro-table td a { text-decoration: none; }
.intro-table td a:hover { text-decoration: underline; }
.intro .about-grid section { scroll-margin-top: var(--s3); }
.tricks-programme { padding-top: var(--s5); }
.tricks-programme h1 { font-size: clamp(2rem, 4.6vw, 3.2rem); }
