/**
 * RSite — Base Design System  v3.2
 * Depends on: (none — this is foundation)
 *
 * Single source of truth: CSS variables, reset, typography, layout primitives.
 * Dark glassmorphism foundation with gold accent color.
 * All other styles inherit variables, never redefine them.
 */

/* 
   1. CSS RESET & VARIABLES
*/

/* ── Mi Sans Font ── */
@font-face {
    font-family: 'Mi Sans';
    src: url('/static/fonts/MiSans-Regular.woff2') format('woff2'),
        url('/static/fonts/MiSans-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

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

:root {
    /* ── Palette ── */
    --bg-dark: #090909;
    --bg-surface: #0f0f0f;
    --bg-gradient: linear-gradient(145deg, #090909 0%, #111111 40%, #0b0b0b 100%);

    /* Glass */
    --glass-bg: rgba(0, 0, 0, 0.6);
    --glass-bg-strong: rgba(0, 0, 0, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(255, 255, 255, 0.15);
    --glass-blur: 10px;

    /* Gold */
    --gold-accent: #d4af37;
    --gold-light: #f4d47c;
    --gold-dark: #a88a2a;
    --gold-glow: rgba(212, 175, 55, 0.25);
    --gold-subtle: rgba(212, 175, 55, 0.08);

    /* Text */
    --text-primary: #c1b798;
    --text-secondary: #8888a0;
    --text-muted: #5a5a72;

    /* Accent palette */
    --success: #35d07a;
    --success-bg: rgba(53, 208, 122, 0.1);
    --error: #e85454;
    --error-bg: rgba(232, 84, 84, 0.1);

    /* ── Typography ── */
    --font-heading: 'Cinzel', 'Noto Serif SC', serif;
    --font-body: 'Mi Sans', 'Crimson Pro', 'Noto Serif SC', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-size-base: 17px;
    --line-height-base: 1.7;

    /* ── Spacing scale ── */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 40px;
    --space-2xl: 64px;

    /* ── Radius ── */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    /* ── Shadows ── */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px var(--gold-glow);

    /* ── Transitions ── */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 0.15s;
    --duration-normal: 0.3s;
    --duration-slow: 0.5s;
}

/* 
   2. BASE ELEMENTS
*/

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    background: var(--bg-dark);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    padding-bottom: 250px;
    /* Space for fixed audio player */
}

a {
    color: var(--gold-accent);
    text-decoration: none;
    transition: all var(--duration-fast) var(--ease-out);
}

a:hover {
    color: var(--gold-light);
}

::selection {
    background: rgba(212, 175, 55, 0.3);
    color: var(--text-primary);
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 
   3. TYPOGRAPHY
*/

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
}

h1 {
    font-size: 3.2em;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gold-accent), var(--gold-light), var(--gold-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 4s ease-in-out infinite;
}

h2 {
    font-size: 1.8em;
    color: var(--gold-accent);
}

h3 {
    font-size: 1.4em;
}

p {
    margin-bottom: var(--space-md);
    color: var(--text-secondary);
    line-height: var(--line-height-base);
}

p:last-child {
    margin-bottom: 0;
}

strong {
    color: var(--gold-accent);
    font-weight: 600;
}

code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: rgba(0, 0, 0, 0.35);
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    color: var(--gold-light);
}

pre {
    background: rgba(0, 0, 0, 0.35);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: var(--space-lg) 0;
    border: 1px solid var(--glass-border);
}

pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
}

/* 
   4. LAYOUT
*/

.container {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
}

.hidden {
    display: none !important;
}

/* Page header */
header,
.page-header {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    margin-bottom: var(--space-xl);
}

.page-header h1 {
    margin-bottom: var(--space-md);
}

.subtitle {
    font-size: 1.15em;
    color: var(--text-secondary);
    font-weight: 300;
    letter-spacing: 4px;
    text-transform: uppercase;
}

/* 
   5. GLASSMORPHISM CARD
*/

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) brightness(110%) contrast(90%) saturate(75%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) brightness(110%) contrast(90%) saturate(75%);
    border: 0.5px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3),
        inset 0 0 4px rgba(255, 255, 255, 0.03);
    transition: border-color var(--duration-normal) ease,
        box-shadow var(--duration-normal) ease;
}

