
/* =========================================================
   HEADER
   ========================================================= */

.flashcard-header {
    position: relative;

    width: 100%;

    padding-top: 70px;

    display: flex;
    align-items: center;
    justify-content: center;
}


.flashcard-back-button {
    width: 44px;
    height: 44px;

    flex-shrink: 0;

    border: none;
    border-radius: 50%;

    font-size: 24px;
    font-weight: 700;

    cursor: pointer;

    background: rgba(255, 255, 255, 0.12);
    color: white;

    backdrop-filter: blur(8px);
}


.flashcard-header-info {
    flex: 1;

    display: flex;
    flex-direction: column;
    align-items: center;

    margin-right: 44px;
}


.flashcard-level {
    color: white;

    font-size: 18px;
    font-weight: 800;

    letter-spacing: 1px;
}


.flashcard-progress {
    margin-top: 4px;

    color: rgba(255, 255, 255, 0.65);

    font-size: 13px;
    font-weight: 600;
}


/* =========================================================
   CONTAINER
   ========================================================= */

.flashcard-container {
    flex: 1;

    width: 100%;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    padding: 20px;

    box-sizing: border-box;
}


/* =========================================================
   CARD
   ========================================================= */

.flashcard {
    position: relative;

    width: min(720px, 88vw);
    height: min(580px, 64vh);

    min-height: 420px;

    border-radius: 28px;

    cursor: pointer;

    user-select: none;

    background: white;

    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.35);

    overflow: hidden;

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease;
}


.flashcard:active {
    transform: scale(0.985);
}


/* =========================================================
   CARD FACE
   ========================================================= */

.flashcard-face {
    position: absolute;
    inset: 0;

    padding: 35px;

    box-sizing: border-box;

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    text-align: center;
}


/* =========================================================
   FRONT
   ========================================================= */

.flashcard-front {
    background:
        linear-gradient(
            145deg,
            #ffffff,
            #f2f4f8
        );
}


.flashcard-question {
    width: 100%;

    font-size: clamp(42px, 5vw, 72px);
    font-weight: 800;

    color: #151a28;

    line-height: 1.2;

    overflow-wrap: break-word;
    word-break: normal;
}


.flashcard-tap-hint {
    position: absolute;

    bottom: 30px;

    font-size: 12px;
    font-weight: 700;

    letter-spacing: 2px;

    color: #999;
}


/* =========================================================
   BACK
   ========================================================= */

.flashcard-back {
    background:
        linear-gradient(
            145deg,
            #ffffff,
            #eef2f8
        );
}


.flashcard-primary {
    width: 100%;
    max-width: 650px;

    font-size: clamp(30px, 3.2vw, 48px);
    font-weight: 800;

    color: #171c29;

    line-height: 1.25;

    overflow-wrap: break-word;
    word-break: normal;
}


.flashcard-secondary {
    width: 100%;

    margin-top: 22px;

    font-size: clamp(20px, 2vw, 28px);
    font-weight: 600;

    color: #555d70;

    line-height: 1.35;

    overflow-wrap: break-word;
    word-break: normal;
}


.flashcard-extra {
    width: 100%;

    margin-top: 14px;

    font-size: clamp(16px, 1.5vw, 20px);

    color: #8990a0;

    line-height: 1.4;

    overflow-wrap: break-word;
    word-break: normal;
}


/* =========================================================
   AUDIO
   ========================================================= */

.flashcard-audio-button {
    position: absolute;

    top: 22px;
    right: 22px;

    width: 48px;
    height: 48px;

    border: none;
    border-radius: 50%;

    font-size: 23px;

    cursor: pointer;

    background: #edf0f6;
}


/* =========================================================
   RATING
   ========================================================= */

.flashcard-rating {
    width: min(720px, 88vw);

    margin-top: 22px;

    display: grid;
    grid-template-columns:
        repeat(4, 1fr);

    gap: 10px;
}


.flashcard-rate-button {
    height: 52px;

    border: none;
    border-radius: 14px;

    cursor: pointer;

    font-size: 12px;
    font-weight: 800;

    letter-spacing: 0.5px;

    background: rgba(255, 255, 255, 0.12);
    color: white;

    backdrop-filter: blur(8px);

    transition:
        transform 0.12s ease,
        background 0.12s ease;
}


.flashcard-rate-button:hover {
    background: rgba(255, 255, 255, 0.2);
}


