/* Shedding Sessions — dark mode.
   Load after shedding.css. Applies when <html data-shed-theme="dark">.

   It works by flipping the paper and ink ramps rather than restyling components: every
   surface, keyline and text colour in the Cadenza primitives reads from those ramps (directly
   or through the semantic aliases), so one swap re-inks the whole app. This is the system's
   own idea — the inks printed on black stock — taken from the player to the whole app.

   Four deliberate departures from a plain inversion:
   - The accent lightens to a pale petrol, and text on it turns dark. Light-on-mid-petrol fails
     contrast on a dark page; dark-on-pale-petrol passes at 6.5:1.
   - Keylines soften. Full-strength cream keylines on near-black read as wireframe; a warm grey
     keeps the printed edge without the glare.
   - Offset shadows stay dark. A flipped ramp would make them cream, which reads as an error.
   - Text selection highlights in deep petrol; Cadenza's banana with the flipped ink can't be read. */

:root[data-shed-theme="dark"] {
  color-scheme: dark;

  --paper-100: #24282A;   /* card */
  --paper-200: #1A1D1F;   /* page */
  --paper-300: #141719;   /* sunken: sidebars, inspectors */
  --paper-400: #3A3F42;   /* inert fills */

  --ink-900: #EEEAE2;     /* strongest text, playhead */
  --ink-800: #D6D1C7;     /* body, played waveform */
  --ink-700: #B5AFA4;
  --ink-500: #948E84;     /* muted text — 4.5:1 on the card (#8E887E was 4.2) */
  --ink-300: #8F897F;     /* muted text on the inverse panel */
  --mark-quiet: #9C968C;  /* quiet graphics, unplayed waveform: 3:1 on the 24% section tints */

  /* accent: pale petrol, dark text on it */
  --poppy-600: #8FD3E0;
  --poppy-500: #4FB3C5;
  --poppy-300: #6FC0CF;
  --poppy-100: #173840;
  /* pressed accent darkens in dark mode too (the ramp flips, so not poppy-600) */
  --accent-press: #3F9DAE;   /* 4.7:1 with the paper-100 label */

  --marigold-600: #E6BC6A;
  --marigold-500: #D9A548;
  --marigold-100: #3A2F18;
  --state-danger: var(--marigold-500);   /* problems stay legible on dark cards (≥ 5:1) */
  --worth-checking: var(--marigold-500);
  --banana-500: #CDBB6A;
  --banana-100: #33301F;
  --teal-700: #93D3C5;
  --teal-500: #5FAE9D;
  --teal-100: #183530;
  --aqua-100: #1C3138;
  --grape-600: #BBA9DC;
  --grape-100: #2C2738;
  --rose-100: #3A2630;

  --line-strong: #75716A;   /* 3:1 on every surface (#6E6A63 was 2.8 on the card) */
  --line-soft: #2E3336;

  --surface-inverse: #0F1112;
  --text-on-dark: #EEEAE2;
  --text-on-accent: var(--paper-100);   /* dark text on gold, as on petrol (near-white was 1.9:1) */
  --state-focus: #796B95;   /* focus ring 3:1 on page, card and sunken; grape-500 itself unchanged */
  --scrim: rgba(0, 0, 0, 0.62);

  --shadow-print-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-print-md: 0 2px 4px rgba(0, 0, 0, 0.4), 0 8px 22px rgba(0, 0, 0, 0.35);
  --shadow-print-lg: 0 4px 10px rgba(0, 0, 0, 0.45), 0 20px 48px rgba(0, 0, 0, 0.5);
  --shadow-print-color: 0 2px 4px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(79, 179, 197, 0.25);
  --shadow-control-rest: 3px 3px 0 #08090A;
  --shadow-control-hover: 5px 5px 0 #08090A;

  /* sections lift a step so dark text reads on a selected block and tints stay visible */
  --section-intro:  #8FB8D6;
  --section-verse:  #6A93C9;
  --section-pre:    #D6B04F;
  --section-chorus: #E08E52;
  --section-bridge: #A78BCB;
  --section-solo:   #5BAA8B;
  --section-outro:  #A8A193;
  --section-custom: #D592AE;
  --section-tint: 24%;
  /* dark text reads on every lifted block (#47) */
  --section-intro-on:  var(--paper-100);
  --section-verse-on:  var(--paper-100);
  --section-pre-on:    var(--paper-100);
  --section-chorus-on: var(--paper-100);
  --section-bridge-on: var(--paper-100);
  --section-solo-on:   var(--paper-100);
  --section-outro-on:  var(--paper-100);
  --section-custom-on: var(--paper-100);

  --coach-near: #C9A877;
  --coach-near-edge: var(--coach-near);   /* dark sand passes on its own (6.6:1) */
  --ladder-next: #173840;
}

/* Increase Contrast (#47), dark: text aims for 7:1, graphics for 4.5:1. The aliases (--accent,
   --coach-with, --state-danger, --worth-checking …) follow their ramps. */
@media (prefers-contrast: more) {
  :root[data-shed-theme="dark"] {
    --poppy-500: #6ACDDF;      /* accent text and fills: 7:1; dark labels on it stay above 4.5 */
    --accent-press: #64C0D1;   /* pressed fill keeps 7:1 with its dark label */
    --ink-700: #C1BBB0;
    --ink-500: #B8B2A7;        /* muted text: 7:1 */
    --ink-300: #A49E93;        /* inverse-panel paragraph: 7:1 */
    --marigold-500: #DEAA4E;   /* state-danger and worth-checking: 7:1 on cards */
    --mark-quiet: #A8A298;     /* quiet graphics: 4.5:1 */
    --line-strong: #928E87;    /* keylines: 4.5:1 on every surface */
    --line-soft: #6D7276;      /* separators become real 3:1 keylines */
    --state-focus: #BAACD9;    /* focus ring: 7:1 */

    --section-intro:  #8FB8D6;
    --section-verse:  #8CB6EE;
    --section-pre:    #D6B04F;
    --section-chorus: #F3A064;
    --section-bridge: #C3A7E9;
    --section-solo:   #73C2A2;
    --section-outro:  #B9B2A4;
    --section-custom: #E4A0BC;
    --section-tint: 12%;
  }
}

/* Text selection: base.css pairs --banana-300 with --ink-900, which flips to near-white here and
   can't be read on the pale highlight. Dark mode highlights in deep petrol instead (10:1). */
:root[data-shed-theme="dark"] ::selection { background: var(--poppy-100); color: var(--ink-900); }
