/**
 * PROJECT MODAL - ULTRA MODERN iOS STYLE
 * Inspired by WaddleGo and premium iOS apps
 * Features: Glassmorphism, Vibrant gradients, Smooth animations
 * Created for Sebastian Contreras Portfolio
 */

/* ========================================
   MODAL OVERLAY
   ======================================== */

.project-modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
}

.project-modal.open {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
}

/* Backdrop - Premium dark gradient (backdrop-filter removed for performance) */
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center,
        rgba(0, 0, 0, 0.85) 0%,
        rgba(0, 0, 0, 0.98) 100%);
    opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.project-modal.open .modal-backdrop {
    opacity: 1;
}

/* ========================================
   MODAL CONTAINER - PREMIUM CARD
   ======================================== */

.modal-container {
    position: relative;
    width: 92%;
    max-width: 1000px;
    max-height: 92vh;

    /* Dynamic glow color variables (change based on project) */
    --glow-color-primary: rgba(0, 122, 255, 0.5);   /* Default - main glow */
    --glow-color-secondary: rgba(88, 86, 214, 0.3); /* Default - secondary glow */
    --glow-color-shadow: rgba(0, 122, 255, 0.15);   /* Default - subtle shadow */

    /* Ultra-premium glassmorphism (backdrop-filter removed for performance) */
    background: linear-gradient(135deg,
        rgba(30, 30, 45, 0.98) 0%,
        rgba(20, 20, 35, 1) 100%);

    /* Multiple borders for depth */
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.06) inset,
        0 50px 100px -20px rgba(0, 0, 0, 0.7),
        0 30px 60px -30px var(--glow-color-primary),
        0 0 120px var(--glow-color-shadow);

    border-radius: 32px;

    /* Layout */
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* GPU acceleration */
    will-change: transform, opacity;
    backface-visibility: hidden;
    transform-style: preserve-3d;

    /* FLIP Animation - Initial state */
    transform: scale(0.3) translate(var(--start-x, 0), var(--start-y, 0));
    opacity: 0;

    /* Smooth spring animation */
    transition:
        transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Final state - Full scale */
.project-modal.open .modal-container {
    transform: scale(1) translate(0, 0);
    opacity: 1;
}

/* ========================================
   CLOSE BUTTON - MODERN STYLE
   ======================================== */

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;

    width: 48px;
    height: 48px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;

    color: var(--color-text-primary);
    cursor: pointer;

    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Hover lift effect */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.modal-close:active {
    transform: scale(0.95) rotate(90deg);
}

.modal-close svg {
    width: 22px;
    height: 22px;
    stroke-width: 2.5;
}

/* ========================================
   HERO SECTION - OVERLAPPING LAYERS (WaddleGo Style)
   ======================================== */

/* Hero Section Container - Fused header + hero */
.modal-hero-section {
    position: relative;
    width: 100%;
    min-height: 420px;
    overflow: visible; /* Allow hero to overflow */

    /* Premium gradient background - uses project color */
    background: linear-gradient(180deg,
        var(--glow-color-shadow) 0%,
        transparent 100%);

    /* Initial hidden state */
    opacity: 0;
    transform: translateY(-20px);
}

