/* ========================================
   GLOBAL SVG SAFETY
   Prevents SVG explosion when CSS loads late
   ======================================== */

/* Default size for all inline SVGs without explicit dimensions */
svg:not([width]):not([height]):not([class*="logo"]) {
    width: 24px;
    height: 24px;
}

/* Common icon sizes */
.sidebar__link-icon,
.topbar__action-icon,
.page-header__icon svg {
    width: 24px !important;
    height: 24px !important;
}

/**
 * RIFT v2 - Design System
 * Clean Slate - Gaming Dashboard Aesthetic
 */

/* ========================================
   FONTS
   ======================================== */

@font-face {
    font-family: 'Dharma Gothic';
    src: url('../fonts/dharma/DharmaGothicE_ExLight_R.woff') format('woff');
    font-weight: 200;
    font-style: normal;
}

@font-face {
    font-family: 'Dharma Gothic';
    src: url('../fonts/dharma/DharmaGothicE_Light_R.woff') format('woff');
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: 'Dharma Gothic';
    src: url('../fonts/dharma/DharmaGothicE_Regular_R.woff') format('woff');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Dharma Gothic';
    src: url('../fonts/dharma/DharmaGothicE_Bold_R.woff') format('woff');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'Dharma Gothic';
    src: url('../fonts/dharma/DharmaGothicE_ExBold_R.woff') format('woff');
    font-weight: 800;
    font-style: normal;
}

@font-face {
    font-family: 'Dharma Gothic';
    src: url('../fonts/dharma/DharmaGothicE_Heavy_R.woff') format('woff');
    font-weight: 900;
    font-style: normal;
}

/* ========================================
   CSS RESET
   ======================================== */

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

/* ========================================
   DESIGN TOKENS
   ======================================== */

:root {
    /* Colors - Base */
    --black: #161616;
    --white: #dedede;
    --gray: #bebebe;
    --gray-dark: #2a2a2a;
    --gray-darker: #1e1e1e;
    
    /* Colors - Accent */
    --red: #FF4655;
    --red-dark: #e63e4d;
    --red-glow: rgba(255, 70, 85, 0.4);
    --red-dim: rgba(255, 70, 85, 0.12);
    --green: #75ab5d;
    --green-dim: rgba(117, 171, 93, 0.12);
    
    /* Semantic */
    --bg: var(--black);
    --bg-elevated: var(--gray-darker);
    --bg-card: var(--gray-dark);
    --text: var(--white);
    --text-muted: var(--gray);
    --text-dim: #666;
    --accent: var(--red);
    --accent-hover: var(--red-dark);
    --success: var(--green);
    
    /* Borders */
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --border-accent: var(--red);
    
    /* Spacing */
    --space-2xs: 4px;
    --space-xs: 8px;
    --space-sm: 12px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;
    
    /* Typography */
    --font-display: 'Dharma Gothic', system-ui, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--red-glow);
    
    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;
    
    /* Layout */
    --sidebar-width: 72px;
    --topbar-height: 0px;
}

/* ========================================
   LIGHT THEME
   ======================================== */

[data-theme="light"] {
    /* Colors - Base (inverted) */
    --black: #f5f5f5;
    --white: #1a1a1a;
    --gray: #666666;
    --gray-dark: #e8e8e8;
    --gray-darker: #ffffff;
    
    /* Colors - Accent (slightly adjusted for light bg) */
    --red: #e63e4d;
    --red-dark: #d63545;
    --red-glow: rgba(230, 62, 77, 0.3);
    --red-dim: rgba(230, 62, 77, 0.1);
    --green: #5a9a45;
    --green-dim: rgba(90, 154, 69, 0.1);
    
    /* Semantic (auto-updated via base vars) */
    --bg: var(--black);
    --bg-elevated: var(--gray-darker);
    --bg-card: var(--gray-dark);
    --text: var(--white);
    --text-muted: var(--gray);
    --text-dim: #999;
    
    /* Borders (darker for light theme) */
    --border: rgba(0, 0, 0, 0.1);
    --border-hover: rgba(0, 0, 0, 0.2);
    
    /* Shadows (softer for light theme) */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
    
    /* Light mode specific - override white-based transparencies */
    --hover-bg: rgba(0, 0, 0, 0.05);
    --active-bg: rgba(0, 0, 0, 0.08);
}

/* Default dark mode hover values */
:root {
    --hover-bg: rgba(255, 255, 255, 0.08);
    --active-bg: rgba(255, 255, 255, 0.12);
}

/* ========================================
   THEME TRANSITION
   ======================================== */

html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
    transition: background-color 0.3s ease, 
                border-color 0.3s ease, 
                color 0.3s ease,
                box-shadow 0.3s ease !important;
}

/* ========================================
   BASE STYLES
   ======================================== */

