/* Shared page chrome, loaded by base.html on every tabbed page.
   Page-specific rules stay in each template's own <style> block.
   Element-level selectors (input, h2, ...) deliberately do NOT go
   here: they would restyle pages that never opted into them. */

/* Theme tokens. Classic dark is the default (no data-theme attribute)
   and matches the site's original palette exactly. Presets are applied
   by setting data-theme="<name>" on <html>; static/theme-boot.js (the
   pre-paint script every page loads) owns that attribute plus
   data-scheme="dark|light", which scheme-dependent code keys off.
   Custom themes reuse the dark/light base and override tokens with
   inline style properties (see theme-boot.js). Pokemon type colors and
   shiny/nature accents are intentionally NOT tokens - they are the
   same in every theme. */
:root {
  /* background decoration (drawn by body::before; presets/custom
     themes override these for patterns and images) */
  --bg-image: none;
  --bg-size: auto;
  --bg-repeat: repeat;
  /* backgrounds */
  --bg: #1e1e1e;
  --surface: #222;
  --surface-2: #252525;
  --surface-3: #2a2a2a;
  --raised: #333;
  --raised-2: #3a3a3a;
  --raised-3: #444;
  --inset: #1a1a1a;
  --inset-2: #111;
  /* borders */
  --border-soft: #333;
  --border: #444;
  --border-2: #555;
  --border-3: #666;
  --border-4: #777;
  --border-hi: #888;
  /* text */
  --text: #e0e0e0;
  --text-strong: #fff;
  --text-hi: #ddd;
  --text-soft: #ccc;
  --text-sub: #bbb;
  --text-muted: #aaa;
  --text-faint: #999;
  --text-dim: #888;
  --text-dim-2: #777;
  --text-disabled: #666;
  --text-ghost: #555;
  --text-ghost-2: #444;
  /* accent (MunchStats gold) */
  --accent: #ffd54f;
  --accent-2: #ffca28;
  --accent-tint: rgba(255, 213, 79, 0.15);
  --accent-tint-2: rgba(255, 213, 79, 0.3);
  --on-accent: #1e1e1e;
  /* semantic */
  --pos: #81c784;
  --pos-2: #4caf50;
  --pos-soft: #a5d6a7;
  --neg: #e57373;
  --neg-soft: #ef9a9a;
  --warn: #ffeb3b;
  /* emphasis borders (selected/hover states brighter than --border-hi) */
  --border-focus: #bbb;
  --border-focus-2: #f0f0f0;
  --divider: rgba(255, 255, 255, 0.12);
  /* shadows / overlays */
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-2: rgba(0, 0, 0, 0.5);
  --scrim: rgba(0, 0, 0, 0.75);
  --surface-scrim: rgba(34, 34, 34, 0.8);
  /* tinted panels (info/danger/notice) */
  --info-bg: #1a2230;
  --info-border: #2a3a4a;
  --info-text: #81d4fa;
  --danger-bg: #3a2424;
  --danger-text: #ffd0d0;
  --banner-bg: #3a2a00;
  --banner-border: #665500;
  /* hover tooltips */
  --tooltip-bg: rgba(10, 10, 10, 0.92);
  --tooltip-text: #fff;
}

html[data-theme="light"] {
  --bg: #f1f1f4;
  --surface: #fff;
  --surface-2: #fafafa;
  --surface-3: #ececef;
  --raised: #e4e4e8;
  --raised-2: #dcdce0;
  --raised-3: #cfcfd4;
  --inset: #e8e8ec;
  --inset-2: #e0e0e4;
  --border-soft: #e0e0e4;
  --border: #c8c8ce;
  --border-2: #b6b6be;
  --border-3: #9a9aa2;
  --border-4: #90909a;
  --border-hi: #7a7a84;
  --text: #26262b;
  --text-strong: #000;
  --text-hi: #333;
  --text-soft: #3f3f45;
  --text-sub: #4a4a52;
  --text-muted: #5a5a62;
  --text-faint: #63636b;
  --text-dim: #6e6e76;
  --text-dim-2: #7a7a82;
  --text-disabled: #8a8a92;
  --text-ghost: #a0a0a8;
  --text-ghost-2: #b0b0b8;
  --accent: #9a6700;
  --accent-2: #7a5200;
  --accent-tint: rgba(154, 103, 0, 0.1);
  --accent-tint-2: rgba(154, 103, 0, 0.25);
  --on-accent: #fff;
  --pos: #2e7d32;
  --pos-2: #1b5e20;
  --pos-soft: #388e3c;
  --neg: #c62828;
  --neg-soft: #d32f2f;
  --warn: #b26a00;
  --border-focus: #55555e;
  --border-focus-2: #26262b;
  --divider: rgba(0, 0, 0, 0.12);
  --shadow: rgba(0, 0, 0, 0.12);
  --shadow-2: rgba(0, 0, 0, 0.22);
  --scrim: rgba(0, 0, 0, 0.5);
  --surface-scrim: rgba(255, 255, 255, 0.85);
  --info-bg: #e7f1fb;
  --info-border: #b9d5ee;
  --info-text: #1565c0;
  --danger-bg: #fdecec;
  --danger-text: #b71c1c;
  --banner-bg: #fff3d6;
  --banner-border: #e2c168;
  --tooltip-bg: rgba(255, 255, 255, 0.98);
  --tooltip-text: #1e1e1e;
}

