/* app-base.css — parte 1 del split de styles-professional.css (2026-07-18).
   Reset, estilos base, estructura de layout y pilares sino-bolivianos.
   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>. */

/*
================================================================================
CONFUC10 ++ - PROFESSIONAL DESIGN SYSTEM
================================================================================
Version: 4.0.0
Description: Modern, professional, and aesthetic design for HSK Learning Platform.
Features: Glassmorphism, Deep Dark Theme, Smooth Animations, Mobile Responsive.
================================================================================
*/

/* ============================================================================
   1. DESIGN TOKENS (VARIABLES)
   ============================================================================ */
/* Design Tokens are now centralized in design-tokens.css.
   All variables (--primary, --bg-app, --text-main, etc.) are inherited from there.
   To customize the theme, edit design-tokens.css — not this file. */

/* ============================================================================
   2. RESET & BASE STYLES
   ============================================================================ */
html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    max-width: 100vw;
}

/* Custom modern scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(229, 57, 53, 0.2);
    border-radius: 4px;
    transition: background 0.2s;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(229, 57, 53, 0.45);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-app);
    /* Atmósfera sutil en secciones de trabajo: leve brillo cálido superior,
       sin competir con el contenido */
    background-image: radial-gradient(1100px 480px at 50% -120px, rgba(229, 57, 53, 0.05), transparent 70%);
    background-repeat: no-repeat;
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

html[data-theme="dark"] body {
    background-image: radial-gradient(1100px 480px at 50% -120px, rgba(229, 57, 53, 0.09), transparent 70%);
}

