/* ==========================================================================
   OneBuy Personal — offer card + category block
   Build spec: "Offer card and category block", approved design 3b.
   Rendered by [onebuy_browse_offers_v2] (onebuy_browse_offers_v2_shortcode).
   Behaviour lives in assets/js/offer-cards.js.
   ========================================================================== */

.ob-browse {
    /* Section 6 tokens */
    --ob-navy: #10394F;
    --ob-teal: #0E7C86;
    --ob-teal-dark: #0B6A72;
    --ob-band-bg: #FDF6E3;
    --ob-band-border: #F0E2BB;
    --ob-band-text: #8A6A0B;
    --ob-body: #61737D;
    --ob-hairline: #EDF2F3;
    --ob-slot: #F2F5F6;
    --ob-chip-border: #DCE5E8;
    --ob-rule: #E1E8EB;

    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--ob-navy);
}

/* Own the box model rather than inheriting it: min-height on the chips and the
   button is a border-box measurement (44px touch target), and <a> defaults to
   content-box. */
.ob-browse,
.ob-browse *,
.ob-browse *::before,
.ob-browse *::after {
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Heading + filter chips — stay on white, above the navy panel
   -------------------------------------------------------------------------- */

.ob-browse__head {
    background: #fff;
    border-bottom: 1px solid var(--ob-rule);
    padding: 0 0 18px;
    margin-bottom: 0;
}

.ob-browse__title {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--ob-navy);
    margin: 0 0 16px;
}

.ob-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ob-chip {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid var(--ob-chip-border);
    border-radius: 999px;
    background: #fff;
    color: var(--ob-navy);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: none;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}

.ob-chip:hover {
    border-color: var(--ob-navy);
    background: #fff;
    color: var(--ob-navy);
}

/* Active chip: solid teal, white text */
.ob-chip[aria-pressed="true"],
.ob-chip[aria-pressed="true"]:hover {
    background: var(--ob-teal);
    border-color: var(--ob-teal);
    color: #fff;
}

.ob-chip:focus-visible {
    outline: 2px solid var(--ob-teal);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Navy panel + grid
   -------------------------------------------------------------------------- */

.ob-browse__panel {
    background: var(--ob-navy);
    border-radius: 12px;
    padding: 20px 22px 22px;
    margin-top: 20px;
}

.ob-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    align-items: stretch;
}

@media (max-width: 1023px) {
    .ob-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 639px) {
    .ob-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }
    .ob-browse__panel { padding: 16px 16px 18px; }
}

.ob-status {
    /* Screen-reader announcement of the filtered count */
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.ob-empty {
    grid-column: 1 / -1;
    margin: 0;
    padding: 28px 0;
    text-align: center;
    color: #C6D4DA;
    font-size: 14px;
}

/* --------------------------------------------------------------------------
   Card shell — section 2 slot order is fixed, footer pins to the bottom
   -------------------------------------------------------------------------- */

.ob-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 0;
    border-radius: 14px;
    overflow: hidden;
    min-width: 0;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease;
    /* Drives the sub-300px footer stack below, independent of viewport width */
    container-type: inline-size;
    container-name: obcard;
}

.ob-card[hidden] { display: none; }

.ob-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(16, 57, 79, .28);
}

.ob-card:hover .ob-card__cta { background: var(--ob-teal-dark); }

/* The CTA is the tab stop; the ring is drawn around the whole card. */
.ob-card:focus-within {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   1 · Creative slot — 6:5, neutral field, never cropped (section 3)
   -------------------------------------------------------------------------- */

.ob-creative {
    position: relative;
    width: 100%;
    aspect-ratio: 6 / 5;
    background: var(--ob-slot);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

/* Fallback for browsers without aspect-ratio */
@supports not (aspect-ratio: 6 / 5) {
    .ob-creative { height: 0; padding-bottom: 83.3333%; }
    .ob-creative > * { position: absolute; }
}

/* Shimmer until the creative reports in; never a zero-height slot. */
.ob-creative::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, #F2F5F6 30%, #E7EDEF 50%, #F2F5F6 70%);
    background-size: 220% 100%;
    animation: ob-shimmer 1.3s linear infinite;
    opacity: 1;
    transition: opacity .25s ease;
    pointer-events: none;
}

.ob-creative.is-ready::before,
.ob-creative.is-failed::before {
    opacity: 0;
    animation: none;
}

@keyframes ob-shimmer {
    from { background-position: 120% 0; }
    to   { background-position: -120% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .ob-creative::before { animation: none; }
    .ob-card:hover { transform: none; }
}

/* 3.1 Image file — contain, centred, never upscaled past natural size
   (the natural-size ceiling is set inline per image by PHP). */
.ob-creative__img {
    position: relative;
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0;
}

/* 3.2 Supplier HTML/JS — the iframe keeps its intrinsic pixel size and is
   fitted with a transform set by JS. Never width:100%. */
.ob-creative__frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: center center;
    transform: translate(-50%, -50%) scale(1);
    line-height: 0;
}

.ob-creative__frame iframe {
    display: block;
    border: 0;
    margin: 0;
    max-width: none;   /* beat theme-wide iframe rules */
    max-height: none;
}

/* 3.4 Failure and fallback — supplier logo, else supplier name in navy 14px */
.ob-creative__fallback {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    text-align: center;
}

.ob-creative.is-failed .ob-creative__fallback { display: flex; }
.ob-creative.is-failed .ob-creative__frame,
.ob-creative.is-failed .ob-creative__img { display: none; }

.ob-creative__fallback img {
    max-width: 78%;
    max-height: 62%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.ob-creative__fallback-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ob-navy);
}

