/* Penguin colour themes (Oct 2026).
   style.css holds the Logbook palette on :root as tokens. Each theme here re-sets those
   tokens on whatever carries data-theme: <html> for the whole app, or a little swatch in
   the picker so it can show a theme without switching to it.

   The rules every theme keeps:
   - only the frame changes (panels, writing, trim, buttons, lettering); the water, the boats,
     the sails, the buoys and the flags are drawn in their true colours whatever the theme
   - writing is at least 4.5:1 against everything it can sit on, including a glass panel over
     white sand; test/themes_palette.mjs checks every pairing and deploy.sh runs it
   - in a light theme the wind rose, tiller gauge and weight pad sit on a dark instrument face,
     as real dinghy instruments do, so their light drawings stay clear */

/* ---------- The Logbook: navy, cream and brass (the default; its tokens are in style.css) ---------- */
[data-theme="logbook"] { color-scheme: dark; }

/* ---------- Admiralty chart: chart paper, navy ink, chart magenta (light) ---------- */
[data-theme="chart"] {
  --panel-rgb: 251, 250, 243; --panel-a: 0.95;
  --solid: #fbfaf3; --bg: #f1efe4; --raise: #ffffff;
  --ink-rgb: 20, 36, 58; --ink: #14243a; --ink-soft: #3a4759; --ink-faint: #56606e; --line-a: 0.2;
  --accent: #a3176a; --accent-rgb: 163, 23, 106; --accent-ink: #ffffff; --accent-text: #9a1564;
  --tide: #0a5f78; --good: #1d6a37; --good-rgb: 29, 106, 55; --warn: #8a4b00; --warn-rgb: 176, 110, 0;
  --danger: #a3241a; --danger-line: #c0392b;
  --scrim-rgb: 20, 36, 58;
  --topbar: linear-gradient(to bottom, rgba(251, 250, 243, 0.97), rgba(251, 250, 243, 0.93));
  --dial: #14243a; --dial-pad: #14243a;
  --f-title: "EB Garamond", Georgia, serif;
  --f-voice: "EB Garamond", Georgia, serif;
  color-scheme: light;
}
/* place names on a chart are in italic */
[data-theme="chart"] :is(.brand-name, .menu-head h1, .sheet h2, .card-title, .drawer h2, .mk-brand b, .hg-head h2, .soc-title b, .theme-mini-title) { font-style: italic; }
[data-theme="chart"] .log-line .text { font-size: 17px; }
html[data-theme="chart"] .topbar { box-shadow: 0 1px 0 rgba(20, 36, 58, 0.25); }

