/* =====================================================================
   CIVIC THEME  —  Step 8: ads
   ---------------------------------------------------------------------
   The ad slots in the feed (sidebar on wide screens, pinned under the
   header on narrow ones) and the advertiser page (/ads/). Remove the
   <link> to revert.
   ===================================================================== */

/* ---- Feed ad slots ---------------------------------------------------- */
.ad-slot { display: none; }
.ad-slot.has-ad { display: block; }
.ad-unit {
    display: block;
    background: #ffffff;
    border: 1px solid #e6e8ec;
    border-radius: 12px;
    box-shadow: 0 6px 18px -10px rgba(30, 40, 60, .22);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
}
.ad-unit img { display: block; width: 100%; height: auto; }
.ad-sponsored {
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: .68em;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #6b7280;
    padding: 6px 10px;
    background: #ffffff;
}

/* Wide screens: sticky in the right-hand column beside the feed. */
.ad-side.has-ad {
    position: sticky;
    /* --bar-h is the fixed header's height, set by tappet.js. */
    top: calc(var(--bar-h, 64px) + 16px);
    margin-top: 3.6em;
    max-width: 240px;
    margin-right: 12px;
}
.ad-top.has-ad { display: none; }

/* Narrow screens: pinned at the top of the feed instead. */
@media (max-width: 899px) {
    .ad-side.has-ad { display: none; }
    .ad-top.has-ad {
        display: block;
        position: sticky;
        top: calc(var(--bar-h, 90px) + 8px);
        z-index: 5;
        max-width: 640px;
        margin: 0 auto 1em;
    }
    .ad-top .ad-unit img { max-height: 110px; object-fit: cover; }
}