/* --------------------------------------------------------------------------
   2 · Discount band — only rendered when the offer carries a live discount
   -------------------------------------------------------------------------- */

.ob-discount {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 16px 11px;
    background: var(--ob-band-bg);
    border-bottom: 1px solid var(--ob-band-border);
    flex: none;
}

.ob-discount__icon {
    flex: none;
    width: 14px;
    height: 14px;
    margin-top: 4px;
    color: var(--ob-band-text);
}

.ob-discount__icon svg { display: block; width: 100%; height: 100%; }

.ob-discount__headline {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ob-navy);
}

.ob-discount__claim {
    margin: 2px 0 0;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.45;
    color: var(--ob-band-text);
}

/* Copy-to-clipboard control on the code itself */
.ob-code {
    position: relative;
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    padding: 0 2px;
    background: none;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    color: var(--ob-navy);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

/* Expand the tap target to ~44px without changing the inline layout */
.ob-code::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 44px;
    transform: translateY(-50%);
    padding: 0 8px;
    margin: 0 -8px;
}

.ob-code:hover { 
    color: var(--ob-teal-dark); 
    background-color: unset;
}
.ob-code:focus-visible { outline: 2px solid var(--ob-teal); outline-offset: 2px; }
.ob-code.is-copied { text-decoration: none; }

.ob-code__copied {
    margin-left: 6px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--ob-teal-dark);
}

/* --------------------------------------------------------------------------
   3 · Category  ·  4 · Title  ·  5 · Description
   -------------------------------------------------------------------------- */

.ob-card__body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    padding: 14px 16px 0;
    min-width: 0;
}

.ob-card__category {
    display: block;
    margin: 0 0 6px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--ob-teal);
}

.ob-card__title {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.28;
    color: var(--ob-navy);
    overflow-wrap: break-word;
}

.ob-card__desc {
    margin: 0 0 16px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--ob-body);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   6 · Footer — pinned to the bottom, giving line left, button right
   -------------------------------------------------------------------------- */

.ob-card__footer {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: auto;
    padding: 12px 16px 14px;
    border-top: 1px solid var(--ob-hairline);
}

.ob-giving {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.35;
    color: var(--ob-body);
}

.ob-giving__icon {
    flex: none;
    width: 12px;
    height: 12px;
    margin-top: 1px;
    color: var(--ob-teal);
}

.ob-giving__icon svg { display: block; width: 100%; height: 100%; }

.ob-card__cta {
    flex: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--ob-teal);
    color: #fff !important;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none !important;
    transition: background-color .18s ease;
}

.ob-card__cta:hover,
.ob-card__cta:focus {
    background: var(--ob-teal-dark);
    color: #fff !important;
}

.ob-card__cta:focus-visible {
    outline: 2px solid var(--ob-navy);
    outline-offset: 2px;
}

/* Below the 300px minimum card width the button takes its own full-width line */
@container obcard (max-width: 300px) {
    .ob-card__footer { flex-wrap: wrap; }
    .ob-card__cta { width: 100%; }
}

/* Fallback for browsers without container queries */
@supports not (container-type: inline-size) {
    @media (max-width: 380px) {
        .ob-card__footer { flex-wrap: wrap; }
        .ob-card__cta { width: 100%; }
    }
}

/* --------------------------------------------------------------------------
   Loading skeleton — real card geometry: 6:5 slot, two text bars, footer bar.
   Not used by the server-rendered grid; kept for an async/paginated grid.
   -------------------------------------------------------------------------- */

.ob-card--skeleton { cursor: default; pointer-events: none; }
.ob-card--skeleton .ob-creative { background: var(--ob-slot); }

.ob-skeleton-bar {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(100deg, #EEF2F4 30%, #E2E9EC 50%, #EEF2F4 70%);
    background-size: 220% 100%;
    animation: ob-shimmer 1.3s linear infinite;
}

.ob-card--skeleton .ob-skeleton-bar + .ob-skeleton-bar { margin-top: 10px; }
.ob-card--skeleton .ob-skeleton-bar:nth-of-type(2) { width: 72%; }
