/* app-browse.css — parte 5 del split de styles-professional.css (2026-07-18).
   Módulo Browse: grid de vocabulario, filtros, tarjetas.
   ORDEN DE CARGA OBLIGATORIO: app-base → header-nav → home → practice →
   browse → strokes → quiz → stats → enhancements → dashboard-extras.
   La cascada depende de este orden; no reordenar los <link>. */

/* ============================================================================
   9. BROWSE MODULE
   ============================================================================ */
.search-section {
    margin-bottom: 24px;
    background: var(--bg-panel);
    padding: 16px 20px;
    border-radius: var(--radius-lg, 16px);
    border: 1px solid var(--color-border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* Omnibar Search Wrapper */
.browse-search-wrapper {
    position: relative;
    flex: 2;
    min-width: 240px;
    display: flex;
    align-items: center;
}

.browse-search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    pointer-events: none;
    transition: color 0.2s ease;
}

.browse-search-wrapper:focus-within .browse-search-icon {
    color: var(--primary, #f43f5e);
}

.search-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px solid var(--color-border);
    color: var(--text-main);
    padding: 10px 38px 10px 42px;
    border-radius: var(--radius-md, 10px);
    font-size: 0.95rem;
    font-weight: 500;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary, #f43f5e);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.18);
}

.search-input:focus-visible {
    outline: 2px solid var(--primary, #f43f5e);
    outline-offset: 2px;
}

.search-clear-btn {
    position: absolute;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.search-clear-btn:hover {
    color: var(--primary, #f43f5e);
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.1);
}

/* Filter Groups (Level & Sort) */
.browse-filter-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md, 10px);
    padding: 2px 10px;
    min-height: 42px;
    transition: border-color 0.2s ease;
}

.browse-filter-group:hover,
.browse-filter-group:focus-within {
    border-color: rgba(244, 63, 94, 0.4);
}

.browse-filter-label {
    color: var(--primary, #f43f5e);
    display: flex;
    align-items: center;
}

.browse-filter-group .select-input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 4px;
    cursor: pointer;
    outline: none;
}

.browse-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 42px;
    padding: 8px 14px;
    font-size: 0.84rem;
    font-weight: 600;
    border-radius: var(--radius-md, 10px);
    white-space: nowrap;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.browse-tool-btn:hover {
    transform: translateY(-1px);
}

/* Quick HSK Level Filter Chips */
.browse-level-chips {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0;
}

.browse-level-chips::-webkit-scrollbar {
    display: none;
}

.level-chip {
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--color-border);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    touch-action: manipulation;
}

.level-chip:hover {
    color: var(--primary, #f43f5e);
    border-color: rgba(244, 63, 94, 0.4);
    background: rgba(244, 63, 94, 0.06);
    transform: translateY(-1px);
}

.level-chip.active {
    color: #ffffff;
    background: var(--primary, #f43f5e);
    border-color: var(--primary, #f43f5e);
    box-shadow: 0 3px 12px rgba(244, 63, 94, 0.35);
    font-weight: 700;
}

.vocabulary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    align-items: stretch;
}

.vocab-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 22px 18px 14px;
    text-align: center;
    transition:
        transform var(--transition-fast),
        border-color var(--transition-fast),
        box-shadow var(--transition-fast);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

/* Lomo de tono: acento de color semántico en el borde izquierdo */
.vocab-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--color-border-subtle);
    transition: width var(--transition-fast), background var(--transition-fast);
}
.vocab-card.tone-spine-1::before { background: var(--color-tone-1); }
.vocab-card.tone-spine-2::before { background: var(--color-tone-2); }
.vocab-card.tone-spine-3::before { background: var(--color-tone-3); }
.vocab-card.tone-spine-4::before { background: var(--color-tone-4); }
.vocab-card.tone-spine-0::before { background: var(--color-tone-0); }

.vocab-card:hover {
    transform: translateY(-4px);
    border-color: rgba(229, 57, 53, 0.45);
    box-shadow: var(--shadow-md);
}
.vocab-card:hover::before {
    width: 5px;
}

/* Acción principal de la tarjeta: botón real (accesible, sin anidar interactivos) */
.vocab-card-main {
    appearance: none;
    -webkit-appearance: none;
    background: none;
    border: none;
    margin: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}
.vocab-card-main:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 4px;
    border-radius: var(--radius-sm);
}

