/* ═══════════════════════════════════════════════════════
   TRACKCAST v2 — Complete Stylesheet
   Fonts: Aldrich (headings), Roboto (body), Press Start 2P (pixel)
   Colors: Black #000, Yellow #ffce00, Rust Red (accent)
   ═══════════════════════════════════════════════════════ */

:root {
    --bg: #080808;
    --bg-card: #0a0a0a;
    --bg-card-hover: #111111;
    --bg-input: #111111;
    --bg-nav: rgba(8,8,8,0.95);
    --accent: #ffce00;
    --accent-hover: #ffffff;
    --rust-red: #dc4a26;
    --cyan: #22d3ee;
    --text: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --border: rgba(255,255,255,0.1);
    --border-hover: rgba(255,255,255,0.3);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --font-heading: 'Aldrich', sans-serif;
    --font-body: 'Roboto', sans-serif;
    --font-pixel: 'Press Start 2P', monospace;
    --green: #16a34a;
    --red: #dc2626;
    --blue: #2563eb;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: inherit; }
img { max-width: 100%; height: auto; }

/* ── CONTAINER ── */
.container { max-width: 1280px; margin: 0 auto; padding: 0 1rem; }

/* ── BUTTONS ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    font-family: var(--font-body); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
    text-decoration: none; border: none; cursor: pointer; transition: all 0.2s;
    padding: 0.625rem 1.5rem; border-radius: var(--radius); font-size: 0.875rem;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent-hover); color: #000; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: rgba(255,255,255,0.1); border-color: var(--border-hover); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #ef4444; }
.btn-sm { padding: 0.375rem 0.875rem; font-size: 0.75rem; }
.btn-lg { padding: 0.875rem 2rem; font-size: 1rem; }
.btn-green { background: var(--green); color: white; }
.btn-green:hover { background: #22c55e; }
.btn-rust { background: var(--rust-red); color: white; }
.btn-rust:hover { background: #ef6a3a; }

/* ── HEADER ── */
.site-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    padding: 0.75rem 0; transition: all 0.3s; background: transparent;
}
.site-header.scrolled {
    background: var(--bg-nav); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border); padding: 0.5rem 0;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; min-height: 56px; }
.logo { display: flex; align-items: center; flex-shrink: 0; }
.logo img { height: 28px; max-height: 28px; width: auto; max-width: 200px; display: block; }
.nav-desktop { display: none; align-items: center; gap: 1.5rem; }
.nav-link {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.15em;
    font-weight: 700; text-decoration: none; color: rgba(255,255,255,0.8);
    transition: color 0.2s; padding: 0.5rem 0;
}
.nav-link:hover, .nav-link.active { color: var(--rust-red); }
.header-actions { display: flex; align-items: center; gap: 0.75rem; }
.header-actions .points-badge,
.header-actions .user-menu,
.header-desktop-only { display: none !important; }
.mobile-menu-btn { display: flex; }
@media (min-width: 1024px) {
    .nav-desktop { display: flex; }
    .mobile-menu-btn { display: none !important; }
    .header-actions .points-badge,
    .header-actions .user-menu,
    .header-desktop-only { display: flex !important; }
    .logo img { height: 36px; max-height: 36px; max-width: 260px; }
}

/* ── USER MENU ── */
.points-badge {
    display: flex; align-items: center; gap: 0.375rem; background: rgba(252,255,0,0.1);
    border: 1px solid rgba(252,255,0,0.2); padding: 0.25rem 0.75rem; border-radius: var(--radius);
    color: var(--accent); font-family: monospace; font-size: 0.8125rem; font-weight: 700;
    text-decoration: none; transition: all 0.15s;
}
.points-badge:hover { background: rgba(252,255,0,0.2); border-color: rgba(252,255,0,0.4); }
.user-menu { position: relative; }
.user-menu-trigger {
    display: flex; align-items: center; gap: 0.5rem; background: none; border: 1px solid transparent;
    color: white; cursor: pointer; padding: 0.25rem 0.5rem 0.25rem 0.25rem; border-radius: 999px; transition: all 0.2s;
}
.user-menu-trigger:hover { border-color: var(--border); background: rgba(255,255,255,0.05); }
.avatar {
    width: 2rem; height: 2rem; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.75rem; background: linear-gradient(135deg, #374151, #111827); border: 1px solid var(--border);
}
.user-name { font-size: 0.8125rem; font-weight: 500; display: none; }
@media (min-width: 768px) { .user-name { display: inline; } }
.user-dropdown {
    position: absolute; right: 0; top: calc(100% + 0.5rem); width: 240px;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5); display: none; z-index: 100; overflow: hidden;
}
.user-dropdown.open { display: block; }
.user-dropdown .dropdown-header { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.user-dropdown .dropdown-header strong { display: block; font-size: 0.875rem; }
.user-dropdown .dropdown-header small { color: var(--text-muted); font-size: 0.6875rem; }
.user-dropdown a {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.625rem 1rem;
    font-size: 0.8125rem; text-decoration: none; color: var(--text-secondary); transition: all 0.15s;
}
.user-dropdown a:hover { background: rgba(255,255,255,0.05); color: white; }
.user-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 0; }

