:root {
    --primary-teal: #00947E;
    --dark-bg: #343a40;
    --primary-purple: #99A9F5;
    --light-bg: #f8f9fa;
    --text-grey: #bcbcbc;
    --text-dark: #212529;
    --text-light: #ffffff;
    --dark-gray-bg: #4b5462;
    --gray-bg: #e0e0e0;
}

/* === โครงสร้างหลักของ Main === */
main {
    display: block;
    width: 100%;
}

.main-hero, 
.main-content-wrapper, 
.video-section {
    width: 100%;
    height: auto;
    box-sizing: border-box;
}

h1 {
    font-size: 1rem;
}

/* === Hero Section === */
.main-hero {
position: relative;
height: 30vh;
padding: 0;
color: var(--text-light);
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
position: relative;
}

.main-hero::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 2;
}

.hero-slider {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.swiper-slide {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
}

.slide-1 { background-image: url('../images/BG_1.webp'); }
.slide-2 { background-image: url('../images/BG_2.webp'); }
.slide-3 { background-image: url('../images/BG_3.webp'); }
.slide-4 { background-image: url('../images/BG_4.webp'); }
.slide-5 { background-image: url('../images/BG_5.webp'); }
.slide-6 { background-image: url('../images/BG_6.webp'); }
.slide-7 { background-image: url('../images/BG_7.webp'); }

.main-hero div.hero-content {
    position: absolute;
    z-index: 3;
    padding: 2rem;
}

.swiper-button-prev,
.swiper-button-next {
    color: var(--light-bg) !important;
    --swiper-navigation-size: 1.5rem;
}

/* === Scroll Down Indicator === */
.scroll-down-indicator {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    color: var(--text-light);
    font-size: 1.5rem;
    cursor: pointer;
    animation: bounce 1.75s infinite;
}

@keyframes bounce {
    0%, 25%, 50%, 75%, 100% {
        transform: translate(-50%, 0);
    }
    35% {
        transform: translate(-50%, -15px);
    }
    65% {
        transform: translate(-50%, -7px);
    }
}

/* === Main Content Layout (Mobile) === */
.main-content-wrapper {
    box-sizing: border-box;
}

.main-article,
.sub-section {
    width: 100%;
    box-sizing: border-box;
}

/* === Article Components === */
@keyframes fadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes hover-card {
  to {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    border-color: var(--primary-purple);
  }
}

.main-article {
    background-color: var(--light-bg);
    padding: 1.5rem;
}

.main-article h2 {
    margin-top: 0;
}

.research-units-section {
    padding: 2rem 1.5rem;
    padding-top: 0px;
    background-color: var(--light-bg);
}

.units-grid-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.unit-card {
    display: flex;
    flex-direction: column;
    text-align: center;
    border: 2px solid var(--gray-bg);
    border-radius: 7px;
    padding: 1rem 1rem;
    opacity: 0;
    transform: translateY(20px);
}

.unit-card.visible {
    animation: fadeIn 0.6s ease-out forwards;
}

.unit-card.is-visible {
    opacity: 1;
    transform: translateY(0);
    transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
}

.unit-card.is-visible:hover {
    border-color: var(--primary-purple);
    box-shadow: 0 0 15px 5px rgba(0, 119, 255, 0.4);
    transform: scale(1.1);
}

.unit-image {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 2px solid var(--gray-bg);
    margin: 0 auto 1rem auto;
    object-fit: cover;
}

.unit-card-content {
    flex-grow: 1;
}

.unit-card h3 {
    font-size: 1.25rem;
    color: var(--text-dark);
    margin-bottom: 1rem;
}

.buttons-wrapper {
    margin-top: auto;
    padding-top: 1rem;
}

.btn-details, .btn-extra-service {
    font-size: 14px;
    background: transparent;
    border-radius: 6px;
    padding: 0.5em 1em;
    color: var(--text-dark);
    text-transform: uppercase;
    position: relative;
    transition: 0.5s ease;
    cursor: pointer;
    text-decoration: none;
    z-index: 1;
}

.btn-details:hover, .btn-extra-service:hover {
    color: var(--text-light);
    transition-delay: 0.4s;
}

.btn-details::after, .btn-extra-service::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    height: 0;
    width: 100%;
    transition: 0.4s ease;
    z-index: -1;
}

