/* AI course surfaces: lesson card, course hubs (syllabus), code viewer.
   Tokens only, from core.css; works in both themes. */

/* ---------------------------------------------------------------- Lesson card */
.lesson-card {
  margin: var(--sp-4) 0 var(--sp-6);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: var(--sp-4);
}
.lesson-card--build { border-color: var(--border-accent); }
.lesson-card-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.lesson-card-kind {
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
  padding: .2rem .65rem; border-radius: var(--r-full); background: var(--accent-subtle); border: 1px solid var(--border-accent);
}
.lesson-card-time { font-size: var(--fs-sm); color: var(--text-muted); }
.lesson-card-block { display: flex; flex-direction: column; gap: var(--sp-2); }
.content .lesson-card-label { margin: 0; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.content .lesson-card-note { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }

.content ul.lesson-card-files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.content ul.lesson-card-files li { margin: 0; padding: 0; }
.content ul.lesson-card-files li::before { content: none; }
.lesson-file {
  display: flex; align-items: center; gap: var(--sp-3); min-height: var(--target-min);
  padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text); text-decoration: none;
}
.lesson-file:hover { border-color: var(--accent); }
.lesson-file:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-ring-offset); }
.lesson-file code { background: none; border: 0; padding: 0; font-size: var(--fs-sm); color: var(--text); }
.lesson-file-tag { flex: 0 0 auto; font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; padding: .15rem .45rem; border-radius: var(--r-sm); color: var(--accent-contrast); background: var(--accent); }
.lesson-file-tag--test { background: var(--success); }
.lesson-file-meta { margin-left: auto; font-size: var(--fs-xs); color: var(--text-dim); white-space: nowrap; }

.lesson-run {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: .5rem .5rem .5rem .75rem; border-radius: var(--r-md); background: var(--code-bg, var(--surface-2)); border: 1px solid var(--border);
}
.lesson-run-label { font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); }
.content .lesson-run-cmd { flex: 1 1 200px; min-width: 0; overflow-x: auto; white-space: nowrap; background: none; border: 0; padding: 0; font-size: var(--fs-sm); color: var(--text); }
.lesson-copy {
  min-height: 32px; padding: .25rem .7rem; font: inherit; font-size: var(--fs-xs); font-weight: 700; cursor: pointer;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
}
.lesson-copy:hover { border-color: var(--accent); color: var(--accent); }
.lesson-copy:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-ring-offset); }

.content ul.lesson-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.content ul.lesson-chips li { margin: 0; padding: 0; }
.content ul.lesson-chips li::before { content: none; }
.lesson-chips a {
  display: inline-flex; align-items: center; min-height: 32px; padding: .25rem .75rem; font-size: var(--fs-sm); text-decoration: none;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-full);
}
.lesson-chips a:hover { border-color: var(--accent); color: var(--accent); }

.lesson-pair {
  position: relative; display: grid; grid-template-columns: 1fr auto; gap: var(--sp-0) var(--sp-3); align-items: center;
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); text-decoration: none;
  background: var(--accent-subtle); border: 1px solid var(--border-accent); color: var(--text);
}
.lesson-pair:hover { border-color: var(--accent); }
.lesson-pair:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-ring-offset); }
.lesson-pair-kicker { grid-column: 1; font-size: var(--fs-xs); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); }
.lesson-pair-title { grid-column: 1; font-weight: 700; }
.lesson-pair-sub { grid-column: 1; font-size: var(--fs-xs); color: var(--text-muted); }
.lesson-pair-arrow { grid-column: 2; grid-row: 1 / span 3; font-size: var(--fs-lg); color: var(--accent); }