/* Animated entrance - ONLY when modal is open */
.project-modal.open .modal-hero-section {
    animation: heroSectionFadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes heroSectionFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Background Layer - Text Behind Image */
.hero-background {
    position: relative;
    z-index: 1;
    padding: 60px 48px 80px;
    text-align: center;
}

/* Category Badge - Hidden */
.modal-category {
    display: none; /* Removed per user request */
}

@keyframes badgePop {
    from {
        opacity: 0;
        transform: scale(0.5) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Title Container - GIANT and BEHIND image (3 ROWS x 3 LAYERS = 9 total) */
.modal-title {
    position: relative;
    min-height: 3.3em; /* CRITICAL: Container needs height for 3 rows of text */
    z-index: 2;

    font-size: clamp(60px, 12vw, 140px);
    font-weight: 900;
    line-height: 0.95;
    margin-bottom: 24px;

    text-transform: uppercase;
    letter-spacing: -10px;
    color: transparent; /* Hide container text */

    /* Dynamic color variables (change based on project) */
    --title-color-light: rgba(137, 207, 240, 0.5); /* Default - light blue */
    --title-color-medium: rgba(89, 127, 215, 0.35); /* Default - medium blue */
    --title-color-dark: rgba(10, 36, 99, 0.3); /* Default - dark blue */

    /* Initial hidden state */
    opacity: 0;
    transform: scale(0.8);
}

/* Animated entrance - ONLY when modal is open */
.project-modal.open .modal-title {
    animation: titleExpand 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s forwards;
}

@keyframes titleExpand {
    from {
        opacity: 0;
        transform: scale(0.8);
        letter-spacing: -10px;
    }
    to {
        opacity: 1;
        transform: scale(1);
        letter-spacing: -2px;
    }
}

/* ============================================
   BREATHING ANIMATIONS - Random Scale Effect
   ============================================ */

@keyframes breathe-slow {
    0%, 100% {
        transform: scale(1) translate(var(--offset-x, 0), var(--offset-y, 0));
    }
    50% {
        transform: scale(1.01) translate(var(--offset-x, 0), var(--offset-y, 0));
    }
}

@keyframes breathe-medium {
    0%, 100% {
        transform: scale(0.99) translate(var(--offset-x, 0), var(--offset-y, 0));
    }
    50% {
        transform: scale(1.015) translate(var(--offset-x, 0), var(--offset-y, 0));
    }
}

@keyframes breathe-fast {
    0%, 100% {
        transform: scale(1.005) translate(var(--offset-x, 0), var(--offset-y, 0));
    }
    50% {
        transform: scale(0.995) translate(var(--offset-x, 0), var(--offset-y, 0));
    }
}

/* Title Layers - Common styles + Performance Optimization */
.title-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    white-space: nowrap; /* Prevent text wrapping variations */

    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    letter-spacing: inherit;
    text-transform: inherit;

    pointer-events: none; /* Don't block interactions with floating image */

    /* Performance optimizations for smooth animation */
    will-change: transform;
    transform-origin: center center;
    backface-visibility: hidden;
    -webkit-font-smoothing: subpixel-antialiased;
    transform-style: flat; /* Prevent 3D rendering overhead */

    /* Pause breathing animations by default (performance) */
    animation-play-state: paused;
}

/* Enable breathing animations when modal is open */
.project-modal.open .title-layer {
    animation-play-state: running;
}

/* ============================================
   OFFSET VARIABLES - For preserving translate while animating scale
   ============================================ */

/* Front layers (1, 4, 7) - No offset */
.title-layer-1,
.title-layer-4,
.title-layer-7 {
    --offset-x: 0;
    --offset-y: 0;
}

/* Middle layers (2, 5, 8) - 6px offset */
.title-layer-2,
.title-layer-5,
.title-layer-8 {
    --offset-x: 6px;
    --offset-y: 6px;
}

/* Back layers (3, 6, 9) - 12px offset */
.title-layer-3,
.title-layer-6,
.title-layer-9 {
    --offset-x: 12px;
    --offset-y: 12px;
}

/* ============================================
   INDIVIDUAL LAYER STYLES + ANIMATIONS
   ============================================ */

/* Layer 1 (front) - BRIGHTEST - No offset, most visible */
.title-layer-1 {
    z-index: 3;
    color: var(--title-color-light);
    text-shadow: 0 0 40px var(--title-color-light);

    /* Breathing animation */
    animation: breathe-slow 4.2s ease-in-out infinite;
}

/* Layer 2 (middle) - VISIBLE - Offset down-right */
.title-layer-2 {
    z-index: 2;
    color: var(--title-color-medium);
    filter: blur(0.4px);
    text-shadow: 0 0 35px var(--title-color-medium);

    /* Breathing animation */
    animation: breathe-medium 3.7s ease-in-out 0.3s infinite;
}

/* Layer 3 (back) - SUBTLE BUT VISIBLE - Most offset and blur */
.title-layer-3 {
    z-index: 1;
    color: var(--title-color-dark);
    filter: blur(1px);
    text-shadow: 0 0 50px var(--title-color-dark);

    /* Breathing animation */
    animation: breathe-fast 3.1s ease-in-out 0.6s infinite;
}

/* ============================================
   SECOND ROW - Title repeated below (layers 4-6)
   ============================================ */

/* Position second row below first row */
.title-layer-4,
.title-layer-5,
.title-layer-6 {
    top: 1.1em; /* Positioned below first row */
}

/* Layer 4 (front of second row) - BRIGHTEST - No offset */
.title-layer-4 {
    z-index: 3;
    color: var(--title-color-light);
    text-shadow: 0 0 40px var(--title-color-light);

    /* Breathing animation */
    animation: breathe-fast 3.9s ease-in-out 0.9s infinite;
}

/* Layer 5 (middle of second row) - VISIBLE - Offset down-right */
.title-layer-5 {
    z-index: 2;
    color: var(--title-color-medium);
    filter: blur(0.4px);
    text-shadow: 0 0 35px var(--title-color-medium);

    /* Breathing animation */
    animation: breathe-slow 4.5s ease-in-out 1.2s infinite;
}

/* Layer 6 (back of second row) - SUBTLE BUT VISIBLE - Most offset and blur */
.title-layer-6 {
    z-index: 1;
    color: var(--title-color-dark);
    filter: blur(1px);
    text-shadow: 0 0 50px var(--title-color-dark);

    /* Breathing animation */
    animation: breathe-medium 3.3s ease-in-out 1.5s infinite;
}

/* ============================================
   THIRD ROW - Title repeated again (layers 7-9)
   ============================================ */

/* Position third row below second row */
.title-layer-7,
.title-layer-8,
.title-layer-9 {
    top: 2.2em; /* Positioned below second row */
}

/* Layer 7 (front of third row) - BRIGHTEST - No offset */
.title-layer-7 {
    z-index: 3;
    color: var(--title-color-light);
    text-shadow: 0 0 40px var(--title-color-light);

    /* Breathing animation */
    animation: breathe-medium 4.1s ease-in-out 1.8s infinite;
}

/* Layer 8 (middle of third row) - VISIBLE - Offset down-right */
.title-layer-8 {
    z-index: 2;
    color: var(--title-color-medium);
    filter: blur(0.4px);
    text-shadow: 0 0 35px var(--title-color-medium);

    /* Breathing animation */
    animation: breathe-fast 3.5s ease-in-out 2.1s infinite;
}

/* Layer 9 (back of third row) - SUBTLE BUT VISIBLE - Most offset and blur */
.title-layer-9 {
    z-index: 1;
    color: var(--title-color-dark);
    filter: blur(1px);
    text-shadow: 0 0 50px var(--title-color-dark);

    /* Breathing animation */
    animation: breathe-slow 4.8s ease-in-out 2.4s infinite;
}

/* ============================================
   PROJECT-SPECIFIC COLOR SCHEMES
   Colors extracted from each project logo background
   All blur layers use the SAME base color, only opacity changes
   ============================================ */

/* WaddleGo (project-1) - Light Blue #B0CFE1 from penguin background */
.modal-container[data-project="project-1"] {
    /* Title colors - ALL use same blue, HIGH visibility */
    --title-color-light: rgba(176, 207, 225, 0.85);
    --title-color-medium: rgba(176, 207, 225, 0.7);
    --title-color-dark: rgba(176, 207, 225, 0.5);
    /* Glow colors - ALL use same blue */
    --glow-color-primary: rgba(176, 207, 225, 0.7);
    --glow-color-secondary: rgba(176, 207, 225, 0.5);
    --glow-color-shadow: rgba(176, 207, 225, 0.3);
}

/* Pill DB (project-2) - Navy Blue #2A4280 from database stack background */
.modal-container[data-project="project-2"] {
    /* Title colors - ALL use same navy, HIGH visibility */
    --title-color-light: rgba(42, 66, 128, 0.85);
    --title-color-medium: rgba(42, 66, 128, 0.7);
    --title-color-dark: rgba(42, 66, 128, 0.5);
    /* Glow colors - ALL use same navy */
    --glow-color-primary: rgba(42, 66, 128, 0.7);
    --glow-color-secondary: rgba(42, 66, 128, 0.5);
    --glow-color-shadow: rgba(42, 66, 128, 0.3);
}

/* AR (project-3) - Default blue gradient (uses emoji, no image) */
.modal-container[data-project="project-3"] {
    /* Title colors - Keep gradient effect for AR, HIGH visibility */
    --title-color-light: rgba(89, 127, 215, 0.85);
    --title-color-medium: rgba(89, 127, 215, 0.7);
    --title-color-dark: rgba(89, 127, 215, 0.5);
    /* Glow colors */
    --glow-color-primary: rgba(89, 127, 215, 0.7);
    --glow-color-secondary: rgba(89, 127, 215, 0.5);
    --glow-color-shadow: rgba(89, 127, 215, 0.3);
}

/* Syncycle (project-4) - Purple #444C99 from clock background */
.modal-container[data-project="project-4"] {
    /* Title colors - ALL use same purple, HIGH visibility */
    --title-color-light: rgba(68, 76, 153, 0.85);
    --title-color-medium: rgba(68, 76, 153, 0.7);
    --title-color-dark: rgba(68, 76, 153, 0.5);
    /* Glow colors - ALL use same purple */
    --glow-color-primary: rgba(68, 76, 153, 0.7);
    --glow-color-secondary: rgba(68, 76, 153, 0.5);
    --glow-color-shadow: rgba(68, 76, 153, 0.3);
}

/* LinkUp (project-5) - Green from person icon background - ADJUSTED for true green */
.modal-container[data-project="project-5"] {
    /* Title colors - ALL use PURE GREEN, reduced blue component */
    --title-color-light: rgba(85, 180, 120, 0.85);
    --title-color-medium: rgba(85, 180, 120, 0.7);
    --title-color-dark: rgba(85, 180, 120, 0.5);
    /* Glow colors - ALL use PURE GREEN */
    --glow-color-primary: rgba(85, 180, 120, 0.7);
    --glow-color-secondary: rgba(85, 180, 120, 0.5);
    --glow-color-shadow: rgba(85, 180, 120, 0.3);
}

/* ============================================
   PROJECT-SPECIFIC TYPOGRAPHY OVERRIDES
   ============================================ */

/* PillDB - Increased letter spacing for better readability */
.modal-container[data-project="project-2"] .modal-title {
    letter-spacing: clamp(15px, 5vw, 30px) !important;
}

/* Override animation for PillDB to maintain increased spacing */
.project-modal.open .modal-container[data-project="project-2"] .modal-title {
    animation: titleExpandPillDB 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s forwards;
}

@keyframes titleExpandPillDB {
    from {
        opacity: 0;
        transform: scale(0.8);
        letter-spacing: 0px;
    }
    to {
        opacity: 1;
        transform: scale(1);
        letter-spacing: clamp(15px, 5vw, 30px);
    }
}

/* LinkUp - Increased letter spacing for better readability */
.modal-container[data-project="project-5"] .modal-title {
    letter-spacing: clamp(15px, 5vw, 30px) !important;
}

/* Override animation for LinkUp to maintain increased spacing */
.project-modal.open .modal-container[data-project="project-5"] .modal-title {
    animation: titleExpandLinkUp 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s forwards;
}

@keyframes titleExpandLinkUp {
    from {
        opacity: 0;
        transform: scale(0.8);
        letter-spacing: 0px;
    }
    to {
        opacity: 1;
        transform: scale(1);
        letter-spacing: clamp(15px, 5vw, 30px);
    }
}

/* Tagline - Hidden */
.modal-tagline {
    display: none; /* Removed per user request */
}

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

/* ========================================
   HERO IMAGE/ICON - FLOATING ABOVE
   ======================================== */

.modal-hero {
    position: absolute;
    bottom: 150px; /* Raised up from bottom */
    left: 50%;
    z-index: 20; /* ABOVE everything */

    /* ULTRA RESPONSIVE SIZE - usa el menor entre vw y vh para mantener proporción */
    width: clamp(280px, min(40vw, 35vh), 420px);
    height: clamp(280px, min(40vw, 35vh), 420px);

    display: flex;
    align-items: center;
    justify-content: center;

    /* Allow shadow to show */
    overflow: visible;

    /* Initial hidden state */
    opacity: 0;
    transform: translateX(-50%) translateY(80px) scale(0.5) rotate(-8deg);
}

/* Animated entrance - ONLY when modal is open */
.project-modal.open .modal-hero {
    animation: heroFloat 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) 1.6s forwards;
}

@keyframes heroFloat {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(80px) scale(0.5) rotate(-8deg);
    }
    50% {
        opacity: 0.7;
        transform: translateX(-50%) translateY(-10px) scale(1.05) rotate(2deg);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1) rotate(0deg);
    }
}

