/* ============================================
   КИМЧИ ХАНГУГО — ДИЗАЙН-СИСТЕМА
   Стиль: Soft Brutalist
   Палитра: Чёрный + Золотой
   ============================================ */

/* === CSS ПЕРЕМЕННЫЕ === */
:root {
    /* Цвета */
    --bg: #0D0D0D;
    --bg-card: #151515;
    --bg-card-hover: #1a1a1a;
    --bg-elevated: #1C1C1E;

    --accent: #FFD700;
    --accent2: #FFA500;
    --accent-dim: rgba(255, 215, 0, 0.15);
    --accent-border: rgba(255, 215, 0, 0.3);

    --text: #FFFFFF;
    --text-secondary: #999999;
    --text-muted: #555555;

    --border: #222222;
    --border-light: #2a2a2a;

    --success: #4CAF50;
    --error: #FF4444;
    --info: #3478F6;

    /* Типографика */
    --font: 'Space Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-size-xs: 10px;
    --font-size-sm: 12px;
    --font-size-base: 14px;
    --font-size-md: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 22px;
    --font-size-xxl: 28px;

    /* Размеры */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;

    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 20px;
    --spacing-xxl: 28px;

    /* Safe areas */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    /* Tab bar */
    --tab-bar-height: 56px;

    /* Android navigation bar compensation (set via JS) */
    --nav-bar-offset: 0px;
}


/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    background-color: var(--bg);
    font-family: var(--font);
    font-size: var(--font-size-base);
    color: var(--text);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
}

/* Подключаем Space Grotesk через Google Fonts в base.html,
   NetflixSans оставляем как фоллбэк если уже скачан */
@font-face {
    font-family: 'NetflixSans-Regular';
    src: url('../fonts/NetflixSans-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}


/* === ТИПОГРАФИКА === */
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-md { font-size: var(--font-size-md); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-xxl { font-size: var(--font-size-xxl); }

.text-accent { color: var(--accent); }
.text-muted { color: var(--text-secondary); }
.text-dim { color: var(--text-muted); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }

.uppercase {
    text-transform: uppercase;
    letter-spacing: 1px;
}

.label {
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
}


/* === DESKTOP ОГРАНИЧЕНИЕ === */
/* Перенесено в desktop.css */


/* === СТРАНИЦА-ОБЁРТКА === */
/* Основной контент страницы — с учётом safe areas и tab bar */
.page-content {
    padding-top: calc(var(--spacing-lg) + var(--safe-top));
    padding-bottom: calc(var(--tab-bar-height) + var(--safe-bottom) + var(--nav-bar-offset) + var(--spacing-lg));
    padding-left: var(--spacing-lg);
    padding-right: var(--spacing-lg);
    min-height: 100vh;
}

/* Для страниц без tab bar (уроки, игры) */
.page-content--no-tab {
    padding-bottom: calc(var(--safe-bottom) + var(--nav-bar-offset) + var(--spacing-lg));
}


/* === КНОПКИ === */

/* Primary — золотой фон */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px 20px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: var(--font-size-base);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: opacity 0.1s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:active {
    opacity: 0.85;
    transform: scale(0.98);
}

/* Secondary — прозрачный с рамкой */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 20px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: opacity 0.1s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.btn-secondary:active {
    opacity: 0.7;
    transform: scale(0.98);
}

/* Ghost — минимальная, для ссылок */
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: none;
    color: var(--text-secondary);
    border: none;
    font-family: var(--font);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}


/* === КАРТОЧКИ === */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    transition: background 0.15s;
}

.card:active {
    background: var(--bg-card-hover);
}

/* Карточка с золотым акцентом слева */
.card--accent {
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* Карточка с золотой рамкой (для премиума) */
.card--gold {
    border: 1.5px solid var(--accent-border);
    border-radius: var(--radius);
}


/* === ЧИПЫ (маленькие кнопки) === */

.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: #ccc;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: opacity 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.chip:active {
    opacity: 0.7;
}


/* === TAB BAR === */

.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: #2C2C2E;
    border-top: 2px solid var(--accent);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-top: 8px;
    padding-bottom: calc(8px + var(--safe-bottom) + var(--nav-bar-offset));
    z-index: 5000;
    -webkit-tap-highlight-color: transparent;
}

/* Desktop ограничение для tab bar — см. desktop.css */

.tab-bar__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.tab-bar__icon {
    font-size: 20px;
    opacity: 0.3;
    transition: opacity 0.15s;
}

.tab-bar__icon-img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    opacity: 0.4;
    transition: opacity 0.15s;
}

.tab-bar__label {
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    transition: color 0.15s;
}

.tab-bar__item--active .tab-bar__icon {
    opacity: 1;
}

