:root { 
    --cpac-blue: #004289; 
    --cpac-light-blue: #0076c0;
    --slate-gray: #f8fafc;
}

body { 
    font-family: 'Sarabun', sans-serif; 
    color: #1e293b; 
    line-height: 1.8; 
    background-color: #ffffff; 
    overflow-x: hidden; 
    max-width: 100%;
    position: relative;
}

h1, h2, h3, h4, .font-kanit { 
    font-family: 'Kanit', sans-serif; 
    letter-spacing: -0.01em; 
}

/* --- Preloader Styles --- */
#preloader {
    position: fixed;
    inset: 0;
    background-color: var(--cpac-blue);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

#preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

.text-pulse-glow {
    animation: pulseGlow 1.2s ease-in-out infinite alternate;
}

@keyframes pulseGlow {
    0% { transform: scale(0.98); opacity: 0.5; text-shadow: 0 0 0px rgba(255, 255, 255, 0); }
    100% { transform: scale(1.05); opacity: 1; text-shadow: 0 0 20px rgba(255, 255, 255, 0.5); }
}

.header-shadow { 
    box-shadow: 0 2px 15px rgba(0,0,0,0.05); 
    transition: all 0.3s ease; 
}

/* --- Hero Section & Zoom Effect --- */
.hero-cpac {
    position: relative;
    overflow: hidden;
    z-index: 1;
    min-height: calc(100svh - 80px) !important; 
    background: none !important; 
}

.hero-cpac::before {
    content: "";
    position: absolute;
    top: -10%; left: -10%; width: 120%; height: 120%;
    background: linear-gradient(90deg, rgba(0, 66, 137, 0.9) 0%, rgba(0, 66, 137, 0.4) 100%), 
                url('https://images.unsplash.com/photo-1541888946425-d81bb19240f5?q=80&w=1600');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-animation: heroZoomV2 15s linear infinite alternate;
    animation: heroZoomV2 15s linear infinite alternate;
}

@-webkit-keyframes heroZoomV2 {
    0% { -webkit-transform: scale(1); }
    100% { -webkit-transform: scale(1.15); }
}

@keyframes heroZoomV2 {
    0% { transform: scale(1); }
    100% { transform: scale(1.15); }
}

/* เอฟเฟกต์ Shine สำหรับการ์ด */
.card-modern {
    position: relative;
    overflow: hidden;
}

.card-modern::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 20%;
    height: 200%;
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(30deg);
    transition: all 0.7s;
    pointer-events: none;
    z-index: 1;
}

.card-modern:hover::after {
    left: 120%;
}

/* ปรับปรุง Smooth Scale */
.card-modern:hover {
    transform: translateY(-12px) scale(1.03);
    box-shadow: 0 25px 50px -12px rgba(0, 66, 137, 0.2);
}

/* --- Navigation & Menus --- */
#mobile-menu {
    transition: transform 0.4s cubic-bezier(0.77, 0, 0.175, 1);
    transform: translateX(100%);
}

#mobile-menu.active { transform: translateX(0); }

.desktop-dropdown { position: relative; }

.desktop-dropdown-content {
    display: block;
    visibility: hidden;
    opacity: 0;
    transform: translateY(15px);
    transition: all 0.3s ease;
    pointer-events: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    min-width: 240px;
    z-index: 50;
}

