/* =================================================================
   FLASHCARDS MODULE STYLES
   Version 3.1 - November 2025
   ================================================================= */

.module-flashcards .controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

/* Flashcard Language Selection */
.flashcard-options {
    margin: 16px 0;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.flashcard-options label:first-child {
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
    color: var(--text-primary);
}

.language-checkboxes {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin: 8px 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 6px 12px;
    background: var(--bg-primary);
    border-radius: 4px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.checkbox-label:hover {
    background: var(--bg-hover);
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.checkbox-label input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.language-hint {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 8px;
}

/* Cards Grid - Fluid responsive using auto-fit */
.cards-grid {
    display: grid;
    /* Use smaller max (240px) to fit more cards per row on large displays */
    /* At 1920px: ~7 cards per row. At 1440px: ~6 cards. At 1024px: ~5 cards */
    grid-template-columns: repeat(auto-fit, minmax(clamp(160px, 15vw, 240px), 1fr));
    gap: clamp(12px, 1.5vw, 20px);
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

/* Removed fixed 1200px breakpoint - fluid sizing handles this automatically */

.card-container {
    cursor: pointer;
    position: relative;
    /* Height scaled proportionally with card width (2:3 aspect ratio) */
    height: clamp(180px, 22vw, 320px);
    transition: width 0.3s ease, max-width 0.3s ease;
}

/* Expanded state for long words */
.card-container.card-expanded {
    width: 350px !important;
    max-width: 350px !important;
    z-index: 10;
}

.card-container.card-expanded .primary-word-box,
.card-container.card-expanded .secondary-language {
    width: 95%;
    max-width: 95%;
}

.card-container .card {
    position: relative;
    width: 100%;
    height: 100%;
}

.card-face {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: opacity 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
}

.card-front {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    opacity: 1;
}

.card-front img,
.card-front video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.card-back {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.word-cebuano {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.word-english {
    font-size: 18px;
    opacity: 0.9;
}

/* Enhanced Card Back Styling */
.card-back-content {
    padding: 16px;
    width: 100%;
    height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

.primary-word-box {
    border: 3px solid var(--primary-color);
    border-radius: 12px;
    padding: 14px;
    background: var(--bg-secondary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    width: 92%;
    max-width: 92%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.primary-lang-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    text-align: center;
}

.primary-word {
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.1;
    margin-bottom: 6px;
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.primary-note {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.secondary-language {
    padding: 10px 14px;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    width: 92%;
    max-width: 92%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.secondary-lang-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.secondary-word {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    text-align: center;
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.secondary-note {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: center;
}

.speaker-icon {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.2s;
    z-index: 10;
}

.speaker-icon:hover {
    transform: scale(1.1);
    background: var(--primary-dark);
}

/* Notes Icon and Popover */
.notes-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: var(--warning, #f59e0b);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.2s;
    z-index: 15;
}

.notes-icon:hover {
    transform: scale(1.1);
    background: var(--warning-dark, #d97706);
}

.notes-popover {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 200px;
    max-width: 280px;
    background: var(--bg-primary, white);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 100;
    text-align: left;
}

.notes-popover.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.notes-popover .note-item {
    font-size: 13px;
    color: var(--text-primary, #111827);
    line-height: 1.4;
    margin-bottom: 8px;
}

.notes-popover .note-item:last-child {
    margin-bottom: 0;
}

.notes-popover .note-item strong {
    color: var(--primary, #2563eb);
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

/* Popover arrow */
.notes-popover::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 12px;
    width: 12px;
    height: 12px;
    background: var(--bg-primary, white);
    border-left: 1px solid var(--border-color, #e5e7eb);
    border-top: 1px solid var(--border-color, #e5e7eb);
    transform: rotate(45deg);
}

.no-cards {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

/* =================================================================
   MOBILE RESPONSIVE - Fluid sizing handles most cases
   ================================================================= */

/* Phone: Override to single column for better UX */
body.mobile-phone .cards-grid {
    grid-template-columns: 1fr;
    gap: clamp(8px, 2vw, 16px);
    max-width: 400px;
    margin: 0 auto;
}

body.mobile-phone .card-container {
    height: clamp(180px, 50vw, 250px);
}

body.mobile-phone .card-container.card-expanded {
    width: 280px !important;
    max-width: 280px !important;
}

body.mobile-phone .word-cebuano {
    font-size: 20px;
}

body.mobile-phone .word-english {
    font-size: 16px;
}

body.mobile-phone .card-back-content {
    padding: 12px;
    gap: 12px;
}

body.mobile-phone .primary-word-box {
    padding: 14px;
}

body.mobile-phone .primary-note,
body.mobile-phone .secondary-note {
    font-size: 13px;
}

body.mobile-phone .speaker-icon {
    width: 48px;
    height: 48px;
    font-size: 22px;
}

body.mobile-phone .notes-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
}

body.mobile-phone .notes-popover {
    min-width: 180px;
    max-width: 240px;
    right: -8px;
}

/* Tablet: Let fluid sizing handle column count */
body.mobile-tablet .cards-grid {
    /* Fluid auto-fit handles tablet layout automatically */
    gap: clamp(12px, 2vw, 20px);
}

/* Tablet Landscape: Fluid sizing handles this */
body.mobile-tablet.landscape .cards-grid {
    /* Auto-fit with minmax handles landscape naturally */
}

@media (max-width: 768px) {
    /* Fluid auto-fit handles grid columns - this ensures minimum sizing */
    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(clamp(140px, 40vw, 200px), 1fr));
    }

    .card-back-content {
        padding: clamp(8px, 2vw, 16px);
        gap: clamp(8px, 2vw, 14px);
    }

    .primary-word-box {
        padding: clamp(10px, 2vw, 16px);
    }

    .primary-note,
    .secondary-note {
        font-size: clamp(11px, 1.5vw, 14px);
    }
}

@media (max-width: 480px) {
    .card-back-content {
        padding: clamp(8px, 3vw, 12px);
        gap: clamp(8px, 2vw, 12px);
    }

    .primary-word-box {
        padding: clamp(8px, 3vw, 14px);
    }

    .primary-note,
    .secondary-note {
        font-size: clamp(10px, 2.5vw, 13px);
    }

    .secondary-language {
        padding: clamp(8px, 2vw, 12px);
    }
}