/*
  MTALK Global Design System
  ═══════════════════════════
  Single source of truth for typography, colors, spacing, shared components.
  Load this BEFORE any other stylesheet on every page.
*/

/* ─── Design Tokens ─── */
:root {
    /* Brand Colors */
    --mt-primary: #FF073A;
    --mt-primary-dark: #700B1A;
    --mt-primary-glow: rgba(255, 7, 58, 0.4);
    --mt-primary-subtle: rgba(255, 7, 58, 0.08);

    /* Accent Colors */
    --mt-cyan: #00D4FF;
    --mt-cyan-glow: rgba(0, 212, 255, 0.3);
    --mt-cyan-subtle: rgba(0, 212, 255, 0.08);
    --mt-gold: #FFD700;
    --mt-gold-subtle: rgba(255, 215, 0, 0.1);

    /* Semantic Colors */
    --mt-success: #4caf50;
    --mt-error: #f44336;
    --mt-warning: #ff9800;
    --mt-info: var(--mt-cyan);

    /* Surface & Background */
    --mt-bg: #000000;
    --mt-bg-elevated: #0a0a0a;
    --mt-surface: rgba(255, 255, 255, 0.03);
    --mt-surface-hover: rgba(255, 255, 255, 0.06);
    --mt-surface-active: rgba(255, 255, 255, 0.09);

    /* Glass */
    --mt-glass: rgba(255, 255, 255, 0.04);
    --mt-glass-border: rgba(255, 255, 255, 0.08);
    --mt-glass-border-hover: rgba(255, 255, 255, 0.15);
    --mt-glass-heavy: rgba(0, 0, 0, 0.85);

    /* Text */
    --mt-text-primary: #ffffff;
    --mt-text-secondary: #e0e0e0;
    --mt-text-tertiary: #a0a0a0;
    --mt-text-muted: #777777;
    --mt-text-dim: rgba(255, 255, 255, 0.5);

    /* Borders */
    --mt-border: rgba(255, 255, 255, 0.06);
    --mt-border-accent: rgba(255, 7, 58, 0.2);
    --mt-border-accent-hover: rgba(255, 7, 58, 0.5);

    /* Spacing Scale (4px base) */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;
    --sp-12: 48px;
    --sp-16: 64px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 50%;

    /* Typography Scale */
    --fs-xs: 0.65rem;
    --fs-sm: 0.75rem;
    --fs-base: 0.875rem;
    --fs-md: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.5rem;
    --fs-2xl: 2rem;
    --fs-3xl: 2.5rem;
    --fs-4xl: 3rem;

    /* Fonts */
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Z-Index Scale */
    --z-header: 1000;
    --z-dropdown: 2000;
    --z-modal: 3000;
    --z-toast: 9000;

    /* Transitions */
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --duration-fast: 0.15s;
    --duration-normal: 0.3s;
    --duration-slow: 0.5s;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--mt-primary-glow);
    --shadow-glow-cyan: 0 0 20px var(--mt-cyan-glow);
}

/* ─── Reset & Base ─── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--mt-bg);
    background-image: radial-gradient(ellipse at 50% 0%, #1a0a10 0%, #080808 50%, #000 100%);
    color: var(--mt-text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
    animation: pageEnter 0.6s ease-out;
}

@keyframes pageEnter {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ─── Typography ─── */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.02em;
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }

p, span, label, li, td, th, input, textarea, select, button, a {
    font-family: var(--font-body);
}

a {
    color: var(--mt-text-primary);
    text-decoration: none;
    transition: color var(--duration-normal) ease;
}

a:hover {
    color: var(--mt-primary);
}

/* ─── Accessibility ─── */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--sp-4);
    background: var(--mt-primary);
    color: white;
    padding: var(--sp-3) var(--sp-6);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--fs-base);
    z-index: 10000;
    transition: top var(--duration-normal) ease;
}

.skip-link:focus {
    top: var(--sp-4);
}

