/* Components: Cards, Buttons, Controls */

/* ========================================
   TIER-BASED TEXT SIZING (Standard Mode)
   Dynamic font sizing based on text length
   ======================================== */

/* TIER-BASED TEXT SIZING (Standard Mode)
   Dynamic font sizing based on text length with clamp() for responsiveness
   ======================================== */

/* TIER 1: Short text (1-8 chars) - Standard size */
.flashcard[data-text-tier="short"] {
    --text-size-ja: clamp(3rem, 10vw + 1rem, 5em);
    --text-size-en: clamp(1.5rem, 4vw + 0.5rem, 2.8em);
    --text-size-roma: clamp(0.9rem, 1.1em, 1.2em);
}

/* TIER 2: Medium text (9-15 chars) - Reduced size */
.flashcard[data-text-tier="medium"] {
    --text-size-ja: clamp(2.2rem, 7vw + 0.5rem, 3.8em);
    --text-size-en: clamp(1.2rem, 3.5vw + 0.5rem, 2.3em);
    --text-size-roma: clamp(0.85rem, 1em, 1.1em);
}

/* TIER 3: Long text (16+ chars) - Smallest size */
.flashcard[data-text-tier="long"] {
    --text-size-ja: clamp(1.8rem, 5vw + 0.5rem, 3em);
    --text-size-en: clamp(1rem, 3vw + 0.5rem, 1.9em);
    --text-size-roma: clamp(0.8rem, 0.9em, 1em);
}

/* App Branding (Top Left) - Elegant text branding */
.app-branding-topleft {
    position: fixed;
    top: 0;
    left: 30px;
    height: 70px; /* Match standard mode top bar height */
    z-index: 100;
    display: flex;
    flex-direction: row;
    align-items: center; /* Vertically center in the 70px space */
    gap: 12px;
    transition: opacity 0.3s ease; /* Only transition opacity, not position */
    opacity: 1;
    pointer-events: none; /* Let clicks pass through */
    /* animation removed - was causing layout jumps in standard mode */
}

.app-branding-topleft > * {
    pointer-events: auto;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app-branding-topleft:hover {
    transform: translateY(-3px) scale(1.02);
}

.branding-title-topleft {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 2.4em;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
    background: linear-gradient(135deg,
        #ff6b9d 0%,
        #667eea 100%);
    background-size: 200% 200%;
    animation: gradientShift 6s ease infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.6));
    position: relative;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.branding-title-topleft .emoji-gradient {
    display: inline-block;
    background: linear-gradient(135deg,
        #ff6b9d 0%,
        #ffd93d 50%,
        #667eea 100%);
    background-size: 200% 200%;
    animation: emojiShift 4s ease infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 6px rgba(255, 107, 157, 0.5))
            drop-shadow(0 0 12px rgba(255, 217, 61, 0.3));
}

@keyframes emojiShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.branding-subtitle-topleft {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 1.05em;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    line-height: 1.3;
}

/* Show text branding in ALL modes - scaled for focus/video/revision */
body.focus-mode .app-branding-topleft,
body.video-mode .app-branding-topleft,
body.revision-mode .app-branding-topleft {
    display: flex;
    position: fixed;
    top: 30px;
    left: 30px;
    height: auto; /* Reset fixed height from standard mode */
    z-index: 1000;
}

/* ===========================================
   BRANDING STYLE OPTIONS FOR FOCUS/VIDEO/REVISION
   Uncomment the option you want to use
   =========================================== */

/* OPTION C: Frosted Glass Pill (Apple-style) */
body.focus-mode .app-branding-topleft,
body.video-mode .app-branding-topleft,
body.revision-mode .app-branding-topleft {
    /* Frosted glass background */
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50px;
    padding: 12px 24px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

body.focus-mode .branding-title-topleft,
body.video-mode .branding-title-topleft,
body.revision-mode .branding-title-topleft {
    font-size: clamp(1.6rem, 2.5vw, 2.2rem);
    /* Clean white text */
    background: none !important;
    -webkit-background-clip: unset !important;
    -webkit-text-fill-color: #ffffff !important;
    background-clip: unset !important;
    color: #ffffff;
    filter: none;
    animation: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Option C: Native emoji colors */
body.focus-mode .branding-title-topleft .emoji-gradient,
body.video-mode .branding-title-topleft .emoji-gradient,
body.revision-mode .branding-title-topleft .emoji-gradient {
    background: none !important;
    -webkit-background-clip: unset !important;
    -webkit-text-fill-color: unset !important;
    background-clip: unset !important;
    filter: none;
    animation: none;
}

/* Logo (Bottom-left inside card) - All modes */
.logo-watermark {
    position: absolute;
    bottom: 25px;
    left: 25px;
    z-index: 100;
    pointer-events: none;
    opacity: 0.85;
    transition: opacity 0.3s ease;
}

.logo-watermark img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 50%;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

/* Larger logo in focus/video/revision modes for YouTube */
body.focus-mode .logo-watermark img,
body.video-mode .logo-watermark img,
body.revision-mode .logo-watermark img {
    width: 80px;
    height: 80px;
}

/* Align stats to right when header is removed */
.top-bar {
    justify-content: flex-end;
}

/* Header Category Badge */
.header-category-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.08) 100%);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.header-category-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.header-category-badge .category-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.header-category-badge .category-label {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.95em;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Card Category Watermark (Bottom Left) */
/* HIDDEN: Category badge disabled to reduce clutter */
.card-category-badge {
    position: absolute;
    bottom: 20px;
    left: 22px;
    display: none !important; /* Was: display: flex */
    align-items: center;
    gap: 14px;
    opacity: 1; /* Fully opaque - no transparency */
    transition: all 0.4s ease;
    pointer-events: none;
}

.card-category-badge .category-icon {
    width: 56px;
    height: 56px;
    object-fit: contain;
    opacity: 1; /* Fully opaque icon */
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.card-category-badge .category-label {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 1.3em;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

/* Hide card badge in focus and video modes - use screen-level indicator instead */
body.focus-mode .card-category-badge,
body.video-mode .card-category-badge {
    display: none;
}

/* Loading screen */
.loading-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

/* Controls */
.controls {
    background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.08) 100%);
    backdrop-filter: blur(15px);
    border-radius: 18px;
    padding: 20px 24px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: border-color 0.6s ease;
    gap: 0;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Subtle category color tint on controls */
.controls::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--category-primary), var(--category-secondary));
    opacity: 0.06;
    border-radius: 18px;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}

