﻿/* ==========================================================
   🌿 HERO SLIDER — Emerald Overlay + Cinematic Light Sweep + Caption Reflection
   (Fixed: height chain, indicators selector, duplicate keyframes, scoped sweep)
   ========================================================== */

.hero {
    position: relative;
    width: 100%;
    /* QUAN TRỌNG: phải có HEIGHT cụ thể thì con height:100% mới ăn */
    height: clamp(420px, 55vh, 720px);
    color: #fff;
    overflow: hidden;
}

/* ===== SLIDER CORE ===== */
.hero .carousel,
.hero .carousel-inner,
.hero .carousel-item 
{
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* ===== IMAGE ===== */
.hero .carousel-item > img 
{
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* mặc định cover */
    object-position: center;
    opacity: 0;
    transform: scale(1.05);
    transition: opacity 2s ease-in-out, transform 5s ease-out;
    animation: emeraldBreath 14s ease-in-out infinite;
    z-index: 0;
}

/* Chỉ active mới hiện */
.hero .carousel-item.active > img 
{
    opacity: 1;
    transform: scale(1);
}

/* ===== GREEN OVERLAY ===== */
.hero .carousel-item::before 
{
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient( 180deg, rgba(3,115,92,0.45) 0%, rgba(3,115,92,0.60) 60%, rgba(0,0,0,0.40) 100% );
    mix-blend-mode: overlay;
    opacity: .6;
    z-index: 1;
}

/* ===== LIGHT SWEEP — CHUYỂN ĐỘNG ĐIỆN ẢNH ===== */
.hero .carousel-item::after 
{
    content: "";
    position: absolute;
    top: 0;
    left: -30%;
    width: 6%;
    height: 100%;
    filter: blur(1px);
    background: linear-gradient( 120deg, transparent 0%, rgba(255,255,255,0.4) 40%, transparent 100% );
    opacity: 0;
    z-index: 2;
    animation: none;
}

/* Scope đúng hero, tránh đụng carousel khác */
.hero .carousel-item.active::after 
{
    animation: lightSweepCinematic 2.5s cubic-bezier(0.1, 0.03, 0.3, 0.5);
}

/* ===== CAPTION (Fade-in trễ sau ảnh) ===== */
.hero .carousel-caption 
{
    position: absolute;
    z-index: 3;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: min(92%, 1100px);
    opacity: 0;
    animation: captionFadeIn 2s ease-in-out forwards;
    animation-delay: 1.8s;
}

.hero .carousel-item.active .carousel-caption 
{
    animation: captionFadeIn 2s ease-in-out forwards;
    animation-delay: 1.8s;
}

@keyframes captionFadeIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -46%);
    }

    50% {
        opacity: .5;
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* ===== CAPTION TEXT ===== */
.hero .carousel-caption h1 {
    font-size: clamp(1.6rem, 2.2vw + .5rem, 3rem);
    font-weight: 800;
    color: #fff;
    position: relative;
    text-shadow: 0 4px 8px rgba(0,0,0,0.6), 0 0 10px rgba(3,115,92,0.4);
}

    /* ✨ PHẢN CHIẾU ÁNH SÁNG LÊN CHỮ ===== */
    .hero .carousel-caption h1::after {
        content: "";
        position: absolute;
        top: 0;
        left: -40%;
        width: 40%;
        height: 100%;
        background: linear-gradient( 120deg, transparent 0%, rgba(255,255,255,0.55) 50%, transparent 100% );
        opacity: 0;
        filter: blur(2px);
    }

.hero .carousel-item.active .carousel-caption h1::after {
    animation: lightSweepCinematic 4.5s ease-in-out;
    animation-delay: 0.3s;
}

.hero .carousel-caption p {
    font-size: clamp(1.05rem, 1.3vw + 0.4rem, 2rem);
    font-weight: 600;
    line-height: 1.5;
    color: #fff;
    text-shadow: 0 4px 8px rgba(0,0,0,0.6), 0 0 10px rgba(3,115,92,0.35);
}

/* ===== INDICATORS (FIX selector) ===== */
.hero .carousel-indicators {
    z-index: 4;
    bottom: 14px;
}

.hero .carousel-indicators [data-bs-target] 
{
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: rgba(255,255,255,0.45);
    border: 1px solid rgba(255,255,255,0.35);
    opacity: 1;
    margin: 0 6px;
    transition: transform .3s ease, background-color .3s ease;
}

.hero .carousel-indicators .active 
{
    background-color: #fff;
    box-shadow: 0 0 8px rgba(255,200,120,0.8);
    transform: scale(1.3);
}

/* ===== ORANGE LINES (Top & Bottom) ===== */
.hero::before,
.hero::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient( 90deg, rgba(255,140,0,0.25) 0%, rgba(255,94,0,0.9) 45%, rgba(255,160,0,0.25) 100% );
    box-shadow: 0 1px 3px rgba(255,140,0,0.45), 0 0 10px rgba(255,100,0,0.3);
    z-index: 5;
}

