/* Site-wide styles. Original "field notebook" look: paper tones, ink text, ruled accents.
   School colors arrive as --school-* variables set by school.js. */

:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-2: #efece3;
  --text: #1d2026;
  --muted: #4f5662;
  --border: #d3cdbf;
  --rule: #e4dfd2;
  --focus: #1a5fb4;
  --ok: #1f6f3f;
  --ok-bg: #e3f2e8;
  --bad: #9b1c1c;
  --bad-bg: #fbe7e7;
  --warn-bg: #fff4d6;
  --warn: #7a4b00;

  /* Neutral default theme; school.js overrides these. */
  --school-primary: #2d5873;
  --school-secondary: #b07a1a;
  --on-primary: #ffffff;
  --on-secondary: #000000;
  --accent-text-light: #2d5873;
  --accent-text-dark: #9cc7e2;
  --accent-text: var(--accent-text-light);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 14px rgb(0 0 0 / 6%);
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
  --font-head: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --maxw: 72rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14171c;
    --surface: #1c2027;
    --surface-2: #252a32;
    --text: #ebe8e1;
    --muted: #aab0b9;
    --border: #3a414c;
    --rule: #2b3139;
    --focus: #8ab4f8;
    --ok: #8fd8a8;
    --ok-bg: #173323;
    --bad: #f3a5a5;
    --bad-bg: #3a1a1a;
    --warn-bg: #3a2e10;
    --warn: #f2cf7a;
    --accent-text: var(--accent-text-dark);
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171c;
  --surface: #1c2027;
  --surface-2: #252a32;
  --text: #ebe8e1;
  --muted: #aab0b9;
  --border: #3a414c;
  --rule: #2b3139;
  --focus: #8ab4f8;
  --ok: #8fd8a8;
  --ok-bg: #173323;
  --bad: #f3a5a5;
  --bad-bg: #3a1a1a;
  --warn-bg: #3a2e10;
  --warn: #f2cf7a;
  --accent-text: var(--accent-text-dark);
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.6 var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 1.25rem 1rem 3rem; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; margin: 1.6em 0 0.5em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin-top: 0.4em; }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); }
h3 { font-size: 1.15rem; }
p, ul, ol { margin: 0 0 1em; }
a { color: var(--accent-text); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
code, kbd, .mono { font-family: var(--font-mono); font-size: 0.92em; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

.skip-link {
  position: absolute; left: 0.5rem; top: -3rem; z-index: 100;
  background: var(--surface); color: var(--text); padding: 0.5rem 1rem; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 0.5rem; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

/* Header / footer */
.site-header {
  background: var(--surface);
  border-top: 6px solid var(--school-primary);
  border-bottom: 1px solid var(--border);
  box-shadow: inset 0 3px 0 var(--school-secondary);
}
.site-header__inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0.6rem 1rem;
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--text); font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; min-height: 44px; }
.brand__mark { width: 36px; height: 36px; border-radius: 8px; object-fit: contain; background: var(--surface-2); }
.site-nav { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-left: auto; align-items: center; }
.site-nav a { padding: 0.55rem 0.75rem; border-radius: var(--radius-sm); text-decoration: none; color: var(--text); min-height: 44px; display: inline-flex; align-items: center; }
.site-nav a:hover, .site-nav a[aria-current="page"] { background: var(--surface-2); }
.school-strip {
  max-width: var(--maxw); margin: 0 auto; padding: 0.35rem 1rem; font-size: 0.9rem;
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; color: var(--muted);
}
.school-strip strong { color: var(--text); }
.site-footer { border-top: 1px solid var(--border); background: var(--surface); }
.site-footer__inner { max-width: var(--maxw); margin: 0 auto; padding: 1rem; font-size: 0.9rem; color: var(--muted); display: flex; gap: 1rem; flex-wrap: wrap; justify-content: space-between; }

/* Buttons and form controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 44px; min-width: 44px; padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm); border: 2px solid var(--school-primary);
  background: var(--school-primary); color: var(--on-primary);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); filter: none; }
.btn--small { min-height: 36px; padding: 0.3rem 0.7rem; font-size: 0.9rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.icon-btn { background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); min-width: 44px; min-height: 44px; cursor: pointer; font: inherit; }
.icon-btn:hover { background: var(--surface-2); }

label { font-weight: 600; display: block; margin-bottom: 0.3rem; }
input[type="text"], input[type="number"], input[type="search"], select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem; min-height: 44px; width: 100%; max-width: 32rem;
}
input:focus, select:focus, textarea:focus { border-color: var(--focus); }
.field { margin-bottom: 1rem; }
.hint-text { font-size: 0.9rem; color: var(--muted); margin-top: 0.25rem; }

/* Cards and layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); }
.stack > * + * { margin-top: 1rem; }
.notice { border-left: 5px solid var(--school-secondary); background: var(--surface-2); padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin: 1rem 0; }
.notice--warn { background: var(--warn-bg); color: var(--warn); border-left-color: var(--warn); }
.notice--bad { background: var(--bad-bg); color: var(--bad); border-left-color: var(--bad); }
.notice--ok { background: var(--ok-bg); color: var(--ok); border-left-color: var(--ok); }
.tag { display: inline-block; font-size: 0.8rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }

.unit { margin-top: 2rem; }
.unit__head { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; border-bottom: 2px solid var(--rule); padding-bottom: 0.3rem; margin-bottom: 1rem; }
.unit__head h3 { margin: 0; }
.unit__num { font-family: var(--font-mono); color: var(--muted); font-size: 0.9rem; }

.game-card { display: flex; flex-direction: column; gap: 0.5rem; }
.game-card h4 { font-family: var(--font-head); font-size: 1.15rem; margin: 0; }
.game-card p { margin: 0; }
.game-card__meta { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.game-card__actions { margin-top: auto; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; padding-top: 0.5rem; }
.empty-unit { color: var(--muted); font-style: italic; }

.hero { padding: 1rem 0 0.5rem; display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.hero__mascot { width: 96px; height: 96px; object-fit: contain; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.hero h1 { margin: 0 0 0.25rem; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { border: 1px solid var(--border); padding: 0.45rem 0.6rem; text-align: left; vertical-align: top; }
th { background: var(--surface-2); }

dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; }
dl.meta dt { font-weight: 600; }
dl.meta dd { margin: 0; }

.swatch { display: inline-block; width: 1.1em; height: 1.1em; border-radius: 3px; border: 1px solid var(--border); vertical-align: -0.15em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
.scheme-btn { padding: 0 0.7rem; font-size: 0.9rem; font-weight: 600; }