/* Glow effect behind hero - RESPONSIVE blur */
.modal-hero::before {
    content: '';
    position: absolute;
    inset: -30%;
    z-index: -1;

    background: radial-gradient(circle,
        var(--glow-color-primary) 0%,
        var(--glow-color-secondary) 40%,
        transparent 70%);

    /* Blur responsive - escala con viewport */
    filter: blur(clamp(40px, 7vw, 70px));
    opacity: 0.8;
}

/* Hero Image */
.modal-hero img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Mantener aspecto */
    object-position: center;
    border-radius: clamp(16px, 3vw, 32px); /* Responsive border-radius */

    /* Image enhancement */
    filter: contrast(1.08) saturate(1.15);

    /* DEEP shadow for floating effect - RESPONSIVE */
    box-shadow:
        0 clamp(40px, 8vw, 60px) clamp(80px, 15vw, 120px) rgba(0, 0, 0, 0.7),
        0 clamp(20px, 4vw, 30px) clamp(40px, 8vw, 60px) rgba(0, 0, 0, 0.5),
        0 0 clamp(60px, 12vw, 100px) var(--glow-color-primary);
}

/* Hero Icon (emoji) */
.modal-hero .hero-icon {
    /* ULTRA RESPONSIVE - escala con el container, 52% del tamaño del hero */
    font-size: clamp(145px, min(21vw, 18vh), 220px);

    /* Massive glow - RESPONSIVE shadows */
    filter:
        drop-shadow(0 clamp(12px, 2.5vw, 20px) clamp(30px, 6vw, 50px) var(--glow-color-primary))
        drop-shadow(0 0 clamp(50px, 10vw, 80px) var(--glow-color-primary));

    /* Continuous floating animation */
    animation: iconFloatContinuous 4s ease-in-out infinite;
}

