/* ============================================
   ADVANCED MODERN CSS - INTERNATIONAL STANDARDS
   Cutting-edge techniques for professional websites
   ============================================ */

/* ============================================
   1. MODERN LAYOUT SYSTEM
   ============================================ */

/* CSS Grid Container - Modern Layouts */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: var(--space-6);
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }

/* Advanced Flexbox Utilities */
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
}

/* ============================================
   2. MODERN RESPONSIVE TYPOGRAPHY
   ============================================ */

/* Fluid Typography with clamp() */
.heading-xl {
    font-size: clamp(2.5rem, 5vw + 1rem, 5rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.heading-lg {
    font-size: clamp(2rem, 4vw + 1rem, 3.5rem);
    font-weight: 700;
    line-height: 1.2;
}

.heading-md {
    font-size: clamp(1.5rem, 3vw + 1rem, 2.5rem);
    font-weight: 600;
    line-height: 1.3;
}

.text-balance {
    text-wrap: balance; /* Modern CSS for balanced text */
}

.text-pretty {
    text-wrap: pretty; /* Prevents orphans */
}

/* ============================================
   3. ADVANCED ANIMATIONS & TRANSITIONS
   ============================================ */

/* Smooth scroll behavior with reduced motion support */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }

    .animate-fade-in {
        animation: fadeIn 0.6s ease-out forwards;
    }

    .animate-slide-up {
        animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    .animate-scale {
        animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Performance optimization for animations */
.will-animate {
    will-change: transform, opacity;
}

.will-animate:not(:hover):not(:focus) {
    will-change: auto;
}

/* ============================================
   4. MODERN CARD COMPONENTS
   ============================================ */

.card-modern {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-small);
    transition: all var(--transition-medium);
    container-type: inline-size; /* Modern container queries */
    position: relative;
    overflow: hidden;
}

.card-modern::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    opacity: 0;
    transition: opacity var(--transition-medium);
    z-index: -1;
}

.card-modern:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-large);
}

.card-modern:hover::before {
    opacity: 0.03;
}

/* Glass morphism effect */
.card-glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
}

/* ============================================
   5. MODERN BUTTON SYSTEM
   ============================================ */

.btn-modern {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-base);
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    text-decoration: none;
    border-radius: var(--radius-lg);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-medium);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn-modern::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-color-light), var(--primary-color-dark));
    z-index: -1;
    transition: transform var(--transition-medium);
}

.btn-modern:hover::before {
    transform: scale(1.05);
}

.btn-modern:active {
    transform: scale(0.98);
}

.btn-primary-modern {
    background: var(--primary-color);
    color: white;
}

.btn-primary-modern:hover {
    background: var(--primary-color-dark);
    box-shadow: 0 8px 16px rgba(195, 21, 28, 0.3);
}

.btn-secondary-modern {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary-modern:hover {
    background: var(--secondary-color-dark);
    box-shadow: 0 8px 16px rgba(18, 52, 107, 0.3);
}

.btn-outline-modern {
    background: transparent;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-modern:hover {
    background: var(--primary-color);
    color: white;
}

/* ============================================
   6. MODERN FOCUS STATES (Accessibility)
   ============================================ */

/* Remove default focus outline */
*:focus {
    outline: none;
}

/* Custom focus-visible for keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    z-index: var(--z-modal);
    padding: var(--space-4) var(--space-6);
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-md);
}

.skip-to-main:focus {
    position: fixed;
    top: var(--space-4);
    left: var(--space-4);
    width: auto;
    height: auto;
}

/* ============================================
   7. MODERN GRADIENT OVERLAYS
   ============================================ */

.gradient-overlay {
    position: relative;
    z-index: 1;
}

.gradient-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(195, 21, 28, 0.9) 0%,
        rgba(18, 52, 107, 0.8) 100%
    );
    z-index: -1;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   8. MODERN SPACING SYSTEM
   ============================================ */

/* Logical properties for better internationalization */
.section-padding {
    padding-block: var(--space-20);
    padding-inline: var(--space-4);
}

@media (min-width: 768px) {
    .section-padding {
        padding-block: var(--space-32);
        padding-inline: var(--space-8);
    }
}

/* ============================================
   9. MODERN ASPECT RATIOS
   ============================================ */

.aspect-video {
    aspect-ratio: 16 / 9;
}

.aspect-square {
    aspect-ratio: 1 / 1;
}

.aspect-portrait {
    aspect-ratio: 3 / 4;
}

/* ============================================
   10. PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Content containment for better performance */
.contain-layout {
    contain: layout;
}

.contain-paint {
    contain: paint;
}

.contain-strict {
    contain: strict;
}

/* Image optimization */
img, picture, video {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Lazy loading optimization */
img[loading="lazy"] {
    content-visibility: auto;
}

/* ============================================
   11. MODERN NAVIGATION
   ============================================ */

.nav-modern {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-light);
    transition: all var(--transition-medium);
}

.nav-modern.scrolled {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow-small);
}

/* ============================================
   12. MODERN FORM ELEMENTS
   ============================================ */

.input-modern {
    width: 100%;
    padding: var(--space-4);
    font-size: var(--text-base);
    font-family: 'Montserrat', sans-serif;
    color: var(--text-dark);
    background: var(--bg-white);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.input-modern:hover {
    border-color: var(--primary-color);
}

.input-modern:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(195, 21, 28, 0.1);
}

.input-modern::placeholder {
    color: var(--text-light);
}

/* ============================================
   13. DARK MODE SUPPORT
   ============================================ */

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-white: #1a1a1a;
        --bg-light: #2a2a2a;
        --text-dark: #ffffff;
        --text-medium: #e0e0e0;
        --text-light: #a0a0a0;
        --border-light: #3a3a3a;
    }
}

/* ============================================
   14. MODERN UTILITY CLASSES
   ============================================ */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================
   15. MODERN SCROLLBAR
   ============================================ */

* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--bg-light);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color-dark);
}