.tab-bar__item--active .tab-bar__icon-img {
    opacity: 1;
}

.tab-bar__item--active .tab-bar__label {
    color: var(--accent);
}

/* Скрываем tab bar на страницах уроков */
.hide-tab-bar .tab-bar {
    display: none;
}


/* === TABS (внутри страницы, как переключатели) === */

.tabs {
    display: flex;
    gap: 0;
    margin-bottom: var(--spacing-lg);
    border-bottom: 2px solid var(--border);
}

.tabs__item {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.tabs__item--active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}


/* === МОДАЛКИ === */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-xl);
}

.modal-overlay--visible {
    display: flex;
}

.modal-content {
    background: var(--bg-elevated);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 360px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}

.modal-title {
    font-size: var(--font-size-md);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--spacing-sm);
}

.modal-text {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--spacing-lg);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    background: var(--border-light);
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.modal-close:active {
    opacity: 0.7;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}


/* === LOADER / SPINNER === */

#loader {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    animation: spin 0.8s linear infinite;
}

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

/* Полноэкранный лоадер при загрузке страницы */
.page-loader {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* === FADE OVERLAY (переходы между страницами) === */

#fadeOverlay {
    position: fixed;
    inset: 0;
    background-color: var(--bg);
    opacity: 0;
    z-index: 10000;
    transition: opacity 0.4s ease;
    pointer-events: none;
}


/* === FLOATING CONTROLS (для страниц уроков, где нет tab bar) === */

.floating-controls {
    position: fixed;
    bottom: calc(20px + var(--safe-bottom) + var(--nav-bar-offset));
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2000;
}

.float-btn {
    width: 52px;
    height: 52px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s;
    padding: 0;
    outline: none;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    -webkit-tap-highlight-color: transparent;
}

.float-btn:active {
    transform: scale(0.93);
    opacity: 0.8;
}

.float-btn img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.btn-home {
    background-image: url('../images/home.png');
    background-size: 55%;
    background-repeat: no-repeat;
    background-position: center;
    background-color: rgba(255, 255, 255, 0.9);
}

.btn-back {
    background-image: url('../images/backarrow.png');
    background-size: 55%;
    background-repeat: no-repeat;
    background-position: center;
    background-color: rgba(255, 255, 255, 0.9);
}


/* === SECTION TITLES === */

.section-title {
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: var(--spacing-md);
}

.page-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--spacing-lg);
}


/* === PREMIUM BANNER === */

.premium-banner {
    display: flex;
    align-items: center;
    background: var(--accent);
    color: #000;
    padding: 14px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 700;
    font-size: var(--font-size-base);
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: opacity 0.1s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
}

.premium-banner:active {
    opacity: 0.9;
    transform: scale(0.99);
}

.premium-banner__icon {
    font-size: 22px;
    margin-right: 10px;
}

.premium-banner__text {
    flex: 1;
}

.premium-banner__arrow {
    margin-left: auto;
    font-size: 18px;
}

/* Shine анимация */
.premium-banner::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 50%;
    height: 200%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: skewX(-25deg);
    animation: shine 4s infinite;
    animation-delay: 1.5s;
}

@keyframes shine {
    from { left: -75%; }
    to { left: 125%; }
}


/* === XP BAR === */

.xp-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
}

.xp-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 3px;
    transition: width 0.5s ease;
}


/* === STAT BOX === */

.stat-box {
    background: var(--bg-card);
    padding: var(--spacing-lg);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.stat-box__value {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--accent);
}

.stat-box__label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 2px;
    font-weight: 600;
}


/* === WEEKLY CHART (Dark Flat стиль для Dashboard) === */

.weekly-chart {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: 14px;
}

.weekly-chart__today {
    text-align: center;
    flex: 0 0 80px;
}

.weekly-chart__time {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--accent);
}

.weekly-chart__label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.weekly-chart__bars {
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 50px;
}

.weekly-chart__bar {
    flex: 1;
    background: var(--accent);
    min-height: 4px;
    border-radius: 3px 3px 0 0;
    transition: height 0.5s ease-out;
}

.weekly-chart__bar--prev {
    background: var(--info);
}

.weekly-chart__days {
    flex: 1;
    display: flex;
    justify-content: space-around;
    padding-top: 4px;
}

.weekly-chart__day {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    font-weight: 600;
}


/* === USER ENTRY (рейтинг) === */

.user-entry {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    padding: 12px var(--spacing-lg);
    margin-bottom: 2px;
    border-left: 3px solid transparent;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    gap: var(--spacing-md);
}

.user-entry--current {
    border-left-color: var(--accent);
    background: var(--bg-card-hover);
}


/* === УТИЛИТЫ === */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.gap-xs { gap: var(--spacing-xs); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.hidden { display: none !important; }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
