/* ============================================
   CARRUSEL PRINCIPAL
   ============================================ */

.carousel-container {
    position: relative;
    width: 100%;
    max-width: 100vw;
    margin: 0 0 4rem 0;
    border-radius: 0;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(74, 144, 226, 0.15);
    background: linear-gradient(135deg, #4A90E2 0%, #5BA0F2 100%);
}

.carousel-wrapper {
    position: relative;
    height: 500px;
    overflow: hidden;
}

.carousel-slides {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.carousel-slide {
    min-width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4A90E2 0%, #5BA0F2 100%);
    color: white;
    text-align: center;
    padding: 3rem;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Overlay para mejorar legibilidad del texto sobre imágenes */
.carousel-slide::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.7) 0%, rgba(91, 160, 242, 0.6) 100%);
    z-index: 1;
}

/* Imagen dentro del slide */
.carousel-slide-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.carousel-slide-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.carousel-video-poster {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .carousel-slide-video {
        display: none;
    }

    .carousel-video-poster {
        display: block;
    }
}

/* Efectos de fondo animados (solo cuando no hay imagen) */
.carousel-slide:not([data-bg]):not(.has-image)::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="1" fill="rgba(255,255,255,0.1)"/></svg>') repeat;
    animation: float 20s infinite linear;
    z-index: 0;
}

.carousel-slide-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    border-radius: 15px;
}

.carousel-slide h2 {
    font-size: clamp(2rem, 4vw, 3.5rem);
    margin-bottom: 1.5rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    line-height: 1.2;
}

.carousel-slide p {
    font-size: clamp(1rem, 2vw, 1.3rem);
    margin-bottom: 2rem;
    opacity: 0.95;
    line-height: 1.6;
}

.carousel-slide .carousel-cta {
    display: inline-block;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

.carousel-slide .carousel-cta:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

/* ============================================
   CONTROLES DEL CARRUSEL
   ============================================ */

.carousel-controls {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    z-index: 10;
}

.carousel-controls:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.carousel-controls.prev {
    left: 20px;
}

.carousel-controls.next {
    right: 20px;
}

.carousel-controls svg {
    width: 20px;
    height: 20px;
    stroke-width: 3;
}

/* ============================================
   INDICADORES
   ============================================ */

.carousel-indicators {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 10;
}

.carousel-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.6);
}

.carousel-indicator.active {
    background: white;
    transform: scale(1.2);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.4);
}

.carousel-indicator:hover {
    background: rgba(255, 255, 255, 0.7);
    transform: scale(1.1);
}

/* ============================================
   VARIANTES DE SLIDES CON IMÁGENES
   ============================================ */

/* Slide de Resinas */
.carousel-slide.slide-resinas:not(.has-image) {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
}

.carousel-slide.slide-resinas:not(.has-image)::after {
    content: '🧪';
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 3rem;
    opacity: 0.3;
    z-index: 1;
}

