/* Study Button */
#egh-study-now-btn {
    background-color: var(--steps-purple-dark, #8A2BE2);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 0;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease;
}

#egh-study-now-btn:hover {
    background-color: var(--steps-purple-light, #BA55D3);
}

/* Study Modal */
#egh-study-modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    padding: 20px 0;
}

#egh-study-modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.study-modal-content {
    background-color: #fff;
    padding: 0;
    /* Remove padding from container, move to children */
    border-radius: 12px;
    width: 95%;
    max-width: 1100px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    position: relative;
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    margin: auto;
    display: flex;
    flex-direction: column;
    height: 95vh;
    max-height: 900px;
    /* Allow scrolling if content overflows */
    /* Fixed height relative to viewport */
    max-height: 90vh;
    overflow: hidden;
}

#egh-study-modal.is-open .study-modal-content {
    transform: scale(1);
    opacity: 1;
}

/* Header */
.study-modal-header {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid #eee;
    background-color: #fff;
    z-index: 10;
}

.study-header-center {
    font-size: 1.25em;
    font-weight: bold;
    color: var(--steps-purple-dark, #8A2BE2);
    text-align: center;
}

.study-header-left {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--steps-purple-dark, #8A2BE2);
}

.study-header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    justify-self: end;
}

.study-points {
    font-weight: 600;
    color: #555;
    font-size: 1.1em;
}

.study-close {
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
    line-height: 1;
    display: block;
}

.study-close:hover {
    color: #333;
}

/* Scroll Body */
.study-modal-body-scroll {
    flex-grow: 1;
    overflow-y: auto;
    padding: 30px;
}

/* Removed #study-modal-title styles as it's moved to header */

/* Options Container */
#study-options-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 20px 0;
}

.study-option-box {
    width: 100px;
    height: 100px;
    background-color: #f8f9fa;
    border: 2px solid var(--steps-purple-dark, #8A2BE2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: var(--steps-purple-dark, #8A2BE2);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.study-option-box:hover {
    background-color: var(--steps-purple-dark, #8A2BE2);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Word List Container */
#study-list-container {
    /* Scrolling handled by .study-modal-body-scroll now */
}

#study-words-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    padding: 10px;
}

/* 
   Old list styles (kept for reference or fallback, 
   though JS now uses flashcard classes) 
*/
.study-word-item {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--steps-purple-dark, #8A2BE2);
}

.study-word-term {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
    text-transform: capitalize;
}

.study-word-def {
    color: #555;
    font-size: 0.95em;
    line-height: 1.4;
}

/* --- Animated Flashcard Loader --- */
#study-loader {
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

#study-loader.is-visible {
    opacity: 1;
}

.custom-loader-container {
    width: 140px;
    height: 120px;
    position: relative;
    perspective: 600px;
    margin: 40px auto 20px auto;
}

.custom-loader-container svg {
    width: 100%;
    height: 100%;
    overflow: visible;
    transform: rotateX(30deg);
}