.vocab-char,
.vocab-character {
    font-size: 2.6rem;
    color: var(--text-main);
    font-family: var(--font-chinese-serif);
    font-weight: 600;
    width: 76px;
    height: 76px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);

    /* Rejilla de Caligrafía 田字格: cruz central limpia, sin diagonales */
    background-color: rgba(254, 252, 251, 0.85); /* Papel de arroz cálido */
    border: 1.5px solid rgba(220, 38, 38, 0.22); /* Borde rojo lacado suave */
    background-image:
        linear-gradient(to bottom, transparent calc(50% - 0.5px), rgba(220, 38, 38, 0.12) calc(50% - 0.5px), rgba(220, 38, 38, 0.12) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
        linear-gradient(to right, transparent calc(50% - 0.5px), rgba(220, 38, 38, 0.12) calc(50% - 0.5px), rgba(220, 38, 38, 0.12) calc(50% + 0.5px), transparent calc(50% + 0.5px));
    background-size: 100% 100%;
    box-shadow:
        inset 0 0 6px rgba(220, 38, 38, 0.03),
        0 2px 6px rgba(0, 0, 0, 0.04);
}

.vocab-character-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 0 auto 14px;
    flex-wrap: wrap;
    min-height: 76px;
    align-items: center;
}

.vocab-character-box {
    font-size: 2rem;
    color: var(--text-main);
    font-family: var(--font-chinese-serif);
    font-weight: 600;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);

    /* Rejilla de Caligrafía 田字格: cruz central limpia, sin diagonales */
    background-color: rgba(254, 252, 251, 0.85); /* Papel de arroz cálido */
    border: 1.5px solid rgba(220, 38, 38, 0.22); /* Borde rojo lacado suave */
    background-image:
        linear-gradient(to bottom, transparent calc(50% - 0.5px), rgba(220, 38, 38, 0.14) calc(50% - 0.5px), rgba(220, 38, 38, 0.14) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
        linear-gradient(to right, transparent calc(50% - 0.5px), rgba(220, 38, 38, 0.14) calc(50% - 0.5px), rgba(220, 38, 38, 0.14) calc(50% + 0.5px), transparent calc(50% + 0.5px));
    background-size: 100% 100%;
    box-shadow:
        inset 0 0 6px rgba(220, 38, 38, 0.03),
        0 2px 6px rgba(0, 0, 0, 0.04);
}

/* Las cajas mi-zi-ge conservan papel claro en ambos temas: los caracteres
   dentro usan la paleta de tonos del tema claro, no la aclarada para
   superficies oscuras */
html[data-theme="dark"] .vocab-character,
html[data-theme="dark"] .vocab-character-box {
    --color-tone-1: #dc2626; /* Rojo */
    --color-tone-2: #16a34a; /* Verde */
    --color-tone-3: #2563eb; /* Azul */
    --color-tone-4: #7c3aed; /* Morado */
    --color-tone-0: #6b7280; /* Gris */
}

html[data-theme="dark"][data-tone-scheme="alt"] .vocab-character,
html[data-theme="dark"][data-tone-scheme="alt"] .vocab-character-box,
body[data-tone-scheme="alt"] .vocab-character,
body[data-tone-scheme="alt"] .vocab-character-box {
    --color-tone-1: #d97706; /* Amarillo */
    --color-tone-2: #2563eb; /* Azul */
    --color-tone-3: #16a34a; /* Verde */
    --color-tone-4: #dc2626; /* Rojo */
    --color-tone-0: #6b7280; /* Gris */
}

.vocab-pinyin {
    color: var(--primary);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    margin-bottom: 4px;
}

.vocab-meaning {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 12px;
}

/* Pie de tarjeta: metadatos alineados al fondo para ritmo uniforme en la rejilla */
.vocab-card-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding-top: 10px;
    border-top: 1px solid var(--color-border-subtle);
}

/* Nivel como badge discreto: metadato, no protagonista */
.vocab-level {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: var(--weight-semibold);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
    background: var(--color-bg-hover);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-pill);
    padding: 2px 10px;
}

/* Botón de audio compacto en el pie */
.vocab-card-footer .vocab-audio-btn {
    width: 30px;
    height: 30px;
}

/* ============================================================================
   MOBILE RESPONSIVE BROWSE STYLES
   ============================================================================ */
