/* --- CẤU HÌNH CHUNG --- */
:root {
    --primary-color: #ff6b6b; /* Màu đỏ cam năng động */
    --secondary-color: #4ecdc4; /* Màu xanh ngọc trẻ trung */
    --dark-color: #2d3436;
    --light-color: #f7f1e3;
    --font-main: 'Source Sans Pro', sans-serif;
    --font-heading: 'Playfair Display', serif;
    --font-art: 'Dancing Script', cursive;
    --font-logo: 'MuseoModerno', sans-serif;
}

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

body {
    font-family: var(--font-main);
    line-height: 1.6;
    color: var(--dark-color);
    background-color: var(--light-color);
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* --- ANIMATION CLASSES --- */
.fade-in {
    opacity: 0;
    transform: translateY(50px); /* Dịch xuống dưới 50px */
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
    will-change: opacity, transform;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0); /* Trở về vị trí cũ */
}

/* --- TYPING EFFECT --- */
.typing-cursor::after {
    content: '|';
    animation: blink 1s step-end infinite;
    color: var(--primary-color);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- HEADER & NAVIGATION --- */
header {
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
    position: fixed;
    width: 95%;
    max-width: 1200px;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    border-radius: 50px;
    transition: all 0.3s ease-in-out; /* Hiệu ứng mượt mà cho cả màu nền và vị trí */
}

/* Class khi cuộn trang: Hiện nền trắng và bóng */
header.header-scrolled {
    background: rgba(255, 255, 255, 0.2); /* Nền trắng trong suốt (20%) */
    backdrop-filter: blur(15px); /* Làm mờ nội dung phía sau */
    -webkit-backdrop-filter: blur(15px); /* Hỗ trợ trình duyệt Safari */
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3); /* Viền kính mỏng */
}

/* Class để ẩn header khi cuộn xuống */
header.header-hidden {
    transform: translate(-50%, -200%);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 5%;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    font-family: var(--font-logo);
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Nút menu trên mobile (mặc định ẩn trên PC) */
.menu-toggle {
    display: none;
}

.nav-links a {
    font-weight: 600;
    padding: 10px 20px;
    background-color: var(--light-color);
    border-radius: 25px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.nav-links a:hover,
.nav-links a.active {
    color: #fff;
    background-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(255, 107, 107, 0.3);
}

/* --- HERO SECTION --- */
.hero {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: #fff;
    padding: 0 20px;
    position: relative;
    overflow: hidden; /* Để ảnh không bị tràn ra ngoài khi nhún */
}

.hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: -1;
    transition: transform 0.5s ease-out;
}

/* Lớp phủ màu tối để chữ dễ đọc hơn trên nền ảnh */
.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: -1;
}

/* Hiệu ứng nhún (Nudge Animation) */
@keyframes nudgeLeft {
    0%, 100% { transform: scale(1.05) translateX(0); }
    50% { transform: scale(1.05) translateX(-15px); }
}

.hero-bg.nudge {
    animation: nudgeLeft 3s ease-in-out infinite; /* Chậm lại cho mượt */
}

/* Gợi ý lướt */
.swipe-hint {
    position: absolute; /* Ghim vị trí tuyệt đối */
    bottom: 30px;       /* Cách đáy màn hình 30px */
    left: 50%;          /* Căn giữa theo chiều ngang */
    transform: translateX(-50%); /* Căn chỉnh chính xác giữa */
    z-index: 10;
    font-size: 0.9rem;
    opacity: 0.8;
    animation: blink 2s infinite;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5); /* Thêm bóng chữ cho dễ đọc */
}

.hero h1 {
    font-size: 3.5rem;
    font-family: var(--font-art); /* Dùng font nghệ thuật */
    margin-bottom: 1rem;
    letter-spacing: 1px;
}

.hero p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

.btn {
    padding: 12px 30px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 25px;
    font-weight: bold;
    transition: transform 0.3s, background 0.3s;
}

.btn:hover {
    transform: scale(1.05);
    background: #ff5252;
}

/* --- COUNTDOWN --- */
.countdown-container.fade-in {
    background: var(--secondary-color);
    padding: 40px 20px;
    text-align: center;
    color: #fff;
}

.timer {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.time-box {
    background: rgba(255,255,255,0.2);
    padding: 15px;
    border-radius: 10px;
    min-width: 100px;
}

.time-box span {
    display: block;
    font-size: 2rem;
    font-weight: bold;
}

/* --- ABOUT & SCHEDULE --- */
.section {
    padding: 60px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    text-align: center;
    margin-bottom: 40px;
    font-size: 2rem;
    font-family: var(--font-heading);
    color: var(--primary-color);
    position: relative;
}

.section-title::after {
    content: '';
    display: block;
    width: 50px;
    height: 3px;
    background: var(--dark-color);
    margin: 10px auto;
}

.timeline {
    position: relative;
    border-left: 3px solid var(--secondary-color);
    margin-left: 20px;
    padding-left: 30px;
}

.timeline-item {
    margin-bottom: 30px;
    position: relative;
}

.timeline-item::before {
    content: '';
    width: 15px;
    height: 15px;
    background: var(--primary-color);
    border-radius: 50%;
    position: absolute;
    left: -39px;
    top: 5px;
}

.time {
    font-weight: bold;
    font-family: var(--font-heading);
    color: var(--secondary-color);
}

/* --- FOOTER --- */
footer {
    background: var(--dark-color);
    color: #fff;
    padding: 40px 20px 20px;
    margin-top: auto;
}

.footer-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    max-width: 1000px;
    margin: 0 auto;
    gap: 30px;
}

