/* =============================================================================
   Sheet Music Library Styles
   public_html/assets/css/sheet-music.css
   Loaded on /sheet-music/ (list) and /sheet-music/view.php (detail).
   Requires Bootstrap 5 base styles already loaded.
============================================================================= */


/* ── Filter bar (list page) ─────────────────────────────────────────────── */

.sheet-music-filters {
    background: #f8f5f0;
    border-bottom: 1px solid rgba(0, 0, 0, .08);
}

.sheet-music-filters .form-label {
    font-size: .85rem;
}


/* ── Music cards (list page) ────────────────────────────────────────────── */

.music-card {
    border: 1px solid rgba(0, 0, 0, .1);
    transition: box-shadow .2s ease, transform .2s ease;
}

.music-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, .12) !important;
    transform: translateY(-2px);
}

/* Thumbnail container — 1:1 square via CSS aspect-ratio (keeps img in normal flow
   so that loading="lazy" can calculate viewport distance correctly). */
.music-card-thumb-link {
    display: block;
    overflow: hidden;
    border-radius: .375rem .375rem 0 0;   /* match card top corners */
}

.music-card-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background-color: #e9e4dc;            /* warm parchment fallback while loading */
}

/* Thumbnail image — in normal flow so loading="lazy" works */
.music-card-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
}

/* Members-only lock overlay on the thumbnail */
.thumb-lock-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .48);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    gap: 6px;
    pointer-events: none;
}

.thumb-lock-overlay i {
    font-size: 1.75rem;
}

.thumb-lock-overlay span {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    font-weight: 600;
}

/* Card title link */
.music-title a {
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    color: inherit;
}

.music-title a:hover {
    color: var(--bs-primary);
}

/* Metadata badge row */
.music-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
}

.music-meta .badge {
    font-size: .7rem;
    font-weight: 500;
}

/* Key / time signature line */
.music-key-sig {
    font-size: .8rem;
}


/* ── View-mode toggle toolbar ───────────────────────────────────────────── */

.sheet-music-library .btn-group .btn.active {
    background-color: var(--bs-secondary);
    color: #fff;
    border-color: var(--bs-secondary);
}


/* ── List view overrides (#music-items.sm-view-list) ────────────────────────
   Applied by JS when the user clicks the list-view toggle button.
   Only the container class changes — card HTML stays identical.
──────────────────────────────────────────────────────────────────────────── */

/* Container: stack cols vertically, remove Bootstrap row-cols gutter */
#music-items.sm-view-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    /* Reset Bootstrap row negative margins */
    margin-left: 0;
    margin-right: 0;
}

/* Each item spans full width */
#music-items.sm-view-list > .sm-item {
    width: 100%;
    max-width: 100%;
    flex: none;
    padding-left: 0;
    padding-right: 0;
}

/* Card becomes a horizontal flex row */
#music-items.sm-view-list .music-card {
    flex-direction: row;
    align-items: stretch;
}

/* Thumbnail: fixed-width strip on the left */
#music-items.sm-view-list .music-card-thumb-link {
    flex: 0 0 96px;
    border-radius: .375rem 0 0 .375rem;
}

#music-items.sm-view-list .music-card-thumb {
    aspect-ratio: unset;    /* cancel the 1:1 square */
    height: 100%;
    min-height: 96px;
}

/* Card body: horizontal flex — info grows, action sits at the right.
   !important overrides Bootstrap's flex-column utility on the .card-body element. */
#music-items.sm-view-list .card-body {
    flex-direction: row !important;
    align-items: center;
    padding: .5rem .875rem;
    gap: .875rem;
}

#music-items.sm-view-list .sm-list-info {
    flex: 1 1 auto;
    min-width: 0;       /* allow text truncation in narrow viewports */
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: .75rem;
}

/* Column 1: title + composer — grows to fill available space */
#music-items.sm-view-list .sm-col-title {
    flex: 1 1 160px;
    min-width: 0;       /* allow long titles to truncate rather than overflow */
}

/* Column 2: difficulty / instrument / genre badges — fixed width */
#music-items.sm-view-list .sm-col-badges {
    flex: 0 0 auto;
}

/* Column 3: key / time signature — fixed, no wrapping */
#music-items.sm-view-list .sm-col-key {
    flex: 0 0 auto;
    white-space: nowrap;
}

#music-items.sm-view-list .sm-list-action {
    flex: 0 0 auto;
    margin-top: 0 !important; /* override mt-auto used in grid mode */
    padding-top: 0 !important;
}

