/* ===== TOP NAV ROOT ===== */
:root {
    --nav-height: 104px;
}

.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    z-index: 1000;
    background: rgba(26, 22, 18, 0.97);
    border-bottom: 1px solid rgba(200, 135, 42, 0.3);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
}

/* 3-column grid: nav links | centred logo | search + icons */
.top-nav__inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    height: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 1.5rem;
    gap: 0;
    position: relative;
}

/* ===== CENTER LOGO ===== */
.top-nav__center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.top-nav__logo {
    display: flex;
    align-items: center;
    text-decoration: none !important;
    flex-shrink: 0;
}

.top-nav__logo img {
    height: 88px;
    width: auto;
}

/* ===== LEFT LINKS (Browse + My Decks) ===== */
.top-nav__left {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    justify-content: flex-start;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    background: transparent;
    border: none;
    color: var(--color-muted);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    text-decoration: none !important;
    white-space: nowrap;
    transition: color 0.15s ease, background 0.15s ease;
}

.nav-btn:hover,
.nav-btn:focus-visible {
    color: var(--color-text);
    background: rgba(200, 135, 42, 0.1);
}

.nav-btn.is-active {
    color: var(--color-accent);
}

.nav-btn .nav-chevron {
    font-size: 0.65rem;
    transition: transform 0.2s ease;
}

.nav-btn[aria-expanded="true"] .nav-chevron {
    transform: rotate(180deg);
}

/* ===== RIGHT: SEARCH + ICONS ===== */
.top-nav__right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    justify-content: flex-end;
}

/* Search bar — compact pill, lives inside right column */
.top-nav__search form {
    display: flex;
    align-items: stretch;
    background: rgba(14, 12, 10, 0.7);
    border: 1px solid rgba(200, 135, 42, 0.35);
    border-radius: 999px;
    overflow: hidden;
    width: 260px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, width 0.25s ease;
    /* GPU compositing prevents antialias fringe at rounded corners */
    transform: translateZ(0);
}

.top-nav__search form:focus-within {
    border-color: var(--color-accent);
    box-shadow: 0 0 10px rgba(200, 135, 42, 0.25);
    width: 320px;
}

.top-nav__search input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 0.5rem 0.9rem;
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 0.85rem;
    min-width: 0;
    align-self: center;
}

.top-nav__search input::placeholder {
    color: var(--color-muted);
}

.top-nav__search button {
    background: var(--color-accent);
    border: none;
    color: #000;
    padding: 0 0.85rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: var(--font-body);
    font-weight: 600;
    /* No border-radius — overflow:hidden on the form clips the shape cleanly */
    transition: filter 0.18s ease;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.top-nav__search button:hover {
    filter: brightness(1.15);
}

.nav-icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: var(--color-muted);
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: 8px;
    transition: color 0.15s ease, background 0.15s ease;
}

.nav-icon-btn:hover {
    color: var(--color-accent);
    background: rgba(200, 135, 42, 0.1);
}

.nav-cart-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--color-pop);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-body);
    pointer-events: none;
    line-height: 1;
}

/* ===== FLYOUT PANELS ===== */
.flyout-panel {
    position: absolute;
    top: calc(var(--nav-height) - 4px);
    background: rgba(26, 22, 18, 0.98);
    border: 1px solid rgba(200, 135, 42, 0.25);
    border-top: 2px solid var(--color-accent);
    border-radius: 0 0 12px 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    padding: 1.25rem;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1001;
}

.flyout-panel.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Browse flyout — anchored left */
.flyout-browse {
    left: 0;
    width: 520px;
}

/* Account flyout — anchored right */
.flyout-account {
    right: 0;
    width: 360px;
}

/* ===== FLYOUT GAME CARDS (Browse) ===== */
.flyout-game-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.flyout-game-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    background: rgba(14, 12, 10, 0.5);
    border: 1px solid rgba(200, 135, 42, 0.15);
    border-radius: 8px;
    text-decoration: none !important;
    color: var(--color-text);
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.flyout-game-card:hover {
    border-color: var(--color-accent);
    background: rgba(200, 135, 42, 0.07);
    transform: translateY(-2px);
    color: var(--color-text);
}

.flyout-game-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.flyout-game-icon.icon-fab  { background: rgba(200,135,42,0.15); color: var(--color-accent); }
.flyout-game-icon.icon-mtg  { background: rgba(76,175,80,0.15);  color: #4caf50; }
.flyout-game-icon.icon-poke { background: rgba(33,150,243,0.15); color: #2196f3; }
.flyout-game-icon.icon-acc  { background: rgba(168,152,128,0.15); color: var(--color-muted); }

.flyout-game-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.flyout-game-name {
    font-family: var(--font-display);
    font-size: 16px;
    letter-spacing: 0.04em;
    color: var(--color-text);
    line-height: 1;
}

.flyout-game-sub {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--color-muted);
}

/* ===== FLYOUT ACCOUNT CARDS ===== */
.flyout-auth-strip {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(200, 135, 42, 0.15);
}

.flyout-auth-btn {
    flex: 1;
    padding: 0.5rem;
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none !important;
    cursor: pointer;
    border: none;
    transition: filter 0.18s ease;
}

.flyout-auth-btn--primary {
    background: var(--color-accent);
    color: #000;
}

.flyout-auth-btn--primary:hover {
    filter: brightness(1.12);
    color: #000;
}

.flyout-auth-btn--secondary {
    background: transparent;
    color: var(--color-muted);
    border: 1px solid rgba(168, 152, 128, 0.35);
}

.flyout-auth-btn--secondary:hover {
    color: var(--color-text);
    border-color: var(--color-muted);
}

.flyout-tool-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.flyout-tool-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: rgba(14, 12, 10, 0.4);
    border: 1px solid rgba(200, 135, 42, 0.12);
    border-radius: 8px;
    text-decoration: none !important;
    color: var(--color-text);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.flyout-tool-card:hover {
    border-color: var(--color-accent);
    background: rgba(200, 135, 42, 0.06);
    color: var(--color-text);
}

/* Admin-only tool cards — subtle red-gold tint to distinguish them */
.flyout-tool-card--admin {
    border-color: rgba(200, 135, 42, 0.22);
    background: rgba(200, 135, 42, 0.04);
}

.flyout-tool-card--admin .flyout-tool-icon {
    background: rgba(200, 135, 42, 0.15);
}

.flyout-tool-card--admin:hover {
    border-color: var(--color-accent);
    background: rgba(200, 135, 42, 0.10);
}

.flyout-tool-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 1rem;
    flex-shrink: 0;
    background: rgba(200, 135, 42, 0.1);
    color: var(--color-accent);
}