.footer-col {
    flex: 1;
    min-width: 250px;
}

.footer-col h3 {
    color: var(--primary-color);
    font-family: var(--font-heading);
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.footer-col p, .footer-col a {
    color: #ccc;
    margin-bottom: 10px;
    display: block;
    transition: color 0.3s;
}

.footer-col a:hover {
    color: var(--secondary-color);
}

.social-links {
    display: flex;
    gap: 15px;
}

.social-links a {
    font-size: 1.5rem;
    color: #fff;
    width: 50px;
    height: 50px;
    background: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Màu sắc thương hiệu cho từng icon */
.social-links a.facebook { background-color: #1877F2; }
.social-links a.tiktok { background-color: #000000; border: 1px solid #333; }
.social-links a.instagram { 
    background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285AEB 90%); 
}

.social-links a:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

.copyright {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.9rem;
    color: #888;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .hero h1 { font-size: 2.5rem; }
    
    /* Navbar trên mobile */
    .navbar {
        flex-direction: column;
        gap: 5px;
        padding: 10px 5%;
    }

    .nav-links {
        display: flex; /* Luôn hiển thị */
        position: static;
        width: auto;
        background: transparent;
        box-shadow: none;
        margin-top: 5px;
        flex-direction: row;
        flex-wrap: wrap; /* Tự động xuống dòng */
        justify-content: center;
        padding: 0;
        gap: 8px; /* Khoảng cách giữa các nút nhỏ hơn */
    }

    .nav-links a {
        font-size: 0.8rem; /* Chữ nhỏ hơn */
        padding: 6px 12px; /* Nút gọn hơn */
        width: auto;
        background-color: rgba(255, 255, 255, 0.9); /* Nền trắng rõ hơn chút để dễ đọc */
    }
    .timer { gap: 10px; }
    .time-box { min-width: 70px; }

    /* Chỉnh sửa sơ đồ trên mobile để Lớp trưởng & Bí thư ngang hàng */
    .org-level { gap: 8px; }
    .member-card { width: 48%; padding: 10px 5px; }
    .member-card h3 { font-size: 1rem; }
    .member-card p { font-size: 0.9rem; }
    .avatar { width: 60px; height: 60px; margin-bottom: 5px; }
}

/* --- ORGANIZATION CHART --- */
.org-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.org-level {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.member-card {
    background: #fff;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    text-align: center;
    width: 220px;
    transition: transform 0.3s;
}

.member-card:hover {
    transform: translateY(-5px);
}

.member-card.teacher {
    border: 2px solid var(--primary-color);
}

.avatar {
    width: 80px;
    height: 80px;
    background-color: #eee;
    border-radius: 50%;
    margin: 0 auto 15px;
    /* Bạn có thể thay link ảnh bên dưới */
    background-image: url('https://cdn-icons-png.flaticon.com/512/3135/3135715.png'); 
    background-size: cover;
}

.member-card h3 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    margin-bottom: 5px;
}

/* CSS cho danh sách tổ */
.groups-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    width: 100%;
    margin-top: 20px;
}

.group-box {
    background: #fff;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    flex: 1;
    min-width: 220px;
    text-align: left;
}

.group-box h4 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 5px;
    margin-bottom: 10px;
    text-align: center;
    font-family: var(--font-heading);
}

.group-box ul li {
    font-size: 0.9rem;
    padding: 3px 0;
    border-bottom: 1px dashed #eee;
}

/* CSS cho nhánh quản lý */
.branch-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.deputy-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* --- FLIP CARD EFFECT --- */
.flip-card {
    background-color: transparent;
    width: 220px;
    height: 240px;
    perspective: 1000px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-radius: 15px;
}

/* Chỉ hover trên thiết bị có chuột (Desktop) */
@media (hover: hover) {
    .flip-card:hover .flip-card-inner {
        transform: rotateY(180deg);
    }
}
/* Class để kích hoạt lật thẻ bằng JS (Mobile) */
.flip-card.is-flipped .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 15px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.flip-card-front {
    background-color: #fff;
}

.flip-card-back {
    transform: rotateY(180deg);
    color: #fff;
}

.flip-card-back h3 {
    color: #fff;
    font-family: var(--font-heading);
    margin-bottom: 5px;
}

.flip-card-back p {
    color: #fff;
    font-size: 0.9rem;
}

/* --- BACK TO TOP BUTTON --- */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
    font-size: 1.2rem;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--secondary-color);
    transform: translateY(-5px);
    color: #fff;
}

/* --- MAGAZINE INTERFACE (GIAO DIỆN TẠP CHÍ) --- */
.magazine-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9); /* Nền đen mờ */
    backdrop-filter: blur(10px); /* Hiệu ứng kính mờ */
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateX(100%); /* Ẩn bên phải */
    transition: all 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55); /* Hiệu ứng nảy */
}

