/* Тёмная «изумрудная» тема: фон, стекло, неон, курсор, анимации. */

:root {
    /* Шкала emerald */
    --em-50: #ecfdf5;
    --em-100: #d1fae5;
    --em-200: #a7f3d0;
    --em-300: #6ee7b7;
    --em-400: #34d399;
    --em-500: #10b981;
    --em-600: #059669;
    --em-700: #047857;
    --em-800: #065f46;
    --em-900: #064e3b;
    --em-950: #022c22;

    --bg: #000;
    --fg: var(--em-50);

    --glass-bg: rgba(4, 44, 34, 0.4);
    --glass-border: rgba(16, 185, 129, 0.2);

    --ease-out-soft: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Чёрный держим только на html: он уходит в фон страницы и рисуется раньше
   всего. У body фон обязан быть прозрачным — фоны блоков в потоке рисуются
   ПОВЕРХ элементов с отрицательным z-index, и непрозрачный body наглухо
   перекрывал бы свечение под курсором. По той же причине не стоит вешать
   непрозрачный фон на обёртки контента. */
html {
    background: var(--bg);
}

html, body {
    color: var(--fg);
}

body {
    background: transparent;
}

/* ── Фон ─────────────────────────────────────────────────────── */

/* Холст с летающими «шариками». Рисуется JS в skyrez-fx.js: частицы
   двигаются хаотично, притягиваются к курсору (магнит) и оставляют след
   (кадры затухают в чёрный, а не стираются начисто). Лежит над свечением,
   но под контентом. */
.sky-balls {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* Радиальное свечение под курсором. Позицию двигает JS.
   Лежит под контентом (z-index -2), поэтому светится только сквозь
   полупрозрачные поверхности: любой непрозрачный фон выше его перекроет. */
.sky-glow {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    background: radial-gradient(600px circle at var(--mx, 50%) var(--my, 50%),
                                rgba(16, 185, 129, 0.13),
                                rgba(6, 78, 59, 0.05) 40%,
                                transparent 70%);
}

/* Плёночный шум поверх всего — убирает бандинг у градиентов. */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    opacity: 0.045;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    /* Без явного размера SVG без intrinsic-размеров растягивается на весь
       экран и зерно раздувается в разы. Тайлим 1:1 к viewBox — зерно ~1px.
       stitchTiles='stitch' убирает швы на стыках плиток. */
    background-size: 200px 200px;
    background-repeat: repeat;
}

/* ── Кастомный курсор ────────────────────────────────────────── */

@media (pointer: fine) {
    html.custom-cursor-active,
    html.custom-cursor-active *,
    html.custom-cursor-active ::before,
    html.custom-cursor-active ::after {
        cursor: none !important;
    }
}

.cursor-dot,
.cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10000;
    pointer-events: none;
    border-radius: 999px;
    opacity: 0;
    will-change: transform;
    transition: opacity 0.25s ease;
}

.cursor-dot {
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    background: var(--em-300);
    box-shadow: 0 0 10px rgba(52, 211, 153, 0.9);
}

.cursor-ring {
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    border: 1px solid rgba(16, 185, 129, 0.55);
    box-shadow: 0 0 18px rgba(16, 185, 129, 0.25), inset 0 0 12px rgba(16, 185, 129, 0.12);
    transition: opacity 0.25s ease, width 0.2s var(--ease-out-soft), height 0.2s var(--ease-out-soft),
                margin 0.2s var(--ease-out-soft), background 0.2s ease, border-color 0.2s ease;
}

.cursor-visible .cursor-dot,
.cursor-visible .cursor-ring { opacity: 1; }

/* Наведение на интерактивный элемент — кольцо раздувается. */
.cursor-hover .cursor-ring {
    width: 56px;
    height: 56px;
    margin: -28px 0 0 -28px;
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(52, 211, 153, 0.8);
}

.cursor-down .cursor-ring {
    width: 26px;
    height: 26px;
    margin: -13px 0 0 -13px;
}

/* ── Стекло и неон ───────────────────────────────────────────── */

.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.neon-tube {
    display: inline-block;
    color: #edfff7;
    text-shadow:
        0 0 2px #fff,
        0 0 6px #fff,
        0 0 14px var(--em-200),
        0 0 28px var(--em-400),
        0 0 55px var(--em-500),
        0 0 100px rgba(16, 185, 129, 0.35);
}

