/* ================================================================
   CampaignsItemPage.css — Campaign item page (ported from reference
   MarketingCampaign.css). Tokens only.
   ================================================================ */

/* min-height fills the viewport — a plain 100% doesn't resolve against the
   flex-grown shell, so the gradient ended early on short campaigns and left a
   dead band. --fc-appbar-h falls back to 0 (main has no fixed app bar here). */
.fc-campaign {
    background: linear-gradient(to bottom, var(--color-surface-info-bg) 0%, var(--color-surface-subtle) 100%);
    min-height: calc(100dvh - var(--fc-appbar-h, 0px));
}

/* The Campaign page has NO Set-Location bar, but --fc-header-h is declared at :root as
   calc(--fc-appbar-h + --fc-location-h) and its vars resolve against :root — where --fc-location-h
   keeps the Home page's ~42px after an SPA navigation. So arriving here from Home's "View Deal",
   --fc-header-h was 142px for the first frame and then dropped to 100px once the var cleared, and
   the `top` transition below ANIMATED that change: the back bar slid in from 33px below the header
   (measured 133 -> 105 -> 100 over ~300ms), which is the bar looking "separated and then
   attaching". reference_project_updated does not hit this because its --fc-header-h is a flat
   100px with no location term.

   Fix is the same one .fc-item already uses: REDECLARE --fc-header-h on this page's root as
   nav-height only, so it is a constant on this page and there is nothing to animate. The 100px
   fallback (not 88px) matters — --fc-appbar-h is JS-measured, so a smaller fallback would itself
   animate up to 100 on a direct page load. Desktop-only; <=1024px uses top:0 via the 0px fallback. */
@media (min-width: 1025px) {
    .fc-campaign { --fc-header-h: var(--fc-appbar-h, 100px); }
    html.fc-header-hidden .fc-campaign { --fc-header-h: 0px; }
}

/* A tablet in landscape is >1024px and so took the desktop offset above - but --fc-appbar-h is
   published by the DESKTOP controller, which never runs on a device, so it fell back to the literal
   100px. The scroller is already padded by the native header (122px here), and `top` on a sticky
   element measures from that padded edge, so the Back bar pinned 100px DOWN from it and floated in
   the middle of the page, over the campaign subtitle. Portrait escaped it only because <=1024px
   leaves the variable undefined and the bar resolves to top: 0.
   Keep it 0 on a native shell at every width - the same value portrait already uses - and let the
   existing html.fc-native-header-hidden transform ride it up with the header as before. */
html.fc-native-shell .fc-campaign { --fc-header-h: 0px; }

/* ── Sticky back bar ── */
.fc-campaign-bar {
    position: sticky;
    /* ≤1024px: --fc-header-h is undefined so this resolves to 0 = the PADDED scroll edge, which sits
       just below the fixed #web-mobile-header; the transform below then rides it to the very top when
       that header collapses (same property/curve, so they stay locked — no seam, no double-offset).
       NOTE: fc-native-header-hidden DOES apply on web ≤1024px.
       ≥1025px: must offset by --fc-header-h (the sticky #topbar_large_screen's measured height, 100px,
       0 when it hides). With a literal top:0 this bar pinned at y=0 UNDERNEATH that topbar — a full
       41px overlap, and the Back button was not clickable. The desktop scroller has no padding, so
       nothing else was holding the bar clear. Same mechanism .fc-item-bar / .fc-home-chips-bar use. */
    top: var(--fc-header-h, 0px);
    /* --fc-z-sticky ("in-page sticky bars"), not the bare 30 it used to be: at 30 the Back bar lost
       to any page-level sticky sub-bar that outranked it, which left it not just invisible but
       unclickable. Still under every app header and far under modals. Matches .fc-item-bar. */
    z-index: var(--fc-z-sticky, 1000);
    background: var(--color-surface-default);
    border-bottom: 1px solid var(--color-border);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                top 0.42s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}
/* When the header is hidden the back bar rides to the very top — clear the iOS notch there. */
html.fc-native-header-hidden .fc-campaign-bar {
    transform: translateY(calc(-1 * var(--native-header-h, 0px)));
    padding-top: var(--fc-safe-top);
    /* Cancels the growth so it never reaches the FLOW. This bar is sticky, i.e. still in normal
       flow, so the inset above made it 32px taller and pushed every element below it down by
       32px - then back up when the header returned, which is the content bouncing on scroll.
       The border box still grows (the bar covers the status bar, "Back" clears the clock);
       the margin box does not. Both are layout properties and stay OUT of the transition
       list above - animating them reflows the page every frame. Changed in one frame they
       cancel exactly, so nothing visible moves. Mirrors ItemDetails.css .fc-item-bar. */
    margin-bottom: calc(-1 * var(--fc-safe-top));
}
.fc-campaign-bar-inner {
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}
/* Back control — same treatment as the item page (.fc-item-back). */
.fc-campaign-back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-half);
    padding: var(--space-1) var(--space-2);
    background: none;
    border: none;
    cursor: pointer;
}
.fc-campaign-back i { font-size: 20px; color: var(--color-text-primary); }
.fc-campaign-back span {
    font-family: var(--font-heading);
    font-size: var(--text-body-md-size);
    font-weight: var(--fw-bold);
    color: var(--color-text-primary);
    letter-spacing: 0.2px;
    line-height: 24px;
}

