/**
 * Modern CSS Reset & Base Styles
 * Based on Josh Comeau's CSS Reset with enterprise enhancements
 */

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

/* Box Sizing Reset */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Remove Default Margins - Only on specific elements, not all */
body, h1, h2, h3, h4, h5, h6, p, ul, ol, li, figure, figcaption, blockquote, dl, dd {
    margin: 0;
}

/* Typography Improvements */
html {
    /* Improve text rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    
    /* Smooth scrolling with respect for reduced motion */
    scroll-behavior: smooth;
    
    /* Prevent horizontal overflow */
    overflow-x: hidden;
    max-width: 100vw;
}

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

/* Body Setup */
body {
    line-height: var(--line-height-normal);
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    color: var(--color-text);
    background-color: var(--color-background);
    
    /* Prevent horizontal overflow */
    overflow-x: hidden;
    max-width: 100vw;
    
    /* Improve text rendering on Windows */
    font-feature-settings: "kern" 1;
    font-kerning: normal;
    
    /* Smooth color transitions for theme switching */
    transition: background-color var(--duration-base) var(--ease-in-out),
                color var(--duration-base) var(--ease-in-out);
}

/* Improve Media Defaults */
img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Remove Built-in Form Typography Styles */
input, button, textarea, select {
    font: inherit;
    color: inherit;
}

/* Avoid Text Overflows */
p, h1, h2, h3, h4, h5, h6 {
    overflow-wrap: break-word;
}

/* Improve Line Wrapping */
p {
    text-wrap: pretty;
}

h1, h2, h3, h4, h5, h6 {
    text-wrap: balance;
}

/* Create Root Stacking Context */
#root, #__next {
    isolation: isolate;
}

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

/* Remove Default Focus Outline */
:focus {
    outline: none;
}

/* Visible Focus for Keyboard Navigation */
:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
}

/* Interactive Elements Focus */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
}

/* =============================================================================
   LINK STYLES
   ============================================================================= */

a {
    color: var(--color-link);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-in-out);
}

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

a:visited {
    color: var(--color-link-visited);
}

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

ul, ol {
    padding-left: var(--space-6);
}

ul[role="list"],
ol[role="list"] {
    list-style: none;
    padding: 0;
}

/* =============================================================================
   TABLE STYLES
   ============================================================================= */

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

/* =============================================================================
   FORM ELEMENTS
   ============================================================================= */

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

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

input, textarea, select {
    background-color: var(--color-surface);
    border: var(--border-width-1) solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */

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

/* Skip to Main Content */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-primary);
    color: white;
    padding: var(--space-2) var(--space-4);
    text-decoration: none;
    z-index: 100;
}

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

/* Container Constraints */
.container, .container-fluid {
    max-width: 100%;
    overflow-x: hidden;
}

/* Prevent Layout Shift from Scrollbars */
html {
    scrollbar-gutter: stable;
}