select, button {
    padding: 9px 18px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-primary);
}

/* Allow category dropdown to flex naturally */
#class-filter {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

button {
    background: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

button:active {
    transform: translateY(0);
}

/* Toggle switches */
.toggle-switch {
    position: relative;
    width: 60px;
    height: 30px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    transform: translateX(30px);
}

/* Turn green when checked - pure CSS, no JavaScript needed */
.toggle-switch:has(input:checked) {
    background: #4ade80;
}

/* Legacy support for JavaScript-added class */
.toggle-switch.active {
    background: #4ade80;
}

/* Mode buttons */
.mode-button {
    background: var(--secondary-gradient);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mode-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* Flashcard container */
.flashcard-container {
    perspective: 1000px;
    margin-bottom: 15px;
    flex: 1; /* Make flashcard container expand to fill available space */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative; /* For logo watermark positioning */
}

/* Card status backgrounds - removed, using card number badge instead */

/* Flashcard */
.flashcard {
    width: 100%;
    max-width: 900px;
    height: 740px;
    margin: 0 auto;
    position: relative;
    cursor: pointer;
    /* Prevent mobile tap highlight/flicker */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 35px; /* More vertical padding to account for fixed position elements */
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.12);
    background: #ffffff;
    transition: opacity 0.3s ease-out;
}

.card-back {
    /* Use visibility instead of display:none to prevent layout flicker on mobile */
    display: flex;
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
}

body.dark-mode .card-face {
    background: var(--glass-bg-dark);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.card-content {
    text-align: center;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 25px;
    position: relative;
}

/* Romanization styling */
.romanization {
    position: relative;
    display: inline-block;
    margin-top: 0;
    font-size: var(--text-size-roma, 1.1em);
    color: #667eea;
    font-weight: 500;
    font-family: 'Poppins', sans-serif;
    font-style: italic;
    letter-spacing: 0.1em;
    padding: 8px 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.15);
    transition: all 0.3s ease;
    z-index: 10;
    text-transform: lowercase;
    white-space: nowrap;
    overflow: visible;
}

body.dark-mode .romanization {
    color: #b8c8ff;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Content text styles */
.vocabulary-image {
    max-width: 520px;
    max-height: 520px;
    width: auto;
    height: auto;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.12);
    object-fit: contain;
    transition: transform 0.3s ease;
}

.vocabulary-image:hover {
    transform: scale(1.02);
}

.japanese-text {
    font-size: var(--text-size-ja, 4.5em);
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'Noto Sans JP', sans-serif;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    line-height: 1.2;
    white-space: nowrap;
    overflow: visible;
}

.english-text {
    font-size: var(--text-size-en, 2.8em);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: visible;
}

/* Class badge (POS only - simple) */
.class-badge {
    position: absolute;
    top: 25px;
    right: 25px;
    background: linear-gradient(135deg, rgba(240,147,251,0.9) 0%, rgba(245,87,108,0.9) 100%);
    color: white;
    padding: 8px 18px;
    border-radius: 50px;
    font-weight: 500;
    font-size: 0.9em;
    box-shadow: 0 6px 20px rgba(240,147,251,0.3);
    text-transform: lowercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

/* Larger POS badge in focus/video modes */
body.focus-mode .class-badge,
body.video-mode .class-badge {
    padding: 16px 32px !important;
    font-size: 1.6em !important;
    top: 30px !important;
    right: 30px !important;
}

.card-number {
    position: absolute;
    top: 25px;
    left: 25px;
    transform: none;
    color: var(--text-secondary);
    font-size: 1em;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 8px 18px;
    border-radius: 25px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    z-index: 100;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

/* Larger card number in focus/video modes */
body.focus-mode .card-number,
body.video-mode .card-number,
body.revision-mode .card-number {
    padding: 18px 36px !important;
    font-size: 2.2em !important; /* Bigger for mobile visibility */
    font-weight: 700 !important; /* Bolder */
    top: 30px !important;
    left: 30px !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important; /* Purple gradient */
    color: white !important; /* White text on colored background */
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4) !important; /* Glowing shadow */
}

/* Card number status colors */
.flashcard.status-known .card-number,
body.dark-mode .flashcard.status-known .card-number {
    background: #16a34a !important;
    color: white !important;
    border-color: #15803d;
    box-shadow: 0 4px 15px rgba(22, 163, 74, 0.3);
}

.flashcard.status-learning .card-number,
body.dark-mode .flashcard.status-learning .card-number {
    background: #ea580c !important;
    color: white !important;
    border-color: #c2410c;
    box-shadow: 0 4px 15px rgba(234, 88, 12, 0.3);
}

/* ========================================
   TEXTBOOK TOOLTIP - COMPACT PREMIUM
   ======================================== */

.textbook-indicator {
    margin-left: 6px;
    font-size: 0.85em;
    opacity: 0.75;
    cursor: help;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-block;
}

.textbook-indicator:hover {
    opacity: 1;
    transform: scale(1.1);
}

.textbook-tooltip {
    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.96);

    /* Positioning */
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 10px;
    z-index: 1000;

    /* Premium glass effect */
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);

    /* Compact sizing - wider to prevent wrapping */
    min-width: 240px;
    max-width: 380px;
    padding: 8px 12px;

    /* Visual styling */
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.11),
        0 4px 10px rgba(0, 0, 0, 0.07),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);

    /* Category color accent */
    border-left: 3px solid var(--category-primary);

    /* Typography */
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.8em;
    line-height: 1.5;
    color: var(--text-primary);

    /* Smooth transitions */
    transition:
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition-delay: 0.12s;

    pointer-events: none;
}