/* ---------------------------------------------------------------- Course hub */
.course-hero {
  padding: var(--sp-6); margin-bottom: var(--sp-5);
  border: 1px solid var(--border-accent); border-radius: var(--r-xl);
  background: radial-gradient(ellipse 60% 90% at 100% 0%, var(--accent-subtle), transparent 70%), var(--surface);
  box-shadow: var(--shadow-md);
}
.content .course-eyebrow { display: inline-block; margin: 0 0 var(--sp-2); padding: .2rem .7rem; font-size: var(--fs-xs); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); background: var(--accent-subtle); border: 1px solid var(--border-accent); border-radius: var(--r-full); }
.content .course-hero h1 { margin: 0 0 var(--sp-2); font-size: var(--fs-3xl); line-height: 1.1; border: 0; padding: 0; }
.content .course-lede { margin: 0 0 var(--sp-4); max-width: 64ch; color: var(--text-muted); font-size: var(--fs-md); line-height: 1.6; }
.content ul.course-facts { list-style: none; margin: 0 0 var(--sp-5); padding: 0; display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); }
.content ul.course-facts li { margin: 0; padding: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.content ul.course-facts li::before { content: none; }
.course-facts strong { color: var(--text); }
.course-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.course-btn {
  display: inline-flex; align-items: center; gap: .4rem; min-height: var(--target-touch); padding: .6rem 1.1rem;
  font-weight: 700; font-size: var(--fs-sm); text-decoration: none; border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
}
.course-btn:hover { border-color: var(--accent); }
.course-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.course-btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.course-btn:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-ring-offset); }

/* Two-course explainer */
.course-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); margin: 0 0 var(--sp-6); }
.course-pair-card { display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); text-decoration: none; color: var(--text); }
.course-pair-card.is-here { border-color: var(--accent); background: var(--accent-subtle); }
a.course-pair-card:hover { border-color: var(--accent); }
.course-pair-kicker { font-size: var(--fs-xs); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); }
.course-pair-title { font-weight: 700; font-size: var(--fs-md); }
.course-pair-sub { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.5; }

/* How each lesson works */
.course-howto { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); margin: 0 0 var(--sp-6); padding: 0; list-style: none; counter-reset: howto; }
.content .course-howto li { margin: 0; padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.content .course-howto li::before { content: none; }
.course-howto strong { display: block; margin-bottom: var(--sp-1); }
.course-howto span { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.5; }

/* Syllabus */
.content .course-h2 { margin: var(--sp-6) 0 var(--sp-3); font-size: var(--fs-xl); border: 0; padding: 0; }
.course-progress-line { margin: 0 0 var(--sp-4); font-size: var(--fs-sm); color: var(--text-muted); }
.course-stages { display: flex; flex-direction: column; gap: var(--sp-3); margin: 0 0 var(--sp-6); }
.course-stage { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.course-stage.is-current { border-color: var(--border-accent); box-shadow: var(--shadow-sm); }
.content .course-stage summary {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); cursor: pointer; list-style: none;
  font-weight: inherit; font-size: inherit; color: inherit; background: none; border: 0; margin: 0;
}
.content .course-stage summary::before { content: none; display: none; }
.course-stage summary::-webkit-details-marker { display: none; }
.course-stage summary::after {
  content: ""; flex: 0 0 auto; width: 8px; height: 8px; margin: 0 var(--sp-1) var(--sp-1) auto;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted); transform: rotate(45deg); transition: transform var(--dur) var(--ease);
}
.course-stage[open] > summary::after { transform: rotate(-135deg); margin-bottom: -var(--sp-1); }
.content .course-stage[open] > summary { border-bottom: 1px solid var(--border); margin: 0; }
.course-stage summary:focus-visible { outline: var(--focus-ring); outline-offset: -2px; }
.course-stage-num {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border-radius: var(--r-full); font-size: var(--fs-sm); font-weight: 800; color: var(--accent); background: var(--accent-subtle); border: 1px solid var(--border-accent);
}
.course-stage.is-complete .course-stage-num { color: var(--accent-contrast); background: var(--success); border-color: var(--success); }
.course-stage-text { display: flex; flex-direction: column; gap: var(--sp-0); min-width: 0; }
.course-stage-title { font-weight: 700; color: var(--text); }
.course-stage-meta { font-size: var(--fs-xs); color: var(--text-muted); }
.content ol.course-lessons { list-style: none; margin: 0; padding: var(--sp-2) var(--sp-3) var(--sp-3); }
.content ol.course-lessons li { margin: 0; padding: 0; }
.content ol.course-lessons li::before { content: none; }
/* THE ROW IS THE `li`. The lesson tick became a real control -- the syllabus
   painted completion it gave no way to set -- and a `button` cannot sit inside
   the `a`, so the two are siblings and the `li` lays them out. The `a` keeps
   its own grid for the three columns inside it. */
.course-lesson-row { display: flex; align-items: center; gap: 0; }
/* Same control as the Section_Sidebar's, and the same reasoning: --target-min
   is the hit target, the box is in the initial response so enabling it after
   auth resolves costs no layout shift, and `disabled` changes only cursor and
   opacity. Sized in flow with the row gap zeroed to pay for it, rather than
   negative-margined out -- the rail's comment in content.css records why. */