@keyframes iconFloatContinuous {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        /* Floating responsive - más sutil en mobile */
        transform: translateY(clamp(-15px, -3vh, -25px)) scale(1.03);
    }
}

/* ========================================
   MODAL CONTENT - SCROLLABLE (now contains hero section)
   ======================================== */

.modal-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;

    /* No padding - hero section has its own */
    padding: 0;

    position: relative;
    z-index: 5; /* Below hero but above background */

    /* Smooth scroll */
    scroll-behavior: smooth;
    overscroll-behavior-y: contain;

    /* Hide scrollbar but keep functionality */
    scrollbar-width: thin;
    scrollbar-color: var(--glow-color-secondary) transparent;
}

/* Custom scrollbar - iOS style */
.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--glow-color-secondary);
    border-radius: 10px;

    transition: background 0.3s ease;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--glow-color-primary);
}

/* ========================================
   PROJECT META INFO - MODERN GRID
   ======================================== */

.modal-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 48px;

    /* Reduced padding since logo is higher now */
    padding: 40px 48px 0 48px;

    /* Initial hidden state */
    opacity: 0;
    transform: translateY(30px);
}

/* Animated entrance - ONLY when modal is open */
.project-modal.open .modal-meta {
    animation: slideInUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s forwards;
}

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

.meta-item {
    position: relative;
    padding: 20px;

    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.04) 0%,
        rgba(255, 255, 255, 0.02) 100%);

    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;

    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.meta-item:hover {
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.06) 0%,
        rgba(255, 255, 255, 0.03) 100%);
    border-color: var(--glow-color-primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--glow-color-shadow);
}

.meta-label {
    display: block;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: 8px;
}

.meta-value {
    font-size: 16px;
    color: var(--color-text-primary);
    font-weight: 600;
}

/* ========================================
   CONTENT SECTIONS - MODERN CARDS
   ======================================== */

.modal-section {
    margin-bottom: 48px;
    padding: 0 48px; /* Horizontal padding for sections */

    /* Initial hidden state */
    opacity: 0;
    transform: translateY(30px);
}

/* Animated entrance - ONLY when modal is open */
.project-modal.open .modal-section {
    animation: slideInUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.project-modal.open .modal-section:nth-child(1) { animation-delay: 0.5s; }
.project-modal.open .modal-section:nth-child(2) { animation-delay: 0.6s; }
.project-modal.open .modal-section:nth-child(3) { animation-delay: 0.7s; }
.project-modal.open .modal-section:nth-child(4) { animation-delay: 0.8s; }
.project-modal.open .modal-section:nth-child(5) { animation-delay: 0.9s; }
.project-modal.open .modal-section:nth-child(6) { animation-delay: 1.0s; }

.modal-section:last-child {
    margin-bottom: 0;
    padding-bottom: 48px; /* Bottom padding for last section */
}

/* Section titles - Clean and simple */
.section-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 24px;
    color: var(--color-text-primary);
    letter-spacing: -0.5px;
}

.section-text {
    font-size: 16px;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.8);
}

/* ========================================
   FEATURES GRID - PREMIUM CARDS
   ======================================== */

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.feature-item {
    position: relative;
    padding: 28px;

    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.02) 100%);

    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;

    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);

    overflow: hidden;
}

/* Hover glow effect */
.feature-item::before {
    content: '';
    position: absolute;
    inset: 0;

    background: var(--glow-color-secondary);

    opacity: 0;
    transition: opacity 0.3s ease;
}

.feature-item:hover::before {
    opacity: 1;
}

.feature-item:hover {
    border-color: var(--glow-color-primary);
    transform: translateY(-4px);
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.25),
        0 0 40px var(--glow-color-shadow);
}

.feature-title {
    font-size: 19px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--color-text-primary);

    position: relative;
    z-index: 1;
}

.feature-description {
    font-size: 15px;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.7);

    position: relative;
    z-index: 1;
}

/* ========================================
   TECH STACK - VIBRANT PILLS
   ======================================== */

.tech-stack-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.tech-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 24px;

    background: var(--glow-color-shadow);

    border: 1px solid var(--glow-color-secondary);
    border-radius: 16px;

    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);

    box-shadow: 0 4px 12px var(--glow-color-shadow);

    cursor: default;
}

.tech-item:hover {
    background: var(--glow-color-secondary);

    border-color: var(--glow-color-primary);
    transform: translateY(-3px) scale(1.05);

    box-shadow:
        0 8px 24px var(--glow-color-secondary),
        0 0 30px var(--glow-color-primary);
}

.tech-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--title-color-light);
    letter-spacing: 0.3px;
}

