/* ========================================
   RESPONSIVE SYSTEM — Fluid Design
   ======================================== */

/* ========================================
   FLUID TYPOGRAPHY with clamp()
   ======================================== */

/* H1: 40px (mobile) → 64px (desktop) */
h1, .h1 {
    font-size: clamp(2.5rem, 5vw, 4rem);
    line-height: 1.15;
}

/* H2: 32px → 48px */
h2, .h2 {
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.2;
}

/* H3: 24px → 32px */
h3, .h3 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    line-height: 1.3;
}

/* H4: 20px → 24px */
h4, .h4 {
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    line-height: 1.4;
}

/* Body: 16px → 18.4px */
body, p, .body-text {
    font-size: clamp(1rem, 2vw, 1.15rem);
    line-height: 1.6;
}

/* Small: 14px → 16px */
small, .small-text {
    font-size: clamp(0.875rem, 1.5vw, 1rem);
}

/* ========================================
   FLUID SPACING
   ======================================== */

/* Section padding: fluid */
.section-padding {
    padding: var(--section-padding) 0;
}

/* Gap utilities */
.gap-sm { gap: clamp(0.5rem, 1vw, 1rem); }
.gap-md { gap: clamp(1rem, 2vw, 2rem); }
.gap-lg { gap: clamp(2rem, 4vw, 4rem); }

/* ========================================
   GRID SYSTEM — Auto-adaptive
   ======================================== */

/* Base grid */
.grid {
    display: grid;
    gap: 2rem;
}

/* Auto-fit: 1-3 columns based on width */
.grid-auto {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* Auto-fit: 1-2 columns */
.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
}

/* Fixed columns */
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Services Grid — Auto-adaptive */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
}

/* Portfolio/Blog Grid */
.portfolio-grid,
.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
}

/* ========================================
   CONTAINER QUERIES (for components)
   ======================================== */

@container (min-width: 400px) {
    .container-responsive {
        padding: 2rem;
    }
}

@container (min-width: 600px) {
    .container-responsive {
        padding: 3rem;
    }
}

/* ========================================
   BREAKPOINT: Tablet ≤900px
   ======================================== */

@media (max-width: 900px) {
    /* Grids: stack to fewer columns */
    .grid-3,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Hero: single column */
    .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 2rem;
    }

    .hero-info {
        border-left: none;
        border-top: 2px solid var(--primary);
        padding-top: 2rem;
    }

    .hero-btns {
        justify-content: center;
    }

    /* Hide decorative elements */
    .hide-tablet {
        display: none;
    }

    /* Flex: wrap */
    .flex-wrap {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Blog editorial: simplify */
    .blog-editorial-item {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }

    .blog-editorial-number {
        display: none;
    }

    .blog-editorial-meta {
        grid-column: 1;
        text-align: left;
        display: flex;
        gap: 1rem;
        align-items: center;
    }

    .blog-editorial-content p {
        max-width: 100%;
    }

    /* Header: allow overlay */
    header {
        overflow: visible;
    }

    .nav-container {
        overflow: visible;
    }

    /* Nav: mobile menu */
    .mobile-menu-btn {
        display: block;
        position: relative;
        z-index: 10002;
    }

    .nav-actions {
        position: relative;
        z-index: 10002;
    }

    nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        background: rgba(5, 10, 20, 0.98);
        backdrop-filter: blur(20px);
        display: flex;
        align-items: flex-start;
        justify-content: center;
        padding-top: 80px;
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 10001;
        transform: translateX(100%);
        overflow-y: auto;
        overflow-x: hidden;
    }

    nav.active {
        transform: translateX(0);
    }

    nav ul {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
        width: 100%;
        padding: 2rem 1.5rem;
    }

    nav a {
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--text-primary);
    }

    /* Blog submenu — mobile inline accordion */
    .nav-blog-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
        position: static;
    }

    .nav-blog-item > a {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
    }

    .submenu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 0.9rem;
        cursor: pointer;
        padding: 0.3rem 0.5rem;
        transition: var(--transition-smooth);
    }

    .submenu-toggle i {
        transition: transform 0.3s ease;
    }

    .nav-blog-item.active .submenu-toggle i {
        transform: rotate(180deg);
    }

    /* Override desktop absolute submenu */
    nav .nav-submenu {
        display: flex;
        position: static;
        transform: none;
        background: transparent;
        border: none;
        border-radius: 0;
        padding: 0;
        min-width: 0;
        box-shadow: none;
        backdrop-filter: none;
        flex-direction: column;
        gap: 0.6rem;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 0.35s ease, opacity 0.3s ease, padding 0.3s ease;
    }

    .nav-blog-item.active .nav-submenu {
        max-height: 400px;
        opacity: 1;
        padding-top: 0.5rem;
    }

    nav .nav-submenu li a {
        font-size: 1rem !important;
        font-weight: 500 !important;
        color: var(--text-muted) !important;
        padding: 0.6rem 1rem;
        display: block;
        border-radius: 8px;
        transition: var(--transition-smooth);
        white-space: normal;
    }

    nav .nav-submenu li a:hover {
        color: var(--primary) !important;
        background: rgba(0, 255, 136, 0.05);
    }

    .submenu-view-all {
        border-top: 1px solid rgba(255, 255, 255, 0.06);
        padding-top: 0.8rem !important;
        margin-top: 0.3rem;
        color: var(--primary) !important;
    }
}

