/*
 * Base Reset and Normalization
 * 
 * Foundational styles that establish consistent baseline across browsers
 * and integrate with the semantic token system.
 */

/* ============================================================================
 * MODERN CSS RESET
 * ============================================================================ */

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

* {
    margin: 0;
    padding: 0;
}

body {
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeSpeed;
}

img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
}

input,
button,
textarea,
select {
    font: inherit;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
    overflow-wrap: break-word;
}

#root,
#__next {
    isolation: isolate;
}

/* ============================================================================
 * SEMANTIC BASE STYLES
 * ============================================================================ */

html {
    font-size: 16px; /* Base for rem calculations */
    scroll-behavior: smooth;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 
                 Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: hsl(var(--surface-primary));
    color: hsl(var(--content-primary));
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================================================================
 * TYPOGRAPHY BASE
 * ============================================================================ */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

h1 { font-size: var(--text-display); }
h2 { font-size: var(--text-heading-1); }
h3 { font-size: var(--text-heading-2); }
h4 { font-size: var(--text-heading-3); }
h5 { font-size: var(--text-body-large); }
h6 { font-size: var(--text-body); }

p {
    font-size: var(--text-body);
    line-height: 1.6;
    margin-bottom: 1rem;
}

small {
    font-size: var(--text-body-small);
}

/* ============================================================================
 * SEMANTIC ELEMENT STYLES
 * ============================================================================ */

a {
    color: hsl(var(--action-primary));
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

a:hover {
    color: hsl(var(--action-primary-hover));
    text-decoration: none;
}

code {
    font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 0.875em;
    background-color: hsl(var(--surface-secondary));
    padding: 0.125rem 0.25rem;
    border-radius: var(--radius-small);
    border: 1px solid hsl(var(--border-primary));
}

pre {
    font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
    background-color: hsl(var(--surface-secondary));
    padding: 1rem;
    border-radius: var(--radius-normal);
    border: 1px solid hsl(var(--border-primary));
    overflow-x: auto;
    font-size: var(--text-body-small);
}

pre code {
    background: none;
    border: none;
    padding: 0;
}

blockquote {
    border-left: 4px solid hsl(var(--border-primary));
    padding-left: 1rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: hsl(var(--content-secondary));
}

hr {
    border: none;
    height: 1px;
    background-color: hsl(var(--border-primary));
    margin: 2rem 0;
}

/* ============================================================================
 * LIST STYLES
 * ============================================================================ */

ul, ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

li {
    margin-bottom: 0.25rem;
}

/* ============================================================================
 * FOCUS MANAGEMENT
 * ============================================================================ */

:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid hsl(var(--border-focus));
    outline-offset: 2px;
}

/* ============================================================================
 * ACCESSIBILITY IMPROVEMENTS
 * ============================================================================ */

/* Screen reader only content */
.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;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-primary: 0 0% 0%;
        --content-secondary: 0 0% 0%;
    }
}

/* Dark mode base adjustments */
@media (prefers-color-scheme: dark) {
    :root:not(.light) {
        color-scheme: dark;
    }
}

/* Reduced motion preferences */
@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;
    }
}