/* ════════════════════════════════════════════════════════════════
   2026 RESPONSIVE WEB DESIGN BEST PRACTICES
   Includes: Fluid Typography, Container Queries, CWV Optimization
   ════════════════════════════════════════════════════════════════ */

/* FLUID TYPOGRAPHY WITH CLAMP() */
html {
    font-size: clamp(14px, 1.5vw, 18px);
    scroll-behavior: smooth;
}

h1 {
    font-size: clamp(28px, 5vw, 48px) !important;
    line-height: 1.2;
    font-weight: 600;
}

h2 {
    font-size: clamp(24px, 4vw, 36px) !important;
    line-height: 1.3;
    font-weight: 600;
}

h3 {
    font-size: clamp(20px, 3.5vw, 28px) !important;
    line-height: 1.4;
    font-weight: 600;
}

h4, h5, h6 {
    font-size: clamp(16px, 2.5vw, 20px) !important;
    line-height: 1.5;
    font-weight: 600;
}

p, span, a, li {
    font-size: clamp(14px, 2vw, 16px);
    line-height: 1.6;
}

/* CONTAINER QUERIES - Component-Based Responsiveness */
@supports (container-type: inline-size) {
    .project-card,
    .blog-post,
    .portfolio-item,
    .form-card,
    .resume-card,
    .card {
        container-type: inline-size;
    }

    /* Small containers (mobile) */
    @container (max-width: 400px) {
        .project-card h3,
        .blog-post h2,
        .portfolio-item h3 {
            font-size: clamp(16px, 4vw, 18px);
        }
        
        .project-card p,
        .blog-post p {
            font-size: clamp(13px, 2vw, 14px);
        }
    }

    /* Medium containers (tablet) */
    @container (min-width: 401px) and (max-width: 700px) {
        .project-card h3,
        .blog-post h2 {
            font-size: clamp(18px, 3vw, 20px);
        }
    }

    /* Large containers (desktop) */
    @container (min-width: 701px) {
        .project-card h3,
        .blog-post h2 {
            font-size: clamp(20px, 2vw, 22px);
        }
    }
}

/* CORE WEB VITALS OPTIMIZATION */

/* 1. CLS (Cumulative Layout Shift) Prevention */
img, video, iframe {
    display: block;
    max-width: 100%;
    height: auto;
    aspect-ratio: auto;
}

/* Aspect ratio containers prevent layout shift */
.image-container,
.video-container {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: #f0f0f0;
}

.image-container img,
.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 2. LCP (Largest Contentful Paint) Optimization */
.hero,
.hero-image,
.main-image,
.featured-image {
    contain: layout style paint;
    content-visibility: auto;
}

/* Preload critical images */
img.critical {
    loading: eager;
    decoding: sync;
}

/* 3. INP (Interaction to Next Paint) Optimization */
button,
input,
select,
textarea,
[role="button"],
[role="checkbox"],
[role="radio"] {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

button {
    border: none;
    font-family: inherit;
}

/* RESPONSIVE IMAGES */

/* Picture element support */
picture {
    display: block;
    width: 100%;
}

picture img {
    width: 100%;
    height: auto;
    display: block;
}

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

/* FORM OPTIMIZATION */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea,
select {
    font-size: clamp(14px, 2vw, 16px) !important;
    padding: clamp(10px, 1.5vw, 14px) !important;
    line-height: 1.5;
    width: 100%;
    max-width: 100%;
    border-radius: 4px;
    border: 1px solid #ddd;
    box-sizing: border-box;
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #3d7a7f;
    outline-offset: 2px;
}

/* Touch-friendly interactive elements */
input,
button,
a[href],
[role="button"],
select,
textarea {
    min-height: 44px;
    min-width: 44px;
}

button {
    font-size: clamp(13px, 2vw, 16px) !important;
    padding: clamp(10px, 1.5vw, 14px) clamp(16px, 3vw, 24px) !important;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

button:active {
    transform: scale(0.98);
}

/* FONT LOADING OPTIMIZATION */

@font-face {
    font-family: 'Cormorant Garamond';
    font-display: swap;
}

@font-face {
    font-family: 'Jost';
    font-display: swap;
}

@font-face {
    font-family: 'DM Mono';
    font-display: swap;
}

/* LAZY LOADING ANIMATION */

img[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* RESPONSIVE SPACING WITH CLAMP */

.section {
    padding: clamp(20px, 5vw, 60px);
}

.container {
    max-width: min(100%, 1200px);
    margin: 0 auto;
    padding: 0 clamp(16px, 4vw, 32px);
}

.row {
    gap: clamp(1rem, 2vw, 2rem);
}

/* MODERN GRID & FLEXBOX */

.grid,
.card-grid {
    display: grid;
    gap: clamp(1rem, 2vw, 2rem);
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.flex-container {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(0.5rem, 1.5vw, 1rem);
    align-items: center;
}

/* ACCESSIBILITY */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: more) {
    * {
        border-width: 2px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }
    
    img {
        opacity: 0.9;
    }
}

/* High DPI Display Optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* PERFORMANCE OPTIMIZATION */

/* Optimize transitions */
* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Containment for layout performance */
.hero,
.sidebar,
.card,
.modal {
    contain: layout style paint;
}

/* RESPONSIVE TEXT */

.text-responsive {
    font-size: clamp(12px, 1.5vw, 14px);
}

.text-large {
    font-size: clamp(16px, 2.5vw, 20px);
}

.text-title {
    font-size: clamp(20px, 4vw, 32px);
}

/* SCROLL OPTIMIZATION */

.scroll-smooth {
    scroll-behavior: smooth;
}

/* VIEWPORT OPTIMIZATION */

@viewport {
    width: device-width;
    zoom: 1;
}

/* Modern background images */
.bg-image {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

@media (prefers-reduced-motion: reduce) {
    .bg-image {
        background-attachment: scroll;
    }
}