.magazine-modal.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.magazine-header {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2001;
}

.close-magazine {
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    background: none;
    border: none;
    transition: transform 0.3s;
    text-shadow: 0 0 10px rgba(255,255,255,0.5);
}
.close-magazine:hover { transform: rotate(90deg); color: var(--primary-color); }

.magazine-container {
    width: 90%;
    height: 80%;
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 20px;
    padding: 100px 20px 40px 20px; /* Tăng khoảng cách trên để dây không bị cắt */
    align-items: flex-start; /* Căn hàng trên cùng để dây thẳng hàng */
    /* Ẩn thanh cuộn */
    scrollbar-width: none; 
    -ms-overflow-style: none;
}

.magazine-container::-webkit-scrollbar { 
    display: none; 
}

.magazine-page {
    flex: 0 0 100%; /* Mỗi trang chiếm 100% chiều rộng container */
    max-width: 400px; 
    scroll-snap-align: center;
    background: transparent; /* Bỏ nền trắng bao quanh div */
    padding: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* --- HIỆU ỨNG DÂY THỪNG & KẸP --- */

/* Dây thừng chạy ngang qua toàn bộ container */
.magazine-page::before {
    content: '';
    position: absolute;
    top: -5px; /* Hạ thấp xuống để khớp với lỗ/kẹp */
    left: -50%; /* Kéo dài sang hai bên */
    width: 200%; /* Đảm bảo nối liền mạch giữa các ảnh */
    height: 3px;
    background: #dcdcdc; /* Màu dây thừng */
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    z-index: 5; /* Dây nằm trên giấy nhưng dưới kẹp/băng dính */
    transform: rotate(0deg); /* Dây thẳng để nối liền đẹp hơn */
}

/* --- CÁC KIỂU KHUNG ẢNH (FRAMES) --- */

.photo-wrap {
    position: relative; /* Để khung tự mở rộng theo ảnh */
    width: auto;
    display: inline-flex;
    flex-direction: column;
    transition: transform 0.5s ease;
    transform-origin: center top;
    will-change: transform;
    z-index: 4; /* Giấy nằm dưới dây */
}

/* Kiểu 1: Polaroid cổ điển (Có lỗ xỏ dây) */
.frame-polaroid {
    background: #fff;
    padding: 15px 15px 25px 15px; /* Dưới dày để viết chữ */
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    transform: rotate(-3deg);
}
.frame-polaroid::before { /* Lỗ đục */
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 15px;
    height: 15px;
    background: transparent; /* Trong suốt để thấy dây xuyên qua */
    border-radius: 50%;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.8);
    z-index: 6; /* Lỗ nằm trên dây */
    border: 2px solid #ccc;
}

/* Kiểu 2: Dán băng dính (Tape) */
.frame-tape {
    background: #fff;
    padding: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transform: rotate(2deg);
}
.frame-tape::before { /* Băng dính */
    content: '';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%) rotate(-2deg);
    width: 120px;
    height: 35px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 6; /* Băng dính đè lên dây */
}

/* Kiểu 3: Giấy cũ kẹp gỗ */
.frame-paper {
    background: #fdfbf7;
    padding: 20px 20px 25px 20px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 15px 30px rgba(0,0,0,0.4);
    transform: rotate(-1deg);
}
.frame-paper::before { /* Kẹp gỗ */
    content: '';
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 50px;
    background: #8e44ad; /* Màu kẹp */
    border-radius: 5px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
    z-index: 6; /* Kẹp đè lên dây */
}

/* Ảnh bên trong */
.photo-wrap img {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 55vh;
    object-fit: cover;
    display: block;
    margin: 0 auto; /* Căn giữa ảnh dọc */
    pointer-events: none;
}

/* --- CAPTION (CHỮ) --- */
.magazine-caption {
    position: relative;
    margin-top: 10px;
    width: 100%;
    text-align: center;
    font-family: var(--font-art);
    font-size: 1.4rem;
    color: #2d3436;
    z-index: 5;
    text-shadow: none;
}

/* --- HIỆU ỨNG FOCUS (KHI LƯỚT TỚI) --- */
.magazine-page.focus {
    z-index: 100; /* Nổi lên trên cùng */
}

.magazine-page.focus .photo-wrap {
    transform: scale(1.1) rotate(0deg) !important; /* Phóng to và thẳng lại */
    box-shadow: 0 30px 60px rgba(0,0,0,0.8); /* Bóng đổ sâu hơn */
    z-index: 10;
}

/* --- CẤU HÌNH RIÊNG CHO PC (MÀN HÌNH LỚN) --- */
@media (min-width: 1024px) {
    .magazine-container {
        gap: 120px; /* Tăng mạnh khoảng cách để khi ảnh phóng to không bị đè lên nhau */
        padding: 80px 100px; /* Căn chỉnh lại lề cho thoáng */
    }
    .magazine-page {
        max-width: 450px; /* Ảnh to hơn để tận dụng màn hình lớn */
    }
}