/* ============================================================
   CARDS PAGE
============================================================ */
.cards-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
}

.cards-header {
    text-align: center;
    margin-bottom: 2rem;
}

.cards-header h1 {
    margin-bottom: 0.5rem;
}

/* ============================================================
   CONTROLS
============================================================ */
.cards-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.search-wrapper {
    position: relative;
    max-width: 400px;
}

.search-icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    pointer-events: none;
}

.search-wrapper input {
    width: 100%;
    padding: 0.7rem 1rem 0.7rem 2.5rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-wrapper input:focus {
    border-color: var(--accent-gold);
}

/* ============================================================
   FILTER PILLS
============================================================ */
.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pill {
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-panel);
    color: var(--text-secondary);
    font-family: 'Nunito', sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.pill:hover {
    border-color: var(--accent-gold);
    color: var(--text-primary);
}

.pill.active {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    color: #1a1d2e;
    font-weight: 600;
}

.pill-count {
    font-size: 0.75rem;
    opacity: 0.7;
}

.pill.baby:hover           { border-color: #ffb3c6; color: #ffb3c6; }
.pill.basic:hover          { border-color: #ffd966; color: #ffd966; }
.pill.magic-creature:hover { border-color: #4c7dff; color: #4c7dff; }
.pill.magic:hover          { border-color: #ff9d6e; color: #ff9d6e; }
.pill.upgrade:hover        { border-color: #6be36b; color: #6be36b; }
.pill.downgrade:hover      { border-color: #fd3333; color: #fd3333; }
.pill.instant:hover        { border-color: #b38aff; color: #b38aff; }

.results-count {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* ============================================================
   CARD GRID
============================================================ */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 1.2rem;
}

/* ============================================================
   PHYSICAL CARD COMPONENT
   Shared between .db-card (grid) and .modal-full-card (modal)
   Same structure, same styles — only width differs
============================================================ */

.db-card,
.modal-full-card {
    position: relative;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;

    /* Dark layered background — depth without noise */
    background:
        radial-gradient(ellipse at 25% 0%, rgba(255,255,255,0.04) 0%, transparent 55%),
        radial-gradient(ellipse at 75% 100%, rgba(0,0,0,0.3) 0%, transparent 60%),
        linear-gradient(165deg, #21253d 0%, #14172a 55%, #191d2f 100%);

    /* Subtle outer glow + inset shine */
    border: 1.5px solid rgba(255,255,255,0.07);
    box-shadow:
        0 0 0 1px rgba(0,0,0,0.7),
        inset 0 1px 0 rgba(255,255,255,0.05),
        0 6px 24px rgba(0,0,0,0.55);

    transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.db-card:hover {
    transform: translateY(-6px) scale(1.015);
    box-shadow:
        0 0 0 1.5px var(--card-accent),
        inset 0 1px 0 rgba(255,255,255,0.05),
        0 12px 32px rgba(0,0,0,0.65),
        0 0 30px color-mix(in srgb, var(--card-accent) 25%, transparent);
}

/* Top colour bar — gradient for depth */
.db-card-stripe,
.modal-full-stripe {
    height: 5px;
    flex-shrink: 0;
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--card-accent) 55%, #000) 0%,
        var(--card-accent) 40%,
        color-mix(in srgb, var(--card-accent) 70%, #fff) 60%,
        var(--card-accent) 80%,
        color-mix(in srgb, var(--card-accent) 55%, #000) 100%
    );
}

/* Corner tag */
.db-card-corner,
.modal-full-corner {
    position: absolute;
    top: 5px;
    right: 0;
    width: 13px;
    height: 38px;
    background: linear-gradient(180deg,
        var(--card-accent) 0%,
        color-mix(in srgb, var(--card-accent) 30%, transparent) 100%
    );
    border-radius: 0 0 0 7px;
    opacity: 0.85;
    z-index: 2;
}

/* Art image area — 4:3 aspect, vignette fades into body */
.db-card-image,
.modal-full-image {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    flex-shrink: 0;
    background: #0a0d1a;
}

/* Vignette overlay — bottom fade bleeds into card body */
.db-card-image::after,
.modal-full-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        transparent 40%,
        rgba(20, 23, 42, 0.65) 78%,
        rgba(20, 23, 42, 0.97) 100%
    );
    pointer-events: none;
    z-index: 1;
}

/* Left-side edge shadow for depth */
.db-card-image::before,
.modal-full-image::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to right,
        rgba(0,0,0,0.25) 0%,
        transparent 25%
    );
    pointer-events: none;
    z-index: 1;
}

.db-card-art,
.modal-full-art {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.db-card:hover .db-card-art {
    transform: scale(1);
}

.db-card-image span,
.modal-full-image span {
    color: rgba(255,255,255,0.12);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 2;
}

/* Card body — nameplate area */
.db-card-body,
.modal-full-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.55rem 0.75rem 0.7rem;
    gap: 0;
    position: relative;

    /* Very subtle parchment warmth */
    background: linear-gradient(180deg,
        rgba(255, 240, 200, 0.025) 0%,
        rgba(255, 255, 255, 0.01) 100%
    );
}

/* Ruled line across top of nameplate — tinted by card type */
.db-card-body::before,
.modal-full-body::before {
    content: '';
    display: block;
    height: 1px;
    margin-bottom: 0.5rem;
    background: linear-gradient(90deg,
        transparent 0%,
        color-mix(in srgb, var(--card-accent) 45%, transparent) 25%,
        color-mix(in srgb, var(--card-accent) 60%, transparent) 50%,
        color-mix(in srgb, var(--card-accent) 45%, transparent) 75%,
        transparent 100%
    );
}

/* Card name */
.db-card-name,
.modal-full-name {
    font-family: 'Cinzel', serif;
    font-size: 0.84rem;
    font-weight: 700;
    color: #ede0c0;
    line-height: 1.25;
    letter-spacing: 0.2px;
    margin-bottom: 0.25rem;
}

/* Type label — small inset banner */
.db-card-type,
.modal-full-type {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    font-size: 0.58rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    color: var(--card-accent);
    background: color-mix(in srgb, var(--card-accent) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--card-accent) 28%, transparent);
    border-radius: 3px;
    padding: 1px 6px 2px;
    margin-bottom: 0.45rem;
}

/* Description area — thin divider above */
.db-card-desc-wrap,
.modal-full-desc-wrap {
    border-top: 1px solid rgba(255,255,255,0.055);
    padding-top: 0.38rem;
    margin-top: 0.05rem;
}

.db-card-desc,
.modal-full-desc {
    font-size: 0.69rem;
    color: rgba(255,255,255,0.48);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Bottom-left corner ornament */
.db-card::before,
.modal-full-card::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 16px;
    height: 16px;
    border-left: 1.5px solid color-mix(in srgb, var(--card-accent) 35%, transparent);
    border-bottom: 1.5px solid color-mix(in srgb, var(--card-accent) 35%, transparent);
    border-radius: 0 0 0 10px;
    pointer-events: none;
    z-index: 3;
}

/* Bottom-right corner ornament */
.db-card::after,
.modal-full-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    border-right: 1.5px solid color-mix(in srgb, var(--card-accent) 35%, transparent);
    border-bottom: 1.5px solid color-mix(in srgb, var(--card-accent) 35%, transparent);
    border-radius: 0 0 10px 0;
    pointer-events: none;
    z-index: 3;
}

/* ============================================================
   MODAL OVERLAY + PANEL
============================================================ */
.card-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.82);
    backdrop-filter: blur(5px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s;
}

.card-modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.card-modal {
    background: linear-gradient(145deg, #1e2235 0%, #14172a 100%);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 18px;
    padding: 2rem;
    max-width: 540px;
    width: 100%;
    display: flex;
    gap: 2rem;
    position: relative;
    transform: scale(0.93) translateY(10px);
    transition: transform 0.28s cubic-bezier(0.34, 1.5, 0.64, 1);
    align-items: flex-start;
    box-shadow:
        0 0 0 1px rgba(0,0,0,0.6),
        0 28px 70px rgba(0,0,0,0.75);
}

.card-modal-overlay.open .card-modal {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.09);
    color: rgba(255,255,255,0.35);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s;
    z-index: 10;
}

.modal-close:hover {
    background: #c0392b;
    color: #fff;
    border-color: #c0392b;
}

/* Modal preview card — fixed width, no hover lift */
.modal-full-card {
    width: 155px;
    flex-shrink: 0;
    cursor: default;
}

.modal-full-card:hover {
    transform: none;
    box-shadow:
        0 0 0 1px rgba(0,0,0,0.7),
        inset 0 1px 0 rgba(255,255,255,0.05),
        0 6px 24px rgba(0,0,0,0.55);
}

/* Modal info panel */
.modal-card-info {
    flex: 1;
    min-width: 0;
    padding-top: 0.15rem;
}

.modal-card-info h2 {
    font-family: 'Cinzel', serif;
    font-size: 1.15rem;
    color: #ede0c0;
    margin-bottom: 0.55rem;
    padding-right: 2.5rem;
    line-height: 1.3;
}

.modal-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.75rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    border: 1px solid;
    margin-bottom: 0.9rem;
    font-family: 'Nunito', sans-serif;
}

.modal-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 0.65rem 0;
}

.modal-description {
    font-size: 0.88rem;
    color: rgba(255,255,255,0.58);
    line-height: 1.65;
    margin-bottom: 1rem;
}

.modal-copies {
    font-size: 0.75rem;
    color: var(--accent-gold);
    font-family: 'Cinzel', serif;
    opacity: 0.75;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 600px) {
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .card-modal {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 1.5rem;
    }

    .modal-full-card {
        width: 150px;
    }

    .modal-full-card:hover { transform: none; }

    .modal-card-info h2 {
        padding-right: 2rem;
    }
}

@media (max-width: 400px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