/* ---------- Exe Sailing: the club's black and white (light) ---------- */
[data-theme="exe"] {
  --panel-rgb: 255, 255, 255; --panel-a: 0.95;
  --solid: #ffffff; --bg: #f2f2f2; --raise: #ffffff;
  --ink-rgb: 12, 12, 12; --ink: #0c0c0c; --ink-soft: #383838; --ink-faint: #5a5a5a; --line-a: 0.22;
  --accent: #0c0c0c; --accent-rgb: 12, 12, 12; --accent-ink: #ffffff; --accent-text: #0c0c0c;
  --tide: #0b5a6e; --good: #1b6633; --good-rgb: 27, 102, 51; --warn: #865000; --warn-rgb: 160, 100, 0;
  --danger: #a8231a; --danger-line: #c0392b;
  --scrim-rgb: 0, 0, 0;
  --topbar: linear-gradient(to bottom, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.95));
  --dial: #0c0c0c; --dial-pad: #0c0c0c;
  --f-title: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-display: "Archivo Narrow", "Arial Narrow", sans-serif;
  color-scheme: light;
}
[data-theme="exe"] :is(.brand-name, .menu-head h1, .sheet h2, .card-title, .drawer h2, .mk-brand b, .hg-head h2, .soc-title b, .theme-mini-title) { font-weight: 800; letter-spacing: -0.02em; }
html[data-theme="exe"] .topbar { box-shadow: 0 2px 0 #0c0c0c; }
/* black and white needs the selected and hover states to be bold rather than tinted */
[data-theme="exe"] .menu-card:hover, [data-theme="exe"] button.menu-card:hover { border-color: #0c0c0c; box-shadow: inset 0 0 0 1px #0c0c0c; }

/* ---------- Regatta: race-committee navy and white, signal-flag red ---------- */
[data-theme="regatta"] {
  --panel-rgb: 11, 26, 56; --panel-a: 0.88;
  --solid: #0b1a38; --bg: #08142c; --raise: #182c54;
  --ink-rgb: 255, 255, 255; --ink: #ffffff; --ink-soft: #ccd5e6; --ink-faint: #9aa7c0; --line-a: 0.2;
  --accent: #d8342b; --accent-rgb: 216, 52, 43; --accent-ink: #ffffff; --accent-text: #ff8c82;
  --tide: #8fd6ef; --good: #85dc9e; --good-rgb: 133, 220, 158; --warn: #ffd34d; --warn-rgb: 255, 211, 77;
  --danger: #ffb4aa; --danger-line: #ff6b5e;
  --scrim-rgb: 8, 20, 44;
  --topbar: linear-gradient(to bottom, rgba(8, 20, 44, 0.85), rgba(8, 20, 44, 0));
  --f-title: "Barlow Condensed", "Arial Narrow", sans-serif;
  --f-voice: "Inter", -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
[data-theme="regatta"] :is(.brand-name, .menu-head h1, .sheet h2, .card-title, .drawer h2, .mk-brand b, .hg-head h2, .soc-title b, .theme-mini-title) { font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
[data-theme="regatta"] .log-line .text { font-size: 15px; }

/* ---------- Night watch: the chart table after dark, dim red and amber ---------- */
[data-theme="night"] {
  --panel-rgb: 9, 11, 17; --panel-a: 0.9;
  --solid: #0b0e15; --bg: #07090e; --raise: #171b25;
  --ink-rgb: 236, 224, 204; --ink: #ece0cc; --ink-soft: #c0b29c; --ink-faint: #998c78; --line-a: 0.16;
  --accent: #e0703f; --accent-rgb: 224, 112, 63; --accent-ink: #120a06; --accent-text: #ef8f5f;
  --tide: #86c9bd; --good: #a3d18e; --good-rgb: 163, 209, 142; --warn: #e9b955; --warn-rgb: 233, 185, 85;
  --danger: #f3a493; --danger-line: #d9654f;
  --scrim-rgb: 4, 5, 8;
  --topbar: linear-gradient(to bottom, rgba(7, 9, 14, 0.85), rgba(7, 9, 14, 0));
  --f-title: "Fraunces", Georgia, serif;
  color-scheme: dark;
}

/* ---------- Safety boat: slate-teal, international orange, Barlow (Penguin's first look) ---------- */
[data-theme="safety"] {
  --panel-rgb: 13, 30, 36; --panel-a: 0.84;
  --solid: #12262d; --bg: #0c1c21; --raise: #1d3a42;
  --ink-rgb: 238, 243, 241; --ink: #eef3f1; --ink-soft: #b3c6c5; --ink-faint: #9cb3b2; --line-a: 0.16;
  --accent: #ef6a22; --accent-rgb: 239, 106, 34; --accent-ink: #1a0d05; --accent-text: #f99a63;
  --tide: #8fe0d2; --good: #8fd39b; --good-rgb: 143, 211, 155; --warn: #f2c230; --warn-rgb: 242, 194, 48;
  --danger: #f6b6a4; --danger-line: #e07a62;
  --scrim-rgb: 9, 22, 27;
  --topbar: linear-gradient(to bottom, rgba(10, 24, 29, 0.78), rgba(10, 24, 29, 0));
  --f-title: "Barlow Condensed", "Arial Narrow", sans-serif;
  --f-body: "Barlow", "Helvetica Neue", Arial, sans-serif;
  --f-voice: "Source Serif 4", Georgia, serif;
  color-scheme: dark;
}
[data-theme="safety"] :is(.brand-name, .menu-head h1, .sheet h2, .card-title, .drawer h2, .mk-brand b, .hg-head h2, .soc-title b, .theme-mini-title) { font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }

/* ---------- Swallow: canvas, tan sails and varnish (light) ---------- */
[data-theme="swallow"] {
  --panel-rgb: 246, 239, 224; --panel-a: 0.95;
  --solid: #f6efe0; --bg: #ede3cd; --raise: #fbf7ee;
  --ink-rgb: 42, 32, 23; --ink: #2a2017; --ink-soft: #4f4235; --ink-faint: #67594a; --line-a: 0.2;
  --accent: #8e3b1c; --accent-rgb: 142, 59, 28; --accent-ink: #fbf7ee; --accent-text: #8a391b;
  --tide: #1d5a73; --good: #2c6630; --good-rgb: 44, 102, 48; --warn: #845000; --warn-rgb: 160, 100, 0;
  --danger: #9e2419; --danger-line: #b8392b;
  --scrim-rgb: 42, 32, 23;
  --topbar: linear-gradient(to bottom, rgba(246, 239, 224, 0.97), rgba(246, 239, 224, 0.93));
  --dial: #1f2c45; --dial-pad: #1f2c45;
  --f-title: "Crimson Pro", Georgia, serif;
  --f-voice: "Crimson Pro", Georgia, serif;
  color-scheme: light;
}
[data-theme="swallow"] .log-line .text { font-size: 17.5px; }
html[data-theme="swallow"] .topbar { box-shadow: 0 1px 0 rgba(42, 32, 23, 0.22); }

/* ---------- light themes: the few things that were drawn for a dark ground ---------- */
/* a sheet floating over the water gets a firmer edge, so it never melts into a pale sky */
:is([data-theme="chart"], [data-theme="exe"], [data-theme="swallow"]) .sheet,
:is([data-theme="chart"], [data-theme="exe"], [data-theme="swallow"]) .drawer { box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(var(--ink-rgb), 0.12); }
/* the shadow under a glass panel stops pale glass blending into foam and sand */
:is([data-theme="chart"], [data-theme="exe"], [data-theme="swallow"]) .panel,
:is([data-theme="chart"], [data-theme="exe"], [data-theme="swallow"]) .log-line { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); }
:is([data-theme="chart"], [data-theme="exe"], [data-theme="swallow"]) .log-line { background: rgba(var(--panel-rgb), 0.92); }
/* the course map in the briefing is the world, so it keeps its own frame */
:is([data-theme="chart"], [data-theme="exe"], [data-theme="swallow"]) .brief-map { border-color: rgba(var(--ink-rgb), 0.3); }

/* ---------- the A button and the picker ---------- */
.chip.theme-a {
  font: 700 15px/1 var(--f-title); letter-spacing: 0; text-transform: none;
  min-width: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 1px;
}
.chip.theme-a small { font-size: 11px; }

.theme-overlay { z-index: 70; } /* above the Boat Jumble and the games */
.theme-sheet { width: min(760px, 100%); gap: 14px; }
.theme-sheet .theme-sub { margin: -8px 0 0; color: var(--ink-soft); font: 400 17px/1.4 var(--f-voice); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.theme-tile {
  border: 0; padding: 0; background: none; text-align: left; display: flex; flex-direction: column; gap: 7px;
  border-radius: 12px; color: var(--ink);
}
.theme-tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.theme-mini {
  position: relative; display: block; height: 92px; border-radius: 10px; overflow: hidden;
  background: linear-gradient(160deg, #3a7d8b, #2f6c7a 55%, #285e6b); /* the sea is the same in every theme */
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
}
.theme-tile[aria-pressed="true"] .theme-mini { box-shadow: 0 0 0 3px var(--panel-solid), 0 0 0 6px var(--accent); }
.theme-mini-bar {
  position: absolute; left: 0; right: 0; top: 0; height: 22px; padding: 0 8px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--topbar); color: var(--ink);
}
.theme-mini-title { font: 600 13px/1 var(--f-title); }
.theme-mini-chip { width: 22px; height: 11px; border-radius: 999px; background: rgba(var(--panel-rgb), 0.72); border: 1px solid var(--line); }
.theme-mini-panel {
  position: absolute; left: 8px; right: 8px; bottom: 8px; height: 46px; padding: 6px 8px;
  border-radius: 7px; background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px;
}
.theme-mini-panel em { font: 400 12px/1.2 var(--f-voice); font-style: normal; color: var(--ink); }
.theme-mini-panel em span { display: block; font: 600 9px/1 var(--f-display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-text); margin-bottom: 3px; }
.theme-mini-go { padding: 5px 9px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font: 700 10px/1 var(--f-display); letter-spacing: 0.08em; text-transform: uppercase; }
.theme-name { font: 600 16px/1.2 var(--f-display); letter-spacing: 0.03em; color: var(--ink); }
.theme-mood { display: block; font: 400 13px/1.3 var(--f-body); letter-spacing: 0; color: var(--ink-soft); margin-top: 2px; }
.theme-on { margin-left: 6px; font: 600 11px/1 var(--f-display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-text); }
.set-theme { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.set-theme b { font: 500 15px/1.2 var(--f-display); letter-spacing: 0.02em; }
