/* app-enhancements.css — parte 9 del split de styles-professional.css (2026-07-18).
   UX enhancements, auth, toasts, fusion upgrade y rediseño de flashcard back (overrides tardíos — deben cargar después de practice).
   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. UX ENHANCEMENTS & ANIMATIONS
   ============================================================================ */

/* Zen Mode */
body.zen-mode .app-header,
body.zen-mode .nav-container,
body.zen-mode .study-progress,
body.zen-mode .level-selector {
    display: none !important;
    opacity: 0;
    transition: opacity 0.5s ease;
}

body.zen-mode .main-content {
    padding-top: 40px;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.zen-mode .practice-container {
    max-width: 800px;
    width: 100%;
}

/* Visual Feedback for Ratings */
.difficulty-button.active-rating {
    transform: none;
    filter: brightness(1.2);
}

.difficulty-button[data-difficulty="easy"].active-rating {
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
}

.difficulty-button[data-difficulty="good"].active-rating {
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}

.difficulty-button[data-difficulty="hard"].active-rating {
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.5);
}

.difficulty-button[data-difficulty="again"].active-rating {
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

/* Feedback Pulse Animation */
@keyframes feedbackPulse {
    0% {
        opacity: 0;
        transform: none;
    }

    50% {
        opacity: 1;
        transform: none;
    }

    100% {
        opacity: 1;
        transform: none;
    }
}

/* ============================================================================
   14. AUTHENTICATION & UTILITIES
   ============================================================================ */
.auth-guest {
    display: flex;
    align-items: center;
}

.github-login-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-card);
    border: 1px solid var(--border-soft);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.github-login-btn:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: var(--primary);
}

.github-login-btn svg {
    width: 20px;
    height: 20px;
}

/* ============================================================================
   TOAST NOTIFICATIONS
   (Moved from ui-controller.js ensureToastStyles() — do not duplicate)
   ============================================================================ */
