/* ============================================================================
   base.css - Global reset, typography, links, focus styles
   ============================================================================
   The "everything inherits this" layer. Loaded after tokens.css.
*/

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;   /* prevent iOS auto-zoom on rotate */
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Headings: medium weight, no tight uppercase tracking, no all-caps. */
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--space-3);
    font-weight: var(--weight-medium);
    line-height: var(--leading-tight);
    color: var(--text-primary);
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4, h5, h6 { font-size: var(--text-base); }

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

/* Links: brand blue, underlined on hover only.  We avoid permanent underline
   because text-heavy pages get noisy. */
a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--duration-fast) var(--easing);
}
a:hover {
    color: var(--text-link-hover);
    text-decoration: underline;
}

/* Visible focus ring for keyboard users.  Hidden on mouse interactions. */
:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

hr {
    border: 0;
    border-top: var(--border-thin) solid var(--border-default);
    margin: var(--space-8) 0;
}

/* Code & monospace: muted background pill, used for technical values. */
code, kbd, samp {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--bg-muted);
    padding: 0.1em 0.3em;
    border-radius: var(--radius-sm);
}

/* Tables: handled in detail in components.css; here just basic reset. */
table {
    border-collapse: collapse;
    width: 100%;
}

/* Images don't break their containers on mobile. */
img, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Screen-reader only utility - text invisible on screen but read aloud. */
.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;
}

/* Page container - holds the main content area at a readable max-width. */
.container {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--space-4);
}
.container-narrow {
    max-width: var(--content-narrow);
    margin: 0 auto;
    padding: 0 var(--space-4);
}

/* Stack utility - vertical rhythm without manual margin tweaking. */
.stack > * + * { margin-top: var(--space-4); }
.stack-lg > * + * { margin-top: var(--space-6); }
.stack-xl > * + * { margin-top: var(--space-8); }