.desktop-dropdown:hover .desktop-dropdown-content {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.mobile-sub-content {
    max-height: 0;
    overflow: hidden;
    /* ใช้ Ease-out เพื่อให้ความรู้สึกที่ลื่นไหลกว่าตอนกางออก */
    transition: max-height 0.4s cubic-bezier(0, 1, 0, 1); 
}

.mobile-sub-content.open {
    /* ใช้ 1000px เพื่อกันเนื้อหาขาด แต่ animation จะเร็วตามเนื้อหาจริง */
    max-height: 1000px; 
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ย้าย Padding และ Background มาไว้ที่ตัวลูก (inner div) */
.mobile-sub-inner {
    padding-left: 1rem;
    padding-bottom: 1rem; /* เพิ่ม padding ล่างเพื่อให้ปุ่มไม่จมติดขอบ */
    background: #f8fafc;
}

.rotate-icon { transition: transform 0.4s; }

.rotate-icon.active { transform: rotate(180deg); }

/* --- Swiper & Components --- */
.swiper-button-next, .swiper-button-prev { 
    color: var(--cpac-blue) !important; 
    scale: 0.7; 
    transition: 0.3s; 
}

.swiper-button-next:hover, .swiper-button-prev:hover { scale: 0.9; }

.swiper-pagination-bullet-active { 
    background: var(--cpac-blue) !important; 
    width: 24px !important; 
    border-radius: 4px !important; 
    transition: 0.3s; 
}

.float-contact-sync { 
    animation: fluidBounce 3s ease-in-out infinite; 
}

#floating-status {
    transition: all 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fluidBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.project-img-wrap { overflow: hidden; border-radius: 8px; }

.project-img-wrap img { transition: transform 0.8s ease; }

.swiper-slide:hover img { transform: scale(1.1); }

/* --- Service Card Image Slider --- */
@keyframes cardSlider {
    0%, 28%   { transform: translateX(0); } 
    33%, 61%  { transform: translateX(-25%); } 
    66%, 94%  { transform: translateX(-50%); } 
    100%      { transform: translateX(-75%); } 
}

.animate-card-slider {
    animation: cardSlider 15s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

.delay-1 { animation-delay: 0s; }
.delay-2 { animation-delay: -5s; }
.delay-3 { animation-delay: -10s; }

/* --- Utilities --- */
[data-aos] { pointer-events: none; }
.aos-animate { pointer-events: auto; }

/* การ์ดที่มีมิติมากขึ้น */
.service-card-hover {
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.service-card-hover:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 25px 50px -12px rgba(0, 66, 137, 0.15);
}

/* เอฟเฟกต์แสงเงาวิ่งผ่านการ์ด (Shine Effect) */
.shine-effect {
    position: relative;
    overflow: hidden;
}

.shine-effect::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 20%;
    height: 200%;
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(30deg);
    transition: all 0.7s;
    pointer-events: none;
}

.shine-effect:hover::after {
    left: 120%;
}

/* --- New Premium Effects --- */

/* เอฟเฟกต์แสงเงาวิ่งผ่านการ์ด (Shine Effect) */
.card-modern {
    position: relative;
    overflow: hidden;
}

.card-modern::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 20%;
    height: 200%;
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(30deg);
    transition: all 0.7s;
    pointer-events: none;
    z-index: 1;
}

.card-modern:hover::after {
    left: 120%;
}

/* ปรับปรุงการ Hover ให้สมูทขึ้น */
.card-modern:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: 0 25px 50px -12px rgba(0, 66, 137, 0.2) !important;
}

/* FAQ Animation Support */
.rotate-180 {
    transform: rotate(180deg);
}

.faq-content {
    transition: max-height 0.5s cubic-bezier(0, 1, 0, 1);
}

/* --- Premium Animation Fix --- */

/* 1. เอฟเฟกต์ Shine และ Hover สำหรับ Card */
.card-premium {
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card-premium:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 66, 137, 0.15) !important;
}

.card-premium::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.4), transparent);
    transform: skewX(-25deg);
    transition: 0.7s;
}

.card-premium:hover::before {
    left: 125%;
}

/* 2. FAQ Accordion State */
/* FAQ Animation Support */
.accordion-content {
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-header i {
    transition: transform 0.3s ease;
}

.accordion-item.active .accordion-header i {
    transform: rotate(180deg);
}

@keyframes bounceSlow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.animate-bounce-slow {
    animation: bounceSlow 3s ease-in-out infinite;
}

/* --- Premium Animation Fix --- */

/* 1. เอฟเฟกต์ Shine และ Hover สำหรับ Card */
.card-premium {
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card-premium:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 66, 137, 0.15) !important;
}

.card-premium::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.4), transparent);
    transform: skewX(-25deg);
    transition: 0.7s;
}

.card-premium:hover::before {
    left: 125%;
}

