/* Page wrapper is the shared .page (main.css) — #card-drawer sizes against it. */

.search-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-wrap input {
    width: 260px;
}

/* ── Set Dropdown ── */
.set-dropdown-wrap {
    position: relative;
}

/* Shared .btn .btn--ghost .btn--mono (components.css). */
.set-dropdown-btn {
    font-size: 0.78rem;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.set-dropdown-btn.open {
    border-color: var(--border-focus);
}

/* .set-dropdown-arrow is the shared .dropdown-arrow (components.css). */

/* Shared .menu (components.css). */
.set-dropdown-menu {
    left: 0;
    min-width: 220px;
    max-width: 660px;
}

#set-dropdown-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    max-height: 400px;
    overflow-y: auto;
}

#set-dropdown-options::-webkit-scrollbar {
    width: 6px;
}

#set-dropdown-options::-webkit-scrollbar-track {
    background: var(--bg-card);
}

#set-dropdown-options::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

#set-dropdown-options::-webkit-scrollbar-thumb:hover {
    background: var(--border-focus);
}

.set-dropdown-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.set-dropdown-option:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.set-dropdown-option.selected {
    color: var(--accent);
}

.set-toggle {
    width: 16px;
    height: 16px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
}

.set-dropdown-option.selected .set-toggle {
    background: var(--accent);
    border-color: var(--accent);
}

/* Shared .btn .btn--primary (components.css). */
.btn-search {
    font-size: 0.85rem;
    padding: 10px 20px;
    white-space: nowrap;
}

.cards-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding-top: 16px;
    padding-left: 32px;
    padding-right: 32px;
    border-bottom: none;
}

.cards-header-left {
    display: flex;
    align-items: center;
}

/* ── Default bin picker ── */
.default-bin-wrap {
    position: relative;
}

/* Shared .btn .btn--ghost (components.css) + muted resting colour + accent hover. */
.default-bin-btn {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.default-bin-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.default-bin-icon {
    font-size: 0.9rem;
    opacity: 0.6;
}

.default-bin-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    z-index: 100;
    overflow: hidden;
    box-shadow: var(--shadow-panel);
}

.default-bin-menu-item {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    color: var(--text);
    padding: 9px 14px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.default-bin-menu-item:hover {
    background: var(--bg-hover);
}

.default-bin-menu-item.active {
    color: var(--accent);
}

.default-bin-check {
    font-size: 0.75rem;
    color: var(--accent);
    opacity: 0;
}

.default-bin-menu-item.active .default-bin-check {
    opacity: 1;
}

.cards-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    height: 100%;
}

.card-grid-wrap {
    flex: 1;
    overflow-y: auto;
    height: 100%;
    min-width: 0;
}

.card-grid-wrap::-webkit-scrollbar {
    width: 10px;
}

.card-grid-wrap::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 10px;
}

.card-grid-wrap::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
    border: 2px solid var(--bg);
}

.card-grid-wrap::-webkit-scrollbar-thumb:hover {
    background: var(--border-focus);
}

.card-grid {
    padding: 32px;
    display: grid;
    grid-template-columns: repeat(auto-fill, 255px);
    gap: 20px;
    align-content: start;
    justify-content: center;
}

.card-tile {
    opacity: 0;
    transform: translateY(10px);
    animation: revealUp 0.3s ease forwards;
    cursor: pointer;
}

.card-tile.animated {
    animation: none;
    opacity: 1;
    transform: none;
}

.card-tile img {
    width: 100%;
    border-radius: 14px;
    display: block;
    transition: transform 0.2s, opacity 0.2s ease;
}

/* img scale → see .card-tile--guest/authed below */

/* ── Image loading placeholder ──
   Card art now downloads lazily on first request (see get_image in app.py)
   instead of being pre-fetched during sync, so a big result grid used to sit
   on collapsed, blank tiles that popped in one by one as each image arrived.
   Reserving the real card aspect ratio (5:7, confirmed against the API's own
   images) up front means every tile has a stable box from the moment it's
   inserted, with a spinner filling that box until buildCardTile's inline
   onload removes it (onerror already replaces the whole tile, spinner
   included, with .card-tile-missing). Scoped to #card-results specifically —
   not the shared .edition-tile-wrap/.card-tile classes Inventory/Decks/
   Prices/Drawer also use — since search results are where dozens of images
   can be loading at once; those other surfaces show far fewer at a time.

   The spinner-to-image handoff is a crossfade rather than an instant swap —
   revealTileImage (cards.js) drives it via fadeSwap (animation.js), the same
   fade-out/mutate/fade-in mechanic page navigation and the drawer's edition
   switch already use. This overrides the shared .fade-out/.fade-in (main.css)
   to an opacity-only fade — `transform: none` cancels the shared rule's
   translateY, which would jolt the spinner inside its clipped frame. */
#card-results .edition-tile-wrap {
    position: relative;
    aspect-ratio: 5 / 7;
    background: var(--bg-card);
    border-radius: 14px;
    overflow: hidden;
}

#card-results .edition-tile-wrap img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
}

#card-results .edition-tile-wrap img.tile-img-loaded {
    opacity: 1;
}

.tile-img-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: inherit;
    pointer-events: none;
    opacity: 1;
}

.tile-img-spinner.fade-out {
    opacity: 0;
    transform: none;
    transition: opacity 0.15s ease;
}

.tile-img-spinner.fade-in {
    opacity: 1;
    transform: none;
    transition: opacity 0.2s ease;
}

