/* flashcard-style.css */

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Category Selection Styles */
#ll-tools-category-selection {
    display: flex;
    flex-direction: column;
    height: auto;
}

.ll-tools-category-selection-buttons {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.ll-tools-category-selection-buttons button {
    margin: 0 5px;
}

#ll-tools-category-checkboxes-container {
    flex-grow: 1;
    text-align: center;
    margin-bottom: 20px;
    max-height: calc(80vh - 150px);
    -webkit-overflow-scrolling: touch;
}

#ll-tools-category-checkboxes {
    display: inline-block;
    text-align: left;
    max-height: 100%;
    min-width: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#ll-tools-start-selected-quiz {
    align-self: center;
}

/* Body State When Flashcard is Open */
body.ll-tools-flashcard-open {
    overflow: hidden;
}

/* Repeat button (play/stop icons) */
#ll-tools-repeat-flashcard {
    background: none;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Fixed container for icons so layout doesn't shift */
#ll-tools-repeat-flashcard .icon-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    position: relative;
}

#ll-tools-repeat-flashcard.play-mode .icon-container img,
#ll-tools-repeat-flashcard.play-mode .icon-container svg {
    width: 100%;
    height: 100%;
    display: block;
}

#ll-tools-repeat-flashcard.stop-mode .icon-container img,
#ll-tools-repeat-flashcard.stop-mode .icon-container svg {
    width: 100%;
    height: 100%;
    margin: auto;
    display: block;
}

#ll-tools-repeat-flashcard.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

#ll-tools-repeat-flashcard.disabled .icon-container {
    opacity: 0.5;
}

#ll-tools-start-flashcard {
    display: block;
    margin-bottom: 40px;
}

/* Flashcard Container */
#ll-tools-flashcard-container {
    position: relative;
}

/* Category Selection Popup */
#ll-tools-category-selection-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: white;
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

#ll-tools-category-selection-popup h3 {
    text-align: center;
    margin-bottom: 10px;
    margin-top: 50px;
}

/* Flashcard Quiz Popup */
#ll-tools-flashcard-quiz-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: white;
    overflow: hidden;
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

/* Close Button Styles */
#ll-tools-close-category-selection,
#ll-tools-close-flashcard {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    padding: 10px;
    line-height: 10px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: black;
}

/* Quiz Results Styles */
#quiz-results {
    display: none;
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    width: 80%;
    max-width: 600px;
    z-index: 10;
}

#quiz-results-message {
    font-size: 14px;
    color: #555;
    margin-top: 10px;
}

/* Loading Animation Styles */
.ll-tools-loading-animation {
    display: none;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #333333;
    border-radius: 50%;
    animation: ll-tools-spin 2s linear infinite;
    order: 3;
    margin-top: 10px;
}

@keyframes ll-tools-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Flashcard Header and Content */
#ll-tools-flashcard-header {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 20px 20px 10px;
}

#ll-tools-flashcard-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    overflow: hidden;
    width: 100%;
}

#ll-tools-flashcard {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    align-items: center;
    max-width: 800px;
    width: 100%;
}

/* Flashcard Container Styles */
.flashcard-container {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    padding: 0;
    background: #fff;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
}

.flashcard-container img {
    object-fit: contain;
}

/* Modifier Classes for Flashcard Orientation */
.flashcard-container.landscape {
    height: auto;
}

.flashcard-container.portrait {
    height: auto;
}

.flashcard-container.text-based {
    width: 250px;
    max-width: 250px;
    height: 150px;
}

/* Correct Answer Overlay */
.correct-answer {
    position: relative;
    z-index: 9999;
}

.correct-answer::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: brightness(1.1);
    z-index: 1;
}

