/*
 * Fase L — base reset + typography.
 *
 * Modern CSS reset plus the default typographic hierarchy. Reads
 * exclusively from `tokens.css` — no raw values. The `html` element
 * carries a transition on bg/text so the dark-mode toggle fades
 * instead of snapping.
 *
 * The `.full-bleed` utility breaks out of the prose max-width for
 * elements (tables, code blocks) that need horizontal room.
 */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  transition:
    background-color var(--transition-base),
    color var(--transition-base);
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

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

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

ul,
ol {
  list-style-position: outside;
}

/* ---------- Typography hierarchy ---------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: var(--leading-tight);
  color: var(--color-text);
  margin-block-start: var(--space-8);
  margin-block-end: var(--space-2);
}

h1 {
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  margin-block-start: 0;
}

h2 {
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.015em;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-2);
}

h3 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
}

h4 {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
}

h5 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

h6 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
}

p {
  margin-block-end: var(--space-4);
  line-height: var(--leading-relaxed);
}

ul,
ol {
  margin-block: var(--space-4);
  padding-inline-start: var(--space-6);
  line-height: var(--leading-relaxed);
}

li {
  margin-block: var(--space-1);
}

/* ---------- Inline code ---------- */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
  /* Long tokens (URLs, snake_case ids) break instead of forcing the
     content column wider than the viewport on phones. `pre code` keeps
     `white-space: pre` so code blocks still scroll, unaffected by this. */
  overflow-wrap: anywhere;
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  line-height: var(--leading-snug);
  margin-block: var(--space-4);
}

pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

/* ---------- Links ---------- */
a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-link-hover);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

/* ---------- Horizontal rule ---------- */
hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin-block: var(--space-8);
}

/* ---------- Blockquote ---------- */
blockquote {
  border-left: 4px solid var(--color-border-strong);
  padding-left: var(--space-4);
  color: var(--color-text-muted);
  margin-block: var(--space-4);
  font-style: italic;
}

/* ---------- Utility: full-bleed escape from prose width ---------- */
.full-bleed {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
}

/* ---------- Astro route announcer ---------- */
/* Astro's View-Transitions route announcer (an aria-live region that reads
 * the new page title after navigation) is normally hidden by an inline
 * style — which the strict CSP blocks, so it renders as visible page-title
 * text on every page. Re-apply the visually-hidden treatment from our own
 * CSP-allowed stylesheet; it stays available to screen readers. */
.astro-route-announcer {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