.tech-category {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

/* ========================================
   METRICS LIST - CHECK MARKS
   ======================================== */

.metrics-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.metrics-list li {
    position: relative;
    padding: 16px 16px 16px 56px;

    background: linear-gradient(135deg,
        rgba(0, 255, 127, 0.05) 0%,
        rgba(0, 255, 127, 0.02) 100%);

    border: 1px solid rgba(0, 255, 127, 0.15);
    border-radius: 14px;

    font-size: 15px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);

    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.metrics-list li:hover {
    background: linear-gradient(135deg,
        rgba(0, 255, 127, 0.08) 0%,
        rgba(0, 255, 127, 0.04) 100%);

    border-color: rgba(0, 255, 127, 0.3);
    transform: translateX(4px);
}

.metrics-list li::before {
    content: '✓';
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);

    width: 32px;
    height: 32px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: linear-gradient(135deg,
        rgba(0, 255, 127, 0.25) 0%,
        rgba(0, 255, 127, 0.15) 100%);

    border: 1px solid rgba(0, 255, 127, 0.4);
    border-radius: 50%;

    font-size: 14px;
    font-weight: 900;
    color: rgba(0, 255, 127, 1);

    box-shadow: 0 0 20px rgba(0, 255, 127, 0.4);
}

/* ========================================
   GALLERY GRID - IMAGE SHOWCASE
   ======================================== */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.gallery-item {
    aspect-ratio: 16 / 9;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;

    border: 1px solid rgba(255, 255, 255, 0.1);

    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.gallery-item:hover {
    transform: scale(1.05) translateY(-4px);
    border-color: var(--glow-color-primary);

    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.3),
        0 0 40px var(--glow-color-primary);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;

    filter: contrast(1.05) saturate(1.1);
    transition: filter 0.3s ease;
}

.gallery-item:hover img {
    filter: contrast(1.1) saturate(1.2);
}

/* ========================================
   MODAL FOOTER - ACTION BUTTONS
   ======================================== */

.modal-footer {
    padding: 32px 48px;

    background: linear-gradient(180deg,
        transparent 0%,
        rgba(0, 0, 0, 0.3) 100%);

    border-top: 1px solid var(--glow-color-shadow);

    /* Center the button */
    display: flex;
    justify-content: center;
    align-items: center;

    /* Initial hidden state */
    opacity: 0;
    transform: translateY(30px);
}

/* Animated entrance - ONLY when modal is open */
.project-modal.open .modal-footer {
    animation: slideInUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 1.1s forwards;
}

.modal-actions {
    display: none; /* Hidden per user request */
}

/* ========================================
   LET'S BUILD BUTTON - PREMIUM CTA
   ======================================== */

.lets-build-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;

    padding: 20px 48px;
    min-width: 280px;

    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;

    background: var(--glow-color-primary);
    color: white;

    border: 2px solid var(--glow-color-primary);
    border-radius: 20px;

    cursor: pointer;
    overflow: hidden;

    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

    box-shadow:
        0 8px 32px var(--glow-color-secondary),
        0 0 60px var(--glow-color-shadow),
        0 0 0 0 var(--glow-color-primary);
}

/* Glow effect on hover */
.lets-build-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.2) 0%,
        rgba(255, 255, 255, 0) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lets-build-btn:hover::before {
    opacity: 1;
}

.lets-build-btn:hover {
    transform: translateY(-4px) scale(1.05);
    border-color: rgba(255, 255, 255, 0.5);

    box-shadow:
        0 16px 48px var(--glow-color-primary),
        0 0 80px var(--glow-color-primary),
        0 0 0 8px rgba(255, 255, 255, 0.1);
}

.lets-build-btn:active {
    transform: translateY(-2px) scale(1.02);
}

/* Button text */
.lets-build-btn .btn-text {
    position: relative;
    z-index: 1;
}

/* Arrow animation */
.lets-build-btn .btn-arrow {
    position: relative;
    z-index: 1;
    font-size: 24px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lets-build-btn:hover .btn-arrow {
    transform: translateX(8px);
}

/* Action buttons - Premium style */
.modal-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    padding: 16px 32px;
    min-width: 160px;

    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    border-radius: 16px;

    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;

    letter-spacing: 0.3px;
}

/* Primary button - Vibrant gradient */
.modal-action-btn.primary {
    background: var(--glow-color-primary);

    color: white;
    border: 1px solid var(--glow-color-primary);

    box-shadow:
        0 8px 24px var(--glow-color-secondary),
        0 0 40px var(--glow-color-shadow);
}

.modal-action-btn.primary:hover {
    transform: translateY(-3px) scale(1.05);

    box-shadow:
        0 12px 32px var(--glow-color-primary),
        0 0 60px var(--glow-color-primary);
}

.modal-action-btn.primary:active {
    transform: translateY(-1px) scale(1.02);
}

/* Secondary button - Subtle */
.modal-action-btn.secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--color-text-primary);
    border: 1px solid rgba(255, 255, 255, 0.15);

    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal-action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-3px);

    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.modal-action-btn.secondary:active {
    transform: translateY(-1px);
}

.modal-action-btn svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   BODY SCROLL LOCK
   ======================================== */

body.modal-open {
    overflow: hidden;
    padding-right: var(--scrollbar-width, 0);
}

/* ========================================
   PROJECT-SPECIFIC LAYOUT VISIBILITY
   Performance optimized: CSS-based visibility control
   ======================================== */

/* Hide all project-specific sections by default */
/* WaddleGo generic sections - hide all except when show-waddlego */
.modal-section-video-right:not([class*="pilldb-"]):not([class*="linkup-"]):not([class*="linkmesh-"]):not([class*="linkfence-"]):not([class*="linkfinder-"]):not([class*="syncycle-"]):not([class*="ar-"]),
.modal-section-video-left:not([class*="pilldb-"]):not([class*="linkup-"]):not([class*="linkmesh-"]):not([class*="linkfence-"]):not([class*="linkfinder-"]):not([class*="syncycle-"]):not([class*="ar-"]),
/* PillDB specific sections */
.modal-dual-videos-section,
.pilldb-ai-recognition,
.pilldb-express-sales,
.pilldb-selective-inventory,
/* LinkUp specific sections */
.linkup-logo-section,
.linkup-mesh-section,
.linkup-safezones-section,
.linkup-emergency-section,
.linkfence-header-section,
.linkfence-interactive-section,
.linkfence-monitoring-section,
.linkfinder-header-section,
.linkfinder-navigation-section,
.linkmesh-header-section,
.linkmesh-groups-section,
.linkmesh-broadcast-section,
.linkmesh-persistence-section,
/* Syncycle specific sections */
.syncycle-wake-section,
.syncycle-sleep-section,
/* AR Navigator specific sections */
.ar-educational-section,
.ar-marketing-section,
.ar-entertainment-section,
.ar-tourism-section,
.ar-marketing2-section {
    display: none !important;
}

