/*
 * Auto Message Library. Divi styles headings, lists and links aggressively,
 * so sizes, spacing and colors are set explicitly inside .aml.
 * Colors come from the wrapper: --aml-accent, --aml-stage, --aml-cols.
 */

.aml,
.aml *,
.aml-dialog,
.aml-dialog * {
    box-sizing: border-box;
}

.aml {
    --aml-radius: 6px;          /* video, thumbnails, chips */
    --aml-latest-radius: 10px;  /* the latest-message box; set to 0 for an edge-to-edge section */
    --aml-on-accent: #fff;
    font-family: inherit;
}

.aml-sr {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Play button (YouTube-style) ---------- */

.aml-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 68px;
    height: 48px;
    border-radius: 12px;
    background: var(--aml-accent);
    transform: translate(-50%, -50%);
    transition: transform 0.15s ease, filter 0.15s ease;
    pointer-events: none;
}

/* display is set explicitly: some sites hide every ::after (Mosaic's custom CSS has `::after { display: none }`). */
.aml-play::after {
    content: "";
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    border-style: solid;
    border-width: 10px 0 10px 17px;
    border-color: transparent transparent transparent #fff;
    transform: translate(-40%, -50%);
}

.aml-player:hover .aml-play,
.aml-card__link:hover .aml-play {
    transform: translate(-50%, -50%) scale(1.06);
    filter: brightness(1.12);
}

.aml a:focus-visible,
.aml button:focus-visible {
    outline: 3px solid var(--aml-accent);
    outline-offset: 3px;
}

/* ---------- Latest message ---------- */

.aml-latest {
    overflow: hidden;
    border-radius: var(--aml-latest-radius);
}

/* Same gap on every side of the video (in a standard 1080px Divi row: 28px all round). */
.aml-latest__stage {
    background: var(--aml-stage);
    padding: clamp(12px, 2.6vw, 28px);
}

.aml-latest__inner {
    max-width: 1024px;
    margin: 0 auto;
}

.aml-player {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--aml-radius);
    background: #000;
}

.aml-player img,
.aml-player iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    object-fit: cover;
}

.aml-player img {
    transform: scale(1.02); /* same letterbox fix as the grid */
}

.aml-audio {
    display: grid;
    justify-items: center;
    gap: 20px;
    max-width: 560px;
    margin: 0 auto;
}

.aml-audio__art {
    display: block;
    width: 100%;
    max-width: 420px;
    height: auto;
    border-radius: var(--aml-radius);
}

.aml-audio__player {
    display: block;
    width: 100%;
}

.aml-latest__bar {
    background: var(--aml-accent);
    color: var(--aml-on-accent);
    padding: 28px clamp(12px, 2.6vw, 28px); /* sides match the stage so the title lines up with the video */
}

.aml-latest__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 20px 32px;
}

.aml-chip {
    display: inline-block;
    margin: 0 0 10px;
    padding: 6px 10px;
    border-radius: var(--aml-radius);
    background: rgba(255, 255, 255, 0.2);
    color: var(--aml-on-accent);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.aml-chip--live {
    background: #fff;
    color: var(--aml-accent);
}

.aml-chip--live::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 6px;
    border-radius: 50%;
    background: currentColor;
    vertical-align: 1px;
}

