/* ==========================================
   QUIZ MODE - COMPLETE STYLES
   Card centered, count selector on right
   ========================================== */

/* ==========================================
   FADE IN ANIMATIONS
   ========================================== */

@keyframes cardFadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes countSelectorSlideIn {
    0% {
        opacity: 0;
        transform: translateY(-50%) translateX(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

/* ==========================================
   CONTAINER
   ========================================== */

.quiz-page .container.quiz-container {
    max-width: 1100px;
    width: 100%;
    min-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2rem;
    padding-top: calc(70px + 2rem);
    overflow: hidden;
}

/* ==========================================
   UNIFIED QUIZ WRAPPER
   ========================================== */

.quiz-unified-wrapper {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    position: relative;
}

/* ==========================================
   SET SELECTION ROW
   ========================================== */

.quiz-set-row {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 1px solid #888888;
    border-radius: 100px;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.quiz-set-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    justify-content: center;
    padding: 0.25rem;
}

.quiz-set-btn {
    padding: 0.625rem 1.25rem;
    background: transparent;
    border: 1px solid #888888;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 0.01em;
    text-transform: lowercase;
}

.quiz-set-btn:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: #666666;
}

.quiz-set-btn.active {
    background: #222221;
    color: #FFF9F7;
    border-color: #222221;
}

/* ==========================================
   QUIZ CONTENT AREA
   Card stays centered, count selector positioned absolutely
   ========================================== */

.quiz-content-area {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ==========================================
   QUESTION CARD - CENTERED
   ========================================== */

.quiz-question-compact {
    width: 100%;
    max-width: 700px;
    background: transparent;
    border-radius: 1.5rem;
    border: 1px solid #888888;
    padding: 2.5rem 2rem;
    text-align: center;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    aspect-ratio: 5 / 4;
    max-height: 450px;
    position: relative;
    /* Only define the transition here - initial state is set inline in HTML */
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

/* Card States */
.quiz-question-compact.correct {
    border-color: var(--success);
    background: linear-gradient(135deg, 
        rgba(76, 175, 80, 0.12) 0%, 
        rgba(76, 175, 80, 0.04) 50%, 
        transparent 100%);
    animation: correctPulse 0.5s ease;
}

.quiz-question-compact.close {
    border-color: var(--warning);
    background: linear-gradient(135deg, 
        rgba(251, 140, 0, 0.12) 0%, 
        rgba(251, 140, 0, 0.04) 50%, 
        transparent 100%);
    animation: closePulse 0.5s ease;
}

.quiz-question-compact.incorrect {
    border-color: var(--error);
    background: linear-gradient(135deg, 
        rgba(229, 57, 53, 0.12) 0%, 
        rgba(229, 57, 53, 0.04) 50%, 
        transparent 100%);
    animation: incorrectShake 0.5s ease;
}

.quiz-question-compact.quiz-complete-state {
    justify-content: center;
}

.quiz-question-compact.quiz-complete-state .quiz-prompt-label,
.quiz-question-compact.quiz-complete-state .quiz-prompt-text,
.quiz-question-compact.quiz-complete-state .quiz-multiple-choice {
    display: none;
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.015); }
}

@keyframes closePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.01); }
}

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* ==========================================
   FLIP ANIMATIONS
   ========================================== */

@keyframes flipOut {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.92);
        opacity: 0;
    }
}

