/**
 * ═══════════════════════════════════════════════════════════
 * Base Styles — Reset & Element Defaults
 * ═══════════════════════════════════════════════════════════
 *
 * Purpose:
 *   - Normalise cross-browser differences
 *   - Set sensible element defaults using design tokens
 *   - Define base typography
 *
 * Load order: after variables.css, before layout.css
 * ═══════════════════════════════════════════════════════════
 */

/* ── Box Model ───────────────────────────────────────────────── */

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

/* ── Root & Body ─────────────────────────────────────────────── */

html {
    font-size: 100%;          /* 1rem = 16px browser default */
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family:      var(--font-sans);
    font-size:        var(--text-base);
    font-weight:      var(--weight-regular);
    line-height:      var(--leading-normal);
    color:            var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing:  antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Prevent layout shift when nav-open class is applied on mobile */
body.nav-open {
    overflow: hidden;
}

/* ── Skip to Content (accessibility) ────────────────────────── */

.skip-to-content {
    /* fixed, not absolute: an absolutely positioned link is placed against
       the document, so once the page is scrolled it cannot come back into
       view when focused. */
    position: fixed;
    top: -100px;
    left: var(--space-4);
    background: var(--color-accent);
    color: var(--color-text-invert);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    font-weight: var(--weight-medium);
    font-size: var(--text-sm);
    z-index: var(--z-tooltip);
    text-decoration: none;
    transition: top var(--transition-fast);
}
.skip-to-content:focus {
    top: var(--space-4);
}

/* ── 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);
}

h1 { font-size: clamp(var(--text-3xl), 5vw, var(--text-5xl)); }
h2 { font-size: clamp(var(--text-2xl), 3.5vw, var(--text-4xl)); }
h3 { font-size: clamp(var(--text-xl),  2.5vw, var(--text-3xl)); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

/* ── Paragraphs & Prose ──────────────────────────────────────── */

p {
    line-height: var(--leading-relaxed);
    color: var(--color-text);
}

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

/* ── Links ───────────────────────────────────────────────────── */

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

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

a:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-sm);
}

/* ── Lists ───────────────────────────────────────────────────── */

ul, ol {
    list-style: none;
}

/* ── Images & Media ──────────────────────────────────────────── */

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

img {
    image-rendering: auto;
}

/* ── Forms (global resets — detailed styles in components.css) ─ */

input,
textarea,
select,
button {
    font-family: inherit;
    font-size:   inherit;
}

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

/* ── Tables ──────────────────────────────────────────────────── */

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

/* ── HR ──────────────────────────────────────────────────────── */

hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: var(--space-8) 0;
}

/* ── Selection ───────────────────────────────────────────────── */

::selection {
    background-color: var(--color-accent-light);
    color: var(--color-accent-hover);
}

/* ── Scrollbar (Webkit) ──────────────────────────────────────── */

::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--color-surface);
}
::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-light);
}

/* ── Reduced Motion ──────────────────────────────────────────── */

@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;
    }
}

/* ── Phase 1 Stub Indicator ──────────────────────────────────── */
/* Remove when page content is implemented */

.section--stub {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stub-label {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    background: var(--color-surface);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-6);
    font-family: monospace;
}
