/* ============================================================================
   Design tokens — themed. Light is the default; [data-theme="dark"] overrides.
   Legacy --c-* names are kept as aliases so every existing page adopts the new
   system without per-file edits. Prefer the new names in new code.
   ============================================================================ */
:root {
    /* ── Brand accent (purple) ── */
    --accent:       #7247BD;
    --accent-2:     #8C48FA;
    --accent-deep:  #5d3a9e;
    --accent-grad:  linear-gradient(135deg, #7247BD, #8C48FA);
    --accent-soft:  rgba(114, 71, 189, .10);
    --accent-glow:  rgba(114, 71, 189, .26);
    --on-accent:    #ffffff;

    /* ── Surfaces (light) ── */
    --bg:        #f4f6fb;
    --bg-2:      #ffffff;
    --surface:   #ffffff;
    --surface-2: #eef1f8;
    --border:    rgba(17, 24, 39, .08);
    --border-2:  rgba(17, 24, 39, .14);

    /* ── Text ── */
    --text:  #131826;
    --dim:   #5b6477;
    --faint: #98a2b5;

    /* ── Semantic ── */
    --success: #16a34a;
    --danger:  #dc2626;
    --warning: #d97706;
    --info:    #2563eb;

    /* ── Status (knowledge / quiz / review) ── */
    --st-ok:     #16a34a;
    --st-review: #d97706;
    --st-gap:    #e11d48;

    /* ── Feedback surfaces (bg / border / text) — themed pairs for callouts,
       toasts, pills, quiz feedback, etc. Use these instead of hardcoded pastels. */
    --success-bg: #f0fdf4; --success-bd: #bbf7d0; --success-fg: #166534;
    --danger-bg:  #fef2f2; --danger-bd:  #fca5a5; --danger-fg:  #991b1b;
    --warning-bg: #fffbeb; --warning-bd: #fde68a; --warning-fg: #92400e;
    --info-bg:    #eff6ff; --info-bd:    #bfdbfe; --info-fg:    #1e40af;
    --neutral-bg: #f1f5f9; --neutral-bd: #e2e8f0; --neutral-fg: #475569;

    /* ── Radii ── */
    --radius-sm: 10px;
    --radius:    14px;
    --radius-lg: 18px;
    --radius-xl: 22px;

    /* ── Elevation ── */
    --shadow-sm: 0 1px 2px rgba(17, 24, 39, .06), 0 1px 3px rgba(17, 24, 39, .04);
    --shadow:    0 6px 18px rgba(28, 40, 80, .06);
    --shadow-lg: 0 24px 60px rgba(28, 40, 80, .14);

    /* ── Type & motion ── */
    --font: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --ease: cubic-bezier(.16, 1, .3, 1);
    --dur:  .2s;

    /* ── Back-compat aliases (legacy --c-* → new tokens) ── */
    --c-primary:   var(--accent);
    --c-primary-h: var(--accent-deep);
    --c-success:   var(--success);
    --c-danger:    var(--danger);
    --c-warning:   var(--warning);
    --c-text:      var(--text);
    --c-muted:     var(--dim);
    --c-border:    var(--border);
    --c-bg:        var(--bg);
    --c-card:      var(--surface);
}

[data-theme="dark"] {
    --bg:        #0a1020;
    --bg-2:      #0c1426;
    --surface:   #121c32;
    --surface-2: #1b2742;
    --border:    rgba(255, 255, 255, .07);
    --border-2:  rgba(255, 255, 255, .14);

    --text:  #eef2fb;
    --dim:   #9aa7c2;
    --faint: #5f6e8e;

    --accent-soft: rgba(140, 72, 250, .16);
    --accent-glow: rgba(140, 72, 250, .34);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow:    0 14px 36px rgba(0, 0, 0, .4);
    --shadow-lg: 0 30px 70px rgba(0, 0, 0, .45);

    /* Feedback surfaces — translucent tints + lighter text for dark bg */
    --success-bg: rgba(52, 211, 153, .12); --success-bd: rgba(52, 211, 153, .30); --success-fg: #6ee7b7;
    --danger-bg:  rgba(251, 113, 133, .12); --danger-bd:  rgba(251, 113, 133, .32); --danger-fg:  #fda4af;
    --warning-bg: rgba(251, 191, 36, .12);  --warning-bd: rgba(251, 191, 36, .30);  --warning-fg: #fcd34d;
    --info-bg:    rgba(96, 165, 250, .12);  --info-bd:    rgba(96, 165, 250, .30);  --info-fg:    #93c5fd;
    --neutral-bg: var(--surface-2);          --neutral-bd: var(--border-2);          --neutral-fg: var(--dim);
}

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

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

/* ── Nav ── */
.nav {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
    height: 56px;
    background: var(--c-card);
    border-bottom: 1px solid var(--c-border);
    box-shadow: var(--shadow);
}
.nav__logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--c-primary);
    text-decoration: none;
    flex-shrink: 0;
}
.nav__links { display: flex; gap: 16px; flex: 1; }
.nav__links a {
    color: var(--c-muted);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
}
.nav__links a:hover { color: var(--c-text); }
.nav__user { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.nav__user span { font-size: .9rem; color: var(--c-muted); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform .12s var(--ease), box-shadow var(--dur) var(--ease),
                background var(--dur) var(--ease), border-color var(--dur) var(--ease), opacity .15s;
    text-decoration: none;
    line-height: 1.1;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--primary  {
    background: var(--accent-grad);
    color: var(--on-accent);
    /* верхний внутренний блик даёт кнопке объём, не меняя геометрию */
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .20), 0 8px 20px var(--accent-glow);
}
.btn--primary:hover:not(:disabled) { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 12px 28px var(--accent-glow); transform: translateY(-1px); }
.btn--primary:active:not(:disabled) { transform: translateY(0); }
.btn--ghost    { background: var(--surface); color: var(--dim); border-color: var(--border-2); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); border-color: var(--accent); }
.btn--danger   { background: var(--danger); color: #fff; }
.btn--full     { width: 100%; }

/* ── Progress bar ──
   Единый «mastery-meter» по всей платформе: мягкая подложка + градиентная
   заливка с бегущим бликом. Та же ДНК, что у прогресса в тренажёре. */
.progress-bar {
    position: relative;
    height: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
}
.progress-bar__fill {
    position: relative;
    height: 100%;
    background: var(--accent-grad);
    border-radius: 999px;
    transition: width .4s var(--ease);
}
.progress-bar__fill::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(100deg, transparent 28%, rgba(255, 255, 255, .45) 50%, transparent 72%);
    background-size: 220% 100%;
    animation: barSheen 2.6s var(--ease) infinite;
}
@keyframes barSheen { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
}
/* Карточка-ссылка приподнимается — общий жест кликабельности для всей платформы.
   Статичные .card (контейнеры) не затрагиваются: правило висит только на <a>. */
