/* Shared look for the site's own pages (dashboard, settings, admin, files,
   server health, …), not the games or projects. Link it before the page's own
   <style>, so a page rule with the same selector still wins.
   The theme comes from header.js, which sets data-theme on <html> (dark by default)
   and loads the display font (Bricolage Grotesque).
   Palette: "Atlas" — passport navy, coral and map sand. Change colors here, not in
   pages: a page that needs a color should use one of these tokens. */

:root {
  /* Base */
  --bg: #0F1520;
  --surface: #18202D;
  --surface2: #212B3A;
  --border: #2A3546;
  --text: #ECE6DB;
  --muted: #A3A9B3;
  /* Status and links */
  --green: #5CBF83;
  --red: #F07A8C;
  --amber: #E3A84E;
  --blue: #8FB8E8;
  --up: #5CBF83;   --up-bg: #15301F;
  --down: #F07A8C; --down-bg: #3A1820;
  /* Brand */
  --accent: #3A5F92;        /* primary buttons, selected states (white text on it) */
  --accent-hover: #46699C;
  --focus: #8FB8E8;
  --primary: #1D3557;       /* header */
  --stripe: #E76F51;        /* coral: stripes and edges only, never text */
  --stripe-ink: #14110F;    /* text on a coral fill */
  --hero: #22406A;          /* the dashboard's big card (white text on it) */
  --hero-muted: #C3CDDC;
  --tint: #33291A;          /* highlights: tonight's game, counts that need attention */
  --tint-ink: #E9C88E;
  --icon-bg: #24344D;
  --icon-fg: #F5D9B8;
  --selected: #24344D;       /* selected list item, current day (--text or --blue on it) */
  /* Shape and type */
  --radius-lg: 16px;        /* cards */
  --radius: 12px;           /* tiles, modals */
  --radius-sm: 8px;         /* buttons, inputs, pills */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #F5EFE4;
  --surface: #FFFCF6;
  --surface2: #EFE6D6;
  --border: #E5DAC6;
  --text: #1D2733;
  --muted: #5F6670;
  --green: #1F6B3D;
  --red: #A3283C;
  --amber: #8A5A00;
  --blue: #22578F;
  --up: #1F6B3D;   --up-bg: #E3F2E8;
  --down: #A3283C; --down-bg: #F8E3E7;
  --accent: #1D3557;
  --accent-hover: #142740;
  --focus: #22578F;
  --primary: #1D3557;
  --stripe: #E76F51;
  --hero: #1D3557;
  --hero-muted: #C3CDDC;
  --tint: #F3E3C3;
  --tint-ink: #6B4A12;
  --icon-bg: #1D3557;
  --icon-fg: #F5EFE4;
  --selected: #E1E7F0;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* Author display rules (e.g. a flex row) would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
/* Zero specificity: any link rule a page writes wins over this default. */
:where(a) { color: var(--blue); }

/* Page widths: default for data pages, .narrow for forms, .wide for the dashboard. */
.page-content { max-width: 960px; margin: 0 auto; padding: 32px 16px 64px; }
.page-content.narrow { max-width: 680px; }
.page-content.wide { max-width: 1200px; }

/* Page title: a bare h1, or .page-head when the title row also holds actions. */
h1 { font-family: var(--font-display); font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.page-content > h1, .page-head { margin-bottom: 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Card. .section is the original name; .card is the same thing without the bottom margin. */
.section, .card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 24px;
}
.section { margin-bottom: 20px; }
.section > h2, .card-title {
  font-family: var(--font-display); font-size: 1.2rem; font-weight: 700;
  letter-spacing: -0.01em; color: var(--text); margin-bottom: 14px;
}
/* Small uppercase label, for a sub-heading inside a card. */
.section-label {
  font-size: 0.72rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 10px;
}

/* Zero specificity (:where), so any rule a page writes for its own inputs wins. */
:where(input[type=text], input[type=email], input[type=password], input[type=search],
       input[type=number], input[type=url], input[type=date], select, textarea) {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 11px; color: var(--text); font-size: 0.9rem; font-family: inherit;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
:where(input, select, textarea):focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
:where(input[type=checkbox], input[type=radio]) { accent-color: var(--accent); }
:where(button, a, summary):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 6px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none;
  font-size: 0.86rem; font-weight: 600; font-family: inherit; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--red); }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 0.8rem; }

