/* ========== GLOBAL & VARIABLES ========== */
:root {
    --deep-space: #0a0f2c;
    --cosmic-blue: #0b2b5e;
    --nebula-purple: #5e2e8c;
    --quantum-glow: #00d4ff;
    --dark-bg: #050914;
    --card-glass: rgba(15, 25, 55, 0.65);
    --border-glow: rgba(0, 212, 255, 0.3);
    --text-light: #f0f4ff;
    --accent-purple: #8b5cf6;
}

/* ========== BODY & BACKGROUND ========== */
body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    color: var(--text-light);
    scroll-behavior: smooth;
    overflow-x: hidden;
    background-color: #020617 !important;
    background-image:
        linear-gradient(rgba(0, 212, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 212, 255, 0.04) 1px, transparent 1px),
        radial-gradient(circle at 20% 30%, #0a0f2c 0%, #020617 100%) !important;
    background-size: 40px 40px, 40px 40px, 100% 100% !important;
    background-attachment: fixed;
}

h1, h2, h3, h4, h5, .nav-link, .btn, .brand-font {
    font-family: 'Prompt', sans-serif;
}

a { color: var(--quantum-glow); }
a:hover { color: #6ee7ff; }

/* ========== NAVBAR ========== */
.navbar-glass {
    background: rgba(5, 9, 20, 0.85) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(0, 212, 255, 0.15);
    transition: all 0.3s ease;
    z-index: 1050;
}
.navbar-glass.scrolled {
    background: rgba(2, 6, 23, 0.95) !important;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}
.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    background: linear-gradient(135deg, #FFFFFF 30%, #00d4ff 100%);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}
.nav-link {
    font-weight: 500;
    color: #c8d6f0 !important;
    margin: 0 0.15rem;
    padding: 0.5rem 0.8rem !important;
    border-radius: 12px;
    transition: all 0.25s ease;
}
.nav-link:hover, .nav-link.active {
    color: var(--quantum-glow) !important;
    background: rgba(0, 212, 255, 0.08);
    text-shadow: 0 0 8px rgba(0, 212, 255, 0.4);
}

/* ========== HERO POSTER - BANNER BACKGROUND ========== */
.hero-poster {
    position: relative;
    background-image: url('../photo/banner1.webp');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    border-bottom: 2px solid rgba(0, 212, 255, 0.4);
    overflow: hidden;
    min-height: 75vh;
    display: flex;
    align-items: center;
}
/* Dark overlay บางๆ เพื่อให้อ่านข้อความได้ แต่ยังเห็นรูปชัด */
.hero-poster::before {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.1);
    z-index: 1;
}
/* Gradient fade ด้านล่าง */
.hero-poster::after {
    content: "";
    position: absolute;
    bottom: 0; left: 0; width: 100%; height: 120px;
    background: linear-gradient(to top, #020617, transparent);
    z-index: 1;
}
.hero-content {
    position: relative;
    z-index: 2;
    padding: 4rem 0;
}
.glow-text {
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.5), 0 0 60px rgba(0, 212, 255, 0.15);
}
.badge-science {
    background: rgba(30, 42, 94, 0.8);
    color: #a0e7ff;
    border-radius: 30px;
    font-size: 0.78rem;
    padding: 0.35rem 1rem;
    border: 1px solid rgba(0, 212, 255, 0.2);
    display: inline-block;
    backdrop-filter: blur(4px);
}

/* ========== BUTTONS ========== */
.btn-outline-quantum {
    border: 1.5px solid var(--quantum-glow);
    background: transparent;
    color: var(--quantum-glow);
    border-radius: 40px;
    padding: 0.6rem 1.8rem;
    transition: all 0.3s ease;
    font-weight: 600;
}
.btn-outline-quantum:hover {
    background: var(--quantum-glow);
    color: #0a0f2c;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.5), 0 0 40px rgba(0, 212, 255, 0.2);
    transform: translateY(-2px);
}
.btn-solid-quantum {
    background: linear-gradient(135deg, #00d4ff, #8b5cf6);
    border: none;
    color: #fff;
    font-weight: 700;
    border-radius: 40px;
    padding: 0.65rem 2rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.25);
}
.btn-solid-quantum:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 212, 255, 0.4);
    color: #fff;
}

/* ========== LAB CARDS ========== */
.lab-card {
    background: var(--card-glass);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    border: 1px solid rgba(0, 212, 255, 0.15);
    transition: all 0.4s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    overflow: hidden;
    height: 100%;
    position: relative;
}
.lab-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 3px;
    background: linear-gradient(90deg, transparent, var(--quantum-glow), var(--accent-purple), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}
