/* Ads of the registry UI: the labelled banner and the ad modal. Tokens come from registry.css. */

/* ------------------------------------------------------------------ banner */

.ad-banner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 970px;
    margin: 24px auto;
    padding: 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.ad-banner--hub {
    max-width: 324px;
}

.ad-banner__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--text-2);
}

.ad-banner__link {
    display: block;
    border-radius: var(--radius-xs);
    overflow: hidden;
}

.ad-banner__image {
    display: block;
    width: 100%;
    height: auto;
}

.ad-banner__note {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--caption);
}

.ad-banner__notice {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-2);
}

/* ------------------------------------------------------------------- modal */

/* One column: a line naming the ad above the creative, a line of the advertiser's notice and the
   actions below it, so the creative takes the height. */
.ad-modal {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    padding: 0;
    border: 0;
    border-radius: calc(var(--radius-lg) + 4px);
    background: var(--card);
    color: var(--text);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
    overflow: auto;
    overscroll-behavior: contain;
}

/* A 4:5 creative: the dialog is as wide as the creative can be while the whole dialog still fits
   the viewport's height (about 250 px go to the lines and buttons around it). */
.ad-modal:has(.ad-modal__panel--portrait) {
    width: min(560px, calc(100vw - 32px), max(280px, calc((100dvh - 250px) * 0.8)));
}

[data-display="serif"] .ad-modal {
    border: 2px solid var(--ink);
}

.ad-modal::backdrop {
    background: rgba(6, 22, 17, 0.66);
    backdrop-filter: blur(3px);
}

[data-display="serif"] .ad-modal::backdrop {
    background: rgba(14, 15, 40, 0.66);
}

.ad-modal__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 6px 6px 16px;
    border-bottom: 1px solid var(--line);
}

.ad-modal__meta {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--text-2);
}

.ad-modal__meta .label--ad {
    margin-right: 8px;
    vertical-align: 1px;
}

.ad-modal__close {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink);
    cursor: pointer;
}

.ad-modal__close:hover {
    background: var(--muted-bg);
}

/* The script focuses the close button when the dialog opens: the ring stays inside the button. */
.ad-modal__close:focus-visible {
    outline-width: 2px;
    outline-offset: -2px;
}

.ad-modal__close-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.ad-modal__media {
    background: var(--muted-bg);
}

.ad-modal__link {
    display: block;
}

.ad-modal__image,
.ad-modal__video {
    display: block;
    width: 100%;
    height: auto;
}

.ad-modal__image {
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.ad-modal__panel--portrait .ad-modal__image {
    aspect-ratio: 4 / 5;
}

.ad-modal__video {
    background: #000;
}

.ad-modal__body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px 12px;
    border-top: 1px solid var(--line);
}

.ad-modal__notice {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-2);
    text-wrap: balance;
}

/* The buttons, then the disclosure on the same line where the dialog is wide enough. */
.ad-modal__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
}

.ad-modal__actions {
    display: flex;
    gap: 8px;
}

.ad-modal__actions .btn {
    min-height: 40px;
    padding: 0 16px;
    font-size: 0.875rem;
}

.ad-modal__why,
.ad-modal__transcript {
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-2);
}

.ad-modal__why {
    margin-left: auto;
}

.ad-modal__why[open] {
    flex-basis: 100%;
    margin-left: 0;
}

/* An upright dialog is too narrow for both on one line: two equal buttons, the disclosure below. */
.ad-modal__panel--portrait .ad-modal__actions {
    flex: 1 1 100%;
}

.ad-modal__panel--portrait .ad-modal__actions .btn {
    flex: 1 1 0;
    padding: 0 12px;
}

.ad-modal__panel--portrait .ad-modal__why {
    margin-left: 0;
}

.ad-modal__why summary,
.ad-modal__transcript summary {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    cursor: pointer;
}

.ad-modal__why summary {
    color: var(--text-2);
    text-decoration: underline;
    text-decoration-color: var(--line);
    text-underline-offset: 3px;
}

.ad-modal__why summary:hover {
    color: var(--ink);
    text-decoration-color: currentColor;
}

.ad-modal__transcript summary {
    font-weight: 600;
    color: var(--ink);
}

.ad-modal__why p,
.ad-modal__transcript p {
    margin: 0 0 4px;
}

@media (max-width: 639px) {
    .ad-modal {
        max-width: 420px;
        border-radius: var(--radius-lg);
    }

    .ad-modal__image {
        aspect-ratio: 4 / 5;
    }

    /* Side by side the labels would break inside the buttons. */
    .ad-modal__actions {
        flex: 1 1 100%;
        flex-direction: column;
    }

    .ad-modal__actions .btn,
    .ad-modal__panel--portrait .ad-modal__actions .btn {
        flex: none;
    }

    .ad-modal__why {
        margin-left: 0;
    }
}