.btn-details:hover::after, .btn-extra-service:hover::after {
    height: 100%;
    transition-delay: 0s;
}

.btn-details {
    border: solid 2px var(--primary-teal);
}

.btn-details:hover {
    color: var(--text-light);
}

.btn-details::after {
    background-color: var(--primary-teal);
}

/* === บริการพิเศษ === */
.btn-extra-service {
    border: solid 2px var(--primary-purple);
    color: var(--text-dark);
}

.btn-extra-service:hover {
    border-color: var(--dark-bg);
    color: var(--text-dark);
}

.btn-extra-service::after {
    background-color: var(--primary-purple);
}

.service-manual-section {
    text-align: center;
    padding: 1rem 0;
    border-top: 1px solid var(--gray-bg);
}

/* === aside === */
.sub-section {
    background-color: var(--gray-bg);
    padding: 2rem 1.5rem;
}

.sub-section .arrow-icon {
    display: none;
}

.aside-content {
    text-align: center;
    box-sizing: border-box;
}

.aside-content h3 {
    text-align: left;
    margin-top: 0;
}

.unit-link-image {
    width: 30%;
    margin-bottom: 1rem;
}

/* === Video Section === */
.video-section {
    text-align: center;
    padding: 1rem 1rem;
    background-color: var(--light-bg);
    border-top: 1px solid var(--gray-bg);
}

.video-section h4 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.main-video {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding-top: 56.25%;
    height: 0;
}

.main-video iframe {
    background-color: var(--light-bg) !important;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* === Responsive Layouts === */
.main-content-wrapper {
    display: flex;
    flex-wrap: wrap;
}

.main-article {
    order: 1;
    width: 100%;
}

.video-section {
    order: 2;
    width: 100%;
}

.sub-section {
    order: 3;
    width: 100%;
}

/* === Tablet 1000px ขึ้นไป) === */
@media (min-width: 1000px) {
    h1 {
        font-size: 2rem;
    }

    .main-hero {
        height: 50vh;
    }

    .swiper-button-prev,
    .swiper-button-next {
        --swiper-navigation-size: 2rem;
    }

    .scroll-down-indicator {
        bottom: 15px;
        font-size: 2rem;
    }

    .units-grid-container {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .main-content-wrapper {
        display: flex;
        flex-wrap: wrap;
    }

    .main-article {
        width: 70%;
        margin-bottom: 0;
    }

    .sub-section {
        width: 30%;
        margin-bottom: 0;
    }

    .unit-link-image {
        width: 50%;
    }

    .main-article, .sub-section, .video-section {
        order: initial;
    }

    .main-video {
        width: 80%;
        padding-top: 45%;
    }
}

/* === Desktop Layout & Animation === */
@media (min-width: 1300px) {
    h1 {
        font-size: 2.5rem;
    }

    .main-hero {
        height: 100vh;
    }

    .swiper-button-prev,
    .swiper-button-next {
        --swiper-navigation-size: 2.5rem;
    }

    .scroll-down-indicator {
        bottom: 15px;
        font-size: 2.5rem;
    }

    .units-grid-container {
        grid-template-columns: repeat(3, 1fr);
    }

    .main-content-wrapper {
        display: flex;
        flex-wrap: wrap;
    }

    .main-article {
        width: 70%;
    }
    
    .sub-section {
        width: 30%;
        position: relative;
    }

    .sub-section .arrow-icon {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 2.5rem;
        opacity: 1;
        transition: opacity 0.3s ease;
    }

    .sub-section .aside-content {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        overflow-y: auto;
        padding: 1rem;
        box-sizing: border-box;
        transition: opacity 0.3s ease;
    }

    .main-video {
        width: 60%;
        padding-top: 33.75%;
    }
}