.course-lesson-row .prog-toggle {
  display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center;
  width: var(--target-min); height: var(--target-min);
  padding: 0; background: none; border: 0; border-radius: var(--r-full); cursor: pointer;
}
.course-lesson-row .prog-toggle[disabled] { cursor: default; opacity: 0.45; }
.course-lesson-row .prog-toggle:not([disabled]):hover .prog-dot { border-color: var(--accent); }
.course-lesson-row .prog-toggle:focus-visible {
  outline: var(--focus-ring); outline-offset: calc(var(--focus-ring-offset) * -1);
}
.course-lesson {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--sp-3);
  flex: 1 1 auto; min-width: 0;
  padding: .6rem var(--sp-3); border-radius: var(--r-md); text-decoration: none; color: var(--text);
}
.course-lesson:hover { background: var(--surface-2); }
.course-lesson:focus-visible { outline: var(--focus-ring); outline-offset: -2px; }
.course-lesson-n {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); border: 2px solid var(--border-strong);
}
.course-lesson.is-done .course-lesson-n { color: var(--accent-contrast); background: var(--success); border-color: var(--success); }
.course-lesson-body { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-0); }
.course-lesson-title { font-weight: 600; line-height: 1.35; }
.course-lesson.is-done .course-lesson-title { color: var(--text-muted); }
.course-lesson-tags { display: flex; flex-wrap: wrap; gap: var(--sp-1h); font-size: var(--fs-xs); color: var(--text-muted); }
.course-tag { padding: 1px var(--sp-2); border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); }
.course-tag--code { color: var(--accent); border-color: var(--border-accent); background: var(--accent-subtle); }
.course-lesson-time { font-size: var(--fs-xs); color: var(--text-dim); white-space: nowrap; }

/* Get the code panel */
.course-code-panel { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-4); align-items: center; padding: var(--sp-5); margin: 0 0 var(--sp-6); border: 1px solid var(--border-accent); border-radius: var(--r-lg); background: var(--surface); }
.content .course-code-panel h2 { margin: 0 0 var(--sp-2); font-size: var(--fs-lg); border: 0; padding: 0; }
.content .course-code-panel p { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.6; }

