/*
 * Grid-specific styles – cards, badges, rarity, sort pop-over, responsive rules
 * --------------------------------------------------
 * 2024-06 – added .sort-dir-pill to mirror .sort-pill visuals
 */

body,
main,
.max-w-7xl.mx-auto,
.max-w-7xl.mx-auto.p-4 {
    padding-bottom: 20px;
}

.flex select { height: 42px; }
.chevron     { height: 42px; }

/* ------------------------------------------------------------------
   POP-OVER BUTTON UNIFICATION
   ------------------------------------------------------------------ */
#sortPop {
    z-index: 999;
}
#export-backdrop {
    z-index: 999;
}

#sortPop button {                      /* every button in the pop-over */
  background-color: transparent;
  border-color: #52525b;               /* zinc-600 */
  color: #a1a1aa;                      /* zinc-400 */
  transition: none;                    /* instant swap, no half-colours */
}

#sortCancelBottom:hover, #sortApply:hover {
  color: #ffffff;
}

#sortPop button.selected {             /* active pill (ASC or DESC or field) */
  background-color: #f59e0b;           /* amber-500 */
  border-color: #f59e0b;
  color: #000;
}

#saveToast {
    white-space: nowrap;
}

/* give the search form a positioning context */
form.mb-2.flex { position: relative; }

/* ==========================================================================
   Base Card Styles
   ========================================================================== */
.card-thumbnail {
    position: relative;
    aspect-ratio: 2.5 / 3.5;
    border-radius: 16px;
    background: url('assets/imgs/card_back.jpg') center/cover no-repeat;
    box-shadow: 0 0 6px 2px #505050;
}

.card-thumbnail img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;          /* hidden until loaded */
    transition: opacity .3s;
}

.card-thumbnail img.loaded { opacity: 1; }

/* ==========================================================================
   Badges
   ========================================================================== */
.qty-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 4px 8px;
    font-size: 1.5rem;
    line-height: 1;
    border-radius: 0 10px 0 0;
}

.price-badge {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 4px 8px;
    font-size: 1.5rem;
    line-height: 1;
    border-radius: 10px 10px 0 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    z-index: 15;
}

.foil-badge {
    width: 1.5rem;
    height: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fde047 0%, #f59e0b 100%);
    color: #111;
    font-weight: 700;
    font-size: 0.875rem;
    border-radius: 9999px;
}

/* ==========================================================================
   Rarity Colors
   ========================================================================== */