.flashcard-rate-button:active {
    transform: scale(0.96);
}


/* =========================================================
   HIDDEN
   ========================================================= */

.flashcard-screen.hidden,
.flashcard-face.hidden,
.flashcard-rating.hidden {
    display: none;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 600px) {

    .flashcard-nav-button {
        display: none;
    }

    .flashcard-navigation {
        gap: 0;
    }

    .flashcard-header {
        padding-left: 14px;
        padding-right: 14px;
    }


    .flashcard-container {
        justify-content: flex-start;

        padding-top: 25px;
    }


    .flashcard {
        width: 92vw;

        height: min(500px,58vh);

        min-height: 340px;

        border-radius: 22px;
    }


    .flashcard-face {
        padding: 25px;
    }


    .flashcard-rating {
        width: 92vw;

        gap: 6px;

        margin-top: 16px;
    }


    .flashcard-rate-button {
        height: 48px;

        font-size: 10px;
    }

}

.flashcard-auto-button {
    display: flex;
    align-items: center;
    justify-content: center;

    gap: 7px;

    width: fit-content;
    min-width: 100px;
    height: 38px;

    margin:
        0 auto
        14px;

    padding:
        0 18px;

    border:
        1px solid
        rgba(255, 255, 255, 0.18);

    border-radius: 19px;

    background:
        rgba(255, 255, 255, 0.10);

    color: #ffffff;

    font-size: 13px;
    font-weight: 800;

    letter-spacing: 0.8px;

    cursor: pointer;

    backdrop-filter:
        blur(8px);

    -webkit-backdrop-filter:
        blur(8px);

    transition:
        background 0.2s ease,
        transform 0.15s ease,
        border-color 0.2s ease;
}


.flashcard-auto-button:hover {
    background:
        rgba(255, 255, 255, 0.17);

    transform:
        translateY(-1px);
}


.flashcard-auto-button:active {
    transform:
        scale(0.96);
}


/* =====================================
   AUTO đang chạy
===================================== */

.flashcard-auto-button.running {
    background: rgba(255, 255, 255, 0.20);

    border-color:
        rgba(255, 255, 255, 0.30);
}


.flashcard-auto-icon {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 16px;

    font-size: 11px;
}

.flashcard-brand {
    position: absolute;

    top: 18px;
    left: 50%;

    transform:
        translateX(-50%);

    display: flex;
    align-items: center;

    font-size: 25px;
    font-weight: 900;

    letter-spacing: -0.8px;

    z-index: 10;

    user-select: none;
}


.flashcard-brand-bat {
    color: #ffffff;
}


.flashcard-brand-lingo {
    color: #ff8a00;
}

.flashcard-screen {
    position: fixed;
    inset: 0;

    width: 100%;
    min-height: 100vh;

    background:
        linear-gradient(
            rgba(4, 8, 20, 0.72),
            rgba(4, 8, 20, 0.82)
        ),
        url("../assets/images/backgrounds/flashcard-bg.webp");

    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;

    overflow-y: auto;
}

#flashcard {
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    will-change: transform;
}

.flashcard-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    width: 100%;
}

.flashcard-nav-button {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    font-size: 36px;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
}

.flashcard-nav-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.08);
}

.flashcard-nav-button:active {
    transform: scale(0.95);
}


/* =========================================================
   BATLINGO FLASHCARD - FILTERS + QUIZ
   ADD AT THE END OF flashcard.css
========================================================= */

/* =========================================================
   FILTER BAR
========================================================= */

#flashcardScreen .flashcard-filters {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;

    width: min(720px, calc(100% - 32px));

    margin: 16px auto 4px;
    box-sizing: border-box;
}

/* =========================================================
   FILTER BUTTON
========================================================= */

#flashcardScreen .flashcard-filter-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    gap: 4px;

    min-width: 0;
    min-height: 64px;
    padding: 9px 4px;

    border: 1px solid rgba(255,255,255,.15);
    border-radius: 13px;

    background: rgba(15,23,42,.86);
    color: #f8fafc;

    cursor: pointer;

    transition:
        background .15s ease,
        border-color .15s ease,
        transform .15s ease;
}

#flashcardScreen .flashcard-filter-btn strong {
    font-size: 20px;
    font-weight: 900;
    line-height: 1.1;
}

#flashcardScreen .flashcard-filter-btn span {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .5px;
}

#flashcardScreen .flashcard-filter-btn:hover {
    background: rgba(51,65,85,.95);
}

