/* Global Styles */
body {
    font-family: var(--font-primary);
    font-size: var(--fs-base);
    font-weight: var(--fw-light);
    color: var(--color-text);
    background-color: var(--color-background);
    line-height: 1.7;
    letter-spacing: 0.01em;
    opacity: 0;
    transition: opacity 0.25s ease;
}

body.is-loaded {
    opacity: 1;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: var(--fw-bold);
    line-height: 1.3;
    margin-bottom: var(--spacing-md);
    color: var(--color-primary);
    letter-spacing: -0.01em;
    text-wrap: balance;
}

h1 {
    font-size: var(--fs-4xl);
    margin-bottom: var(--spacing-lg);
}

h2 {
    font-size: var(--fs-3xl);
}

h3 {
    font-size: var(--fs-2xl);
    font-family: var(--font-primary);
    font-weight: var(--fw-medium);
}

h4 {
    font-size: var(--fs-xl);
    font-family: var(--font-primary);
    font-weight: var(--fw-medium);
}

h5 {
    font-size: var(--fs-large);
    font-family: var(--font-primary);
    font-weight: var(--fw-semibold);
}

h6 {
    font-size: var(--fs-base);
    font-family: var(--font-primary);
    font-weight: var(--fw-medium);
}

p {
    margin-bottom: var(--spacing-md);
    line-height: 1.7;
    font-weight: var(--fw-light);
}

a {
    color: var(--color-accent-darker);
    transition: color var(--transition-fast);
    text-decoration: underline;
    text-decoration-color: var(--color-text-lighter);
    text-underline-offset: 4px;
}

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

/* ===== ACCESSIBILITY: FOCUS MANAGEMENT ===== */

/* Focus indicators for keyboard navigation */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 3px solid var(--color-accent);
    outline-offset: 4px;
    border-radius: 2px;
}

/* Use :focus-visible to show focus only for keyboard users */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
    outline: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 4px;
    border-radius: 2px;
}

/* Ensure focus is visible on dark/colored backgrounds */
.site-footer a:focus,
.site-footer a:focus-visible {
    outline-color: var(--color-background);
}

.project-card:focus,
.project-card:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 4px;
    border-radius: 2px;
}

/* Layout Utilities */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.container-narrow {
    max-width: var(--max-width-narrow);
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.section {
    padding: var(--spacing-3xl) 0;
}

.section-small {
    padding: var(--spacing-lg) 0;
}

.section-grey {
    background-color: var(--color-background-grey);
}

/* Text Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--color-text-light);
}

.subtitle {
    font-size: var(--fs-medium);
    color: var(--color-text);
    line-height: 1.7;
    font-weight: var(--fw-light);
}

/* Grid System */
.grid {
    display: flex;
    flex-wrap: wrap;
    margin: 0 calc(var(--spacing-md) * -1);
}

.grid-gap {
    gap: var(--spacing-lg);
}

.grid-gap-xl {
    gap: var(--spacing-xl);
}

.col {
    flex: 1;
    padding: 0 var(--spacing-md);
}

.col-4 {
    flex: 0 0 33.333%;
    max-width: 33.333%;
    padding: 0 var(--spacing-md);
}

.col-6 {
    flex: 0 0 50%;
    max-width: 50%;
    padding: 0 var(--spacing-md);
}

.col-7 {
    flex: 0 0 58.333%;
    max-width: 58.333%;
    padding: 0 var(--spacing-md);
}

.col-8 {
    flex: 0 0 66.666%;
    max-width: 66.666%;
    padding: 0 var(--spacing-md);
}

.col-12 {
    flex: 0 0 100%;
    max-width: 100%;
    padding: 0 var(--spacing-md);
}

/* Responsive Images */
img {
    max-width: 100%;
    height: auto;
}

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

/* ===== ACCESSIBILITY: REDUCED MOTION SUPPORT ===== */

/* Respect user's 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;
    }
    
    /* Ensure all content is immediately visible */
    .project-card {
        opacity: 1 !important;
        transform: none !important;
    }
    
    /* Disable smooth scrolling */
    html {
        scroll-behavior: auto !important;
    }
    
    /* Hide GIF animations and show static alternatives */
    img[src$=".gif"] {
        /* GIFs will still display but without motion preference, 
           users can manually pause if their OS preference is set */
        content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><text>Animation Paused</text></svg>');
    }
}
