/**
 * FCA Ads Manager — frontend ad chrome (injected into the FC portal feed,
 * header, and sidebar). Uses FC design tokens so ads inherit the active
 * theme incl. dark mode.
 */

.fca-ad {
    position: relative;
    box-sizing: border-box;
}

/* Multi-ad placement grid: columns follow the zone's configured ad count
 * (capped at 6 via --fca-cols), collapsing to a single column on narrow
 * containers so ads never squash. */
.fca-zone-grid-slots {
    display: grid;
    grid-template-columns: repeat(var(--fca-cols, 1), minmax(0, 1fr));
    gap: 12px;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
}
.fca-zone-grid-slots > .fca-ad {
    width: 100%;
    margin: 0;
}
/* Feed ad block: spacing so it reads as its own row between feed posts. */
.fca-feed-grid {
    margin: 16px 0;
}
@media (max-width: 782px) {
    .fca-zone-grid-slots {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    }
}

/* Demo-mode placeholder: sized box shown in place of a live network slot. */
.fca-ad__placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: 0 auto;
    color: var(--fcom-secondary-text, #65676b);
    background: repeating-linear-gradient(
        45deg,
        var(--fcom-active-bg, #f0f2f5),
        var(--fcom-active-bg, #f0f2f5) 10px,
        var(--fcom-card-bg, #fff) 10px,
        var(--fcom-card-bg, #fff) 20px
    );
    border: 1px dashed var(--fcom-border-color, #ccd0d5);
    border-radius: 8px;
    text-align: center;
    overflow: hidden;
}
.fca-ad__placeholder--responsive {
    width: 100%;
}
.fca-ad__placeholder-label {
    font-weight: 600;
    font-size: 13px;
    letter-spacing: .02em;
    text-transform: uppercase;
}
.fca-ad__placeholder-size {
    font-size: 12px;
    opacity: .7;
}

/* Between-posts + header banner sit in the main content column and should
   visually match FC feed cards. */
.fca-ad--feed,
.fca-ad--header {
    margin: 0 0 16px;
    background: var(--fcom-card-bg, #fff);
    border: 1px solid var(--fcom-border-color, #e9ebee);
    border-radius: var(--fcom-card-radius, 10px);
    padding: 12px;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.fca-ad--header {
    margin-bottom: 16px;
}

/* Sidebar ad reuses FC's own widget shell (.app_side_widget) — only the
   inner padding needs help. */
.fca-ad--sidebar {
    padding: 12px;
}

/* Fixed footprints: width capped per FluentCommunity column
 *   feed/header/posts → .fcom_feed_box max 680px
 *   left nav          → .fcom_sidebar_wrap 270px
 *   right widgets     → .app_side_widgets 320px
 */
.fca-ad.fca-ad--fixed .fca-ad__body {
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
    box-sizing: border-box;
    position: relative;
}
.fca-ad.fca-ad--header .fca-ad__body,
.fca-ad.fca-ad--feed .fca-ad__body,
.fca-ad.fca-ad--global-feed .fca-ad__body,
.fca-ad.fca-ad--space-feed .fca-ad__body,
.fca-ad.fca-ad--post-before .fca-ad__body,
.fca-ad.fca-ad--post-inside .fca-ad__body,
.fca-ad.fca-ad--post-after .fca-ad__body,
.fca-ad.fca-ad--event-list .fca-ad__body,
.fca-ad.fca-ad--event-single-before .fca-ad__body,
.fca-ad.fca-ad--event-single-inside .fca-ad__body,
.fca-ad.fca-ad--event-single-after .fca-ad__body {
    max-width: min(100%, 680px);
}
.fca-ad.fca-ad--sidebar-left .fca-ad__body {
    max-width: min(100%, 246px);
}
.fca-ad.fca-ad--sidebar .fca-ad__body {
    max-width: min(100%, 296px);
}

.fca-ad.fca-ad--fixed .fca-ad__body > .fca-ad__house,
.fca-ad.fca-ad--fixed .fca-ad__body > .fca-ad__placeholder,
.fca-ad.fca-ad--fixed .fca-ad__body > iframe.fca-ad__sandbox {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
}
.fca-ad.fca-ad--fixed .fca-ad__house img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

/* Left-sidebar (navigation) ad. FC's nav column (.space_contents) is a
   fixed, internally-scrolling flex column, so an ad appended at its end sits
   below the fold and is never seen. Pin it to the bottom of the column so it
   stays 100% visible while the menu scrolls underneath it. */
.fca-ad.fca-ad--sidebar-left {
    position: sticky;
    bottom: 0;
    margin: auto 0 0;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    padding: 12px;
    background: var(--fcom-primary-bg, var(--fcom-card-bg, #fff));
    border-top: 1px solid var(--fcom-primary-border, var(--fcom-border-color, #e4e7eb));
    z-index: 5;
}
/* Keep the creative/placeholder inside the narrow (~270px) nav width. */
.fca-ad.fca-ad--sidebar-left .fca-ad__placeholder,
.fca-ad.fca-ad--sidebar-left .fca-ad__body,
.fca-ad.fca-ad--sidebar-left img {
    max-width: min(246px, 100%);
}
.fca-ad.fca-ad--sidebar-left .fca-ad__body {
    overflow: hidden !important;
}

.fca-ad__label {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fcom-text-light-color, #8a8d91);
    margin-bottom: 8px;
}

.fca-ad__body {
    min-height: 1px;
}

/* House creative */
.fca-ad__house {
    display: block;
    text-decoration: none;
    color: inherit;
}

.fca-ad__house img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.fca-ad__house-title {
    font-size: 14px;
    font-weight: 600;
    margin: 8px 0 0;
    color: var(--fcom-text-color, #050505);
}

.fca-ad__house-body {
    font-size: 13px;
    color: var(--fcom-text-light-color, #65676b);
    margin: 4px 0 0;
}

/* When a house creative sets a background color, pad it so text isn't flush. */
.fca-ad__house[style*="background"] {
    padding: 14px;
    border-radius: 8px;
}

/* AdSense responsive units */
.fca-ad .adsbygoogle {
    display: block;
}

/* [fca_ads_listing] table */
.fca-ads-listing {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.fca-ads-listing th,
.fca-ads-listing td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--fcom-border-color, #e9ebee);
}

.fca-ads-listing th {
    font-weight: 700;
    white-space: nowrap;
}

.fca-ads-listing th a {
    text-decoration: none;
    color: inherit;
}

.fca-ads-listing-empty {
    color: var(--fcom-text-light-color, #65676b);
}

/* ── Member "Report ad" control ─────────────────────────────────────────
   A small, unobtrusive flag button in the top-right of a served ad. Fades
   in on hover/focus so it never competes with the creative. */
.fca-ad--reportable {
    position: relative;
}
.fca-ad__report {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    margin: 0;
    border: 1px solid var(--fcom-border-color, #e9ebee);
    border-radius: 6px;
    background: var(--fcom-card-bg, #fff);
    color: var(--fcom-text-light-color, #8a8d91);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s ease, color .15s ease, border-color .15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}
.fca-ad--reportable:hover .fca-ad__report,
.fca-ad--reportable:focus-within .fca-ad__report,
.fca-ad__report:focus {
    opacity: 1;
}
.fca-ad__report:hover {
    color: var(--fcom-danger, #e0245e);
    border-color: var(--fcom-danger, #e0245e);
}
@media (hover: none) {
    .fca-ad__report { opacity: .6; }
}

/* Already reported: locked, always visible, green so the viewer knows their
   report was recorded. */
.fca-ad__report--reported,
.fca-ad--reportable:hover .fca-ad__report--reported,
.fca-ad__report--reported:hover,
.fca-ad__report--reported:focus {
    opacity: 1;
    cursor: default;
    color: #fff;
    background: var(--fcom-success, #16a34a);
    border-color: var(--fcom-success, #16a34a);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
@media (hover: none) {
    .fca-ad__report--reported { opacity: 1; }
}

/* Report popover (appended to <body>, positioned by JS). */
.fca-ad-report-pop {
    position: absolute;
    z-index: 100000;
    width: 260px;
    max-width: calc(100vw - 16px);
    padding: 12px;
    background: var(--fcom-card-bg, #fff);
    border: 1px solid var(--fcom-border-color, #e9ebee);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .18);
    font-size: 13px;
    color: var(--fcom-text-color, #050505);
}
.fca-ad-report-pop__title {
    font-weight: 700;
    margin-bottom: 8px;
}
.fca-ad-report-pop__reason {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    padding: 8px;
    border: 1px solid var(--fcom-border-color, #d7dbdf);
    border-radius: 8px;
    font: inherit;
    color: inherit;
    background: var(--fcom-active-bg, #f7f8fa);
}
.fca-ad-report-pop__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}
.fca-ad-report-pop__actions button {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.fca-ad-report-pop__cancel {
    background: transparent;
    border-color: var(--fcom-border-color, #d7dbdf);
    color: var(--fcom-text-light-color, #65676b);
}
.fca-ad-report-pop__send {
    background: var(--fcom-danger, #e0245e);
    color: #fff;
}
.fca-ad-report-pop__send:disabled {
    opacity: .7;
    cursor: default;
}
.fca-ad-report-pop__done {
    padding: 4px 0;
    font-weight: 600;
    color: var(--fcom-text-color, #050505);
}

/* Sandboxed custom-ad iframe — isolates third-party scripts from the portal. */
.fca-ad__sandbox {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    border: 0;
    background: transparent;
    overflow: hidden;
}
.fca-ad__custom {
    width: 100%;
    height: 100%;
}