.correct-answer::after {
    content: "\2714";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 64px;
    color: #85cd6a !important;
    font-weight: bold;
    font-family: Arial, Helvetica, sans-serif !important;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
    z-index: 2;
    line-height: 1;
    -webkit-text-size-adjust: none;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Fade-Out Animation */
.fade-out {
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}

/* Quiz Image Styles */
.quiz-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.quiz-text {
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    padding-top: 20px;
    padding-bottom: 20px;
    padding-left: 20px;
    padding-right: 20px;
    border-radius: 5px;
}

.quiz-image:hover {
    transform: scale(1.05);
}

/* Hide the audio player */
#ll-tools-flashcard audio {
    display: none;
}

/* New Classes for Flashcard Sizes */
.flashcard-size-small {
    width: 150px;
    height: 150px;
    max-width: 150px;
    max-height: 150px;
}

.flashcard-size-medium {
    width: 200px;
    height: 200px;
    max-width: 200px;
    max-height: 200px;
}

.flashcard-size-large {
    width: 250px;
    height: 250px;
    max-width: 250px;
    max-height: 250px;
}

/* --- Flashcard header: stack category label above play/pause --- */
.ll-tools-category-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    order: 2;
}

/* Ensure the category name is centered and visually distinct */
#ll-tools-category-display.ll-tools-category-display {
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    max-width: 100%;
    word-wrap: anywhere;
}

/* Learning Progress Bar */
#ll-tools-learning-progress {
    width: 100%;
    max-width: 600px;
    text-align: center;
    padding: 8px 60px 8px 15px;
    font-size: 14px;
    color: #666;
    order: 1;
    margin-bottom: 8px;
    margin-top: -5px;
}

#ll-tools-learning-progress .progress-text {
    font-weight: 500;
}

.learning-progress-bar {
    position: relative;
    width: 100%;
    height: 12px;
    background: #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.learning-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 6px;
}

.introduced-fill {
    background: #9ad19d;
    z-index: 1;
}

.completed-fill {
    background: #2e7d32;
    z-index: 2;
}

/* Learning mode: dim cards during introduction */
.flashcard-container.introducing {
    opacity: 0.9;
    cursor: pointer;
}

.flashcard-container.introducing:hover {
    opacity: 1;
    transform: scale(1.02);
}

/* Learning mode: card being actively introduced */
.flashcard-container.introducing-active {
    animation: pulse-card 1s ease-in-out;
    transform-origin: center;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
}

@keyframes pulse-card {

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

    50% {
        transform: scale(1.08);
    }
}

/* Mode Switcher Button */
.ll-tools-mode-switcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #2196F3;
    border: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.ll-tools-mode-switcher:hover {
    background: #1976D2;
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.ll-tools-mode-switcher:active {
    transform: scale(0.95);
}

.ll-tools-mode-switcher .mode-icon {
    font-size: 28px;
    line-height: 1;
    display: block;
}

/* Different colors for different modes */
.ll-tools-mode-switcher.standard-mode {
    background: #a2a2a2;
}

.ll-tools-mode-switcher.standard-mode:hover {
    background: #8b8b8b;
}

.ll-tools-mode-switcher.learning-mode {
    background: #a2a2a2;
}

.ll-tools-mode-switcher.learning-mode:hover {
    background: #8b8b8b;
}

/* Quiz Mode Buttons on Results Page */
#quiz-mode-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.quiz-mode-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.3s ease;
    min-width: 160px;
    justify-content: center;
}

.quiz-mode-button .button-icon {
    font-size: 20px;
    line-height: 1;
}

#restart-standard-mode {
    background: #a2a2a2;
    color: white;
    border: 2px solid #a2a2a2;
}

#restart-standard-mode:hover {
    background: #8b8b8b;
    border-color: #8b8b8b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#restart-learning-mode {
    background: #a2a2a2;
    color: white;
    border: 2px solid #a2a2a2;
}

#restart-learning-mode:hover {
    background: #8b8b8b;
    border-color: #8b8b8b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Hide mode switcher during results */