/* ── MOBILE MENU ── */
.mobile-menu {
    position: fixed; inset: 0; z-index: 100; background: var(--bg);
    transform: translateX(100%); transition: transform 0.3s ease;
}
.mobile-menu.open { transform: translateX(0); }
.mobile-nav { display: flex; flex-direction: column; padding: 1rem 2rem; }
.mobile-nav a {
    padding: 0.875rem 0; font-size: 1rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.1em; text-decoration: none; color: var(--text-secondary); border-bottom: 1px solid var(--border);
}
.mobile-nav a:hover { color: var(--accent); }
.mobile-nav hr { border: none; border-top: 1px solid var(--border); margin: 0.5rem 0; }

/* ── FLASH ── */
.flash {
    padding: 0.75rem 1.5rem; margin: 5rem auto 0; max-width: 600px; border-radius: var(--radius);
    font-size: 0.875rem; font-weight: 500; text-align: center; position: relative; z-index: 30;
}
.flash-success { background: rgba(22,163,74,0.15); color: #4ade80; border: 1px solid rgba(22,163,74,0.3); }
.flash-error { background: rgba(220,38,38,0.15); color: #f87171; border: 1px solid rgba(220,38,38,0.3); }

/* ── FORMS ── */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 0.8125rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.375rem; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 0.625rem 0.875rem; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius); color: white; font-size: 0.875rem; font-family: var(--font-body); transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--accent); }
.form-textarea { resize: vertical; min-height: 100px; }

/* ── CARDS ── */
.card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    overflow: hidden; transition: all 0.3s;
}
.card:hover { border-color: var(--accent); }
.card-image { width: 100%; height: 200px; object-fit: cover; display: block; background: #111; }
.card-body { padding: 1.25rem; }
.card-title { font-family: var(--font-heading); font-size: 1.125rem; color: white; margin-bottom: 0.5rem; }

/* ── GRIDS ── */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ── HERO ── */
.hero {
    position: relative; min-height: 90vh; display: flex; align-items: center;
    background-size: cover; background-position: center; overflow: hidden;
}
.hero::before {
    content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0.75); z-index: 1;
}
.hero-content { position: relative; z-index: 2; max-width: 800px; }
.hero h1 { font-family: var(--font-heading); font-size: clamp(2.5rem, 6vw, 4.5rem); line-height: 1; margin-bottom: 1.5rem; }
.hero p { font-size: clamp(1rem, 2vw, 1.25rem); color: #d1d5db; margin-bottom: 2.5rem; max-width: 640px; line-height: 1.7; }
.hero-badge {
    display: inline-flex; align-items: center; gap: 0.5rem; background: rgba(255,206,0,0.1);
    border: 1px solid rgba(255,206,0,0.2); color: var(--accent); padding: 0.375rem 1rem;
    border-radius: 999px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.15em; margin-bottom: 1.5rem; backdrop-filter: blur(4px);
}
.hero-badge .pulse { width: 0.625rem; height: 0.625rem; background: var(--accent); border-radius: 50%; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.hero-actions { display: flex; flex-wrap: wrap; gap: 1rem; }

/* ── PAGE HEADERS ── */
.page-header { padding: 6rem 0 2rem; }
.page-header h1 { font-family: var(--font-heading); font-size: clamp(1.5rem, 4vw, 2.5rem); text-transform: uppercase; letter-spacing: 0.05em; }
.page-header p { color: var(--text-secondary); margin-top: 0.5rem; }

/* ── FILTER BAR ── */
.filter-bar { display: flex; gap: 0.75rem; align-items: center; }
.filter-bar .form-select { width: auto; min-width: 150px; }
.filter-bar .btn { white-space: nowrap; flex-shrink: 0; }
.search-input { position: relative; flex: 1; min-width: 0; }
.search-input i { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 18px; height: 18px; pointer-events: none; z-index: 1; }
.search-input .form-input { padding-left: 2.5rem; width: 100%; }
@media (max-width: 768px) { .filter-bar { flex-wrap: wrap; } .search-input { flex: 1 1 100%; } .filter-bar .form-select { flex: 1; } }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--text-muted); }