#flashcardScreen .flashcard-filter-btn:active {
    transform: scale(.97);
}

/* =========================================================
   FILTER COLORS
========================================================= */

#flashcardScreen [data-fc-filter="all"] strong {
    color: #e2e8f0;
}

#flashcardScreen [data-fc-filter="again"] strong {
    color: #f87171;
}

#flashcardScreen [data-fc-filter="hard"] strong {
    color: #fdba74;
}

#flashcardScreen [data-fc-filter="good"] strong {
    color: #86efac;
}

#flashcardScreen [data-fc-filter="easy"] strong {
    color: #93c5fd;
}

#flashcardScreen .flashcard-filter-btn.active {
    background: rgba(51,65,85,.95);
    border-color: #38bdf8;
    box-shadow: 0 0 0 1px rgba(56,189,248,.25);
}

/* =========================================================
   EMPTY FILTER
========================================================= */

#flashcardScreen .flashcard-empty-message {
    padding: 18px 12px;
    text-align: center;
    color: #cbd5e1;
    font-weight: 700;
}

#flashcardScreen .flashcard-empty-message.hidden {
    display: none !important;
}

#flashcardScreen #flashcard.hidden {
    display: none !important;
}

/* =========================================================
   QUIZ AREA
========================================================= */

#flashcardScreen .flashcard-quiz-area {
    width: min(720px, calc(100% - 32px));
    margin: 12px auto 30px;
    flex-shrink: 0;
}

#flashcardScreen .flashcard-create-quiz-btn {
    display: block;
    width: 100%;
    min-height: 45px;

    border: 1px solid rgba(56,189,248,.45);
    border-radius: 13px;

    background: rgba(14,116,144,.28);
    color: #e0f2fe;

    font-size: 13px;
    font-weight: 900;
    letter-spacing: 1px;

    cursor: pointer;
    transition: background .15s ease;
}

#flashcardScreen .flashcard-create-quiz-btn:hover {
    background: rgba(14,116,144,.48);
}

#flashcardScreen .flashcard-create-quiz-btn:disabled {
    opacity: .35;
    cursor: not-allowed;
}

/* =========================================================
   QUIZ SETTINGS
========================================================= */

#flashcardScreen .flashcard-quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;

    margin-top: 12px;
    padding: 18px;

    background: rgba(15,23,42,.97);
    border: 1px solid #334155;
    border-radius: 16px;

    color: #f8fafc;
}

#flashcardScreen .flashcard-quiz-options.hidden {
    display: none !important;
}

#flashcardScreen .flashcard-quiz-heading {
    font-size: 15px;
    font-weight: 900;
    color: #7dd3fc;
}

#flashcardScreen .flashcard-quiz-available {
    font-size: 12px;
    color: #cbd5e1;
}

#flashcardScreen .flashcard-quiz-options label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .7px;
    color: #94a3b8;
}

#flashcardScreen .flashcard-quiz-options select {
    width: 100%;
    height: 42px;

    padding: 0 12px;

    border: 1px solid #475569;
    border-radius: 10px;

    background: #1e293b;
    color: #f8fafc;

    font-size: 13px;
}

#flashcardScreen .flashcard-quiz-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
}

#flashcardScreen .flashcard-quiz-actions button {
    min-height: 43px;

    border: none;
    border-radius: 10px;

    font-size: 12px;
    font-weight: 900;

    cursor: pointer;
}

#flashcardQuizCancelBtn {
    background: #334155;
    color: #e2e8f0;
}

#flashcardQuizStartBtn {
    background: #0284c7;
    color: white;
}

/* =========================================================
   FILTER QUIZ - HIDE BATTLE STATS
========================================================= */

#gameScreen.flashcard-quiz-mode .game-header,
#gameScreen.flashcard-quiz-mode #combo {
    display: none !important;
}

/* =========================================================
   COMPACT FLASHCARD LAYOUT
========================================================= */

#flashcardScreen {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

#flashcardScreen.hidden {
    display: none !important;
}

#flashcardScreen .flashcard-container {
    flex: 0 0 auto;
    justify-content: flex-start;
    padding-top: 12px;
    padding-bottom: 8px;
}

/* Card size after adding filter bar */

#flashcardScreen .flashcard {
    height: clamp(300px, 48dvh, 490px);
    min-height: 300px;
}