html {
    font-size: 16px;
    background: var(--bg);
    color: var(--text);
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    background: #151515;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */

.display {
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
}

.display-xl { font-size: clamp(3rem, 8vw, 5rem); }
.display-lg { font-size: clamp(2rem, 5vw, 3rem); }
.display-md { font-size: clamp(1.5rem, 3vw, 2rem); }
.display-sm { font-size: clamp(1.25rem, 2vw, 1.5rem); }

.label {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
}

.mono {
    font-family: var(--font-mono);
}

/* ========================================
   APP LAYOUT
   ======================================== */

.app {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ========================================
   SIDEBAR, TOPBAR, FOOTER
   See separate CSS files:
   - sidebar.css (DEPRECATED - now using TopNav)
   - topbar.css (DEPRECATED - now using TopNav)
   - footer.css
   ======================================== */

/* ========================================
   MAIN CONTENT
   ======================================== */

.main {
    flex: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.main__content {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    background: #111111;
    min-height: calc(100vh - 122px - 72px); /* Subtract TopNav + Dock */
}

/* ========================================
   RESPONSIVE - MOBILE
   ======================================== */

@media (max-width: 768px) {
    .main {
        margin-left: 0;
    }
}

/* ========================================
   SCROLLBAR
   ======================================== */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-dark);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* ========================================
   SELECTION
   ======================================== */

::selection {
    background: var(--red-dim);
    color: var(--text);
}

/* ========================================
   FOCUS
   ======================================== */

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ========================================
   UTILITY
   ======================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   TOAST NOTIFICATIONS (Legacy - now in ui.css)
   ======================================== */

/* Old toast styles removed - using new system in ui.css */

/* ========================================
   CONFIRM DIALOG
   ======================================== */

.confirm-dialog-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 10000;
}

.confirm-dialog-overlay.active {
    opacity: 1;
    visibility: visible;
}

.confirm-dialog {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.confirm-dialog-overlay.active .confirm-dialog {
    transform: scale(1);
}

.confirm-dialog__message {
    margin: 0 0 20px 0;
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

.confirm-dialog__actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ========================================
   SCROLL TO TOP BUTTON
   ======================================== */

.scroll-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 99;
}

.scroll-to-top:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top svg {
    width: 24px;
    height: 24px;
}

/* ========================================
   BACK BUTTON
   ======================================== */

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    margin-bottom: 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-button:hover {
    background: var(--bg-elevated);
    border-color: var(--border-hover);
    color: var(--text);
}

.back-button svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   SKELETON LOADER
   ======================================== */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-elevated) 25%,
        rgba(255, 255, 255, 0.05) 50%,
        var(--bg-elevated) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

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

.skeleton--text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton--text:last-child {
    width: 60%;
}

.skeleton--title {
    height: 24px;
    width: 70%;
    margin-bottom: 12px;
}

.skeleton--image {
    width: 100%;
    height: 140px;
    border-radius: 8px;
}

.skeleton--avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton--button {
    width: 100px;
    height: 36px;
    border-radius: 8px;
}

/* ========================================
   OFFLINE INDICATOR
   ======================================== */

.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 10px 16px;
    background: var(--accent);
    color: white;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 10001;
}

.offline-indicator.visible {
    transform: translateY(0);
}

.offline-indicator::before {
    content: '⚠';
    margin-right: 8px;
}

/* ========================================
   VIEW TRANSITIONS (Enhancement for modern browsers)
   ======================================== */

/* Enable view transitions where supported */
@view-transition {
    navigation: auto;
}

/* Simple crossfade for root */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.3s;
}

/* Keep sidebar and topbar static */
.sidebar {
    view-transition-name: sidebar;
}

.topbar {
    view-transition-name: topbar;
}

::view-transition-old(sidebar),
::view-transition-new(sidebar),
::view-transition-old(topbar),
::view-transition-new(topbar) {
    animation: none;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation: none;
    }
}

/* ========================================
   PAGE LOAD ANIMATIONS
   ======================================== */

/* Hero entrance - scale down with blur clear */
.animate-hero {
    animation: heroEntrance 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-fill-mode: backwards;
}

@keyframes heroEntrance {
    from {
        opacity: 0;
        transform: scale(1.03);
        filter: blur(6px);
    }
    to {
        opacity: 1;
        transform: scale(1);
        filter: blur(0);
    }
}

/* Fade up animation for cards and widgets */
.animate-fade-up {
    animation: fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-fill-mode: backwards;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade in animation */
.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
    animation-fill-mode: backwards;
}

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

/* Scale in animation */
.animate-scale-in {
    animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-fill-mode: backwards;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ========================================
   MICRO INTERACTIONS
   ======================================== */

/* Button press effect */
.btn:active,
button:active {
    transform: scale(0.97);
}

/* Card hover lift */
.widget:hover,
.hero--secondary:hover {
    transform: translateY(-2px);
}

.widget,
.hero--secondary {
    transition: transform 0.2s var(--ease-out), 
                border-color 0.2s ease,
                box-shadow 0.2s ease;
}

/* Link underline animation */
.animated-link {
    position: relative;
    text-decoration: none;
}

.animated-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.3s var(--ease-out);
}

.animated-link:hover::after {
    width: 100%;
}

/* Focus ring animation */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    transition: outline-offset 0.15s ease;
}

*:focus-visible:active {
    outline-offset: 0;
}

/* Ripple effect for buttons */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    transform: scale(0);
    opacity: 0;
    transition: transform 0.5s ease, opacity 0.3s ease;
}

.ripple:active::after {
    transform: scale(2.5);
    opacity: 1;
    transition: none;
}

/* ========================================
   THEME TOGGLE
   ======================================== */

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--bg-elevated);
    border-color: var(--border-hover);
    color: var(--text);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s var(--ease-bounce);
}

.theme-toggle:hover svg {
    transform: rotate(15deg);
}

/* Sun icon for dark mode, moon icon for light mode */
.theme-toggle__sun,
.theme-toggle__moon {
    display: none;
}

[data-theme="dark"] .theme-toggle__sun,
:root:not([data-theme]) .theme-toggle__sun {
    display: block;
}

[data-theme="light"] .theme-toggle__moon {
    display: block;
}
