/*
  Relic Realms: the website's one stylesheet.
  Hand-written. No external fonts or scripts: the fonts are the reader's own system fonts, and the only images are
  the brand's own, served from brand/.
  Colours are tokens on :root, with a dark set under prefers-color-scheme. Every text colour pair meets
  WCAG AA (4.5:1) in both sets, and the focus ring meets 3:1.
*/

:root {
  color-scheme: light dark;

  --bg: #f6f1e8;
  --surface: #fffcf6;
  --surface-alt: #efe6d8;
  --text: #1e1915;
  --muted: #574c43;
  --border: #d5c8b6;
  --rule: #a8977f;
  --accent: #8f1d2c;
  --accent-soft: #f4e2df;
  --link: #8f1d2c;
  --link-hover: #5c0f1a;
  --focus: #1a5cab;
  --code-bg: #ece3d4;
  --draft-bg: #fbeec2;
  --draft-border: #a87e00;
  --draft-text: #3a2a00;
  --shadow: 0 1px 2px rgb(60 40 20 / 0.08), 0 4px 16px rgb(60 40 20 / 0.06);

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans",
    "Liberation Sans", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", P052,
    Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;

  --measure: 44rem;
  --wide: 70rem;
  --radius: 0.6rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13100d;
    --surface: #1c1814;
    --surface-alt: #27211b;
    --text: #efe7dc;
    --muted: #bcae9e;
    --border: #463c32;
    --rule: #6d5f50;
    --accent: #ee8d97;
    --accent-soft: #3a1b1f;
    --link: #f4a6ae;
    --link-hover: #ffd3d7;
    --focus: #8cc3ff;
    --code-bg: #2c251e;
    --draft-bg: #372c0c;
    --draft-border: #a8841d;
    --draft-text: #fae5a0;
    --shadow: none;
  }
}

/* Base */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

[id] {
  scroll-margin-top: 1rem;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.1rem, 1.6rem + 2.4vw, 3rem);
  margin: 0.4rem 0 0.9rem;
}

h2 {
  font-size: clamp(1.45rem, 1.3rem + 0.8vw, 1.8rem);
  margin: 2.4rem 0 0.75rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}

h3 {
  font-size: 1.2rem;
  margin: 1.7rem 0 0.45rem;
}

p,
ul,
ol,
dl,
table,
blockquote,
pre {
  margin: 0 0 1rem;
}

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

li + li {
  margin-top: 0.3rem;
}

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

a:hover {
  color: var(--link-hover);
  text-decoration-thickness: 2px;
}

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

code {
  padding: 0.08em 0.35em;
  background: var(--code-bg);
  border-radius: 0.3em;
}

