/*
 * YT Playlist Cards
 * Responsive grid + card + modal styles.
 *
 * Default class names (per spec):
 *   .ytpc-grid, .ytpc-card, .ytpc-thumbnail, .ytpc-title,
 *   .ytpc-date, .ytpc-description, .ytpc-watch-link
 */

.ytpc-grid {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: 1fr;
    margin: 1.25rem 0;
}

/* Configured-column counts. Mobile defaults to 1 column for any cols-N. */
.ytpc-grid--cols-1 { grid-template-columns: 1fr; }

@media (min-width: 600px) {
    .ytpc-grid--cols-2,
    .ytpc-grid--cols-3,
    .ytpc-grid--cols-4,
    .ytpc-grid--cols-5,
    .ytpc-grid--cols-6 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 900px) {
    .ytpc-grid--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .ytpc-grid--cols-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .ytpc-grid--cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .ytpc-grid--cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1200px) {
    .ytpc-grid--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .ytpc-grid--cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .ytpc-grid--cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.ytpc-card {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .15s ease, box-shadow .15s ease;
}

.ytpc-card:hover,
.ytpc-card:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.ytpc-card-link {
    display: flex;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
    height: 100%;
}

/*
 * Themes (Astra in particular) often style "content" links with
 * `.entry-content a { text-decoration: underline; }` (specificity 0,1,1).
 * That rule beats `.ytpc-card-link` (specificity 0,1,0) and turns every
 * piece of text inside the card — title, date, description, "Watch" — into
 * an underlined link. Match all link states with a two-class selector so
 * we reliably win the cascade without resorting to !important.
 */
.ytpc-card .ytpc-card-link,
.ytpc-card .ytpc-card-link:link,
.ytpc-card .ytpc-card-link:visited,
.ytpc-card .ytpc-card-link:hover,
.ytpc-card .ytpc-card-link:focus,
.ytpc-card .ytpc-card-link:active {
    text-decoration: none;
    box-shadow: none;
}

/*
 * Belt-and-braces: kill any text-decoration the theme might apply to the
 * inline children of the anchor (some themes add `border-bottom` or
 * `text-decoration` to descendants of `.entry-content a`).
 */
.ytpc-card .ytpc-card-link .ytpc-title,
.ytpc-card .ytpc-card-link .ytpc-date,
.ytpc-card .ytpc-card-link .ytpc-channel,
.ytpc-card .ytpc-card-link .ytpc-description,
.ytpc-card .ytpc-card-link .ytpc-watch-link {
    text-decoration: none;
    border-bottom: 0;
}

.ytpc-card-link:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.ytpc-thumbnail-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
}

.ytpc-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ytpc-thumbnail--missing {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #555, #222);
}

.ytpc-play-badge {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding-left: 4px;
    transition: background .15s ease, transform .15s ease;
}

.ytpc-card:hover .ytpc-play-badge,
.ytpc-card:focus-within .ytpc-play-badge {
    background: rgba(204, 24, 30, 0.95);
    transform: scale(1.05);
}

.ytpc-card-body {
    padding: .9rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    flex: 1;
}

.ytpc-title {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.3;
    font-weight: 600;
}

.ytpc-date,
.ytpc-channel {
    margin: 0;
    font-size: .85rem;
    opacity: .75;
}

.ytpc-description {
    margin: .25rem 0 0;
    font-size: .9rem;
    line-height: 1.4;
    opacity: .85;
}

.ytpc-watch-link {
    margin-top: auto;
    padding-top: .5rem;
    font-size: .85rem;
    font-weight: 600;
    color: #cc181e;
    text-transform: uppercase;
    letter-spacing: .03em;
}

/* ------------------------------------------------------------------
 * Inline embed (open="embed")
 * ----------------------------------------------------------------*/

.ytpc-card.is-embedded .ytpc-thumbnail-wrap {
    background: #000;
}

.ytpc-card.is-embedded .ytpc-thumbnail,
.ytpc-card.is-embedded .ytpc-play-badge {
    display: none;
}

.ytpc-card.is-embedded .ytpc-embed-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ------------------------------------------------------------------
 * Notices / errors
 * ----------------------------------------------------------------*/

.ytpc-notice,
.ytpc-error {
    padding: .75rem 1rem;
    border-radius: 6px;
    background: rgba(0, 0, 0, .04);
    margin: 1rem 0;
}

.ytpc-error {
    background: rgba(204, 24, 30, .08);
    color: #7a0f13;
}

/* ------------------------------------------------------------------
 * Modal (open="modal")
 * ----------------------------------------------------------------*/

.ytpc-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    padding: 1.5rem;
    opacity: 0;
    transition: opacity .15s ease;
}

.ytpc-modal.is-open {
    opacity: 1;
}

.ytpc-modal[hidden] {
    display: none;
}

.ytpc-modal__dialog {
    position: relative;
    width: 100%;
    max-width: 960px;
    background: #000;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
    aspect-ratio: 16 / 9;
}

.ytpc-modal__close {
    position: absolute;
    top: -42px;
    right: 0;
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    padding: .25rem .5rem;
}

.ytpc-modal__close:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.ytpc-modal__frame {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 8px;
}

.ytpc-modal__title {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 600px) {
    .ytpc-modal__close {
        top: -36px;
        font-size: 1.4rem;
    }
}