:focus-visible {
    outline: 2px solid var(--mt-cyan);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

/* Remove outline for mouse clicks, keep for keyboard */
:focus:not(:focus-visible) {
    outline: none;
}

/* ─── Shared Header ─── */
.site-header {
    width: 100%;
    padding: var(--sp-5) var(--sp-12);
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: var(--z-header);
    border-bottom: 1px solid var(--mt-glass-border);
    transition: background var(--duration-normal) ease;
}

.site-header:hover {
    background: rgba(0, 0, 0, 0.6);
}

.site-logo {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    color: var(--mt-primary);
    text-transform: uppercase;
    cursor: pointer;
    letter-spacing: 2px;
    transition: text-shadow var(--duration-normal) ease;
    text-decoration: none;
}

.site-logo:hover {
    color: var(--mt-primary);
    text-shadow: 0 0 20px var(--mt-primary-glow);
}

.site-nav {
    display: flex;
    gap: var(--sp-5);
    align-items: center;
}

.site-nav a {
    text-decoration: none;
    color: var(--mt-text-secondary);
    font-family: var(--font-body);
    font-size: var(--fs-base);
    font-weight: 500;
    transition: color var(--duration-normal) ease;
    white-space: nowrap;
    position: relative;
    padding-bottom: 2px;
}

.site-nav a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--mt-primary);
    transition: width var(--duration-normal) var(--ease-out);
    border-radius: 1px;
}

.site-nav a:hover {
    color: var(--mt-text-primary);
}

.site-nav a:hover::after {
    width: 100%;
}

.site-nav a.active {
    color: var(--mt-primary);
}

.site-nav a.active::after {
    width: 100%;
}

/* ─── Hamburger (mobile) ─── */
.hamburger-btn {
    display: none;
    background: none;
    border: 1px solid rgba(255, 7, 58, 0.2);
    color: var(--mt-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 6px 10px;
    z-index: 1001;
    line-height: 1;
    border-radius: var(--radius-md);
    transition: transform var(--duration-normal) ease,
                border-color var(--duration-normal) ease,
                box-shadow var(--duration-normal) ease,
                background var(--duration-normal) ease;
    width: 44px;
    height: 44px;
    display: none;
    align-items: center;
    justify-content: center;
}

.hamburger-btn:active {
    border-color: var(--mt-primary);
    background: rgba(255, 7, 58, 0.05);
}

/* ─── Main Content ─── */
.site-main {
    min-height: calc(100vh - 80px);
}

/* ─── Shared Footer ─── */
.site-footer {
    text-align: center;
    padding: var(--sp-12) var(--sp-6);
    border-top: 1px solid var(--mt-border);
    margin-top: var(--sp-16);
    background: linear-gradient(to top, rgba(255, 7, 58, 0.02), transparent);
}

.footer-brand {
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 700;
    color: var(--mt-primary);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: var(--sp-2);
}

.footer-tagline {
    font-size: var(--fs-sm);
    color: var(--mt-text-tertiary);
    margin-bottom: var(--sp-6);
    font-style: italic;
    letter-spacing: 1px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: var(--sp-6);
    margin-bottom: var(--sp-6);
    flex-wrap: wrap;
}

.footer-links a {
    font-size: var(--fs-sm);
    color: var(--mt-text-muted);
    transition: color var(--duration-normal) ease;
}

.footer-links a:hover {
    color: var(--mt-primary);
}

.footer-copy {
    font-size: var(--fs-xs);
    color: var(--mt-text-muted);
    letter-spacing: 0.5px;
}

/* ─── Ambient Background Effects ─── */
.ambient-glow {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.ambient-glow::before {
    content: '';
    position: absolute;
    top: -20%;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 400px;
    background: radial-gradient(ellipse, rgba(255, 7, 58, 0.06) 0%, transparent 70%);
    filter: blur(60px);
}

.ambient-glow::after {
    content: '';
    position: absolute;
    bottom: -10%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.03) 0%, transparent 70%);
    filter: blur(80px);
}

/* ─── Glass Card ─── */
.glass-card {
    background: var(--mt-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--mt-glass-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-8);
    transition: border-color var(--duration-normal) ease, box-shadow var(--duration-normal) ease;
}

.glass-card:hover {
    border-color: var(--mt-glass-border-hover);
    box-shadow: var(--shadow-md);
}

/* ─── Custom Toast System ─── */
.mt-toast-container {
    position: fixed;
    bottom: var(--sp-8);
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column-reverse;
    gap: var(--sp-3);
    align-items: center;
    pointer-events: none;
}

.mt-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-6);
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--mt-glass-border);
    border-radius: 30px;
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    color: var(--mt-text-primary);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.4s var(--ease-spring);
    max-width: 420px;
    overflow: hidden;
    position: relative;
}

.mt-toast.success { border-left: 4px solid var(--mt-success); }
.mt-toast.error { border-left: 4px solid var(--mt-error); }
.mt-toast.warning { border-left: 4px solid var(--mt-warning); }
.mt-toast.info { border-left: 4px solid var(--mt-cyan); }

.mt-toast.exit {
    animation: toastOut 0.3s ease-in forwards;
}

