/* ============================================================
   site.css: layout, type and color for the JBW Chess Club site
   ============================================================ */

:root {
  /* Whatever the reader's device already uses: San Francisco on Mac and
     iPhone, Segoe UI on Windows, Roboto on Android. Nothing to download,
     and the site looks native wherever it is opened. */
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-body: var(--font-ui);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;
  --font-chess: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols 2",
    "DejaVu Sans", "Arial Unicode MS", sans-serif;

  /* Built from the school colors: navy #002060 and gold #FEDA24.
     The navy is dark enough to be text, so it carries headings, links
     and buttons. The gold can never be text on a light background, so
     it only ever appears as a fill with dark navy sitting on top of it. */
  --paper: #f8f9fc;
  --card: #ffffff;
  --ink: #14203c;
  --muted: #566179;
  --line: #dde3ef;
  --accent: #002060;
  --accent-dark: #00174a;
  --accent-soft: #e8edf8;
  --on-accent: #ffffff;
  --gold: #feda24;
  --gold-ink: #7a5c00;
  --on-gold: #14203c;
  --good: #1a7a4e;
  --on-good: #ffffff;
  --bad: #b83a2b;
  --hover: #eef2f9;
  --focus: #1668dc;
  --focus-board: #05122e;
  --sq-light: #dfe7f5;
  --sq-dark: #7a95c4;
  --sq-light-mark: #f6e389;
  --sq-dark-mark: #d9c153;
  --sq-light-pick: #f2d64f;
  --sq-dark-pick: #ceb232;
  --board-frame: #1f3566;
  --shadow: 0 1px 2px rgba(20, 32, 60, 0.06), 0 8px 22px -14px rgba(20, 32, 60, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark mode is the school navy itself, with the gold carrying the
       warmth. Board squares stay light, because a chessboard has to. */
    --paper: #0e1728;
    --card: #16223c;
    --ink: #e9eef8;
    --muted: #9aa7bf;
    --line: #2a3854;
    --accent: #8fb2ea;
    --accent-dark: #a9c5f2;
    --accent-soft: #1b2a49;
    --on-accent: #0e1728;
    --gold: #feda24;
    --gold-ink: #feda24;
    --on-gold: #0e1728;
    --good: #4ecf95;
    --on-good: #0e1728;
    --bad: #ff8271;
    --hover: #1c2b47;
    --focus: #5f9bf5;
    --focus-board: #05122e;
    --sq-light: #c2d0e7;
    --sq-dark: #5f79a9;
    --sq-light-mark: #ddc978;
    --sq-dark-mark: #bda548;
    --sq-light-pick: #d8bd45;
    --sq-dark-pick: #b2982c;
    --board-frame: #22304f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 26px -16px rgba(0, 0, 0, 0.85);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5.5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: clamp(1.03rem, 0.98rem + 0.3vw, 1.15rem);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4, .brand, .btn, .card h3 {
  font-family: var(--font-ui);
}

h1 { font-size: clamp(1.85rem, 1.4rem + 2.1vw, 2.75rem); line-height: 1.14; letter-spacing: -0.021em; margin: 0 0 0.4rem; }
h2 { font-size: clamp(1.35rem, 1.12rem + 1.05vw, 1.8rem); line-height: 1.2; letter-spacing: -0.014em; margin: 2.6rem 0 0.6rem; color: var(--accent); }
h3 { font-size: clamp(1.12rem, 1.04rem + 0.42vw, 1.3rem); letter-spacing: -0.008em; margin: 1.8rem 0 0.4rem; }
p { margin: 0.7rem 0; }
a { color: var(--accent-dark); }
@media (prefers-color-scheme: dark) { a { color: var(--accent); } }
a:focus-visible, .card:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }

code, kbd, .san {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--hover);
  padding: 0.05em 0.25em;
  border-radius: 4px;
}

.skip {
  position: absolute;
  left: -999px;
}
.skip:focus {
  left: 0.75rem;
  top: 0.75rem;
  z-index: 50;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.6rem 1rem;
  border-radius: 8px;
}

/* --- header + nav ------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 68rem;
  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: inherit;
  margin-right: auto;
}
.brand-mark {
  font-size: 1.9rem;
  line-height: 1;
  color: var(--on-gold);
  background: var(--gold);
  border-radius: 10px;
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
}
.brand strong { display: block; font-size: 1.1rem; line-height: 1.2; letter-spacing: -0.012em; }
.brand small { display: block; font-size: 0.76rem; color: var(--muted); }

/* The header carries one job besides the club mark: getting back to the
   lesson list. The home page is the menu, so there is nothing to fold
   away on a phone. */
.header-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex: none;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  min-height: 2.5rem;
  transition: background 120ms ease, border-color 120ms ease;
}
.header-link:hover { background: var(--hover); border-color: var(--accent); }
.header-link .link-short { display: none; }

/* On a narrow phone the school name and the full label together push the
   header onto a second row, so both shorten rather than wrap. */
@media (max-width: 34rem) {
  .brand small { display: none; }
  .brand strong { font-size: 1.05rem; }
  .header-link { padding: 0.5rem 0.8rem; font-size: 0.9rem; }
  .header-link .link-long { display: none; }
  .header-link .link-short { display: inline; }
}

