/* Hero Slider CSS - Responsive Version with Fixed z-index */

/* ========================================== */
/* CRITICAL FIX: Hero Section z-index */
/* ========================================== */
#hero-section {
    position: relative;
    width: 100%;
    overflow: hidden;
    z-index: 1 !important;
    /* ต่ำกว่า header (z-index: 1000) */
}

/* Hero Wrapper ที่บรรจุสไลด์ทั้งหมด */
#hero-wrapper {
    display: flex;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    position: relative;
    z-index: 1;
}

/* แต่ละสไลด์ */
#hero-section .hero-slide {
    flex-shrink: 0;
    position: relative;
    height: 100%;
    z-index: 1;
    overflow: hidden;
    background-color: #ffffff;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* ========================================== */
/* Slide Background (รองรับ zoom effects)     */
/* ========================================== */
.slide-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    will-change: transform;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Ken Burns Zoom In */
.slide-bg.zoom-in {
    animation: kenBurnsIn 12s ease-in-out infinite alternate;
}

/* Ken Burns Zoom Out */
.slide-bg.zoom-out {
    animation: kenBurnsOut 12s ease-in-out infinite alternate;
}

/* Ken Burns Zoom In-Out Loop */
.slide-bg.zoom-in-out {
    animation: kenBurnsInOut 12s ease-in-out infinite;
}

@keyframes kenBurnsIn {
    from { transform: scale(1);    }
    to   { transform: scale(1.15); }
}
@keyframes kenBurnsOut {
    from { transform: scale(1.15); }
    to   { transform: scale(1);    }
}
@keyframes kenBurnsInOut {
    0%   { transform: scale(1);    }
    50%  { transform: scale(1.12); }
    100% { transform: scale(1);    }
}

/* ========================================== */
/* YouTube Video Slide                        */
/* ========================================== */
.youtube-container {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden;
    background: #000;
}

/* Full-cover YouTube iframe (crops sides on narrow screens) */
.youtube-container iframe {
    position: absolute;
    top: 50%;
    left: 50%;
    /* 16:9 cover technique */
    width: 100vw;
    height: 56.25vw;   /* 100vw * (9/16) */
    min-height: 100%;
    min-width: 177.78vh; /* 100vh * (16/9) */
    transform: translate(-50%, -50%);
    border: 0;
    pointer-events: none; /* prevent iframe interaction that breaks slider */
}

/* ความสูง max 640px บน desktop ลดลงตามความกว้างหน้าจออัตโนมัติ */
#hero-section {
    height: clamp(160px, 33.33vw, 640px) !important;
    min-height: unset !important;
}

/* ========================================== */
/* Navigation Buttons - Fixed z-index */
/* ========================================== */
.slider-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    cursor: pointer;
    z-index: 10 !important;
    /* ภายใน hero section เท่านั้น */
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.slider-nav:hover {
    background-color: rgba(0, 0, 0, 0.7);
    transform: translateY(-50%) scale(1.1);
}

.slider-nav.prev {
    left: 15px;
}

.slider-nav.next {
    right: 15px;
}

.slider-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: translateY(-50%);
}

/* ปรับขนาดปุ่มสำหรับมือถือ */
@media (max-width: 640px) {
    .slider-nav {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .slider-nav.prev {
        left: 8px;
    }

    .slider-nav.next {
        right: 8px;
    }
}

/* ========================================== */
/* Indicators - Fixed z-index */
/* ========================================== */
#hero-indicators {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10 !important;
    /* ภายใน hero section เท่านั้น */
    padding: 8px 12px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

.hero-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.5);
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
}

.hero-indicator:hover {
    background-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.3);
}

.hero-indicator.active {
    background-color: rgba(255, 255, 255, 1);
    transform: scale(1.4);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

/* รองรับ class เก่าด้วย */
.hero-indicator.bg-opacity-100 {
    background-color: rgba(255, 255, 255, 1);
    transform: scale(1.4);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

/* สำหรับมือถือ */
@media (max-width: 640px) {
    #hero-indicators {
        bottom: 12px;
        gap: 8px;
        padding: 6px 10px;
    }

    .hero-indicator {
        width: 10px;
        height: 10px;
    }

    .hero-indicator.active,
    .hero-indicator.bg-opacity-100 {
        transform: scale(1.3);
    }
}

/* ========================================== */
/* Overlay และ Content - Fixed z-index */
/* ========================================== */
#hero-section .absolute.inset-0.bg-black {
    z-index: 2 !important;
}

#hero-section #slide-content {
    position: relative;
    z-index: 5 !important;
}

.slide-text {
    animation: smoothFadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transition: opacity 0.3s ease;
}

@keyframes smoothFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ปรับขนาดข้อความตามหน้าจอ */
@media (max-width: 640px) {
    .slide-text h2 {
        font-size: 1.5rem !important;
        /* 24px */
        line-height: 1.2;
        margin-bottom: 0.5rem !important;
    }

    .slide-text p {
        font-size: 0.875rem !important;
        /* 14px */
        line-height: 1.4;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .slide-text h2 {
        font-size: 2rem !important;
        /* 32px */
    }

    .slide-text p {
        font-size: 1rem !important;
        /* 16px */
    }
}

/* เพิ่ม smooth scrolling effect และ hardware acceleration */
#hero-wrapper {
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

#hero-section .hero-slide {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Loading state */
#hero-section.loading .hero-slide {
    background-color: #f3f4f6;
}

/* Accessibility */
.slider-nav:focus,
.hero-indicator:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* Touch device optimization */
@media (hover: none) and (pointer: coarse) {
    .slider-nav:hover {
        transform: translateY(-50%);
        background-color: rgba(0, 0, 0, 0.5);
    }

    .hero-indicator:hover {
        transform: scale(1);
    }
}

/* ========================================== */
/* Text / Letter Slide Animations             */
/* ========================================== */
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-80px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(80px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideInUp {
    from { opacity: 0; transform: translateY(50px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInDown {
    from { opacity: 0; transform: translateY(-50px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes textZoomIn {
    from { opacity: 0; transform: scale(0.75); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes bounceIn {
    0%   { opacity: 0; transform: scale(0.3); }
    40%  { opacity: 1; transform: scale(1.08); }
    65%  { transform: scale(0.93); }
    80%  { transform: scale(1.04); }
    100% { opacity: 1; transform: scale(1); }
}