.mt-toast-icon {
    font-size: var(--fs-lg);
    flex-shrink: 0;
}

.mt-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--mt-primary);
    border-radius: 0 0 30px 30px;
    animation: toastProgress 3s linear forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* ─── Skeleton Loading ─── */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--mt-surface) 25%,
        var(--mt-surface-hover) 50%,
        var(--mt-surface) 75%
    );
    background-size: 400% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 14px;
    margin-bottom: var(--sp-2);
    border-radius: var(--radius-sm);
}

.skeleton-circle {
    border-radius: var(--radius-full);
}

.skeleton-card {
    height: 200px;
    border-radius: var(--radius-lg);
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Section Headers ─── */
.section-title {
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    text-align: center;
    margin-bottom: var(--sp-8);
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, var(--mt-primary), var(--mt-cyan));
    border-radius: 2px;
}

/* ─── Utility Classes ─── */
.text-primary { color: var(--mt-primary); }
.text-cyan { color: var(--mt-cyan); }
.text-gold { color: var(--mt-gold); }
.text-muted { color: var(--mt-text-muted); }
.text-secondary { color: var(--mt-text-secondary); }
.text-center { text-align: center; }
.font-display { font-family: var(--font-display); }
.font-body { font-family: var(--font-body); }

/* ─── Login Toast (legacy support) ─── */
.login-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(255, 7, 58, 0.95);
    color: white;
    padding: var(--sp-3) var(--sp-8);
    border-radius: var(--radius-lg);
    font-size: var(--fs-base);
    font-family: var(--font-body);
    z-index: var(--z-toast);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s, transform 0.4s;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px var(--mt-primary-glow);
    text-align: center;
}

.login-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.login-toast a {
    color: #fff;
    text-decoration: underline;
    font-weight: bold;
    margin-left: var(--sp-2);
}

/* ─── Admin Button ─── */
.admin-only {
    display: none;
}

/* ─── Nav Login Link ─── */
.nav-login-link {
    display: none;
}

/* ─── Loading Overlay ─── */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--mt-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--mt-primary-subtle);
    border-top: 4px solid var(--mt-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ─── Error Message ─── */
.error-msg {
    color: var(--mt-error);
    font-size: var(--fs-base);
    margin-top: var(--sp-3);
    display: none;
    font-family: var(--font-body);
}

/* ─── Responsive: Tablet (≤768px) ─── */
@media (max-width: 768px) {
    .hamburger-btn {
        display: flex;
    }

    .site-header {
        padding: var(--sp-4) var(--sp-5);
        flex-wrap: nowrap;
    }

    .site-header .site-nav {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        background: rgba(5, 5, 5, 0.97);
        backdrop-filter: blur(25px);
        -webkit-backdrop-filter: blur(25px);
        padding: 0;
        gap: 0;
        border-bottom: 2px solid transparent;
        box-shadow: none;
        overflow: hidden;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-8px);
        transition: opacity 0.25s ease,
                    visibility 0.25s ease,
                    transform 0.25s ease,
                    border-color 0.25s ease,
                    box-shadow 0.25s ease;
        pointer-events: none;
    }

    .site-header .site-nav.active {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        padding: var(--sp-2) 0;
        pointer-events: auto;
        border-bottom: 2px solid var(--mt-border-accent);
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 7, 58, 0.05);
    }

    .site-header .site-nav a,
    .site-header .site-nav button {
        display: block;
        text-align: center;
        padding: var(--sp-4) var(--sp-5);
        margin: 0;
        font-size: var(--fs-md);
        border-bottom: 1px solid rgba(255, 255, 255, 0.03);
        transition: background var(--duration-normal), color var(--duration-normal);
        width: 100%;
    }

    .site-header .site-nav a::after {
        display: none;
    }

    .site-header .site-nav a:hover,
    .site-header .site-nav button:hover {
        background: var(--mt-primary-subtle);
        color: var(--mt-primary);
    }

    .site-header .site-nav a.active {
        background: rgba(255, 7, 58, 0.06);
        color: var(--mt-primary);
        font-weight: 600;
        border-left: 3px solid var(--mt-primary);
    }

    .site-logo {
        font-size: 22px;
    }

    .site-footer {
        padding: var(--sp-8) var(--sp-4);
    }
}

/* ─── Responsive: Mobile (≤480px) ─── */
@media (max-width: 480px) {
    .site-header {
        padding: var(--sp-3) var(--sp-4);
    }

    .site-logo {
        font-size: 20px;
    }

    h1 { font-size: var(--fs-xl); }
    h2 { font-size: var(--fs-lg); }
}