/* Keep the button from stretching to 100% in list mode */
#music-items.sm-view-list .sm-list-action .btn {
    width: auto;
    white-space: nowrap;
}

/* Tighten spacing inside the info block for the compact row */
#music-items.sm-view-list .music-title {
    font-size: 1rem;
    margin-bottom: .125rem !important;
}

#music-items.sm-view-list .card-subtitle {
    margin-bottom: .25rem !important;
}

#music-items.sm-view-list .music-meta {
    margin-bottom: .25rem !important;
}

#music-items.sm-view-list .music-key-sig {
    margin-bottom: 0 !important;
}

/* Suppress the h-100 height on the card in list mode — not needed */
#music-items.sm-view-list .music-card {
    height: auto !important;
}

/* Responsive: on small phones collapse list view back to card-like rows */
@media (max-width: 479.98px) {
    #music-items.sm-view-list .music-card {
        flex-direction: column;
    }
    #music-items.sm-view-list .music-card-thumb-link {
        flex: none;
        border-radius: .375rem .375rem 0 0;
    }
    #music-items.sm-view-list .music-card-thumb {
        aspect-ratio: 5 / 2;   /* equivalent to the old padding-top: 40% strip */
        height: auto;
    }
    #music-items.sm-view-list .card-body {
        flex-direction: column !important;
        align-items: flex-start;
    }
    #music-items.sm-view-list .sm-list-info {
        flex-direction: column;
        align-items: flex-start;
    }
    #music-items.sm-view-list .sm-col-title,
    #music-items.sm-view-list .sm-col-badges,
    #music-items.sm-view-list .sm-col-key {
        flex: none;
        white-space: normal;
    }
    #music-items.sm-view-list .sm-list-action {
        width: 100%;
        margin-top: .5rem !important;
    }
    #music-items.sm-view-list .sm-list-action .btn {
        width: 100%;
    }
}


/* ── Detail page: PDF viewer (member) ──────────────────────────────────── */

.pdf-viewer-wrap {
    overflow: hidden;
    border-radius: .375rem;
    background: #f0ebe2;
}

.pdf-viewer-frame {
    display: block;
    width: 100%;
    height: 680px;
    border: none;
}


/* ── Detail page: letter-size composite preview (guest) ─────────────────
   Layout: two stacked halves → top half = sheet music image,
           bottom half = login CTA panel.
   Together the container holds a 17:22 portrait-letter proportion.
   On very small screens the fixed aspect-ratio is released and both
   halves become fixed height instead.
──────────────────────────────────────────────────────────────────────── */

.music-preview-composite {
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: .375rem;
    overflow: hidden;
    background: #fff;
    /* 17:22 = portrait letter proportions (8.5 × 11 inches doubled) */
    aspect-ratio: 17 / 22;
}

/* Top half: sheet music preview image */
.preview-music-half {
    flex: 0 0 50%;
    overflow: hidden;
    background: #f0ebe2;
}

.preview-music-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}

/* Bottom half: club branding + login CTA */
.preview-cta-half {
    flex: 0 0 50%;
    background: #faf7f2;
    border-top: 1px solid rgba(0, 0, 0, .08);
}

.preview-cta-logo {
    max-height: 100px;
    max-width: 180px;
    object-fit: contain;
    opacity: .85;
}

.preview-cta-heading {
    font-size: 1.05rem;
    color: #3d2b1a;
}

.preview-cta-text {
    font-size: .875rem;
    max-width: 26ch;
    margin-left: auto;
    margin-right: auto;
}

.preview-join-link {
    font-size: .8rem;
}


/* ── Detail page: metadata panel ────────────────────────────────────────── */

.music-detail-title {
    font-weight: 700;
    line-height: 1.2;
}

.music-meta-table {
    font-size: .9rem;
}

.music-meta-label {
    width: 38%;
    white-space: nowrap;
    padding-left: 0;
    vertical-align: top;
}

.music-description {
    font-size: .9rem;
}

.ls-1 {
    letter-spacing: .05em;
}


/* ── Responsive overrides ────────────────────────────────────────────────── */

@media (max-width: 991.98px) {
    /* On medium screens the two columns stack; constrain the preview width */
    .music-preview-composite {
        max-width: 540px;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 575.98px) {
    /* Release the aspect-ratio lock on tiny phones; fix each half's height */
    .music-preview-composite {
        aspect-ratio: auto;
    }
    .preview-music-half {
        flex: none;
        height: 220px;
    }
    .preview-cta-half {
        flex: none;
        height: 220px;
    }

    /* Smaller iframe on phones */
    .pdf-viewer-frame {
        height: 420px;
    }
}
