/* flashcard/mode-listening.css */

.ll-tools-mode-switcher.listening-mode {
    background: #6366f1;
}

.ll-tools-mode-switcher.listening-mode:hover {
    background: #4f46e5;
}

.flashcard-container.listening-placeholder {
    position: relative;
    background: #e5e7eb;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
    cursor: default;
    /* Responsive width: prefer large, but respect viewport */
    width: min(80vw, 420px, calc(100vh - 340px));
    /* Height is determined dynamically in JS via aspect-ratio based on
       image natural dimensions or measured text height. */
    height: auto;
    max-width: 100%;
}

.flashcard-container.listening-placeholder .ll-tools-loading-animation {
    background: transparent;
}

/* Keep image fully visible inside square for mixed aspect ratios */
.flashcard-container.listening-placeholder .quiz-image,
.flashcard-container.listening-final .quiz-image {
    object-fit: contain;
    width: 100%;
    height: 100%;
}

/* Gray overlay that hides the pre-rendered image until reveal */
.flashcard-container.listening-placeholder .listening-overlay {
    position: absolute;
    inset: 0;
    background: #e5e7eb;
    z-index: 2;
}

/* Countdown shown within the visualizer space */
#ll-tools-listening-countdown,
.ll-tools-listening-countdown {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.02em;
    margin-top: 0;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

#ll-tools-listening-countdown .digit,
.ll-tools-listening-countdown .digit {
    display: inline-block;
    opacity: 0.95;
    transform: scale(0.7);
    animation: ll-listening-countdown-pop 0.6s ease-out forwards;
}

@keyframes ll-listening-countdown-pop {
    0% {
        transform: scale(0.7);
        opacity: 0;
    }

    40% {
        transform: scale(1.15);
        opacity: 1;
    }

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

/* Visualizer now placed between the image box and controls */
#ll-tools-listening-visualizer {
    position: static;
    z-index: auto;
    transform: none;
    margin: 10px 0 8px;
    background: transparent !important;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#ll-tools-listening-visualizer.countdown-active .ll-tools-visualizer-bar {
    opacity: 0 !important;
    display: none !important;
}

.listening-visualizer-text {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    color: #111827;
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 0 12px;
}

.listening-text {
    min-height: 44px;
    margin: 6px 0 4px;
    font-size: 32px;
    font-weight: 600;
    text-align: center;
    line-height: 1.25;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Keep placeholder + visualizer stacked as one unit */
.listening-stack {
    display: flex;
    flex-direction: column;
    position: relative;
    align-items: center;
    gap: 8px;
}

.ll-listening-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    margin-top: 14px;
}

.ll-listening-controls .ll-listen-btn {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

.ll-listening-controls .ll-listen-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.ll-listening-controls .ll-listen-btn:active {
    transform: scale(0.97);
    background: #f3f4f6;
    border-color: #d1d5db;
}

.ll-listening-controls .ll-listen-btn:focus {
    outline: none;
    box-shadow: none;
}

.ll-listening-controls .ll-listen-btn:focus-visible {
    background: #eef2ff;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.ll-listening-controls .ll-listen-btn svg {
    display: block;
}

/* --- Hardening: ensure controls and icons render despite theme overrides --- */
.ll-listening-controls .ll-listen-btn {
    width: 42px !important;
    height: 42px !important;
    padding: 0 !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    color: #333 !important;
    /* fallback for currentColor-driven SVGs */
    background: #fff !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: none !important;
    text-decoration: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}

.ll-listening-controls .ll-listen-btn:hover {
    background: #f9fafb !important;
    border-color: #d1d5db !important;
}

.ll-listening-controls .ll-listen-btn:active {
    background: #f3f4f6 !important;
    border-color: #d1d5db !important;
}

.ll-listening-controls .ll-listen-btn:focus {
    outline: none !important;
    box-shadow: none !important;
}

.ll-listening-controls .ll-listen-btn:focus-visible {
    background: #eef2ff !important;
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18) !important;
}

.ll-listening-controls .ll-listen-btn svg {
    display: block !important;
    width: 28px !important;
    height: 28px !important;
    overflow: visible !important;
    /* avoid clipping under theme svg resets */
}

/* Keep loop icon as stroked outline regardless of theme svg fill rules */
#ll-listen-loop svg {
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 2 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
}

.ll-listening-controls #ll-listen-loop.active {
    color: #4f46e5 !important;
    /* ensure visible active color */
    border-color: #6366f1 !important;
    background: rgba(99, 102, 241, 0.10) !important;
}

.ll-listening-controls .ll-listen-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}

/* Fade overlay used when loop restarts */
.ll-listening-loop-overlay {
    position: absolute;
    inset: 0;
    background: #ffffff;
    z-index: 9999;
    pointer-events: none;
}
