/*
 * 35.md — one stylesheet, every page.
 *
 * Monospace throughout, because the site is about plain text and pretending
 * otherwise would be decoration. Hairline rules instead of boxes, no radius, no
 * shadow, one accent colour used only where something is live: the dot in the
 * wordmark, a focus ring, a link you are pointing at, a module that is the
 * cursor. Everything else is the grid.
 *
 * The typeface is served from this origin. A webfont CDN would hand every
 * visitor's address to a third party, which is the one thing this site is for
 * not doing.
 */

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Caveat';
  src: url('/fonts/Caveat.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
/* Author display rules such as .row and button would otherwise outrank the attribute. */
[hidden] { display: none !important; }

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #fafafa;
  --bg-tertiary: #f0f0f0;
  --text-primary: #101010;
  --text-secondary: #6b6b6b;
  --text-tertiary: #9b9b9b;
  --border-color: #e4e4e4;
  --border-strong: #cfcfcf;
  --accent-color: #ff4d00;

  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono',
    Menlo, Consolas, 'Liberation Mono', monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #0a0a0a;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #161616;
    --text-primary: #ededed;
    --text-secondary: #8a8a8a;
    --text-tertiary: #5e5e5e;
    --border-color: #222222;
    --border-strong: #333333;
    --accent-color: #ff5c14;
  }
}
:root[data-theme="dark"] {
  --bg-primary: #0a0a0a;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #161616;
  --text-primary: #ededed;
  --text-secondary: #8a8a8a;
  --text-tertiary: #5e5e5e;
  --border-color: #222222;
  --border-strong: #333333;
  --accent-color: #ff5c14;
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  font-weight: 400;
  background: var(--bg-secondary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-ligatures: none;
}

::selection { background: var(--accent-color); color: #fff; }

:where(a, button, input):focus-visible {
  outline: 1px solid var(--accent-color);
  outline-offset: 2px;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 3rem 1.25rem 6rem;
}
.wrap > section { margin-bottom: 3rem; }

.label {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  display: block;
  margin-bottom: 0.5rem;
}
.label .n { color: var(--accent-color); }

.homehead { display: grid; justify-items: center; margin: 1.6rem 0 2.8rem; }
/* The mark's square box is empty above and below its two rows; the negative
   margin gives that space back, so the gap to the wordmark is the grid gap. */
.homehead svg { width: 96px; height: 96px; margin: -24px 0; display: block; }
.homehead a { display: grid; color: inherit; }

.theme-btn { position: fixed; top: 0.6rem; right: 0.6rem; z-index: 20; min-width: 2.75rem; min-height: 2.75rem; padding: 0; font-size: 20px; }

/* ── Controls ───────────────────────────────────────────────────────────── */

button, .btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.55rem 1rem;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--text-primary); color: var(--bg-primary); border-color: var(--text-primary); }
button:active, .btn:active { opacity: 0.85; }
button:disabled { opacity: 0.4; cursor: not-allowed; background: transparent; color: var(--text-tertiary); border-color: var(--border-color); }

.btn.primary { border-color: var(--accent-color); color: var(--accent-color); }
.btn.primary:hover { background: var(--accent-color); color: #fff; border-color: var(--accent-color); }
button.sm { padding: 0.3rem 0.6rem; font-size: 10px; }
button.ghost { border-color: transparent; color: var(--text-secondary); }
button.ghost:hover { background: transparent; color: var(--accent-color); border-color: transparent; }

input[type="text"] {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  padding: 0.6rem 0.75rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 0;
}
input::placeholder { color: var(--text-tertiary); }
input:focus { outline: 1px solid var(--accent-color); outline-offset: -1px; border-color: var(--accent-color); }

.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 0.35rem; }
.spacer { flex: 1; }

/* ── Games ──────────────────────────────────────────────────────────────── */

.pz-head { display: flex; align-items: center; justify-content: center; gap: 0.25rem; }
.tri { background: none; border: 0; min-width: 2.75rem; min-height: 2.75rem; padding: 0; font-size: 22px; line-height: 1; color: var(--text-tertiary); cursor: pointer; }
.tri:hover { background: none; color: var(--accent-color); border: 0; }
/* A fixed width keeps the arrows still while the game name changes under them. */
.game-title { margin-bottom: 0; min-width: 14em; font-size: 14px; text-align: center; }