/* WaddleGo (project-1): Show WaddleGo video layouts */
.modal-container.show-waddlego .modal-section-video-right:not([class*="pilldb-"]):not([class*="linkup-"]):not([class*="linkmesh-"]):not([class*="linkfence-"]):not([class*="linkfinder-"]):not([class*="syncycle-"]):not([class*="ar-"]),
.modal-container.show-waddlego .modal-section-video-left:not([class*="pilldb-"]):not([class*="linkup-"]):not([class*="linkmesh-"]):not([class*="linkfence-"]):not([class*="linkfinder-"]):not([class*="syncycle-"]):not([class*="ar-"]) {
    display: grid !important;
}

/* PillDB (project-2): Show PillDB sections */
.modal-container.show-pilldb .modal-dual-videos-section,
.modal-container.show-pilldb .pilldb-ai-recognition,
.modal-container.show-pilldb .pilldb-express-sales,
.modal-container.show-pilldb .pilldb-selective-inventory {
    display: grid !important;
}

/* AR Navigator (project-3): Show AR sections */
.modal-container.show-ar .ar-educational-section,
.modal-container.show-ar .ar-marketing-section,
.modal-container.show-ar .ar-entertainment-section,
.modal-container.show-ar .ar-tourism-section,
.modal-container.show-ar .ar-marketing2-section {
    display: grid !important;
}

/* LinkUp (project-5): Show LinkUp sections */
.modal-container.show-linkup .linkup-logo-section,
.modal-container.show-linkup .linkfence-header-section,
.modal-container.show-linkup .linkfinder-header-section,
.modal-container.show-linkup .linkmesh-header-section {
    display: block !important;
}

.modal-container.show-linkup .linkup-mesh-section,
.modal-container.show-linkup .linkup-safezones-section,
.modal-container.show-linkup .linkup-emergency-section,
.modal-container.show-linkup .linkfence-interactive-section,
.modal-container.show-linkup .linkfence-monitoring-section,
.modal-container.show-linkup .linkfinder-navigation-section,
.modal-container.show-linkup .linkmesh-groups-section,
.modal-container.show-linkup .linkmesh-broadcast-section,
.modal-container.show-linkup .linkmesh-persistence-section {
    display: grid !important;
}