/* ── TABLES ── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.admin-table th { text-align: left; padding: 0.75rem; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.admin-table td { padding: 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: middle; }
.admin-table tr:hover td { background: rgba(255,255,255,0.02); }

/* ── STATUS BADGES ── */
.badge {
    display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.125rem 0.5rem;
    border-radius: 0.25rem; font-size: 0.625rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
}
.badge-live { background: var(--red); color: white; animation: pulse 2s infinite; }
.badge-upcoming { background: var(--blue); color: white; }
.badge-completed { background: #4b5563; color: white; }
.badge-free { background: var(--green); color: white; }
.badge-purchased { background: var(--green); color: white; }
.badge-pending { background: #d97706; color: white; }
.badge-draft { background: #374151; color: #9ca3af; }

/* ── FOOTER ── */
.site-footer { background: var(--bg); border-top: 1px solid rgba(255,255,255,0.2); padding: 5rem 0 2.5rem; }
.footer-grid { display: grid; grid-template-columns: 1fr; gap: 3rem; margin-bottom: 4rem; }
@media (min-width: 768px) { .footer-grid { grid-template-columns: 2fr 1fr 1fr; } }
.footer-brand p { color: var(--text-muted); margin-top: 1.5rem; font-size: 0.875rem; line-height: 1.7; max-width: 360px; }
.footer-grid h4 { font-size: 0.875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.15em; color: var(--text-muted); margin-bottom: 1.25rem; }
.footer-grid > div > a { display: block; color: white; text-decoration: none; font-weight: 700; font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.75rem; }
.footer-grid > div > a:hover { color: var(--accent); }
.social-links { display: flex; gap: 0.75rem; }
.social-links a {
    width: 2.5rem; height: 2.5rem; display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); color: white; text-decoration: none; transition: all 0.3s;
}
.social-links a:hover { border-color: white; background: white; color: black; }
.footer-bottom {
    display: flex; flex-direction: column-reverse; align-items: center; gap: 1rem;
    border-top: 1px solid var(--border); padding-top: 2rem;
}
@media (min-width: 768px) { .footer-bottom { flex-direction: row; justify-content: space-between; } }
.footer-links { display: flex; gap: 2rem; }
.footer-links a { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.15em; color: var(--text-muted); text-decoration: none; }
.footer-links a:hover { color: white; }
.footer-links .admin-link { color: var(--rust-red); font-weight: 700; }
.footer-bottom > p { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.15em; color: var(--text-muted); }

/* ── ADMIN ── */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 260px; background: #0a0a0a; border-right: 1px solid var(--border);
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
    overflow-y: auto; display: none;
}
@media (min-width: 1024px) { .admin-sidebar { display: block; } }
.admin-sidebar.open { display: block; }
.admin-sidebar-brand { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.admin-sidebar-nav { padding: 1rem 0; }
.admin-sidebar-nav .nav-section { padding: 0.5rem 1.5rem; font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.15em; color: var(--text-muted); margin-top: 0.5rem; }
.admin-sidebar-nav a {
    display: flex; align-items: center; gap: 0.625rem; padding: 0.5rem 1.5rem;
    font-size: 0.8125rem; color: var(--text-secondary); text-decoration: none; transition: all 0.15s;
}
.admin-sidebar-nav a:hover { background: rgba(255,255,255,0.05); color: white; }
.admin-sidebar-nav a.active { background: rgba(255,206,0,0.1); color: var(--accent); border-right: 2px solid var(--accent); }
.admin-main { flex: 1; margin-left: 0; }
@media (min-width: 1024px) { .admin-main { margin-left: 260px; } }
.admin-header {
    height: 4rem; background: #0a0a0a; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; position: sticky; top: 0; z-index: 30;
}
.admin-content { padding: 2rem 1.5rem; max-width: 1200px; }

/* ── STAT CARDS ── */
.stat-card {
    background: #1a2332; padding: 1.5rem; border-radius: var(--radius-lg);
    border: 1px solid var(--border); position: relative; overflow: hidden; transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--border-hover); }
.stat-card .stat-icon { position: absolute; top: 1rem; right: 1rem; opacity: 0.1; }
.stat-card .stat-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.stat-card .stat-value { font-size: 2rem; font-weight: 800; font-family: var(--font-heading); margin-top: 0.25rem; }

/* ── UTILITY ── */
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-green { color: #4ade80; }
.text-red { color: #f87171; }
.text-cyan { color: var(--cyan); }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-8 { margin-bottom: 2rem; }
.font-heading { font-family: var(--font-heading); }
.font-mono { font-family: monospace; }
.uppercase { text-transform: uppercase; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

/* ─── Timing Tabs ─── */
@keyframes spin { to { transform: rotate(360deg); } }
.race-tab { transition: all 0.15s; }
.race-tab:hover { color: white !important; }

/* ─── Logo Sizing ─── */
.site-logo { height: 32px; max-height: 32px; width: auto; max-width: 240px; display: block; }
.footer-logo { height: 40px; max-height: 40px; width: auto; max-width: 280px; display: block; }
@media (max-width: 768px) {
    .site-logo { height: 26px; max-height: 26px; max-width: 180px; }
    .footer-logo { height: 32px; max-height: 32px; max-width: 220px; }
}