.hero::before {
    top: 0;
}

.hero::after {
    bottom: 0;
}

/* ===== EMERALD BREATH ===== */
@keyframes emeraldBreath {
    0%, 100% {
        filter: brightness(100%) saturate(110%);
    }

    50% {
        filter: brightness(112%) saturate(125%);
    }
}

/* ===== LIGHT SWEEP (ONLY ONE definition - tránh loạn) ===== */
@keyframes lightSweepCinematic {
    0% {
        left: -40%;
        opacity: 0;
        transform: scaleX(1.05);
    }

    15% {
        left: -10%;
        opacity: 0.35;
    }

    35% {
        left: 25%;
        opacity: 0.6;
        transform: scaleX(1.02);
    }

    50% {
        left: 45%;
        opacity: 0.75;
        transform: scaleX(1);
    }

    60% {
        left: 55%;
        opacity: 0.7;
    }

    80% {
        left: 90%;
        opacity: 0.35;
        transform: scaleX(1.03);
    }

    100% {
        left: 130%;
        opacity: 0;
        transform: scaleX(1.05);
    }
}

/* ===== TABLET / iPad (<= 992px): hạ chiều cao để không phải kéo xuống ===== */
@media (max-width: 992px) {
    .hero {
        height: clamp(280px, 46vh, 480px);
    }

    .hero .carousel-caption {
        width: min(94%, 900px);
    }
}

@media (min-width: 992px) {
    .hero .carousel-item > img {
        object-position: center 50%;
    }
}

/* ===== MOBILE (<= 768px): chữ gọn + chiều cao hợp lý ===== */
@media (max-width: 768px) {
    .hero {
        height: clamp(240px, 42vh, 360px);
    }

        .hero .carousel-caption {
            top: 48%;
            width: 92%;
        }

            .hero .carousel-caption h1 {
                font-size: clamp(1.15rem, 3.2vw + 0.35rem, 1.9rem);
                font-weight: 700;
            }

            .hero .carousel-caption p {
                font-size: clamp(0.95rem, 2.2vw + 0.2rem, 1.2rem);
                font-weight: 600;
            }
}

/* ===== Máy thấp chiều cao (laptop 1366x768, iPad giả lập…) ===== */
@media (max-height: 800px) {
    .hero {
        height: min(52vh, 520px);
    }
}

/* ===== PC lớn: cao hơn chút (đúng ý anh) ===== */
@media (min-width: 1200px) {
    .hero {
        height: clamp(520px, 62vh, 860px);
    }
}

/* ===== Mobile dọc: CONTAIN “đủ ảnh” nhưng KHÓA KHUNG 16:9 để không dư quá ===== */
@media (max-width: 768px) and (orientation: portrait) {

    /* Khóa khung theo 16:9 (ảnh 1920x1080 chuẩn) */
    .hero 
    {
        height: auto; /* bỏ height theo vh */
        aspect-ratio: 16 / 9; /* khung đúng 16:9 */
        max-height: 46vh; /* không chiếm quá màn hình */        
    }

    .hero .carousel,
    .hero .carousel-inner,
    .hero .carousel-item {
        height: 100%; /* dùng aspect-ratio */
    }

    .hero .carousel-item > img {
        object-fit: contain; /* show đủ ảnh */
        transform: none; /* tránh scale gây cảm giác “dư” */
        animation: none; /* contain + zoom dễ nhìn “lạ” -> tắt trên dọc */
    }

    .hero .carousel-item.active > img {
        transform: none;
    }
}

.homepage-banner {
    margin-bottom: 30px;
}

.banner-img {
    aspect-ratio: 16/9;
    object-fit: cover;
    border-radius: 12px;
}

.carousel-caption {
    background: linear-gradient(to top, rgba(0,0,0,.6), transparent);
    border-radius: 10px;
    padding: 20px;
}

    .carousel-caption h3 {
        color: #fff;
        font-weight: 800;
    }