.lab-card:hover {
    transform: translateY(-10px);
    border-color: rgba(0, 212, 255, 0.4);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 212, 255, 0.15);
}
.lab-card:hover::before { opacity: 1; }
.lab-img {
    height: 200px;
    object-fit: cover;
    width: 100%;
    transition: transform 0.5s ease;
}
.lab-card:hover .lab-img { transform: scale(1.08); }
.lab-icon {
    font-size: 2rem;
    background: rgba(0, 212, 255, 0.1);
    width: 52px; height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    color: var(--quantum-glow);
    border: 1px solid rgba(0, 212, 255, 0.15);
}
.stats-badge {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    border-radius: 40px;
    padding: 0.25rem 0.8rem;
    font-size: 0.72rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ========== NEWS CAROUSEL ========== */
.news-carousel .carousel-item img {
    border-radius: 16px;
    max-height: 400px;
    object-fit: cover;
}

/* ========== HIGHLIGHT BOX ========== */
.highlight-box {
    background: linear-gradient(120deg, rgba(11, 26, 58, 0.9), rgba(14, 19, 64, 0.9));
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 24px;
    position: relative;
    overflow: hidden;
}

/* ========== SECTION HEADERS ========== */
.section-header {
    position: relative;
    display: inline-block;
}
.section-header::after {
    content: "";
    display: block;
    width: 60px; height: 3px;
    background: linear-gradient(90deg, var(--quantum-glow), var(--accent-purple));
    margin: 0.8rem auto 0;
    border-radius: 2px;
}

/* ========== FOOTER ========== */
.footer-sci {
    background: rgba(2, 6, 23, 0.95) !important;
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(0, 212, 255, 0.2);
}
.footer-sci a {
    color: #8899bb;
    text-decoration: none;
    transition: color 0.2s;
}
.footer-sci a:hover { color: var(--quantum-glow); }
.social-icon {
    width: 40px; height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(0, 212, 255, 0.08);
    border: 1px solid rgba(0, 212, 255, 0.15);
    color: var(--quantum-glow);
    transition: all 0.25s ease;
    cursor: pointer;
    font-size: 1.1rem;
}
.social-icon:hover {
    background: rgba(0, 212, 255, 0.2);
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.2);
}

/* ========== SCROLL TO TOP ========== */
.scroll-top-btn {
    position: fixed;
    bottom: 30px; right: 30px;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--quantum-glow), var(--accent-purple));
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 999;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
}
.scroll-top-btn.show { opacity: 1; transform: translateY(0); }
.scroll-top-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 212, 255, 0.5);
}

/* ========== PARTICLES ========== */
.particles-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}
.particle {
    position: absolute;
    border-radius: 50%;
    background: var(--quantum-glow);
    opacity: 0.15;
    animation: floatParticle 20s infinite ease-in-out;
}
.particle:nth-child(1) { width: 4px; height: 4px; top: 10%; left: 20%; animation-delay: 0s; animation-duration: 25s; }
.particle:nth-child(2) { width: 6px; height: 6px; top: 30%; left: 70%; animation-delay: 3s; animation-duration: 20s; }
.particle:nth-child(3) { width: 3px; height: 3px; top: 60%; left: 40%; animation-delay: 6s; animation-duration: 30s; }
.particle:nth-child(4) { width: 5px; height: 5px; top: 80%; left: 80%; animation-delay: 2s; animation-duration: 22s; background: var(--accent-purple); }
.particle:nth-child(5) { width: 4px; height: 4px; top: 50%; left: 10%; animation-delay: 8s; animation-duration: 28s; }
.particle:nth-child(6) { width: 7px; height: 7px; top: 20%; left: 90%; animation-delay: 4s; animation-duration: 18s; background: var(--accent-purple); opacity: 0.1; }

@keyframes floatParticle {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -50px) scale(1.2); }
    50% { transform: translate(-20px, 30px) scale(0.8); }
    75% { transform: translate(40px, 20px) scale(1.1); }
}

/* ========== DIVIDER ========== */
hr {
    opacity: 0.2;
    background: linear-gradient(90deg, transparent, var(--quantum-glow), transparent);
    height: 1px;
    border: none;
}

/* ========== FADE-UP ANIMATION ========== */
/* Fade-up: แสดงผลได้เลยแม้ JS ไม่โหลด */
.fade-up {
    opacity: 1;
    transform: translateY(0);
}
/* ถ้า JS โหลดได้ จะเพิ่ม class นี้ให้ body แล้ว reset เป็น hidden ก่อน */
body.js-loaded .fade-up {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease-out;
}
body.js-loaded .fade-up.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ========== FOLDER DIAGRAM ========== */
.folder-diagram {
    background: rgba(11, 17, 32, 0.8);
    border-radius: 20px;
    border-left: 4px solid var(--quantum-glow);
    font-family: 'Courier New', monospace;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(25px); }
    to { opacity: 1; transform: translateY(0); }
}
section { animation: fadeUp 0.6s ease-out forwards; }

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

