/* One lesson destination vocabulary: prose links and catalog rows.
   Tokens follow the surrounding surface; app-embed's explicit theme wins. */
:root {
  --bw-lesson-accent: #1d4ed8;
  --bw-lesson-ink: #292333;
  --bw-lesson-muted: #685f73;
  --bw-lesson-surface: #fff;
  --bw-lesson-line: #ded7e6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bw-lesson-accent: #93c5fd;
    --bw-lesson-ink: #f5eefb;
    --bw-lesson-muted: #c2b4d0;
    --bw-lesson-surface: #211a2a;
    --bw-lesson-line: #493954;
  }
}
html[data-bw-theme="light"], html[data-bw-theme="paper"], html.phq-mode-light, [data-bw-lesson-theme="light"] {
  --bw-lesson-accent: #1d4ed8; --bw-lesson-ink: #292333;
  --bw-lesson-muted: #685f73; --bw-lesson-surface: #fff; --bw-lesson-line: #ded7e6;
}
html[data-bw-theme="dark"], html[data-bw-theme="night"], html[data-bw-theme="exam"], html[data-bw-theme="lights-out"], html.phq-mode-dark, [data-bw-lesson-theme="dark"] {
  --bw-lesson-accent: #93c5fd; --bw-lesson-ink: #f5eefb;
  --bw-lesson-muted: #c2b4d0; --bw-lesson-surface: #211a2a; --bw-lesson-line: #493954;
}
/* The study themes (Night, Exam, Lights Out, Paper) resolve to a scheme on <html>. Without this, a light OS under a dark
   study theme kept the light-surface link colour on a near-black ground. */
html[data-bw-study-scheme="dark"] {
  --bw-lesson-accent: #93c5fd; --bw-lesson-ink: #f5eefb;
  --bw-lesson-muted: #c2b4d0; --bw-lesson-surface: #211a2a; --bw-lesson-line: #493954;
}
html[data-bw-study-scheme="light"] {
  --bw-lesson-accent: #1d4ed8; --bw-lesson-ink: #292333;
  --bw-lesson-muted: #685f73; --bw-lesson-surface: #fff; --bw-lesson-line: #ded7e6;
}
/* Legacy button declarations and authored inline styles must not turn prose
   destinations back into boxes. Navigation, citations, and actions are excluded. */
