/* ==========================================================================
   Base — reset, typography, layout primitives, utilities.
   ========================================================================== */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}

body {
  --page-bg: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

main {
  flex: 1;
  /* Content is rendered by JS after load: reserve a screen so the footer starts below
     the fold instead of jumping down when the page fills in (layout shift). */
  min-height: 100vh;
}

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

img {
  height: auto;
}

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

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

a {
  color: inherit;
  text-decoration: none;
}

/* :where() keeps specificity at 0 so component classes can still set padding */
:where(ul[role="list"], ol[role="list"]) {
  list-style: none;
  padding: 0;
}

h1,
h2,
h3,
h4 {
  line-height: var(--lh-snug);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

strong {
  font-weight: var(--fw-semibold);
  color: var(--text);
}

::selection {
  background: var(--accent);
  color: var(--accent-contrast);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

[hidden] {
  display: none !important;
}

/* ---------- Layout primitives ---------- */

/* :root raises specificity so third-party CSS (ZenUML injects Tailwind's own .container) can't resize the page */
:root .container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

:root .container--prose {
  max-width: calc(var(--container-prose) + var(--gutter) * 2);
}

.section {
  padding-block: var(--section-y);
}

.section--subtle {
  background: var(--bg-subtle);
}

.section__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: clamp(var(--space-8), 4vw, var(--space-12));
}

.section__title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.025em;
}

.section__lead {
  margin-top: var(--space-2);
  max-width: 60ch;
  color: var(--text-muted);
  font-size: var(--fs-md);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.02em;
  color: var(--text-subtle);
}

/* ---------- Utilities ---------- */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-weight: var(--fw-medium);
}

.skip-link:focus {
  top: var(--space-3);
}

.muted {
  color: var(--text-muted);
}

.mono {
  font-family: var(--font-mono);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
