/* ============================================================================
   BASE — Reset, Typography, Layout Primitives
   ============================================================================ */

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

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

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

body {
    font-family: var(--font-body);
    font-size: var(--text-body);
    line-height: var(--leading-normal);
    color: var(--color-text);
    background: var(--color-surface-white);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--color-text);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    font-weight: var(--weight-bold);
}

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

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

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover { color: var(--color-primary-dark); }

/* Inline links within text blocks must be underlined for WCAG link-in-text-block */
p a, li a, address a, td a, dd a, figcaption a {
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}

a:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ── Layout ── */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

.container-narrow {
    max-width: var(--container-narrow);
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

section[id] {
    scroll-margin-top: calc(var(--nav-height) + var(--space-4));
}

body.nav-open {
    overflow: hidden;
}

/* ── Section Spacing ── */
.section {
    padding: var(--section-gap) 0;
}

.section-alt {
    padding: var(--section-gap) 0;
    background: var(--color-surface-low);
}

.section-dark {
    padding: var(--section-gap) 0;
    background: var(--color-dark);
    color: var(--color-text-on-dark);
}

.section-header {
    text-align: center;
    margin-bottom: var(--space-12);
}

.section-header h2 {
    margin-bottom: var(--space-3);
}

.section-header p {
    font-size: var(--text-h4);
    max-width: 600px;
    margin: 0 auto;
}

/* ── Accessibility ── */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-primary);
    color: white;
    padding: var(--space-2) var(--space-4);
    z-index: 1000;
    font-weight: var(--weight-semibold);
    border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
    top: 0;
}

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

/* ── Noscript ── */
.noscript-error {
    text-align: center;
    padding: var(--space-8);
    background: var(--color-warning-bg);
    border: 1px solid var(--color-warning-border);
    border-radius: var(--radius-md);
    margin: var(--space-4);
}

/* ── Skeleton Loading Animation (shared) ── */
@keyframes skeletonPulse {
    0% { opacity: 0.6; }
    50% { opacity: 0.3; }
    100% { opacity: 0.6; }
}

.skeleton-pulse {
    background: var(--color-outline-variant);
    border-radius: var(--radius-xs);
    animation: skeletonPulse 1.5s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .skeleton-pulse {
        animation: none;
        opacity: 0.4;
    }
}
