/* ═══════════════════════════════════════════════════════
   Base layer — reset, typography scale, layout primitives, a11y utils.
   Depends on variables.css. Everything sitewide lives here; components.css
   consumes these as the substrate.
   ═══════════════════════════════════════════════════════ */

/* ─── Modern reset ────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

html:focus-within {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100svh;
  font-family: var(--font-body);
  font-size: var(--text-body-m);
  font-weight: var(--weight-regular);
  line-height: var(--lh-body);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

img {
  height: auto;
  object-fit: cover;
}

/* Inherit font styling */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

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

/* Lists without forced bullets when role="list" is used */
ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Links */
a {
  color: var(--color-text-brand);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

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

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

/* ─── Typography scale ─────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  color: var(--color-text);
  font-weight: var(--weight-semibold);
  line-height: var(--lh-heading);
}

/* Display serif for h1/h2 by default */
h1 {
  font-family: var(--font-display);
  font-size: var(--text-display-l);
  font-weight: var(--weight-regular);
  letter-spacing: var(--tracking-snug);
  line-height: var(--lh-tight);
}

h2 {
  font-family: var(--font-display);
  font-size: var(--text-display-m);
  font-weight: var(--weight-regular);
  letter-spacing: var(--tracking-snug);
  line-height: var(--lh-tight);
}

h3 {
  font-family: var(--font-body);
  font-size: var(--text-heading-l);
}

h4 {
  font-family: var(--font-body);
  font-size: var(--text-heading-m);
}

h5 {
  font-family: var(--font-body);
  font-size: var(--text-heading-s);
}

h6 {
  font-family: var(--font-body);
  font-size: var(--text-overline);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--color-text-secondary);
}

p {
  margin: 0;
  max-width: 65ch;
}

/* Typography helper classes */
.text-display-xl { font-family: var(--font-display); font-size: var(--text-display-xl); font-weight: var(--weight-regular); line-height: var(--lh-display); letter-spacing: var(--tracking-tight); }
.text-display-l  { font-family: var(--font-display); font-size: var(--text-display-l);  font-weight: var(--weight-regular); line-height: var(--lh-tight);   letter-spacing: var(--tracking-snug); }
.text-display-m  { font-family: var(--font-display); font-size: var(--text-display-m);  font-weight: var(--weight-regular); line-height: var(--lh-tight);   letter-spacing: var(--tracking-snug); }
.text-display-s  { font-family: var(--font-display); font-size: var(--text-display-s);  font-weight: var(--weight-medium);  line-height: var(--lh-tight); }

.text-heading-l  { font-family: var(--font-body); font-size: var(--text-heading-l); font-weight: var(--weight-semibold); line-height: var(--lh-heading); }
.text-heading-m  { font-family: var(--font-body); font-size: var(--text-heading-m); font-weight: var(--weight-semibold); line-height: var(--lh-heading); }
.text-heading-s  { font-family: var(--font-body); font-size: var(--text-heading-s); font-weight: var(--weight-semibold); line-height: var(--lh-subhead); }

.text-body-l     { font-size: var(--text-body-l); line-height: var(--lh-body); }
.text-body-m     { font-size: var(--text-body-m); line-height: var(--lh-body); }
.text-body-s     { font-size: var(--text-body-s); line-height: var(--lh-body); }
.text-caption    { font-size: var(--text-caption); line-height: var(--lh-subhead); }

.text-overline {
  font-size: var(--text-overline);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--color-text-secondary);
  line-height: var(--lh-heading);
}

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

/* Italic em within display headings: brand-accented phrase */
.font--display em,
h1 em,
h2 em {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--color-brand);
  font-weight: inherit;
}

/* ─── Layout primitives ───────────────────────────── */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-px);
}

.container--mid    { max-width: var(--container-mid); }
.container--narrow { max-width: var(--container-narrow); }
.container--wide   { max-width: calc(var(--container-max) + var(--space-10)); }

/* Section wrapper — vertical rhythm only */
.section {
  padding-block: var(--section-gap);
}

.section--compact { padding-block: var(--space-12); }
.section--flush   { padding-block: 0; }

/* Section backgrounds (opt-in via modifier) */
.section--alt   { background: var(--color-bg-alt); }
.section--dark  { background: var(--color-dark); color: var(--color-text-inverse); }
.section--dark h1,
.section--dark h2,
.section--dark h3,
.section--dark h4,
.section--dark h5 { color: var(--color-text-inverse); }
.section--dark p  { color: rgba(255, 255, 255, 0.75); }
.section--dark .text-secondary,
.section--dark .text-overline { color: rgba(255, 255, 255, 0.65); }

/* Section header — overline + display heading + optional lead */
.section__header {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 720px;
  margin-bottom: var(--space-10);
}

.section__header--centered {
  margin-inline: auto;
  text-align: center;
  align-items: center;
}

.section__lead {
  font-size: var(--text-body-l);
  color: var(--color-text-secondary);
  max-width: 60ch;
}

.section--dark .section__lead { color: rgba(255, 255, 255, 0.75); }

/* 12-col grid — mobile-first (4 → 8 → 12) */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-6);
}

@media (min-width: 768px) {
  .grid { grid-template-columns: repeat(8, 1fr); }
}

@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(12, 1fr); }
}

/* Column span helpers — use on grid children at md+ */
@media (min-width: 768px) {
  .col-md-4  { grid-column: span 4; }
  .col-md-6  { grid-column: span 6; }
  .col-md-8  { grid-column: span 8; }
}

@media (min-width: 1024px) {
  .col-lg-3  { grid-column: span 3; }
  .col-lg-4  { grid-column: span 4; }
  .col-lg-5  { grid-column: span 5; }
  .col-lg-6  { grid-column: span 6; }
  .col-lg-7  { grid-column: span 7; }
  .col-lg-8  { grid-column: span 8; }
  .col-lg-9  { grid-column: span 9; }
  .col-lg-12 { grid-column: span 12; }
}

/* ─── Accessibility utilities ─────────────────────── */

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

.skip-link {
  position: absolute;
  top: -48px;
  left: var(--space-4);
  z-index: var(--z-toast);
  padding: var(--space-3) var(--space-5);
  background: var(--color-dark);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  font-size: var(--text-body-s);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  transition: top var(--duration-fast) var(--ease-out);
}

.skip-link:focus-visible {
  top: var(--space-4);
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}

/* Global focus ring — components can override */
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}

/* Selection colour — brand tint */
::selection {
  background: var(--color-brand);
  color: var(--color-dark);
}

/* ─── Reveal animation (scroll-triggered) ─────────── */

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity var(--duration-slow) var(--ease-out),
    transform var(--duration-slow) var(--ease-out);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

@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;
  }
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ─── Utility — aspect ratios ─────────────────────── */
.aspect-16-9 { aspect-ratio: 16 / 9; }
.aspect-4-3  { aspect-ratio: 4 / 3;  }
.aspect-3-2  { aspect-ratio: 3 / 2;  }
.aspect-1-1  { aspect-ratio: 1 / 1;  }

/* ─── Utility — flow/stack ────────────────────────── */
.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.stack-lg > * + * { margin-top: var(--space-6); }
.stack-xl > * + * { margin-top: var(--space-10); }
