/* ============================================
   Card Component Styles — The 12 Tribes™ TCG
   ============================================ */

/* -- Faction color variables -- */
:root {
    --faction-kingdom:  #D4A017;
    --faction-prophecy: #2563EB;
    --faction-law:      #9CA3AF;
    --faction-wisdom:   #16A34A;
    --faction-wrath:    #DC2626;
    --faction-divine:   #A855F7;

    --faction-kingdom-dark:  #A67C00;
    --faction-prophecy-dark: #1D4ED8;
    --faction-law-dark:      #6B7280;
    --faction-wisdom-dark:   #15803D;
    --faction-wrath-dark:    #B91C1C;
    --faction-divine-dark:   #7C3AED;

    --faction-kingdom-bg:  rgba(212, 160, 23, 0.08);
    --faction-prophecy-bg: rgba(37, 99, 235, 0.08);
    --faction-law-bg:      rgba(156, 163, 175, 0.06);
    --faction-wisdom-bg:   rgba(22, 163, 74, 0.08);
    --faction-wrath-bg:    rgba(220, 38, 38, 0.08);
    --faction-divine-bg:   rgba(168, 85, 247, 0.08);
}

/* -- Card frame -- */
.card-frame {
    --fc: var(--faction-kingdom);
    --fc-dark: var(--faction-kingdom-dark);
    --fc-bg: var(--faction-kingdom-bg);
    position: relative;
    aspect-ratio: 2.5 / 3.5;
    border-radius: 0.75rem;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: linear-gradient(135deg, color-mix(in srgb, var(--fc) 12%, #1A1A2E), #0E0E1A);
    border: 1px solid color-mix(in srgb, var(--fc) 25%, transparent);
}

.card-frame:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 30px -8px color-mix(in srgb, var(--fc) 30%, transparent);
    border-color: color-mix(in srgb, var(--fc) 50%, transparent);
}

/* Faction-specific colors */
.card-frame[data-faction="kingdom"]  { --fc: var(--faction-kingdom);  --fc-dark: var(--faction-kingdom-dark);  --fc-bg: var(--faction-kingdom-bg); }
.card-frame[data-faction="prophecy"] { --fc: var(--faction-prophecy); --fc-dark: var(--faction-prophecy-dark); --fc-bg: var(--faction-prophecy-bg); }
.card-frame[data-faction="law"]      { --fc: var(--faction-law);      --fc-dark: var(--faction-law-dark);      --fc-bg: var(--faction-law-bg); }
.card-frame[data-faction="wisdom"]   { --fc: var(--faction-wisdom);   --fc-dark: var(--faction-wisdom-dark);   --fc-bg: var(--faction-wisdom-bg); }
.card-frame[data-faction="wrath"]    { --fc: var(--faction-wrath);    --fc-dark: var(--faction-wrath-dark);    --fc-bg: var(--faction-wrath-bg); }
.card-frame[data-faction="divine"]   { --fc: var(--faction-divine);   --fc-dark: var(--faction-divine-dark);   --fc-bg: var(--faction-divine-bg); }

/* Card inner layout */
.card-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0.5rem;
}

/* -- Card header (cost + faction badge) -- */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
    flex-shrink: 0;
}

.card-cost {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--fc), var(--fc-dark));
    color: #1A1A2E;
    font-weight: 800;
    font-size: 0.75rem;
    box-shadow: 0 2px 6px color-mix(in srgb, var(--fc) 40%, transparent);
}

.card-faction-badge {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--fc);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    background: color-mix(in srgb, var(--fc) 15%, transparent);
}