a.card {
    text-decoration: none;
    color: inherit;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
                border-color var(--dur) var(--ease);
}
a.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-glow);
}

/* ── Empty state ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 64px 24px;
    text-align: center;
}
.empty-state__icon  { color: var(--c-border); font-size: 2.5rem; line-height: 1; }
.empty-state__title { font-size: 1.15rem; font-weight: 600; color: var(--c-text); }
.empty-state__text  { font-size: .9rem; color: var(--c-muted); max-width: 360px; }

/* ── Auth ── */
.auth-wrap {
    min-height: calc(100vh - 56px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 40px 36px;
}
.auth-card__title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 28px;
    text-align: center;
}
.auth-card__reset {
    display: block;
    text-align: center;
    margin-top: 16px;
    font-size: .85rem;
    color: var(--c-muted);
}

/* ── Demo login panel (APP_DEMO only) ── */
.demo-panel {
    max-width: 400px;
    margin: 16px auto 0;
    background: var(--warning-bg);
    border: 1px solid var(--warning-bd);
    border-radius: var(--radius);
    padding: 16px;
}
.demo-panel__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--warning-fg);
    margin-bottom: 12px;
}
.demo-panel__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.demo-panel__btn {
    background: var(--surface);
    border: 1px solid var(--warning-bd);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: pointer;
    text-align: left;
    transition: background .15s;
}
.demo-panel__btn:hover { background: var(--warning-bg); }
.demo-panel__btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.demo-panel__role { display: block; font-size: .8rem; font-weight: 600; color: var(--warning-fg); }
.demo-panel__cred { display: block; font-size: .75rem; color: var(--warning-fg); margin-top: 2px; }

/* ── Form fields ── */
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: .85rem; font-weight: 600; color: var(--c-muted); }
.field__input {
    padding: 11px 13px;
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field__input::placeholder { color: var(--faint); }
.field__input:focus,
.field__input:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.auth-form__error {
    padding: 10px 12px;
    background: var(--danger-bg);
    border: 1px solid var(--danger-bd);
    border-radius: var(--radius-sm);
    color: var(--danger-fg);
    font-size: .9rem;
}

/* ── Loading ── */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
    color: var(--c-muted);
}
.loading__spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--c-border);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
.toast-wrap {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
}
.toast {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    animation: slideIn .2s ease;
    max-width: 320px;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } }
.toast--success { background: var(--success-bg); color: var(--success-fg); border: 1px solid var(--success-bd); }
.toast--error   { background: var(--danger-bg); color: var(--danger-fg); border: 1px solid var(--danger-bd); }
.toast--info    { background: var(--info-bg); color: var(--info-fg); border: 1px solid var(--info-bd); }

/* ── Page container ── */
.page { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.page__title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 24px; }

/* ── Responsive ── */
@media (max-width: 480px) {
    .nav { padding: 0 16px; gap: 12px; }
    .auth-card { padding: 28px 20px; }
    .page { padding: 24px 16px; }
}

/* ── Reduced motion ──
   Standard a11y reset for users who request less motion. !important is the
   sanctioned exception here: it must override per-component transition/animation
   durations across the cascade. The loading spinner is re-enabled because its
   rotation conveys "in progress" — essential, not decorative. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
    .loading__spinner {
        animation-duration: .7s !important;
        animation-iteration-count: infinite !important;
    }
}
