/* High-contrast modes — user preference (users.high_contrast), overrides the
   per-game palette on the game screen only. Scoped to :has(.game-screen)
   like the per-game theme block in games/show.html.erb; the extra body class
   outranks that block regardless of stylesheet order. */

body.hc-dark:has(.game-screen) {
  --theme-bg: #000000;
  --theme-text: #ffffff;
  --theme-accent: #ffd60a;
  --theme-bg-image: none;
  --panel-bg: #111111;
  --panel-header: #1a1a1a;
  --border-color: #777777;
  --border-subtle: #555555;
  --text-bright: #ffffff;
  --text-mid: #ffffff;
  --text-muted: #d0d0d0;
  --text-dim: #d0d0d0;
  --line-dim: #d0d0d0;
  --color-success: #4dd97a;
  --color-partial: #ffd60a;
  --color-failure: #ff6b6b;
  --color-failure-text: #ff6b6b;
  --color-heal: #4dd97a;
  --color-danger-text: #ff6b6b;
  --color-exit: #7fe0b0;
  --color-exit-hover: #a8f0cc;
}

body.hc-light:has(.game-screen) {
  --theme-bg: #ffffff;
  --theme-text: #000000;
  --theme-accent: #0047ab;
  --theme-bg-image: none;
  --panel-bg: #f2f2f2;
  --panel-header: #e8e8e8;
  --border-color: #888888;
  --border-subtle: #aaaaaa;
  --text-bright: #000000;
  --text-mid: #000000;
  --text-muted: #2a2a2a;
  --text-dim: #2a2a2a;
  --line-dim: #2a2a2a;
  --color-success: #0a6b32;
  --color-partial: #7a5800;
  --color-failure: #b00020;
  --color-failure-text: #b00020;
  --color-heal: #0a6b32;
  --color-danger-text: #b00020;
  --color-exit: #00584a;
  --color-exit-hover: #007a66;
}

/* The browser's own parts (scrollbars, form controls) follow the palette.
   Outranks _theme_style's html:has(.game-screen). */
html:has(body.hc-dark .game-screen) { color-scheme: dark; scrollbar-color: #d0d0d0 #000000; }
html:has(body.hc-light .game-screen) { color-scheme: light; scrollbar-color: #2a2a2a #ffffff; }

/* Solid panels — the default 50%-transparent mixes stack with the background
   art and vignette, which is exactly the washed-out effect being fixed. */
body.hc-dark:has(.game-screen) .scene-panel,
body.hc-dark:has(.game-screen) .save-panel,
body.hc-light:has(.game-screen) .scene-panel,
body.hc-light:has(.game-screen) .save-panel {
  background: var(--panel-bg);
  border-color: var(--border-color);
}

/* Opacity-based dimming is invisible to the variable overrides above — these
   selectors fade text with `opacity`, so they must be reset explicitly. */
body.hc-dark:has(.game-screen) .stat-label,
body.hc-light:has(.game-screen) .stat-label,
body.hc-dark:has(.game-screen) .attribute-value.zero,
body.hc-light:has(.game-screen) .attribute-value.zero,
body.hc-dark:has(.game-screen) .xp-bar-inner,
body.hc-light:has(.game-screen) .xp-bar-inner,
body.hc-dark:has(.game-screen) .turn-hint-text,
body.hc-light:has(.game-screen) .turn-hint-text,
body.hc-dark:has(.game-screen) .turn-hint-dismiss,
body.hc-light:has(.game-screen) .turn-hint-dismiss,
body.hc-dark:has(.game-screen) .turn-hint-close,
body.hc-light:has(.game-screen) .turn-hint-close,
body.hc-dark:has(.game-screen) .action-prompt,
body.hc-light:has(.game-screen) .action-prompt,
body.hc-dark:has(.game-screen) .console-separator,
body.hc-light:has(.game-screen) .console-separator,
body.hc-dark:has(.game-screen) #inventory-panel .scene-panel-header h3,
body.hc-light:has(.game-screen) #inventory-panel .scene-panel-header h3,
body.hc-dark:has(.game-screen) .panel-legal a,
body.hc-light:has(.game-screen) .panel-legal a,
body.hc-dark:has(.game-screen) .panel-legal span,
body.hc-light:has(.game-screen) .panel-legal span {
  opacity: 1;
}

/* Inactive momentum pips, faint at 0.12 elsewhere: legible here but still
   clearly "unfilled". Only the inactive ones — this outranks .momentum-pip.active,
   and dimmed the lit pip with the rest. */
body.hc-dark:has(.game-screen) .momentum-pip:not(.active),
body.hc-light:has(.game-screen) .momentum-pip:not(.active) {
  opacity: 0.4;
}

/* The stat bar tints its background with the accent, which muddies the
   accent-colored labels sitting on it. Keep it flat. */
body.hc-dark:has(.game-screen) .hero-stat-bar,
body.hc-light:has(.game-screen) .hero-stat-bar {
  background: var(--panel-bg);
}

/* No background art or edge vignette in high-contrast modes */
body.hc-dark:has(.game-screen)::before,
body.hc-light:has(.game-screen)::before,
body.hc-dark:has(.game-screen)::after,
body.hc-light:has(.game-screen)::after {
  display: none;
}
