* { margin: 0; padding: 0; box-sizing: border-box; }

/* ========================================= */
/* --- System Variables --- */
/* ========================================= */
:root {
    --primary-color: #eab308;
    --primary-hover: #ca8a04;
}


body {
    font-family: 'Kanit', sans-serif;
    color: #ffffff;
    overflow-x: hidden; 
}

.hero-bg {
    width: 100vw;
    min-height: 100vh; 
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    transition: background-image 0.5s ease-in-out;
    position: relative;
}

/* ========================================= */
/* --- Header: โลโก้ด้านบน ชื่อด้านล่าง --- */
/* ========================================= */
header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 30px; 
    z-index: 10;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent 100%);
}

.college-brand { display: flex; flex-direction: column; align-items: center; gap: 15px; }
.college-logo { height: 135px; width: auto; object-fit: contain; filter: drop-shadow(2px 2px 5px rgba(0,0,0,0.5)); transition: all 0.3s ease; }
.college-name { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }

.char-box {
    position: relative;
    display: inline-block;
    font-family: 'Kanit', sans-serif;
    font-size: clamp(24px, 5vw, 90px); 
    font-weight: 600;
    color: #ffffff; 
    z-index: 1; 
    transform-origin: top center;
    transform: perspective(600px) rotateX(-90deg);
    opacity: 0;
    animation: unfoldChar 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.char-box::before {
    content: attr(data-char);
    position: absolute;
    left: 0;
    top: 0;
    z-index: -1; 
    color: transparent; 
    -webkit-text-stroke: 6px transparent;
    background: linear-gradient(90deg, #ff0000 0%, transparent 25%, #00d2ff 50%, transparent 75%, #ff0000 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text; 
    background-clip: text;
    animation: runningStroke 1.5s linear infinite;
    filter: blur(2px) drop-shadow(0 0 5px rgba(255,0,0,0.4));
}

@keyframes unfoldChar {
    0% { transform: perspective(600px) rotateX(-90deg); opacity: 0; }
    60% { transform: perspective(600px) rotateX(15deg); opacity: 1; }
    100% { transform: perspective(600px) rotateX(0deg); opacity: 1; }
}

@keyframes runningStroke {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

/* ========================================= */
/* --- Main Content --- */
/* ========================================= */
main {
    flex: 1;
    display: flex;
    flex-direction: column; 
    justify-content: flex-end; 
    padding: 20px 5% 120px 5%; 
    gap: 30px;
    z-index: 20;
}

.left-content { width: 100%; transition: opacity 0.5s; pointer-events: auto; }
.subtitle { font-size: 14px; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 10px; display: flex; align-items: center; }
.subtitle::before { content: ''; width: 30px; height: 2px; background: #fff; margin-right: 15px; }
.title { font-family: 'Oswald', sans-serif; font-size: clamp(30px, 5vw, 60px); line-height: 1.1; margin-bottom: 15px; text-shadow: 2px 4px 10px rgba(0,0,0,0.7); }
.desc { font-size: clamp(14px, 1.8vw, 16px); line-height: 1.6; max-width: 600px; margin-bottom: 25px; text-shadow: 1px 1px 5px rgba(0,0,0,0.8); }

.explore-btn {
    background-color: var(--primary-color); color: #000; padding: 10px 25px 10px 10px; border-radius: 40px;
    font-weight: 600; display: inline-flex; align-items: center; gap: 15px; text-decoration: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); transition: 0.3s;
}
.explore-btn:hover { background-color: var(--primary-hover); transform: translateY(-3px); }
.play-icon { width: 35px; height: 35px; background: #fff; border-radius: 50%; display: flex; justify-content: center; align-items: center; }

.right-content { width: 100%; height: 250px; position: relative; pointer-events: auto; }
.carousel-container { width: 100%; height: 100%; overflow: hidden; }
.carousel-track { display: flex; gap: 20px; height: 100%; }

.card {
    min-width: 170px; height: 100%; border-radius: 12px;
    background-size: cover; background-position: center; position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5); cursor: pointer; transition: 0.3s;
}
.card:hover { transform: translateY(-10px); }
.card::after { content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 70%; background: linear-gradient(to top, rgba(0,0,0,0.9), transparent); }
.card-content { position: absolute; bottom: 15px; left: 15px; z-index: 2; }
.card-content h4 { font-size: 10px; color: #ccc; text-transform: uppercase; }
.card-content h3 { font-family: 'Oswald', sans-serif; font-size: 14px; }

.bottom-controls { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 0 5% 30px 5%; position: absolute; bottom: 0; left: 0; z-index: 20; }
.arrow-btn { width: 45px; height: 45px; border-radius: 50%; background: var(--primary-color); color: #000; border: none; font-size: 18px; font-weight: bold; cursor: pointer; transition: 0.3s; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); }
.arrow-btn:hover { transform: scale(1.1); }
.progress-bar { flex: 1; max-width: 300px; height: 3px; background: rgba(255,255,255,0.3); margin: 0 20px; position: relative; border-radius: 2px;}
.progress-fill { position: absolute; left: 0; top: 0; height: 100%; background: var(--primary-color); transition: width 0.4s ease; border-radius: 2px;}
.slide-number { font-family: 'Oswald', sans-serif; font-size: 20px; font-weight: 500; width: 25px; text-align: center; }

/* ========================================= */
/* --- Top Right Controls --- */
/* ========================================= */
.top-right-controls { position: absolute; top: 20px; right: 30px; display: flex; gap: 10px; z-index: 100; transition: all 0.3s; }
.control-btn {
    background-color: rgba(0, 0, 0, 0.6); color: #ffffff; border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px; padding: 8px 15px; font-family: 'Oswald', 'Kanit', sans-serif; font-size: 16px;
    cursor: pointer; transition: all 0.3s ease; backdrop-filter: blur(5px);
}
.control-btn:hover { background-color: var(--primary-color); color: #000000; transform: translateY(-2px); }

/* ========================================= */
/* --- Light Mode Styles --- */
/* ========================================= */
body.light-mode { color: #222222; }
body.light-mode header { background: linear-gradient(to bottom, rgba(255,255,255,0.9), transparent 100%); }
body.light-mode .char-box { color: #111111; text-shadow: 2px 2px 5px rgba(255,255,255,0.8); }
body.light-mode .subtitle::before { background: #222222; }
body.light-mode .title { text-shadow: 2px 2px 10px rgba(255,255,255,0.9); }
body.light-mode .desc { text-shadow: 1px 1px 5px rgba(255,255,255,0.9); font-weight: 600; }
body.light-mode .card::after { background: linear-gradient(to top, rgba(255,255,255,0.95), transparent); }
body.light-mode .card-content h4 { color: #666666; }
body.light-mode .card-content h3 { color: #111111; text-shadow: 1px 1px 3px rgba(255,255,255,0.8); }

/* ========================================= */
/* --- Popup Modal --- */
/* ========================================= */
.popup-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: rgba(0, 0, 0, 0.85); display: flex; justify-content: center; align-items: center;
    z-index: 1000; opacity: 0; visibility: hidden; transition: opacity 0.4s ease, visibility 0.4s ease; backdrop-filter: blur(5px);
}
.popup-overlay.show { opacity: 1; visibility: visible; }

.popup-content {
    position: relative; max-width: 70vw; max-height: 75vh; 
    display: flex; justify-content: center; align-items: center;
    border-radius: 12px; transform: scale(0.7); transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.popup-overlay.show .popup-content { transform: scale(1); }


.popup-link {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    max-height: 75vh;
    color: inherit;
    text-decoration: none;
}

.popup-link.is-disabled {
    cursor: default;
}

.popup-image {
    max-width: 100%; max-height: 75vh; width: auto; height: auto;
    object-fit: contain; border-radius: 12px; box-shadow: 0 15px 35px rgba(0,0,0,0.5); transition: opacity 0.2s ease;
}

.popup-close {
    position: absolute; top: 15px; right: 15px; width: 35px; height: 35px;
    background-color: rgba(0, 0, 0, 0.6); color: #ffffff; border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%; font-size: 22px; font-weight: bold; cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    z-index: 1005; transition: all 0.3s ease; padding-bottom: 3px; 
}
.popup-close:hover { background-color: var(--primary-color); color: #000; border-color: var(--primary-color); transform: scale(1.1) rotate(90deg); }

.popup-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.6); color: #ffffff; border: 2px solid rgba(255, 255, 255, 0.5);
    width: 45px; height: 45px; border-radius: 50%; font-size: 20px; cursor: pointer;
    display: flex; justify-content: center; align-items: center; transition: all 0.3s ease;
    z-index: 1010 !important; -webkit-tap-highlight-color: transparent;
}
.popup-nav:hover, .popup-nav:active { background-color: var(--primary-color); color: #000; border-color: var(--primary-color); }
.popup-nav.right { right: -20px; }

/* ========================================= */
/* --- Responsive (Desktop, Tablet, Mobile) --- */
/* ========================================= */

/* --- 1. คอมพิวเตอร์ (Desktop: 1024px ขึ้นไป) --- */
@media (min-width: 1024px) {
    main { flex-direction: row; align-items: flex-end; padding-bottom: 120px; }
    .left-content { width: 45%; }
    .right-content { width: 55%; height: 320px; }
    .card { min-width: 200px; }
    .bottom-controls { width: auto; right: 5%; left: auto; gap: 20px; }
}

/* --- 2. ไอแพดและแท็บเล็ต (Tablet/iPad: 768px ถึง 1023px) --- */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    header { padding-top: 20px; }
    .college-logo { height: 100px; }
    .char-box { font-size: 40px !important; }
    .char-box::before { -webkit-text-stroke: 4px transparent; }
    
    main { padding-top: 150px; padding-bottom: 100px; gap: 20px; justify-content: center; }
    .title { font-size: 45px !important; }
    .desc { font-size: 15px; margin-bottom: 20px; max-width: 100%; }
    
    .right-content { height: 260px; }
    .card { min-width: 180px; }
    
    .popup-content { max-width: 85vw; max-height: 65vh; }
    .popup-image { max-height: 65vh; width: 100%; object-fit: contain; }
    .popup-close { top: 10px; right: 10px; width: 40px; height: 40px; font-size: 22px; }
    .popup-nav { width: 50px !important; height: 50px !important; font-size: 22px !important; }
    .popup-nav.right { right: 15px !important; }
}

/* --- 3. โทรศัพท์มือถือทั่วไป (Mobile: ต่ำกว่า 768px) --- */
@media screen and (max-width: 767px) {
    header { padding-top: 15px; }
    .college-brand { gap: 10px; }
    .college-logo { height: 70px; }
    .char-box { font-size: 26px !important; }
    .char-box::before { -webkit-text-stroke: 3px transparent; }
    
    .top-right-controls { top: 10px; right: 10px; transform: scale(0.85); transform-origin: top right; }

    main { padding-top: 140px; justify-content: center; padding-bottom: 90px; gap: 15px; }
    .title { font-size: 32px !important; margin-bottom: 10px; }
    .desc { font-size: 13px; line-height: 1.5; margin-bottom: 15px; }
    
    .right-content { height: 220px; }
    .card { min-width: 150px; }
    
    .bottom-controls { padding-bottom: 20px; }
    
    .popup-content { max-width: 95vw; max-height: 65vh; }
    .popup-image { max-height: 65vh; width: 100%; object-fit: contain; }
    .popup-close { top: 5px; right: 5px; width: 35px; height: 35px; font-size: 18px; }
    
    .popup-nav { width: 40px !important; height: 40px !important; font-size: 20px !important; }
    .popup-nav.right { right: 10px !important; } 
}

/* --- 4. โทรศัพท์มือถือจอเล็กมาก (Small Mobile: ต่ำกว่า 400px) --- */
@media screen and (max-width: 400px) {
    .college-logo { height: 55px; }
    .char-box { font-size: 20px !important; }
    .title { font-size: 26px !important; }
    .desc { font-size: 12px; }
    
    .right-content { height: 180px; }
    .card { min-width: 130px; }
    .card-content h3 { font-size: 12px; }
}