/*
 * assets/css/base.css
 * Browser normalization and foundational typography.
 * No layout rules here — those live in layout.css.
 * No component styles here — those live in components.css.
 */

/* ===== Box model reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== Root ===== */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Body ===== */
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--leading-relaxed);
  color: var(--color-text-primary);
  background-color: var(--color-bg-page);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Headings ===== */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text-primary);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); font-weight: var(--weight-bold); }
h6 { font-size: var(--text-sm);   font-weight: var(--weight-bold); }

@media (min-width: 768px) {
  h1 { font-size: var(--text-4xl); }
  h2 { font-size: var(--text-3xl); }
  h3 { font-size: var(--text-2xl); }
}

/* ===== Paragraphs ===== */
p {
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
}

/* ===== Inline text ===== */
strong {
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}

em {
  font-style: italic;
}

/* ===== Links ===== */
a {
  color: var(--color-text-link);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--color-text-link-hover);
}

a:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ===== Lists ===== */
ul, ol {
  padding-left: var(--space-6);
}

li {
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
}

/* ===== Code ===== */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--color-bg-code);
  color: var(--color-gold);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background-color: var(--color-bg-code);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  overflow-x: auto;
  line-height: var(--leading-relaxed);
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: var(--color-text-primary);
}

/* ===== Images ===== */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ===== Horizontal rule ===== */
hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-8) 0;
}

/* ===== Tables ===== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

th {
  text-align: left;
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  background-color: var(--color-bg-raised);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-4);
}

td {
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border-subtle);
  padding: var(--space-3) var(--space-4);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

/* ===== Focus management ===== */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 3px;
}

/* ===== Text selection ===== */
::selection {
  background-color: var(--color-gold-subtle);
  color: var(--color-text-primary);
}