.glass-card-strong {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(var(--glass-blur)) brightness(110%) contrast(90%) saturate(75%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) brightness(110%) contrast(90%) saturate(75%);
    border: 0.5px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3),
        inset 0 0 4px rgba(255, 255, 255, 0.03);
}

/* 
   5.5 MATTE PLASTIC (Thin Frosted Glass Utility)
*/

.matte-plastic {
    --plastic-bg: rgba(0, 0, 0, 0.78);
    --plastic-border: rgba(255, 255, 255, 0.1);
    --plastic-bg-hover: rgba(5, 5, 5, 0.85);
    --plastic-border-hover: rgba(212, 175, 55, 0.35);
    --plastic-blur: 7px;
    --plastic-brightness: 115%;
    --plastic-contrast: 85%;
    --plastic-saturate: 70%;

    background: var(--plastic-bg);
    backdrop-filter: blur(var(--plastic-blur)) brightness(var(--plastic-brightness)) contrast(var(--plastic-contrast)) saturate(var(--plastic-saturate));
    -webkit-backdrop-filter: blur(var(--plastic-blur)) brightness(var(--plastic-brightness)) contrast(var(--plastic-contrast)) saturate(var(--plastic-saturate));
    border: 0.5px solid var(--plastic-border);
    box-shadow:
        var(--shadow-md),
        inset 0 0 4px rgba(255, 255, 255, 0.05);
    transition: all var(--duration-normal) var(--ease-out);
}

.matte-plastic:hover {
    border-color: var(--plastic-border-hover);
}

/* 
   5.6 SELECT / DROPDOWN (Global styles)
*/

select.matte-plastic-select,
.matte-plastic-select select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--plastic-bg);
    backdrop-filter: blur(var(--plastic-blur)) brightness(var(--plastic-brightness)) contrast(var(--plastic-contrast)) saturate(var(--plastic-saturate));
    -webkit-backdrop-filter: blur(var(--plastic-blur)) brightness(var(--plastic-brightness)) contrast(var(--plastic-contrast)) saturate(var(--plastic-saturate));
    border: 0.5px solid var(--plastic-border);
    border-radius: var(--radius-md);
    box-shadow:
        var(--shadow-md),
        inset 0 0 4px rgba(255, 255, 255, 0.05);
    padding: var(--space-sm) var(--space-lg);
    color: var(--gold-accent);
    font-family: var(--font-heading);
    font-size: 0.95em;
    letter-spacing: 0.02em;
    text-align: center;
    text-align-last: center;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

select.matte-plastic-select:hover,
.matte-plastic-select select:hover {
    background: var(--plastic-bg-hover);
    border-color: var(--plastic-border-hover);
    backdrop-filter: blur(3px) contrast(95%);
    -webkit-backdrop-filter: blur(3px) contrast(95%);
}

select.matte-plastic-select:focus,
.matte-plastic-select select:focus {
    outline: none;
    border-color: var(--plastic-border-hover);
    box-shadow:
        0 0 0 2px rgba(212, 175, 55, 0.08),
        var(--shadow-md);
}

select.matte-plastic-select option,
.matte-plastic-select select option {
    background: var(--bg-surface);
    color: var(--text-primary);
    padding: var(--space-sm) var(--space-md);
}

/* 
   5.7 CUSTOM DROPDOWN (matte plastic style)
*/

.custom-dropdown {
    position: relative;
    width: 100%;
}

.custom-dropdown-trigger {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(212, 175, 55, 0.2);
    backdrop-filter: blur(var(--plastic-blur-light));
    -webkit-backdrop-filter: blur(var(--plastic-blur-light));
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-lg);
    color: var(--gold-accent);
    font-family: var(--font-heading);
    font-size: 0.95em;
    letter-spacing: 0.02em;
    text-align: center;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.custom-dropdown-trigger:hover {
    background: rgba(0, 0, 0, 0.6);
    border-color: rgba(212, 175, 55, 0.3);
}

