/* =========================================================================
   MP Media Grid — Frontend styles
   ========================================================================= */

/* -------------------------------------------------------------------------
   Toolbar (search + filters)
   ------------------------------------------------------------------------- */

.mpmg-wrap {
    width: 100%;
    background-color: #000000;
}

.mpmg-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    background-color: #000000;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition:
        max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1),
        opacity    0.35s cubic-bezier(0.4, 0, 0.2, 1),
        transform  0.35s cubic-bezier(0.4, 0, 0.2, 1),
        padding    0.35s cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0s linear 0.45s;
}

.mpmg-toolbar.is-open {
    max-height: 300px;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    padding: 20px;
    transition:
        max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1),
        opacity    0.35s cubic-bezier(0.4, 0, 0.2, 1) 0.05s,
        transform  0.35s cubic-bezier(0.4, 0, 0.2, 1) 0.05s,
        padding    0.35s cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0s linear 0s;
}

/* Search */
.mpmg-search-wrap {
    flex: 1 1 240px;
    position: relative;
}

.mpmg-search {
    width: 100%;
    background: transparent;
    border: 1px solid #ffffff;
    border-radius: 50px;
    color: #ffffff !important;
    font-family: "Anna", sans-serif;
    font-size: 1.2em !important;
    padding: 10px 50px 7px 20px;
    outline: none;
    box-sizing: border-box;
    /* Hide native browser clear button */
    -webkit-appearance: none;
    appearance: none;
}

.mpmg-search::-webkit-search-cancel-button,
.mpmg-search::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.mpmg-search::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.mpmg-search:focus {
    border-color: #ffffff;
}

/* Custom clear button */
.mpmg-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent !important;
    border: none !important;
    border-radius: 0;
    color: #ffffff !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    text-decoration: none;
    transition: opacity 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.mpmg-search-clear:hover {
    opacity: 0.6;
}

/* Filters */
.mpmg-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mpmg-filter {
    background: transparent;
    border: 1px solid #ffffff;
    border-radius: 50px;
    color: #ffffff !important;
    font-family: "Anna", sans-serif;
    font-size: 1em !important;
    padding: 8px 16px 5px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.mpmg-filter:hover,
.mpmg-filter.is-active {
    background-color: #ffffff;
    color: #000000 !important;
}

/* -------------------------------------------------------------------------
   Grid
   ------------------------------------------------------------------------- */

.mpmg-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* mobile : 2 colonnes */
    gap: 1px;
    background-color: rgba(0, 0, 0, 0.9);
}

@media only screen and (min-width: 415px) {
    .mpmg-grid {
        grid-template-columns: repeat(4, 1fr); /* tablet : 4 colonnes */
    }
}

@media only screen and (min-width: 981px) {
    .mpmg-grid {
        grid-template-columns: repeat(8, 1fr); /* desktop : 8 colonnes */
    }
}

/* -------------------------------------------------------------------------
   Item card
   ------------------------------------------------------------------------- */

.mpmg-item {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    background-color: #000000;
}

.mpmg-item--hidden {
    display: none;
}

.mpmg-item--filtered {
    display: none;
}

.mpmg-item__btn {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0 !important;
    border: none;
    background: #000000;
    cursor: pointer;
    overflow: hidden;
}

.mpmg-item__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.3s ease;
}

.mpmg-item__btn:hover .mpmg-item__img,
.mpmg-item__btn:focus .mpmg-item__img {
    transform: scale(1.05);
}

/* Overlay */
.mpmg-item__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mpmg-item__btn:hover .mpmg-item__overlay,
.mpmg-item__btn:focus .mpmg-item__overlay {
    opacity: 1;
}

.mpmg-item__overlay-title {
    font-family: "Anna", sans-serif;
    font-size: 1em;
    line-height: 1.2;
    color: #ffffff;
    text-transform: uppercase;
    text-align: center;
    word-break: break-word;
}

.mpmg-item__no-img {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-family: "Anna", sans-serif;
    font-size: 0.8em;
    padding: 8px;
    text-align: center;
    background: #222222;
}

/* -------------------------------------------------------------------------
   Load more
   ------------------------------------------------------------------------- */

