/*
 * Ad Manager 3.0 - https://xplaytube.com
 *
 * Neutral by design: surfaces and borders are derived from the surrounding text color,
 * so cards look right on light and dark themes. Override any variable in your theme:
 *   :root { --am-accent: #ff2d55; --am-radius: 8px; --am-img: 140px; }
 */
:root {
    --am-accent: #e5334b;
    --am-accent-text: #fff;
    --am-radius: 14px;
    --am-gap: 16px;
    --am-img: 132px;
}

.am-wrap,
.am-zone,
.am-stats,
.am-form-wrap,
.am-popup {
    box-sizing: border-box;
    line-height: 1.5;
}
.am-wrap *, .am-zone *, .am-stats *, .am-form-wrap *, .am-popup * {
    box-sizing: border-box;
}

/* ---------- Directory grid ---------- */
.am-directory {
    display: grid;
    grid-template-columns: repeat(var(--am-cols, 3), minmax(0, 1fr));
    gap: var(--am-gap);
    margin: 0;
}
.am-zone {
    display: grid;
    gap: var(--am-gap);
    margin: 1.5em 0;
}

/* ---------- Card (row: text left, square image right) ---------- */
.am-card {
    display: flex;
    align-items: stretch;
    gap: 16px;
    padding: 16px;
    border-radius: var(--am-radius);
    background: rgba(128, 128, 128, 0.08);
    background: color-mix(in srgb, currentColor 6%, transparent);
    border: 1px solid rgba(128, 128, 128, 0.25);
    border: 1px solid color-mix(in srgb, currentColor 14%, transparent);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    overflow: hidden;
}
.am-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
    border-color: var(--am-accent);
}
.am-card[hidden] {
    display: none;
}

.am-card__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.am-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    opacity: 0.85;
}
.am-card__meta:empty {
    display: none;
}
.am-card__cat {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.75;
}

.am-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--am-accent);
    color: var(--am-accent-text);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.6;
}

.am-card__title {
    margin: 0;
    font-size: 1.15em;
    line-height: 1.3;
    font-weight: 700;
}
.am-card__title a {
    color: inherit;
    text-decoration: none;
}
.am-card__title a:hover {
    color: var(--am-accent);
}

.am-card__desc {
    margin: 0;
    font-size: 0.93em;
    opacity: 0.8;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.am-card__code {
    font-size: 0.9em;
    overflow-wrap: anywhere;
}

.am-card__foot {
    margin-top: auto;
    padding-top: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.am-card__host {
    font-size: 12px;
    opacity: 0.6;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Square image on the right */
.am-card__media {
    flex: 0 0 var(--am-img);
    width: var(--am-img);
    align-self: flex-start;
}
.am-card__imglink {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: calc(var(--am-radius) - 4px);
    overflow: hidden;
    background: rgba(128, 128, 128, 0.2);
}
.am-card__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
    max-width: none;
    border-radius: 0;
    transition: transform 0.3s ease;
}
.am-card:hover .am-card__img {
    transform: scale(1.04);
}
.am-card__media > .am-card__img {
    aspect-ratio: 1 / 1;
    border-radius: calc(var(--am-radius) - 4px);
}

/* Paid / featured cards */
.am-card--paid {
    border-color: var(--am-accent);
    box-shadow: 0 0 0 1px var(--am-accent) inset;
}

/* ---------- Buttons ---------- */
.am-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 0;
    border-radius: 999px;
    background: var(--am-accent);
    color: var(--am-accent-text) !important;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none !important;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.15s ease;
}
.am-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}
.am-btn--lg {
    padding: 12px 24px;
    font-size: 15px;
}

/* ---------- Stack layout (sidebar, popup): image on top ---------- */
.am-card--stack {
    flex-direction: column-reverse;
    gap: 12px;
}
.am-card--stack .am-card__media {
    flex: none;
    width: 100%;
}
.am-card--no-image.am-card--stack {
    flex-direction: column;
}

/* Standard 300x250 ad unit used by the Ad Manager widget. */
.am-zone--widget .am-card {
    width: 300px;
    height: 250px;
    max-width: 100%;
    align-items: center;
    padding: 12px;
    gap: 0;
}
.am-zone--widget .am-card__media {
    flex: 0 0 100px;
    width: 100px;
    height: 100px;
    align-self: center;
}
.am-zone--widget .am-card__imglink {
    height: 100%;
    aspect-ratio: auto;
}
.am-zone--widget .am-card__body {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    gap: 3px;
    padding-top: 8px;
    border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent);
    overflow: hidden;
}
.am-zone--widget .am-card--no-image .am-card__body {
    padding-top: 0;
    border-top: 0;
}
.am-zone--widget .am-card__title {
    font-size: 1em;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}