/* Pills: small status labels. */
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px;
  border-radius: 999px; font-size: 0.8rem; font-weight: 700; white-space: nowrap;
  background: var(--surface2); color: var(--muted);
}
.pill-up   { background: var(--up-bg);   color: var(--up); }
.pill-down { background: var(--down-bg); color: var(--down); }
.pill-tint { background: var(--tint);    color: var(--tint-ink); }

/* Segmented control: a row of buttons where one is selected (aria-pressed="true"). */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface2); }
.seg > button {
  min-width: 44px; min-height: 34px; padding: 0 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); font: inherit; font-size: 0.84rem; font-weight: 600; cursor: pointer;
}
.seg > button:hover { color: var(--text); }
.seg > button[aria-pressed="true"], .seg > button.active { background: var(--accent); color: #fff; }

/* Square icon holder, e.g. in a tile or a list row. */
.icon-box {
  flex: none; width: 44px; height: 44px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: var(--icon-bg); color: var(--icon-fg);
}
.icon-box svg { width: 22px; height: 22px; }

/* Tile: a big link to another page. */
.tile {
  display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-bottom: 3px solid var(--stripe);
  border-radius: var(--radius); color: var(--text); text-decoration: none;
  font-family: var(--font-display); font-size: 1.1rem; font-weight: 700;
  transition: border-color 0.15s, transform 0.15s;
}
.tile:hover { border-color: var(--muted); border-bottom-color: var(--stripe); }

/* Hero: the navy card with a coral edge (dashboard greeting + weather). */
.hero {
  background: var(--hero); color: #fff; border-radius: var(--radius-lg);
  box-shadow: inset 6px 0 0 var(--stripe); padding: 26px 28px 24px 32px;
}
.hero :where(a) { color: #fff; }
.hero .muted { color: var(--hero-muted); }

.muted { color: var(--muted); }
.note { font-size: 0.8rem; color: var(--muted); }
.msg { font-size: 0.84rem; min-height: 18px; margin-top: 10px; }
.msg.ok, .msg.success { color: var(--green); }
.msg.err, .msg.error { color: var(--red); }

/* Side menu: a page's sections listed on the left, one shown at a time on the
   right (Settings, Admin). Phones get the menu first, then the chosen section
   under a back link. /side-nav.js builds the menu from the panes' data-side. */
.side-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.side-nav { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 2px; }
.side-nav-group {
  font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.1em; padding: 16px 12px 6px;
}
.side-nav-group:first-child { padding-top: 0; }
.side-nav a {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 7px 12px;
  border-radius: var(--radius); color: var(--text); text-decoration: none; font-size: 0.92rem; font-weight: 500;
}
.side-nav a:hover { background: var(--surface2); }
.side-nav a[aria-current="true"] { background: var(--selected); font-weight: 700; box-shadow: inset 3px 0 0 var(--stripe); }
.side-nav .side-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-nav .side-s { margin-left: auto; font-size: 0.72rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.side-av {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--icon-bg); color: var(--icon-fg); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.02em;
}
.side-main [data-side]:not(.side-on) { display: none; }
.side-back { display: none; }
@media (max-width: 759px) {
  .side-layout { display: block; }
  .side-nav {
    position: static; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 6px;
  }
  .side-nav-group { padding: 14px 10px 4px; }
  .side-nav-group:first-child { padding-top: 8px; }
  .side-nav a { min-height: 50px; font-size: 1rem; }
  .side-nav a[aria-current="true"] { background: none; font-weight: 500; box-shadow: none; }
  .side-nav a::after { content: '›'; color: var(--muted); font-size: 1.3rem; line-height: 1; margin-left: 8px; }
  .side-nav a:not(:has(.side-s))::after { margin-left: auto; }
  .side-layout.side-detail .side-nav, .side-layout:not(.side-detail) .side-main { display: none; }
  .page-content:has(> .side-layout.side-detail) > h1 { display: none; }
  .side-back {
    display: inline-flex; align-items: center; gap: 4px; margin: -8px 0 14px; padding: 6px 0;
    color: var(--blue); font-weight: 600; text-decoration: none;
  }
}