/* ---- Advertiser page (/ads/) ---------------------------------------- */
.adpage {
    max-width: 1040px;
    margin: 0 auto;
    padding: 24px 16px 60px;
}
.adpage-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 1px solid #e6e8ec;
}
.adpage-who { display: flex; align-items: center; gap: 14px; }
.adpage-who-text { text-align: right; line-height: 1.3; }
.adpage-who-text b { display: block; font-size: .95em; }
.adpage-who-text span { font-size: .82em; color: #6b7280; }
.adpage-who .ghost-btn { text-decoration: none; }
.adpage-head { margin-bottom: 18px; }
.adpage-brand {
    font-family: 'obida', 'Newsreader', Georgia, serif;
    font-size: 1.6em;
    color: #1b1f26;
    text-decoration: none;
}
.adpage-head h1 { font-size: 1.6em; margin: 0 0 4px; }
.adpage-sub { color: #3f454e; max-width: 680px; margin: 0; }
.adpage-card { max-width: none; padding: 18px 20px; margin-bottom: 18px; }
.adpage-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.adpage-card-head h2 { font-size: 1.1em; margin: 0; }
.adpage-card-head .ghost-btn { text-decoration: none; }

.ad-notice { border-radius: 12px; padding: 12px 16px; margin-bottom: 18px; border: 1px solid #d3dbe8; background: #eef2f7; color: #2c3e5e; }
.ad-notice-ok { background: #e8f5ec; border-color: #bfe0cb; color: #1f6b4a; }
.ad-rerun-note { margin: 0 0 6px; font-size: .9em; }
.adpage-card-head .link-btn { font-size: .85em; font-weight: 600; color: #566277; }
.ad-actions a.link-btn { display: inline-block; margin-right: 8px; font-size: .85em; font-weight: 600; color: #566277; text-decoration: none; }

.ad-muted, .ad-hint { color: #6b7280; font-size: .82em; }
.ad-hint { margin-top: 4px; }
.ad-error { color: #a33328; font-size: .85em; margin-top: 4px; }

.ad-table-wrap { overflow-x: auto; }
.ad-table { width: 100%; border-collapse: collapse; font-size: .9em; }
.ad-table th, .ad-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #eceef2; vertical-align: middle; }
.ad-table th { font-size: .82em; font-weight: 600; color: #3f454e; }
.ad-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ad-cell-name { min-width: 220px; }
.ad-cell-name .ad-name-wrap { display: flex; gap: 10px; align-items: center; }
.ad-cell-name img { flex: none; width: 72px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid #e6e8ec; }
.ad-cell-name .ad-muted { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-table td.ad-dates-cell { white-space: nowrap; }
.ad-actions { white-space: nowrap; }
.ad-actions form { display: inline-block; margin: 0 4px 0 0; }

.ad-status {
    display: inline-block;
    font-size: .78em;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    background: #eef1f7;
    color: #3f454e;
    white-space: nowrap;
}
.ad-status-running { background: #e8f5ec; color: #1f6b4a; }
.ad-status-scheduled, .ad-status-in-review { background: #eef2f7; color: #2c3e5e; }
.ad-status-awaiting-payment { background: #fdf6e3; color: #7a5a0b; }
.ad-status-rejected { background: #fdeeed; color: #a33328; }

.btn-pay {
    font: inherit;
    font-weight: 600;
    font-size: .85em;
    color: #ffffff;
    background: #566277;
    border: 1px solid #566277;
    border-radius: 8px;
    padding: 7px 14px;
    cursor: pointer;
}
.btn-pay:hover { background: #414b5c; }
.btn-pay[disabled] { opacity: .5; cursor: not-allowed; }
.btn-pay-lg { font-size: 1em; padding: 11px 22px; }
.ad-actions .link-btn { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-size: .85em; font-weight: 600; color: #566277; }

.ad-form label { display: block; font-size: .82em; font-weight: 600; color: #3f454e; margin: 14px 0 5px; }
.ad-form input, .ad-form select {
    width: 100%;
    font: inherit;
    font-size: .95em;
    padding: 8px 10px;
    border: 1px solid #d3d9e6;
    border-radius: 8px;
    background: #fff;
}
.ad-form-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 24px; }
.ad-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ad-preview { margin-top: 10px; max-width: 320px; border: 1px solid #e6e8ec; border-radius: 12px; overflow: hidden; }
.ad-preview img { display: block; width: 100%; }
#ad-map {
    position: relative;
    height: 380px;
    border-radius: 12px;
    border: 1px solid #e6e8ec;
    overflow: hidden;
}
#ad-map .center-marker { width: 44px; height: 44px; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 5; pointer-events: none; }
#ad-map .center-marker img { width: 100%; }
#ad-map .maplibregl-ctrl-group { border: 1px solid #d3d9e6; border-radius: 8px; box-shadow: none; overflow: hidden; }

.ad-summary {
    display: grid;
    grid-template-columns: minmax(170px, auto) 1fr auto;
    align-items: center;
    gap: 24px;
    margin-top: 22px;
    padding: 18px 20px;
    background: #f5f6f8;
    border: 1px solid #e6e8ec;
    border-radius: 12px;
}
.ad-price-label {
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: .7em;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #6b7280;
}
.ad-total { font-size: 1.9em; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.ad-price-calc { font-size: .82em; color: #3f454e; margin-top: 2px; }
.ad-fineprint {
    margin: 0;
    padding: 0 0 0 22px;
    border-left: 1px solid #dfe3ea;
    list-style: none;
    font-size: .84em;
    line-height: 1.5;
    color: #3f454e;
}
.ad-fineprint li { position: relative; padding-left: 14px; }
.ad-fineprint li::before { content: '·'; position: absolute; left: 0; font-weight: 700; color: #566277; }
.ad-checkout { display: grid; grid-template-columns: auto auto; align-items: center; justify-items: center; gap: 8px 14px; }
.ad-checkout .btn-pay { grid-column: 1; }
.btn-cancel-link { grid-column: 2; font-size: .9em; font-weight: 600; color: #566277; text-decoration: none; }
.btn-cancel-link:hover { text-decoration: underline; }
.ad-paywith { grid-column: 1 / -1; color: #6b7280; font-size: .76em; line-height: 1.4; text-align: center; }

@media (max-width: 760px) {
    .ad-form-grid { grid-template-columns: 1fr; }
    #ad-map { height: 300px; }
    .ad-summary { grid-template-columns: 1fr; gap: 14px; }
    .ad-fineprint { border-left: 0; padding-left: 0; }
    .ad-checkout { grid-template-columns: 1fr auto; justify-items: stretch; }
    .btn-cancel-link { justify-self: center; }
    .adpage-who-text { font-size: .9em; }
}
