/*
 * Text on parchment, under a strip of leather.
 *
 * Every pairing of ink and ground clears WCAG AA for body text (4.5:1); most clear
 * AAA. The parchment's mottling is drawn in the background only, and never darkens
 * it enough to pull the ink below that line.
 */

:root {
  --parchment: #f1e4c4;
  --parchment-shade: rgba(120, 80, 30, 0.14);
  --parchment-light: rgba(255, 255, 255, 0.35);
  --ink: #3a2a18;
  --ink-soft: #5a4128;
  --link: #6b3d12;
  --rule: #b89c6a;
  --leather: #4a3520;
  --leather-ink: #f6ead0;
  --measure: 70ch;
  color-scheme: light;
}

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

html {
  background: var(--parchment);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 15% 5%, var(--parchment-light), transparent 55%),
    radial-gradient(ellipse at 85% 95%, var(--parchment-shade), transparent 60%),
    var(--parchment);
  background-attachment: fixed;
  font: 1.125rem/1.65 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

a {
  color: var(--link);
  text-underline-offset: 0.15em;
}

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

:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
  border-radius: 2px;
}

main:focus {
  outline: none;
}

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

.skip {
  position: absolute;
  left: 1rem;
  top: -100vh;
  z-index: 1;
  padding: 0.5rem 1rem;
  background: var(--parchment);
  color: var(--ink);
}

.skip:focus {
  top: 0.5rem;
}

/* The leather strip */

.tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0 1.5rem;
  padding: 0.5rem 1rem 0;
  background: var(--leather);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.95rem;
}

.tabs a {
  color: var(--leather-ink);
  text-decoration: none;
}

.tabs .home {
  padding: 0.6rem 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
}

.tabs ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tabs ul a {
  display: block;
  padding: 0.7rem 0.85rem;
  border-radius: 6px 6px 0 0;
}

.tabs ul a:hover {
  text-decoration: underline;
}

.tabs ul a[aria-current] {
  background: var(--parchment);
  color: var(--ink);
}

.tabs :focus-visible {
  outline-offset: -3px;
}

@media (max-width: 40rem) {
  .tabs .home {
    width: 100%;
    padding-bottom: 0.25rem;
  }

  .tabs ul a {
    padding: 0.55rem 0.6rem;
  }
}

/* The page */

main {
  max-width: calc(var(--measure) + 2rem);
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

main:has(.with-aside) {
  max-width: calc(var(--measure) + 24rem);
}

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

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  font-weight: normal;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 2.25rem;
  letter-spacing: 0.01em;
}

h2 {
  font-size: 1.5rem;
  margin: 2rem 0 0.5rem;
}

h3 {
  font-size: 1.2rem;
  margin: 1.5rem 0 0.5rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  font-variant: small-caps;
  letter-spacing: 0.06em;
}

.meta {
  margin: 0 0 1.5rem;
  color: var(--ink-soft);
  font-style: italic;
}

.empty {
  color: var(--ink-soft);
  font-style: italic;
}

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

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

table {
  border-collapse: collapse;
  margin: 1rem 0;
  width: 100%;
}

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

img {
  max-width: 100%;
  height: auto;
}

/* Previous and next */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--measure);
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.pager a:last-child {
  text-align: right;
}

.pager .label {
  display: block;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* Lists of entries, and the trail back up */

.entries {
  padding-left: 1.25rem;
}

.entries li + li {
  margin-top: 0.5rem;
}

.entries .meta {
  margin: 0;
  font-size: 0.95rem;
}

.trail ol {
  display: flex;
  flex-wrap: wrap;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
  font-size: 0.95rem;
}

.trail li + li::before {
  content: "›";
  padding: 0 0.5rem;
  color: var(--ink-soft);
}

.glossary section > section {
  margin-left: 1rem;
}

/* Collapsible blocks: the date selector and the eras of history */

details {
  margin: 0.25rem 0;
}

summary {
  cursor: pointer;
  padding: 0.25rem 0;
}

details details {
  margin-left: 1rem;
}

details ol {
  margin: 0.25rem 0 0.75rem;
  padding-left: 1.25rem;
}

.era {
  border-bottom: 1px solid var(--rule);
}

.era > summary {
  font-size: 1.5rem;
  padding: 0.75rem 0;
}

.when,
.count {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* The stories index, with its date selector to the right */

.with-aside {
  display: grid;
  gap: 2rem 3rem;
}

@media (min-width: 60rem) {
  .with-aside {
    grid-template-columns: minmax(0, 1fr) 18rem;
  }

  .with-aside aside {
    padding-left: 1.5rem;
    border-left: 1px solid var(--rule);
  }
}

aside h2 {
  margin-top: 0.5rem;
  font-size: 1.25rem;
}

@media (forced-colors: active) {
  .tabs ul a[aria-current] {
    border: 2px solid CanvasText;
  }
}
