/**
 * ============================================================================
 * ROOTS ARCHIVES — CARDS (cards.css)
 * ============================================================================
 *
 * Album cards, release cards, grid card layout, overview cards.
 * ============================================================================
 */


/* ── Base card ─────────────────────────────────────── */

/* Card wrapper with a small top margin (used on many pages) */
.card-section-top {
    margin-top: 1.2rem;
}

/* Album cover aspect ratio on album detail page */
.album-cover-ratio {
    aspect-ratio: 1 / 1;
    min-height: 300px;
}

.card {
    border: 1px solid var(--color-card-border);
    border-radius: var(--radius-card);
    transition: transform 0.2s, box-shadow 0.2s;
    background-color: var(--color-card-bg);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.card-title a {
    color: var(--color-primary);
    font-weight: 600;
}

.card-title a:hover {
    color: var(--color-dark);
}

.card .card-body {
    padding: var(--spacing-card);
}

/* Card body with nav-tabs — remove horizontal padding */
.card .card-body:has(> .nav-tabs) {
    padding-left: 0;
    padding-right: 0;
}

.card .card-body .nav-tabs ~ * {
    padding-left: var(--spacing-card);
    padding-right: var(--spacing-card);
}


/* ── Card header ───────────────────────────────────── */

.card-header.section-header {
    background-color: var(--color-section-header-bg);
    color: var(--color-section-header-text);
    border-bottom: 2px solid var(--color-dark);
}

.card-header.section-header h2,
.card-header.section-header h3,
.card-header.section-header h5 {
    margin: 0;
    color: var(--color-section-header-text);
}

.card-header.section-header .btn-toggle-view {
    color: var(--color-section-header-text);
    border-color: var(--color-section-header-text);
}
.card-header.section-header .btn-toggle-view:hover {
    background-color: var(--color-section-header-text);
    color: var(--color-section-header-bg);
}

/* Force stat card headers to 2 lines minimum (desktop) */
@media (min-width: 992px) {
    .card-header {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 3.6em;
        padding: 0.5em 0.5em;
    }

    .card-header h2 {
        margin: 0;
        width: 100%;
        text-align: center;
        font-size: 0.95rem;
        font-weight: 600;
        line-height: 1.3em;
        min-height: 2.6em;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}


/* ── Album card ────────────────────────────────────── */

.album-card-col {
    display: flex;
    min-width: 0;
}

.album-card {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    background-color: var(--color-card-bg);
}

.album-card .ratio {
    width: 100%;
}

.album-card .card-img-top {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.album-card .bg-light {
    width: 100%;
    height: 100%;
}

/* Album card placeholder when no cover */
.album-card-placeholder {
    height: 100%;
}

.album-card-placeholder-icon {
    font-size: 40px;
    color: var(--color-muted);
}

/* Album card body — compact layout */
.album-card .card-body {
    gap: 0.17rem;
    padding: 0.6rem;
}

/* Album card title row */
.album-card-title-wrap {
    margin-bottom: 0.1rem;
    line-height: 1.35;
}

.album-card-title-link {
    font-size: 0.943rem;
    line-height: 1.35;
}

/* Album card artist row */
.album-card-artist-wrap {
    margin-bottom: 0.13rem;
    line-height: 1.35;
}

.album-card-artist {
    font-size: 0.857rem;
    color: var(--color-primary);
    font-weight: 700;
    line-height: 1.35;
}

.album-card-artist-link {
    color: var(--color-primary);
    text-decoration: none;
    font-size: 0.79rem;
}

.album-card-artist-link:hover {
    text-decoration: underline;
}

/* Album card meta row (label, catno, date) */
.album-card-meta {
    font-size: 0.715rem;
    color: var(--color-muted);
    margin-bottom: 0.13rem;
    line-height: 1.35;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.17em;
}

.album-card-label {
    font-size: 0.715rem;
    color: var(--color-muted);
    font-weight: 700;
}

.album-card-catno,
.album-card-date {
    font-size: 0.715rem;
    color: var(--color-secondary);
}

.album-card-date {
    margin-left: 0.3em;
}


/* ── Card images ───────────────────────────────────── */

.card-img-top {
    aspect-ratio: 1 / 1;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.card:hover .card-img-top {
    transform: scale(1.05);
}


/* ── Placeholder cover ─────────────────────────────── */

.placeholder-cover {
    min-height: 300px;
    background: linear-gradient(135deg, var(--color-light) 0%, var(--color-secondary) 100%);
}


/* ── Grid view cards — flexbox alignment ───────────── */

.row.g-4 > [class*='col-'] {
    display: flex;
    flex-direction: column;
}

.row.g-4 .card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.row.g-4 .card .card-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: var(--spacing-card);
}

/* Card title in grid — 2 lines max */
.row.g-4 .card .card-title,
.album-card .card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    min-height: 2.6em;
    max-height: 2.6em;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
}

/* Card title link — dark brown */
.row.g-4 .card .card-title a,
.album-card .card-title a {
    color: var(--color-page-title);
    text-decoration: none;
}

.row.g-4 .card .card-title a:hover,
.album-card .card-title a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

/* Hide card subtitle in grid */
.row.g-4 .card .card-text.small,
.album-card .card-text.small {
    display: none;
}

/* Push footer to bottom */
.row.g-4 .card-body > div:last-of-type,
.row.g-4 .card-body > p:last-child {
    margin-top: auto;
}

.row.g-4 .card > a:first-child {
    flex-shrink: 0;
}

/* Grid spacing */
.row.g-4 {
    display: flex;
    flex-wrap: wrap;
}


/* ── Release card v2 ───────────────────────────────── */

.release-card-v2 {
    border: 1px solid var(--color-card-border);
    background: var(--color-card-bg);
    border-radius: var(--radius-card);
}

.release-card-v2 .card-header {
    background: var(--color-accent);
}


/* ── Overview / stats cards ────────────────────────── */

.overview-card {
    border: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border-radius: 6px;
}

.overview-card .card-body {
    padding: 0.25rem 0.5rem;
}

.overview-card h3 {
    color: var(--color-stat-number);
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.overview-stat {
    text-align: center;
    padding: 0.25rem 0.3rem;
    border-right: 1px solid var(--color-overview-border);
    transition: all 0.2s ease;
}

.overview-stat:hover {
    background-color: #FFFEF9;
    transform: translateY(-1px);
}

.overview-stat:last-child {
    border-right: none;
}

.stat-number {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-stat-number);
    line-height: 1;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--color-stat-label);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 0.1rem;
    font-weight: 500;
}


/* ── Album header ──────────────────────────────────── */

.album-header {
    animation: fadeInUp 0.6s ease-out;
    padding-bottom: 1rem;
    border-bottom: none;
    margin-bottom: 2rem;
}

.album-header h1 {
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.album-header h2 {
    color: var(--color-muted);
}

.album-header .page-title {
    margin-bottom: 1rem;
}

/* Fade-in animation on album page cards */
.row > .col-lg-8 > .card {
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
}

.row > .col-lg-8 > .card:nth-child(1) { animation-delay: 0.1s; }
.row > .col-lg-8 > .card:nth-child(2) { animation-delay: 0.2s; }
.row > .col-lg-8 > .card:nth-child(3) { animation-delay: 0.3s; }


/* ── Expand/Collapse buttons ──────────────────────── */

.expand-collapse-btns {
    display: flex;
    gap: 0.5rem;
}

.expand-collapse-btns .btn {
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
    white-space: nowrap;
    background-color: white;
    color: var(--color-primary);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.expand-collapse-btns .btn:hover {
    background-color: var(--color-accent);
    color: var(--color-dark);
    border-color: var(--color-accent);
}

.expand-collapse-btns .btn i {
    font-size: 0.9rem;
}

/* Release content toggle */
.release-content {
    display: none;
}

.release-content.open {
    display: block;
}


/* ── Responsive — mobile card overrides ────────────── */

@media (max-width: 768px) {
    /* Card header text */
    .card-header h2 {
        font-size: 0.85rem;
    }

    /* Expand/collapse buttons */
    .expand-collapse-btns {
        flex-direction: column;
        gap: 0.25rem;
    }

    .expand-collapse-btns .btn {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
    }

    /* Overview stats mobile */
    .stat-number {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .overview-stat {
        padding: 0.6rem 0.25rem;
    }

    /* Album header mobile */
    .album-header h1 {
        font-size: 1.75rem;
    }

    .album-header h2 {
        font-size: 1.25rem;
    }

    /* Credits section titles — smaller on mobile */
    .card-body .row.g-4 .card-title,
    .mb-5 .row.g-4 .card-title,
    .mb-4 .row.g-4 .card-title {
        font-size: 0.72rem;
        line-height: 1.2;
        min-height: 1.7em;
    }

    .card-body .row.g-4 .card-text,
    .mb-5 .row.g-4 .card-text,
    .mb-4 .row.g-4 .card-text,
    .card-body .row.g-4 .card-text small,
    .mb-5 .row.g-4 .card-text small,
    .mb-4 .row.g-4 .card-text small {
        font-size: 0.65rem;
        line-height: 1.1;
    }

    /* Album cards — all consistent on mobile */
    .col-6 .album-card .card-body,
    .album-card .card-body {
        padding: 0.3rem;
    }

    .col-6 .album-card .card-title,
    .album-card .card-title,
    .col-6 .card-title,
    .row.g-3 .card-title,
    .row.g-4 .card-title {
        font-size: 0.75rem;
        line-height: 1.2;
        height: auto;
        min-height: 1.8em;
        margin-bottom: 0.3rem;
        font-weight: 600;
    }

    .col-6 .card-text,
    .album-card .card-text,
    .row.g-3 .card-text,
    .row.g-4 .card-text {
        font-size: 0.72rem;
        line-height: 1.2;
    }

    .col-6 .card-text small,
    .album-card .card-text small,
    .row.g-3 .card-text small,
    .row.g-4 .card-text small {
        font-size: 0.72rem;
        line-height: 1.2;
    }

    .col-6 .d-flex.justify-content-between,
    .album-card .d-flex.justify-content-between,
    .row.g-3 .d-flex.justify-content-between,
    .row.g-4 .d-flex.justify-content-between {
        gap: 0.3rem;
        margin-bottom: 0.5rem;
    }

    /* Artist page: force grid 2-col for discography on mobile */
    #albums-grid,
    #compilations-grid {
        display: flex;
        row-gap: 1rem;
        --bs-gutter-y: 1rem;
    }

    #albums-list,
    #compilations-list {
        display: none;
    }

    #albums-grid .col-6,
    #compilations-grid .col-6 {
        flex: 0 0 50%;
        max-width: 50%;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        padding-top: 0;
        padding-bottom: 0;
        margin-top: 0;
        margin-bottom: 0;
    }

    #albums-grid .album-card,
    #compilations-grid .album-card {
        margin-bottom: 0;
    }

    #albums-grid .card-body,
    #compilations-grid .card-body {
        padding: 0.5rem;
    }

    #albums-grid .card-title,
    #compilations-grid .card-title {
        font-size: 0.75rem;
        line-height: 1.2;
        height: auto;
        min-height: 1.8em;
    }

    #albums-grid .card-text,
    #compilations-grid .card-text,
    #albums-grid .card-text small,
    #compilations-grid .card-text small {
        font-size: 0.72rem;
        line-height: 1.2;
    }

    #albums-grid .d-flex.justify-content-between,
    #compilations-grid .d-flex.justify-content-between {
        gap: 0.3rem;
        margin-bottom: 0.5rem;
    }

    #albums-grid .album-card .card-body,
    #compilations-grid .album-card .card-body {
        padding-top: 0.4rem;
        padding-bottom: 0.4rem;
    }
}