a.bw-lesson-inline,
a.ex-bwlink,
a#source-link,
a.ll-round-resource,
.ll-feedback-links a {
  display: inline !important;
  width: auto !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: none !important;
  box-shadow: none !important;
  color: var(--bw-embed-link, var(--bw-lesson-accent)) !important;
  -webkit-text-fill-color: currentColor !important;
  font: inherit !important;
  font-weight: 600 !important;
  letter-spacing: normal !important;
  line-height: inherit !important;
  text-decoration: none !important;
  text-underline-offset: .2em;
  text-decoration-thickness: 1px;
  overflow-wrap: anywhere;
  transform: none !important;
}
a.bw-lesson-inline:is(:hover, :focus-visible),
a.ex-bwlink:is(:hover, :focus-visible),
a#source-link:is(:hover, :focus-visible),
a.ll-round-resource:is(:hover, :focus-visible),
.ll-feedback-links a:is(:hover, :focus-visible) {
  text-decoration: underline !important;
}
a.ex-bwlink { display: inline-block !important; margin-top: 1rem !important; }
a.bw-lesson-row {
  display: grid !important;
  align-content: center;
  gap: .45rem;
  min-height: 64px !important;
  min-width: 0;
  max-width: 100%;
  margin: .6rem 0 !important;
  padding: 1rem 1.15rem !important;
  border: 1px solid var(--bw-lesson-line) !important;
  border-radius: 12px !important;
  background: var(--bw-lesson-surface) !important;
  color: var(--bw-lesson-ink) !important;
  -webkit-text-fill-color: currentColor !important;
  box-shadow: none !important;
  text-decoration: none !important;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
a.bw-lesson-row :is(h3, h4, strong, .card-title, .card-title-area) {
  color: inherit !important;
  -webkit-text-fill-color: currentColor !important;
}
a.bw-lesson-row :is(p, .description) { color: var(--bw-lesson-muted) !important; }
a.bw-lesson-row:is(:hover, :focus-visible) {
  border-color: var(--bw-lesson-accent) !important;
  box-shadow: 0 6px 18px -12px var(--bw-lesson-accent) !important;
  transform: translateY(-2px) !important;
}
.bw-lesson-system {
  display: block;
  color: var(--bw-lesson-accent) !important;
  font: 650 .7rem/1.4 var(--font-sans, system-ui, sans-serif);
  letter-spacing: .08em;
  text-transform: uppercase;
}
a:is(.bw-lesson-inline, .bw-lesson-row, .ex-bwlink, #source-link, .ll-round-resource):focus-visible,
.ll-feedback-links a:focus-visible {
  outline: 2px solid var(--bw-lesson-accent) !important;
  outline-offset: 4px;
}
@media (prefers-reduced-motion: reduce) {
  a.bw-lesson-row { transition: none; }
  a.bw-lesson-row:is(:hover, :focus-visible) { transform: none !important; }
}
/* Source-question controls still open dialogs; keep their button semantics. */
#cc-miss-sources:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .75rem;
}
button:is(#review-source, #cc-view-question, #cc-miss-question-source) {
  min-height: 44px;
  padding: .5rem 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: none !important;
  box-shadow: none !important;
  color: var(--bw-embed-link, var(--bw-lesson-accent)) !important;
  font: inherit !important;
  font-weight: 600 !important;
  text-underline-offset: .2em;
  cursor: pointer;
}
button:is(#review-source, #cc-view-question, #cc-miss-question-source):is(:hover, :focus-visible) {
  text-decoration: underline;
}
button:is(#review-source, #cc-view-question, #cc-miss-question-source):focus-visible {
  outline: 2px solid var(--bw-lesson-accent);
  outline-offset: 4px;
}
/* Never reveal a source before the existing answer/access gate reveals it. */
a:is(.bw-lesson-inline, .bw-lesson-row, .ex-bwlink, #source-link, #cc-miss-lesson-source, .ll-round-resource)[hidden],
button:is(#review-source, #cc-view-question, #cc-miss-question-source)[hidden] { display: none !important; }

/* Question explanations on study-session: lesson and source links take the lesson tokens, so the
   site Theme (data-bw-theme / data-bw-study-scheme) sets the colour, never the device. Scoped to the
   explanation (#questionExplain) and its "Revisit the lesson" link; every other card link, button and
   the error-recovery link keep their colours. Site-wide .ss-link colours are unchanged. */
#questionExplain a[href],
#quizPanel #freeQuizLesson.ss-link {
  color: var(--bw-lesson-accent) !important;
  -webkit-text-fill-color: currentColor !important;
  text-decoration: underline !important;
  text-decoration-color: currentColor;
  text-underline-offset: .2em;
  text-decoration-thickness: 1px;
}
#questionExplain a[href]:is(:hover, :focus-visible),
#quizPanel #freeQuizLesson.ss-link:is(:hover, :focus-visible) {
  color: var(--bw-lesson-accent) !important;
}
#questionExplain a[href]:focus-visible,
#quizPanel #freeQuizLesson.ss-link:focus-visible {
  outline: 2px solid currentColor !important;
  outline-offset: 3px;
}

/* Source markers ([n]) inside a lesson practice card are source links: they take the lesson tokens
   in both study themes. Reference markers in lesson prose are not changed. */
#authored-practice a[href^="#ref-"] {
  color: var(--bw-lesson-accent) !important;
  -webkit-text-fill-color: currentColor !important;
  text-decoration: underline !important;
  text-decoration-color: currentColor;
  text-underline-offset: .2em;
  font-weight: 600;
}
#authored-practice a[href^="#ref-"]:is(:hover, :focus-visible) {
  color: var(--bw-lesson-accent) !important;
}
#authored-practice a[href^="#ref-"]:focus-visible {
  outline: 2px solid currentColor !important;
  outline-offset: 3px;
}