/* -- Card art area -- */
.card-art {
    flex: 1 1 0;
    min-height: 0;
    border-radius: 0.5rem;
    margin-bottom: 0.25rem;
    background: color-mix(in srgb, var(--fc) 6%, #0F0F1A);
    border: 1px solid color-mix(in srgb, var(--fc) 12%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.card-art svg {
    width: 2rem;
    height: 2rem;
    color: color-mix(in srgb, var(--fc) 30%, transparent);
}

.card-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* -- Card name -- */
.card-name {
    font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    font-weight: 700;
    font-size: 0.7rem;
    color: #F3F4F6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* -- Type line -- */
.card-type-line {
    font-size: 0.55rem;
    color: var(--fc);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.85;
    margin-bottom: 0.125rem;
}

/* -- Ability text -- */
.card-ability {
    font-size: 0.5rem;
    color: #D1D5DB;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-shrink: 0;
    min-height: 1.4em;
}

/* -- Card footer (ATK/DEF + rarity) -- */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 0.25rem;
    flex-shrink: 0;
}

.card-stats {
    display: flex;
    gap: 0.375rem;
}

.card-stat {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    font-size: 0.6rem;
    font-weight: 700;
}

.card-stat-atk { color: #F87171; }
.card-stat-def { color: #60A5FA; }

.card-stat svg {
    width: 0.625rem;
    height: 0.625rem;
}

/* Rarity indicator */
.card-rarity {
    display: flex;
    gap: 1px;
}

.rarity-pip {
    width: 0.35rem;
    height: 0.35rem;
    border-radius: 50%;
    background: #374151;
}

.rarity-pip.active { background: var(--fc); box-shadow: 0 0 4px color-mix(in srgb, var(--fc) 50%, transparent); }
.rarity-pip.mythic { background: linear-gradient(135deg, #D4A017, #A855F7); box-shadow: 0 0 6px rgba(212, 160, 23, 0.5); }

/* -- List view card -- */
.card-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: color-mix(in srgb, var(--fc) 4%, #16213E);
    border: 1px solid color-mix(in srgb, var(--fc) 15%, transparent);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.card-list-item:hover {
    background: color-mix(in srgb, var(--fc) 8%, #16213E);
    border-color: color-mix(in srgb, var(--fc) 35%, transparent);
}

.card-list-item[data-faction="kingdom"]  { --fc: var(--faction-kingdom); }
.card-list-item[data-faction="prophecy"] { --fc: var(--faction-prophecy); }
.card-list-item[data-faction="law"]      { --fc: var(--faction-law); }
.card-list-item[data-faction="wisdom"]   { --fc: var(--faction-wisdom); }
.card-list-item[data-faction="wrath"]    { --fc: var(--faction-wrath); }
.card-list-item[data-faction="divine"]   { --fc: var(--faction-divine); }

.card-list-cost {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--fc), color-mix(in srgb, var(--fc) 70%, #000));
    color: #1A1A2E;
    font-weight: 800;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-list-info {
    flex: 1;
    min-width: 0;
}

.card-list-name {
    font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    font-weight: 700;
    font-size: 0.875rem;
    color: #F3F4F6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-list-meta {
    font-size: 0.7rem;
    color: #9CA3AF;
    display: flex;
    gap: 0.75rem;
    margin-top: 0.125rem;
}

.card-list-stats {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.card-list-stat {
    font-size: 0.75rem;
    font-weight: 700;
}

/* -- Modal card -- */
.modal-card-art {
    aspect-ratio: 16 / 9;
    border-radius: 0.75rem;
    background: color-mix(in srgb, var(--fc) 6%, #0F0F1A);
    border: 1px solid color-mix(in srgb, var(--fc) 15%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-card-art svg {
    width: 4rem;
    height: 4rem;
    color: color-mix(in srgb, var(--fc) 25%, transparent);
}

/* -- Responsive breakpoints -- */
@media (min-width: 640px) {
    .card-inner { padding: 0.625rem; }
    .card-cost { width: 2rem; height: 2rem; font-size: 0.8rem; }
    .card-name { font-size: 0.8rem; }
    .card-type-line { font-size: 0.6rem; }
    .card-ability { font-size: 0.55rem; }
    .card-stat { font-size: 0.65rem; }
    .card-art svg { width: 2.5rem; height: 2.5rem; }
    .rarity-pip { width: 0.4rem; height: 0.4rem; }
}

@media (min-width: 1024px) {
    .card-inner { padding: 0.75rem; }
    .card-cost { width: 2.25rem; height: 2.25rem; font-size: 0.85rem; }
    .card-name { font-size: 0.85rem; }
    .card-type-line { font-size: 0.625rem; }
    .card-ability { font-size: 0.6rem; -webkit-line-clamp: 3; }
    .card-art svg { width: 3rem; height: 3rem; }
}

/* -- Animations -- */
@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.card-frame, .card-list-item {
    animation: cardFadeIn 0.3s ease forwards;
}

/* Stagger animation for cards */
.card-frame:nth-child(1)  { animation-delay: 0.02s; }
.card-frame:nth-child(2)  { animation-delay: 0.04s; }
.card-frame:nth-child(3)  { animation-delay: 0.06s; }
.card-frame:nth-child(4)  { animation-delay: 0.08s; }
.card-frame:nth-child(5)  { animation-delay: 0.10s; }
.card-frame:nth-child(6)  { animation-delay: 0.12s; }
.card-frame:nth-child(7)  { animation-delay: 0.14s; }
.card-frame:nth-child(8)  { animation-delay: 0.16s; }
.card-frame:nth-child(9)  { animation-delay: 0.18s; }
.card-frame:nth-child(10) { animation-delay: 0.20s; }
.card-frame:nth-child(11) { animation-delay: 0.22s; }
.card-frame:nth-child(12) { animation-delay: 0.24s; }

/* Pagination button styles */
.page-btn {
    min-width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s;
    border: 1px solid #374151;
    color: #9CA3AF;
    background: #16213E;
}

.page-btn:hover:not(:disabled):not(.active) {
    background: #1E3A5F;
    border-color: #4B5563;
    color: #E5E7EB;
}

.page-btn.active {
    background: linear-gradient(135deg, var(--faction-kingdom), var(--faction-kingdom-dark));
    color: #1A1A2E;
    font-weight: 700;
    border-color: var(--faction-kingdom);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Scrollbar styling */
#modal-content::-webkit-scrollbar { width: 6px; }
#modal-content::-webkit-scrollbar-track { background: transparent; }
#modal-content::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
#modal-content::-webkit-scrollbar-thumb:hover { background: #4B5563; }
