/* ============================================
   CSS VARIABLES — dark space theme
   ============================================ */
:root {
    --navbar-height: 56px;
    --bg:           #0a0a0f;
    --surface:      #13131f;
    --surface2:     #1a1a2e;
    --border:       #2a2a4a;
    --text:         #e2e8f0;
    --text-muted:   #8892a4;
    --accent:       #4a9eff;
    --accent-hover: #6ab0ff;
    --success:      #22c55e;
    --warning:      #f59e0b;
    --danger:       #ef4444;

    /* Side colors */
    --light-side:   #6ab0ff;
    --dark-side:    #c94040;
    --neutral:      #c4a870;
    --yuuzhan-vong: #3a9955;

    /* Gold accent */
    --gold:      #c4963e;
    --gold-dim:  rgba(196, 150, 62, 0.1);
    --gold-glow: rgba(196, 150, 62, 0.3);
}

/* ============================================
   LIGHT MODE OVERRIDES
   ============================================ */
[data-theme="light"] {
    --bg:           #eef0f6;
    --surface:      #ffffff;
    --surface2:     #dde0ed;
    --border:       #b8bcce;
    --text:         #16182a;
    --text-muted:   #555c75;
    --accent:       #1a6fd4;
    --accent-hover: #2a80e8;
    --gold-dim:  rgba(196, 150, 62, 0.12);
    --gold-glow: rgba(196, 150, 62, 0.28);
}

/* ============================================
   BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

[hidden] { display: none !important; }

html {
    scrollbar-gutter: stable;
}

body {
    font-family: 'Exo 2', sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.2s, color 0.2s;
}

#app {
    flex: 1;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    color: var(--accent-hover);
    text-decoration: none;
}

h1, h2, h3 {
    margin: 0 0 16px;
    font-weight: 700;
}

/* ============================================
   NAVBAR
   ============================================ */
#navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

#nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-logo {
    font-size: 22px;
    font-weight: bold;
    color: var(--text);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-logo:hover {
    color: var(--accent);
}

.nav-logo-img {
    height: 32px;
    width: auto;
    border-radius: 3px;
    object-fit: cover;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    gap: 20px;
}

/* My Decks lives in nav-right on desktop; hidden here to avoid duplication */
.nav-my-decks {
    display: none;
}

/* Login links in hamburger menu — hidden on desktop (buttons in nav-right instead) */
.nav-mobile-auth {
    display: none;
}

.nav-links a {
    color: var(--text-muted);
    font-size: 18px;
    font-weight: 500;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.nav-links a:hover,
.nav-links a.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.nav-link {
    color: var(--text-muted);
    font-size: 18px;
    font-weight: 500;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.nav-link:hover,
.nav-link.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-username {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.nav-username:hover {
    color: var(--accent-hover);
    border-bottom-color: var(--accent);
}

.nav-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 6px;
    line-height: 1;
    transition: color 0.15s;
}
.theme-toggle:hover {
    color: var(--text);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover {
    background: var(--border);
    color: var(--text);
    text-decoration: none;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: #2d7de0;
    border-color: #2d7de0;
    color: #fff;
}

.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-secondary {
    background: transparent;
    border-color: var(--gold);
    color: var(--gold);
}
.btn-secondary:hover {
    background: var(--gold-dim);
}

/* OAuth buttons */
.btn-discord {
    background: #5865F2;
    border-color: #5865F2;
    color: #fff;
}
.btn-discord:hover {
    background: #4752c4;
    border-color: #4752c4;
    color: #fff;
}

.btn-google {
    background: #fff;
    border-color: #dadce0;
    color: #3c4043;
}
.btn-google:hover {
    background: #f8f9fa;
    color: #3c4043;
}

.btn-dev {
    background: var(--warning);
    border-color: var(--warning);
    color: #000;
    font-weight: 700;
}
.btn-dev:hover {
    background: #d97706;
    border-color: #d97706;
    color: #000;
}

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

/* Sticky page-top: wraps a page header + filter bar so both scroll as one unit */
.page-sticky-top {
    position: sticky;
    top: var(--navbar-height);
    z-index: 50;
    background: var(--bg);
    padding: 12px 0 0;
    margin-top: -12px;
}
/* Cancel the filter bar's own sticky when it lives inside .page-sticky-top */
.page-sticky-top .dg-filter-bar {
    position: static;
    margin-top: 0;
    padding-top: 0;
}

.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* ============================================
   PLACEHOLDER — empty states & loading
   ============================================ */
.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--text-muted);
    font-size: 16px;
    text-align: center;
}

/* ============================================
   SIDE BADGES
   ============================================ */
.badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================
   MODAL
   ============================================ */
/* Prevent body scroll while any modal overlay is open.
   :has() activates automatically when .modal-overlay is in the DOM and
   deactivates when it's removed — no JS changes needed, covers all close paths. */
body:has(.modal-overlay) {
    overflow: hidden;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;   /* vw/vh use the CSS viewport (simulated device size in DevTools/RDM) */
    height: 100vh;  /* inset:0 uses window.innerWidth/Height (real browser) — wrong in simulation */
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 2px solid var(--gold);
    border-radius: 10px;
    max-width: 880px;
    width: 100%;
    min-width: 0;
    max-height: 90vh;
    overflow: hidden;    /* scroll lives in .modal-body so .modal-close never scrolls away */
    padding: 0;
    position: relative;
    display: flex;
    flex-direction: column;
}
/* Scrollable content area — sits below the absolute-positioned close button */
.modal-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain; /* prevent page-scroll bleed-through on iOS */
    padding: 24px;
    padding-top: 52px; /* clear the close button (top:8px + height:44px) */
}
.modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}
.modal-close:hover { color: var(--text); background: var(--surface2); }

.cb-modal-nav {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1;
}
.cb-nav-btn {
    padding: 3px 10px;
    font-size: 13px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
}
.cb-nav-btn:hover:not(:disabled) { background: var(--border); }
.cb-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.cb-nav-counter {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Confirm dialog */
.confirm-modal {
    max-width: 380px;
    padding: 28px 28px 24px;
}
.confirm-modal-msg {
    font-size: 15px;
    color: var(--text);
    margin: 0 0 24px;
    line-height: 1.5;
}
.confirm-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
