/**
 * base.css — Reset, typography base, layout primitives
 */
@import url('./tokens.css');

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

html { font-size: 16px; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--font-body);
  font-size: var(--text-body-md);
  color: var(--color-text-primary);
  background-color: var(--color-canvas);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Typography ── */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 400; line-height: 1.1; letter-spacing: -0.01em; }
h5, h6 { font-family: var(--font-body); font-weight: 600; }
h1 { font-size: var(--text-display-xl); line-height: 1.05; letter-spacing: -0.02em; }
h2 { font-size: var(--text-display-md); line-height: 1.15; letter-spacing: -0.01em; }
h3 { font-size: var(--text-display-sm); line-height: 1.2; }
h4 { font-size: var(--text-heading-lg); font-family: var(--font-body); font-weight: 600; }
h5 { font-size: var(--text-heading-md); }
h6 { font-size: var(--text-heading-sm); }
p { max-width: 70ch; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img, video { max-width: 100%; height: auto; display: block; }
ul, ol { padding-left: var(--space-6); }
li { margin-bottom: var(--space-1); }

/* ── Focus ── */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── Mobile typography scale ── */
@media (max-width: 767px) {
  h1 { font-size: 2.25rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.375rem; }
}

/* ── Layout containers ── */
.container {
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: var(--space-4);
}
@media (min-width: 768px)  { .container { padding-inline: var(--space-8); } }
@media (min-width: 1280px) { .container { padding-inline: var(--space-16); } }

/* ── Section backgrounds / theming ── */
.section--light {
  background-color: var(--color-surface-0);
  color: var(--color-text-primary);
}
.section--light h1, .section--light h2, .section--light h3,
.section--light h4, .section--light p { color: var(--color-text-primary); }

.section--tint {
  background-color: var(--color-surface-1);
  color: var(--color-text-primary);
}
.section--tint h1, .section--tint h2, .section--tint h3,
.section--tint h4, .section--tint p { color: var(--color-text-primary); }

.section--dark {
  background-color: var(--color-ink);
  color: var(--color-text-inverse);
}
.section--dark h1, .section--dark h2, .section--dark h3,
.section--dark h4, .section--dark p { color: var(--color-text-inverse); }

.section--dark .card {
  background-color: var(--color-ink-secondary);
  color: var(--color-text-inverse);
}

/* ── Section padding rhythm ── */
.section-pad { padding-block: var(--space-12); }
@media (min-width: 768px) { .section-pad { padding-block: var(--space-16); } }
.section-pad--hero { padding-block: var(--space-16); }
@media (min-width: 768px) { .section-pad--hero { padding-block: var(--space-20); } }

/* ── Scroll reveal ── */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}
.reveal.reveal--visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Reduced motion (critical — override everything) ── */
@media (prefers-reduced-motion: reduce) {
  .reveal,
  .reveal.reveal--visible {
    opacity: 1;
    transform: none;
    transition: none;
  }
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

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

/* ── Skip link ── */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 1000;
  padding: var(--space-3) var(--space-6);
  background: var(--color-accent);
  color: var(--color-canvas);
  font-weight: 600;
  border-radius: var(--radius-md);
  text-decoration: none;
}
.skip-link:focus { top: var(--space-4); }

/* ── Prose / article body ── */
.prose { max-width: 720px; margin-inline: auto; }
.prose p { margin-bottom: var(--space-6); color: var(--color-text-primary); }
.prose h2 { margin-top: var(--space-10); margin-bottom: var(--space-4); }
.prose h3 { margin-top: var(--space-8); margin-bottom: var(--space-3); }
.prose ul, .prose ol { margin-bottom: var(--space-6); }
.prose li { margin-bottom: var(--space-2); color: var(--color-text-primary); }
.prose strong { font-weight: 600; }
.prose a { color: var(--color-accent); text-decoration: underline; }
.prose hr { border: none; border-top: 1px solid var(--color-border); margin-block: var(--space-8); }
.prose img { border-radius: var(--radius-md); margin-block: var(--space-6); }

/* ── Responsive picture helper ── */
.img-responsive {
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
}
