:root {
  --ink: #111;
  --paper: #fff;
  --sq-light: #ebebeb;
  --sq-dark: #b4b4b4;
  --serif: Charter, "Iowan Old Style", Georgia, Cambria, "Times New Roman", serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --measure: 65ch;
}

/* Dark scheme. Switch by adding or removing "dark" on the <html> tag in index.html. */
.dark {
  --ink: #e6e6e6;
  --paper: #111;
  --sq-light: #5c5c5c;
  --sq-dark: #333;
}
.dark .piece.w { --pf: #f2f2f2; --ps: #f2f2f2; --pd: #111; }
.dark .piece.b { --pf: #111; --ps: #e6e6e6; --pd: #e6e6e6; }

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.6;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}
a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
p { margin: 0 0 1.2em; }
p:last-child { margin-bottom: 0; }

/* ---------- layout ---------- */

.page {
  display: grid;
  grid-template-columns: minmax(0, var(--measure)) minmax(16rem, 30rem);
  column-gap: 6rem;
  justify-content: center;
  padding: 0 3rem;
}
.text-col { grid-column: 1; grid-row: 1; max-width: var(--measure); }
.board-col { grid-column: 2; grid-row: 1; }

/* The board rides vertically centred in the viewport while the text scrolls. */
.board-sticky {
  position: sticky;
  top: 50vh;
  transform: translateY(-50%);
}
.board { width: min(100%, 80vh); margin: 0 auto; }
.board svg { display: block; width: 100%; height: auto; }

/* Without JS the board cannot render; the page reads as a plain essay. */
.no-js .board-col, .no-js .spacer, .no-js .theme { display: none; }

/* Theme switch: a word in the corner. T toggles it too. */
.theme {
  position: fixed;
  right: 1.25rem;
  bottom: 1rem;
  z-index: 2;
  padding: 0.25rem 0;
  border: 0;
  background: none;
  color: inherit;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  opacity: 0.55;
  cursor: pointer;
}
.theme:hover, .theme:focus-visible { opacity: 1; }

/* ---------- board ---------- */

.sq-light { fill: var(--sq-light); }
.sq-dark { fill: var(--sq-dark); }

/* Pieces: fill / outline / detail colours, inherited into <use> shadow trees. */
.piece { transition: transform 350ms ease-out, opacity 350ms ease-out; }
.piece.w { --pf: #fff; --ps: #111; --pd: #111; }
.piece.b { --pf: #111; --ps: #111; --pd: #fff; }

@media (prefers-reduced-motion: reduce) {
  .piece { transition: none; }
}

/* ---------- landing ---------- */

.landing {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
}
.cue {
  position: absolute;
  bottom: 2.5rem;
  left: 0;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.9rem;
}
.no-js .cue { display: none; }
.question {
  font-size: 1.375rem;
  line-height: 1.45;
  max-width: 34ch;
}

/* ---------- opening ---------- */

.opening { padding: 10vh 0 20vh; }
.player {
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  margin: 0 0 1.5rem;
}
.opening-line { margin: 0; }
.spacer { height: 3rem; }

/* ---------- annotated moves ---------- */

/* Each move fills a viewport, its text centred on the board's centre line. */
.move {
  box-sizing: border-box;
  min-height: 100vh;
  padding: 12vh 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.move header {
  display: flex;
  font-family: var(--mono);
  font-size: 0.9375rem;
  line-height: 1;
  letter-spacing: 0.02em;
  margin-bottom: 1.25rem;
}
.move .num { margin-right: 1ch; }
.move .sym { min-width: 2ch; }
.move h2 {
  font-size: 1.5rem;
  font-weight: normal;
  line-height: 1.3;
  margin: 0 0 1.25rem;
}

/* A one-line note on the opponent's reply, set in the gap between moves. */
.reply {
  font-size: 1rem;
  margin: 0;
}

/* ---------- closing and footer ---------- */

.closing { padding: 30vh 0 20vh; }
.closing p { max-width: 34ch; }

.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  font-size: 1rem;
  padding: 4rem 0 3rem;
}

/* ---------- narrow screens: board as a sticky strip on top ---------- */

@media (max-width: 52rem) {
  body { font-size: 1.0625rem; }
  .page { display: block; padding: 0 1.25rem; }
  .text-col { max-width: none; }
  .board-col {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--paper);
    padding: 0.75rem 0;
  }
  .board-sticky { position: static; transform: none; }
  .board { width: min(100%, 36vh); }

  .landing { min-height: calc(100vh - 36vh - 1.5rem); }
  .question { font-size: 1.25rem; }
  .opening { padding: 5vh 0 15vh; }
  .move { min-height: 0; padding: 22vh 0; }
  .move h2 { font-size: 1.3rem; }
  .closing { padding: 22vh 0 10vh; }
  .footer { padding: 3rem 0 2rem; }
}