.hsk-toast-container {
    position: fixed;
    top: 84px;
    right: 20px;
    z-index: 10050;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.hsk-toast {
    min-width: 260px;
    max-width: 400px;
    border-radius: 12px;
    padding: 12px 18px;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(10px);
    transition:
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.hsk-toast.show {
    opacity: 1;
    transform: translateY(0);
}
.hsk-toast.hide {
    opacity: 0;
    transform: translateY(-10px);
}
.hsk-toast-success {
    background: rgba(22, 163, 74, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.hsk-toast-error {
    background: rgba(220, 38, 38, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.hsk-toast-info {
    background: rgba(37, 99, 235, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.hsk-toast-warning {
    background: rgba(217, 119, 6, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.hsk-toast-action {
    background: #fff;
    color: #000;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}
.hsk-toast-action:hover {
    background: rgba(255, 255, 255, 0.9);
}
.hsk-toast-text {
    line-height: 1.4;
}

/* ============================================================================
   10. SINO-BOLIVIAN FUSION UX/UI UPGRADE
   ============================================================================ */

/* Barra de Coronación Aguayo Andino (Header Top) */
/* Acento superior = legend de los 4 tonos del mandarín (color semántico,
   no decorativo). Usa las variables de tono para coherencia con el tema. */
.app-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(to right,
        var(--color-tone-1) 0% 25%,
        var(--color-tone-2) 25% 50%,
        var(--color-tone-3) 50% 75%,
        var(--color-tone-4) 75% 100%
    );
    opacity: 0.9;
    z-index: 1010;
    pointer-events: none;
}

/* Efecto de Pergamino Imperial (Borde de Oro Superior en Tarjetas) */
.home-card,
.stat-card,
.flashcard,
.stats-chart-card,
.stats-achievements-card,
.level-progress,
.past-exam-card,
.vocab-detail-card,
.sr-card,
.achievement-badge {
    position: relative;
    border-top: 3.5px solid var(--accent) !important; /* Oro Imperial */
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.08),
        0 1px 2px rgba(0, 0, 0, 0.05) !important;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.home-card:hover,
.stat-card:hover,
.past-exam-card:hover,
.vocab-detail-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: 
        0 12px 28px rgba(0, 0, 0, 0.14),
        0 0 15px rgba(245, 158, 11, 0.15) !important; /* Brillo dorado suave en hover */
}

/* Resplandor Premium de Botones (Imperial Red Glow Shadow) */
.btn-primary,
.snakeq-btn-primary {
    position: relative;
    box-shadow: 
        0 4px 12px rgba(229, 57, 53, 0.25),
        0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all var(--transition-normal);
}

.btn-primary:hover,
.snakeq-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 20px rgba(229, 57, 53, 0.45),
        0 0 12px rgba(250, 204, 21, 0.3); /* Destello dorado lateral */
}

.btn-secondary,
.snakeq-btn-secondary {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.btn-secondary:hover,
.snakeq-btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}

/* Sello Académico Caligráfico Chino Tradicional (Yinzhang) */
.hsk-academic-seal {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 32px;
    height: 32px;
    background: radial-gradient(circle at 35% 35%, #f43f5e, #dc2626 70%, #9f1239);
    border: 2px double var(--accent); /* Doble borde dorado imperial */
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-family: var(--font-chinese);
    font-size: 0.95rem;
    font-weight: 700;
    transform: rotate(-8deg);
    box-shadow: 
        0 4px 10px rgba(220, 38, 38, 0.4),
        0 0 0 1px rgba(245, 158, 11, 0.2);
    user-select: none;
    z-index: 10;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.achievement-badge .hsk-academic-seal,
.vocab-card .hsk-academic-seal {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
    top: 10px;
    right: 10px;
    border-width: 1px;
}

.hsk-academic-seal:hover {
    transform: scale(1.12) rotate(4deg);
    box-shadow: 
        0 6px 14px rgba(220, 38, 38, 0.55),
        0 0 8px rgba(245, 158, 11, 0.35);
}

/* ============================================================================
   11. PREMIUM FLASHCARD BACK REDESIGN (ACADEMIC & BILINGUAL)
   ============================================================================ */

/* Contenedor expandido del reverso de tarjeta */
.word-info-expanded {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 8px;
}

/* Header del Reverso — layout horizontal compacto */
.card-back-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    margin-bottom: 2px;
    flex-shrink: 0;
}

/* Bloque de texto al lado del carácter */
.card-back-header-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.card-back-pinyin {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
    margin: 0;
}

.pinyin-syllable-badge {
    padding: 1px 6px;
    border-radius: 5px;
    background: color-mix(in srgb, currentColor 6%, transparent);
    border: 1px solid color-mix(in srgb, currentColor 15%, transparent);
    font-size: 1.1rem;
}

/* Botón de pronunciación compacto */
.card-back-pronunciation {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    border: 1.5px solid rgba(245, 158, 11, 0.3) !important;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(211, 47, 47, 0.04) 100%);
    color: var(--accent) !important;
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.card-back-pronunciation svg {
    transition: transform 0.3s ease;
}

.card-back-pronunciation:hover {
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
    color: #ffffff !important;
    border-color: transparent !important;
    transform: translateY(-2px);
    box-shadow: 
        0 6px 14px rgba(245, 158, 11, 0.3),
        0 0 8px rgba(211, 47, 47, 0.15);
}

.card-back-pronunciation:hover svg {
    transform: scale(1.15) rotate(-5deg);
}

.card-back-pronunciation:active {
    transform: translateY(0) scale(0.97);
}

/* Sección de Traducciones — compacta, sin scroll */
.translations-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    flex-shrink: 0;
}

.translation-item {
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    transition: all 0.25s ease;
}

.translation-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* Primaria */
.primary-translation {
    border-left: 4px solid var(--primary);
    background: rgba(211, 47, 47, 0.02);
}

.primary-translation .translation-header {
    background: rgba(211, 47, 47, 0.05);
    border-bottom: 1px solid rgba(211, 47, 47, 0.08);
}

.primary-translation .translation-content {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--primary);
}

/* Secundaria */
.secondary-translation {
    border-left: 4px solid var(--accent);
    background: rgba(245, 158, 11, 0.02);
}

.secondary-translation .translation-header {
    background: rgba(245, 158, 11, 0.05);
    border-bottom: 1px solid rgba(245, 158, 11, 0.08);
}

.secondary-translation .translation-content {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.translation-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
}

.lang-flag {
    font-size: 0.62rem;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.primary-translation .lang-flag {
    background: linear-gradient(135deg, #d32f2f 0%, #388e3c 100%);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.secondary-translation .lang-flag {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.lang-name {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.translation-content {
    padding: 8px 12px;
    line-height: 1.4;
}

/* Cuadrícula de Detalles — compacta */
.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    flex-shrink: 0;
}

/* Una sola tarjeta de detalle (Tonos): ocupa el ancho completo */
.details-grid--single {
    grid-template-columns: 1fr;
}

.detail-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
    transition: all 0.25s ease;
}

.detail-card:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(245, 158, 11, 0.15);
}

.detail-card-classifier {
    cursor: pointer;
}

.detail-card-classifier:hover {
    border-color: rgba(200, 16, 46, 0.4);
    background: rgba(200, 16, 46, 0.05);
}

.classifier-display {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.classifier-badge {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    background: rgba(200, 16, 46, 0.12);
    color: var(--primary-color, #c8102e);
    padding: 2px 7px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.88rem;
}

.classifier-badge .classifier-pinyin {
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0.85;
}

.classifier-phrase {
    font-size: 0.85rem;
    color: var(--text-muted, #94a3b8);
}

.detail-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.detail-icon svg {
    width: 14px;
    height: 14px;
}

/* Iconos de detalle temáticos */
.detail-card:nth-child(1) .detail-icon {
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.detail-card:nth-child(2) .detail-icon {
    background: rgba(211, 47, 47, 0.12);
    color: var(--primary);
    border: 1px solid rgba(211, 47, 47, 0.2);
}

.detail-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

/* Badges para clasificación por Gemas Preciosas */
.word-type-badge {
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Verde Jade para Verbos */
.word-type-verb {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Oro Imperial para Sustantivos */
.word-type-noun {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Azul Lapislázuli para Adjetivos */
.word-type-adj {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Rojo Rubí para Pronombres, Clasificadores o Caracteres únicos */
.word-type-char, .word-type-word {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Badges Visuales Direccionales de Tonos */
.tone-visual-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 800;
    box-shadow: 0 1.5px 3px rgba(0, 0, 0, 0.04);
}

/* Canonical tone palette: 1=red 2=green 3=blue 4=purple 0=gray */
.tone-1 { color: #dc2626; }
.tone-2 { color: #16a34a; }
.tone-3 { color: #2563eb; }
.tone-4 { color: #7c3aed; }
.tone-0 { color: #6b7280; }

.tone-visual-badge.tone-1 {
    background: rgba(220, 38, 38, 0.10);
    color: #dc2626;
    border: 1px solid rgba(220, 38, 38, 0.25);
}

.tone-visual-badge.tone-2 {
    background: rgba(22, 163, 74, 0.10);
    color: #16a34a;
    border: 1px solid rgba(22, 163, 74, 0.25);
}

.tone-visual-badge.tone-3 {
    background: rgba(37, 99, 235, 0.10);
    color: #2563eb;
    border: 1px solid rgba(37, 99, 235, 0.25);
}

.tone-visual-badge.tone-4 {
    background: rgba(124, 58, 237, 0.10);
    color: #7c3aed;
    border: 1px solid rgba(124, 58, 237, 0.25);
}

.tone-visual-badge.tone-0 {
    background: rgba(107, 114, 128, 0.10);
    color: #6b7280;
    border: 1px solid rgba(107, 114, 128, 0.25);
}

.tone-arrow {
    font-family: Arial, sans-serif;
    font-size: 0.9rem;
    line-height: 1;
}

/* Oraciones de Ejemplo — compactas */
.example-section {
    width: 100%;
    flex: 1;
    min-height: 0;
}

.example-title {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    border-left: 3px solid var(--accent);
    padding-left: 8px;
}

.example-sentence {
    position: relative;
    border-radius: 10px;
    padding: 10px 14px !important;
    background: rgba(254, 252, 251, 0.4) !important;
    border: 1px solid rgba(245, 158, 11, 0.2) !important;
    border-left: 4px solid var(--accent) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .example-sentence {
    background: rgba(30, 41, 59, 0.25) !important;
    border-color: rgba(245, 158, 11, 0.12) !important;
}

.example-chinese {
    font-size: 1.15rem !important;
    font-weight: 700;
    font-family: var(--font-chinese);
    color: var(--color-text-charcoal);
    letter-spacing: 0.8px;
    line-height: 1.5;
}

.example-pinyin {
    font-size: 0.85rem !important;
    margin-top: 4px;
    font-weight: 500;
    opacity: 0.85;
}

.example-translations {
    margin-top: 6px !important;
    display: flex;
    flex-direction: column;
    gap: 3px;
    border-top: 1px solid rgba(245, 158, 11, 0.08);
    padding-top: 6px;
}

.example-translations > div {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-main);
    display: flex;
    align-items: center;
    line-height: 1.3;
}

.example-translations .lang-flag {
    font-size: 0.58rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    margin-right: 6px;
    box-shadow: none;
}

/* Resaltado caligráfico de Hanzi */
.highlight-char {
    color: var(--primary) !important;
    font-weight: 900;
    padding: 0 3px;
    background: rgba(211, 47, 47, 0.06);
    border-radius: 4px;
    border-bottom: 2px dashed var(--accent); /* Ondulado caligráfico en oro */
    margin: 0 2px;
    display: inline-block;
    transition: all 0.25s ease;
}

.highlight-char:hover {
    background: rgba(211, 47, 47, 0.12);
    transform: scale(1.08);
}

/* Responsividad para Reverso de Tarjeta */
@media (max-width: 580px) {
    .translations-section,
    .details-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .detail-card {
        padding: 6px 10px;
    }

    .classifier-display {
        gap: 6px;
    }

    .classifier-badge {
        font-size: 0.84rem;
        padding: 2px 6px;
    }

    .classifier-phrase {
        font-size: 0.82rem;
    }
}

/* ============================================================================
   9.5 ACCESSIBILITY & VIEW TRANSITIONS
   ============================================================================ */

/* High-Contrast Focus Visible Ring (WCAG 2.1 AA) */
:focus-visible {
    outline: 2px solid var(--primary, #e11d48) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.25) !important;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* Reduced Motion Preference Overrides */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) {
        animation: none !important;
    }
}

/* View Transitions Root Smoothing */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.22s;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}