.am-zone--widget .am-card__desc {
    -webkit-line-clamp: 1;
}
.am-zone--widget .am-card__foot {
    flex: 0 0 auto;
    padding-top: 4px;
    gap: 6px;
}
.am-zone--widget .am-card__foot .am-btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* ---------- Category filter chips ---------- */
.am-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 var(--am-gap);
}
.am-chip {
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid rgba(128, 128, 128, 0.35);
    border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.am-chip:hover {
    border-color: var(--am-accent);
}
.am-chip.is-active {
    background: var(--am-accent);
    border-color: var(--am-accent);
    color: var(--am-accent-text);
}

.am-empty {
    opacity: 0.7;
}

/* ---------- Popup ---------- */
.am-popup {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 99990;
    width: 300px;
    max-width: calc(100vw - 32px);
    animation: am-pop 0.35s ease both;
}
.am-popup[hidden] {
    display: none;
}
.am-popup .am-card {
    background: #16161c;
    color: #f2f2f5;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
.am-popup__close {
    position: absolute;
    top: -10px;
    right: -10px;
    z-index: 2;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #111;
    font-size: 20px;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.am-popup__close:hover {
    background: var(--am-accent);
    color: var(--am-accent-text);
}
@keyframes am-pop {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

/* ---------- Public stats ---------- */
.am-stats__summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: var(--am-gap);
}
.am-stats__summary > div {
    flex: 1 1 110px;
    padding: 12px 16px;
    border-radius: var(--am-radius);
    background: rgba(128, 128, 128, 0.08);
    background: color-mix(in srgb, currentColor 6%, transparent);
    border: 1px solid rgba(128, 128, 128, 0.25);
    border: 1px solid color-mix(in srgb, currentColor 14%, transparent);
}
.am-stats__summary strong {
    display: block;
    font-size: 1.5em;
    line-height: 1.2;
}
.am-stats__summary span {
    font-size: 12px;
    opacity: 0.7;
}
.am-stats__summary .am-stats__period {
    flex: 0 0 auto;
    background: none;
    border: 0;
    font-size: 13px;
    opacity: 0.7;
}
.am-stats__scroll {
    overflow-x: auto;
}
.am-stats__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}
.am-stats__table th,
.am-stats__table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(128, 128, 128, 0.25);
    border-bottom: 1px solid color-mix(in srgb, currentColor 14%, transparent);
    background: none;
}
.am-stats__table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.7;
}
.am-stats__table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.am-stats__table tbody tr:hover td {
    background: rgba(128, 128, 128, 0.07);
}

/* ---------- Submission form ---------- */
.am-form {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 24px;
    border-radius: var(--am-radius);
    background: rgba(128, 128, 128, 0.08);
    background: color-mix(in srgb, currentColor 6%, transparent);
    border: 1px solid rgba(128, 128, 128, 0.25);
    border: 1px solid color-mix(in srgb, currentColor 14%, transparent);
}
.am-form__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.am-field {
    margin-bottom: 16px;
}
.am-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
}
.am-field input[type="text"],
.am-field input[type="email"],
.am-field input[type="url"],
.am-field select,
.am-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(128, 128, 128, 0.4);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.92);
    color: #111;
    font: inherit;
}
.am-field input[type="file"] {
    width: 100%;
    font: inherit;
}
.am-field input:focus,
.am-field select:focus,
.am-field textarea:focus {
    outline: 2px solid var(--am-accent);
    outline-offset: 1px;
}
.am-field small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.65;
}
.am-field--hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ---------- Notices ---------- */
.am-notice {
    margin: 0 0 16px;
    padding: 12px 16px;
    border-radius: 10px;
    border-left: 4px solid;
    font-size: 14px;
}
.am-notice--success {
    background: rgba(34, 197, 94, 0.14);
    border-color: #22c55e;
}
.am-notice--error {
    background: rgba(239, 68, 68, 0.14);
    border-color: #ef4444;
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
    .am-directory {
        grid-template-columns: minmax(0, 1fr);
    }
    .am-form__row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    .am-popup--no-mobile {
        display: none !important;
    }
}
@media (max-width: 420px) {
    :root {
        --am-img: 96px;
    }
    .am-card {
        padding: 12px;
        gap: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .am-card,
    .am-card__img,
    .am-btn,
    .am-popup {
        transition: none;
        animation: none;
    }
    .am-card:hover {
        transform: none;
    }
}