@keyframes flipIn {
    0% {
        transform: scale(0.92);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.quiz-question-compact.flip-out {
    animation: flipOut 0.25s ease-out forwards;
}

.quiz-question-compact.flip-in {
    animation: flipIn 0.25s ease-out forwards;
}

/* ==========================================
   QUESTION COUNT SELECTOR - POSITIONED RIGHT
   ========================================== */

.quiz-count-selector {
    position: absolute;
    right: -80px;
    top: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    /* Only transition - initial state set inline in HTML */
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.count-selector-label {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    font-size: 0.625rem;
    font-weight: 500;
    text-transform: lowercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    white-space: nowrap;
    margin-bottom: 0.25rem;
}

.count-btn-wrapper {
    position: relative;
}

.quiz-count-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid #888888;
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quiz-count-btn:hover:not(:disabled):not(.disabled) {
    background: rgba(0, 0, 0, 0.04);
    border-color: #666666;
    transform: scale(1.05);
}

.quiz-count-btn.active {
    background: #222221;
    color: #FFF9F7;
    border-color: #222221;
}

.quiz-count-btn.active:hover {
    background: #333333;
    border-color: #333333;
}

.quiz-count-btn.disabled,
.quiz-count-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.quiz-count-btn.disabled:hover,
.quiz-count-btn:disabled:hover {
    transform: none;
    background: transparent;
    border-color: #888888;
}

.quiz-count-btn[data-count="infinite"] span {
    font-size: 1.125rem;
    line-height: 1;
}

/* ==========================================
   COUNT TOOLTIPS
   ========================================== */

.count-tooltip {
    position: absolute;
    right: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: #222221;
    color: #FFF9F7;
    padding: 0.5rem 0.875rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    z-index: 100;
    pointer-events: none;
}

.count-tooltip::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #222221;
}

.count-tooltip.show {
    opacity: 1;
    visibility: visible;
}

/* ==========================================
   PROMPT ELEMENTS
   ========================================== */

.quiz-prompt-label {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: lowercase;
    letter-spacing: 0.02em;
    color: var(--text-tertiary);
    margin: 0 0 1rem 0;
}

.quiz-prompt-text {
    font-family: 'Fraunces', serif;
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
    word-break: break-word;
}

/* Correct translation feedback - MOVED UP */
.quiz-correct-translation {
    position: absolute;
    bottom: 2.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quiz-correct-translation.show {
    opacity: 1;
}

/* ==========================================
   MULTIPLE CHOICE OPTIONS
   ========================================== */

.quiz-multiple-choice {
    display: none;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
    width: 100%;
    max-width: 400px;
    margin-top: 1.5rem;
}

.quiz-multiple-choice.visible {
    display: grid;
}

.quiz-choice-btn {
    padding: 0.75rem 1rem;
    background: transparent;
    border: 1px solid #888888;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-word;
}

.quiz-choice-btn:hover:not(:disabled):not(.disabled) {
    background: rgba(0, 0, 0, 0.04);
    border-color: #666666;
    transform: translateY(-2px);
}

.quiz-choice-btn:active:not(:disabled):not(.disabled) {
    transform: translateY(0) scale(0.98);
}

.quiz-choice-btn.correct {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success);
}

.quiz-choice-btn.close {
    background: var(--warning-light);
    border-color: var(--warning);
    color: #E65100;
}

.quiz-choice-btn.incorrect {
    background: var(--error-light);
    border-color: var(--error);
    color: var(--error);
}

.quiz-choice-btn.disabled,
.quiz-choice-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* ==========================================
   NEXT ARROW BUTTON
   ========================================== */

.quiz-next-arrow {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #222221;
    border: none;
    color: #FFF9F7;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
}

.quiz-next-arrow.show {
    transform: translateY(-50%) scale(1);
    opacity: 1;
}

.quiz-next-arrow:hover {
    background: #333333;
    transform: translateY(-50%) scale(1.08);
}

.quiz-next-arrow i {
    font-size: 1rem;
}

/* ==========================================
   QUIZ COMPLETE CONTENT
   ========================================== */

.quiz-complete-content {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    width: 100%;
    padding: 1rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.quiz-complete-content.show {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.complete-text-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.complete-title {
    font-family: 'Fraunces', serif;
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: lowercase;
    margin: 0;
}

.complete-score-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.complete-score {
    font-family: 'Fraunces', serif;
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1;
}

.complete-percentage {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.375rem 0.75rem;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 100px;
    border: 1px solid var(--border-light);
}

.complete-play-again {
    padding: 0.625rem 1.25rem;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid #888888;
    border-radius: 100px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    text-transform: lowercase;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.complete-play-again:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: #666666;
    transform: translateY(-2px);
}

.complete-play-again i {
    font-size: 0.75rem;
}

/* ==========================================
   ANSWER SECTION
   ========================================== */

.quiz-answer-section {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.quiz-input-row {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.quiz-input-wrapper {
    flex: 1;
    min-width: 0;
    position: relative;
    display: flex;
    align-items: center;
    background: #FFFFFF;
    border: 1px solid #888888;
    border-radius: 100px;
    height: 48px;
    transition: all 0.2s ease;
    overflow: hidden;
}

.quiz-input-wrapper:focus-within {
    border-color: #666666;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}

.quiz-input-wrapper .quiz-answer-input {
    flex: 1;
    min-width: 0;
    padding: 0.75rem 1rem;
    padding-right: 0.5rem;
    font-size: 1rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    border: none;
    background: transparent;
    color: var(--text-primary);
    height: 100%;
    outline: none;
}

.quiz-input-wrapper .quiz-answer-input:disabled {
    color: var(--text-tertiary);
}

.quiz-input-wrapper .quiz-answer-input::placeholder {
    color: var(--text-tertiary);
}

/* ==========================================
   INLINE LANGUAGE TOGGLE
   ========================================== */

.quiz-lang-toggle-inline {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 100px;
    padding: 3px;
    cursor: pointer;
    width: 130px;
    height: 38px;
    margin-right: 5px;
    flex-shrink: 0;
    transition: all 0.25s ease;
}

.quiz-lang-toggle-inline:hover {
    background: rgba(0, 0, 0, 0.05);
}

.quiz-lang-toggle-inline .toggle-slider {
    position: absolute;
    width: calc(50% - 3px);
    height: calc(100% - 6px);
    background: #222221;
    border-radius: 100px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    left: 3px;
    top: 3px;
    z-index: 1;
}

.quiz-lang-toggle-inline.english-active .toggle-slider {
    transform: translateX(100%);
}

.quiz-lang-toggle-inline .toggle-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    z-index: 2;
    padding: 4px;
    transition: all 0.25s ease;
}

.quiz-lang-toggle-inline .toggle-option .flag-img {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.quiz-lang-toggle-inline .toggle-option span {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    transition: color 0.25s ease;
    letter-spacing: 0.02em;
    position: relative;
    z-index: 2;
}

.quiz-lang-toggle-inline .toggle-option[data-active="true"] span {
    color: #FFF9F7;
}

/* ==========================================
   QUIZ ACTION BUTTONS
   ========================================== */

.quiz-submit-btn,
.quiz-skip-btn,
.quiz-speak-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid #888888;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    background: transparent;
    color: var(--text-primary);
}

.quiz-submit-btn {
    background: #222221;
    border-color: #222221;
    color: #FFF9F7;
}

.quiz-submit-btn:hover:not(:disabled) {
    background: #333333;
    border-color: #333333;
    transform: scale(1.05);
}

.quiz-submit-btn:disabled {
    background: transparent;
    border-color: #888888;
    color: var(--text-tertiary);
    opacity: 0.4;
    cursor: not-allowed;
}

.quiz-skip-btn:hover:not(:disabled),
.quiz-speak-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.04);
    border-color: #666666;
    transform: scale(1.05);
}

.quiz-skip-btn:disabled,
.quiz-speak-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.quiz-speak-btn.speaking {
    background: var(--info-light);
    border-color: var(--info);
    color: var(--info);
    animation: speakPulse 1s ease-in-out infinite;
}

@keyframes speakPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ==========================================
   SPANISH CHARACTERS - SPACED OUT TO FILL BAR
   ========================================== */

.spanish-chars-container {
    display: none;
    flex-wrap: nowrap;
    justify-content: space-between;
    padding: 0.5rem 1.5rem;
    background: transparent;
    border-radius: 100px;
    border: 1px solid #888888;
    height: 48px;
    align-items: center;
    width: 100%;
}

.spanish-chars-container.visible {
    display: flex;
}

.spanish-char-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid #888888;
    background: transparent;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spanish-char-btn:hover {
    background: #222221;
    color: #FFF9F7;
    border-color: #222221;
    transform: scale(1.05);
}

/* ==========================================
   STATUS BAR
   ========================================== */

.quiz-status-bar {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.quiz-progress-bar {
    width: 100%;
    height: 6px;
    background: #E8E0DD;
    border-radius: 3px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: #4A4A4A;
    transition: width 0.3s ease;
    width: 0%;
}

.quiz-status-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quiz-counter {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.quiz-score-badge {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3125rem 0.75rem;
    background: var(--success-light);
    color: var(--success);
    border-radius: 100px;
    font-size: 0.8125rem;
    font-weight: 600;
}

/* ==========================================
   FLIP ANIMATIONS
   ========================================== */

@keyframes flipOut {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.92);
        opacity: 0;
    }
}

@keyframes flipIn {
    0% {
        transform: scale(0.92);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.quiz-question-compact.flip-out {
    opacity: 1;
    transform: translateY(0);
    animation: flipOut 0.25s ease-out forwards;
}

.quiz-question-compact.flip-in {
    opacity: 0;
    transform: translateY(0);
    animation: flipIn 0.25s ease-out forwards;
}

/* ==========================================
   RESPONSIVE - TABLET & SMALLER DESKTOP
   ========================================== */

@media (max-width: 900px) {
    .quiz-count-selector {
        position: static;
        transform: none !important;
        opacity: 1 !important;
        flex-direction: row;
        margin-bottom: 1rem;
    }
    
    .quiz-content-area {
        flex-direction: column-reverse;
    }
    
    .count-selector-label {
        writing-mode: horizontal-tb;
        transform: none;
        margin-bottom: 0;
        margin-right: 0.75rem;
        font-size: 0.6875rem;
    }
    
    .count-tooltip {
        right: auto;
        left: 50%;
        top: calc(100% + 8px);
        transform: translateX(-50%);
    }
    
    .count-tooltip::after {
        left: 50%;
        top: -6px;
        transform: translateX(-50%) rotate(90deg);
        border-left-color: transparent;
        border-bottom-color: #222221;
    }
}

@media (max-width: 600px) {
    .quiz-page .container.quiz-container {
        padding: 1rem;
        padding-top: calc(70px + 1rem);
    }
    
    .quiz-question-compact {
        min-height: 300px;
        max-height: 350px;
        padding: 2rem 1.5rem;
    }
    
    .quiz-correct-translation {
        bottom: 2rem;
        font-size: 0.875rem;
    }
    
    .spanish-chars-container {
        padding: 0.5rem 1rem;
    }
    
    .spanish-char-btn {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }
}