/* Washi paper texture */
.textbook-tooltip::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.04) 2px, rgba(255, 255, 255, 0.04) 4px),
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(255, 255, 255, 0.04) 2px, rgba(255, 255, 255, 0.04) 4px),
        repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(0, 0, 0, 0.015) 3px, rgba(0, 0, 0, 0.015) 6px);
    opacity: 0.5;
    mix-blend-mode: overlay;
    pointer-events: none;
    border-radius: inherit;
    z-index: 1;
}

/* Category color tint */
.textbook-tooltip::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--category-primary) 6%, transparent) 0%,
        transparent 100%);
    opacity: 0.5;
    pointer-events: none;
    border-radius: inherit;
    z-index: 2;
}

.card-number:hover .textbook-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Arrow */
.textbook-tooltip-arrow {
    position: absolute;
    bottom: 100%;
    left: 18px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 7px solid var(--category-primary);
    filter: drop-shadow(0 -2px 3px rgba(0, 0, 0, 0.08));
    z-index: 3;
}

.textbook-tooltip > * {
    position: relative;
    z-index: 10;
}

/* Compact items */
.textbook-tooltip-item {
    margin-bottom: 6px;
    padding: 5px 8px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.textbook-tooltip-item:last-child {
    margin-bottom: 0;
}

/* Source */
.textbook-tooltip-source {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.92em;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--category-primary);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.textbook-tooltip-source::before {
    content: '📖';
    font-size: 1.05em;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.textbook-tooltip-source[data-textbook*="Ippo"]::before {
    content: '🎌';
}

.textbook-tooltip-source[data-textbook*="Genki"]::before {
    content: '📘';
}

.textbook-tooltip-source[data-textbook*="JapanesePod"]::before {
    content: '🎧';
}

/* Lesson */
.textbook-tooltip-lesson {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.88em;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 3px 8px;
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.5) 0%,
        rgba(255, 255, 255, 0.25) 100%);
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: inline-block;
    white-space: nowrap; /* Prevent wrapping */
}

