/* ตั้งค่าพื้นฐาน */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Sarabun', sans-serif;
    overflow: hidden; 
}

/* คอนเทนเนอร์หลัก */
.scroll-container {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory; 
    scroll-behavior: smooth;
}

.step-section {
    height: 100vh;
    scroll-snap-align: start; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* โทนสีพื้นหลัง */
.bg-dark { background-color: #1a1a1a; color: white; }
.bg-light { background-color: #f4f6f9; color: #333; }
.bg-white { 
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    color: #333; 
}

/* --------------------------------------------------- */
/* 🌟 กล่องเนื้อหาหลัก (เพิ่มระบบ Fade Up Animation และป้องกันตกจอ) */
/* --------------------------------------------------- */
.content-box {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    text-align: center;
    
    /* ซ่อนไว้และเลื่อนลงล่างนิดนึง เพื่อรอให้ JS สั่งโชว์ */
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.8s ease-out, transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    will-change: opacity, transform;

    /* 🌟 เพิ่ม 3 บรรทัดนี้ เพื่อกันเหนียวไม่ให้ทะลุขอบจอ และให้เลื่อนได้ถ้าจอเล็กมาก */
    max-height: 95vh;
    overflow-y: auto;
    padding: 10px 5px;
}

/* 🌟 ซ่อน Scrollbar ของ content-box ให้ดูเนียนตา */
.content-box::-webkit-scrollbar { width: 0px; background: transparent; }

/* คลาสนี้ JavaScript จะเป็นคนแอบเติมให้ตอนเลื่อนมาถึง */
.content-box.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.content-box h2 { font-size: 1.5rem; margin-bottom: 5px; color: #222; }
.content-box p { font-size: 1rem; margin-bottom: 10px; color: #555; }

.content-image { width: 100%; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); margin-bottom: 20px; object-fit: cover; }
video { width: 100%; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }

.input-group { width: 100%; text-align: left; margin-bottom: 15px; }
.input-group label { display: block; margin-bottom: 8px; font-weight: bold; color: #444; }

/* --------------------------------------------------- */
/* 🌟 สไตล์แบบ Glassmorphism (ฟอร์มกระจก) */
/* --------------------------------------------------- */
textarea, input[type="text"] {
    width: 100%;
    padding: 15px;
    background: rgba(255, 255, 255, 0.5); 
    backdrop-filter: blur(10px); 
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.8); 
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05); 
    transition: all 0.3s ease;
    color: #333;
}

input[type="text"]:focus, textarea:focus { 
    outline: none; 
    background: rgba(255, 255, 255, 0.9);
    border-color: #212529; 
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1); 
    transform: translateY(-2px); 
}
textarea { height: 100px; }

.input-error { 
    border-color: #dc3545 !important; 
    box-shadow: 0 0 10px rgba(220, 53, 69, 0.2) !important; 
    background: rgba(220, 53, 69, 0.05) !important;
}

/* ปุ่มส่งคำตอบหน้าสุดท้าย */
.btn-submit {
    width: 100%; padding: 15px; background-color: #007bff; color: white;
    border: none; border-radius: 12px; font-size: 1.2rem; font-weight: bold;
    cursor: pointer; margin-top: 10px; transition: background 0.3s, transform 0.2s;
}
.btn-submit:hover { background-color: #0056b3; transform: translateY(-2px); }

/* ปุ่มเริ่มบทเรียน / ปลดล็อก */
.btn-start {
    width: fit-content; 
    min-width: 200px;
    margin: 20px auto 10px auto; 
    padding: 12px 30px; 
    background-color: #212529; 
    color: white;
    border: none; 
    border-radius: 50px; 
    font-size: 1.1rem; 
    font-weight: bold;
    cursor: pointer; 
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15); 
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px; 
}
.btn-start:hover { 
    background-color: #000000; 
    transform: translateY(-3px); 
    box-shadow: 0 6px 20px rgba(0,0,0,0.25); 
}

/* ลูกศรและคำใบ้ */
.scroll-hint {
    margin-top: 30px; text-align: center;
    opacity: 1; visibility: visible;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    display: flex; flex-direction: column; align-items: center;
}
.scroll-hint p { font-size: 0.9rem; margin-bottom: 5px; color: inherit; }
.text-dark { color: #666; }

.bouncing-arrow { color: #212529; animation: bounce 2s infinite; }
.bg-dark .bouncing-arrow { color: #ffffff; }

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
    60% { transform: translateY(-4px); }
}

/* --------------------------------------------------- */
/* 📝 สไตล์สำหรับกล่องคำถามและตัวเลือก (Modern Quiz UI) */
/* --------------------------------------------------- */
.question-container {
    width: 100%;
    margin-top: 10px;
}

.question-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.05);
    text-align: left; 
    width: 100%;
    /* 🌟 ปลดล็อกความสูงของกล่องหลัก ให้เป็นกล่องปกติ เพื่อป้องกันบั๊ก Flex */
}

/* 🌟 แก้บั๊กป้ายตัวเลข (Badge) ตกบรรทัดเมื่อโจทย์ยาว */
.q-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* จัดให้อยู่ชิดบนเสมอ เผื่อโจทย์ยาวหลายบรรทัด */
    gap: 15px; /* ดันให้โจทย์กับป้ายมีระยะห่างกันเสมอ */
    margin-bottom: 18px;
    flex-shrink: 0; /* ไม่ให้ส่วนหัวหดตัว */
}

.question-title {
    font-size: 1.15rem;
    font-weight: bold;
    color: #212529;
    margin-bottom: 0; 
    line-height: 1.6;
    flex-grow: 1; /* ให้ข้อความโจทย์ใช้พื้นที่ที่เหลืออย่างเต็มที่ */
}

/* ป้ายบอกจำนวนข้อ (เช่น 1 / 3) */
.q-badge {
    background-color: #6c757d;
    color: white;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: bold;
    letter-spacing: 1px;
    white-space: nowrap; /* บังคับไม่ให้ตัวอักษรตัดขึ้นบรรทัดใหม่ */
    flex-shrink: 0; /* บังคับไม่ให้กล่องหดตัวเมื่อข้อความโจทย์ยาว */
}

.choice-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px; 
    
    /* 🌟 พระเอกอยู่ตรงนี้: จำกัดความสูงเฉพาะตัวเลือก และล็อคให้ Scroll ไหลลื่น */
    max-height: 40vh; 
    overflow-y: auto; 
    overscroll-behavior: contain; /* ป้องกันไม่ให้การไถนิ้วทะลุไปโดนหน้าจอหลัก */
    -webkit-overflow-scrolling: touch; /* ให้ iOS/Android ไถลื่นๆ ไม่หนืด */
    
    padding-right: 5px; 
    padding-bottom: 5px;
}