/* ---------------------------------------------------------------- Code viewer */
.code-page { margin-bottom: var(--sp-4); }
.content .code-crumb { margin: 0 0 var(--sp-2); font-size: var(--fs-sm); color: var(--text-muted); }
.content .code-title { margin: 0 0 var(--sp-2); font-size: var(--fs-2xl); border: 0; padding: 0; }
.content .code-title code { background: none; border: 0; padding: 0; font-size: inherit; color: var(--text); }
.content .code-blurb { margin: 0 0 var(--sp-4); color: var(--text-muted); }
.code-used { margin: 0 0 var(--sp-4); }
.content .code-used-label { margin: 0 0 var(--sp-1); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.content .code-used ul { margin: 0; padding-left: 1.2rem; }
.code-used-tag { font-size: 10px; font-weight: 800; text-transform: uppercase; padding: 1px var(--sp-1h); border-radius: var(--r-xs); color: var(--accent-contrast); background: var(--success); }
.code-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: 0 0 var(--sp-4); }
.code-btn { display: inline-flex; align-items: center; min-height: var(--target-min); padding: .5rem 1rem; font: inherit; font-size: var(--fs-sm); font-weight: 700; text-decoration: none; cursor: pointer; border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); }
.code-btn:hover { border-color: var(--accent); }
.code-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.code-btn-primary:hover { background: var(--accent-hover); }
.code-btn:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-ring-offset); }
.code-files { display: flex; flex-wrap: wrap; gap: var(--sp-1h); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.code-files a { padding: .2rem .55rem; border-radius: var(--r-sm); text-decoration: none; border: 1px solid transparent; }
.code-files a code { background: none; border: 0; padding: 0; font-size: var(--fs-xs); color: var(--text-muted); }
.code-files a:hover code, .code-files a[aria-current="page"] code { color: var(--accent); }
.code-files a[aria-current="page"] { border-color: var(--border-accent); background: var(--accent-subtle); }
.content ol.code-steps { list-style: none; margin: 0 0 var(--sp-5); padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.content ol.code-steps li { margin: 0; padding: 0; display: flex; gap: var(--sp-3); align-items: flex-start; }
.content ol.code-steps li::before { content: none; }
.code-steps li > div { flex: 1; min-width: 0; }
.content .code-steps p { margin: var(--sp-2) 0 0; }
.code-step-n { flex: 0 0 auto; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-full); font-weight: 800; color: var(--accent-contrast); background: var(--accent); }
.content .code-h2 { margin: var(--sp-5) 0 var(--sp-3); font-size: var(--fs-xl); border: 0; padding: 0; }
.content ul.code-table { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.content ul.code-table li { margin: 0; padding: 0; }
.content ul.code-table li::before { content: none; }
.code-row { display: grid; grid-template-columns: minmax(0, 15rem) 1fr auto; gap: var(--sp-3); align-items: center; padding: .65rem .9rem; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); text-decoration: none; color: var(--text); }
.code-row:hover { border-color: var(--accent); }
.code-row code { background: none; border: 0; padding: 0; font-size: var(--fs-sm); color: var(--accent); }
.code-row-blurb { font-size: var(--fs-sm); color: var(--text-muted); }
.code-row-meta { font-size: var(--fs-xs); color: var(--text-dim); white-space: nowrap; }

@media (max-width: 720px) {
  .course-hero { padding: var(--sp-5); }
  .content .course-hero h1 { font-size: var(--fs-2xl); }
  .course-pair, .course-howto { grid-template-columns: 1fr; }
  .course-code-panel { grid-template-columns: 1fr; }
  .course-lesson { grid-template-columns: auto 1fr; }
  .course-lesson-time { display: none; }
  .code-row { grid-template-columns: 1fr; gap: var(--sp-0); }
  .lesson-card { padding: var(--sp-4); }
  .lesson-file-meta { display: none; }
}

/* ---------------------------------------------------------------- Article overrides
   These surfaces sit inside .article-body, whose prose rules cap lists and
   paragraphs at a reading measure and colour/underline every link. */
.content .course-hero, .content .course-pair, .content .course-howto, .content .course-stages,
.content .course-code-panel, .content .lesson-card, .content .code-page,
.content .course-hero p, .content .course-lessons, .content .code-table, .content .code-steps { max-width: none; }
.content a.course-btn, .content a.course-pair-card, .content a.course-lesson, .content a.lesson-file,
.content a.lesson-pair, .content a.code-row, .content a.code-btn, .content .lesson-chips a,
.content .code-files a { text-decoration: none; border-bottom: 0; }
/* The hero is the full page frame wide now (1390px at 1440), so the lede keeps
   its own reading measure rather than the `.course-hero p` reset above; and
   `.content ol` would otherwise indent the how-to cards by its list padding. */
.content .course-hero .course-lede { max-width: 72ch; }
.content ol.course-howto { padding: 0; }
.content a.course-btn { color: var(--text); }
.content a.course-btn-primary, .content a.code-btn-primary { color: var(--accent-contrast); }
.content a.course-pair-card { color: var(--text); padding: var(--sp-4); }
.content a.course-lesson, .content a.lesson-pair, .content a.lesson-file, .content a.code-row { color: var(--text); }
.content .lesson-file code, .content .code-files a code { background: none; border: 0; padding: 0; }
.content .lesson-pair-title { color: var(--text); }
@media (max-width: 720px) {
  .course-actions .course-btn { flex: 1 1 auto; justify-content: center; }
}
/* On a phone three actions wrap two-then-one, and `flex: 1 1 auto` then
   stretches the pair to fill row one — so the PRIMARY action ends up the
   narrowest target on the card while a secondary one gets the full width
   below it. Measured on /sql/ at 390px: "Start Lesson 1" 135px, "15 practice
   problems" 185px, "Open the playground" the full 318px.

   Stacking them is what makes the row read in priority order again, and it
   gives every action the same full-width tap target rather than making the
   first one the hardest to hit. 480px is where two of these labels stop
   fitting side by side; above it the two-up row is still comfortable.

   Applies to all six course hubs, which all carry two or three actions of the
   same shape — /sql/, /ai-engineer/, /agentic-ai/ and the three fundamentals
   hubs — so none of them has the inverted-priority row either. */
@media (max-width: 480px) {
  .course-actions { flex-direction: column; align-items: stretch; }
  .course-actions .course-btn { flex: 0 0 auto; width: 100%; }
}