.tile-img-spinner svg {
    width: 26px;
    height: 26px;
    color: var(--text-muted);
    opacity: 0.6;
    animation: tile-img-spin 0.85s linear infinite;
}

/* Parked by queueTileImageLoad (tiles.js): the tile is too far from the
   viewport for its image to have been requested yet. Keep the frame but
   hold the spin — a long deck/bin/search list can park hundreds of these
   at once, and none of them are actually loading. The spin resumes when
   the tile scrolls near view and its load starts. */
.tile-img-spinner--parked svg {
    animation: none;
    opacity: 0.3;
}

/* ── Featured sets — shown in #card-results before any search is made
   (see loadFeaturedSets in cards.js). Landscape banners rather than the
   portrait card art .card-grid's 255px tracks are sized for, so this
   modifier (added alongside .card-grid, not instead of it) widens the
   tracks — kept later in the file so it wins the cascade tie. */
.card-grid--featured {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

.featured-set-tile {
    opacity: 0;
    transform: translateY(10px);
    animation: revealUp 0.3s ease forwards;
    cursor: pointer;
    position: relative;
}

.featured-set-tile.animated {
    animation: none;
    opacity: 1;
    transform: none;
}

.featured-set-media {
    position: relative;
    aspect-ratio: 3 / 2;
    border-radius: 14px;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.featured-set-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Taller than the label's own text needs so the dark fade builds up well
   before it reaches the name/prefixes — a short fade over a busy banner
   image left the text sitting right at the color transition, which is
   exactly where it's hardest to read. */
.featured-set-label {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 65%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 14px 16px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.55) 50%, transparent 100%);
    pointer-events: none;
}

.featured-set-name {
    font-family: var(--font-sans);
    font-size: 1.05rem;
    font-weight: 600;
    color: #ffffff;
}

/* Every prefix in the release, "•"-joined (see buildFeaturedSetTile) — can
   run long (e.g. 5 prefixes), so this truncates rather than wrapping and
   inflating the tile's fixed-aspect media area. */
.featured-set-prefixes {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-tile-missing {
    width: 100%;
    aspect-ratio: 3/4;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ── Autocomplete ── */
.autocomplete-wrap {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    z-index: 300;
    overflow: hidden;
}

.autocomplete-item {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text);
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--bg-hover);
    color: var(--accent);
}

.edition-rarity-badge {
    position: absolute;
    bottom: 10px;
    left: 10px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 3px 8px;
    border-radius: 4px;
    pointer-events: none;
    backdrop-filter: blur(4px);
    background: rgba(0, 0, 0, 0.6);
}

/* ═══════════════════════════════════════
   CARD TILE HOVER — GUEST vs AUTHED
   Shared overlay/badge/qty styles → tiles.css
═══════════════════════════════════════ */

.card-tile {
    position: relative;
}

/* Hover-zoom/dim/action-button behavior lives in tiles.css's shared
   .tile-hoverable/.tile-zoom vocabulary — see buildCardTile in cards.js. */

/* ── Card search confirm bar — same style as inventory, anchored to cards-body ── */
#cards-qty-confirm-bar {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
}

/* ── Cards filter button & menu ── */
.cards-filter-wrap {
    position: relative;
}

/* Shared .btn .btn--ghost .btn--mono (components.css). */
.cards-filter-btn {
    font-size: 0.78rem;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.cards-filter-btn.open {
    border-color: var(--border-focus);
}

.cards-filter-btn.active {
    border-color: var(--accent);
    color: var(--accent);
}

/* .cards-filter-arrow is the shared .dropdown-arrow (components.css). */

/* Shared .menu (components.css). */
.cards-filter-menu {
    right: 0;
    min-width: 200px;
}

.cards-filter-section {
    padding: 10px 14px 6px;
    border-bottom: 1px solid var(--border);
}

.cards-filter-section:last-of-type {
    border-bottom: none;
}

/* .cards-filter-section-label is the shared .label .label--muted .label--sm (main.css). */
.cards-filter-section-label {
    margin-bottom: 6px;
}

.cards-filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding-bottom: 6px;
}

/* Shared .btn .btn--subtle .btn--mono (components.css) + full-width row style. */
.cards-filter-clear-btn {
    display: block;
    width: 100%;
    font-size: 0.7rem;
    border: none;
    border-top: 1px solid var(--border);
    border-radius: 0;
    padding: 8px 14px;
    text-align: left;
    letter-spacing: 0.04em;
}

.cards-filter-clear-btn:hover {
    color: var(--error);
}

/* ── Set search progress bar ── */
.cards-set-progress-wrap {
    padding: 12px 32px;
}

.cards-set-progress-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cards-set-progress-track {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.cards-set-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.2s ease;
}

/* Target-section picker hides whenever the bin picker is hidden (logged out) */
#default-bin-wrap.hidden + #target-section-wrap {
    display: none;
}

#target-section-wrap {
    margin-left: 10px;
}

/* Section picker is icon-only; hovering expands to reveal the selection */
#target-section-btn {
    gap: 0;
}

#target-section-label {
    display: inline-block;
    max-width: 0;
    margin-left: 0;
    overflow: hidden;
    white-space: nowrap;
    opacity: 0;
    transition: max-width 0.25s ease, opacity 0.2s ease, margin-left 0.25s ease;
}

#target-section-wrap:hover #target-section-label {
    max-width: 160px;
    margin-left: 7px;
    opacity: 1;
}