.aml .aml-latest__title {
    margin: 0;
    padding: 0;
    color: var(--aml-on-accent);
    font-size: clamp(20px, 2.4vw, 26px);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.aml .aml-latest__date {
    margin: 6px 0 0;
    padding: 0;
    color: var(--aml-on-accent);
    font-size: 15px;
    line-height: 1.4;
    opacity: 0.9;
}

.aml-latest__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* ---------- Buttons ---------- */

.aml .aml-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 160px;
    margin: 0;
    padding: 15px 28px;
    border: 2px solid transparent;
    border-radius: 999px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.1em;
    text-decoration: none;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.aml-latest__bar .aml-btn--solid {
    background: #fff;
    color: var(--aml-accent);
}

.aml-latest__bar .aml-btn--solid:hover {
    background: rgba(255, 255, 255, 0.85);
}

.aml-latest__bar .aml-btn--outline {
    border-color: rgba(255, 255, 255, 0.75);
    background: transparent;
    color: #fff;
}

.aml-latest__bar .aml-btn--outline:hover {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.aml-feed .aml-btn--solid {
    background: var(--aml-accent);
    color: var(--aml-on-accent);
}

.aml-feed .aml-btn--solid:hover {
    filter: brightness(1.1);
}

/* ---------- Feed ---------- */

.aml-feed {
    --aml-title: var(--aml-accent);
    --aml-date: rgba(17, 17, 17, 0.7);
    --aml-gap: 20px;
    padding: 32px 0;
}

.aml-feed--dark {
    --aml-title: #fff;
    --aml-date: rgba(255, 255, 255, 0.65);
}

/* At most --aml-cols columns; fewer as the space narrows (never under 240px wide). */
.aml ul.aml-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(max(240px, calc((100% - (var(--aml-cols) - 1) * var(--aml-gap)) / var(--aml-cols))), 1fr));
    gap: 36px var(--aml-gap);
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.aml .aml-card {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.aml .aml-card[hidden] {
    display: none !important;
}

.aml .aml-card__link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.aml-card__thumb {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--aml-radius);
    background: #000;
}

/*
 * Older YouTube videos only have 4:3 thumbnails with black letterbox bars. object-fit
 * crops them exactly, so rounding can leave a 1px black line; the slight zoom hides it.
 */
.aml-card__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.02);
    transition: transform 0.3s ease;
}

.aml-card__link:hover .aml-card__thumb img {
    transform: scale(1.05);
}

.aml-card__thumb .aml-play {
    width: 60px;
    height: 42px;
    border-radius: 10px;
}

/* Podcast artwork usually has the title painted in the middle; keep the button off it. */
.aml-card--audio .aml-play {
    top: auto;
    bottom: 8px;
    left: 8px;
    width: 44px;
    height: 32px;
    border-radius: 8px;
    transform: none;
}

.aml-card--audio .aml-play::after {
    border-width: 7px 0 7px 12px;
}

.aml-card--audio .aml-card__link:hover .aml-play {
    transform: scale(1.06);
}

.aml-duration {
    position: absolute;
    right: 8px;
    bottom: 8px;
    padding: 3px 6px;
    border-radius: 3px;
    background: rgba(34, 34, 34, 0.81);
    color: #fff;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.aml-card__title {
    display: block;
    margin-top: 14px;
    color: var(--aml-title);
    font-size: 15px;
    font-weight: 800;
    line-height: 1.3;
    text-transform: uppercase;
}

.aml-card__date {
    display: block;
    margin-top: 4px;
    color: var(--aml-date);
    font-size: 12px;
    line-height: 1.4;
}

.aml .aml-more-wrap {
    margin: 36px 0 0;
    padding: 0;
    text-align: center;
}

/* ---------- Popup player ---------- */

.aml-dialog {
    width: min(1100px, calc(100vw - 32px));
    max-width: none;
    max-height: none;
    margin: auto;
    padding: 0;
    border: 0;
    overflow: visible;
    background: #000;
    color: #fff;
}

.aml-dialog--audio {
    width: min(560px, calc(100vw - 32px));
    background: var(--aml-stage, #111);
}

.aml-dialog::backdrop {
    background: rgba(0, 0, 0, 0.85);
}

.aml-dialog__media {
    position: relative;
    aspect-ratio: 16 / 9;
}

.aml-dialog__media iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.aml-dialog__art {
    display: block;
    width: 100%;
    height: auto;
}

.aml-dialog__audio {
    display: block;
    width: calc(100% - 32px);
    margin: 0 16px 16px;
}

.aml-dialog .aml-dialog__title {
    margin: 0;
    padding: 14px 16px;
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
}

.aml-dialog .aml-dialog__close {
    position: absolute;
    top: -44px;
    right: -4px;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    background: none;
    color: #fff;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
}

/* ---------- Admin hint (only shown to admins when nothing loads) ---------- */

.aml-hint {
    padding: 12px 16px;
    border: 2px dashed #c3c4c7;
    background: #fff;
    color: #1d2327;
    font-size: 14px;
}

@media (max-width: 767px) {
    .aml-latest__actions,
    .aml .aml-btn {
        width: 100%;
    }
    .aml-latest__actions .aml-btn {
        flex: 1 1 140px;
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .aml-play,
    .aml-card__thumb img,
    .aml .aml-btn {
        transition: none;
    }
    .aml-card__link:hover .aml-card__thumb img {
        transform: scale(1.02);
    }
}