.rarity-common   { color: #ffffff; }
.rarity-uncommon { color: #60a5fa; }
.rarity-rare     { color: #fbbf24; }
.rarity-mythic   { color: #f97316; }
.rarity-special  { color: #ef4444; }
.rarity-bonus    { color: #22c55e; }

/* ==========================================================================
   Card Information Lines
   ========================================================================== */
.mask-icon {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    background-color: currentColor;
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
}

.info-set,
.info-loc {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 0.05rem;
    font-size: 0.875rem;
}

.info-set { padding-top: 0.55rem; }
.info-set .set { color: #fff; font-weight: 600; }
.info-set .num { color: #9ca3af; }

.info-loc .loc-label { color: #fff; }
.info-loc .loc-val   { color: #9ca3af; margin-left: 0.25rem; }

.qty-badge,
.price-badge,
.foil-badge { z-index: 15; }

/* ==========================================================================
   Card Grid Layout
   ========================================================================== */
#card-grid {
    display: grid;
    gap: 0.375rem;
    grid-template-columns: repeat(4, 1fr);
    padding: 0 0.25rem;
}

/* ==========================================================================
   Special Effects
   ========================================================================== */
.card-glow { box-shadow: 0 0 6px 2px #fbbf24; }

.shimmer {
    pointer-events: none;
}

.shimmer::after {
    content: '';
    position: absolute;
    inset: -150%;
    background: conic-gradient(from 0deg, #ff0000 0%, #ff7f00 14.28%, #ffff00 28.56%, #00ff00 42.84%, #0000ff 57.12%, #4b0082 71.4%, #9400d3 85.68%, #ff0000 100%);
    filter: blur(40px);
    animation: rotate 4s linear infinite;
    mix-blend-mode: color-dodge;
    opacity: 0.35;
    z-index: 10;
}

@keyframes rotate { to { transform: rotate(360deg); } }

/* search bar */
form[method="get"] input::placeholder { color: #9ca3af; }

/* ----------  Stat Footer Bar  ---------- */
.stat-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 44px;
    background: rgba(10, 10, 10, .85);
    backdrop-filter: blur(4px);
    border-top: 1px solid #3f3f46;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 1.25rem;
    gap: .5rem;
    font-size: .875rem;
    color: #e4e4e7;
    z-index: 100;
}

.stat-sep {
    width: 6px;
    height: 6px;
    background: #e4e4e7;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    align-self: center;
}

.stat-item { white-space: nowrap; }

#card-grid.has-pagination,
nav.has-pagination { padding-bottom: 52px; }

#sidebar { z-index: 110; }

/* ==========================================================================
   Media Queries
   ========================================================================== */
@media (min-width: 1650px) {
    #card-grid {
        gap: 1.375rem;
        grid-template-columns: repeat(6, 1fr);
        padding: 0 15rem;
    }
    .max-w-7xl.mx-auto {
        max-width: 100% !important;
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
    }
    .qty-badge,
    .price-badge {
        font-size: clamp(0.75rem, 2.5vw, 1.5rem);
        padding: 0.325rem 0.575rem;
    }
    .foil-badge {
        width: clamp(0.9rem, 2.8vw, 1.3rem);
        height: clamp(0.9rem, 2.8vw, 1.3rem);
        font-size: clamp(0.55rem, 1.8vw, 0.8rem);
    }
}

@media (max-width: 1024px) and (max-width: 1649px) {
    body,
    main,
    .max-w-7xl.mx-auto,
    .max-w-7xl.mx-auto.p-4,
    #card-grid {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-top: 5px !important;
        margin-left: 2px !important;
        margin-right: 2px !important;
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (orientation: landscape) and (max-width: 1023px) {
    body,
    main,
    .max-w-7xl.mx-auto,
    .max-w-7xl.mx-auto.p-4,
    #card-grid {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-top: 5px !important;
        margin-left: 2px !important;
        margin-right: 2px !important;
        grid-template-columns: repeat(4, 1fr);
    }
    .qty-badge,
    .price-badge {
        font-size: clamp(0.55rem, 2.5vw, 1.0rem);
        padding: 0.125rem 0.475rem;
    }
    .foil-badge {
        width: clamp(0.7rem, 2.8vw, 0.9rem);
        height: clamp(0.7rem, 2.8vw, 0.9rem);
        font-size: clamp(0.45rem, 1.8vw, 0.7rem);
    }
    .card-thumbnail { border-radius: 6px; }
    .loc-label { font-size: 0; }
    .loc-label::before {
        content: "Loc:";
        font-size: .875rem;
    }
    .sidebar-logo { display: none; }
}

@media (max-width: 639px) {
    body,
    main,
    .max-w-7xl.mx-auto,
    .max-w-7xl.mx-auto.p-4,
    #card-grid {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-top: 5px !important;
        margin-left: 2px !important;
        margin-right: 2px !important;
    }
    #card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    .card-wrapper { width: 100%; }
    .card-thumbnail { border-radius: 8px; }
    .qty-badge,
    .price-badge {
        font-size: clamp(1.3rem, 3.2vw, 1.6rem);
        padding: 0.2rem 0.4rem;
    }
    .foil-badge {
        width: clamp(1.1rem, 3.2vw, 1.4rem);
        height: clamp(1.1rem, 3.2vw, 1.4rem);
        font-size: clamp(0.8rem, 2vw, 1.0rem);
    }
    .loc-label { font-size: 0; }
    .loc-label::before {
        content: "Loc:";
        font-size: .875rem;
    }
    .stat-bar { padding: 0 .5rem; }
    .unique-cards-stat { display: none; }
}