#quiz-results:not([style*="display: none"])~.ll-tools-mode-switcher {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .ll-tools-mode-switcher {
        width: 48px;
        height: 48px;
        bottom: 15px;
        right: 15px;
    }

    .ll-tools-mode-switcher .mode-icon {
        font-size: 24px;
    }

    .quiz-mode-button {
        min-width: 140px;
        padding: 10px 20px;
        font-size: 14px;
    }

    .quiz-mode-button .button-icon {
        font-size: 18px;
    }

    /* Constrain progress bar width on mobile to avoid close button */
    #ll-tools-learning-progress {
        max-width: calc(100% - 50px);
        width: calc(100% - 50px);
        padding: 8px 10px 8px 10px;
        margin-right: 50px;
    }

    .learning-progress-bar {
        height: 10px;
    }
}

/* === Theme-proof overrides for the floating mode switcher === */
#ll-tools-mode-switcher.ll-tools-mode-switcher {
    /* Reset hostile theme rules and set explicit layout */
    all: initial;
    box-sizing: border-box;

    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px !important;
    height: 56px !important;
    aspect-ratio: 1 / 1;
    border-radius: 9999px !important;

    background: #2196F3;
    color: #ffffff;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 0 !important;
    line-height: 1 !important;
    text-decoration: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, .3);
    transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}

#ll-tools-mode-switcher.ll-tools-mode-switcher:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, .35);
}

#ll-tools-mode-switcher.ll-tools-mode-switcher:focus-visible {
    outline: 3px solid #38bdf8;
    outline-offset: 2px;
}

/* Icon sizing — beat theme typography rules */
#ll-tools-mode-switcher.ll-tools-mode-switcher .mode-icon {
    font-size: 28px !important;
    line-height: 1 !important;
    display: block !important;
}

/* Mode colors (keeps your existing learning/standard classes) */
#ll-tools-mode-switcher.ll-tools-mode-switcher.standard-mode {
    background: #a2a2a2 !important;
}

#ll-tools-mode-switcher.ll-tools-mode-switcher.learning-mode {
    background: #22c55e !important;
}

/* Mobile tweak to match your earlier responsive sizing */
@media (max-width: 480px) {
    #ll-tools-mode-switcher.ll-tools-mode-switcher {
        width: 48px !important;
        height: 48px !important;
        bottom: 15px;
        right: 15px;
    }

    #ll-tools-mode-switcher.ll-tools-mode-switcher .mode-icon {
        font-size: 24px !important;
    }
}

/* Autoplay blocked overlay */
.ll-tools-autoplay-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.ll-tools-autoplay-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 20px;
    transition: transform 0.2s ease;
    animation: pulse 2s ease-in-out infinite;
}

.ll-tools-autoplay-button:hover {
    transform: scale(1.05);
}

.ll-tools-autoplay-button:active {
    transform: scale(0.95);
}

.ll-tools-autoplay-button span {
    color: white;
    font-size: 24px;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

/* Ensure the overlay appears above everything in the flashcard widget */
#ll-tools-flashcard-content {
    position: relative;
}

/* Autoplay blocked overlay */
.ll-tools-autoplay-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.5) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 999999 !important;
    backdrop-filter: blur(3px) !important;
}

.ll-tools-autoplay-button {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    padding: 20px !important;
    transition: transform 0.2s ease !important;
}

/* Ensure the flashcard content container is positioned for the overlay */
#ll-tools-flashcard-content {
    position: relative !important;
}

/* Learning Mode Completion Checkmark */
.ll-learning-checkmark {
    display: block;
    margin: 0 auto 20px auto;
}

.ll-checkmark-circle {
    stroke: #4CAF50;
    stroke-width: 2;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: ll-stroke-circle 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.ll-checkmark-check {
    stroke: #4CAF50;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: ll-stroke-check 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}

@keyframes ll-stroke-circle {
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes ll-stroke-check {
    100% {
        stroke-dashoffset: 0;
    }
}

#quiz-results-message {
    font-size: 14px;
    color: #555;
    margin-top: 0;
    text-align: center;
}