pre {
  padding: 0.75rem 1rem;
  background: var(--code-bg);
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

pre code {
  padding: 0;
  background: none;
  font-size: 1em;
}

h2 code,
h3 code {
  font-size: 0.8em;
}

blockquote {
  padding-left: 1rem;
  border-left: 3px solid var(--rule);
  margin-left: 0;
  margin-right: 0;
}

strong {
  font-weight: 700;
}

/* Skip link and focus */

.skip-link {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--accent);
  border-radius: 0.4rem;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

main:focus {
  outline: none;
}

/* Layout */

.wrap {
  width: min(100% - 2rem, var(--wide));
  margin-inline: auto;
}

.prose {
  max-width: var(--measure);
}

main {
  display: block;
  padding-block: 1.75rem 3.5rem;
}

/* Header */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 0.85rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding-block: 0.2rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.wordmark .emblem {
  flex: none;
  width: 2rem;
  height: 2rem;
}

.hero-emblem {
  display: block;
  width: 8rem;
  max-width: 100%;
  height: auto;
  margin-bottom: 0.75rem;
}

.wordmark:hover {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav li + li {
  margin-top: 0;
}

.site-nav a {
  display: block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  color: var(--text);
  font-size: 0.97rem;
  font-weight: 500;
  text-decoration: none;
}

.site-nav a:hover {
  background: var(--surface-alt);
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.site-nav a[aria-current="page"] {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* Text blocks */

.lede {
  max-width: var(--measure);
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1.55;
}

.draft {
  margin: 0 0 1.25rem;
  padding: 0.8rem 1rem;
  background: var(--draft-bg);
  color: var(--draft-text);
  border: 1px solid var(--draft-border);
  border-left-width: 6px;
  border-radius: var(--radius);
}

.callout {
  margin: 1.5rem 0;
  padding: 1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 6px solid var(--accent);
  border-radius: var(--radius);
}

.callout > :last-child {
  margin-bottom: 0;
}

.callout-strong {
  background: var(--accent-soft);
}

.callout-title {
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.effective {
  color: var(--muted);
  font-style: italic;
}

.address {
  display: inline-block;
  padding: 0.25em 0.55em;
  font-size: 1.05rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Contents box */

.toc {
  margin: 1.25rem 0 0.5rem;
  padding: 0.9rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.toc-title {
  margin: 0 0 0.4rem;
  font-weight: 700;
}

.toc ul {
  margin: 0;
  padding-left: 1.2rem;
  columns: 2 14rem;
  column-gap: 2rem;
}

.toc li {
  margin: 0 0 0.25rem;
  break-inside: avoid;
}

.toc li + li {
  margin-top: 0;
}

/* Lists with a job */

.rules > li {
  padding-left: 0.25rem;
}

.rules > li + li {
  margin-top: 0.6rem;
}

.rules > li::marker,
.steps > li::marker {
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
}

.kinds {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.25rem;
}

.kinds dt {
  font-weight: 600;
}

.kinds dd {
  margin: 0;
}

/* Tables */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.97rem;
}

caption {
  padding-bottom: 0.5rem;
  font-weight: 700;
  text-align: left;
}

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

thead th {
  background: var(--surface-alt);
}

tbody th {
  font-weight: 600;
}

td code,
th code {
  overflow-wrap: anywhere;
}

/* The home page */

.intro {
  display: grid;
  gap: 1.5rem;
  align-items: start;
  padding: 1.25rem 0 0.5rem;
}

.hero h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(2.6rem, 1.8rem + 4vw, 4.2rem);
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1.05rem + 0.9vw, 1.6rem);
  line-height: 1.3;
}

.join {
  padding: 1.25rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.join h2 {
  margin: 0 0 0.6rem;
  padding: 0;
  border: 0;
  font-size: 1.4rem;
}

.join ul {
  margin-bottom: 0;
}

.ornament {
  position: relative;
  height: 1rem;
  margin: 2.25rem 0 0.5rem;
  border: 0;
  background:
    linear-gradient(var(--rule), var(--rule)) left center / calc(50% - 1rem) 1px no-repeat,
    linear-gradient(var(--rule), var(--rule)) right center / calc(50% - 1rem) 1px no-repeat;
}

.ornament::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.5rem;
  height: 0.5rem;
  background: var(--accent);
  transform: translate(-50%, -50%) rotate(45deg);
}

.ornament + section > h2:first-child {
  margin-top: 1rem;
  padding-top: 0;
  border-top: 0;
}

.section-prose {
  max-width: var(--measure);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: 1rem;
  margin: 1.5rem 0 1rem;
  padding: 0;
  list-style: none;
}

.cards > li {
  margin: 0;
}

.card {
  padding: 1.1rem 1.25rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 0.4rem;
}

.card p {
  margin: 0;
}

/* Footer */

.site-footer {
  padding-block: 1.6rem 2.2rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.95rem;
}

.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.site-footer li + li {
  margin-top: 0;
}

.site-footer a {
  display: inline-block;
  padding-block: 0.15rem;
}

.site-footer a[aria-current="page"] {
  font-weight: 700;
}

.disclaimer {
  max-width: var(--measure);
  margin: 0;
}

/* Wider screens */

@media (min-width: 60rem) {
  .intro {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    align-items: center;
    gap: 3rem;
  }
}

/* Phones */

@media (max-width: 40rem) {
  body {
    font-size: 1rem;
  }

  .lede {
    font-size: 1.1rem;
  }

  /* Tables marked .stack become one card per row. Their ARIA roles keep them tables for screen readers. */
  .stack,
  .stack caption,
  .stack tbody,
  .stack tr,
  .stack th,
  .stack td {
    display: block;
  }

  .stack {
    background: none;
  }

  .stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .stack tr {
    margin-bottom: 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .stack th,
  .stack td {
    padding: 0.35rem 0.9rem;
    border: 0;
  }

  .stack tbody th {
    padding-top: 0.75rem;
  }

  .stack tr > :last-child {
    padding-bottom: 0.8rem;
  }

  .stack td[data-label]::before {
    content: attr(data-label);
    content: attr(data-label) / "";
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
}

@media (max-width: 30rem) {
  .kinds {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .kinds dd {
    margin-bottom: 0.55rem;
  }
}

/* Windows high contrast and other forced colours */

@media (forced-colors: active) {
  .ornament::after {
    forced-color-adjust: none;
    background: CanvasText;
  }

  .site-nav a[aria-current="page"] {
    outline: 2px solid CanvasText;
  }
}

/* Print */

@media print {
  .skip-link,
  .site-nav,
  .site-footer nav {
    display: none;
  }

  body,
  .site-header,
  .site-footer,
  .card,
  .callout,
  .toc,
  .join,
  table {
    background: #fff;
    color: #000;
    box-shadow: none;
  }

  a {
    color: #000;
  }
}