.flyout-tool-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.flyout-tool-name {
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
}

.flyout-tool-desc {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--color-muted);
}

/* ===== CART SLIDE PANEL ===== */
.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1099;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.cart-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.cart-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 360px;
    max-width: 95vw;
    background: rgba(26, 22, 18, 0.99);
    border-left: 1px solid rgba(200, 135, 42, 0.25);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.6);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.cart-panel.is-open {
    transform: translateX(0);
}

.cart-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(200, 135, 42, 0.2);
    flex-shrink: 0;
}

.cart-panel__title {
    font-family: var(--font-display);
    font-size: 20px;
    letter-spacing: 0.06em;
    color: var(--color-accent);
    margin: 0;
}

.cart-panel__close {
    background: none;
    border: none;
    color: var(--color-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: color 0.15s ease;
}

.cart-panel__close:hover {
    color: var(--color-text);
}

.cart-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cart-panel__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 0.75rem;
    color: var(--color-muted);
    font-family: var(--font-body);
    font-size: 0.9rem;
    text-align: center;
}

.cart-panel__empty i {
    font-size: 2.5rem;
    color: rgba(200, 135, 42, 0.3);
}

.cart-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.6rem;
    background: rgba(14, 12, 10, 0.5);
    border: 1px solid rgba(200, 135, 42, 0.1);
    border-radius: 8px;
}

.cart-item__img {
    width: 48px;
    height: 67px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    background: rgba(0,0,0,0.3);
}

.cart-item__details {
    flex: 1;
    min-width: 0;
}

.cart-item__name {
    font-family: var(--font-display);
    font-size: 14px;
    letter-spacing: 0.03em;
    color: var(--color-text);
    line-height: 1.2;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item__set {
    font-family: var(--font-body);
    font-size: 0.72rem;
    color: var(--color-muted);
    margin-bottom: 0.25rem;
}

.cart-item__qty-price {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-body);
    font-size: 0.85rem;
}

.cart-item__qty {
    color: var(--color-muted);
}

.cart-item__price {
    color: var(--color-accent);
    font-weight: 700;
}

.cart-item__remove {
    background: none;
    border: none;
    color: rgba(168, 152, 128, 0.5);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.2rem;
    flex-shrink: 0;
    transition: color 0.15s ease;
    margin-top: 2px;
}

.cart-item__remove:hover {
    color: var(--color-danger);
}

.cart-panel__footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(200, 135, 42, 0.2);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    flex-shrink: 0;
}

.cart-panel__total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-body);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.cart-panel__total-label {
    color: var(--color-muted);
}

.cart-panel__total-value {
    font-family: var(--font-accent);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-accent);
}

.btn-cart-clear {
    padding: 0.6rem;
    background: transparent;
    border: 1px solid rgba(140, 58, 46, 0.4);
    border-radius: 999px;
    color: var(--color-muted);
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.btn-cart-clear:hover {
    color: var(--color-danger);
    border-color: var(--color-danger);
}

.btn-cart-checkout {
    display: block;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--color-accent) 0%, #e8a040 100%);
    border: none;
    border-radius: 999px;
    color: #000;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.95rem;
    text-align: center;
    text-decoration: none !important;
    cursor: pointer;
    transition: filter 0.18s ease, box-shadow 0.18s ease;
}

.btn-cart-checkout:hover {
    filter: brightness(1.12);
    box-shadow: 0 0 14px rgba(200, 135, 42, 0.4);
    color: #000;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    :root {
        --nav-height: 72px;
    }

    .top-nav__inner {
        grid-template-columns: auto 1fr auto;
        padding: 0 0.75rem;
        gap: 0.5rem;
    }

    /* On mobile: left has browse only, center is logo, right is icons */
    .top-nav__center {
        justify-content: center;
    }

    .top-nav__logo img {
        height: 52px;
    }

    .nav-btn.nav-btn--mydecks {
        display: none;
    }

    /* Hide text search on mobile — show only the icon */
    .top-nav__search {
        display: none;
    }

    .flyout-browse {
        width: calc(100vw - 1.5rem);
        left: 0.75rem;
    }

    .flyout-game-grid {
        grid-template-columns: 1fr;
    }

    .flyout-account {
        width: calc(100vw - 1.5rem);
        right: 0.75rem;
        left: 0.75rem;
    }

    .cart-panel {
        width: 100vw;
    }
}