/* Dark mode */
body.dark-mode .textbook-tooltip {
    background: rgba(30, 30, 40, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.35),
        0 4px 10px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

body.dark-mode .textbook-tooltip-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
}

body.dark-mode .textbook-tooltip-lesson {
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.07) 0%,
        rgba(255, 255, 255, 0.03) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Hide textbook indicator in video/revision modes only (shown in focus mode for study) */
body.video-mode .textbook-indicator,
body.revision-mode .textbook-indicator {
    display: none !important;
}

/* Focus mode textbook tooltip - match standard mode light theme */
body.focus-mode .textbook-tooltip {
    /* Same light glass as standard mode for consistency */
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.15),
        0 4px 10px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    color: var(--text-primary, #1d1d1f);
    /* Ensure proper text containment */
    max-width: 420px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

body.focus-mode .textbook-tooltip-source {
    color: var(--category-primary, #6366f1);
}

body.focus-mode .textbook-tooltip-lesson {
    color: #1d1d1f;
    word-break: break-word;
    white-space: normal;
}

body.focus-mode .textbook-tooltip-item {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(0, 0, 0, 0.04);
}

body.focus-mode .textbook-tooltip-arrow {
    border-bottom-color: rgba(255, 255, 255, 0.98);
}



/* Audio button (Updated for visibility) */
.audio-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08); /* Match nav-buttons */
    border: none;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.4rem; /* Match nav-buttons */
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.3, 1.5, 0.5, 1);
    box-shadow: none; /* Remove shadow to match nav-buttons style initially */
    display: flex;
    align-items: center;
    justify-content: center;
    /* Remove absolute positioning to fit in flex container */
    position: static; 
    bottom: auto;
    right: auto;
}

.audio-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.15);
    color: white;
}

.audio-button.playing {
    animation: pulse 1.5s infinite;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.audio-button.hidden {
    display: none !important;
}

/* Navigation */
.navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    margin-bottom: 10px;
}

.nav-button {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4em;
    background: linear-gradient(145deg, #ffffff 0%, #f5f5f5 100%);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.nav-button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

/* Score buttons */
.score-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    margin-bottom: 0;
}

.score-button {
    padding: 14px 35px;
    border-radius: 25px;
    font-weight: 600;
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9em;
}

.score-button.known {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
}

.score-button.learning {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

.score-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Progress bar */
.progress-container {
    width: 100%;
    max-width: 900px;
    margin: 15px auto 15px;
    background: linear-gradient(90deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.1) 100%);
    border-radius: 10px;
    padding: 2px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
}

.progress-bar {
    height: 8px;
    background: linear-gradient(90deg, var(--category-light) 0%, var(--category-primary) 100%);
    border-radius: 8px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
}

/* Focus mode button on card */
.focus-button-card {
    position: absolute;
    bottom: 25px;
    right: 25px;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #555;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 110;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.focus-button-card:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: scale(1.08);
    opacity: 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

body.dark-mode .focus-button-card {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
}

body.dark-mode .focus-button-card:hover {
    background: rgba(0, 0, 0, 0.6);
    color: white;
}

/* Hide old focus button on card - now in action bar */
.focus-button-card {
    display: none !important;
}

/* ========================================
   PREMIUM FILTER SECTION
   ======================================== */

.filter-section {
    width: 100%;
    margin-bottom: 16px;
}

.filter-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.filter-icon {
    font-size: 1.4em;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.filter-title {
    font-family: 'Inter', sans-serif;
    font-size: 1.1em;
    font-weight: 600;
    color: white;
    letter-spacing: -0.01em;
}

.word-count-badge {
    margin-left: auto;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.word-count-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

#filteredWordCount {
    font-weight: 700;
    font-size: 1.1em;
}

.filter-controls {
    width: 100%;
}

.filter-row {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    flex: 1 1 0;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-size: 0.9em;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    gap: 6px;
}

.premium-select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.95);
    color: #2d3748;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.premium-select:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.4);
    background: white;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.premium-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
}

.premium-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.6);
}

.control-divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 20%,
        rgba(255, 255, 255, 0.3) 80%,
        transparent 100%
    );
    margin: 16px 0;
}

.settings-section {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

/* Responsive adjustments for filters */
@media (max-width: 900px) {
    .filter-row {
        flex-direction: column;
    }
    
    .filter-group {
        min-width: 100%;
    }
}


/* Pulse animation for word count badge */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}