/* Patrón sutil recursivo con espirales (Fusión Bolivia - China: Tiwanaku/Chakana & Nubes Xiangyun).
   Capa fija para una atmósfera continua sin repintar el body. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.92)),
        url("../images/background01.webp");
    background-size: cover;
    background-position: center;
    opacity: 0.7;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

html[data-theme="dark"] body::before {
    background-image:
        linear-gradient(rgba(10, 10, 15, 0.90), rgba(10, 10, 15, 0.95)),
        url("../images/background01.webp");
    opacity: 0.75;
}

html[data-active-tab="home"] body::before {
    opacity: 1;
}

html[data-theme="dark"][data-active-tab="home"] body::before {
    opacity: 0.9;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

a {
    text-decoration: none;
    color: inherit;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

input::placeholder,
textarea::placeholder,
select:disabled,
input:disabled,
textarea:disabled,
button:disabled {
    color: var(--text-muted);
}

input::placeholder,
textarea::placeholder {
    opacity: 0.9;
}

select:disabled,
input:disabled,
textarea:disabled,
button:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

ul {
    list-style: none;
}

:where(
    a,
    button,
    input,
    select,
    textarea,
    [role="button"],
    [tabindex]
):focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.home-card:focus-visible,
.vocab-card:focus-visible,
#flashcard:focus-visible,
.nav-tab:focus-visible,
.header-control:focus-visible,
.action-btn:focus-visible,
.btn-primary:focus-visible {
    box-shadow: var(--shadow-glow);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-app);
}

::-webkit-scrollbar-thumb {
    background: var(--text-dim);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================================================
   3. LAYOUT STRUCTURE
   ============================================================================ */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .app-container {
        min-height: 100dvh;
    }

    .main-content {
        padding: 10px max(10px, env(safe-area-inset-left, 0px)) calc(var(--bottom-nav-height, 60px) + var(--safe-area-bottom, 0px) + 24px) max(10px, env(safe-area-inset-right, 0px));
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Prevent unwanted iOS auto-zoom when focusing form inputs */
    input,
    select,
    textarea {
        font-size: 16px !important;
    }

    button,
    .btn,
    .header-control,
    .nav-tab,
    .action-btn,
    .tone-pill-btn,
    .syllable-chip,
    .word-chip-btn,
    .vocab-card,
    .quiz-option-btn {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Universal Bottom-Sheet Dialogs for Mobile */
    dialog {
        position: fixed !important;
        bottom: 0 !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: calc(100dvh - 36px) !important;
        border-radius: 20px 20px 0 0 !important;
        padding-bottom: max(16px, env(safe-area-inset-bottom, 0px)) !important;
        box-sizing: border-box;
    }

    dialog::backdrop {
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

/* Standalone PWA adjustments */
html.is-pwa-standalone .app-header {
    padding-top: max(10px, env(safe-area-inset-top, 0px)) !important;
}

html.is-pwa-standalone .pwa-smart-banner,
html.is-pwa-standalone #pwa-install-row {
    display: none !important;
}

/* ============================================================================
   3. SINO-BOLIVIAN FUSION DECORATIONS (THEMED PILLARS & TEXT)
   ============================================================================ */

/* Ocultar por defecto en móviles y pantallas estándar */
.vertical-pillar-left,
.vertical-pillar-right,
.vertical-text-left,
.vertical-text-right,
.lantern-top,
.coin-bottom {
    display: none;
}

/* Reactivar de forma armónica en pantallas de escritorio amplias */
@media (min-width: 1520px) {
    .vertical-pillar-left,
    .vertical-pillar-right {
        display: block;
        position: fixed;
        top: 110px;
        bottom: 68px;
        width: 14px;
        background: rgba(30, 41, 59, 0.45);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid rgba(245, 158, 11, 0.35); /* Borde de Oro Imperial */
        border-radius: 8px;
        box-shadow: 
            0 0 16px rgba(245, 158, 11, 0.12),
            inset 0 0 8px rgba(0, 0, 0, 0.35);
        z-index: 80;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .vertical-pillar-left {
        left: calc(50vw - 680px - 45px);
    }

    .vertical-pillar-right {
        right: calc(50vw - 680px - 45px);
    }

    /* Patrón Textil Aguayo Andino vertical dentro de los pilares */
    .vertical-pillar-left::before,
    .vertical-pillar-right::before {
        content: '';
        position: absolute;
        top: 6px;
        bottom: 6px;
        left: 4px;
        width: 4px;
        border-radius: 2px;
        background: linear-gradient(to bottom, 
            #dc2626 0%, #dc2626 15%, 
            #eab308 15%, #eab308 30%, 
            #10b981 30%, #10b981 45%, 
            #ec4899 45%, #ec4899 60%, 
            #3b82f6 60%, #3b82f6 75%, 
            #eab308 75%, #eab308 90%, 
            #dc2626 90%, #dc2626 100%
        );
        box-shadow: 0 0 6px rgba(255, 255, 255, 0.15);
    }

    /* Faroles Chinos Colgantes en el tope */
    .lantern-top {
        display: block;
        position: absolute;
        top: -30px;
        left: -11px;
        width: 36px;
        height: 36px;
        background: radial-gradient(circle at 35% 35%, #f43f5e, #dc2626 60%, #9f1239);
        border: 2px solid var(--color-accent, #facc15);
        border-radius: 50% 50% 45% 45%;
        box-shadow: 
            0 0 16px rgba(220, 38, 38, 0.65),
            inset 0 -4px 10px rgba(0, 0, 0, 0.35);
        transform-origin: top center;
        pointer-events: auto;
        cursor: pointer;
        transition: transform 0.15s ease-out;
    }

    /* Borlas y detalles del farol */
    .lantern-top::after {
        content: '';
        position: absolute;
        bottom: -14px;
        left: 14px;
        width: 4px;
        height: 14px;
        background: #f59e0b;
        border-radius: 2px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    }
    
    .lantern-top::before {
        content: '';
        position: absolute;
        top: -6px;
        left: 14px;
        width: 4px;
        height: 6px;
        background: #f59e0b;
        border-radius: 2px;
    }

    /* Monedas de Bronce Imperiales en la base que giran con scroll */
    .coin-bottom {
        display: flex;
        position: absolute;
        bottom: -18px;
        left: -11px;
        width: 36px;
        height: 36px;
        background: radial-gradient(circle at 35% 35%, #ffe082, #f59e0b 60%, #b45309);
        border: 2px solid #fffbcf;
        border-radius: 50%;
        box-shadow: 
            0 4px 12px rgba(0, 0, 0, 0.45),
            0 0 10px rgba(245, 158, 11, 0.3);
        pointer-events: auto;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        transition: transform 0.12s ease-out;
    }

    /* Agujero cuadrado tradicional en el centro de la moneda china */
    .coin-bottom::after {
        content: '';
        width: 10px;
        height: 10px;
        background: #0f172a;
        border: 1px solid #92400e;
        transform: rotate(45deg);
    }

    html[data-theme="light"] .coin-bottom::after {
        background: #ffffff;
    }
}

/* ============================================================================
   4. APP FOOTER
   ============================================================================ */
.app-footer {
    width: 100%;
    background: var(--bg-panel, rgba(15, 23, 42, 0.4));
    border-top: 1px solid var(--color-border);
    padding: 12px 24px;
    box-sizing: border-box;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.footer-content {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.dev-signature {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-logo {
    width: 36px;
    height: 36px;
    min-width: 36px;
    max-width: 36px;
    max-height: 36px;
    object-fit: contain;
    border-radius: var(--radius-sm, 6px);
    border: 1px solid var(--color-border);
    background: #ffffff;
    padding: 2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.signature-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.35;
}

.signature-text p {
    margin: 0;
}

.signature-text a {
    color: var(--color-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.signature-text a:hover {
    color: var(--color-accent);
}

/* Animaciones de Farol Swing */
@keyframes swinging-lantern {
    0% { transform: rotate(-6deg); }
    100% { transform: rotate(6deg); }
}

@keyframes swinging-lantern-fast {
    0% { transform: rotate(-18deg); }
    100% { transform: rotate(18deg); }
}