.mpmg-loadmore-wrap {
    display: flex;
    justify-content: center;
    padding: 30px 20px;
    background-color: #000000;
}

.mpmg-loadmore {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid #ffffff;
    border-radius: 50px;
    color: #ffffff !important;
    font-family: "Anna", sans-serif;
    font-size: 1.2em !important;
    padding: 12px 32px 9px;
    cursor: pointer;
    background-color: transparent;
    background-image: linear-gradient(to top, #ffffff 50%, #000000 50%);
    background-size: 100% 201%;
    background-position: 0 0;
    transition: background-position 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.mpmg-loadmore:hover {
    background-position: 0 100%;
    color: #000000 !important;
}

.mpmg-loadmore[hidden] {
    display: none;
}

/* Infinite scroll sentinel */
.mpmg-sentinel {
    height: 1px;
    background: #000000;
}

/* No results */
.mpmg-no-results {
    text-align: center;
    font-family: "Anna", sans-serif;
    font-size: 1.2em;
    color: #ffffff;
    background-color: #000000;
    padding: 40px 20px;
    margin: 0;
}

/* =========================================================================
   Lightbox — native <dialog>
   ========================================================================= */

.mpmg-lightbox {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    padding: 0;
    margin: 0;
    border: none;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    box-sizing: border-box;
}

.mpmg-lightbox[open] {
    display: flex;
}

.mpmg-lightbox::backdrop {
    display: none; /* We handle the backdrop ourselves. */
}

/* Inner layout */
.mpmg-lb__inner {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1200px;
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #111111;
    border: 1px solid #ffffff;
    margin: auto;
}

@media only screen and (min-width: 768px) {
    .mpmg-lb__inner {
        flex-direction: row;
        gap: 32px;
        padding: 32px;
        height: 80vh;
        max-height: 80vh;
        overflow: hidden;
    }
}

/* Media column */
.mpmg-lb__media {
    flex: 0 0 auto;
    width: 100%;
    background: transparent;
    position: sticky;
    top: 0;
    z-index: 0;
}

@media only screen and (min-width: 768px) {
    .mpmg-lb__media {
        flex: 0 0 33.333%;
        width: 33.333%;
        height: 100%;
        overflow-y: auto;
        min-height: 0;
        position: static; /* disable sticky on desktop */
    }
}

.mpmg-lb__img {
    width: 100%;
    height: auto;
    object-fit: contain;
    object-position: top;
    display: block;
}

/* Content column */
.mpmg-lb__content {
    flex: 1 1 auto;
    padding: 32px 28px;
    color: #ffffff;
    font-family: "Anna", sans-serif;
    overflow-y: visible; /* scroll handled by .mpmg-lb__inner on mobile */
    min-height: 0;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    background: #111111;
}

@media only screen and (min-width: 768px) {
    .mpmg-lb__content {
        flex: 0 0 66.666%;
        width: 66.666%;
        height: 100%;
        overflow-y: auto; /* desktop : content column scrolls independently */
    }
}

.mpmg-lb__title {
    font-family: "Anna", sans-serif;
    font-size: 28px;
    font-weight: 500;
    text-transform: uppercase;
    line-height: 1.1;
    margin: 0 0 16px;
}

/* Meta (artist, album, year) */
.mpmg-lb__meta {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 12px;
    row-gap: 6px;
    margin: 0 0 20px;
    font-size: 0.95em;
}

.mpmg-lb__meta dt {
    opacity: 0.55;
    text-transform: uppercase;
    font-size: 0.75em;
    letter-spacing: 0.05em;
    padding-top: 2px;
}

.mpmg-lb__meta dd {
    margin: 0;
}

/* Links (Spotify, YouTube, etc.) */
.mpmg-lb__links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.mpmg-lb__link {
    display: inline-block;
    border: 1px solid #ffffff;
    border-radius: 50px;
    padding: 6px 18px 4px;
    color: #ffffff;
    text-decoration: none;
    font-size: 0.85em;
    text-transform: uppercase;
    transition: background-color 0.2s;
}

.mpmg-lb__link:hover {
    background-color: #ffffff;
    color: #000000;
}

/* Content (post_content) */
.mpmg-lb__body {
    font-size: 0.9em;
    line-height: 1.6;
    opacity: 0.85;
}

.mpmg-lb__body p:first-child {
    margin-top: 0;
}

/* Nav buttons */
.mpmg-lb__prev,
.mpmg-lb__next {
    position: fixed;
    bottom: 24px; /* mobile/tablet : aligned to bottom */
    top: auto;
    transform: none;
    z-index: 10;
    width: 48px;
    height: 48px;
    padding: 0 !important;
    background: #000000;
    border: 1.5px solid rgba(255, 255, 255, 0.6) !important;
    border-radius: 50%;
    color: #ffffff !important;
    font-size: 1.4em !important;
    line-height: 1;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

/* Desktop : vertically centered */
@media only screen and (min-width: 768px) {
    .mpmg-lb__prev,
    .mpmg-lb__next {
        top: 50%;
        bottom: auto;
        transform: translateY(-50%);
    }
}

.mpmg-lb__prev:hover,
.mpmg-lb__next:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: #ffffff !important;
}

@media only screen and (max-width: 767px) {
    .mpmg-lb__prev:hover,
    .mpmg-lb__next:hover {
        background-color: #000000 !important;
    }
}

.mpmg-lb__prev:active,
.mpmg-lb__next:active,
.mpmg-lb__prev:focus,
.mpmg-lb__next:focus,
.mpmg-lb__prev:focus-visible,
.mpmg-lb__next:focus-visible {
    background: #000000 !important;
    border-color: #ffffff !important;
    outline: none !important;
    box-shadow: none !important;
}

.mpmg-lb__prev { left: 12px; }
.mpmg-lb__next { right: 12px; }

/* Close button */
.mpmg-lb__close {
    position: fixed;
    top: 12px;
    right: 16px;
    width: 40px;
    height: 40px;
    padding: 0 !important;
    background: #000000;
    border: 1.5px solid rgba(255, 255, 255, 0.6) !important;
    border-radius: 50%;
    color: #ffffff !important;
    font-size: 1.2em !important;
    line-height: 1;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    transition: background-color 0.2s, border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

.mpmg-lb__close:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: #ffffff !important;
}

@media only screen and (max-width: 767px) {
    .mpmg-lb__close:hover {
        background-color: #000000 !important;
    }
}

.mpmg-lb__close:active,
.mpmg-lb__close:focus,
.mpmg-lb__close:focus-visible {
    background: #000000 !important;
    border-color: #ffffff !important;
    outline: none !important;
    box-shadow: none !important;
}

/* =========================================================================
   Audio player
   ========================================================================= */

.mpmg-lb__audio {
    padding: 16px 0 0;
    color: #ffffff;
    font-family: "Anna", sans-serif;
}

/* Hide native audio element — we build our own controls */
.mpmg-lb__audio-el {
    display: none;
}

.mpmg-lb__audio-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

/* Base styles shared by all 3 audio control buttons */
.mpmg-lb__audio-play,
.mpmg-lb__audio-prev,
.mpmg-lb__audio-next {
    position: relative;
    width: 40px;
    height: 40px;
    padding: 0 !important;
    background: transparent !important;
    border: 1.5px solid rgba(255, 255, 255, 0.6) !important;
    border-radius: 50% !important;
    color: #ffffff !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    -webkit-appearance: none !important;
    appearance: none !important;
    box-sizing: border-box;
    outline: none !important;
    box-shadow: none !important;
    flex-shrink: 0;
}

/* Play triangle (default state) */
.mpmg-lb__audio-play::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 7px 0 7px 12px;
    border-color: transparent transparent transparent #ffffff;
    margin-left: 3px; /* optical centering */
}

/* Pause bars (when playing) */
.mpmg-lb__audio-play.is-playing::before {
    width: 4px;
    height: 14px;
    background: #ffffff;
    border: none;
    border-radius: 1px;
    margin-left: -4px;
    box-shadow: 8px 0 0 #ffffff;
}

/* Prev: left-pointing chevron */
.mpmg-lb__audio-prev::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 9px 6px 0;
    border-color: transparent #ffffff transparent transparent;
    margin-right: 2px;
}

