/* CSS themes layered on top of Bulma 0.9.1 (vendored, pre-dates
   Bulma's own CSS variables) — see docs/ui-notes.md "CSS themes".

   Each theme is just a `body[data-theme="..."]` block defining this
   small custom-property palette; one shared block below points the
   Bulma classes this app actually uses at those variables instead of
   Bulma's hardcoded colors. Deliberately NOT themed: .is-success/
   .is-danger/.is-warning (dice pips, stress boxes, delete buttons) —
   those are functional color signals (checked/unchecked, safe/unsafe)
   that need to read the same regardless of theme. Deliberately out of
   scope for now: the battle canvas's SVG shapes, which keep their own
   hardcoded fill/stroke colors until there's a richer asset library to
   theme those with too (see [[campaign-auth-plan]] in memory / the
   session that added this). fae-online.views/main-panel sets
   `data-theme` on <body> directly (not the app root div) so these
   variables cascade to every descendant and cover the full viewport
   for background/text with no extra layout wrapper. */

body[data-theme="standard"] {
  --theme-bg: #ffffff;
  --theme-surface: #ffffff;
  --theme-surface-alt: #f5f5f5;
  --theme-text: #4a4a4a;
  --theme-text-muted: #7a7a7a;
  --theme-heading: #363636;
  --theme-border: #dbdbdb;
  --theme-primary: #3273dc;
  --theme-primary-text: #ffffff;
  --theme-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body[data-theme="tron"] {
  --theme-bg: #05070a;
  --theme-surface: #0b1420;
  --theme-surface-alt: #0f1e2e;
  --theme-text: #cfe8ff;
  --theme-text-muted: #5f92b3;
  --theme-heading: #00e5ff;
  --theme-border: #144a63;
  --theme-primary: #00c8ff;
  --theme-primary-text: #001018;
  --theme-font: Consolas, "SF Mono", "Courier New", monospace;
}

body[data-theme="forest"] {
  --theme-bg: #f3ead6;
  --theme-surface: #faf3e3;
  --theme-surface-alt: #e9dfc4;
  --theme-text: #3b2f22;
  --theme-text-muted: #7a6a52;
  --theme-heading: #3f6b3a;
  --theme-border: #c9b98f;
  --theme-primary: #4c7a3f;
  --theme-primary-text: #f6fbe6;
  --theme-font: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
}

body[data-theme="dungeon"] {
  --theme-bg: #141313;
  --theme-surface: #1e1c1b;
  --theme-surface-alt: #272423;
  --theme-text: #d8cfc2;
  --theme-text-muted: #8a8079;
  --theme-heading: #c98a3b;
  --theme-border: #3a3532;
  --theme-primary: #b5651d;
  --theme-primary-text: #1a1512;
  --theme-font: Cambria, Georgia, "Times New Roman", serif;
}

body[data-theme="far-west"] {
  --theme-bg: #e8d9b5;
  --theme-surface: #f1e4c2;
  --theme-surface-alt: #dcc79c;
  --theme-text: #4a3423;
  --theme-text-muted: #8a6f4e;
  --theme-heading: #7a2e1d;
  --theme-border: #b89a68;
  --theme-primary: #8a3324;
  --theme-primary-text: #f6e9cf;
  --theme-font: "Copperplate", "Rockwell", "Arial Narrow", sans-serif;
}

body[data-theme="grimdark"] {
  --theme-bg: #0a0a0a;
  --theme-surface: #141414;
  --theme-surface-alt: #1c1c1c;
  --theme-text: #c9c9c9;
  --theme-text-muted: #6e6e6e;
  --theme-heading: #8a0303;
  --theme-border: #2b2b2b;
  --theme-primary: #a10000;
  --theme-primary-text: #e8e8e8;
  --theme-font: "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
}

body[data-theme="snowbound"] {
  --theme-bg: #e9eef2;
  --theme-surface: #f8fafb;
  --theme-surface-alt: #dde5eb;
  --theme-text: #2b333b;
  --theme-text-muted: #6b7a87;
  --theme-heading: #5a1f2a;
  --theme-border: #c3ced7;
  --theme-primary: #3d5a73;
  --theme-primary-text: #f4f8fb;
  --theme-font: Baskerville, "Libre Baskerville", Georgia, serif;
}

/* --- Shared overrides, apply regardless of which theme is active --- */

/* body is only one viewport tall (the height:100% chain in style.css the
   battle arena needs), so its colour must paint the canvas instead —
   which browsers only do when <html> has no background of its own. */
html {
  background-color: transparent;
}

body[data-theme] {
  background-color: var(--theme-bg);
  color: var(--theme-text);
  font-family: var(--theme-font);
  /* Text on panels. Same as on the page unless the campaign customizes
     its colours; then fae-online.views/apply-theme-colors! sets these
     (and the muted/alt/border/primary-text ones) inline, picked for
     contrast against the panel colour. */
  --theme-surface-text: var(--theme-text);
  --theme-surface-muted: var(--theme-text-muted);
  --theme-surface-heading: var(--theme-heading);
  --theme-surface-primary: var(--theme-primary);
}

/* Inside a panel, the page-level names mean the panel versions, so every
   rule below (and anything nested) reads right on either background. */
body[data-theme] :is(.box, .panel, .card, .modal-card) {
  --theme-text: var(--theme-surface-text);
  --theme-text-muted: var(--theme-surface-muted);
  --theme-heading: var(--theme-surface-heading);
  --theme-primary: var(--theme-surface-primary);
}

/* Bulma hardcodes these dark, which vanishes on a dark theme. */
body[data-theme] strong {
  color: inherit;
}

body[data-theme] .box,
body[data-theme] .panel,
body[data-theme] .panel-block,
body[data-theme] .card,
body[data-theme] .modal-card-body {
  background-color: var(--theme-surface);
  color: var(--theme-text);
  border-color: var(--theme-border);
}

body[data-theme] .panel-heading,
body[data-theme] .modal-card-head,
body[data-theme] .modal-card-foot {
  background-color: var(--theme-surface-alt);
  color: var(--theme-heading);
  border-color: var(--theme-border);
}

body[data-theme] .modal-card-title {
  color: var(--theme-heading);
}

body[data-theme] .has-background-light {
  background-color: var(--theme-surface-alt) !important;
}

body[data-theme] .has-text-grey,
body[data-theme] .has-text-grey-light {
  color: var(--theme-text-muted) !important;
}

body[data-theme] .title,
body[data-theme] .subtitle,
body[data-theme] .heading {
  color: var(--theme-heading);
}

body[data-theme] a,
body[data-theme] .tabs a {
  color: var(--theme-primary);
}

body[data-theme] a.about-link {
  color: var(--theme-text-muted);
}

body[data-theme] a.about-link:hover {
  color: var(--theme-text);
}

body[data-theme] .tabs li.is-active a {
  color: var(--theme-primary);
  border-bottom-color: var(--theme-primary);
}

body[data-theme] .button {
  background-color: var(--theme-surface);
  color: var(--theme-surface-text);
  border-color: var(--theme-border);
}

body[data-theme] .button.is-link,
body[data-theme] .button.is-primary {
  background-color: var(--theme-primary);
  color: var(--theme-primary-text);
  border-color: transparent;
}

body[data-theme] .button.is-link:hover,
body[data-theme] .button.is-primary:hover {
  filter: brightness(1.12);
}

body[data-theme] .input,
body[data-theme] .textarea,
body[data-theme] .select select {
  background-color: var(--theme-surface);
  color: var(--theme-surface-text);
  border-color: var(--theme-border);
}

body[data-theme] .input::placeholder,
body[data-theme] .textarea::placeholder {
  color: var(--theme-text-muted);
  opacity: 0.8;
}

body[data-theme] .file-cta {
  background-color: var(--theme-surface);
  color: var(--theme-surface-text);
  border-color: var(--theme-border);
}

body[data-theme] .label {
  color: var(--theme-text);
}

body[data-theme] .table {
  background-color: transparent;
  color: var(--theme-text);
}

body[data-theme] .table td,
body[data-theme] .table th {
  color: var(--theme-text);
  border-color: var(--theme-border);
}

/* Dice pips keep their meaning colours in every theme, just dark enough
   for white text (Bulma's own green is 2.2:1). The neutral "0" follows
   the panel. */
body[data-theme] .tag.is-success:not(.is-light) {
  background-color: #23774a;
}

body[data-theme] .tag.is-danger:not(.is-light) {
  background-color: #c0283f;
}

body[data-theme] .tag.is-light:not(.is-success):not(.is-danger):not(.is-warning):not(.is-info) {
  background-color: var(--theme-surface-alt);
  color: var(--theme-text);
}

/* Per-campaign customization (docs/ui-notes.md "CSS themes" —
   customization): colour overrides are set as inline custom properties
   on <body> by fae-online.views/main-panel, so they win over the theme
   block above with no extra CSS. The backdrop is a fixed full-viewport
   layer behind the content; its opacity is the campaign's setting.
   `isolation` makes <body> its own stacking context, so the backdrop's
   z-index: -1 lands above body's background colour, not under it. */
body[data-theme] {
  isolation: isolate;
}

.campaign-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  pointer-events: none;
}
