/* 1848 Square — one stylesheet, no build step.
   Light: paper, ink, storefront brick, limestone.
   Dark: same materials after sundown. */

:root {
  color-scheme: light;
  --paper: #fdfcf9;
  --ink: #1c1b18;
  --ink-soft: #55524b;
  --limestone: #a39e93;
  --brick: #8c3b2e;
  --hairline: #e4e1d8;
  --wash: #f7f5ef;
  --measure: 38rem;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #191815;
  --ink: #eceae3;
  --ink-soft: #b0aca1;
  --limestone: #7d7970;
  --brick: #d08a76;
  --hairline: #33312b;
  --wash: #21201c;
}

/* System preference applies only until the reader chooses. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --paper: #191815;
    --ink: #eceae3;
    --ink-soft: #b0aca1;
    --limestone: #7d7970;
    --brick: #d08a76;
    --hairline: #33312b;
    --wash: #21201c;
  }
}

* { box-sizing: border-box; }

html { font-size: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.65;
}

a { color: var(--brick); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--ink); }
a:focus-visible { outline: 2px solid var(--brick); outline-offset: 2px; }

/* Masthead */

.masthead {
  text-align: center;
  padding: 2.5rem 1rem 1.25rem;
}

.masthead-name {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  font-weight: 500;
  line-height: 1.05;
  margin: 0;
}

.masthead-name a { color: var(--ink); text-decoration: none; }

.masthead-tagline {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 0.35rem 0 0;
}

.masthead-dateline {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--limestone);
  margin: 0.6rem 0 0;
}

/* Nav */

.site-nav {
  display: flex;
  justify-content: center;
  gap: 1.75rem;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  font-size: 0.9rem;
}

.site-nav a { color: var(--ink-soft); text-decoration: none; }
.site-nav a:hover { color: var(--brick); }

/* Content column */

.content {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

/* Homepage story list */

.story-card {
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--hairline);
}

.story-card-lead .story-headline { font-size: 1.7rem; }

.story-headline {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: 1.3rem;
  line-height: 1.25;
  margin: 0.15rem 0 0;
}

.story-headline a { color: var(--ink); text-decoration: none; }
.story-headline a:hover { color: var(--brick); }

.story-summary { color: var(--ink-soft); margin: 0.5rem 0 0; }

.story-date { font-size: 0.8rem; color: var(--limestone); margin: 0.5rem 0 0; }

.empty-note { color: var(--ink-soft); text-align: center; padding: 3rem 0; }

/* Post page */

.post-kicker {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--brick);
  margin: 0 0 0.25rem;
}

.post-headline {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: clamp(1.7rem, 5vw, 2.3rem);
  line-height: 1.15;
  margin: 0;
}

.post-standfirst {
  font-size: 1.1rem;
  color: var(--ink-soft);
  margin: 0.75rem 0 0;
}

.post-dateline {
  font-size: 0.85rem;
  color: var(--limestone);
  margin: 0.75rem 0 0;
}

.post-figure { margin: 1.75rem 0; }
.post-figure img { width: 100%; height: auto; display: block; }
.post-figure figcaption { font-size: 0.8rem; color: var(--limestone); margin-top: 0.4rem; }

.post-body { font-size: 1.05rem; }
.post-body p { margin: 1.1rem 0; }

.post-body h2 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: 1.35rem;
  margin: 2rem 0 0.5rem;
}

.post-body blockquote {
  margin: 1.5rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--brick);
  color: var(--ink-soft);
  font-style: italic;
}

/* Page title (category pages) */

.page-title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: 1.8rem;
  margin: 0 0 0.5rem;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 0.75rem;
}

/* Share row */

.post-share {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hairline);
}

.post-share-label { font-size: 0.85rem; color: var(--ink-soft); margin-right: 0.25rem; }

.post-share button,
.post-share a {
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  background: none;
  border: 1px solid var(--limestone);
  border-radius: 3px;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
  text-decoration: none;
}

.post-share button:hover,
.post-share a:hover { border-color: var(--brick); color: var(--brick); }

.post-share button:focus-visible,
.post-share a:focus-visible { outline: 2px solid var(--brick); outline-offset: 2px; }

/* Sources box */

.post-sources {
  margin-top: 2.5rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--hairline);
  background: var(--wash);
}

