/* ==========================================================================
   Base: reset, typography, layout primitives, focus, utilities.
   Colors, sizes, and spacing come from tokens.css only.
   ========================================================================== */

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

* {
  margin: 0;
}

/* The hidden attribute always wins over component display rules. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 6rem; /* Keeps anchored headings clear of the sticky header. */
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: var(--leading-body);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

button {
  cursor: pointer;
}

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

ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
}

/* ---- Typography ----------------------------------------------------------- */
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: var(--leading-tight);
  color: var(--color-heading);
  text-wrap: balance;
}

h1 {
  font-size: var(--step-4);
  letter-spacing: -0.015em;
}

h2 {
  font-size: var(--step-3);
  letter-spacing: -0.01em;
}

h3 {
  font-size: var(--step-2);
  line-height: var(--leading-snug);
}

h4 {
  font-size: var(--step-1);
  line-height: var(--leading-snug);
}

p,
li {
  text-wrap: pretty;
}

.display {
  font-family: var(--font-display);
  font-size: var(--step-5);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
}

.lead {
  font-size: var(--step-1);
  line-height: var(--leading-snug);
  color: var(--text-muted);
}

/* Small caps label above a heading, like a movement marking on a score. */
.eyebrow {
  font-family: var(--font-body);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--accent);
}

.meta,
small {
  font-size: var(--step--1);
  color: var(--text-muted);
}

a {
  color: var(--color-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--dur-fast) ease, text-decoration-color var(--dur-fast) ease;
}

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

strong {
  font-weight: 650;
}

em {
  font-style: italic;
}

blockquote {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--step-2);
  line-height: var(--leading-snug);
  border-inline-start: 2px solid var(--color-border-subtle);
  padding-inline-start: var(--space-m);
}

hr {
  border: 0;
  border-top: 1px solid var(--color-border-subtle);
}

::selection {
  background: var(--panel);
  color: var(--text);
}

/* ---- Focus ---------------------------------------------------------------- */
:focus {
  outline: none;
}

:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius-s);
}

/* ---- Skip link ------------------------------------------------------------ */
.skip-link {
  position: absolute;
  inset-block-start: var(--space-xs);
  inset-inline-start: var(--space-xs);
  z-index: 1000;
  padding: var(--space-2xs) var(--space-s);
  background: var(--accent);
  color: var(--color-on-accent);
  font-weight: 600;
  border-radius: var(--radius-m);
  transform: translateY(-200%);
}

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

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

/* Centered page column with side gutters. */
.wrapper {
  width: min(100% - 2 * var(--gutter), var(--page-max));
  margin-inline: auto;
}

/* Readable line length for prose. */
.measure {
  max-width: var(--measure);
}

/* Vertical rhythm: children spaced by --stack-space. */
.stack {
  --stack-space: var(--space-s);
  display: flex;
  flex-direction: column;
}

.stack > * + * {
  margin-block-start: var(--stack-space);
}

.stack-l {
  --stack-space: var(--space-l);
}

.stack-xl {
  --stack-space: var(--space-xl);
}

/* Inline group that wraps: buttons, tags, nav items. */
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-space, var(--space-s));
}

/* Responsive grid: as many columns as fit at --grid-min wide. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--grid-min, 18rem), 100%), 1fr));
  gap: var(--grid-gap, var(--space-l));
}

/* Grid that stretches a few items across the full row instead of leaving empty columns. */
.grid--fit {
  grid-template-columns: repeat(auto-fit, minmax(min(var(--grid-min, 18rem), 100%), 1fr));
}

/* Page section spacing. */
.section {
  padding-block: var(--space-2xl);
}

.section + .section {
  position: relative;
}

/* Divider between sections: a five-line music staff with a bar line at each end.
   motion.js draws it in from the left as it scrolls into view. */
.section + .section::before {
  content: "";
  position: absolute;
  inset-block-start: -12px;
  inset-inline: 0;
  height: 25px;
  border-inline: 1px solid var(--color-border-subtle);
  background: repeating-linear-gradient(to bottom, var(--color-border-subtle) 0 1px, transparent 1px 6px);
  transform-origin: left;
  transition: transform 1.4s var(--ease-out);
}

.motion-ready .section + .section:not(.is-drawn)::before {
  transform: scaleX(0);
}

/* ---- 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;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
