/* Zaytun Project — site styles.
 *
 * Written for screen readers first and eyes second. Notes on the choices that matter:
 *   - Base font is 1.125rem (18px) and every size is relative, so browser zoom and
 *     user stylesheets work without anything collapsing.
 *   - Colours meet WCAG AA against their backgrounds; nothing is signalled by colour
 *     alone, and body links keep their underline.
 *   - Focus is always visible, and never removed.
 *   - Line length is capped near 70 characters, which helps low-vision and dyslexic
 *     readers as much as it helps anyone else.
 */

:root {
  --bg: #f7f5ef;
  --panel: #fffdf7;
  --ink: #1a1a16;
  --muted: #4d4b43;
  --rule: #d5cfbe;
  --accent: #4a6626;
  --accent-strong: #3c5420;
  --code-bg: #f0ede3;
  --term-bg: #1d1e19;
  --term-ink: #e4e0d2;
  --term-dim: #a6a394;
  --focus: #12408f;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14150f;
    --panel: #1c1d16;
    --ink: #eeeadd;
    --muted: #b3b0a1;
    --rule: #3a3b30;
    --accent: #a9c66d;
    --accent-strong: #c0da85;
    --code-bg: #1c1d16;
    --term-bg: #0d0e08;
    --term-ink: #e4e0d2;
    --term-dim: #9a9788;
    --focus: #8ab4ff;
  }
}

:root[data-theme="dark"] {
  --bg: #14150f;
  --panel: #1c1d16;
  --ink: #eeeadd;
  --muted: #b3b0a1;
  --rule: #3a3b30;
  --accent: #a9c66d;
  --accent-strong: #c0da85;
  --code-bg: #1c1d16;
  --term-bg: #0d0e08;
  --term-ink: #e4e0d2;
  --term-dim: #9a9788;
  --focus: #8ab4ff;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 1.125rem;
  line-height: 1.7;
  font-family: ui-serif, Georgia, "Iowan Old Style", "Palatino Linotype", serif;
}

code, pre, .mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

/* --- skip link: first thing in the tab order, visible the moment it is focused --- */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--panel);
  color: var(--ink);
  padding: .75rem 1rem;
  border: 2px solid var(--focus);
  border-radius: 0 0 var(--radius) 0;
  z-index: 100;
}
.skip:focus { left: 0; }

/* --- focus, never removed --- */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

a { color: var(--accent-strong); }
main a, footer a { text-decoration: underline; text-underline-offset: .18em; }
a:hover { color: var(--ink); }

.wrap { max-width: 48rem; margin: 0 auto; padding: 0 1.25rem; }
.wrap-wide { max-width: 62rem; margin: 0 auto; padding: 0 1.25rem; }

/* --- masthead and navigation --- */
.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--panel);
}
.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  align-items: baseline;
  padding: 1rem 1.25rem;
  max-width: 62rem;
  margin: 0 auto;
}
.sitename {
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: -.01em;
}
.masthead nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.25rem;
  margin: 0;
  padding: 0;
  font-size: 1rem;
}
.masthead nav a {
  text-decoration: none;
  color: var(--muted);
  padding: .15rem 0;
  border-bottom: 2px solid transparent;
}
.masthead nav a:hover { color: var(--ink); }
/* current page is marked with aria-current, and shown two ways: weight and a rule */
.masthead nav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 700;
  border-bottom-color: var(--accent);
}

/* --- headings --- */
h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.2;
  letter-spacing: -.02em;
  margin: 2.5rem 0 .5rem;
  font-weight: 700;
}
h2 {
  font-size: clamp(1.4rem, 3vw, 1.7rem);
  line-height: 1.3;
  margin: 2.75rem 0 .5rem;
  font-weight: 700;
}
h3 {
  font-size: 1.2rem;
  margin: 2rem 0 .35rem;
  font-weight: 700;
}
h4 { font-size: 1.05rem; margin: 1.5rem 0 .25rem; font-weight: 700; }

p, li { max-width: 70ch; }
p { margin: 0 0 1.1rem; }
.lede { font-size: 1.2rem; color: var(--ink); }
.sub { color: var(--muted); margin-top: -.2rem; }

ul, ol { padding-left: 1.4rem; }
li { margin-bottom: .5rem; }

blockquote {
  margin: 1.5rem 0;
  padding: .25rem 0 .25rem 1.25rem;
  border-left: 4px solid var(--accent);
  color: var(--ink);
  font-style: normal;
}

hr { border: 0; border-top: 1px solid var(--rule); margin: 3rem 0; }

/* --- code --- */
figure { margin: 1.5rem 0; }
figure figcaption {
  font-size: .95rem;
  color: var(--muted);
  margin-bottom: .5rem;
}
figure figcaption b { color: var(--ink); }
pre {
  margin: 0;
  padding: 1rem 1.1rem;
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: .95rem;
  line-height: 1.55;
}
pre.term { background: var(--term-bg); color: var(--term-ink); border-color: var(--term-bg); }
pre.term .prompt { color: #b7d178; }
pre.term .dim { color: var(--term-dim); }
code { font-size: .95em; }
p code, li code, td code, dd code {
  background: var(--code-bg);
  padding: .1em .35em;
  border-radius: 4px;
}

/* --- description lists, used instead of layout tables --- */
dl { margin: 1.25rem 0; }
dt { font-weight: 700; margin-top: 1.1rem; }
dt:first-child { margin-top: 0; }
dd { margin: .15rem 0 0; color: var(--muted); max-width: 70ch; }
dd a { color: var(--accent-strong); }

/* --- real tables, for real tabular data --- */
table { border-collapse: collapse; margin: 1.25rem 0; width: 100%; font-size: 1rem; }
caption { text-align: left; color: var(--muted); padding-bottom: .5rem; font-size: .95rem; }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 700; }
.table-scroll { overflow-x: auto; }

/* --- panels --- */
.panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin: 1.5rem 0;
}
.panel > :first-child { margin-top: 0; }
.panel > :last-child { margin-bottom: 0; }

/* --- game entries --- */
.game { border-top: 1px solid var(--rule); padding-top: 1.5rem; margin-top: 2.5rem; }
.game:first-of-type { border-top: 0; }
.meta { color: var(--muted); font-size: 1rem; margin: 0 0 1rem; }
.meta b { color: var(--ink); }

/* --- on-this-page contents --- */
.toc { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem 1.25rem; }
.toc h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
.toc ul { margin: 0; }
.toc li { margin-bottom: .3rem; }

footer {
  border-top: 1px solid var(--rule);
  margin-top: 4rem;
  padding: 2rem 0 3rem;
  color: var(--muted);
  font-size: 1rem;
}
footer p { margin: 0 0 .5rem; }
