/* Code & WordPress Section */

.pantalla-codeWP {
    background: #e73c7e;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Title uses the shared .section-title class from style.css;
   .cwp-title inherits .section-title positioning but needs its own z-index */
.cwp-title {
    position: absolute;
    top: 2.5rem;
    left: 3rem;
    z-index: 2;
    line-height: 1;
    pointer-events: none;
}

.cwp-title h2 {
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    font-weight: 800;
    color: rgba(0, 0, 0, 0.82);
    letter-spacing: -0.5px;
    margin: 0;
}

.cwp-title-wp {
    color: #ffffff;
}

/* Logos row */
.cwp-logos-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(2rem, 5vw, 5rem);
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

/* When a project is open, slide the logos left (mirrors perfil.js flood) */
.pantalla-codeWP.cwp-open .cwp-logos-wrapper {
    transform: translateX(-25vw) scale(0.65);
    transform-origin: center center;
}

/* Individual logo */
.cwp-logo {
    cursor: pointer;
    transition: transform 0.3s ease, opacity 0.3s ease, filter 0.3s ease;
    filter: brightness(0) invert(1);
}

.cwp-logo img {
    display: block;
    height: clamp(40px, 8vh, 80px);
    width: auto;
    max-width: 160px;
    object-fit: contain;
    user-select: none;
}

.cwp-logo:hover {
    transform: translateY(-6px) scale(1.08);
}

/* Active logo gets a white ring */
.cwp-logo.active {
    filter: brightness(0) invert(1);
    transform: translateY(-6px) scale(1.1);
}

/* Non-active logos dim when panel is open */
.cwp-logo.dimmed {
    opacity: 0.3;
    filter: brightness(0) invert(1);
}

/* Detail panel — slides in from the right */
.cwp-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 48%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    /* allow content to start at top */
    overflow-y: auto;
    /* scroll when content overflows */
    padding: 4.5rem 2.5rem 2.5rem;
    /* top padding makes room for close btn */
    transform: translateX(100%);
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 3;
}

.pantalla-codeWP.cwp-open .cwp-panel {
    transform: translateX(0);
}

.cwp-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.7);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cwp-close:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

/* Panel content */
.cwp-panel-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: auto 0;
    /* center vertically within the flex panel */
    width: 100%;
}

.cwp-panel-logo {
    height: clamp(50px, 9vh, 100px);
    width: auto;
    max-width: 240px;
    object-fit: contain;
    filter: none;
    margin-bottom: 0.5rem;
}

/* Screenshot gallery strip */
.cwp-gallery {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.cwp-gallery img {
    height: 80px;
    width: auto;
    border-radius: 8px;
    object-fit: cover;
    cursor: zoom-in;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cwp-gallery img:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.cwp-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    padding: 4px 12px;
    border-radius: 100px;
    text-transform: uppercase;
    align-self: flex-start;
}

.cwp-badge--own {
    background: rgba(238, 119, 82, 0.2);
    color: #ee7752;
    border: 1px solid rgba(238, 119, 82, 0.4);
}

.cwp-badge--client {
    background: rgba(231, 60, 126, 0.2);
    color: #e73c7e;
    border: 1px solid rgba(231, 60, 126, 0.4);
}

.cwp-badge--fct {
    background: rgba(35, 166, 213, 0.2);
    color: #23a6d5;
    border: 1px solid rgba(35, 166, 213, 0.4);
}

.cwp-panel-body h3 {
    font-size: 2rem;
    color: #f0f0f0;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0;
}

.cwp-tagline {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.45);
    font-style: italic;
    margin: 0;
}

.cwp-desc {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.7;
    margin: 0;
}

.cwp-tech {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cwp-tech span {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 3px 10px;
    border-radius: 100px;
}

.cwp-link {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #e73c7e;
    text-decoration: none;
    border-bottom: 2px solid rgba(231, 60, 126, 0.4);
    padding-bottom: 3px;
    align-self: flex-start;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.cwp-link:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.5);
    gap: 14px;
}

.cwp-link svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.cwp-link:hover svg {
    transform: translate(4px, -4px);
}

/* Panel body stagger-in animations */
.cwp-panel-body>* {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.pantalla-codeWP.cwp-open .cwp-panel-body>*:nth-child(1) {
    opacity: 1;
    transform: none;
    transition-delay: 0.35s;
}

.pantalla-codeWP.cwp-open .cwp-panel-body>*:nth-child(2) {
    opacity: 1;
    transform: none;
    transition-delay: 0.42s;
}

.pantalla-codeWP.cwp-open .cwp-panel-body>*:nth-child(3) {
    opacity: 1;
    transform: none;
    transition-delay: 0.48s;
}

.pantalla-codeWP.cwp-open .cwp-panel-body>*:nth-child(4) {
    opacity: 1;
    transform: none;
    transition-delay: 0.54s;
}

.pantalla-codeWP.cwp-open .cwp-panel-body>*:nth-child(5) {
    opacity: 1;
    transform: none;
    transition-delay: 0.60s;
}

.pantalla-codeWP.cwp-open .cwp-panel-body>*:nth-child(6) {
    opacity: 1;
    transform: none;
    transition-delay: 0.66s;
}

.pantalla-codeWP.cwp-open .cwp-panel-body>*:nth-child(7) {
    opacity: 1;
    transform: none;
    transition-delay: 0.70s;
}

.pantalla-codeWP.cwp-open .cwp-panel-body>*:nth-child(8) {
    opacity: 1;
    transform: none;
    transition-delay: 0.74s;
}

/* Catch-all: any extra children also fade in */
.pantalla-codeWP.cwp-open .cwp-panel-body>*:nth-child(n+9) {
    opacity: 1;
    transform: none;
    transition-delay: 0.78s;
}

/* ===========================
   Lightbox overlay
=========================== */
.cwp-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    cursor: zoom-out;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    backdrop-filter: blur(6px);
}

.cwp-lightbox.open {
    opacity: 1;
    pointer-events: all;
}

.cwp-lightbox img {
    max-width: 90vw;
    max-height: 88vh;
    border-radius: 10px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    object-fit: contain;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: default;
}

.cwp-lightbox.open img {
    transform: scale(1);
}

.cwp-lightbox-close {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    z-index: 10000;
}

.cwp-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* Prev / Next arrows */
.cwp-lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: white;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-size: 1.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 10000;
    line-height: 1;
}

.cwp-lightbox-prev {
    left: 1.5rem;
}

.cwp-lightbox-next {
    right: 5rem;
}

/* offset from close btn */

.cwp-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%) scale(1.08);
}

/* Counter e.g. "2 / 6" */
.cwp-lightbox-counter {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    z-index: 10000;
}

/* Smooth opacity transition for image swap */
.cwp-lightbox img {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.15s ease;
}

/* ==========================================================================
   CODE & WP RESPONSIVE
   ========================================================================== */
@media screen and (max-width: 768px) {
    .cwp-logos-wrapper {
        flex-direction: column;
        gap: 3rem;
    }

    /* Optimización de rendimiento: quitamos blur en móvil */
    .cwp-panel {
        width: 100%;
        padding: 4rem 1.5rem 1.5rem;
        backdrop-filter: none;
        background: rgba(0, 0, 0, 0.98);
    }

    .pantalla-codeWP.cwp-open .cwp-logos-wrapper {
        transform: translateX(-40vw) scale(0.5);
    }
}