/* playtopoi.com. Colours follow the hero photo: the terracotta mat, charcoal
   and ivory stones. The board diagrams are SVGs drawn from the engine
   (diagrams.mjs) and inlined, so the --tp-* variables below colour them.

   Light (sand page) and dark (charcoal page) follow the system until the
   toggle in the header sets data-theme on <html>. The board stays
   terracotta in both. */
:root {
  --paper: #f3ead8;
  --paper-2: #e9dcc2;
  --ink: #2a2116;
  --ink-2: #4d3f2d;
  --muted: #7a6a52;
  --rule: #dccbab;
  --accent: #6e4718;
  --accent-ink: #fff9ee;
  --shadow: 0 1px 2px rgb(60 30 10 / 0.06), 0 12px 32px rgb(60 30 10 / 0.10);
  --serif: "EB Garamond", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --wrap: 1080px;
  --gold: #c7704c;
  --tp-board: #c7704c;
  --tp-line: rgba(55, 22, 8, 0.42);
  --tp-edge: #4a2616;
  --tp-mark: #173a58;
  --tp-light-region: rgba(255, 255, 255, 0.38);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #2a2724; --paper-2: #34302c; --ink: #f0e9df; --ink-2: #cfc6ba; --muted: #9a9086; --rule: #46403a;
  --accent: #e39c78; --accent-ink: #2a1208;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.4);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #2a2724; --paper-2: #34302c; --ink: #f0e9df; --ink-2: #cfc6ba; --muted: #9a9086; --rule: #46403a;
    --accent: #e39c78; --accent-ink: #2a1208;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.4);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
figure { margin: 0; }

.wrap { width: min(100% - 32px, var(--wrap)); margin-inline: auto; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 12px; background: var(--paper); padding: 8px 12px; z-index: 10; }

/* Header */
.site-head { border-bottom: 1px solid var(--rule); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.brand span { font: italic 600 25px/1 var(--serif); }
.site-nav { display: flex; align-items: center; gap: 2px; }
.site-nav a { color: var(--ink-2); text-decoration: none; font-size: 15px; font-weight: 500; padding: 8px 12px; border-radius: 999px; }
.site-nav a:hover { color: var(--ink); background: var(--paper-2); }
.site-nav a[aria-current="page"] { color: var(--ink); background: var(--paper-2); }
.site-nav .btn { margin-left: 8px; padding: 9px 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink) !important;
  font: 600 15px/1 var(--sans); text-decoration: none;
  padding: 13px 20px; border-radius: 999px; border: 1px solid transparent;
  transition: filter 0.15s ease;
}
.btn:hover { filter: brightness(1.12); background: var(--accent) !important; }
.btn.ghost { background: transparent; color: var(--ink) !important; border-color: var(--rule); }
.btn.ghost:hover { background: var(--paper-2) !important; filter: none; }
.btn .tag { font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.75; }

/* Type */
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.1; margin: 0 0 0.4em; text-wrap: balance; }
h1 { font-size: clamp(60px, 9vw, 104px); font-style: italic; letter-spacing: -0.01em; }
h2 { font-size: clamp(30px, 4vw, 42px); }
h3 { font-size: 25px; margin-bottom: 0.25em; }
p { margin: 0 0 1em; }
.eyebrow { font: 600 12px/1.2 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
.lede { font-size: clamp(18px, 2vw, 20px); color: var(--ink-2); max-width: 36ch; }
.muted { color: var(--muted); }
.measure { max-width: 62ch; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

/* Board diagrams (inlined SVG, so the theme reaches them) */
svg.diagram { display: block; width: 100%; height: auto; }
.board-figure img { width: 100%; }
.board-figure { max-width: 440px; width: 100%; justify-self: center; }
.board-figure figcaption { font-size: 14px; color: var(--muted); margin-top: 10px; text-align: center; text-wrap: balance; }

/* Hero: the mat photo as a full-width banner, the copy over a warm shade on
   the left (the bottom on phones) so it stays readable */
.hero { position: relative; isolation: isolate; overflow: hidden; display: flex; align-items: center; min-height: clamp(520px, 74vh, 760px); padding: clamp(56px, 8vw, 96px) 0; background: #5a2e1c; color: #fbf6ef; }
.hero-photo img { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; object-position: 62% 50%; }
.hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgb(28 14 8 / 0.82) 0%, rgb(28 14 8 / 0.62) 38%, rgb(28 14 8 / 0.08) 72%); }
.hero .wrap { display: block; }
.hero-copy { max-width: 520px; }
.hero h1 { margin-bottom: 0.12em; color: #fffaf3; }
.hero .eyebrow { color: #f2c6a4; }
.hero .lede { color: rgb(255 248 240 / 0.9); }
.hero .btn { background: #fbf6ef !important; color: #1b1915 !important; }
.hero .btn.ghost { background: transparent !important; color: #fbf6ef !important; border-color: rgb(255 248 240 / 0.45); }
.hero .btn.ghost:hover { background: rgb(255 248 240 / 0.12) !important; }
.hero-actions { display: grid; gap: 12px; margin-top: 36px; padding-top: 24px; border-top: 1px solid rgb(255 248 240 / 0.25); }
.hero-actions .actions { margin-top: 0; }
/* Shopify Buy Button, rendered without its iframe: hidden until it's ready so
   the row doesn't jump, and Shopify's wrappers kept out of the layout */
.buy-set { display: none; }
.buy-set:has(button) { display: contents; }
.buy-set .shopify-buy__product, .buy-set .shopify-buy__btn-wrapper { display: contents; }
.buy-set .btn:disabled { opacity: 0.6; cursor: default; }
.buy-set .btn { cursor: pointer; }
.facts { display: flex; gap: 28px; margin: 36px 0 0; padding: 20px 0 0; list-style: none; border-top: 1px solid rgb(255 248 240 / 0.25); color: rgb(255 248 240 / 0.75); font-size: 14px; }
.facts strong { display: block; font: 500 30px/1 var(--serif); color: #fffaf3; margin-bottom: 4px; }
.small { font-size: 14px; margin-top: 20px; }

/* Sections */
section { padding: clamp(56px, 8vw, 96px) 0; }
.band { background: var(--paper-2); }
.section-head { max-width: 620px; margin-bottom: 36px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 6vw, 72px); align-items: center; }
.split.top { align-items: start; }

.moves-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.move-card { background: var(--paper); border: 1px solid var(--rule); border-radius: 18px; padding: 20px 20px 24px; }
.move-card .diagram { border-radius: 12px; margin-bottom: 18px; }
.move-card p { color: var(--ink-2); margin: 0; }

.cta { text-align: center; }
.cta .lede { margin-inline: auto; }
.cta .actions { justify-content: center; }

/* Rulebook */
.page-head { padding: clamp(36px, 6vw, 64px) 0 clamp(20px, 3vw, 28px); }
.page-head h1 { font-size: clamp(48px, 8vw, 80px); }
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0 0; padding: 0; list-style: none; }
.toc a { display: block; font-size: 14px; font-weight: 500; color: var(--ink-2); text-decoration: none; border: 1px solid var(--rule); border-radius: 999px; padding: 7px 14px; }
.toc a:hover { color: var(--ink); background: var(--paper-2); }
.rule { padding: clamp(40px, 6vw, 64px) 0; border-top: 1px solid var(--rule); scroll-margin-top: 12px; }
.rule p, .rule li { color: var(--ink-2); }
.rule ul { padding-left: 1.2em; }
.rule li + li { margin-top: 8px; }
.moves { display: grid; margin-top: 12px; }
.move { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(24px, 5vw, 64px); align-items: center; padding: 32px 0; }
.move + .move { border-top: 1px dashed var(--rule); }
.analogy { display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); padding: 4px 10px; border-radius: 999px; margin-bottom: 12px; }
.note { font-size: 14px; color: var(--muted); border-left: 3px solid var(--gold); padding-left: 12px; margin-top: 16px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(24px, 4vw, 48px); margin-top: 40px; }
.pair .board-figure { max-width: none; }
dl.glossary { display: grid; grid-template-columns: max-content 1fr; gap: 12px 28px; margin: 28px 0 0; max-width: 760px; }
dl.glossary dt { font: italic 500 21px/1.3 var(--serif); }
dl.glossary dd { margin: 0; color: var(--ink-2); }
.stack { display: grid; gap: 24px; }
/* Four small still diagrams for counting corners: before and after, two cases */
.corner-count { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.corner-count .board-figure { max-width: none; }
.corner-count figcaption { font-size: 13px; margin-top: 6px; }
.callout { background: var(--paper-2); border-radius: 16px; padding: 24px 28px; }
.band .callout { background: var(--paper); }
.callout p:last-child { margin: 0; }
.spirit { font: italic 500 clamp(23px, 3vw, 28px)/1.3 var(--serif); color: var(--ink) !important; }

/* Contact */
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding-bottom: clamp(56px, 8vw, 96px); }
.contact-card { border: 1px solid var(--rule); border-radius: 18px; padding: 28px; }
.contact-card h2 { font-size: 26px; }
.big-mail { font: 500 clamp(22px, 3vw, 27px)/1.2 var(--serif); margin: 0; }
.socials { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0; list-style: none; }
.socials a { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; border: 1px solid var(--rule); border-radius: 999px; padding: 9px 16px 9px 12px; font-size: 15px; font-weight: 500; }
.socials a:hover { background: var(--paper-2); }
.socials svg { width: 18px; height: 18px; fill: currentColor; }

/* Light/dark toggle: shows the moon in light mode, the sun in dark */
.mode-toggle { display: grid; place-items: center; width: 36px; height: 36px; margin-left: 4px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--ink-2); cursor: pointer; }
.mode-toggle:hover { color: var(--ink); background: var(--paper-2); }
.mode-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mode-toggle .sun { display: none; }
:root[data-theme="dark"] .mode-toggle .sun { display: block; }
:root[data-theme="dark"] .mode-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mode-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .mode-toggle .moon { display: none; }
}
/* Move diagrams: the shading changes over quickly once the move lands */
svg[data-anim] .tp-before, svg[data-anim] .tp-after { transition: opacity 0.35s ease-out; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Footer */
.site-foot { border-top: 1px solid var(--rule); padding: 28px 0 36px; font-size: 14px; color: var(--muted); }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 12px 32px; align-items: center; justify-content: space-between; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.site-foot a { color: var(--ink-2); text-decoration: none; }
.site-foot a:hover { color: var(--ink); text-decoration: underline; }

@media (max-width: 860px) {
  .split, .move, .contact-grid, .pair { grid-template-columns: 1fr; }
  .hero { align-items: flex-end; min-height: 640px; }
  .hero-photo img { object-position: 70% 30%; }
  .hero::before { background: linear-gradient(0deg, rgb(28 14 8 / 0.9) 0%, rgb(28 14 8 / 0.7) 45%, rgb(28 14 8 / 0.1) 80%); }
  .moves-grid { grid-template-columns: 1fr; }
  .move-card { display: grid; grid-template-columns: 112px 1fr; gap: 16px; align-items: center; padding: 14px; }
  .move-card .diagram { margin: 0; }
  .board-figure { max-width: 400px; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .site-head .wrap { gap: 8px; }
  .site-nav a:not(.btn) { padding: 8px 6px; font-size: 14px; }
  .site-nav .btn { margin-left: 4px; padding: 8px 12px; }
  .site-nav .btn .tag { display: none; }
  .mode-toggle { width: 32px; height: 32px; margin-left: 0; }
  .brand { gap: 8px; }
  .brand span { font-size: 22px; }
  .facts { gap: 20px; }
  dl.glossary { grid-template-columns: 1fr; gap: 2px; }
  dl.glossary dd { margin-bottom: 10px; }
}