/* Одна «перегоревшая» буква/слово в неоновой вывеске. */
.neon-burnout {
    animation: tubeFlicker 3.2s steps(1) 1.6s infinite;
}

@keyframes tubeFlicker {
    0%, 5%, 7%, 18%, 20%, 30%, 32%, 50%, 52%, 65%, 67%, 80%, 83%, 100% {
        color: #edfff7;
        text-shadow: 0 0 2px #fff, 0 0 6px #fff, 0 0 14px var(--em-200),
                     0 0 28px var(--em-400), 0 0 55px var(--em-500),
                     0 0 100px rgba(16, 185, 129, 0.35);
    }
    6%, 19%, 31%, 51%, 66%, 81%, 82% {
        color: #0d2017;
        text-shadow: none;
    }
    33%, 34%, 35%, 36% {
        color: #7ecfa8;
        text-shadow: 0 0 3px var(--em-400), 0 0 10px rgba(52, 211, 153, 0.4);
    }
}

/* ── Анимации появления ──────────────────────────────────────── */

@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: none; }
}

.fx-in {
    animation: fade-in-up 0.6s var(--ease-out-soft) both;
}

/* Каскад для списков/сеток: .fx-stagger > * получают нарастающую задержку. */
.fx-stagger > * { animation: fade-in-up 0.6s var(--ease-out-soft) both; }
.fx-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.fx-stagger > *:nth-child(2) { animation-delay: 0.10s; }
.fx-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.fx-stagger > *:nth-child(4) { animation-delay: 0.20s; }
.fx-stagger > *:nth-child(5) { animation-delay: 0.25s; }
.fx-stagger > *:nth-child(6) { animation-delay: 0.30s; }
.fx-stagger > *:nth-child(n+7) { animation-delay: 0.35s; }

/* ── MudBlazor поверх тёмного фона ───────────────────────────── */

/* Тени elevation задаются в SkyrezTheme.Shadows (C#): MudThemeProvider
   инжектит свои переменные в рантайме и перебил бы правку отсюда. */

.mud-appbar,
.mud-drawer {
    background: var(--glass-bg) !important;
    border-color: var(--glass-border) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.mud-drawer { border-right: 1px solid var(--glass-border); }
.mud-appbar { border-bottom: 1px solid var(--glass-border); }

.mud-paper:not(.mud-alert):not(.mud-menu-popover) {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.mud-nav-link.active:not(.mud-nav-link-disabled) {
    border-right: 2px solid var(--em-400);
    background: rgba(16, 185, 129, 0.1) !important;
}

.mud-button-root {
    transition: transform 0.2s var(--ease-out-soft), box-shadow 0.2s var(--ease-out-soft);
}

.mud-button-filled.mud-button-filled-primary {
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.35);
}

.mud-button-root:hover {
    transform: translateY(-1px);
}

/* ── Поля ввода ──────────────────────────────────────────────── */

/* Автозаполнение Chrome красит поле жёлтой подложкой, которая не вписывается
   в тёмную тему. Полностью убираем её: трюк с «бесконечным» transition не даёт
   браузеру закрасить фон, а text-fill/caret возвращают наш цвет текста. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--fg);
    caret-color: var(--fg);
    transition: background-color 100000s ease-in-out 0s;
}

/* На статических SSR-страницах (вход/регистрация) MudBlazor не навешивает
   класс shrink, поэтому после потери фокуса лейбл с заполненного поля падал
   ПОВЕРХ введённого текста. Ловим «в поле есть текст» через placeholder-трюк
   (полям проставлен placeholder=" ") и всплываем лейбл + раскрываем вырез в
   рамке — теми же значениями, что MudBlazor использует для :focus-within. */
.mud-input.mud-input-outlined:has(input[placeholder]:not(:placeholder-shown)) > .mud-input-outlined-border legend {
    width: auto;
    padding: 0 5px;
}
.mud-input.mud-input-outlined:has(input[placeholder]:not(:placeholder-shown)) ~ label.mud-input-label-inputcontrol.mud-input-label-outlined {
    transform: translate(14px, -6px) scale(0.75);
    max-width: calc(133.333% - 18.6667px);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #04120c; }
::-webkit-scrollbar-thumb { background: var(--em-800); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--em-600); }

/* ── Доступность ─────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .neon-burnout, .fx-in, .fx-stagger > * {
        animation: none;
    }
    .mud-button-root:hover { transform: none; }
}