/* 🌟 ตกแต่งแถบ Scrollbar ของตัวเลือกให้ดูเรียบร้อย */
.choice-wrapper::-webkit-scrollbar { width: 5px; }
.choice-wrapper::-webkit-scrollbar-track { background: #f1f3f5; border-radius: 10px; }
.choice-wrapper::-webkit-scrollbar-thumb { background: #ced4da; border-radius: 10px; }
.choice-wrapper::-webkit-scrollbar-thumb:hover { background: #adb5bd; }

.custom-choice-box {
    display: block;
    position: relative;
    cursor: pointer;
    margin: 0;
}

.custom-choice-box input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.choice-content {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    transition: all 0.2s ease;
    color: #495057;
    font-size: 1.05rem;
}

.choice-circle {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border-radius: 50%;
    border: 2px solid #adb5bd;
    margin-right: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.choice-circle::after {
    content: '';
    width: 10px;
    height: 10px;
    background: #007bff;
    border-radius: 50%;
    transform: scale(0);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.custom-choice-box:hover .choice-content {
    background: #f8f9fa;
    border-color: #ced4da;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

/* เอฟเฟกต์ตอนกดเลือกคำตอบ */
.custom-choice-box input[type="radio"]:checked ~ .choice-content {
    background: #f0f7ff; 
    border-color: #007bff; 
    color: #0056b3;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.15);
}

.custom-choice-box input[type="radio"]:checked ~ .choice-content .choice-circle {
    border-color: #007bff;
}

.custom-choice-box input[type="radio"]:checked ~ .choice-content .choice-circle::after {
    transform: scale(1);
}

.custom-textarea {
    width: 100%;
    border-radius: 12px !important;
    border: 2px solid #e9ecef !important;
    padding: 15px !important;
    background: #ffffff !important;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.02) !important;
    flex-shrink: 0; /* กันกล่องข้อความหดตัว */
}
.custom-textarea:focus {
    border-color: #007bff !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.1) !important;
}

/* --------------------------------------------------- */
/* 🛑 Custom Modal แจ้งเตือนวิดีโอและอื่นๆ (อัปเดต Typography) */
/* --------------------------------------------------- */
.custom-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center;
    z-index: 9999; opacity: 0; visibility: hidden; transition: 0.3s ease;
}
.custom-modal-overlay.show { opacity: 1; visibility: visible; }

.custom-modal-box {
    background: white; 
    padding: 40px 30px; 
    border-radius: 24px;
    text-align: center; 
    max-width: 400px; 
    width: 85%;
    transform: scale(0.8); 
    transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
    font-family: inherit; 
}
.custom-modal-overlay.show .custom-modal-box { transform: scale(1); }

.alert-icon-wrapper { margin-bottom: 20px; }
.alert-icon-animated {
    font-size: 4.5rem;
    color: #ff4757; 
    animation: pulseAlert 1.5s infinite;
}

@keyframes pulseAlert {
    0% { transform: scale(1); text-shadow: 0 0 0 rgba(255, 71, 87, 0.4); }
    50% { transform: scale(1.1); text-shadow: 0 0 20px rgba(255, 71, 87, 0.6); }
    100% { transform: scale(1); text-shadow: 0 0 0 rgba(255, 71, 87, 0); }
}

.custom-alert-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: #212529;
    line-height: 1.5;
    margin-bottom: 12px;
    padding: 0 10px;
    word-break: break-word; 
}

.custom-alert-desc {
    font-size: 1rem;
    color: #6c757d;
    line-height: 1.6;
    margin-bottom: 25px;
}

.custom-modal-btn {
    background: #ffc107; 
    color: #212529; 
    border: none; 
    padding: 12px 35px;
    border-radius: 50px; 
    font-size: 1.1rem;
    font-weight: bold; 
    font-family: inherit; 
    cursor: pointer; 
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(255, 193, 7, 0.3);
}
.custom-modal-btn:hover { 
    background: #ffb300; 
    transform: translateY(-2px); 
    box-shadow: 0 6px 15px rgba(255, 193, 7, 0.4);
}

/* --------------------------------------------------- */
/* 🔄 สไตล์สำหรับการสไลด์คำถาม (Question Flip) */
/* --------------------------------------------------- */
.q-slide {
    animation: fadeInSlide 0.4s ease forwards;
    /* 🌟 เอา Flex ที่ทับซ้อนออก เพื่อไม่ให้เบราว์เซอร์คำนวณความสูงพลาด */
}

@keyframes fadeInSlide {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.q-nav-buttons .btn {
    font-weight: bold;
    transition: all 0.2s ease;
}

.q-nav-buttons .btn-primary {
    background-color: #007bff;
    border: none;
}

.q-nav-buttons .btn-primary:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3) !important;
}

/* ซ่อนปุ่มยืนยันหลักของ Section ไว้ก่อน ถ่ายังทำไม่ถึงข้อสุดท้าย */
.hide-main-btn {
    display: none !important;
}

/* --------------------------------------------------- */
/* 🔄 สไตล์ปุ่ม ย้อนกลับ / ถัดไป (ไม่พึ่ง Bootstrap) */
/* --------------------------------------------------- */

/* กล่องครอบปุ่มนำทาง */
.q-nav-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: 15px; /* ปรับลด margin นิดนึงให้กระชับขึ้น */
    flex-shrink: 0; /* 🌟 ป้องกันกล่องโดนบีบจนตกจอ */
}

/* ปุ่มนำทางพื้นฐาน */
.nav-btn {
    padding: 10px 24px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    outline: none;
}

/* ปุ่มย้อนกลับ (สีขาวขอบเทา) */
.nav-btn-prev {
    background-color: #ffffff;
    color: #6c757d;
    border: 2px solid #dee2e6;
}
.nav-btn-prev:hover {
    background-color: #f8f9fa;
    color: #343a40;
    border-color: #adb5bd;
    transform: translateX(-4px); /* ลูกเล่นขยับไปทางซ้ายนิดๆ */
}

/* ปุ่มถัดไป (สีฟ้าเด่น) */
.nav-btn-next {
    background-color: #007bff;
    color: #ffffff;
    border: 2px solid #007bff;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}
.nav-btn-next:hover {
    background-color: #0056b3;
    border-color: #0056b3;
    transform: translateX(4px); /* ลูกเล่นขยับไปทางขวานิดๆ */
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

/* --------------------------------------------------- */
/* 📱 Slide to Unlock (สไตล์ iPhone) */
/* --------------------------------------------------- */
.unlock-slider-wrapper {
    width: 100%;
    max-width: 320px;
    margin: 15px auto 0 auto; /* ปรับลด margin นิดนึง */
    transition: opacity 0.5s ease;
    flex-shrink: 0; /* 🌟 ป้องกันกล่องโดนบีบจนตกจอ */
}

.unlock-slider {
    position: relative;
    height: 56px;
    background: rgba(33, 37, 41, 0.85); /* สีเทาเข้มโปร่งแสงนิดๆ */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 30px;
    display: flex;
    align-items: center;
    overflow: hidden;
    box-shadow: inset 0 3px 6px rgba(0,0,0,0.4), 0 4px 15px rgba(0,0,0,0.1);
}

.unlock-text {
    width: 100%;
    text-align: center;
    font-weight: bold;
    font-size: 1.1rem;
    user-select: none;
    pointer-events: none;
    z-index: 1;
    
    /* เอฟเฟกต์สะท้อนแสงแว้บๆ สไตล์ iPhone */
    background: linear-gradient(90deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,1) 50%, rgba(255,255,255,0.4) 100%);
    background-size: 200% auto;
    color: transparent;
    -webkit-background-clip: text;
    background-clip: text;
    animation: shimmerText 2.5s linear infinite;
}

@keyframes shimmerText {
    0% { background-position: -100% center; }
    100% { background-position: 200% center; }
}

.unlock-thumb {
    position: absolute;
    left: 4px;
    top: 4px;
    width: 48px;
    height: 48px;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #212529;
    font-size: 1.2rem;
    cursor: grab;
    z-index: 2;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.unlock-thumb:active { cursor: grabbing; }
.unlock-thumb.snapping { transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* สถานะเมื่อปลดล็อกสำเร็จ */
.unlock-slider.unlocked {
    background: #198754; /* สีเขียว Success */
    transition: background 0.4s ease;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2), 0 4px 15px rgba(25, 135, 84, 0.3);
}
.unlock-slider.unlocked .unlock-text {
    animation: none;
    background: none;
    color: #ffffff;
    -webkit-text-fill-color: #ffffff;
    padding-left: 20px;
}
.unlock-slider.unlocked .unlock-thumb {
    color: #198754;
    cursor: default;
}

/* ==========================================
   🌟 Effect: เคอร์เซอร์กะพริบสำหรับพิมพ์ดีด (Typewriting)
   ========================================== */
.typing-cursor::after {
    content: '|';
    font-weight: bold;
    color: #d32f2f;
    animation: blink 0.8s infinite;
    margin-left: 3px;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}