/* Tidbit Trivia website: reset, element defaults, layout primitives.
   Nothing here is a component. Components live in site.css. */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* offset for the sticky header when jumping to an anchor */
  scroll-padding-top: 5rem;
}

body {
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

input, button, textarea, select { font: inherit; color: inherit; }

p, li { text-wrap: pretty; }

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); letter-spacing: normal; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--s-6) 0;
}

code, kbd, pre { font-family: var(--font-mono); font-size: 0.92em; }

kbd {
  display: inline-block;
  padding: 0.1em 0.42em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 0.85em;
  line-height: 1.5;
}

/* ---------- focus ---------- */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}
:focus:not(:focus-visible) { outline: none; }

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

/* ---------- layout primitives ---------- */

/* Centred content column with responsive gutters. */
.wrap {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--page-pad);
}
.wrap--narrow { max-width: 46rem; }
.wrap--wide   { max-width: 80rem; }

/* Standard vertical rhythm between page sections. */
.section { padding-block: var(--section-y); }

/* Constrain prose to a readable measure. */
.measure { max-width: var(--measure); }

/* Vertical stack with a consistent gap. */
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack--tight { gap: var(--s-2); }
.stack--loose { gap: var(--s-6); }

.row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
}

/* ---------- utility ---------- */

.visually-hidden:not(:focus):not(:active) {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.muted { color: var(--muted); }
.center { text-align: center; }

/* Skip link, visible only on keyboard focus. */
.skip-link {
  position: absolute;
  top: var(--s-2);
  left: var(--s-2);
  z-index: 100;
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform var(--t-dur-ui) var(--ease);
}
.skip-link:focus { transform: translateY(0); }

/* ---------- motion preference ----------
   Honoured globally. Any animation added later inherits this. */

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