/**
 * Album Filters Component Styles
 * Era filtering, sorting, grid/list view toggle for albums page
 * @version 1.0.0
 */

/* ============================================================
   FILTER BAR
   ============================================================ */

.album-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    background: oklch(0.2 0.005 260);
    border: 1px solid oklch(0.3 0.005 260);
    border-radius: var(--radius-lg, 12px);
    backdrop-filter: blur(8px);

    /* Era filter group */
    & .album-filters__eras {
        display: flex;
        flex-wrap: wrap;
        gap: 0.375rem;
        flex: 1 1 auto;
        min-width: 0;
    }

    /* Sort + View group */
    & .album-filters__controls {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        flex-shrink: 0;
    }
}

/* ============================================================
   ERA PILL BUTTONS
   ============================================================ */

.album-filters__era-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: var(--font-primary, 'Inter', sans-serif);
    color: oklch(0.7 0.01 260);
    background: oklch(0.25 0.005 260);
    border: 1px solid oklch(0.35 0.01 260);
    border-radius: 9999px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 200ms ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;

    &:hover {
        color: oklch(0.9 0.01 260);
        background: oklch(0.3 0.01 260);
        border-color: oklch(0.45 0.01 260);
    }

    &:focus-visible {
        outline: 2px solid var(--accent, #dc2626);
        outline-offset: 2px;
    }

    &[aria-pressed="true"] {
        color: #fff;
        background: var(--accent, #dc2626);
        border-color: var(--accent, #dc2626);
        box-shadow: 0 2px 8px oklch(0.5 0.2 25 / 0.3);
    }
}

/* ============================================================
   SORT DROPDOWN
   ============================================================ */

.album-filters__sort {
    appearance: none;
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: var(--font-primary, 'Inter', sans-serif);
    color: oklch(0.8 0.01 260);
    background-color: oklch(0.25 0.005 260);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.625rem center;
    border: 1px solid oklch(0.35 0.01 260);
    border-radius: var(--radius-md, 8px);
    cursor: pointer;
    transition: all 200ms ease;

    &:hover {
        border-color: oklch(0.45 0.01 260);
        background-color: oklch(0.28 0.005 260);
    }

    &:focus-visible {
        outline: 2px solid var(--accent, #dc2626);
        outline-offset: 2px;
    }

    & option {
        background: oklch(0.2 0.005 260);
        color: oklch(0.85 0.01 260);
    }
}

/* ============================================================
   VIEW TOGGLE (GRID / LIST)
   ============================================================ */

.album-filters__view-toggle {
    display: flex;
    border: 1px solid oklch(0.35 0.01 260);
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
}

.album-filters__view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: none;
    background: oklch(0.25 0.005 260);
    color: oklch(0.6 0.01 260);
    cursor: pointer;
    transition: all 200ms ease;

    & svg {
        width: 1rem;
        height: 1rem;
        stroke: currentColor;
        fill: none;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    &:hover {
        color: oklch(0.85 0.01 260);
        background: oklch(0.3 0.01 260);
    }

    &:focus-visible {
        outline: 2px solid var(--accent, #dc2626);
        outline-offset: -2px;
    }

    &[aria-pressed="true"] {
        color: #fff;
        background: var(--accent, #dc2626);
    }

    & + & {
        border-left: 1px solid oklch(0.35 0.01 260);
    }
}

/* ============================================================
   SHOWING COUNT
   ============================================================ */

.album-filters__count {
    font-size: 0.8125rem;
    color: oklch(0.6 0.01 260);
    padding: 0.25rem 0;
    min-height: 30px; /* measured actual height at desktop: 30px (font 13px + padding 8px) */
    transition: opacity 200ms ease;

    & strong {
        color: oklch(0.85 0.01 260);
        font-weight: 600;
    }
}

/* ============================================================
   ALBUM CARD FILTER TRANSITIONS
   ============================================================ */

.album-card[data-filter-state] {
    transition: opacity 300ms ease, transform 300ms ease;
}

.album-card[data-filter-state="visible"] {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.album-card[data-filter-state="hidden"] {
    opacity: 0;
    transform: scale(0.92);
    pointer-events: none;
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    border: 0;
}

/* ============================================================
   LIST VIEW
   ============================================================ */

.albums-bento-grid.album-view-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;

    & .album-card {
        flex-direction: row;
        align-items: center;
        gap: 1rem;
        aspect-ratio: unset;
        max-width: 100%;
    }

    & .album-cover {
        width: 5rem;
        height: 5rem;
        min-width: 5rem;
        flex-shrink: 0;
        border-radius: var(--radius-md, 8px);
        overflow: hidden;
    }

    & .album-cover img,
    & .album-cover picture img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    & .album-info {
        flex: 1;
        min-width: 0;
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 0.5rem 0;
    }

    & .album-info h3 {
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 1rem;
    }

    & .album-info .album-meta {
        flex-shrink: 0;
        margin: 0;
    }

    & .album-year-badge {
        position: static;
        flex-shrink: 0;
        order: -1;
        font-size: 0.8125rem;
        padding: 0.25rem 0.5rem;
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .album-filters {
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }

    .album-filters__eras {
        order: 2;
        width: 100%;
        gap: 0.3125rem;
    }

    .album-filters__controls {
        order: 1;
        width: 100%;
        justify-content: space-between;
    }

    .album-filters__era-btn {
        padding: 0.3125rem 0.625rem;
        font-size: 0.75rem;
    }

    .albums-bento-grid.album-view-list {
        & .album-cover {
            width: 4rem;
            height: 4rem;
            min-width: 4rem;
        }

        & .album-info {
            flex-direction: column;
            align-items: flex-start;
            gap: 0.25rem;
        }
    }
}

@media (max-width: 480px) {
    .album-filters__view-toggle {
        display: none;
    }
}

/* ============================================================
   LIGHT THEME OVERRIDES
   ============================================================ */

[data-theme="light"] {
    & .album-filters {
        background: oklch(0.96 0.005 260);
        border-color: oklch(0.88 0.005 260);
    }

    & .album-filters__era-btn {
        color: oklch(0.4 0.01 260);
        background: oklch(0.94 0.005 260);
        border-color: oklch(0.85 0.01 260);

        &:hover {
            color: oklch(0.2 0.01 260);
            background: oklch(0.9 0.01 260);
        }

        &[aria-pressed="true"] {
            color: #fff;
            background: var(--accent, #dc2626);
            border-color: var(--accent, #dc2626);
        }
    }

    & .album-filters__sort {
        color: oklch(0.3 0.01 260);
        background-color: oklch(0.96 0.005 260);
        border-color: oklch(0.85 0.01 260);
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234b5563' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");

        & option {
            background: #fff;
            color: oklch(0.2 0.01 260);
        }
    }

    & .album-filters__view-btn {
        background: oklch(0.96 0.005 260);
        color: oklch(0.45 0.01 260);

        &:hover {
            color: oklch(0.2 0.01 260);
            background: oklch(0.92 0.01 260);
        }

        &[aria-pressed="true"] {
            color: #fff;
            background: var(--accent, #dc2626);
        }
    }

    & .album-filters__view-toggle {
        border-color: oklch(0.85 0.01 260);
    }

    & .album-filters__view-btn + .album-filters__view-btn {
        border-left-color: oklch(0.85 0.01 260);
    }

    & .album-filters__count {
        color: oklch(0.45 0.01 260);

        & strong {
            color: oklch(0.2 0.01 260);
        }
    }
}
