/* ============================================================================
   MILONOV EVENT PLATFORM — DESIGN SYSTEM
   Bootstrap 5 (data-bs-theme="dark") + React Bits Engineering UI
   Zero Emoji · Bento Grid · Spotlight Cards · Subtle Dot Matrix
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
    --bg-base: #0a0a0c;
    --bg-surface: #121316;
    --bg-surface-elevated: #18191e;
    --bg-subtle: #1e2026;
    
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.14);
    --border-strong: rgba(255, 255, 255, 0.24);
    
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    --accent-blue: #3b82f6;
    --accent-blue-subtle: rgba(59, 130, 246, 0.12);
    --accent-emerald: #10b981;
    --accent-emerald-subtle: rgba(16, 185, 129, 0.12);
    --accent-amber: #f59e0b;
    --accent-amber-subtle: rgba(245, 158, 11, 0.12);
    --accent-rose: #f43f5e;
    --accent-rose-subtle: rgba(244, 63, 94, 0.12);
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background-color: var(--bg-base);
    background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
    background-size: 24px 24px;
    background-position: 0 0;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    display: flex;
    flex-direction: column;
}

/* ─── Типографика ─────────────────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.025em;
}

code, kbd, samp, pre, .font-mono {
    font-family: var(--font-mono) !important;
}

/* ─── Шапка сайта (Header & Navbar) ───────────────────────────────────────── */

header.site-header {
    background-color: rgba(10, 10, 12, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 1050;
    padding: 0.75rem 0;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background-color: #ffffff;
    color: #0a0a0c;
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: 6px;
    letter-spacing: -0.03em;
    user-select: none;
}

.brand-title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    text-decoration: none;
}

.site-nav {
    display: flex;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.site-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.site-nav a:hover {
    color: var(--text-primary);
    background-color: var(--bg-surface-elevated);
}

.site-nav a.active {
    color: var(--text-primary);
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
}

.user-nav-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.825rem;
    transition: all 0.2s ease;
}

.user-nav-badge:hover {
    color: var(--text-primary);
    border-color: var(--border-medium);
    background-color: var(--bg-surface-elevated);
}

.header-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-medium);
}

/* ─── Интерактивная Spotlight Card (React Bits) ───────────────────────────── */

.spotlight-card {
    position: relative;
    background-color: var(--bg-surface);
    background-image: radial-gradient(
        480px circle at var(--mouse-x, -500px) var(--mouse-y, -500px),
        rgba(255, 255, 255, 0.05),
        transparent 45%
    );
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 1.5rem;
    overflow: hidden;
    transition: border-color 0.2s ease, transform 0.2s var(--ease-out-expo);
}

.spotlight-card::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: radial-gradient(
        320px circle at var(--mouse-x, -500px) var(--mouse-y, -500px),
        rgba(255, 255, 255, 0.22),
        transparent 40%
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 2;
}

.spotlight-card:hover {
    border-color: var(--border-medium);
}

/* ─── Bento Grid Layout ───────────────────────────────────────────────────── */

.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1rem;
}

.bento-col-12 { grid-column: span 12; }
.bento-col-8  { grid-column: span 8; }
.bento-col-6  { grid-column: span 6; }
.bento-col-4  { grid-column: span 4; }
.bento-col-3  { grid-column: span 3; }

@media (max-width: 991.98px) {
    .bento-col-8, .bento-col-6, .bento-col-4, .bento-col-3 {
        grid-column: span 12;
    }
}

/* ─── Микро-анимация Blur Text / Fade In (React Bits) ─────────────────────── */

@keyframes blurFadeIn {
    0% {
        opacity: 0;
        filter: blur(8px);
        transform: translateY(12px);
    }
    100% {
        opacity: 1;
        filter: blur(0);
        transform: translateY(0);
    }
}

.blur-fade {
    animation: blurFadeIn 0.55s var(--ease-out-expo) both;
}

.blur-fade-delay-1 { animation-delay: 0.08s; }
.blur-fade-delay-2 { animation-delay: 0.16s; }
.blur-fade-delay-3 { animation-delay: 0.24s; }

/* ─── Кнопки в стиле Shiny / Tilted (React Bits) ──────────────────────────── */

.btn-shiny {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.55rem 1.15rem;
    border-radius: 6px;
    border: 1px solid var(--border-medium);
    background-color: var(--bg-surface-elevated);
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    overflow: hidden;
    user-select: none;
    transition: transform 0.18s var(--ease-out-expo), border-color 0.18s ease, background-color 0.18s ease;
}

.btn-shiny::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(60deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    transform: rotate(25deg) translateY(-100%);
    transition: transform 0.65s var(--ease-out-expo);
    pointer-events: none;
}

.btn-shiny:hover::after {
    transform: rotate(25deg) translateY(100%);
}

.btn-shiny:hover {
    transform: translateY(-1px);
    border-color: var(--border-strong);
    background-color: var(--bg-subtle);
    color: #ffffff;
}

.btn-shiny:active {
    transform: translateY(0);
}

.btn-shiny-primary {
    background-color: #ffffff;
    color: #0a0a0c;
    border-color: #ffffff;
    font-weight: 600;
}

.btn-shiny-primary:hover {
    background-color: #e4e4e7;
    color: #0a0a0c;
    border-color: #e4e4e7;
}