/* Syncycle (project-4): Show Syncycle sections */
.modal-container.show-syncycle .syncycle-wake-section,
.modal-container.show-syncycle .syncycle-sleep-section {
    display: grid !important;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Mobile (<768px) */
@media (max-width: 768px) {
    .modal-container {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .modal-hero-section {
        min-height: 400px; /* Reducido para layout más compacto */
    }

    .hero-background {
        padding: 50px 24px 70px; /* Optimizado para logo más alto */
    }

    .modal-category {
        padding: 8px 18px;
        font-size: 11px;
        margin-bottom: 24px;
    }

    .modal-title {
        font-size: clamp(48px, 15vw, 72px);
        letter-spacing: -1px;
        min-height: 2.8em;
    }

    /* Adjust layer offsets for mobile */
    .title-layer-2,
    .title-layer-5,
    .title-layer-8 {
        --offset-x: 4px;
        --offset-y: 4px;
    }

    .title-layer-3,
    .title-layer-6,
    .title-layer-9 {
        --offset-x: 8px;
        --offset-y: 8px;
    }

    /* Reduce blur for mobile performance */
    .title-layer-2,
    .title-layer-5,
    .title-layer-8 {
        filter: blur(0.5px);
    }

    .title-layer-3,
    .title-layer-6,
    .title-layer-9 {
        filter: blur(1px);
    }

    .modal-tagline {
        font-size: 16px;
        max-width: 90%;
    }

    .modal-hero {
        /* ULTRA RESPONSIVE - usa el menor entre ancho y alto de viewport */
        width: clamp(260px, min(75vw, 32vh), 340px);
        height: clamp(260px, min(75vw, 32vh), 340px);
        bottom: clamp(50px, 12vh, 80px); /* Logo MÁS ARRIBA - responsive con viewport */
    }

    .modal-hero .hero-icon {
        /* Escala proporcionalmente - 50% del container */
        font-size: clamp(130px, min(37vw, 16vh), 170px);
    }

    .modal-hero img {
        /* Asegurar que las imágenes también escalen bien */
        max-width: 100%;
        max-height: 100%;
        width: 100%;
        height: 100%;
    }

    .modal-content {
        padding: 50px 24px 32px; /* Optimizado padding top */
        margin-top: 0;
    }

    .modal-meta {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 35px 48px 0 48px; /* Reducido padding top */
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .section-title {
        font-size: 24px;
    }

    .modal-footer {
        padding: 24px;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-action-btn {
        width: 100%;
    }

    .lets-build-btn {
        width: 100%;
        min-width: auto;
        padding: 18px 32px;
        font-size: 16px;
    }

    .metrics-list {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   LARGE MOBILE / SMALL TABLET (481px-768px)
   ======================================== */
@media (min-width: 481px) and (max-width: 768px) {
    .modal-hero-section {
        min-height: clamp(420px, 90vh, 480px);
    }

    .hero-background {
        padding: clamp(48px, 9vh, 55px) clamp(24px, 4vw, 32px) clamp(75px, 13vh, 90px);
    }

    .modal-hero {
        /* ULTRA RESPONSIVE - equilibrio entre width/height en pantallas medianas */
        width: clamp(290px, min(65vw, 34vh), 370px);
        height: clamp(290px, min(65vw, 34vh), 370px);
        bottom: clamp(55px, 13vh, 90px); /* Logo alto en pantallas medianas */
    }

    .modal-hero .hero-icon {
        /* Escala - 51% del container */
        font-size: clamp(145px, min(33vw, 17vh), 185px);
    }

    .modal-hero img {
        max-width: 100%;
        max-height: 100%;
        width: 100%;
        height: 100%;
    }

    .modal-content {
        padding: clamp(52px, 10vh, 60px) clamp(24px, 4vw, 32px) 32px;
    }

    .modal-meta {
        padding: clamp(38px, 7vh, 45px) clamp(40px, 6vw, 48px) 0;
    }
}

/* Tablet (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .modal-container {
        max-width: 90%;
    }

    .modal-hero-section {
        min-height: clamp(480px, 95vh, 540px); /* Responsive */
    }

    .hero-background {
        padding: clamp(52px, 10vh, 60px) 40px clamp(120px, 18vh, 150px); /* Responsive padding */
    }

    .modal-title {
        font-size: clamp(70px, 10vw, 110px);
        min-height: 3em;
    }

    /* Adjust layer offsets for tablet */
    .title-layer-2,
    .title-layer-5,
    .title-layer-8 {
        --offset-x: 5px;
        --offset-y: 5px;
    }

    .title-layer-3,
    .title-layer-6,
    .title-layer-9 {
        --offset-x: 10px;
        --offset-y: 10px;
    }

    /* Hide third depth layer on tablets for better performance */
    .title-layer-3,
    .title-layer-6,
    .title-layer-9 {
        opacity: 0.5;
        filter: blur(1.5px);
    }

    .modal-hero {
        /* ULTRA RESPONSIVE - tablet usa más viewport width */
        width: clamp(350px, min(38vw, 36vh), 420px);
        height: clamp(350px, min(38vw, 36vh), 420px);
        bottom: clamp(100px, 15vh, 140px); /* Logo bien alto en tablet */
    }

    .modal-hero .hero-icon {
        /* Escala - 52% del container */
        font-size: clamp(175px, min(20vw, 19vh), 210px);
    }

    .modal-hero img {
        max-width: 100%;
        max-height: 100%;
        width: 100%;
        height: 100%;
    }

    .modal-content {
        padding: clamp(85px, 12vh, 100px) 40px 40px; /* Responsive */
    }
}

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

.modal-close:focus-visible,
.modal-action-btn:focus-visible {
    outline: 3px solid var(--glow-color-primary);
    outline-offset: 3px;
}

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .modal-container,
    .modal-backdrop,
    .modal-hero-section,
    .hero-background,
    .modal-category,
    .modal-title,
    .modal-tagline,
    .modal-hero,
    .modal-meta,
    .modal-section,
    .modal-footer,
    .feature-item,
    .tech-item,
    .gallery-item,
    .modal-action-btn {
        animation: none !important;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }

    .modal-container {
        transform: none !important;
    }

    .modal-hero {
        position: relative;
        bottom: 0;
        transform: none !important;
        margin: 40px auto;
    }

    .modal-content {
        margin-top: 0;
    }

    .feature-item:hover,
    .tech-item:hover,
    .gallery-item:hover,
    .modal-action-btn:hover {
        transform: none;
    }
}

/* ========================================
   iPHONE XR / 11 OPTIMIZATION (376px-480px)
   ======================================== */
@media (min-width: 376px) and (max-width: 480px) {
    /* Hero Section - Optimizado */
    .modal-hero-section {
        min-height: clamp(380px, 85vh, 440px); /* Responsive height */
    }

    .hero-background {
        padding: clamp(42px, 8vh, 48px) 20px clamp(65px, 12vh, 80px); /* Responsive padding */
    }

    /* Title - Medium size */
    .modal-title {
        font-size: clamp(42px, 13vw, 64px);
        letter-spacing: clamp(-2px, -0.3vw, -1px);
        min-height: 2.6em;
    }

    /* Optimized layer offsets for iPhone XR */
    .title-layer-2,
    .title-layer-5,
    .title-layer-8 {
        --offset-x: 4px;
        --offset-y: 4px;
    }

    .title-layer-3,
    .title-layer-6,
    .title-layer-9 {
        --offset-x: 7px;
        --offset-y: 7px;
    }

    /* Reduced blur for iPhone XR performance */
    .title-layer-2,
    .title-layer-5,
    .title-layer-8 {
        filter: blur(0.4px);
    }

    .title-layer-3,
    .title-layer-6,
    .title-layer-9 {
        filter: blur(0.8px);
    }

    /* Hero Image - ULTRA RESPONSIVE con viewport dual */
    .modal-hero {
        width: clamp(240px, min(62vw, 28vh), 290px);
        height: clamp(240px, min(62vw, 28vh), 290px);
        bottom: clamp(45px, 11vh, 70px); /* Logo MÁS ARRIBA - fluido con viewport */
    }

    .modal-hero .hero-icon {
        /* Escala - 49% del container */
        font-size: clamp(115px, min(30vw, 14vh), 142px);
    }

    .modal-hero img {
        max-width: 100%;
        max-height: 100%;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    /* Content - Optimizado */
    .modal-content {
        padding: clamp(45px, 9vh, 55px) 20px 28px; /* Responsive padding */
    }

    /* Meta - Responsive padding */
    .modal-meta {
        padding: clamp(32px, 6vh, 40px) 24px 0 24px;
        gap: 12px;
    }

    .meta-item {
        padding: 18px;
    }

    /* Sections - Medium padding */
    .modal-section {
        padding: 0 24px;
        margin-bottom: 40px;
    }

    /* Section Titles */
    .section-title {
        font-size: 22px;
        padding-left: 18px;
    }

    /* Features */
    .feature-item {
        padding: 24px;
    }

    .feature-title {
        font-size: 18px;
    }

    /* Tech Stack */
    .tech-item {
        padding: 14px 20px;
    }

    .tech-name {
        font-size: 14px;
    }

    .tech-category {
        font-size: 10px;
    }

    /* Footer */
    .modal-footer {
        padding: 24px 20px;
    }

    .lets-build-btn {
        padding: 19px 36px;
        font-size: 16px;
    }

    /* Navigation - 44px touch targets */
    .carousel-nav {
        width: 44px;
        height: 44px;
    }
}

/* ========================================
   EXTRA SMALL DEVICES (<320px) - iPhone 5/SE (1st gen)
   ======================================== */
@media (max-width: 320px) {
    .modal-hero-section {
        min-height: clamp(320px, 75vh, 360px);
    }

    .hero-background {
        padding: clamp(35px, 6vh, 40px) 12px clamp(55px, 10vh, 65px);
    }

    .modal-title {
        font-size: clamp(32px, 11vw, 48px);
        letter-spacing: clamp(-2px, -0.5vw, -1px);
        min-height: 2em;
    }

    .title-layer-7,
    .title-layer-8,
    .title-layer-9 {
        display: none;
    }

    .modal-hero {
        /* ULTRA RESPONSIVE - pantallas muy pequeñas */
        width: clamp(190px, min(52vw, 24vh), 240px);
        height: clamp(190px, min(52vw, 24vh), 240px);
        bottom: clamp(30px, 9vh, 50px); /* Compacto pero visible */
    }

    .modal-hero .hero-icon {
        /* Escala - 47% del container */
        font-size: clamp(90px, min(24vw, 11vh), 115px);
    }

    .modal-hero img {
        max-width: 100%;
        max-height: 100%;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .modal-content {
        padding: clamp(35px, 7vh, 45px) 12px 20px;
    }

    .modal-meta {
        padding: clamp(24px, 4vh, 32px) 16px 0;
        gap: 8px;
        grid-template-columns: 1fr; /* Single column en pantallas muy pequeñas */
    }

    .section-title {
        font-size: 18px;
    }

    .section-text {
        font-size: 13px;
    }
}

/* ========================================
   iPHONE SE OPTIMIZATION (321px-375px)
   ======================================== */
@media (min-width: 321px) and (max-width: 375px) {
    /* Container */
    .modal-container {
        border-radius: 0;
    }

    /* Hero Section - Compact y responsive */
    .modal-hero-section {
        min-height: clamp(350px, 80vh, 400px); /* Responsive height */
    }

    .hero-background {
        padding: clamp(38px, 7vh, 44px) 16px clamp(60px, 11vh, 75px); /* Responsive padding */
    }

    /* Title - Smaller and tighter */
    .modal-title {
        font-size: clamp(36px, 12vw, 56px);
        letter-spacing: clamp(-2px, -0.4vw, -1px);
        min-height: 2.2em;
    }

    /* Simplify to 6 layers (2 rows) instead of 9 */
    .title-layer-7,
    .title-layer-8,
    .title-layer-9 {
        display: none;
    }

    /* Tighter layer offsets */
    .title-layer-2,
    .title-layer-5 {
        --offset-x: 3px;
        --offset-y: 3px;
    }

    .title-layer-3,
    .title-layer-6 {
        --offset-x: 6px;
        --offset-y: 6px;
    }

    /* Minimal blur for iPhone SE performance */
    .title-layer-2,
    .title-layer-5 {
        filter: blur(0.3px);
    }

    .title-layer-3,
    .title-layer-6 {
        filter: blur(0.6px);
    }

    /* Hero Image - ULTRA RESPONSIVE y MÁS ARRIBA */
    .modal-hero {
        width: clamp(210px, min(56vw, 26vh), 270px);
        height: clamp(210px, min(56vw, 26vh), 270px);
        bottom: clamp(35px, 10vh, 60px); /* Logo MÁS ARRIBA - adaptativo */
    }

    .modal-hero .hero-icon {
        /* Escala - 48% del container */
        font-size: clamp(100px, min(27vw, 12.5vh), 130px);
    }

    .modal-hero img {
        max-width: 100%;
        max-height: 100%;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    /* Content - Responsive padding */
    .modal-content {
        padding: clamp(40px, 8vh, 50px) 16px 24px; /* Responsive top padding */
    }

    /* Meta - Responsive padding */
    .modal-meta {
        padding: clamp(28px, 5vh, 36px) 20px 0 20px;
        gap: 10px;
    }

    .meta-item {
        padding: 16px;
    }

    .meta-label {
        font-size: 10px;
    }

    .meta-value {
        font-size: 14px;
    }

    /* Sections - Less padding */
    .modal-section {
        padding: 0 20px;
        margin-bottom: 36px;
    }

    /* Section Titles - Smaller */
    .section-title {
        font-size: 20px;
        padding-left: 16px;
        margin-bottom: 20px;
    }

    .section-title::before {
        width: 4px;
    }

    .section-text {
        font-size: 14px;
        line-height: 1.7;
    }

    /* Features - Smaller padding */
    .feature-item {
        padding: 20px;
    }

    .feature-title {
        font-size: 17px;
        margin-bottom: 10px;
    }

    .feature-description {
        font-size: 14px;
    }

    /* Tech Stack - Tighter */
    .tech-item {
        padding: 12px 18px;
        gap: 4px;
    }

    .tech-name {
        font-size: 14px;
    }

    .tech-category {
        font-size: 9px;
    }

    /* Metrics - Force single column */
    .metrics-list {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .metrics-list li {
        padding: 14px 14px 14px 50px;
        font-size: 14px;
    }

    .metrics-list li::before {
        width: 28px;
        height: 28px;
        font-size: 12px;
        left: 14px;
    }

    /* Gallery - Tighter */
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Footer - Less padding */
    .modal-footer {
        padding: 20px 16px;
    }

    /* Let's Build Button - Adequate touch target */
    .lets-build-btn {
        padding: 20px 32px;
        font-size: 15px;
        min-width: auto;
    }

    /* Close Button - Adjust position */
    .modal-close {
        top: 16px;
        right: 16px;
    }
}