/* ========================================
   BREAKPOINT: Móvil ≤768px
   ======================================== */

@media (max-width: 768px) {
    /* Grids: single column */
    .grid-3,
    .grid-4,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    /* Auto-fit: still works but single column */
    .grid-auto,
    .services-grid,
    .portfolio-grid,
    .blog-grid {
        grid-template-columns: 1fr;
    }

    /* Section padding: smaller */
    section {
        padding: clamp(3rem, 6vw, 6rem) 0;
    }

    /* Hide on mobile */
    .hide-mobile {
        display: none;
    }

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

    /* Flex column */
    .flex-column-mobile {
        flex-direction: column;
    }

    /* Full width buttons */
    .btn-full-mobile {
        width: 100%;
        justify-content: center;
    }

    /* Hero */
    .hero {
        padding-top: 120px;
        padding-bottom: 3rem;
    }

    .hero h1 {
        text-align: center;
    }

    .hero p {
        text-align: center;
    }

    .hero-btns {
        flex-direction: column;
        width: 100%;
    }

    .hero-btns .btn {
        width: 100%;
        justify-content: center;
    }

    /* Services */
    .services-grid {
        gap: 2rem;
    }

    .service-card {
        padding: 1.5rem;
    }

    /* Newsletter */
    .newsletter-card {
        padding: 2rem;
    }

    .newsletter-form {
        flex-direction: column;
    }

    .newsletter-form input,
    .newsletter-form button {
        width: 100%;
    }

    /* Blog */
    .blog-editorial-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .blog-editorial-number {
        display: none;
    }

    .blog-editorial-meta {
        grid-column: 1;
        margin-top: 0.5rem;
    }

    /* Cookie banner - centrado y sin cortes */
    .cookie-banner {
        top: 50%;
        left: 50%;
        right: auto;
        bottom: auto;
        width: 95%;
        max-width: 500px;
        max-height: 85vh;
        max-height: 85dvh;
        overflow-y: auto;
        transform: translate(-50%, -50%);
        border-radius: 16px;
        padding: 1.5rem;
    }

    .cookie-banner .actions-main {
        flex-direction: column;
    }

    /* Privacy modal */
    .privacy-modal .modal-content {
        padding: 3rem 1.5rem;
        border-radius: 0;
        max-height: 100vh;
    }

    .modal-body h2 {
        font-size: clamp(1.5rem, 4vw, 1.8rem);
    }
}

/* ========================================
   BREAKPOINT: Small ≤480px
   ======================================== */

@media (max-width: 480px) {
    /* Even smaller padding */
    section {
        padding: clamp(2rem, 5vw, 4rem) 0;
    }

    /* Container padding: tighter */
    .container {
        padding: 0 1rem;
    }

    /* Cards: full width */
    .card,
    .service-card {
        margin: 0 -0.5rem;
        border-radius: 16px;
    }

    /* Buttons: stack vertically */
    .cta-group,
    .hero-btns {
        flex-direction: column;
    }

    .cta-group .btn,
    .hero-btns .btn {
        width: 100%;
        justify-content: center;
    }

    /* Header */
    header {
        padding: 0.5rem 0;
    }

    .logo-text {
        font-size: 1.2rem;
    }

    /* Hero */
    .hero {
        padding-top: 100px;
        padding-bottom: 2rem;
    }

    /* Blog filters */
    .blog-filters .container {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        min-width: auto;
    }
}

/* ========================================
   RESPONSIVE UTILITIES
   ======================================== */

/* Show/hide at breakpoints */
.show-mobile { display: none; }
.show-tablet { display: none; }
.show-desktop { display: block; }

@media (max-width: 768px) {
    .show-mobile { display: block; }
    .hide-mobile { display: none; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .show-tablet { display: block; }
    .hide-tablet { display: none; }
}

@media (min-width: 1025px) {
    .show-desktop { display: block; }
    .hide-desktop { display: none; }
}

/* ========================================
   RESPONSIVE IMAGES
   ======================================== */

.img-responsive {
    width: 100%;
    height: auto;
    object-fit: cover;
}

.img-circle {
    border-radius: 50%;
    object-fit: cover;
}

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

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

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

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

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

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

@media (max-width: 768px) {
    .text-center-mobile { text-align: center; }
    .text-left-mobile { text-align: left; }
}