/* Next: right-pointing chevron */
.mpmg-lb__audio-next::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 0 6px 9px;
    border-color: transparent transparent transparent #ffffff;
    margin-left: 2px;
}

/* Larger play button */
.mpmg-lb__audio-play {
    width: 48px !important;
    height: 48px !important;
}

.mpmg-lb__audio-play:hover,
.mpmg-lb__audio-prev:hover,
.mpmg-lb__audio-next:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
    border-color: #ffffff !important;
}

.mpmg-lb__audio-play:focus,
.mpmg-lb__audio-prev:focus,
.mpmg-lb__audio-next:focus,
.mpmg-lb__audio-play:active,
.mpmg-lb__audio-prev:active,
.mpmg-lb__audio-next:active {
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

.mpmg-lb__audio-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75em;
    opacity: 0.8;
}

.mpmg-lb__audio-current,
.mpmg-lb__audio-duration {
    font-size: 2em;
}

.mpmg-lb__audio-seek {
    flex: 1;
    height: 3px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    cursor: pointer;
    outline: none;
    border: none !important;
    padding: 0 !important;
}

.mpmg-lb__audio-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-radius: 50%;
    cursor: pointer;
}

.mpmg-lb__audio-seek::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

/* Tracklist */
.mpmg-lb__tracklist {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
    max-height: 180px;
    overflow-y: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.mpmg-lb__tracklist li {
    padding: 8px 4px;
    font-size: 1.2em;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    counter-increment: track;
}

.mpmg-lb__tracklist li::before {
    content: counter(track) ". ";
    opacity: 0.5;
}

.mpmg-lb__tracklist {
    counter-reset: track;
}

.mpmg-lb__tracklist li:hover {
    color: rgba(255, 255, 255, 0.7);
}

.mpmg-lb__tracklist li.is-active {
    color: #ffffff;
    font-weight: bold;
}

.mpmg-lb__tracklist li.is-active::before {
    content: "▶ ";
    opacity: 1;
}

/* YouTube embed */
.mpmg-lb__youtube {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin-bottom: 16px;
    border-radius: 4px;
    overflow: hidden;
    background: #000;
}
.mpmg-lb__youtube-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* SoundCloud embed */
.mpmg-lb__soundcloud {
    padding-top: 16px;
}

.mpmg-lb__soundcloud-frame {
    width: 100%;
    height: 166px;
    border: none;
    display: block;
}

/* =========================================================================
   Lightbox — mobile overflow fixes
   ========================================================================= */
@media only screen and (max-width: 767px) {
    /* Content column: reduced padding, scroll handled by parent inner */
    .mpmg-lb__content {
        padding: 20px 16px;
        overflow-y: visible;
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
        min-height: 100vh; /* ensures content always covers the sticky media */
    }

    /* Prevent any child from breaking out */
    .mpmg-lb__content * {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Title */
    .mpmg-lb__title {
        font-size: 22px;
        word-break: break-word;
    }

    /* Meta grid: stack on very narrow screens */
    .mpmg-lb__meta {
        grid-template-columns: auto 1fr;
        font-size: 0.85em;
    }

    /* Links: wrap naturally */
    .mpmg-lb__links {
        flex-wrap: wrap;
    }

    /* YouTube: full width, ratio preserved */
    .mpmg-lb__youtube {
        width: 100%;
        margin-bottom: 12px;
    }

    /* Audio controls: reduce sizes slightly */
    .mpmg-lb__audio-controls {
        gap: 8px;
    }

    .mpmg-lb__audio-current,
    .mpmg-lb__audio-duration {
        font-size: 1.4em;
    }

    /* Tracklist: max-height adapts to available space */
    .mpmg-lb__tracklist {
        max-height: 140px;
    }

    /* SoundCloud iframe */
    .mpmg-lb__soundcloud-frame {
        width: 100%;
    }

    /* Body text */
    .mpmg-lb__body {
        font-size: 0.85em;
        word-break: break-word;
    }
}

/* =========================================================================
   Gutenberg editor placeholder
   ========================================================================= */

.mpmg-block-placeholder {
    background: #1e1e1e;
    color: #ffffff;
    padding: 40px;
    text-align: center;
    border-radius: 4px;
}

.mpmg-block-placeholder .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    display: block;
    margin: 0 auto 16px;
}
