/* ============================================================
   wuld.ink — base styles
   Reset + element defaults. Loads after tokens.css.
   ============================================================ */

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

* {
  margin: 0;
  padding: 0;
}

html {
  /* Bump root from browser default (16px) to 18px — Garamond has a small
     x-height and needs the extra optical size for sustained reading.
     All rem-based tokens scale up proportionally. */
  font-size: 112.5%;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  background-color: var(--c-bg);
  color: var(--c-fg);
  font-family: var(--font-body);
  font-size: var(--t-base);
  line-height: var(--lh-default);
  /* Serif body benefits from old-style figures + discretionary ligatures
     where available. EB Garamond supports both. */
  font-feature-settings: "liga", "kern", "onum";
  min-height: 100vh;
  transition:
    background-color var(--t-base-d) var(--ease),
    color var(--t-base-d) var(--ease);
}

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

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

button {
  background: none;
  border: none;
  cursor: pointer;
}

/* ---------- Selection ---------- */
::selection {
  background-color: var(--c-selection-bg);
  color: var(--c-selection-fg);
}

/* ---------- Focus ---------- */
:focus-visible {
  outline: none;
  box-shadow: var(--c-focus-ring);
}

/* ---------- Typography defaults ----------
   Headings tier the type system:
     h1, h2  → --font-headline (IM Fell English) — major titles
     h3, h4, h5 → --font-body (EB Garamond) — section/sub-section
     h6 → --font-mono (IBM Plex Mono) — eyebrow / structural label
*/
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  color: var(--c-fg);
  /* Lining figures + small caps where supported, for headline polish */
  font-feature-settings: "lnum", "smcp", "kern";
}

h1, h2 {
  font-family: var(--font-headline);
  font-weight: 400;       /* IM Fell English is its own weight; no need to bold */
  font-style: normal;
}

h3, h4, h5 {
  font-family: var(--font-body);
  font-weight: 600;
}

h1 { font-size: var(--t-h1); margin-block-end: var(--s-6); }
h2 { font-size: var(--t-h2); margin-block-end: var(--s-5); margin-block-start: var(--s-7); }
h3 { font-size: var(--t-h3); margin-block-end: var(--s-4); margin-block-start: var(--s-6); }
h4 { font-size: var(--t-h4); margin-block-end: var(--s-4); margin-block-start: var(--s-5); line-height: var(--lh-snug); }
h5 { font-size: var(--t-h5); margin-block-end: var(--s-3); margin-block-start: var(--s-4); line-height: var(--lh-snug); }
h6 {
  font-family: var(--font-mono);
  font-size: var(--t-sm);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--c-fg-muted);
  margin-block-end: var(--s-2);
  margin-block-start: var(--s-4);
}

/* Display utility — Cormorant Garamond for homepage hero / title-page */
.display {
  font-family: var(--font-display);
  font-size: var(--t-display);
  font-weight: 500;
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
}

p {
  margin-block-end: var(--s-4);
  max-width: var(--w-prose);
}

p + p {
  margin-block-start: 0;
}

a {
  color: var(--c-accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-thickness: var(--bw-thin);
  transition: color var(--t-fast) var(--ease),
              text-decoration-thickness var(--t-fast) var(--ease);
}

a:hover {
  color: var(--c-accent-hover);
  text-decoration-thickness: var(--bw-base);
}

a:visited {
  color: var(--c-accent-dim);
}

strong, b {
  font-weight: 700;
  color: var(--c-fg);
}

em, i {
  font-style: italic;
}

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

code {
  background-color: var(--c-bg-elevated);
  padding: 0.1em 0.35em;
  border: var(--bw-thin) solid var(--c-border);
}

pre {
  background-color: var(--c-bg-elevated);
  border: var(--bw-base) solid var(--c-border);
  padding: var(--s-4);
  overflow-x: auto;
  margin-block: var(--s-5);
}

pre code {
  background: none;
  border: none;
  padding: 0;
}

blockquote {
  border-left: var(--bw-slab) solid var(--c-accent);
  padding-left: var(--s-4);
  margin-block: var(--s-5);
  font-style: italic;
  color: var(--c-fg-muted);
  max-width: var(--w-prose);
}

hr {
  border: none;
  border-top: var(--bw-base) solid var(--c-border);
  margin-block: var(--s-7);
}

ul, ol {
  padding-left: var(--s-5);
  margin-block-end: var(--s-4);
  max-width: var(--w-prose);
}

li {
  margin-block-end: var(--s-2);
}

li::marker {
  color: var(--c-accent);
}

/* ---------- Layout helpers ---------- */
.container {
  width: 100%;
  max-width: var(--w-max);
  margin-inline: auto;
  padding-inline: var(--s-5);
}

.prose {
  max-width: var(--w-prose);
  margin-inline: auto;
}

/* ---------- Eyebrow / label ---------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--c-fg-muted);
  margin-block-end: var(--s-2);
}

/* ---------- Endnote ref (placeholder; full impl TBD per open Q) ---------- */
.endnote-ref {
  font-family: var(--font-mono);
  font-size: 0.7em;
  vertical-align: super;
  color: var(--c-accent);
  text-decoration: none;
  padding-inline: 0.15em;
}

.endnote-ref:hover {
  background-color: var(--c-accent);
  color: var(--c-bg);
}

/* ---------- Skip link (accessibility) ---------- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--c-accent);
  color: var(--c-bg);
  padding: var(--s-3) var(--s-4);
  font-family: var(--font-mono);
  z-index: 1000;
}

.skip-link:focus-visible {
  top: 0;
}

/* ---------- Reader-mode body adjustments ----------
   In reader mode, bump body line-height + size slightly for endurance. */
[data-mode="reader"] {
  font-size: var(--t-lead);
  line-height: var(--lh-loose);
}

[data-mode="reader"] p {
  margin-block-end: var(--s-5);
}
