/**
 * base.css: reset, typography, a11y helpers.
 * Everything reads from tokens.css. No !important.
 */
:root {
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
  color-scheme: light;
}

@media (min-width: 768px) {
  html {
    scroll-padding-top: 4.5rem;
  }
}

html[data-theme="dark"] {
  color-scheme: dark;
}

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

  *,
  *::before,
  *::after {
    transition: none;
    animation: none;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--theme-bg);
  color: var(--theme-text);
  font: var(--text-base) / var(--leading-normal) var(--font-sans-body);
  -webkit-font-smoothing: antialiased;
}

/* Typography */
h1,
h2,
h3,
h4 {
  margin: 0 0 var(--space-3);
  font-family: var(--font-serif-heading);
  line-height: var(--leading-tight);
  color: var(--theme-text);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

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

a {
  color: var(--theme-accent);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--theme-accent-hover);
}

img,
video,
iframe {
  max-width: 100%;
}

img,
video {
  height: auto;
}

blockquote {
  margin: var(--space-4) 0;
  padding: var(--space-2) var(--space-4);
  border-inline-start: 4px solid var(--kaliyattam-gold);
  background: var(--theme-surface-alt);
  color: var(--theme-text-secondary);
}

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

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--theme-border-subtle);
  text-align: start;
}

/* Focus and a11y */
:focus-visible {
  outline: 2px solid var(--theme-accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-3);
  top: -4rem;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--theme-surface);
  color: var(--theme-text);
  box-shadow: var(--shadow-md);
}

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

.container {
  width: min(100% - 2 * var(--container-padding), var(--container-max-width));
  margin-inline: auto;
}
