/* Dark color scheme for legacy lessons on the learning-surfaces paper design
   (body[data-bw-learning-design='20260909'], /assets/bw-learning/surfaces-*.css).
   sitewide-theme-20260928, CSS only. The dark variant is inside (prefers-color-scheme: dark)
   and skipped in the native app reader, which keeps light. The block at the end fixes
   independent-review contrast findings in both modes.
   Palette: the legacy dark tokens (--bg oklch(15% .016 300), --surface, --ink #eef1f8,
   --violet #c084fc). The paper tokens are remapped; the surfaces rules that hard-code a
   light fill are restated with dark fills. Game/stage islands already own a dark palette.
   Clinical images and SVG pixels are not recolored; figures keep their own card. */
@media (prefers-color-scheme: dark) {
  :root:not([data-bw-app-mode='1']):not([data-bw-native-reader-ready='1']):not(:has(#bw-native-reader-style)) body[data-bw-learning-design='20260909']:not(.bw-ios-app-mode) {
    --bw26-paper: oklch(15% .016 300); --bw26-white: oklch(18.5% .018 300);
    --bw26-ink: #eef1f8; --bw26-muted: #c3cbdc; --bw26-line: rgba(214, 196, 255, .20);
    --bw26-purple: #d6bcff; --bw26-lilac: #d6bcff;
    --bw-dk-surface2: oklch(22.5% .020 300);
    color-scheme: dark;
  }
  :root:not([data-bw-app-mode='1']):not([data-bw-native-reader-ready='1']):not(:has(#bw-native-reader-style)) body[data-bw-learning-design='20260909']:not(.bw-ios-app-mode) :is(.key-fact, .memory-hook, .pearl, .clinical-pearl) {
    background: rgba(192, 132, 252, .10) !important; border-color: rgba(214, 196, 255, .28) !important; border-left-color: #c084fc !important;
  }
  :root:not([data-bw-app-mode='1']):not([data-bw-native-reader-ready='1']):not(:has(#bw-native-reader-style)) body[data-bw-learning-design='20260909']:not(.bw-ios-app-mode) :is(.board-trap, .trap-box, .warning-card) {
    background: rgba(242, 117, 140, .10) !important; color: #f7a6b4 !important; border-color: rgba(242, 117, 140, .35) !important; border-left-color: #f2758c !important;
  }
  :root:not([data-bw-app-mode='1']):not([data-bw-native-reader-ready='1']):not(:has(#bw-native-reader-style)) body[data-bw-learning-design='20260909']:not(.bw-ios-app-mode) :is(.board-trap, .trap-box, .warning-card) :is(p, strong, b) { color: #f7a6b4 !important; }
  :root:not([data-bw-app-mode='1']):not([data-bw-native-reader-ready='1']):not(:has(#bw-native-reader-style)) body[data-bw-learning-design='20260909']:not(.bw-ios-app-mode) :is(.compare-table, table:not(.stagecraft table):not(.sc-stage table)) th { background: var(--bw-dk-surface2) !important; }
  :root:not([data-bw-app-mode='1']):not([data-bw-native-reader-ready='1']):not(:has(#bw-native-reader-style)) body[data-bw-learning-design='20260909']:not(.bw-ios-app-mode) :is(.compare-table, table:not(.stagecraft table):not(.sc-stage table)) tr:hover { background: rgba(214, 196, 255, .06) !important; }
  :root:not([data-bw-app-mode='1']):not([data-bw-native-reader-ready='1']):not(:has(#bw-native-reader-style)) body[data-bw-learning-design='20260909']:not(.bw-ios-app-mode) :is(input:not([type='checkbox']):not([type='radio']):not([type='range']), select, textarea) { border-color: #8f7fae !important; }
  :root:not([data-bw-app-mode='1']):not([data-bw-native-reader-ready='1']):not(:has(#bw-native-reader-style)) body[data-bw-learning-design='20260909']:not(.bw-ios-app-mode) :is(input, textarea)::placeholder { color: #a9a3b8 !important; }
  :root:not([data-bw-app-mode='1']):not([data-bw-native-reader-ready='1']):not(:has(#bw-native-reader-style)) body[data-bw-learning-design='20260909']:not(.bw-ios-app-mode) main .bw-band {
    --bw-bg: oklch(15% .016 300); --bw-surface: oklch(18.5% .018 300); --bw-raise: oklch(22.5% .020 300); --bw-wash: rgba(192, 132, 252, .10);
    --bw-ink: #eef1f8; --bw-ink2: #d9deea; --bw-ink3: #c3cbdc; --bw-ink4: #b3bbcd;
    --bw-accent: #d6bcff; --bw-good: #8ef0c2; --bw-gold: #fbbf24; --bw-line: rgba(214, 196, 255, .30); --bw-hair: rgba(214, 196, 255, .14);
    background: oklch(15% .016 300) !important; color: #d9deea !important; color-scheme: dark;
  }
  /* Controls lose the paper/white contrast that outlined them in light: draw a lilac inset ring
     (no layout change) so each control boundary stays >= 3:1 on the dark ground. */
  :root:not([data-bw-app-mode='1']):not([data-bw-native-reader-ready='1']):not(:has(#bw-native-reader-style)) body[data-bw-learning-design='20260909']:not(.bw-ios-app-mode) button:not([aria-hidden='true']):not([data-hotspot] *):not(#bw-global-header *):not(.bw26-site-header *):not(#hd-header *):not(:disabled) {
    box-shadow: inset 0 0 0 1px rgba(214, 196, 255, .55) !important;
  }
  /* Plain page footers drawn for paper with a mid-grey ink. */
  :root:not([data-bw-app-mode='1']):not([data-bw-native-reader-ready='1']):not(:has(#bw-native-reader-style)) body[data-bw-learning-design='20260909']:not(.bw-ios-app-mode) > footer:not([class]) { color: #aab2c5 !important; }
  :root:not([data-bw-app-mode='1']):not([data-bw-native-reader-ready='1']):not(:has(#bw-native-reader-style)) body[data-bw-learning-design='20260909']:not(.bw-ios-app-mode) .bw-skip:focus { color: #10111b !important; }
}
/* Both modes (independent review contrast findings): names and headings that the legacy page
   inked for its old dark ground, disabled step buttons faded below 4.5:1 text contrast, and
   light-mode control boundaries (inset ring, no layout change). */
body[data-bw-learning-design='20260909'] :is(.med-review strong, .bw-freemium-teaser-title) { color: var(--bw26-ink, #191923) !important; }
body[data-bw-learning-design='20260909'] :is(.subpage-btn, .sp-btn, .sp-prev, .sp-next):is(:disabled, .sp-at-edge) { opacity: 1 !important; }
@media (prefers-color-scheme: light) {
  body[data-bw-learning-design='20260909'] button:not([aria-hidden='true']):not([data-hotspot] *):not(#bw-global-header *):not(.bw26-site-header *):not(#hd-header *):not(:disabled) {
    box-shadow: inset 0 0 0 1px #857a96 !important;
  }
}
/* Light mode (readability-20260928): legacy pages inked these for their old dark ground (slate, cyan and
   lilac tints, or a token that resolves light); on the paper ground they read below 4.5:1. Only text
   colour changes. */
@media (prefers-color-scheme: light) {
  body[data-bw-learning-design='20260909'] .bw-freemium-teaser .bw-freemium-secondary { color: #191923 !important; }
  body[data-bw-learning-design='20260909'] :is(.subpage-btn, .sp-btn, .sp-prev, .sp-next).sp-at-edge { color: #4b4658 !important; }
  body[data-bw-learning-design='20260909'] a.cs-back { color: #4a2d75 !important; }
  body[data-bw-learning-design='20260909'] a.cs-home { color: #34313f !important; }
  body[data-bw-learning-design='20260909'] .battle-tab.active { color: #4a2d75 !important; }
  body[data-bw-learning-design='20260909'] a.nav-link { color: #4b4658 !important; }
  body[data-bw-learning-design='20260909'] a.nav-link:is(:hover, .active) { color: #0e6072 !important; }
  body[data-bw-learning-design='20260909'] :is(.sec-desc, .section-sub, .scroll-cue) { color: #4b4658 !important; }
}
/* Light mode, second pass (readability-20260928): dark-authored panels and diagrams. */
@media (prefers-color-scheme: light) {
  /* Panels drawn as a translucent dark wash over a dark page: give them the dark ground they were designed on
     (background-color sits under the original gradient, so the artwork is unchanged). */
  body[data-bw-learning-design='20260909'] :is(.clin-card, .photo-card, .attending-box, .stage-frame, .ventricle-stage, .quad-cell, .mechanism-stage, .ear-svg-wrap, .seesaw-container) { background-color: #0d0d18; }
  body[data-bw-learning-design='20260909'] > .header { background-color: #0a0a0f; }
  /* Footers and section headings inked for the dark ground. */
  body[data-bw-learning-design='20260909'] :is(footer[style*='#aeb8c8'], footer[style*='--nbs-text-faint']) { color: #4b4658 !important; }
  body[data-bw-learning-design='20260909'] footer[style*='--nbs-text-faint'] a { color: #4a2d75 !important; }
  body[data-bw-learning-design='20260909'] .section-header h2 { color: #191923 !important; }
  /* Inline diagrams are dark-authored: text that inherits colour (no fill) must inherit the dark-ground ink, not the paper ink. */
  body[data-bw-learning-design='20260909'] svg:not([width="16"]):not([height="16"]):not(.icon):not([aria-hidden="true"]):not(#bw-global-header *):not(.bw26-site-header *):not(#hd-header *):not(button *):not(a *) { color: #eef1f8; }
}