.loader-card {
    fill: #ffffff;
    stroke: var(--steps-purple-dark, #8A2BE2);
    stroke-width: 1.5;
    rx: 4;
    filter: drop-shadow(0px 3px 0px rgba(138, 43, 226, 0.2));
}

.loader-card-decor {
    stroke: var(--steps-purple-light, #BA55D3);
    stroke-width: 2;
    stroke-linecap: round;
}

.stack-group {
    animation: stack-slide 1s ease-in-out infinite;
}

.flier-left {
    opacity: 0;
    animation: fly-in-left 2s cubic-bezier(0.1, 0.8, 0.2, 1) infinite;
}

.flier-right {
    opacity: 0;
    animation: fly-in-right 2s cubic-bezier(0.1, 0.8, 0.2, 1) infinite;
    animation-delay: 1s;
}

@keyframes stack-slide {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(0, 8px);
    }
}

@keyframes fly-in-left {
    0% {
        transform: translate(-80px, -60px) rotate(-15deg) scale(1.1);
        opacity: 0;
    }

    35% {
        opacity: 1;
    }

    50% {
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 1;
    }

    50.1% {
        opacity: 0;
    }

    100% {
        opacity: 0;
    }
}

@keyframes fly-in-right {
    0% {
        transform: translate(80px, -60px) rotate(15deg) scale(1.1);
        opacity: 0;
    }

    35% {
        opacity: 1;
    }

    50% {
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 1;
    }

    50.1% {
        opacity: 0;
    }

    100% {
        opacity: 0;
    }
}

.card-fade {
    animation: fade-out 1s linear infinite;
}

@keyframes fade-out {
    0% {
        opacity: 1;
        transform: translate(0, 0);
    }

    100% {
        opacity: 0;
        transform: translate(0, 6px);
    }
}

.loader-text {
    color: var(--steps-purple-dark, #8A2BE2);
    font-weight: 600;
    font-size: 1.2em;
    letter-spacing: 0.5px;
    text-align: center;
    animation: textPulse 2s ease-in-out infinite;
    margin-bottom: 20px;
}

@keyframes textPulse {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .study-option-box {
        width: 80px;
        height: 80px;
        font-size: 20px;
    }
}

/* --- Flashcards --- */

.flashcard-container {
    /* Fixed Desktop Layout */
    width: 200px;
    height: 200px;
    flex: none;
    /* Don't grow or shrink */

    perspective: 1000px;
    opacity: 0;
    transform: translateY(50px);
    animation: flyUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.desktop-break {
    flex-basis: 100%;
    height: 0;
    margin: 0;
    padding: 0;
}

@keyframes flyUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flashcard {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    text-align: center;
    transition: transform 0.8s;
    transform-style: preserve-3d;
    cursor: pointer;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.flashcard.is-flipped {
    transform: rotateY(180deg);
}

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

.flashcard-front {
    background-color: var(--steps-purple-dark, #8A2BE2);
    color: white !important;
    border: 2px solid var(--steps-purple-dark, #8A2BE2);
    padding: 20px 15px 10px 15px;
    /* Optically centered: Top > Bottom */
    transition: padding 0.3s ease;
}

.flashcard-front.media-active {
    padding: 15px 15px 70px 15px;
    /* Reserve space when audio button is visible */
}

.flashcard-front h3 {
    margin: 0;
    font-size: 1.4em;
    text-transform: capitalize;
    color: white !important;
}

.flashcard-back {
    background-color: var(--steps-purple-light, #BA55D3);
    color: #222;
    transform: rotateY(180deg);
    border: 2px solid var(--steps-purple-light, #BA55D3);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flashcard-back p {
    margin: 0;
    font-size: 1.1em;
    line-height: 1.4;
    font-weight: 500;
}

@media (max-width: 600px) {
    .study-modal-content {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
        transform: none !important;
        /* Override scale animation for fuller feel or adjust if needed */
    }

    #study-words-list {
        /* Remove explicit grid cols, rely on flex wrapping */
        gap: 8px;
        padding: 5px;
    }

    /* Fixed Layout Mobile Overrides */
    .flashcard-container {
        /* Force 2 per row on mobile (approx 50% minus gap) */
        flex: 0 0 calc(50% - 10px) !important;
        width: auto !important;
        height: auto !important;
        aspect-ratio: 1/1;
    }

    .desktop-break {
        display: none !important;
    }

    .flashcard-front,
    .flashcard-back {
        padding: 5px;
    }

    .flashcard-front h3 {
        font-size: 0.9em;
    }

    .flashcard-back p {
        font-size: 0.8em;
    }

    /* Ensure modal header is compact on mobile */
    /* Ensure modal header is compact on mobile */
    /* Ensure modal header is compact on mobile */
    .study-modal-header {
        padding: 10px 15px;
        display: flex;
        /* Fallback to flex on mobile if space is tight, or keep grid but adjust cols */
        flex-direction: column;
        gap: 10px;
    }

    .study-header-center {
        order: 2;
    }

    .study-header-right {
        order: 1;
        width: 100%;
        justify-content: space-between;
    }

    .study-header-left {
        display: none;
        /* Hide 'Study Vocabulary' label on mobile to save space */
    }
}

/* --- Next Button & Tooltip --- */
#study-next-btn-container {
    width: 100%;
    margin-top: 30px;
    display: flex;
    justify-content: center;
    padding-bottom: 20px;
}

#study-next-btn {
    background-color: var(--steps-purple-dark, #8A2BE2);
    color: white;
    font-size: 18px;
    padding: 12px 40px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(138, 43, 226, 0.3);
    transition: all 0.3s ease;
    position: relative;
    opacity: 1;
}

#study-next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(138, 43, 226, 0.4);
}

#study-next-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Tooltip for disabled button */
#study-next-btn:disabled:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
}

#study-next-btn:disabled:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* --- Quiz UI --- */
#study-quiz-container {
    display: none;
    /* Hidden by default */
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
}

.quiz-question-card {
    background: #fff;
    border-radius: 12px;
    padding: 30px;
    width: 100%;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
    margin-bottom: 30px;
    border: 1px solid #eee;
}

.quiz-question-text {
    font-size: 1.4em;
    color: #333;
    font-weight: 500;
    line-height: 1.5;
}

.quiz-options-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* Stacked on mobile/desktop by default for better readability? Or 2-col? Let's go 1-col for clarity */
    gap: 15px;
    width: 100%;
}

.quiz-option-btn {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    padding: 15px 20px;
    border-radius: 10px;
    font-size: 1.1em;
    color: #444;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    text-transform: capitalize;
}

.quiz-option-btn:hover {
    border-color: var(--steps-purple-dark, #8A2BE2);
    background: #fefeff;
    color: var(--steps-purple-dark, #8A2BE2);
}

.quiz-option-btn.correct {
    background-color: #d4edda !important;
    border-color: #28a745 !important;
    color: #155724 !important;
}

.quiz-option-btn.incorrect {
    background-color: #f8d7da !important;
    border-color: #dc3545 !important;
    color: #721c24 !important;
}

/* Score Pop Animation */
.score-pop {
    animation: scorePop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: #28a745;
    /* Turn green momentarily */
}

@keyframes scorePop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.5);
    }

    100% {
        transform: scale(1);
    }
}

/* Transition Animation for Questions */
.fade-out {
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.3s ease;
}

.fade-in {
    opacity: 0;
    transform: translateX(20px);
    animation: slideIn 0.3s forwards;
}

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* --- Example Sentence Quiz --- */
.example-sentence-box {
    font-size: 1.4em;
    color: #333;
    line-height: 1.6;
    margin-bottom: 25px;
}

.egh-quiz-gap-custom {
    color: var(--steps-purple-dark, #8A2BE2);
    font-weight: bold;
    padding: 0 2px;
    display: inline-block;
}

.quiz-input-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.quiz-input {
    padding: 12px 15px;
    font-size: 1.1em;
    border: 2px solid #ddd;
    border-radius: 8px;
    width: 250px;
    transition: border-color 0.2s;
}

.quiz-input:focus {
    border-color: var(--steps-purple-dark, #8A2BE2);
    outline: none;
}

.quiz-check-btn {
    background-color: var(--steps-purple-dark, #8A2BE2);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.quiz-check-btn:hover {
    background-color: var(--steps-purple-light, #BA55D3);
}

.quiz-feedback {
    margin-top: 15px;
    font-weight: bold;
    min-height: 24px;
}

.quiz-feedback.success {
    color: #28a745;
}

.quiz-feedback.error {
    color: #dc3545;
}

/* --- Big Audio Button --- */
.egh-big-audio-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: var(--steps-purple-dark, #8A2BE2);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.egh-big-audio-btn:hover {
    transform: scale(1.05);
    background-color: var(--steps-purple-light, #BA55D3);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

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

.egh-big-audio-btn.pulse {
    animation: btnPulse 1.5s infinite;
}

@keyframes btnPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(138, 43, 226, 0.7);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(138, 43, 226, 0);
    }
}

/* Flashcard Translation */
.flashcard-translation {
    margin-top: 10px;
    font-size: 0.9em;
    font-style: italic;
    color: rgba(255, 255, 255, 0.9) !important;
    transition: all 0.3s ease;
    max-height: 100px;
    opacity: 1;
}

.flashcard-translation.hidden {
    opacity: 0;
    pointer-events: none;
    max-height: 0;
    margin-top: 0;
    margin-bottom: 0;
    padding: 0;
    overflow: hidden;
}

/* Flashcard Audio Button */
.flashcard-audio-btn {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.8);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;

    /* Fixed Positioning */
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);

    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 1;
    z-index: 5;
}

.flashcard-audio-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(-50%) scale(1.1);
    /* maintain centering */
}

.flashcard-audio-btn.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) scale(0.8);
    /* slight shrink effect */
}