#flashcardScreen .flashcard-rating {
    margin-top: 14px;
}

/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 600px) {

    #flashcardScreen .flashcard-header {
        padding-top: 58px;
    }

    #flashcardScreen .flashcard-filters {
        width: calc(100% - 20px);
        gap: 4px;
        margin-top: 12px;
    }

    #flashcardScreen .flashcard-filter-btn {
        min-height: 57px;
        padding: 7px 2px;
        border-radius: 10px;
    }

    #flashcardScreen .flashcard-filter-btn strong {
        font-size: 17px;
    }

    #flashcardScreen .flashcard-filter-btn span {
        font-size: 9px;
        letter-spacing: 0;
    }

    #flashcardScreen .flashcard-container {
        padding: 12px 10px 6px;
    }

    #flashcardScreen .flashcard {
        height: clamp(260px, 43dvh, 410px);
        min-height: 260px;
    }

    #flashcardScreen .flashcard-rating {
        width: 100%;
        gap: 5px;
        margin-top: 12px;
    }

    #flashcardScreen .flashcard-quiz-area {
        width: calc(100% - 20px);
        margin-top: 8px;
    }

    #flashcardScreen .flashcard-create-quiz-btn {
        min-height: 44px;
    }
}

/* =========================================================
   SMALL HEIGHT SCREENS
========================================================= */

@media (max-height: 700px) {

    #flashcardScreen .flashcard {
        height: 280px;
        min-height: 260px;
    }

    #flashcardScreen .flashcard-container {
        padding-top: 8px;
    }
}


/* =========================================================
   FLASHCARD - STABLE LAYOUT FIX
   Rating / Create Quiz no jumping
========================================================= */

/* Screen */
#flashcardScreen {
    display: flex;
    flex-direction: column;
    align-items: center;

    height: 100dvh;
    min-height: 0;

    overflow-x: hidden;
    overflow-y: auto;

    box-sizing: border-box;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* Header */
#flashcardScreen .flashcard-header {
    flex-shrink: 0;
    padding-top: 64px;
}

/* 5 filters */
#flashcardScreen .flashcard-filters {
    flex-shrink: 0;
    width: min(720px, calc(100% - 32px));
    margin: 12px auto 0;
}

/* Main container */
#flashcardScreen .flashcard-container {
    flex: 0 0 auto;

    width: 100%;
    min-height: 0;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;

    padding: 12px 12px 0;
    margin: 0;

    box-sizing: border-box;
}

/* AUTO stays above card */
#flashcardScreen .flashcard-auto-button {
    flex-shrink: 0;
    margin: 0 auto 10px;
}

/* Card navigation */
#flashcardScreen .flashcard-navigation {
    flex-shrink: 0;
    width: 100%;
    min-height: 0;
}

/* Card height does not depend on rating visibility */
#flashcardScreen #flashcard {
    flex-shrink: 0;

    width: min(720px, 88vw);
    height: clamp(300px, 46dvh, 490px);
    min-height: 300px;
}

/* =========================================================
   IMPORTANT: RESERVE RATING SPACE

   The .hidden class must NOT remove the
   rating element from layout.
========================================================= */

#flashcardScreen #flashcardRating {
    display: grid !important;

    grid-template-columns: repeat(4, minmax(0, 1fr));

    flex-shrink: 0;

    width: min(720px, 88vw);
    height: 52px;
    min-height: 52px;

    gap: 10px;
    margin: 14px auto 0;

    padding: 0;
    box-sizing: border-box;
}

/* Hidden rating keeps its original dimensions */
#flashcardScreen #flashcardRating.hidden {
    display: grid !important;

    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

/* Revealed rating */
#flashcardScreen #flashcardRating:not(.hidden) {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

/* Buttons cannot change container height */
#flashcardScreen #flashcardRating
.flashcard-rate-button {
    height: 52px;
    min-height: 52px;
    width: 100%;
    margin: 0;
}

/* =========================================================
   CREATE QUIZ - FIXED POSITION IN FLOW
========================================================= */

#flashcardScreen .flashcard-quiz-area {
    flex-shrink: 0;

    width: min(720px, 88vw);

    margin: 12px auto 20px;
    padding: 0;

    box-sizing: border-box;
}

#flashcardScreen .flashcard-create-quiz-btn {
    width: 100%;
    height: 46px;
    min-height: 46px;

    margin: 0;
}

/* Quiz options open below the button */
#flashcardScreen .flashcard-quiz-options {
    margin-top: 12px;
}

