/*! ===========================================================================
 *  Alpéia — base styles (element level)
 *  Reset, document defaults, headings, prose, layout primitives.
 *  Consumes tokens only (tokens.css): no literal colour, no literal size.
 * =========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd, ol, ul, pre {
  margin: 0;
}

ol[class],
ul[class] {
  padding: 0;
  list-style: none;
}

/* --- Document ------------------------------------------------------------ */
body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-body);
  line-height: var(--leading-body);
  min-height: 100vh;
  /* Charter R-T6: left aligned, never justified, no automatic hyphenation. */
  text-align: left;
  hyphens: none;
  -webkit-font-smoothing: antialiased;
}

/* --- Headings ------------------------------------------------------------
   One h1 per page, no skipped level (charter §8.1). h4 and below belong to
   the interface family, not the serif (charter §4.2). */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-brand);
  font-family: var(--font-heading);
  font-weight: var(--weight-heading);
  line-height: var(--leading-heading);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-h1);
  margin-bottom: var(--space-4);
}

h2 {
  font-size: var(--text-h2);
  margin-top: var(--space-12);
  margin-bottom: var(--space-4);
}

h3 {
  font-size: var(--text-h3);
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
}

h4 {
  font-family: var(--font-body);
  font-size: var(--text-h4);
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
}

h5, h6 {
  font-family: var(--font-body);
  font-size: var(--text-base);
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
}

/* Uppercase runs always carry the charter tracking value (R-T4). */
.alpeia-caps {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-heading);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* Display size: hero claim or key figure (charter §4.2). Fluid between the
   h1 step and the display step so a long claim never breaks the layout. */
.alpeia-display {
  font-family: var(--font-heading);
  font-size: clamp(var(--text-h1), 5vw, var(--text-display));
  font-weight: var(--weight-heading);
  line-height: var(--leading-display);
  color: var(--color-brand);
}

/* Short graphic rule: the charter's rare accent, graphics only (§3.4). */
.alpeia-rule-accent {
  width: 3rem;
  height: 2px;
  background: var(--color-accent-graphic);
  margin-bottom: var(--space-4);
}

/* --- Text --------------------------------------------------------------- */
p,
li,
dd,
blockquote {
  max-width: var(--measure);
}

p {
  margin-bottom: var(--space-4);
}

strong, b {
  font-weight: var(--weight-strong);
}

small {
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* Lead paragraph: 18 px, used right after the h1 (charter §4.2). */
.alpeia-lead {
  font-size: var(--text-lead);
  line-height: 1.5;
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

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

blockquote {
  border-left: 3px solid var(--color-border-control);
  padding-left: var(--space-4);
  color: var(--color-text-muted);
}

/* --- Code --------------------------------------------------------------- */
code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

code {
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-1);
}

pre {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  overflow-x: auto;
  line-height: 1.5;
}

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

/* --- Media ------------------------------------------------------------- */
img, svg, video {
  max-width: 100%;
  height: auto;
}

/* --- Focus (charter R-A4) ----------------------------------------------
   Never removed: a 2 px ring plus a 2 px gap, both keyed on the theme
   (bleu-600 on light, the lightest neutral on dark). The gap is painted with
   the page colour, so the ring stays visible on any surface. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}

/* --- Selection --------------------------------------------------------- */
::selection {
  background: var(--color-selection-surface);
  color: var(--color-selection-text);
}

/* --- Layout ------------------------------------------------------------ */
.alpeia-container {
  width: 100%;
  max-width: var(--layout-max-width);
  margin-inline: auto;
  padding-inline: var(--layout-gutter);
}

.alpeia-section {
  padding-block: var(--space-12);
}

@media (min-width: 640px) {
  .alpeia-section {
    padding-block: var(--space-16);
  }
}

/* Wide screens give a "page breathing" block to the first section.
   The breakpoints are literals because a custom property cannot be used in
   a media query condition (see README.md, "Known limits"). */
@media (min-width: 1200px) {
  .alpeia-section--breathing {
    padding-block-start: var(--space-24);
    padding-block-end: var(--space-12);
  }
}

.alpeia-grid {
  display: grid;
  gap: var(--space-6);
  align-items: start;
}

.alpeia-grid--2,
.alpeia-grid--3 {
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .alpeia-grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .alpeia-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Vertical rhythm for a block of running text. */
.alpeia-prose > * + * {
  margin-top: var(--space-4);
}

.alpeia-prose h2,
.alpeia-prose h3 {
  margin-top: var(--space-8);
}

.alpeia-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

/* --- Accessibility utilities ------------------------------------------- */
.alpeia-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Skip link (charter R-A6): out of the way until it takes focus. */
.alpeia-skip-link {
  position: absolute;
  left: var(--space-2);
  top: calc(-1 * var(--space-16));
  z-index: 10;
  background: var(--color-surface);
  color: var(--color-link);
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-weight: var(--weight-accent);
  text-decoration: underline;
  transition: top var(--duration-fast) var(--ease-standard);
}

.alpeia-skip-link:focus {
  top: var(--space-2);
  outline: 2px solid var(--color-focus);
  outline-offset: var(--focus-offset);   /* charter R-A4 */
}

/* --- Motion (charter R-M3, R-M4, R-A8) --------------------------------- */
@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;
  }
}
