/**
 * Twingital Grid Pro — Frontend CSS
 * Layouts: Cubo 3D & Carousel Stack
 * Responsive: mobile-first
 */

/* ════════════════════════════════════════════════════════════
   CUBO 3D
   ════════════════════════════════════════════════════════════ */

.tgp-cube-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 40px 20px;
    /* Variables inyectadas desde PHP */
    /* --cube-size, --cube-half, --cube-speed, --cube-direction */
}

/* ── Escena ── */
.tgp-cube-scene {
    width:  var(--cube-size, 380px);
    height: var(--cube-size, 380px);
    perspective: calc(var(--cube-size, 380px) * 2.5);
    perspective-origin: 50% 50%;
}

/* ── Cubo ── */
.tgp-cube {
    width:  100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateY(0deg);
    transition: transform 0.9s cubic-bezier(0.77, 0, 0.175, 1);
    will-change: transform;
    animation: none; /* el JS controla la rotación */
}

/* ── Caras ── */
.tgp-cube__face {
    position: absolute;
    inset: 0;
    width:  var(--cube-size, 380px);
    height: var(--cube-size, 380px);
    border-radius: 16px;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-color: #1e1e1e;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.tgp-cube__face--front  { transform: rotateY(  0deg) translateZ(var(--cube-half, 190px)); }
.tgp-cube__face--right  { transform: rotateY( 90deg) translateZ(var(--cube-half, 190px)); }
.tgp-cube__face--back   { transform: rotateY(180deg) translateZ(var(--cube-half, 190px)); }
.tgp-cube__face--left   { transform: rotateY(270deg) translateZ(var(--cube-half, 190px)); }

/* ── Overlay de texto ── */
.tgp-cube__face-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 28px 24px;
    background: linear-gradient(
        to top,
        rgba(0,0,0,0.85) 0%,
        rgba(0,0,0,0.4)  55%,
        transparent      100%
    );
    color: #fff;
}

.tgp-cube__title {
    font-size: clamp(16px, 3.5vw, 22px);
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 8px;
}

.tgp-cube__title a {
    color: #fff;
    text-decoration: none;
    transition: opacity 0.2s;
}

.tgp-cube__title a:hover { opacity: 0.85; }

.tgp-cube__excerpt {
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255,255,255,0.8);
    margin: 0 0 14px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tgp-cube__btn {
    display: inline-block;
    padding: 8px 18px;
    background: rgba(255,255,255,0.95);
    color: #1e1e1e;
    font-size: 12px;
    font-weight: 700;
    border-radius: 40px;
    text-decoration: none;
    transition: background 0.2s, transform 0.2s;
    align-self: flex-start;
    letter-spacing: 0.3px;
}

.tgp-cube__btn:hover {
    background: #fff;
    transform: translateY(-2px);
}

/* ── Sombra / reflejo ── */
.tgp-cube-shadow-soft   { filter: drop-shadow(0 30px 60px rgba(0,0,0,0.35)); }
.tgp-cube-shadow-reflection { filter: drop-shadow(0 40px 20px rgba(0,0,0,0.5)); }

/* ── Controles ── */
.tgp-cube-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    order: -1;
}

.tgp-cube-counter {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    min-width: 36px;
    text-align: center;
}

.tgp-cube-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width:  40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #e5e7eb;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    color: #374151;
}

.tgp-cube-btn svg {
    width:  18px;
    height: 18px;
}

.tgp-cube-btn:hover {
    border-color: #667eea;
    color: #667eea;
    box-shadow: 0 4px 12px rgba(102,126,234,0.25);
    transform: scale(1.08);
}

/* ── Puntos ── */
.tgp-cube-dots {
    display: flex;
    gap: 8px;
}

.tgp-cube-dot {
    width:  10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    background: transparent;
    cursor: pointer;
    transition: all 0.25s;
    padding: 0;
}

.tgp-cube-dot.is-active {
    background: #667eea;
    border-color: #667eea;
    transform: scale(1.3);
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .tgp-cube-wrapper {
        --cube-size: min(85vw, 320px);
        --cube-half: calc(var(--cube-size) / 2);
        padding: 24px 12px;
    }

    .tgp-cube-scene {
        width:  var(--cube-size);
        height: var(--cube-size);
    }

    .tgp-cube__face {
        width:  var(--cube-size);
        height: var(--cube-size);
    }

    .tgp-cube__face-overlay { padding: 18px 16px; }
}


/* ════════════════════════════════════════════════════════════
   CAROUSEL STACK
   ════════════════════════════════════════════════════════════ */

.tgp-stack-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    padding: 40px 20px;
    /* --stack-offset, --stack-scale, --stack-visible */
}

/* ── Pila ── */
.tgp-stack {
    position: relative;
    width: min(480px, 90vw);
    /* altura mínima calculada en base al offset visible */
    height: calc(360px + var(--stack-visible, 3) * var(--stack-offset, 20px));
}

/* ── Tarjeta ── */
.tgp-stack__card {
    position: absolute;
    inset: 0;
    width:  100%;
    height: 360px;
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    transition:
        transform  0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity    0.55s ease,
        box-shadow 0.3s ease;
    cursor: pointer;
    transform-origin: top center;
    will-change: transform, opacity;
    display: flex;
    flex-direction: column;
}

.tgp-stack__card.is-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

.tgp-stack__card.is-active {
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    cursor: default;
}

/* ── Imagen ── */
.tgp-stack__img {
    flex-shrink: 0;
    height: 200px;
    background-size: cover;
    background-position: center;
    transition: transform 0.6s ease;
}

.tgp-stack__card.is-active .tgp-stack__img {
    transform: scale(1.02);
}

/* ── Cuerpo ── */
.tgp-stack__body {
    flex: 1;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tgp-stack__cat {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #667eea;
    background: #ede9ff;
    padding: 3px 8px;
    border-radius: 20px;
    align-self: flex-start;
}

.tgp-stack__title {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    margin: 4px 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tgp-stack__title a {
    color: #1f2937;
    text-decoration: none;
    transition: color 0.2s;
}

.tgp-stack__title a:hover { color: #667eea; }

.tgp-stack__excerpt {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.55;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tgp-stack__link {
    margin-top: auto;
    font-size: 12px;
    font-weight: 700;
    color: #667eea;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: gap 0.2s;
}

.tgp-stack__link:hover { gap: 8px; }

/* ── Controles ── */
.tgp-stack-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.tgp-stack-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width:  44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid #e5e7eb;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    color: #374151;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.tgp-stack-btn svg {
    width:  18px;
    height: 18px;
}

.tgp-stack-btn:hover {
    border-color: #667eea;
    color: #667eea;
    box-shadow: 0 4px 16px rgba(102,126,234,0.3);
    transform: scale(1.1);
}

/* ── Dots ── */
.tgp-stack-dots {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 200px;
}

.tgp-stack-dot {
    width:  8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background: #d1d5db;
    cursor: pointer;
    transition: all 0.25s;
    padding: 0;
}

.tgp-stack-dot.is-active {
    background: #667eea;
    transform: scale(1.5);
}

/* ── Responsive ── */
@media (max-width: 520px) {
    .tgp-stack {
        width: 100%;
    }

    .tgp-stack__card {
        height: 320px;
    }

    .tgp-stack__img {
        height: 160px;
    }

    .tgp-stack-wrapper {
        padding: 24px 12px;
        gap: 24px;
    }
}