/* Speedy Tortoise Games — shared stylesheet.
   Plain CSS, no build step, system fonts only.

   Theming
   -------
   Colours are tokens on :root. The page follows the device's light/dark setting
   ("Auto") unless the visitor picks Light or Dark in the header switch.
   The switch is three radio buttons read with :has(). There is no JavaScript
   and no storage, so the choice is not remembered between pages. That is
   deliberate: the privacy policy says the site stores nothing in the browser. */

/* ---------- Tokens ---------- */

:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #efeee8;
  --text: #191c1a;
  --muted: #58605b;
  --border: #dddcd4;
  --accent: #23794f;          /* links, brand, focus */
  --accent-soft: #e4f2ea;
  --on-accent: #ffffff;
  --glow: rgb(35 121 79 / 0.10);
  --shadow: 0 1px 2px rgb(20 30 25 / 0.05), 0 4px 16px rgb(20 30 25 / 0.06);
  --header-bg: rgb(247 246 242 / 0.82);
  color-scheme: light;
}

/* Dark tokens: used when the device prefers dark and the visitor has not
   chosen Light, or when the visitor has chosen Dark. Keep both blocks the same. */
@media (prefers-color-scheme: dark) {
  :root:not(:has(#theme-light:checked)) {
    --bg: #0e1110;
    --surface: #161a18;
    --surface-2: #1d2220;
    --text: #e6ebe8;
    --muted: #a0aaa4;
    --border: #2b322f;
    --accent: #74d8a8;
    --accent-soft: #1a3429;
    --on-accent: #06140d;
    --glow: rgb(116 216 168 / 0.10);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 20px rgb(0 0 0 / 0.35);
    --header-bg: rgb(14 17 16 / 0.8);
    color-scheme: dark;
  }
}

:root:has(#theme-dark:checked) {
  --bg: #0e1110;
  --surface: #161a18;
  --surface-2: #1d2220;
  --text: #e6ebe8;
  --muted: #a0aaa4;
  --border: #2b322f;
  --accent: #74d8a8;
  --accent-soft: #1a3429;
  --on-accent: #06140d;
  --glow: rgb(116 216 168 / 0.10);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 20px rgb(0 0 0 / 0.35);
  --header-bg: rgb(14 17 16 / 0.8);
  color-scheme: dark;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 5rem; /* keeps #anchors clear of the sticky header */
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1;
}

.wrap {
  width: 100%;
  max-width: 58ch; /* ~70 characters per line */
  margin: 0 auto;
  padding: 0 1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 20;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.skip-link:focus {
  top: 0.75rem;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

h1,
h2,
h3 {
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.2;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2rem, 1.4rem + 3vw, 2.9rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.75rem;
}

h2 {
  font-size: 1.45rem;
  margin: 0 0 0.75rem;
}

h3 {
  font-size: 1.1rem;
  margin: 1.75rem 0 0.5rem;
}

p,
ul,
ol {
  margin: 0 0 1rem;
  text-wrap: pretty;
}

ul,
ol {
  padding-left: 1.25rem;
}

li {
  margin-bottom: 0.35rem;
}

li::marker {
  color: var(--muted);
}

strong {
  font-weight: 650;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  border-radius: 5px;
  background: var(--surface-2);
  overflow-wrap: anywhere;
}

address {
  font-style: normal;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--surface-2);
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.6rem 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-decoration: none;
}

.brand:visited {
  color: var(--text);
}

/* The logo: a hexagonal shell. Colour comes from --accent. */
.brand-mark {
  width: 1.75rem;
  height: 1.75rem;
  flex: none;
  color: var(--accent);
}

.brand-mark .seams {
  fill: none;
  stroke: var(--bg);
  stroke-width: 1.6;
  stroke-linejoin: round;
}

/* Theme switch: a segmented control made of three radio buttons */
.theme-switch {
  display: flex;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.theme-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.theme-switch label {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
}

.theme-switch label:hover {
  color: var(--text);
}

.theme-switch svg {
  width: 1.1rem;
  height: 1.1rem;
}

.theme-switch input:checked + label {
  background: var(--accent-soft);
  color: var(--accent);
}

.theme-switch input:focus-visible + label {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

/* Browsers without :has() cannot use the switch, so hide it there. */
@supports not selector(:has(*)) {
  .theme-switch {
    display: none;
  }
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 4rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer .wrap {
  padding-top: 1.5rem;
  padding-bottom: 2rem;
}

.site-footer p {
  margin-bottom: 0.35rem;
}

/* ---------- Home page ---------- */

.home {
  background-image: radial-gradient(40rem 28rem at 50% -6rem, var(--glow), transparent 70%);
  background-repeat: no-repeat;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-top: 4rem;
  padding-bottom: 2rem;
}

.hero .brand-mark {
  width: 4.5rem;
  height: 4.5rem;
  margin-bottom: 1.5rem;
}

.hero .brand-mark .seams {
  stroke-width: 1.2;
}

.lede {
  font-size: 1.2rem;
  color: var(--muted);
  margin-bottom: 2rem;
}

.button {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow);
}

.button:visited {
  color: var(--on-accent);
}

.button:hover {
  filter: brightness(1.08);
}

/* ---------- Policy page ---------- */

.doc {
  padding-top: 3rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

.meta li {
  margin: 0;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}

.meta li:first-child {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.4rem;
  margin: 0 0 1.5rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.card ul,
.card ol {
  margin-bottom: 0;
}

.summary {
  border-top: 3px solid var(--accent);
}

.toc ol {
  columns: 2 14rem;
  column-gap: 1.5rem;
}

.toc li {
  break-inside: avoid;
}

.toc a {
  text-decoration: none;
}

.toc a:hover {
  text-decoration: underline;
}

.doc > section:not(.card) {
  padding-top: 2.25rem;
  margin-top: 2.25rem;
  border-top: 1px solid var(--border);
}

.closing {
  margin-top: 3rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Table: scrolls sideways on small screens rather than squashing */
.table-scroll {
  overflow-x: auto;
  margin: 0 0 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 32rem;
  font-size: 0.925rem;
  line-height: 1.5;
}

caption {
  text-align: left;
  font-weight: 650;
  padding: 0.85rem 1rem 0.5rem;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.7rem 0.8rem;
  border-top: 1px solid var(--border);
}

thead th {
  background: var(--surface-2);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

tbody th {
  font-weight: 650;
}

/* Wide screens: contents move to a sticky sidebar beside the text */
@media (min-width: 68rem) {
  .doc {
    max-width: 72rem;
    display: grid;
    grid-template-columns: minmax(0, 58ch) 15rem;
    justify-content: center;
    column-gap: 4rem;
    align-items: start;
  }

  .doc > * {
    grid-column: 1;
  }

  .doc > .toc {
    grid-column: 2;
    grid-row: 1 / span 30;
    position: sticky;
    top: 5.5rem;
    margin: 0;
    padding: 0 0 0 1.25rem;
    border: 0;
    border-left: 1px solid var(--border);
    border-radius: 0;
    background: none;
    box-shadow: none;
    font-size: 0.9rem;
  }

  .toc ol {
    columns: auto;
  }
}

/* ---------- Print: black on white, no chrome, link targets shown ---------- */

@media print {
  /* :root:root:not(#print) is deliberately heavy so it beats the dark-theme
     selectors above: print is always black on white. */
  :root:root:not(#print) {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #ffffff;
    --text: #000000;
    --muted: #333333;
    --border: #999999;
    --accent: #000000;
    --accent-soft: #ffffff;
    --shadow: none;
    color-scheme: light;
  }

  body {
    display: block;
    font-size: 11pt;
  }

  .wrap,
  .doc {
    display: block;
    max-width: none;
    padding: 0;
  }

  .skip-link,
  .site-header,
  .toc {
    display: none;
  }

  .home {
    background: none;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    overflow-wrap: anywhere;
  }

  h2,
  h3 {
    break-after: avoid;
  }

  table,
  tr,
  .card {
    break-inside: avoid;
  }

  table {
    min-width: 0;
  }
}