/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 600px) {

    #flashcardScreen .flashcard-header {
        padding-top: 58px;
    }

    #flashcardScreen .flashcard-filters {
        width: calc(100% - 20px);
        margin-top: 10px;
    }

    #flashcardScreen .flashcard-container {
        padding: 10px 10px 0;
    }

    #flashcardScreen .flashcard-auto-button {
        margin-bottom: 8px;
    }

    #flashcardScreen #flashcard {
        width: 92vw;

        height: clamp(250px, 40dvh, 390px);
        min-height: 250px;
    }

    #flashcardScreen #flashcardRating {
        width: 92vw;

        height: 48px;
        min-height: 48px;

        gap: 6px;
        margin-top: 10px;
    }

    #flashcardScreen #flashcardRating
    .flashcard-rate-button {
        height: 48px;
        min-height: 48px;

        font-size: 10px;
    }

    #flashcardScreen .flashcard-quiz-area {
        width: 92vw;
        margin-top: 10px;
        margin-bottom: 14px;
    }

    #flashcardScreen .flashcard-create-quiz-btn {
        height: 44px;
        min-height: 44px;
    }
}

/* =========================================================
   SHORT SCREENS
========================================================= */

@media (max-height: 700px) {

    #flashcardScreen #flashcard {
        height: 260px;
        min-height: 260px;
    }

    #flashcardScreen .flashcard-auto-button {
        margin-bottom: 6px;
    }
}


/* =========================================================
   BATLINGO - FLASHCARD LISTEN AUTO
========================================================= */

#flashcardScreen .flashcard-playback-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    width: min(720px, 88vw);
    min-height: 40px;

    margin: 0 auto 8px;
    flex-shrink: 0;
}

/* Existing AUTO */
#flashcardScreen .flashcard-playback-controls
.flashcard-auto-button {
    flex: 1;
    width: auto;
    min-width: 0;
    max-width: none;

    height: 40px;
    margin: 0;
}

/* LISTEN + LANGUAGE */
#flashcardScreen .flashcard-listen-auto-controls {
    display: flex;
    align-items: center;
    gap: 7px;

    flex: 1.4;
    min-width: 0;
}

/* LISTEN BUTTON */
#flashcardScreen .flashcard-listen-auto-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;

    flex: 1;
    min-width: 0;
    height: 40px;

    padding: 0 8px;

    border: 1px solid rgba(56,189,248,.5);
    border-radius: 20px;

    background: rgba(14,116,144,.3);
    color: #e0f2fe;

    font-size: 12px;
    font-weight: 800;

    white-space: nowrap;
    cursor: pointer;
}

#flashcardScreen .flashcard-listen-auto-button:hover {
    background: rgba(14,116,144,.5);
}

#flashcardScreen .flashcard-listen-auto-button.running {
    border-color: #f87171;
    background: rgba(185,28,28,.4);
    color: #fee2e2;
}

/* VI / EN SELECT */
#flashcardScreen .flashcard-listen-language {
    flex: 0 0 58px;
    width: 58px;
    height: 40px;

    padding: 0 5px;

    border: 1px solid #475569;
    border-radius: 12px;

    background: #1e293b;
    color: #f8fafc;

    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

/* Stable status height */
#flashcardScreen .flashcard-listen-auto-status {
    display: flex;
    align-items: center;
    justify-content: center;

    width: min(720px, 88vw);
    min-height: 20px;
    height: 20px;

    margin: 0 auto 4px;
    flex-shrink: 0;

    color: #93c5fd;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .5px;

    text-align: center;
}

/* MOBILE */
@media (max-width: 600px) {

    #flashcardScreen .flashcard-playback-controls {
        width: 92vw;
        gap: 6px;
    }

    #flashcardScreen .flashcard-playback-controls
    .flashcard-auto-button {
        height: 38px;
        font-size: 11px;
        padding: 0 6px;
    }

    #flashcardScreen .flashcard-listen-auto-button {
        height: 38px;
        font-size: 10px;
        padding: 0 4px;
    }

    #flashcardScreen .flashcard-listen-language {
        flex-basis: 52px;
        width: 52px;
        height: 38px;
        font-size: 11px;
    }

    #flashcardScreen .flashcard-listen-auto-status {
        width: 92vw;
        height: 18px;
        min-height: 18px;
        font-size: 9px;
    }
}

