/* Explain: Base reset, typography, accessibility, and color theme utilities. */
* {
    box-sizing: border-box;
}

html {
    background: var(--background-color);
    color: var(--text-color);
    scroll-padding-top: 1.5rem;
    overflow-x: hidden;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    background-color: var(--background-color);
    background-image:
        radial-gradient(circle at 0% 0%, var(--sage-soft), transparent 45rem),
        radial-gradient(circle at 100% 20%, var(--terracotta-soft), transparent 40rem),
        radial-gradient(circle at 50% 100%, var(--sage-soft), transparent 45rem);
    color: var(--text-color);
    font-family: var(--font-body);
    line-height: 1.65;
    overflow-wrap: break-word;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Unified heading typography across every section */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    line-height: 1.2;
}

/* Readable paragraph rhythm */
p,
li,
span,
label,
a {
    text-underline-offset: 3px;
}

button,
a,
select {
    cursor: pointer;
}

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

::selection {
    background: var(--accent-color);
    color: #ffffff;
}

/* Accessibility Utilities */
html.a11y-text-1 { font-size: 110%; }
html.a11y-text-2 { font-size: 120%; }
html.a11y-text-3 { font-size: 130%; }

html.a11y-font * {
    font-family: Arial, Helvetica, sans-serif !important;
}

html.a11y-links a {
    text-decoration: underline !important;
    font-weight: 800 !important;
}

html.a11y-contrast {
    --primary-color: #ffffff;
    --primary-hover: #ffff00;
    --secondary-color: #111111;
    --accent-color: #ffff00;
    --button-color: #ffff00;
    --background-color: #000000;
    --surface-color: #111111;
    --footer-bg: #000000;
    --text-color: #ffffff;
    --text-muted: #dddddd;
    --border-color: #ffff00;
    --glass-bg: rgba(0, 0, 0, 0.95);
    --glass-border: #ffff00;
    --nav-bg: rgba(0, 0, 0, 0.95);
    --field-bg: #222222;
    --sage-soft: #222222;
    --terracotta-soft: #222222;
    --sage-dark: #ffff00;
}

html.a11y-contrast .btn,
html.a11y-contrast button[type="submit"],
html.a11y-contrast #a11y-reset {
    color: #000000 !important;
    background-color: #ffff00 !important;
}

/* Desktop: keep the fixed header cleared when jumping to in-page anchors */
@media (min-width: 1024px) {
    html {
        scroll-padding-top: 210px;
    }
}

/* Mobile readability */
@media (max-width: 640px) {
    body {
        line-height: 1.75;
    }

    p,
    li {
        line-height: 1.75;
    }

    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        line-height: 1.25;
    }
}

/* Balanced line breaks so headings and text look even across every screen size */
h1,
h2,
h3,
h4,
h5,
h6 {
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

/* Smooth in-page navigation for everyone (respecting reduced-motion preferences) */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}