.custom-dropdown-trigger.active {
    border-color: rgba(212, 175, 55, 0.35);
}

.custom-dropdown-trigger svg {
    flex-shrink: 0;
    transition: transform var(--duration-fast) var(--ease-out);
}

.custom-dropdown-trigger.active svg {
    transform: rotate(180deg);
}

/* Выпадающее меню */
.custom-dropdown-menu {
    position: fixed;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(7px) brightness(115%) contrast(85%) saturate(70%);
    -webkit-backdrop-filter: blur(7px) brightness(115%) contrast(85%) saturate(70%);
    border: 0.5px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        inset 0 0 4px rgba(255, 255, 255, 0.05);
    max-height: 580px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--duration-fast) var(--ease-out);
    z-index: 9999;
}

.custom-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Скроллбар для меню */
.custom-dropdown-menu {
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.25) transparent;
}

.custom-dropdown-menu::-webkit-scrollbar {
    width: 4px;
}

.custom-dropdown-menu::-webkit-scrollbar-button {
    display: none;
}

.custom-dropdown-menu::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px 0;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.25);
    border-radius: 2px;
    border: 8px solid transparent;
    background-clip: content-box;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, 0.4);
    background-clip: content-box;
}

/* Опции меню */
.custom-dropdown-item {
    padding: var(--space-sm) var(--space-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    text-align: center;
}

.custom-dropdown-item:last-child {
    border-bottom: none;
}

.custom-dropdown-item:hover {
    background: rgba(212, 175, 55, 0.1);
    color: var(--gold-accent);
}

.custom-dropdown-item.selected {
    background: rgba(212, 175, 55, 0.15);
    color: var(--gold-accent);
    font-weight: 500;
}

.dropdown-selected-mark {
    color: var(--gold-accent);
    font-size: 2em;
    margin: 0 4px;
    line-height: 0;
    animation: mark-pulse 2s ease-in-out infinite;
}

@keyframes mark-pulse {
    0%, 100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
        text-shadow: 0 0 6px rgba(212, 175, 55, 0.4);
    }
}

/* Lightweight variant for dropdowns inside plastic elements */
select.matte-plastic-select-light,
.matte-plastic-select-light select {
    --plastic-bg-light: rgba(0, 0, 0, 0.35);
    --plastic-border-light: rgba(212, 175, 55, 0.12);
    --plastic-blur-light: 4px;

    background: var(--plastic-bg-light);
    border: 1px solid var(--plastic-border-light);
    backdrop-filter: blur(var(--plastic-blur-light));
    -webkit-backdrop-filter: blur(var(--plastic-blur-light));
    border-radius: var(--radius-md);
    box-shadow: none;
}

select.matte-plastic-select-light:hover,
.matte-plastic-select-light select:hover {
    background: rgba(0, 0, 0, 0.45);
    border-color: rgba(212, 175, 55, 0.2);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/*
   5b. SORT BAR — reusable filter/sort controls
*/

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

.sort-btn {
    padding: 4px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.78em;
    cursor: pointer;
    transition: all var(--duration-fast) ease;
}

.sort-btn:hover {
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-secondary);
}

.sort-btn.active {
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.2);
    color: var(--gold-accent);
}

.sort-label {
    color: var(--text-muted);
    font-size: 0.82em;
}

/*
   6. NAVIGATION GRID (Index page cards)
*/

.nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-xl);
}

.nav-card {
    position: relative;
    padding: var(--space-xl) var(--space-lg);
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    transition: transform var(--duration-normal) var(--ease-spring),
        box-shadow var(--duration-normal) var(--ease-out),
        border-color var(--duration-normal) ease;
}

/* Sweep light effect */
.nav-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.06), transparent);
    transition: left 0.7s var(--ease-out);
}

.nav-card:hover::before {
    left: 100%;
}

.nav-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: rgba(212, 175, 55, 0.4);
}

.card-icon {
    font-size: 2.4em;
    margin-bottom: var(--space-md);
    display: block;
}

.card-title {
    font-family: var(--font-heading);
    font-size: 1.4em;
    font-weight: 600;
    color: var(--gold-accent);
    margin-bottom: var(--space-sm);
}