/* Two lines of room whatever the text, so every game's board starts at one height. */
.howto { display: flex; align-items: center; justify-content: center; min-height: 3.4em; margin: 0.2rem 0 0.9rem; font-size: 12px; letter-spacing: 0.04em; color: var(--text-secondary); text-align: center; }
.howto b { color: var(--accent-color); font-weight: 500; }

/* A fixed height: what a game prints while it is played never moves the board. */
.pz-meter { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; height: 2.5rem; margin: 0.35rem 0 0.75rem; }
.pz-chain { font-size: 15px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pz-total { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.pz-total.is-35 { color: var(--accent-color); }

.pz-row { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.6rem; }
.pz-tile { width: 56px; aspect-ratio: 1; padding: 0; font-size: 19px; }
#pz-ops button[data-op] { width: 46px; aspect-ratio: 1; padding: 0; font-size: 16px; color: var(--accent-color); }
#pz-ops button[data-op].armed { background: var(--accent-color); border-color: var(--accent-color); color: #fff; }
.pz-win { border-top: 1px solid var(--border-color); padding-top: 0.75rem; }

.match-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 0.75rem; }
.mcard {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}
.mcard.up { background: transparent; color: var(--text-primary); border-color: var(--border-strong); }
.mcard.made { background: transparent; color: var(--accent-color); border-color: var(--accent-color); }
.mcard.gift { background: var(--accent-color); color: #fff; border-color: var(--accent-color); }
.mcard.hole { background: transparent; border-style: dashed; }
.mcard.lit { background: var(--accent-color); border-color: var(--accent-color); }
.mcard:disabled { opacity: 1; cursor: default; }

.snake-grid { display: grid; gap: 2px; margin-bottom: 0.75rem; }
#mode-snake { touch-action: none; user-select: none; }
.snake-grid i { aspect-ratio: 1; background: var(--bg-tertiary); }
.snake-grid i.on { background: var(--text-primary); }
.snake-grid i.food { background: var(--accent-color); }

/* ── The postcard ───────────────────────────────────────────────────────── */

/* The postcard is paper — its colours are the same in both themes. */
.postcard {
  margin-top: 0.85rem;
  background: #ece3d4;
  color: #2b241a;
  aspect-ratio: 5 / 3;
  max-width: 420px;
  padding: 1rem 1.15rem;
  position: relative;
  transform: rotate(-1.4deg);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
}
.postcard .to { font-size: 10px; letter-spacing: 0.14em; color: #7a6f5c; text-transform: uppercase; }
.postcard .msg {
  font-family: 'Caveat', cursive;
  font-size: clamp(22px, 5.5vw, 28px);
  font-weight: 500;
  line-height: 1.25;
  margin: auto 0;
  padding-right: 4.2rem;
  overflow-wrap: anywhere;
}
.postcard .card-foot {
  display: flex; justify-content: space-between; gap: 0.5rem;
  font-size: 9.5px; letter-spacing: 0.1em; color: #7a6f5c; text-transform: uppercase;
}
.stamp { position: absolute; top: 0.8rem; right: 0.8rem; background: #fff; padding: 7px; outline: 3px dashed #ddd2bf; }
.stamp .srow { display: flex; gap: 2.5px; }
.stamp .srow + .srow { margin-top: 2.5px; }
.stamp i { display: block; width: 6px; height: 6px; background: #2b241a; }
.stamp i.hot { background: #ff4d00; }

dialog#share-dialog {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  padding: 0;
  width: min(340px, calc(100vw - 2.5rem));
}
dialog#share-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.sd-body { padding: 1.1rem; font-family: var(--font-mono); }
.sd-card {
  width: 100%;
  max-width: none;
  transform: rotate(-1.2deg);
  margin: 0.4rem 0 1.1rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
}
#sd-line { margin-bottom: 0.6rem; font-size: 13px; }
#sd-text { flex: 1; min-width: 8rem; font-size: 12px; }
.sd-foot { margin-top: 0.5rem; margin-bottom: 0; }

/* ── Small screens, and motion ──────────────────────────────────────────── */

@media (max-width: 720px) {
  .wrap { padding: 2rem 1rem 4rem; }
}


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