/* ---- Preset themes ----
   Dark-scheme presets only override the chrome (backgrounds, borders,
   accents, background pattern); text tokens stay on the dark defaults.
   Light-scheme presets (sylveon) must override the FULL light set. */

/* Starry Night: deep indigo sky with a faint star field. */
html[data-theme="starry"] {
  --bg: #0b1026;
  --surface: #11172f;
  --surface-2: #131a34;
  --surface-3: #171f3c;
  --raised: #1e2749;
  --raised-2: #232d54;
  --raised-3: #2b3766;
  --inset: #080c1e;
  --inset-2: #05081a;
  --border-soft: #1e2749;
  --border: #2b3766;
  --border-2: #364279;
  --border-3: #46528e;
  --border-4: #56629e;
  --border-hi: #6b77ae;
  --accent: #ffe082;
  --accent-2: #ffd54f;
  --accent-tint: rgba(255, 224, 130, 0.14);
  --accent-tint-2: rgba(255, 224, 130, 0.28);
  --on-accent: #0b1026;
  --info-bg: #101b38;
  --info-border: #24345c;
  --surface-scrim: rgba(17, 23, 47, 0.8);
  --bg-image:
    radial-gradient(1.4px 1.4px at 22px 34px, rgba(255, 255, 255, 0.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 88px 112px, rgba(255, 255, 255, 0.4) 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 150px 60px, rgba(255, 240, 200, 0.45) 50%, transparent 51%),
    radial-gradient(0.8px 0.8px at 200px 180px, rgba(255, 255, 255, 0.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 55px 210px, rgba(200, 220, 255, 0.42) 50%, transparent 51%),
    radial-gradient(1.6px 1.6px at 240px 20px, rgba(255, 255, 255, 0.3) 50%, transparent 51%);
  --bg-size: 280px 280px;
}

/* Rayquaza: deep emerald with gold-ring accents. */
html[data-theme="rayquaza"] {
  --bg: #0c1b14;
  --surface: #10231a;
  --surface-2: #12261c;
  --surface-3: #162c21;
  --raised: #1c3729;
  --raised-2: #21402f;
  --raised-3: #2a4f3a;
  --inset: #091510;
  --inset-2: #060f0b;
  --border-soft: #1c3729;
  --border: #2a4f3a;
  --border-2: #356247;
  --border-3: #427558;
  --border-4: #4f8767;
  --border-hi: #639a79;
  --accent: #f6c945;
  --accent-2: #eab308;
  --accent-tint: rgba(246, 201, 69, 0.14);
  --accent-tint-2: rgba(246, 201, 69, 0.28);
  --on-accent: #0c1b14;
  --surface-scrim: rgba(16, 35, 26, 0.8);
  --bg-image: repeating-linear-gradient(135deg, rgba(246, 201, 69, 0.025) 0 2px, transparent 2px 26px);
}

/* Umbreon: moonlit near-black with golden rings. */
html[data-theme="umbreon"] {
  --bg: #101010;
  --surface: #161616;
  --surface-2: #191919;
  --surface-3: #1e1e1e;
  --raised: #262626;
  --raised-2: #2d2d2d;
  --raised-3: #363636;
  --inset: #0a0a0a;
  --inset-2: #060606;
  --border-soft: #262626;
  --border: #363636;
  --border-2: #454545;
  --border-3: #575757;
  --border-4: #676767;
  --border-hi: #7d7d7d;
  --accent: #ffd83d;
  --accent-2: #f5c518;
  --accent-tint: rgba(255, 216, 61, 0.14);
  --accent-tint-2: rgba(255, 216, 61, 0.28);
  --on-accent: #101010;
  --surface-scrim: rgba(22, 22, 22, 0.8);
  --bg-image: radial-gradient(circle at 70px 70px, transparent 22px, rgba(255, 216, 61, 0.05) 23px, rgba(255, 216, 61, 0.05) 27px, transparent 28px);
  --bg-size: 190px 190px;
}

/* Gengar: dusk purple with a soft haze glow. */
html[data-theme="gengar"] {
  --bg: #191227;
  --surface: #1f1731;
  --surface-2: #221a36;
  --surface-3: #271e3e;
  --raised: #2f2549;
  --raised-2: #362b54;
  --raised-3: #413363;
  --inset: #120d1f;
  --inset-2: #0c0817;
  --border-soft: #2f2549;
  --border: #413363;
  --border-2: #4d3d75;
  --border-3: #5d4b8b;
  --border-4: #6c5a9a;
  --border-hi: #8171ab;
  --accent: #c5a3ff;
  --accent-2: #b388ff;
  --accent-tint: rgba(197, 163, 255, 0.14);
  --accent-tint-2: rgba(197, 163, 255, 0.28);
  --on-accent: #191227;
  --surface-scrim: rgba(31, 23, 49, 0.8);
  --bg-image: radial-gradient(900px 500px at 50% -100px, rgba(179, 136, 255, 0.1), transparent 65%);
  --bg-repeat: no-repeat;
}

/* Munchlax: the house theme - dark teal with cream accents. */
html[data-theme="munchlax"] {
  --bg: #0f2224;
  --surface: #132a2c;
  --surface-2: #152e30;
  --surface-3: #193638;
  --raised: #204244;
  --raised-2: #254c4e;
  --raised-3: #2e5d5f;
  --inset: #0b1a1c;
  --inset-2: #071214;
  --border-soft: #204244;
  --border: #2e5d5f;
  --border-2: #396f71;
  --border-3: #468384;
  --border-4: #549394;
  --border-hi: #68a6a7;
  --accent: #f2dca2;
  --accent-2: #e8cd85;
  --accent-tint: rgba(242, 220, 162, 0.14);
  --accent-tint-2: rgba(242, 220, 162, 0.28);
  --on-accent: #0f2224;
  --surface-scrim: rgba(19, 42, 44, 0.8);
}

/* Sylveon: pastel pink light scheme (full light token set). */
html[data-theme="sylveon"] {
  --bg: #fdf2f6;
  --surface: #ffffff;
  --surface-2: #fffafc;
  --surface-3: #f8e9ef;
  --raised: #f1dce5;
  --raised-2: #ead0dc;
  --raised-3: #dfbfce;
  --inset: #f5e3ea;
  --inset-2: #efd9e2;
  --border-soft: #efd9e2;
  --border: #ddc0cc;
  --border-2: #ccaaba;
  --border-3: #b18ba0;
  --border-4: #a67f95;
  --border-hi: #8f6980;
  --text: #2b2229;
  --text-strong: #14060d;
  --text-hi: #362b33;
  --text-soft: #43363e;
  --text-sub: #4e404a;
  --text-muted: #5e4e58;
  --text-faint: #675562;
  --text-dim: #72606c;
  --text-dim-2: #7e6b78;
  --text-disabled: #8e7b88;
  --text-ghost: #a4909e;
  --text-ghost-2: #b4a0ae;
  --accent: #c2185b;
  --accent-2: #96124a;
  --accent-tint: rgba(194, 24, 91, 0.1);
  --accent-tint-2: rgba(194, 24, 91, 0.25);
  --on-accent: #fff;
  --pos: #2e7d32;
  --pos-2: #1b5e20;
  --pos-soft: #388e3c;
  --neg: #c62828;
  --neg-soft: #d32f2f;
  --warn: #b26a00;
  --border-focus: #5e4a56;
  --border-focus-2: #2b2229;
  --divider: rgba(0, 0, 0, 0.12);
  --shadow: rgba(0, 0, 0, 0.12);
  --shadow-2: rgba(0, 0, 0, 0.22);
  --scrim: rgba(0, 0, 0, 0.5);
  --surface-scrim: rgba(255, 255, 255, 0.85);
  --info-bg: #e7f1fb;
  --info-border: #b9d5ee;
  --info-text: #1565c0;
  --danger-bg: #fdecec;
  --danger-text: #b71c1c;
  --banner-bg: #fff3d6;
  --banner-border: #e2c168;
  --tooltip-bg: rgba(255, 255, 255, 0.98);
  --tooltip-text: #1e1e1e;
  --bg-image: radial-gradient(2px 2px at 12px 12px, rgba(194, 24, 91, 0.07) 50%, transparent 52%);
  --bg-size: 48px 48px;
}

body {
  background-color: var(--bg);
  display: grid;
  /* minmax(0,…): an auto-min 1fr track grows to fit the tab bar's full
     unscrolled width on mobile, pushing the page past the viewport */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  color: var(--text);
  font-family: Arial, sans-serif;
}

/* Fixed background decoration layer (patterns / custom images).
   A pseudo-element instead of body background-attachment: fixed,
   which iOS Safari mishandles. z-index -1 keeps it behind content
   but above the propagated body background color. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: var(--bg-image);
  background-size: var(--bg-size);
  background-repeat: var(--bg-repeat);
  background-position: center top;
}

/* Tab bar */
.top-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.tab-bar { text-align: left; padding-bottom: 0; }
.tab-btn {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-bottom: none;
  display: inline-block;
  padding: 6px 18px;
  cursor: pointer;
  font-size: 13px;
  margin-right: 4px;
  text-decoration: none;
  transition: color 0.2s, background 0.2s;
}
.tab-btn:hover { color: var(--text-strong); background: var(--surface-3); }
.tab-btn.tab-active { background: var(--bg); color: var(--accent); border-color: var(--border-hi); }
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 5px 6px 0;
  flex-shrink: 0;
}
/* Mobile-only nav toggle; the tab bar becomes its dropdown menu. */
.nav-burger {
  display: none;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 34px;
  height: 29px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-burger:hover { color: var(--accent); background: var(--surface-3); }
.twitter-follow-div {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.theme-toggle {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 30px;
  height: 29px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: color 0.2s, background 0.2s;
}
.theme-toggle:hover { color: var(--accent); background: var(--surface-3); }

/* Theme picker menu (markup in _tabs.html, behavior in theme-boot.js).
   Inputs/selects declare their own width/padding/margin because pages
   style bare form elements. */
.theme-menu-wrap { position: relative; flex-shrink: 0; }
.theme-menu {
  position: absolute;
  right: 0;
  top: 34px;
  z-index: 1000;
  width: 236px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 6px 24px var(--shadow-2);
  text-align: left;
}
.theme-menu-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin: 2px 0 6px;
}
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.theme-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  color: var(--text-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 7px;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.theme-chip:hover { background: var(--surface-3); color: var(--text-strong); }
.theme-chip.sel { border-color: var(--accent); color: var(--accent); }
.theme-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border-hi);
  position: relative;
  flex-shrink: 0;
}
.theme-swatch > span {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid var(--border-hi);
}
.lang-select {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  height: 29px;
  width: auto;
  padding: 2px 4px;
  margin: 0;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}
.lang-select:hover { color: var(--text-strong); }

.about-link {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  height: 29px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  font-size: 13px;
  text-decoration: none;
  flex-shrink: 0;
}
.about-link:hover { color: var(--accent); background: var(--surface-3); }

@media (max-width: 700px) {
  .twitter-follow-div { display: none; }
  /* One row: burger left, controls right; tabs unfold below as a menu. */
  .top-bar { flex-wrap: wrap; align-items: center; padding: 4px 0; }
  .nav-burger { display: inline-flex; margin-left: 5px; }
  .top-bar-right { padding: 0 5px 0 0; }
  .tab-bar { display: none; }
  .top-bar.nav-open .tab-bar {
    order: 3;
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-top: 4px;
    padding: 4px 0 6px;
    border-top: 1px solid var(--border);
  }
  .tab-btn {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 12px 14px;
    font-size: 14px;
    background: none;
    border: none;
    border-left: 3px solid transparent;
  }
  .tab-btn.tab-active { border-left-color: var(--accent); background: var(--surface); }
}