.card-description {
    color: var(--text-secondary);
    line-height: 1.65;
    font-size: 0.95em;
}

/* 
   7. ANIMATED BACKGROUND (Mist)
*/

.mist {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 10% 60%, rgba(212, 175, 55, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 35%, rgba(212, 175, 55, 0.02) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 90%, rgba(168, 138, 42, 0.02) 0%, transparent 40%);
    animation: mistMove 30s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes mistMove {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }

    33% {
        transform: translate(20px, -15px) scale(1.02);
        opacity: 0.8;
    }

    66% {
        transform: translate(-15px, 10px) scale(0.98);
        opacity: 0.9;
    }
}

/* 
   8. DECORATIVE RUNES — Gold with glow
*/

.runes {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.5em;
    pointer-events: none;
    z-index: 0;
    letter-spacing: 0.15em;
    color: var(--gold-accent);
}

.runes-left {
    left: 20px;
    writing-mode: vertical-rl;
}

.runes-right {
    right: 20px;
    writing-mode: vertical-rl;
}

/* Individual rune spans — staggered glow */
.runes span {
    display: inline;
    opacity: 0.06;
    animation: runeGlow 8s ease-in-out infinite;
}

/* Stagger: each rune gets a different delay */
.runes span:nth-child(5n+1) {
    animation-delay: 0s;
}

.runes span:nth-child(5n+2) {
    animation-delay: 1.6s;
}

.runes span:nth-child(5n+3) {
    animation-delay: 3.2s;
}

.runes span:nth-child(5n+4) {
    animation-delay: 4.8s;
}

.runes span:nth-child(5n+5) {
    animation-delay: 6.4s;
}

@keyframes runeGlow {

    0%,
    100% {
        opacity: 0.06;
        text-shadow: none;
    }

    15% {
        opacity: 0.2;
        text-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
    }

    30% {
        opacity: 0.35;
        text-shadow: 0 0 16px rgba(212, 175, 55, 0.5), 0 0 32px rgba(212, 175, 55, 0.15);
    }

    45% {
        opacity: 0.12;
        text-shadow: 0 0 4px rgba(212, 175, 55, 0.15);
    }
}

/* 
   9. KEYFRAMES
*/

@keyframes shimmer {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.15);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* 
   10. CUSTOM TOOLTIP — Matte Plastic
*/

.rs-tooltip {
    position: fixed;
    z-index: 99999;
    padding: 5px 10px;
    font-family: var(--font-body);
    font-size: 0.78em;
    letter-spacing: 0.02em;
    color: var(--text-primary);
    white-space: nowrap;
    pointer-events: none;

    /* Matte plastic */
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px) brightness(112%) contrast(88%);
    -webkit-backdrop-filter: blur(8px) brightness(112%) contrast(88%);
    border: 0.5px solid rgba(212, 175, 55, 0.18);
    border-radius: var(--radius-md);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.4),
        inset 0 0 3px rgba(255, 255, 255, 0.03);

    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s var(--ease-out), transform 0.15s var(--ease-out);
}

.rs-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Arrow */
.rs-tooltip::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -4px;
    width: 8px;
    height: 8px;
    background: rgba(0, 0, 0, 0.8);
    border-right: 0.5px solid rgba(212, 175, 55, 0.18);
    border-bottom: 0.5px solid rgba(212, 175, 55, 0.18);
    transform: translateX(-50%) rotate(45deg);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s var(--ease-out) forwards;
}

.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

/* 
   10. RESPONSIVE
*/

@media (max-width: 768px) {
    :root {
        --font-size-base: 16px;
    }

    h1 {
        font-size: 2.2em;
    }

    .container {
        padding: var(--space-lg) var(--space-md);
    }

    .nav-grid {
        grid-template-columns: 1fr;
    }

    .runes {
        display: none;
    }

    header,
    .page-header {
        padding: var(--space-xl) var(--space-md);
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.8em;
    }

    .subtitle {
        font-size: 0.95em;
        letter-spacing: 2px;
    }
}

@media (max-width: 420px) {
    .dropdown-selected-mark {
        display: none;
    }
}