/* ── Content container ── */
.fc-campaign-body {
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
    padding: var(--space-2) var(--space-2) var(--space-10);
    box-sizing: border-box;
}

/* ── Title block ── */
.fc-campaign-head {
    display: flex;
    flex-direction: column;
    gap: var(--space-half);
    margin-bottom: var(--space-2);
}
.fc-campaign-title {
    font-family: var(--font-heading);
    font-size: var(--text-heading-lg-size);
    line-height: var(--text-heading-lg-lh);
    font-weight: var(--fw-bold);
    color: var(--color-text-primary);
}
.fc-campaign-subtitle {
    font-family: var(--font-body);
    font-size: var(--text-body-md-size);
    line-height: var(--text-body-md-lh);
    color: var(--color-text-primary);
}

/* ── Sort row ── */
.fc-campaign-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: var(--space-2);
}
.fc-campaign-sort.mud-button-root {
    text-transform: none;
    gap: var(--space-1);
    background: var(--color-surface-default);
    border-color: var(--color-border);
    color: var(--color-text-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-1) var(--space-2);
    font-family: var(--font-heading);
    font-size: var(--text-label-md-size);
    font-weight: var(--fw-bold);
}
.fc-campaign-sort.mud-button-root:hover { background: var(--color-surface-subtle); }
.fc-campaign-sort-icon { font-size: 14px; }

/* ── Product grid ── */
/* Same column ladder as .items-product-grid (ItemListing.css), so a campaign card is the same
   size as a Suggested Items card at every width. This grid still carried the OLD ladder
   (2 / 3 at 640 / 4 at 768 / 5 at 1024) that home was moved off deliberately - see the note on
   .items-product-grid: at 768px it gave 175px cards against v3.0.2's 235px. On an iPad at 820px
   that was 4x185 here against 3x252 on home. */
.fc-campaign-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: var(--space-2);
}
/* ItemListing.css (globally linked, used by other pages) paints
   .itemlist-item-container with a subtle background; the E2E tests
   require that class on each card root, so neutralize it here. */
.fc-campaign-grid .itemlist-item-container { background: transparent; }

/* ── Empty / not-found / error ── */
.fc-campaign-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: var(--space-2);
    min-height: 70vh;
    padding: var(--space-6) var(--space-2);
}
.fc-campaign-empty-title {
    font-family: var(--font-heading);
    font-size: var(--text-heading-sm-size);
    font-weight: var(--fw-bold);
    color: var(--color-text-primary);
}
.fc-campaign-cta.mud-button-root {
    text-transform: none;
    background-color: var(--color-brand-accent);
    color: var(--color-surface-default);
    border-radius: var(--radius-lg);
    padding: var(--space-1) var(--space-2);
    font-family: var(--font-heading);
    font-weight: var(--fw-bold);
}

/* ── Paging (infinite scroll fallback / end of list) ── */
.fc-campaign-loadmore {
    display: flex;
    justify-content: center;
    padding: var(--space-3) 0;
}
.fc-campaign-end {
    display: flex;
    justify-content: center;
    padding: var(--space-3) 0;
    color: var(--color-text-muted);
}

/* ── Loading spinner (brand ring + favicon center) ── */
.progress-wrapper {
    position: relative;
    display: inline-block;
}
.progress-center {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    font-weight: bold;
}

/* ── Responsive: 2 up to 767, 3 through 1279, 5 above - mirrors .items-product-grid exactly. ── */
@media (max-width: 767px) {
    .fc-campaign-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 768px) and (max-width: 1279px) {
    .fc-campaign-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ── Sort modal popup (reference SortModal design; hosted as an inline MudDialog) ──
   Sheet-style picker: drag handle, icon + title + close, vertical radio list,
   full-width Apply (red) / Clear (outlined). Chrome + bottom-sheet come from app.css. */
.fc-sortmodal.mud-dialog { max-width: 700px; width: 100%; margin: 0 auto; }
.fc-sortmodal-head { display: flex; align-items: center; justify-content: space-between; }
.fc-sortmodal-head-title { display: flex; align-items: center; gap: var(--space-1); }
.fc-sortmodal-head-icon { font-size: 20px; color: var(--color-text-primary); }
.fc-sortmodal-title { font-family: var(--font-heading); font-size: var(--text-heading-sm-size); line-height: var(--text-heading-sm-lh); font-weight: var(--fw-bold); color: var(--color-text-primary); }
.fc-sortmodal-opts { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-1) 0; }
.fc-sortmodal-opt { display: flex; align-items: center; gap: var(--space-1); cursor: pointer; }
.fc-sortmodal-opt input[type="radio"] { width: 24px; height: 24px; margin: 0; accent-color: var(--color-brand-primary); cursor: pointer; }
.fc-sortmodal-opt-label { font-family: var(--font-body); font-size: var(--text-action-md-size); line-height: var(--text-action-md-lh); color: var(--color-text-primary); }
.fc-sortmodal .mud-dialog-actions { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.fc-sortmodal-apply, .fc-sortmodal-clear { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1); height: 56px; border-radius: var(--radius-lg); font-family: var(--font-heading); font-size: var(--text-action-md-size); font-weight: var(--fw-bold); cursor: pointer; }
.fc-sortmodal-apply { background: var(--color-brand-accent); color: var(--color-surface-default); border: none; }
.fc-sortmodal-clear { background: transparent; color: var(--color-brand-primary); border: 1px solid var(--color-brand-primary); }
