/* Design tokens */
:root {
  color-scheme: light;
  --bg: #fff;
  --surface: #f4f3ef;
  --surface-strong: #e7e6e1;
  --text: #11120f;
  --muted: #5f625b;
  --border: #c9cbc4;
  --green: #4f5e49;
  --green-text: #fff;
  --coral: #e94f42;
  --coral-hover: #c83d33;
  --link: #825800;
  --footer: #f4e6b8;
  --header: rgb(255 255 255 / 94%);
  --content: 75rem;
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 5rem;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151713;
  --surface: #20231e;
  --surface-strong: #2a2e27;
  --text: #f2f3ee;
  --muted: #b6baaf;
  --border: #494e44;
  --green: #718268;
  --green-text: #fff;
  --coral: #f06457;
  --coral-hover: #ff7a6e;
  --link: #e7bc64;
  --footer: #2b2b20;
  --header: rgb(21 23 19 / 94%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 7rem; }
body { margin: 0; background: var(--bg); color: var(--text); font: 1rem/1.45 Arial, Helvetica, sans-serif; }
img { max-width: 100%; }
a { color: inherit; text-underline-offset: .2em; }
a:hover { text-decoration-thickness: .12em; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: .2rem solid var(--coral); outline-offset: .2rem; }

.skip-link { position: fixed; inset: .5rem auto auto .5rem; z-index: 20; translate: 0 -150%; padding: .75rem 1rem; background: var(--text); color: var(--bg); }
.skip-link:focus { translate: 0; }

header { position: sticky; inset-block-start: 0; z-index: 10; border-block-end: 1px solid var(--border); background: var(--header); backdrop-filter: blur(.75rem); -webkit-backdrop-filter: blur(.75rem); }
.header-inner { width: min(100%, var(--content)); min-height: 4rem; margin-inline: auto; padding: .625rem 1rem; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .625rem 1rem; }
.logo { width: max-content; text-decoration: none; line-height: .8; }
.logo b, .logo span { display: block; }
.logo span { margin-block-start: .35rem; font-size: .7rem; }
nav { grid-column: 1 / -1; display: flex; gap: 1.25rem; overflow-x: auto; scrollbar-width: none; font-size: .8125rem; white-space: nowrap; }
nav::-webkit-scrollbar { display: none; }
nav a { padding-block: .25rem; text-decoration: none; }
nav a:hover { text-decoration: underline; }
.header-actions { display: flex; align-items: center; gap: .5rem; }
.theme-toggle { width: 2.5rem; height: 2.5rem; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text); cursor: pointer; font: 1.25rem/1 Arial, sans-serif; }
.theme-toggle:hover { background: var(--surface-strong); }
.button { display: inline-flex; min-height: 2.5rem; align-items: center; justify-content: center; padding: .625rem 1rem; border: 0; text-decoration: none; font-size: .8125rem; font-weight: 700; }
.community-button { background: var(--green); color: var(--green-text); }
.coral { background: var(--coral); color: #fff; }
.coral:hover { background: var(--coral-hover); text-decoration: none; }

main { width: min(100%, var(--content)); margin-inline: auto; padding: 2rem 1rem 5rem; }
section { scroll-margin-top: 7rem; }
h1, h2, h3 { text-wrap: balance; }
h1 { max-width: 48rem; margin: 1.5rem 0 2rem; font-size: clamp(1.65rem, 5.5vw, 2.25rem); line-height: 1.05; }
h2 { margin: 0 0 2rem; font-size: clamp(2.5rem, 9vw, 3.5rem); line-height: .95; }
h3 { margin: 3rem 0 1rem; font-size: clamp(1.25rem, 3vw, 1.55rem); line-height: 1.12; }
p { max-width: 43rem; }

.hero { display: grid; gap: 2rem; }
.hero-grid { display: grid; gap: 1.5rem; align-items: start; }
.hero-grid p { margin: 0; font-size: .9rem; }
.photo-placeholder { min-height: 16rem; display: grid; place-items: center; border: 1px solid var(--border); background: var(--surface); color: var(--muted); }
.photo-placeholder.small { display: none; min-height: 11rem; }
.photo-placeholder span { font-size: .8125rem; }

.with-aside { margin-block-start: var(--space-8); }
.with-aside > aside, .mobile-link { margin-block-end: 2rem; color: var(--link); font-size: 1.125rem; line-height: 1.1; }
.with-aside > aside a, .mobile-link a { text-decoration: none; }
.with-aside > aside a:hover, .mobile-link a:hover { text-decoration: underline; }
.with-aside > div { min-width: 0; }
.wide-photo { display: block; width: 100%; max-height: 26rem; margin-block-start: 2rem; object-fit: cover; object-position: center; }

.etiquette { margin: 0; }
.etiquette > div { display: grid; gap: .4rem; padding-block: 1rem; border-block-end: 1px solid var(--border); }
.etiquette dt { font-size: 1.125rem; font-weight: 700; }
.etiquette dd { margin: 0; color: var(--muted); font-size: .8125rem; }
.etiquette dd:last-child { color: var(--text); }
.steps { display: grid; gap: .75rem; }
.steps p { min-height: 0; margin: 0; padding: 1rem; background: var(--green); color: var(--green-text); }

.diagram { display: block; height: auto; padding: .5rem; border: 1px solid var(--border); background: #fff; }
.setup { width: min(100%, 40.625rem); margin-block-start: 1.75rem; }
.pieces { width: 100%; }
.board { width: min(100%, 40rem); aspect-ratio: 1; margin-block-start: 1.75rem; object-fit: contain; }
.first-move { display: grid; gap: 1.5rem; margin-block: 3rem; }
.first-move img { width: min(100%, 26.1875rem); height: auto; align-self: center; padding: .5rem; background: #fff; }
.first-move h3 { margin-block-start: 0; }
.columns { display: grid; gap: 1rem; }
.capture-grid { display: grid; gap: 1.25rem; }
.capture-grid figure { margin: 0; min-width: 0; }
.capture-grid img { display: block; width: 100%; height: auto; aspect-ratio: 468 / 216; object-fit: contain; background: #fff; }
.capture-grid figcaption { margin-block-start: .75rem; font-size: .8125rem; }
.mobile-link { margin-block: 3rem; }
.callout { font-size: clamp(1.45rem, 4vw, 1.9rem); }
.illegal { display: grid; gap: .5rem; }
.illegal p { min-height: 0; margin: 0; padding: 1rem; background: var(--coral); color: #fff; }

.useful { margin-block-start: var(--space-8); }
.useful h2 { font-size: clamp(2rem, 7vw, 2.5rem); }
.useful ul { padding-inline-start: 1.25rem; }
.useful li { margin-block: .75rem; }
.useful a { font-weight: 700; }
footer { min-height: 5rem; padding: 1.25rem max(1rem, calc((100% - var(--content)) / 2 + 1rem)); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: center; background: var(--footer); font-size: .75rem; }

@media (min-width: 37.5rem) {
  .header-inner { padding-inline: 1.5rem; }
  main { padding-inline: 1.5rem; }
  .etiquette > div { grid-template-columns: 1fr 1fr; gap: .75rem 1.25rem; }
  .etiquette dd:last-child { grid-column: 1 / -1; }
  .columns, .capture-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem; }
  .illegal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 48rem) {
  html { scroll-padding-top: 5rem; }
  .header-inner { min-height: 4rem; grid-template-columns: 1fr auto 1fr; }
  nav { grid-column: auto; justify-content: center; overflow: visible; }
  .header-actions { justify-self: end; }
  .hero { grid-template-columns: minmax(15rem, 30%) minmax(0, 1fr); gap: clamp(2rem, 6vw, 5rem); }
  .hero-grid { grid-template-columns: minmax(0, 1fr) auto; }
  .hero-grid p { grid-column: 1; }
  .hero-grid .button { grid-column: 2; grid-row: 1; }
  .photo-placeholder { min-height: 28rem; }
  .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .steps p { min-height: 10rem; }
  .first-move { grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr); gap: 2.5rem; }
  .illegal { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 60rem) {
  .with-aside { display: grid; grid-template-columns: 13.75rem minmax(0, 48.75rem); gap: clamp(3rem, 7vw, 6rem); }
  .with-aside > aside { padding-block-start: 8rem; }
  .with-aside > div { max-width: 48.75rem; }
  .useful { margin-inline-start: min(19.75rem, 26vw); }
  .etiquette > div { grid-template-columns: 1fr 1fr 2fr; }
  .etiquette dd:last-child { grid-column: auto; }
}

@media (min-width: 75rem) {
  .header-inner, main { padding-inline: 0; }
  .hero-grid { grid-template-columns: 16.25rem minmax(0, 1fr) auto; gap: 2rem; }
  .hero-grid .photo-placeholder { display: grid; grid-column: 1; grid-row: 1; }
  .hero-grid p { grid-column: 2; }
  .hero-grid .button { grid-column: 3; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media print {
  :root, html[data-theme="dark"] { color-scheme: light; --bg: #fff; --text: #000; --muted: #333; --border: #999; }
  header { position: static; }
  nav, .header-actions, .photo-placeholder, .skip-link { display: none; }
  main { width: 100%; padding: 1rem; }
  .with-aside { display: block; }
  .with-aside > aside { padding: 0; }
  section { break-inside: avoid; }
}
