/**
 * SEMANTIC STRUCTURE ENHANCEMENTS
 * Improves semantic HTML structure and visual hierarchy
 * 2026 Best Practices for Accessibility and SEO
 */

/* ====== SEMANTIC LANDMARKS ====== */

/* Main content area */
main,
[role="main"] {
    display: block;
    min-height: calc(100vh - 200px);
}

/* Header/Hero section */
header,
.hero-section,
section.hero {
    position: relative;
    width: 100%;
}

/* Article sections */
article {
    display: block;
    margin-bottom: var(--spacing-4, 32px);
}

/* Aside/Sidebar */
aside {
    display: block;
}

/* Footer */
footer {
    margin-top: auto;
}

/* ====== HEADING HIERARCHY ====== */

/* Ensure proper heading structure */
h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h2 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.875rem;
    margin-top: 2rem;
}

h3 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
}

h4 {
    font-size: clamp(1.25rem, 2.5vw, 1.5rem);
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.625rem;
    margin-top: 1.25rem;
}

h5 {
    font-size: clamp(1.125rem, 2vw, 1.25rem);
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

h6 {
    font-size: clamp(1rem, 1.5vw, 1.125rem);
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

/* Prevent heading level skipping */
h1 + h3,
h2 + h4,
h3 + h5 {
    font-size: inherit;
    font-weight: inherit;
}

/* ====== SECTION STRUCTURE ====== */

/* Section spacing with 8-point grid */
section {
    padding: var(--spacing-5, 40px) var(--spacing-2, 16px);
    margin: 0;
}

section:first-of-type {
    padding-top: calc(var(--spacing-5, 40px) + 60px); /* Account for navbar */
}

/* Section titles */
section > h2:first-child,
.section-title {
    margin-top: 0;
    margin-bottom: var(--spacing-3, 24px);
}

/* ====== VISUAL HIERARCHY ====== */

/* Content hierarchy */
.hero-section h1 {
    font-size: clamp(2.5rem, 6vw, 4rem);
    margin-bottom: var(--spacing-3, 24px);
}

.hero-section p {
    font-size: clamp(1.125rem, 2vw, 1.5rem);
    margin-bottom: var(--spacing-4, 32px);
}

/* Main content readability */
main p,
article p {
    max-width: 65ch; /* Optimal reading width */
    line-height: 1.7;
    margin-bottom: var(--spacing-2, 16px);
}

/* ====== LANDMARK ROLES ====== */

/* Ensure proper ARIA landmarks */
[role="banner"] {
    position: relative;
}

[role="navigation"] {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 10000;
}

[role="main"] {
    padding-top: 60px; /* Account for fixed navbar */
}

[role="contentinfo"] {
    margin-top: var(--spacing-6, 48px);
    padding: var(--spacing-4, 32px) var(--spacing-2, 16px);
}

/* ====== ACCESSIBILITY ENHANCEMENTS ====== */

/* Skip to main content link */
.skip-to-main,
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--primary-color, #0d6efd);
    color: white;
    padding: var(--spacing-2, 16px) var(--spacing-3, 24px);
    text-decoration: none;
    font-weight: 600;
    z-index: 10001;
    border-radius: 0 0 4px 0;
    transition: top 0.3s ease;
}

.skip-to-main:focus,
.skip-link:focus {
    top: 0;
    outline: 3px solid var(--accent-color, #ff6b6b);
    outline-offset: 2px;
}

/* Focus visible for all interactive elements */
*:focus-visible {
    outline: 3px solid var(--primary-color, #0d6efd);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ====== RESPONSIVE TYPOGRAPHY ====== */

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    h3 {
        font-size: 1.5rem;
    }
    
    section {
        padding: var(--spacing-4, 32px) var(--spacing-2, 16px);
    }
    
    section:first-of-type {
        padding-top: calc(var(--spacing-4, 32px) + 56px); /* Mobile navbar height */
    }
}

/* ====== PRINT STYLES ====== */

@media print {
    nav,
    .sidebar,
    .skip-to-main,
    .skip-link {
        display: none;
    }
    
    main {
        padding-top: 0;
    }
    
    section {
        page-break-inside: avoid;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
    }
}