/* Slide de Fibras */
.carousel-slide.slide-fibras:not(.has-image) {
    background: linear-gradient(135deg, #5BA0F2 0%, #4A90E2 100%);
}

.carousel-slide.slide-fibras:not(.has-image)::after {
    content: '🪶';
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 3rem;
    opacity: 0.3;
    z-index: 1;
}

/* Slide de Servicios */
.carousel-slide.slide-servicios:not(.has-image) {
    background: linear-gradient(135deg, #4A90E2 0%, #5BA0F2 100%);
}

.carousel-slide.slide-servicios:not(.has-image)::after {
    content: '🔧';
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 3rem;
    opacity: 0.3;
    z-index: 1;
}

/* Slides con imagen de fondo */
.carousel-slide.has-image {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Ajustar overlay cuando hay imagen */
.carousel-slide.has-image::after {
    background: linear-gradient(135deg, rgba(74, 145, 226, 0.559) 0%, rgba(91, 159, 242, 0.331) 100%);
}

/* Portada de video: la resina y el logo quedan despejados en el centro. */
.titan-video-hero .carousel-slide.has-video::after {
    background: linear-gradient(90deg, rgba(2, 18, 34, 0.72) 0%, rgba(2, 18, 34, 0.16) 48%, rgba(2, 18, 34, 0.04) 70%);
}

.titan-video-hero .carousel-slide-content {
    align-self: flex-end;
    width: calc(100% - 6vw);
    max-width: 1380px;
    margin: 0 auto 1.25rem;
    padding: 1rem 1.25rem;
    text-align: left;
    background: rgba(2, 18, 34, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.16);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    display: grid;
    grid-template-columns: auto minmax(260px, 1fr) auto;
    align-items: center;
    gap: 1.25rem;
    opacity: 0;
    transform: translateY(28px);
    pointer-events: none;
    transition: opacity .65s cubic-bezier(.2,.8,.2,1), transform .65s cubic-bezier(.2,.8,.2,1);
}

.titan-video-hero .carousel-slide-content.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.titan-video-hero .carousel-slide h2 {
    margin: 0;
    font-size: clamp(1.45rem, 2.2vw, 2.25rem);
    white-space: nowrap;
}

.titan-video-hero .carousel-slide p {
    margin: 0;
    font-size: clamp(.95rem, 1.2vw, 1.08rem);
}

.titan-video-hero .carousel-cta{white-space:nowrap}

@media (max-width: 768px) {
    .titan-video-hero .carousel-slide.has-video::after {
        background: linear-gradient(0deg, rgba(2, 18, 34, 0.82) 0%, rgba(2, 18, 34, 0.08) 72%);
    }

    .titan-video-hero .carousel-slide-content {
        margin: 0 auto 0.75rem;
        padding: 1.1rem 1.25rem;
        text-align: center;
        width: calc(100% - 24px);
        grid-template-columns: 1fr;
        gap: .65rem;
    }

    .titan-video-hero .carousel-slide h2{white-space:normal}
}

@media (prefers-reduced-motion: reduce) {
    .titan-video-hero .carousel-slide-content {
        opacity: 1;
        transform: none;
    }
}

/* Contenido más destacado sobre imágenes */
.carousel-slide.has-image .carousel-slide-content {
    /* Fondo oscuro suficiente para legibilidad sin desenfocar/rasterizar el texto. */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* ============================================
   AUTOPLAY INDICATOR
   ============================================ */

.carousel-autoplay-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    transition: width 0.1s linear;
    z-index: 10;
}

/* ============================================
   ESTADOS DE PAUSA
   ============================================ */

.carousel-container.paused .carousel-autoplay-progress {
    animation-play-state: paused;
}

.carousel-container:hover .carousel-controls {
    opacity: 1;
}

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

@media (max-width: 1200px) {
    .carousel-container {
        margin: 0 0 3rem 0;
    }
    
    .carousel-wrapper {
        height: 450px;
    }
    
    .carousel-slide {
        padding: 2.5rem;
    }
}

@media (max-width: 768px) {
    .carousel-wrapper {
        height: 400px;
    }
    
    .carousel-slide {
        padding: 2rem;
    }
    
    .carousel-controls {
        width: 40px;
        height: 40px;
    }
    
    .carousel-controls.prev {
        left: 15px;
    }
    
    .carousel-controls.next {
        right: 15px;
    }
    
    .carousel-controls svg {
        width: 16px;
        height: 16px;
    }
    
    .carousel-indicators {
        bottom: 15px;
        gap: 10px;
    }
    
    .carousel-indicator {
        width: 10px;
        height: 10px;
    }
}

@media (max-width: 480px) {
    .carousel-container {
        margin: 0 0 2rem 0;
        border-radius: 0;
    }
    
    .carousel-wrapper {
        height: 350px;
    }
    
    .carousel-slide {
        padding: 1.5rem;
    }
    
    .carousel-slide .carousel-cta {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }
}

/* ============================================
   ANIMACIONES
   ============================================ */

@keyframes float {
    0% {
        transform: translateX(0) translateY(0) rotate(0deg);
    }
    33% {
        transform: translateX(30px) translateY(-30px) rotate(120deg);
    }
    66% {
        transform: translateX(-20px) translateY(20px) rotate(240deg);
    }
    100% {
        transform: translateX(0) translateY(0) rotate(360deg);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50px);
    }
}

/* Animación de entrada para el contenido */
.carousel-slide-content {
    animation: slideIn 0.6s ease-out;
}

/* ============================================
   ACCESIBILIDAD
   ============================================ */

.carousel-controls:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

.carousel-indicator:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

/* Modo de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    .carousel-slides {
        transition: none;
    }
    
    .carousel-slide::before {
        animation: none;
    }
    
    .carousel-slide-content {
        animation: none;
    }
    
    .carousel-controls,
    .carousel-indicator {
        transition: none;
    }
}

/* Modo de alto contraste */
@media (prefers-contrast: high) {
    .carousel-container {
        border: 2px solid #000;
    }
    
    .carousel-controls,
    .carousel-indicator {
        border: 2px solid #000;
    }
}

/* ============================================
   UTILIDADES
   ============================================ */

.carousel-fade-transition .carousel-slides {
    transition: opacity 0.6s ease-in-out;
}

.carousel-slide.fade-in {
    opacity: 1;
}

.carousel-slide.fade-out {
    opacity: 0;
}

/* TITAN: texto del banner de video siempre nítido */
.titan-video-hero .carousel-slide-content {
    animation: none;
    filter: none;
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
}
.titan-video-hero .carousel-slide h2,
.titan-video-hero .carousel-slide p,
.titan-video-hero .carousel-slide .carousel-cta {
    filter: none;
    transform: translateZ(0);
}
.titan-video-hero .carousel-slide h2 {
    text-shadow: 0 1px 2px rgba(0,0,0,.18);
}