.post-sources h2 {
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  margin: 0 0 0.5rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.post-sources ul { margin: 0; padding-left: 1.1rem; font-size: 0.9rem; }
.post-sources li { margin: 0.25rem 0; }

/* Footer */

.site-footer {
  text-align: center;
  border-top: 1px solid var(--hairline);
  padding: 1.75rem 1rem 2.25rem;
  font-size: 0.85rem;
  color: var(--limestone);
}

.footer-mark {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 1.6rem;
  color: var(--limestone);
  margin: 0 0 0.4rem;
}

.site-footer p { margin: 0.25rem 0; }
.site-footer a { color: var(--ink-soft); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Theme toggle */

.theme-toggle {
  font-size: 1rem;
  line-height: 1;
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.theme-toggle:hover { color: var(--brick); }
.theme-toggle:focus-visible { outline: 2px solid var(--brick); outline-offset: 2px; }

/* Games */

:root { --gold: #b8860b; }
:root[data-theme="dark"] { --gold: #d4a437; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { --gold: #d4a437; }
}

.game { text-align: center; }
.game-title { font-family: "Fraunces", Georgia, serif; font-weight: 500; font-size: 1.8rem; margin: 0 0 0.25rem; }
.game-number { color: var(--limestone); font-size: 1.1rem; }
.game-help { font-size: 0.9rem; color: var(--ink-soft); max-width: 30rem; margin: 0 auto 1.25rem; }
.game-msg { min-height: 1.4rem; color: var(--brick); font-weight: 600; margin: 0.75rem 0; }
.game-stats { font-size: 0.85rem; color: var(--limestone); margin: 0.5rem 0; }
.game button, .game input {
  font: inherit; font-size: 0.9rem; color: var(--ink);
  background: none; border: 1px solid var(--limestone);
  border-radius: 3px; padding: 0.4rem 0.9rem; cursor: pointer;
}
.game input { cursor: text; text-transform: lowercase; width: 8rem; text-align: center; }
.game button:hover { border-color: var(--brick); color: var(--brick); }
.chip { padding: 0 0.35rem; border-radius: 2px; color: #fff; font-size: 0.8rem; }
.chip.correct { background: var(--brick); }
.chip.present { background: var(--gold); }

/* SQUARE board + keyboard */
.sq-board { display: inline-flex; flex-direction: column; gap: 5px; }
.sq-row { display: flex; gap: 5px; }
.sq-cell {
  width: 3.1rem; height: 3.1rem; display: flex; align-items: center;
  justify-content: center; border: 2px solid var(--hairline);
  font-weight: 700; font-size: 1.4rem; text-transform: uppercase;
}
.sq-cell.filled { border-color: var(--limestone); }
.sq-cell.correct { background: var(--brick); border-color: var(--brick); color: #fff; }
.sq-cell.present { background: var(--gold); border-color: var(--gold); color: #fff; }
.sq-cell.absent { background: var(--hairline); border-color: var(--hairline); color: var(--ink-soft); }
.sq-kbd { margin-top: 1rem; user-select: none; }
.sq-kbd-row { display: flex; justify-content: center; gap: 4px; margin-bottom: 4px; }
.sq-kbd button {
  min-width: 2rem; padding: 0.7rem 0.35rem; border: none;
  background: var(--wash); border-radius: 4px; font-weight: 600;
}
.sq-kbd button.wide { min-width: 3.4rem; font-size: 0.75rem; }
.sq-kbd button.correct { background: var(--brick); color: #fff; }
.sq-kbd button.present { background: var(--gold); color: #fff; }
.sq-kbd button.absent { background: var(--hairline); color: var(--limestone); }
@media (max-width: 420px) {
  .sq-cell { width: 2.6rem; height: 2.6rem; font-size: 1.2rem; }
}

/* Around the Square */
.ar-board {
  width: 15rem; height: 15rem; margin: 0 auto; position: relative;
  border: 2px solid var(--ink); background: var(--wash);
}
.ar-side { position: absolute; display: flex; gap: 0.75rem; justify-content: center; }
.ar-side-0 { top: -1.2rem; left: 0; right: 0; }
.ar-side-1 { bottom: -1.2rem; left: 0; right: 0; }
.ar-side-2 { left: -1.2rem; top: 0; bottom: 0; flex-direction: column; align-items: center; }
.ar-side-3 { right: -1.2rem; top: 0; bottom: 0; flex-direction: column; align-items: center; }
.ar-board button {
  width: 2.4rem; height: 2.4rem; padding: 0; border-radius: 50%;
  background: var(--paper); font-weight: 700; border: 2px solid var(--ink);
}
.ar-board button.used { background: var(--brick); border-color: var(--brick); color: #fff; }
.ar-board button:disabled { opacity: 0.3; cursor: default; }
.ar-current { font-family: "Fraunces", Georgia, serif; font-size: 1.5rem; letter-spacing: 0.1em; margin: 1.6rem 0 0.5rem; min-height: 1.8rem; }
.ar-words { color: var(--ink-soft); min-height: 1.3rem; }

/* The Ladder */
.ld-ladder { display: inline-flex; flex-direction: column-reverse; gap: 6px; }
.ld-rung {
  border: 2px solid var(--hairline); padding: 0.45rem 2.2rem;
  font-weight: 700; letter-spacing: 0.35em; font-size: 1.2rem;
}
.ld-rung.goal { border-color: var(--brick); color: var(--brick); }
.ld-rung.met { background: var(--brick); color: #fff; border-color: var(--brick); }

/* Games landing */
.game-cards { display: grid; gap: 12px; margin: 1.25rem 0 2rem; }
.game-card {
  display: block; border: 1px solid var(--hairline); padding: 1.1rem 1.25rem;
  text-decoration: none; color: var(--ink); background: var(--wash);
}
.game-card:hover { border-color: var(--brick); color: var(--ink); }
.game-card h2 { font-family: "Fraunces", Georgia, serif; font-weight: 500; margin: 0 0 0.25rem; font-size: 1.25rem; }
.game-card p { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }
.transfer { border-top: 1px solid var(--hairline); padding-top: 1.25rem; }
.transfer h2 { font-family: "Fraunces", Georgia, serif; font-weight: 500; font-size: 1.2rem; }
.transfer button {
  font: inherit; font-size: 0.9rem; color: var(--ink); background: none;
  border: 1px solid var(--limestone); border-radius: 3px;
  padding: 0.4rem 0.9rem; cursor: pointer; margin-right: 0.5rem;
}
.transfer button:hover { border-color: var(--brick); color: var(--brick); }
.transfer textarea {
  width: 100%; font-family: ui-monospace, monospace; font-size: 0.8rem;
  color: var(--ink); background: var(--wash);
  border: 1px solid var(--hairline); padding: 0.5rem;
}