@media (max-width: 640px) {
    .search-section {
        padding: 14px;
        margin-bottom: 16px;
    }

    .search-container {
        flex-direction: column;
        gap: 10px;
    }

    .browse-search-wrapper {
        min-width: 100%;
        width: 100%;
    }

    .search-input {
        min-width: 100%;
        width: 100%;
        min-height: 44px;
        padding: 10px 36px 10px 38px;
    }

    .browse-filter-group {
        width: 100%;
        justify-content: space-between;
    }

    .browse-tool-btn {
        width: 100%;
        justify-content: center;
    }

    .vocabulary-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }

    .vocab-card {
        padding: 14px 10px 10px;
        border-radius: var(--radius-md);
    }

    .vocab-char,
    .vocab-character {
        width: 60px;
        height: 60px;
        font-size: 2.1rem;
        margin-bottom: 8px;
    }

    .vocab-character-container {
        min-height: 60px;
        margin-bottom: 8px;
        gap: 4px;
    }

    .vocab-character-box {
        width: 44px;
        height: 44px;
        font-size: 1.5rem;
    }

    .vocab-pinyin {
        font-size: 0.95rem;
        margin-bottom: 2px;
    }

    .vocab-meaning {
        font-size: 0.78rem;
        margin-bottom: 8px;
    }

    .vocab-card-footer {
        padding-top: 8px;
        gap: 6px;
    }
}

@media (max-width: 360px) {
    .vocabulary-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   BROWSE LOADING & STATUS INDICATORS
   ============================================================================ */
.browse-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px 0;
    width: 100%;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.browse-loading .loading-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: browse-spin 0.8s linear infinite;
}

@keyframes browse-spin {
    to { transform: rotate(360deg); }
}

.browse-no-more {
    text-align: center;
    padding: 24px 0 16px;
    width: 100%;
    color: var(--text-dim);
    font-size: 0.88rem;
}

.browse-no-more .no-more-text {
    display: inline-block;
    padding: 6px 16px;
    background: var(--bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
}

.browse-sentinel {
    height: 20px;
    width: 100%;
    margin: 10px 0;
    pointer-events: none;
    opacity: 0;
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 16px;
    background: var(--bg-card);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-lg, 16px);
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.no-results .no-results-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    color: var(--primary, #f43f5e);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.no-results h4 {
    color: var(--text-main);
    font-size: 1.15rem;
    margin-bottom: 6px;
}

.no-results p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.no-results .reset-filter-btn {
    border-radius: 999px;
    padding: 8px 20px;
    font-weight: 600;
    cursor: pointer;
    background: var(--primary, #f43f5e);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 14px rgba(244, 63, 94, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.no-results .reset-filter-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(244, 63, 94, 0.35);
}

/* ---- Selection Mode & Floating Action Bar ---- */
.selection-floating-bar {
    position: sticky;
    top: 12px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-panel, #ffffff);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid var(--primary, #f43f5e);
    border-radius: var(--radius-md, 14px);
    box-shadow: 0 12px 32px -4px rgba(244, 63, 94, 0.22), 0 8px 16px -6px rgba(0, 0, 0, 0.12);
    margin-bottom: 16px;
    animation: slideDownFade 0.25s ease-out;
}

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

.selection-bar-info {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary, #f43f5e);
}

.selection-bar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.browse-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-md, 8px);
    font-weight: 600;
}

.vocab-card {
    position: relative;
}

.vocab-card-select-label {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.vocab-card:hover .vocab-card-select-label,
.selection-mode-active .vocab-card-select-label,
.vocab-card.is-card-selected .vocab-card-select-label {
    opacity: 1;
}

.vocab-card-select-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--primary, #f43f5e);
    cursor: pointer;
    border-radius: 4px;
    transition: transform 0.15s ease;
}

.vocab-card-select-checkbox:hover {
    transform: scale(1.15);
}

.vocab-card.is-card-selected {
    border-color: var(--primary, #f43f5e);
    background-color: rgba(244, 63, 94, 0.04);
    box-shadow: 0 0 0 1.5px var(--primary, #f43f5e), 0 8px 24px rgba(244, 63, 94, 0.15);
}

/* Tablet Responsive Browse Layout (641px - 1024px) */
@media (min-width: 641px) and (max-width: 1024px) {
    .search-section {
        padding: 18px;
    }

    .search-container {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
    }

    .search-input {
        flex: 1 1 240px;
        min-height: 44px;
    }

    .vocabulary-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
        gap: 14px;
    }
}