/* ---------- TABLET (max-width: 991px) ---------- */
@media (max-width: 991.98px) {
    .hero-poster {
        min-height: 60vh;
    }
    .hero-content {
        padding: 3rem 0;
    }
    h1.display-4 {
        font-size: 2.2rem;
    }
    h2.display-6 {
        font-size: 1.4rem;
    }
    .hero-content .col-lg-5 {
        display: none;
    }
    .lab-img {
        height: 180px;
    }
    .navbar-brand {
        font-size: 1.3rem;
    }
    .nav-link {
        padding: 0.6rem 1rem !important;
    }
    .news-carousel .carousel-item img {
        max-height: 300px;
    }
}

/* ---------- MOBILE LANDSCAPE & SMALL TABLET (max-width: 767px) ---------- */
@media (max-width: 767.98px) {
    .hero-poster {
        min-height: 55vh;
    }
    .hero-content {
        padding: 2rem 0;
        text-align: center;
    }
    h1.display-4 {
        font-size: 1.8rem;
    }
    h2.display-6 {
        font-size: 1.15rem;
    }
    .hero-content .lead {
        font-size: 0.95rem;
        max-width: 100% !important;
    }
    .hero-content .row.mt-4 {
        justify-content: center;
        font-size: 0.85rem;
    }
    .btn-outline-quantum,
    .btn-solid-quantum {
        padding: 0.5rem 1.4rem;
        font-size: 0.9rem;
    }
    .lab-card {
        border-radius: 18px;
    }
    .lab-img {
        height: 160px;
    }
    .lab-icon {
        width: 44px; height: 44px;
        font-size: 1.6rem;
        border-radius: 12px;
    }
    .stats-badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.6rem;
    }
    .lab-card .p-4 {
        padding: 1rem !important;
    }
    .lab-card h3,
    .lab-card h4 {
        font-size: 1rem;
    }
    .lab-card p {
        font-size: 0.8rem;
    }
    .highlight-box {
        padding: 1.5rem !important;
        border-radius: 18px;
    }
    .highlight-box h4 {
        font-size: 1rem;
    }
    .section-header {
        font-size: 1.3rem;
    }
    .news-carousel .carousel-item img {
        max-height: 200px;
    }
    .news-carousel h3 {
        font-size: 1rem;
    }
    .news-carousel p {
        font-size: 0.85rem;
    }
    .footer-sci .row > div {
        text-align: center;
    }
    .footer-sci .d-flex.gap-2 {
        justify-content: center;
    }
    .scroll-top-btn {
        bottom: 20px;
        right: 20px;
        width: 42px; height: 42px;
    }
    .navbar-glass {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* ---------- MOBILE PORTRAIT (max-width: 575px) ---------- */
@media (max-width: 575.98px) {
    .hero-poster {
        min-height: 50vh;
    }
    h1.display-4 {
        font-size: 1.5rem;
    }
    h2.display-6 {
        font-size: 1rem;
    }
    .badge-science {
        font-size: 0.65rem;
        padding: 0.25rem 0.7rem;
    }
    .hero-content .d-flex.gap-3 {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem !important;
    }
    .hero-content .d-flex.gap-3 .btn {
        width: 100%;
        max-width: 280px;
    }
    .hero-content .row.mt-4 .col-auto {
        font-size: 0.78rem;
    }
    .lab-img {
        height: 140px;
    }
    .lab-card:hover {
        transform: translateY(-5px);
    }
    .carousel-control-prev,
    .carousel-control-next {
        width: 30px;
    }
    .footer-sci h4 {
        font-size: 1.1rem;
    }
    .footer-sci h5 {
        font-size: 1rem;
    }
    .footer-sci p {
        font-size: 0.85rem;
    }
    .social-icon {
        width: 36px; height: 36px;
        font-size: 1rem;
    }
}

/* ---------- VERY SMALL SCREENS (max-width: 375px) ---------- */
@media (max-width: 375px) {
    h1.display-4 {
        font-size: 1.3rem;
    }
    h2.display-6 {
        font-size: 0.9rem;
    }
    .navbar-brand {
        font-size: 1.1rem;
    }
    .lab-img {
        height: 120px;
    }
}

/* ---------- LARGE DESKTOP (min-width: 1400px) ---------- */
@media (min-width: 1400px) {
    .hero-poster {
        min-height: 80vh;
    }
    .hero-content {
        padding: 5rem 0;
    }
    .lab-img {
        height: 220px;
    }
}