.btn-shiny-danger {
    background-color: var(--accent-rose-subtle);
    border-color: rgba(244, 63, 94, 0.3);
    color: #fda4af;
}

.btn-shiny-danger:hover {
    background-color: #e11d48;
    border-color: #e11d48;
    color: #ffffff;
}

/* ─── Статусные индикаторы ────────────────────────────────────────────────── */

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.775rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.status-active .status-dot {
    background-color: var(--accent-emerald);
    box-shadow: 0 0 6px var(--accent-emerald);
}

.status-paused .status-dot {
    background-color: var(--accent-amber);
    box-shadow: 0 0 6px var(--accent-amber);
}

.status-maintenance .status-dot {
    background-color: var(--accent-rose);
    box-shadow: 0 0 6px var(--accent-rose);
}

/* ─── Формы (Form Controls) ───────────────────────────────────────────────── */

.form-control, .form-select {
    background-color: var(--bg-base);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-base);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text-primary);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    font-size: 0.825rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

/* ─── Таблицы (Tables) ────────────────────────────────────────────────────── */

.table-custom {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}

.table-custom th {
    background-color: var(--bg-surface-elevated);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.775rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.table-custom td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    vertical-align: middle;
}

.table-custom tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
}

/* ─── Общесемейный баннер (Global Alert Banner) ────────────────────────────── */

#globalFamilyBanner {
    display: none;
    background-color: var(--bg-surface-elevated);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.55rem 1rem;
    font-size: 0.85rem;
    text-align: center;
    color: var(--text-primary);
}

.banner-badge {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    margin-right: 0.6rem;
    letter-spacing: 0.05em;
}

/* ─── Подвал (Footer) ─────────────────────────────────────────────────────── */

footer.site-footer {
    margin-top: auto;
    border-top: 1px solid var(--border-subtle);
    padding: 1.5rem 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    background-color: var(--bg-base);
}

/* ─── Специфика Квеста и Мини-игр ─────────────────────────────────────────── */

.quest-step-container {
    display: none;
}
.quest-step-container.active {
    display: block;
}

.memory-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin: 1.25rem auto;
    max-width: 480px;
}

@media (max-width: 520px) {
    .memory-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }
}

.memory-card {
    aspect-ratio: 1 / 1;
    background-color: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.memory-card:hover:not(.flipped):not(.matched) {
    border-color: var(--border-strong);
    background-color: var(--bg-surface-elevated);
}

.memory-card.flipped {
    background-color: var(--bg-subtle);
    border-color: var(--border-strong);
}

.memory-card.matched {
    background-color: var(--accent-emerald-subtle);
    border-color: rgba(16, 185, 129, 0.4);
    color: #34d399;
    cursor: default;
}

.memory-card .card-back {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.memory-card .card-front {
    display: none;
}
.memory-card.flipped .card-front,
.memory-card.matched .card-front {
    display: block;
}
.memory-card.flipped .card-back,
.memory-card.matched .card-back {
    display: none;
}

/* Сетка цепи 8x8 (Задание 9) */
.circuit-grid-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    background-color: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 8px;
    max-width: 460px;
    margin: 1rem auto;
    user-select: none;
}

.grid-cell {
    aspect-ratio: 1 / 1;
    background-color: var(--bg-surface);
    border-radius: 4px;
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background-color 0.1s ease;
}

.grid-cell:hover:not(.wire-locked):not(.endpoint) {
    background-color: var(--bg-subtle);
    border-color: var(--border-medium);
}

.grid-cell.endpoint {
    border-radius: 6px;
    font-weight: 800;
}

.grid-cell.endpoint-active {
    outline: 2px solid #ffffff;
}

.grid-cell.wire-active {
    outline: 1px solid #ffffff;
}

.grid-cell.wire-locked {
    opacity: 0.9;
    cursor: default;
}

.grid-circuit-alert {
    background-color: var(--accent-rose-subtle);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fda4af;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 0.75rem;
}

.shake {
    animation: shake 0.35s ease;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* Опции для Задания 3 */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.5rem;
    margin: 1rem 0;
}

.option-btn {
    background-color: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
}

.option-btn:hover {
    border-color: var(--border-medium);
    color: var(--text-primary);
}

.option-btn.selected {
    background-color: var(--bg-surface-elevated);
    border-color: #ffffff;
    color: #ffffff;
    font-weight: 600;
}

/* ─── Mafia In-Game Glass Toasts ─── */
.mafia-toast {
    position: relative;
    background: rgba(18, 18, 22, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    max-width: 400px;
    width: 100%;
    margin-bottom: 0.75rem;
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: opacity 0.25s ease, transform 0.25s ease;
    overflow: hidden;
}

.mafia-toast.toast-hiding {
    opacity: 0;
    transform: translateX(35px) scale(0.95);
}

.mafia-toast.toast-success {
    border-left: 3px solid #10b981;
}

.mafia-toast.toast-danger,
.mafia-toast.toast-error {
    border-left: 3px solid #ef4444;
}

.mafia-toast.toast-warning {
    border-left: 3px solid #f59e0b;
}

.mafia-toast.toast-info {
    border-left: 3px solid #3b82f6;
}

.mafia-toast.toast-sheriff {
    border-left: 3px solid #06b6d4;
    background: linear-gradient(135deg, rgba(18, 18, 22, 0.96), rgba(6, 182, 212, 0.12));
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 20px rgba(6, 182, 212, 0.2);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