/* At 320px the two still want six more pixels than there are. */
@media (max-width: 22rem) {
  .header-inner { padding-left: 0.7rem; padding-right: 0.7rem; gap: 0.5rem; }
  .brand { gap: 0.45rem; }
  .brand-mark { width: 2.1rem; height: 2.1rem; font-size: 1.6rem; }
  .brand strong { font-size: 1rem; }
  .header-link { padding: 0.45rem 0.7rem; font-size: 0.86rem; }
}
.header-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* --- page frame -------------------------------------------- */

main {
  max-width: 52rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}
main.wide { max-width: 68rem; }

.lede {
  font-size: 1.14em;
  color: var(--muted);
  margin-bottom: 1.4rem;
}

.crumb {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 0.3rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--font-ui);
}

/* --- home page cards --------------------------------------- */

.hero {
  background: linear-gradient(140deg, var(--accent-soft), transparent 70%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.6rem 1.4rem;
  margin-bottom: 2rem;
}
.hero p:last-child { margin-bottom: 0; }

/* The one thing the home page is asking you to do. */
.cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-ui);
  font-size: 1.02rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: background 120ms ease, transform 80ms ease;
}
.cta:hover { background: var(--accent-dark); transform: translateY(-1px); }
.cta:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.card-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  padding: 0;
  margin: 1.2rem 0;
  list-style: none;
}
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.card:hover { transform: translateY(-2px); }
.card h3 { margin: 0.15rem 0 0.3rem; font-size: 1.15rem; }
.card-num {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 0.4rem;
}
.card h3 a { text-decoration: none; color: inherit; }
.card h3 a::after { content: ""; position: absolute; inset: 0; }
.card p { margin: 0; font-size: 0.95rem; color: var(--muted); }
.card .icon { font-size: 1.7rem; line-height: 1; color: var(--accent); }

/* --- callouts ---------------------------------------------- */

.note {
  margin: 1.3rem 0;
  padding: 0.9rem 1.1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  background: var(--card);
}
.note.rule { border-left-color: var(--gold); }
.note.warn { border-left-color: var(--bad); }
.note.fact { border-left-color: var(--good); }
.note > :first-child { margin-top: 0; }
.note > :last-child { margin-bottom: 0; }
.note strong:first-child { color: var(--accent); }
.note.rule strong:first-child { color: var(--gold-ink); }
.note.warn strong:first-child { color: var(--bad); }
.note.fact strong:first-child { color: var(--good); }

/* --- misc content ------------------------------------------ */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0;
  font-size: 0.97rem;
}
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); }
th { font-family: var(--font-ui); color: var(--accent); }

.value-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 0.7rem;
  padding: 0;
  margin: 1.2rem 0;
  list-style: none;
  text-align: center;
}
.value-list li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.4rem;
}
.value-list .glyph {
  display: block;
  font-size: 2.1rem;
  line-height: 1.1;
  font-family: var(--font-chess);
}
.value-list .name { display: block; font-weight: 700; font-size: 0.95rem; }
.value-list .pts { display: block; color: var(--muted); font-size: 0.88rem; }

ul.checklist { list-style: none; padding-left: 0; }
ul.checklist li { padding-left: 1.8rem; position: relative; margin: 0.45rem 0; }
ul.checklist li::before {
  content: "♟︎";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-family: var(--font-chess);
}

.lesson-nav {
  display: grid;
  gap: 0.75rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
@media (min-width: 44rem) {
  .lesson-nav { grid-template-columns: 1fr auto 1fr; align-items: stretch; }
}
.lesson-nav.home { grid-template-columns: 1fr; }
/* On its own, the card reads left to right like everything else. */
.lesson-nav.home .lesson-step.next { text-align: left; align-items: flex-start; }

.lesson-step {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 120ms ease, border-color 120ms ease;
}
.lesson-step:hover { transform: translateY(-2px); border-color: var(--accent); }
.lesson-step:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.lesson-step .dir {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.lesson-step .step-num {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
}
.lesson-step .step-title {
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.008em;
}
.lesson-step .step-sub {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.35;
}

/* Going forward is the common move, so it leads. */
.lesson-step.next { border-color: var(--accent); }
.lesson-step.next .dir { color: var(--accent); }
@media (min-width: 44rem) {
  .lesson-step.next { text-align: right; align-items: flex-end; }
}

/* The middle escape hatch stays small: it is the fallback, not the path. */
.lesson-step.all {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  box-shadow: none;
  background: transparent;
}
.lesson-step.all .step-title { font-size: 0.95rem; }
@media (min-width: 44rem) {
  .lesson-step.all { flex-direction: column; justify-content: center; padding: 0.9rem; }
}

.lesson-step.empty { display: none; }
@media (min-width: 44rem) {
  .lesson-step.empty { display: block; border: 0; background: none; box-shadow: none; }
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1.5rem 1rem 2.5rem;
}

/* --- print: a lesson should survive being handed out on paper */

@media print {
  .site-header, .lesson-nav, .board-controls, .site-footer { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .board-widget { break-inside: avoid; border-color: #999; }
  .board { max-width: 3.2in; }
  main { max-width: none; }
  a { color: #000; text-decoration: underline; }
}