/* 2. FAQ Accordion State */
.accordion-content {
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-item.active .accordion-header i {
    transform: rotate(180deg);
}

.accordion-header i {
    transition: transform 0.3s ease;
}

/* 3. ปุ่มลอย Bounce Effect */
@keyframes bounceSlow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.animate-bounce-slow {
    animation: bounceSlow 3s ease-in-out infinite;
}

/* ซ่อนสถานะเริ่มต้น */
    .trigger-card .draw-line-effect { width: 0%; opacity: 0; }
    .trigger-card .pop-icon-effect { transform: scale(0.5) translateY(20px); opacity: 0; }

    /* เมื่อเลื่อนมาเจอ (AOS ใส่ class .aos-animate ให้) ค่อยเล่นอนิเมชัน */
    .aos-animate.trigger-card .draw-line-effect {
        animation: drawLineEffect 0.8s ease-out forwards;
    }
    .aos-animate.trigger-card .pop-icon-effect {
        animation: popIconEffect 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    }

    /* ตั้งค่าหน่วงเวลา (Delay) แยกตามลำดับการ์ด เพื่อให้ไล่ระดับสวยงาม */
    .aos-animate.delay-step-1 .draw-line-effect { animation-delay: 0.1s; }
    .aos-animate.delay-step-1 .pop-icon-effect { animation-delay: 0.3s; }
    
    .aos-animate.delay-step-2 .draw-line-effect { animation-delay: 0.3s; }
    .aos-animate.delay-step-2 .pop-icon-effect { animation-delay: 0.5s; }
    
    .aos-animate.delay-step-3 .draw-line-effect { animation-delay: 0.5s; }
    .aos-animate.delay-step-3 .pop-icon-effect { animation-delay: 0.7s; }
    
    .aos-animate.delay-step-4 .draw-line-effect { animation-delay: 0.7s; }
    .aos-animate.delay-step-4 .pop-icon-effect { animation-delay: 0.9s; }

    /* Keyframes */
    @keyframes drawLineEffect {
        0% { width: 0%; opacity: 0; }
        100% { width: 100%; opacity: 1; }
    }
    @keyframes popIconEffect {
        0% { transform: scale(0.5) translateY(20px); opacity: 0; }
        70% { transform: scale(1.1) translateY(-5px); opacity: 1; }
        100% { transform: scale(1) translateY(0); opacity: 1; }
    }

    @keyframes stepFlashDark {
        0% { 
            background-color: #1e293b; 
            transform: scale(1); 
            box-shadow: none;
        }
        30% { 
            background-color: #2563eb; /* สว่างเป็นสีฟ้า */
            transform: scale(1.1); /* ขยายขึ้นนิดนึง */
            box-shadow: 0 0 25px rgba(37, 99, 235, 0.8);
        }
        100% { 
            background-color: #1e293b; 
            transform: scale(1); 
            box-shadow: none;
        }
    }

    /* สั่งให้ทำงานเมื่อ AOS ตรวจจับได้ว่าเลื่อนจอมาถึงระยะ (ไม่มี delay แอบแฝง) */
    .trigger-step.aos-animate .flash-circle {
        animation: stepFlashDark 1.2s ease-in-out forwards;
    }

    /* อนิเมชันสำหรับโล่ลอย (ทำงานตลอดเวลา) */
    @keyframes floatShield {
        0%, 100% { transform: translateY(0) rotate(-5deg); }
        50% { transform: translateY(-20px) rotate(5deg); }
    }
    .animate-float-shield {
        animation: floatShield 6s ease-in-out infinite;
    }

    /* อนิเมชันไอคอนฝั่งซ้ายเมื่อเลื่อนจอมาถึง */
    @keyframes iconPopScroll {
        0% { transform: scale(0.5) translateY(15px); opacity: 0; color: #94a3b8; }
        60% { transform: scale(1.2) translateY(-5px); color: #3b82f6; opacity: 1; }
        100% { transform: scale(1) translateY(0); color: #004289; opacity: 1; }
    }
    .tech-card .tech-icon { opacity: 0; }
    .tech-card.aos-animate .tech-icon {
        animation: iconPopScroll 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    }

    /* อนิเมชันวงกลมสีเขียวกะพริบ 2 จังหวะ เมื่อเลื่อนจอมาถึง */
    @keyframes checkBlinkScroll {
        0% { transform: scale(0.5); opacity: 0; background-color: transparent; box-shadow: none; }
        20% { transform: scale(1.4); opacity: 1; background-color: #22c55e; box-shadow: 0 0 20px #22c55e; color: #fff; } /* สว่างจังหวะที่ 1 */
        50% { transform: scale(1); background-color: transparent; box-shadow: none; color: #4ade80; } /* ดับลง */
        75% { transform: scale(1.3); background-color: #22c55e; box-shadow: 0 0 15px #22c55e; color: #fff; } /* สว่างจังหวะที่ 2 */
        100% { transform: scale(1); opacity: 1; background-color: rgba(34, 197, 94, 0.15); box-shadow: 0 0 10px rgba(34, 197, 94, 0.3); color: #4ade80; } /* ค้างสถานะเรืองแสงอ่อนๆ */
    }
    .safe-list .check-icon { opacity: 0; }
    .safe-list.aos-animate .check-icon {
        animation: checkBlinkScroll 1s ease-in-out forwards;
    }

        @keyframes led-blink {
        0%, 100% { opacity: 1; scale: 1; }
        50% { opacity: 0.4; scale: 0.9; }
    }
    .animate-led {
        animation: led-blink 1.5s ease-in-out infinite;
    }

    /* สไตล์ปุ่ม Filter ที่ Active */
    .filter-btn.active {
        background-color: #004289;
        color: white;
        border-color: #004289;
    }

    /* Animation เวลาบทความหายไป/ปรากฏ */
    .article-item {
        transition: all 0.4s ease-in-out;
    }

    .article-item.hidden {
        display: none;
        opacity: 0;
        transform: scale(0.9);
    }