/* ===== Quiz Styles ===== */

/* Quiz fullscreen layout */
.quiz-fullscreen {
    height: 100vh;
    height: 100dvh; /* Dynamic viewport for mobile browsers */
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
}

/* Quiz Carousel */
.quiz-carousel {
    touch-action: pan-y;
    user-select: none;
    min-height: 0;
    position: relative;
    flex: 1;
    overflow: hidden;
}

.quiz-cards-wrapper {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    height: 100%;
}

/* Question Card */
.question-card {
    min-width: 100%;
    max-width: 100%;
    padding: 8px 12px;
    flex-shrink: 0;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-padding-top: 8px;
}

/* Ensure card scroll resets to top when navigated to */
.question-card::-webkit-scrollbar {
    display: none;
}
.question-card {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.question-card-inner {
    background: white;
    border-radius: 20px;
    padding: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
    min-height: 0;
    display: flex;
    flex-direction: column;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: 2px solid transparent;
    position: relative;
}

.question-card-inner.answered {
    border-color: #E8E7FF;
    background: #FAFAFF;
}

.question-card-inner.correct {
    border-color: #2E7D32;
    background: linear-gradient(135deg, #F0FFF9, #E8FFF6);
}

.question-card-inner.partial {
    border-color: #FFC107;
    background: linear-gradient(135deg, #FFFDF0, #FFF8E1);
}

.question-card-inner.wrong {
    border-color: #B5432A;
    background: linear-gradient(135deg, #FFF5F7, #FFEBEE);
}

/* Locked indicator */
.question-card-inner.answered::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    width: 20px;
    height: 20px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%239CA3AF' viewBox='0 0 20 20'%3E%3Cpath fill-rule='evenodd' d='M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z' clip-rule='evenodd'/%3E%3C/svg%3E") center/contain no-repeat;
    opacity: 0.3;
}

/* Question number badge */
.question-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1B3A5C, #2A5580);
    color: white;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}

/* Media container */
.question-media {
    width: 100%;
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 12px;
    position: relative;
    background: #f3f4f6;
    flex-shrink: 0;
    cursor: pointer;
}

.question-media img {
    width: 100%;
    height: auto;
    max-height: 50vh;
    object-fit: contain;
    border-radius: 14px;
    transition: opacity 0.3s;
}

.question-media video {
    width: 100%;
    height: auto;
    max-height: 50vh;
    border-radius: 14px;
    transition: opacity 0.3s;
}

.question-media video {
    object-fit: contain;
    background: black;
}

/* ===== Audio Player ===== */
.question-audio-player,
.answer-audio-player {
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #EDE7F6 0%, #E3F2FD 100%);
    border: 1px solid rgba(27, 58, 92, 0.12);
    flex-shrink: 0;
}

.answer-audio-player,
.answer-media-video {
    margin-top: 10px;
    background: linear-gradient(135deg, #E8F5E9 0%, #F1F8E9 100%);
    border-color: rgba(76, 175, 80, 0.2);
}

.audio-player-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #1B3A5C;
    margin-bottom: 10px;
}

.audio-player-header i {
    color: #7C3AED;
    font-size: 14px;
}

.answer-audio-header {
    color: #2E7D32;
}

.answer-audio-header i {
    color: #43A047;
}

.audio-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.audio-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.audio-btn-play {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #1B3A5C, #2563EB);
    color: white;
    font-size: 18px;
    box-shadow: 0 3px 10px rgba(27, 58, 92, 0.3);
}

.audio-btn-play.playing {
    background: linear-gradient(135deg, #7C3AED, #A855F7);
    animation: audioPulse 1.5s ease-in-out infinite;
}

.answer-audio-player .audio-btn-play {
    background: linear-gradient(135deg, #2E7D32, #43A047);
}

.answer-audio-player .audio-btn-play.playing {
    background: linear-gradient(135deg, #1B5E20, #2E7D32);
}

.audio-btn-play:hover {
    transform: scale(1.08);
}

.audio-btn-play:active {
    transform: scale(0.95);
}

.audio-btn-restart,
.audio-btn-stop {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.8);
    color: #555;
    font-size: 13px;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.audio-btn-restart:hover,
.audio-btn-stop:hover {
    background: white;
    color: #1B3A5C;
    transform: scale(1.05);
}

.audio-btn-restart:active,
.audio-btn-stop:active {
    transform: scale(0.92);
}

.audio-progress-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    margin-bottom: 4px;
}

.audio-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #7C3AED, #2563EB);
    border-radius: 3px;
    transition: width 0.1s linear;
}

.answer-audio-player .audio-progress-bar {
    background: linear-gradient(90deg, #43A047, #66BB6A);
}

.audio-time {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #777;
    font-variant-numeric: tabular-nums;
    direction: ltr;
}

@keyframes audioPulse {
    0%, 100% { box-shadow: 0 3px 10px rgba(124, 58, 237, 0.3); }
    50% { box-shadow: 0 3px 18px rgba(124, 58, 237, 0.55); }
}

/* Answer media video header */
.answer-media-video {
    margin-top: 10px;
    padding: 10px;
    border-radius: 12px;
    background: linear-gradient(135deg, #E8F5E9 0%, #F1F8E9 100%);
    border: 1px solid rgba(76, 175, 80, 0.2);
}

.answer-media-video .audio-player-header {
    margin-bottom: 8px;
    color: #2E7D32;
}

.answer-media-video .audio-player-header i {
    color: #43A047;
}

/* Question text */
.question-text {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.6;
    color: #1A1A2E;
    margin-bottom: 12px;
    flex: 0 0 auto;
}

/* Difficulty badge */
.difficulty-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 10px;
    border-radius: 16px;
    font-size: 10px;
    font-weight: 600;
}

.difficulty-badge.d-1 { background: #E8FFF6; color: #B08C3E; }
.difficulty-badge.d-2 { background: #E8F5E9; color: #2E7D32; }
.difficulty-badge.d-3 { background: #FFF8E1; color: #F57F17; }
.difficulty-badge.d-4 { background: #FFF3E0; color: #E65100; }
.difficulty-badge.d-5 { background: #FFEBEE; color: #C62828; }

/* Reveal Answer Button */
.btn-reveal {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #1B3A5C, #2A5580);
    color: white;
    border: none;
    border-radius: 14px;
    font-family: 'Heebo', sans-serif;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-reveal::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn-reveal:hover::before {
    left: 100%;
}

.btn-reveal:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(108, 99, 255, 0.4);
}

.btn-reveal:active {
    transform: scale(0.98) translateY(0);
}

/* Answer Section */
.answer-section {
    margin-top: 8px;
    animation: slideDown 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    flex-shrink: 0;
}

.answer-box {
    background: linear-gradient(135deg, #F8F7FF, #EEF0FF);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 8px;
    border-right: 4px solid #1B3A5C;
    position: relative;
}

.answer-label {
    font-size: 12px;
    font-weight: 600;
    color: #1B3A5C;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.answer-text {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1A1A2E;
    line-height: 1.5;
}

.explanation-box {
    background: #FFFDF0;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 8px;
    border-right: 3px solid #FFC107;
    flex-shrink: 0;
}

.explanation-label {
    font-size: 11px;
    font-weight: 600;
    color: #F57F17;
    margin-bottom: 4px;
}

.explanation-text {
    font-size: 0.88rem;
    color: #555;
    line-height: 1.55;
}

/* Rating Buttons */
.rating-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 6px;
    flex-shrink: 0;
}

.rating-btn {
    padding: 10px 8px;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    background: white;
    font-family: 'Heebo', sans-serif;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    position: relative;
    overflow: hidden;
}

.rating-btn .rating-emoji {
    font-size: 24px;
    transition: transform 0.3s;
}

.rating-btn .rating-points {
    font-size: 10px;
    color: #9CA3AF;
    transition: color 0.3s;
}

.rating-btn:hover:not(.disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.rating-btn.correct { border-color: #2E7D32; background: #F0FFF9; color: #2E7D32; }
.rating-btn.partial { border-color: #C9A84C; background: #FFFDF0; color: #8D6E1E; }
.rating-btn.wrong { border-color: #B5432A; background: #FFF5F7; color: #B5432A; }

.rating-btn.correct:hover:not(.disabled), .rating-btn.correct.selected {
    background: linear-gradient(135deg, #2E7D32, #1B5E20);
    color: white; border-color: #2E7D32;
    box-shadow: 0 4px 15px rgba(46, 125, 50, 0.4);
}

.rating-btn.partial:hover:not(.disabled), .rating-btn.partial.selected {
    background: linear-gradient(135deg, #FFC107, #FFB300);
    color: white; border-color: #FFC107;
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.4);
}

.rating-btn.wrong:hover:not(.disabled), .rating-btn.wrong.selected {
    background: linear-gradient(135deg, #B5432A, #FF3366);
    color: white; border-color: #B5432A;
    box-shadow: 0 4px 15px rgba(255, 101, 132, 0.4);
}

.rating-btn.selected .rating-emoji {
    transform: scale(1.15);
}

.rating-btn.selected .rating-points {
    color: rgba(255,255,255,0.8);
}

.rating-btn.disabled:not(.selected) {
    opacity: 0.35;
    pointer-events: none;
    cursor: default;
    transform: scale(0.95);
}

/* Quiz dots */
.quiz-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #E5E7EB;
    transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    cursor: pointer;
    flex-shrink: 0;
}

.quiz-dot.active {
    width: 16px;
    border-radius: 3px;
    background: #1B3A5C;
    box-shadow: 0 2px 6px rgba(108, 99, 255, 0.4);
}

.quiz-dot.answered {
    background: #C9A84C;
}

.quiz-dot.answered.active {
    background: #B08C3E;
}

/* Quiz bottom nav */
.quiz-bottom-nav {
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 30;
    position: relative;
}

/* ===== Swipe Edge Indicators ===== */
.swipe-edge-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    color: #1B3A5C;
    font-size: 14px;
}

.swipe-edge-right {
    right: 2px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.9));
    border-radius: 8px 0 0 8px;
}

.swipe-edge-left {
    left: 2px;
    background: linear-gradient(to left, transparent, rgba(255,255,255,0.9));
    border-radius: 0 8px 8px 0;
}

.swipe-edge-indicator.visible {
    opacity: 0.7;
}

/* ===== Swipe Hint Overlay ===== */
.swipe-hint-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.swipe-hint-overlay.hidden {
    display: none;
}

.swipe-hint-content {
    background: white;
    border-radius: 16px;
    padding: 20px 32px;
    text-align: center;
    color: #1B3A5C;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    animation: popIn 0.4s ease-out;
}

/* ===== Swipe drag feedback ===== */
.quiz-carousel.swiping {
    cursor: grabbing;
}

.quiz-carousel.swiping .question-card-inner {
    transform: scale(0.98);
    transition: transform 0.2s;
}

/* Results Breakdown */
.result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 12px;
    background: #F9FAFB;
    transition: all 0.2s;
}

.result-item:hover {
    background: #F3F4F6;
    transform: translateX(-2px);
}

.result-item .result-q-num {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.result-item .result-q-num.correct { background: linear-gradient(135deg, #C9A84C, #B08C3E); }
.result-item .result-q-num.partial { background: linear-gradient(135deg, #FFC107, #FFB300); }
.result-item .result-q-num.wrong { background: linear-gradient(135deg, #B5432A, #FF3366); }
.result-item .result-q-num.unanswered { background: #9CA3AF; }

.result-item .result-q-text {
    flex: 1;
    font-size: 12px;
    color: #374151;
    line-height: 1.3;
}

.result-item .result-q-score {
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

/* Quiz summary bottom sheet */
.quiz-summary-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    z-index: 45;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    max-height: 60vh;
    overflow-y: auto;
}

.quiz-summary-sheet.visible {
    transform: translateY(0);
}

/* ===== Mobile Small Screen Optimizations ===== */
@media (max-height: 700px) {
    .question-card {
        padding: 4px 8px;
    }
    .question-card-inner {
        padding: 12px;
        border-radius: 16px;
    }
    .question-text {
        font-size: 1.05rem;
        margin-bottom: 8px;
    }
    .question-media {
        margin-bottom: 6px;
    }
    .question-media img,
    .question-media video {
        max-height: 40vh;
    }
    .question-audio-player,
    .answer-audio-player {
        padding: 10px 12px;
        margin-bottom: 8px;
    }
    .audio-btn-play {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
    .audio-btn-restart,
    .audio-btn-stop {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    .btn-reveal {
        padding: 12px;
        font-size: 15px;
    }
    .answer-box {
        padding: 10px;
    }
    .answer-text {
        font-size: 1rem;
    }
    .explanation-box {
        padding: 8px 10px;
    }
    .explanation-text {
        font-size: 0.8rem;
    }
    .rating-btn {
        padding: 8px 6px;
    }
    .rating-btn .rating-emoji {
        font-size: 22px;
    }
}

@media (max-height: 600px) {
    .question-card-inner {
        padding: 10px;
    }
    .question-text {
        font-size: 0.95rem;
        line-height: 1.45;
    }
    .question-number {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    .rating-buttons {
        gap: 6px;
    }
    .question-media img,
    .question-media video {
        max-height: 35vh;
    }
}

/* ===== Large Screen Optimization ===== */
@media (min-height: 800px) {
    .question-card {
        padding: 12px 16px;
    }
    .question-card-inner {
        padding: 20px;
    }
    .question-text {
        font-size: 1.25rem;
        line-height: 1.65;
        margin-bottom: 16px;
    }
    .btn-reveal {
        padding: 16px;
        font-size: 17px;
    }
    .answer-text {
        font-size: 1.25rem;
    }
    .explanation-text {
        font-size: 0.95rem;
        line-height: 1.6;
    }
    .explanation-label {
        font-size: 12px;
    }
    .answer-label {
        font-size: 13px;
    }
    .rating-btn {
        padding: 12px 10px;
        font-size: 14px;
    }
    .rating-btn .rating-emoji {
        font-size: 28px;
    }
    .rating-btn .rating-points {
        font-size: 11px;
    }
    .question-media img,
    .question-media video {
        max-height: 55vh;
    }
}

/* ===== Extra large tablet/desktop ===== */
@media (min-height: 900px) and (min-width: 500px) {
    .question-card-inner {
        padding: 24px;
    }
    .question-text {
        font-size: 1.35rem;
        line-height: 1.7;
    }
    .answer-text {
        font-size: 1.3rem;
    }
    .explanation-text {
        font-size: 1rem;
    }
    .rating-btn {
        padding: 14px 12px;
        font-size: 15px;
    }
    .rating-btn .rating-emoji {
        font-size: 30px;
    }
}

/* ===== Image Lightbox / Fullscreen Viewer ===== */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    padding: 16px;
    cursor: zoom-out;
}
.image-lightbox.active {
    opacity: 1;
}
.image-lightbox img {
    max-width: 95vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.25s ease;
}
.image-lightbox.active img {
    transform: scale(1);
}
.image-lightbox .lightbox-close {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    backdrop-filter: blur(8px);
}
.image-lightbox .lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}
.image-lightbox .lightbox-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    pointer-events: none;
}

/* Expand icon on media images */
.question-media {
    position: relative;
}
.question-media .media-expand-icon {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    opacity: 0.7;
    transition: opacity 0.2s;
    pointer-events: none;
    backdrop-filter: blur(4px);
}
.question-media:hover .media-expand-icon {
    opacity: 1;
}
