/*
 * Congress listing cards (resources/views/app/congresses/partials/congress-card.blade.php): /congresses and its
 * facet pages, the no-results suggestions and a series page's next edition.
 *
 * Each card is a ticket: the city's photo, the congress, and a stub with its dates, behind a perforated line with
 * a notch cut out at each end. The layout follows the width of the list (container queries on .cbCardList), not
 * the screen, so the card fits whatever column it sits in:
 *   > 700px   photo | congress | stub
 *   <= 700px  photo | congress, the stub as a row underneath
 *   <= 520px  compact: small square photo, about four cards per phone screen
 *
 * Site tokens: navy #333d4c, yellow #fddd01, purple #6433a1, border #e5e8ef, Nunito.
 */

.cbResults,
.cbCardList,
.cbPager {
    --cbInk: #262d38;
    --cbInk2: #4f5968;
    --cbMuted: #636c7b;
    --cbLine: #e2e5ec;
    --cbLineStrong: #c7cdd8;
    --cbCard: #fff;
    --cbStub: #fafbfc;
    --cbSun: #fddd01;
    --cbSunHover: #f0d000;
    --cbPlum: #6433a1;
    --cbPlumSoft: #efe8f8;
    --cbRadius: 14px;
    --cbNotch: 10px;
}

.cbResults { margin-bottom: 36px; }

/* ---------- Month headings, pinned while their congresses scroll under them ---------- */
.cbMonth { margin-top: 26px; }
.cbMonth:first-child { margin-top: 18px; }
.cbMonthTitle {
    position: sticky; top: 0; z-index: 4; margin: 0 0 2px; padding: 10px 0;
    font-size: 17px; font-weight: 800; letter-spacing: -.01em; color: var(--cbInk);
    background: linear-gradient(var(--cbCard) 72%, rgba(255, 255, 255, 0));
}

/* ---------- List ---------- */
.cbCardList {
    container-type: inline-size; container-name: cbCards;
    list-style: none; margin: 0; padding: 0;
}
.cbCardList > li { margin: 0; padding: 0; }
/* Spacing sits on the items, not as the list's gap: the list is the query container, and a container query can
   only restyle what is inside it */
.cbCardList > li + li { margin-top: 16px; }
.cbSuggestions .cbCardList { margin-top: 20px; }

/* The shadow is a drop-shadow on the card's wrapper, so it follows the cut-out notches */
.cbCardItem {
    filter: drop-shadow(0 1px 1.5px rgba(25, 31, 42, .07)) drop-shadow(0 3px 8px rgba(25, 31, 42, .04));
    transition: filter .3s ease;
}
.cbCardItem:hover { filter: drop-shadow(0 2px 3px rgba(25, 31, 42, .06)) drop-shadow(0 10px 20px rgba(25, 31, 42, .09)); }

.cbIcon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- The card ----------
 * The notches are real holes, and the border follows them exactly because it is built from the same cut: .cbCard
 * is a 1px frame in the border colour with a hole of radius notch - 1; the white .cbCardIn sits inside it with a
 * hole 1px larger around the same centre. What stays visible between the two holes is the border.
 * --cbCutA / --cbCutB are the notch centres in .cbCard's box, --cbCutInA / --cbCutInB the same points in
 * .cbCardIn's box (1px in): on wide cards the top and bottom of the stub's dashed edge.
 */
.cbCard {
    --cbStubW: 196px;
    --cbCutA: calc(100% - var(--cbStubW)) 0;
    --cbCutB: calc(100% - var(--cbStubW)) 100%;
    --cbCutInA: calc(100% - var(--cbStubW) + 1px) -1px;
    --cbCutInB: calc(100% - var(--cbStubW) + 1px) calc(100% + 1px);
    --cbHoleA: radial-gradient(circle at var(--cbCutA), #0000 calc(var(--cbNotch) - 1px), #000 calc(var(--cbNotch) - .4px));
    --cbHoleB: radial-gradient(circle at var(--cbCutB), #0000 calc(var(--cbNotch) - 1px), #000 calc(var(--cbNotch) - .4px));
    position: relative; padding: 1px; background: var(--cbLine); border-radius: var(--cbRadius);
    -webkit-mask: var(--cbHoleA), var(--cbHoleB); -webkit-mask-composite: source-in;
    mask: var(--cbHoleA), var(--cbHoleB); mask-composite: intersect;
    transition: background-color .25s ease, translate .3s ease;
}
.cbCardIn {
    --cbHoleInA: radial-gradient(circle at var(--cbCutInA), #0000 var(--cbNotch), #000 calc(var(--cbNotch) + .6px));
    --cbHoleInB: radial-gradient(circle at var(--cbCutInB), #0000 var(--cbNotch), #000 calc(var(--cbNotch) + .6px));
    display: grid; grid-template-columns: 236px minmax(0, 1fr) var(--cbStubW); min-height: 186px;
    background: var(--cbCard); border-radius: calc(var(--cbRadius) - 1px); overflow: hidden;
    -webkit-mask: var(--cbHoleInA), var(--cbHoleInB); -webkit-mask-composite: source-in;
    mask: var(--cbHoleInA), var(--cbHoleInB); mask-composite: intersect;
}
/* Quiet feedback: a firmer edge, a deeper shadow (on .cbCardItem), a 2px lift */
.cbCardItem:hover .cbCard { background-color: var(--cbLineStrong); translate: 0 -2px; }

/* The one link sits on the congress name and stretches over the whole card */
.cbCardLink { color: inherit; text-decoration: none; }
.cbCardLink:hover, .cbCardLink:focus { color: inherit; text-decoration: none; }
.cbCardLink::after { content: ""; position: absolute; inset: 0; z-index: 2; border-radius: var(--cbRadius); }
.cbCardLink:focus-visible { outline: none; }
.cbCardLink:focus-visible::after { outline: 3px solid var(--cbPlum); outline-offset: -3px; }

/* ---------- Photo: the city, with how many hotels we list there ---------- */
.cbCardPhoto { position: relative; overflow: hidden; background: #d9dde5; }
.cbCardPhoto img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; transition: scale .9s ease; }
.cbCardItem:hover .cbCard .cbCardPhoto img { scale: 1.03; }
.cbCardPhoto::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(to top, rgba(12, 16, 24, .72) 0%, rgba(12, 16, 24, .18) 42%, rgba(12, 16, 24, 0) 62%);
}
.cbCardHotels {
    position: absolute; top: 12px; left: 12px; z-index: 1; display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px 5px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 800; line-height: 1.2; color: var(--cbInk);
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .14);
}
.cbCardHotels .cbIcon { width: 14px; height: 14px; color: var(--cbPlum); }
.cbCardPlace {
    position: absolute; left: 14px; right: 14px; bottom: 12px; z-index: 1;
    color: #fff; line-height: 1.15; text-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}
.cbCardPlace b { display: block; font-size: 17px; font-weight: 800; }
.cbCardPlace span { font-size: 12.5px; font-weight: 600; opacity: .9; }

/* ---------- Body: what the congress is and where ---------- */
.cbCardBody { padding: 18px 22px; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.cbCardTop { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cbCardField {
    min-width: 0; padding: 3px 8px; border-radius: 6px; background: var(--cbPlumSoft); color: var(--cbPlum);
    font-size: 11.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; line-height: 1.4;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cbCardWhen {
    flex: none; display: inline-flex; align-items: center; gap: 5px; margin-left: auto;
    font-size: 12.5px; font-weight: 700; color: var(--cbMuted); white-space: nowrap;
}
.cbCardWhen .cbIcon { width: 14px; height: 14px; }
.cbCardTitle {
    margin: 6px 0 0; font-size: 26px; line-height: 1.12; font-weight: 900; letter-spacing: -.02em; color: var(--cbInk);
    text-wrap: balance; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cbCardItem:hover .cbCard .cbCardLink { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; text-decoration-color: var(--cbLineStrong); }
.cbCardFull { margin: 0; color: var(--cbInk2); font-size: 14.5px; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cbCardLines { display: grid; gap: 4px; margin-top: auto; padding-top: 10px; }
.cbCardLine { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--cbInk2); min-width: 0; }
.cbCardLine > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cbCardLine strong { color: var(--cbInk); font-weight: 800; }
.cbCardLine .cbIcon { color: var(--cbMuted); }
.cbCardCity { display: none; }

/* ---------- Stub: perforated edge, the dates, the button ---------- */
.cbCardStub {
    position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
    padding: 18px 18px 18px 20px;
    background-color: var(--cbStub);
    background-image: linear-gradient(to bottom, var(--cbLineStrong) 0 6px, transparent 6px 12px);
    background-size: 2px 12px; background-repeat: repeat-y; background-position: 0 0;
}
.cbCardDates { display: grid; gap: 2px; margin: 0; text-align: center; }
.cbCardMonth { font-size: 12px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; color: var(--cbPlum); text-wrap: balance; }
.cbCardDays { padding-top: 4px; font-size: 30px; font-weight: 900; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; color: var(--cbInk); white-space: nowrap; }
.cbCardWeekdays { font-size: 13px; font-weight: 700; color: var(--cbMuted); white-space: nowrap; }
.cbCardSoon { display: none; }
.cbCardCta {
    display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 16px;
    border-radius: 10px; background: var(--cbSun); color: var(--cbInk); font-size: 15px; font-weight: 900; white-space: nowrap;
    transition: background-color .2s ease;
}
.cbCardCta .cbIcon { transition: transform .25s ease; }
.cbCardItem:hover .cbCard .cbCardCta { background-color: var(--cbSunHover); }
.cbCardItem:hover .cbCard .cbCardCta .cbIcon { transform: translateX(3px); }

/* ---------- Scroll: cards settle into place as they arrive (where supported; elsewhere static) ---------- */
@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        .cbCard { animation: cbCardSettle linear both; animation-timeline: view(); animation-range: entry 0% entry 55%; }
        @keyframes cbCardSettle { from { opacity: 0; transform: translateY(12px); } }
    }
}

/* ---------- Narrower lists: the stub drops under the card at a fixed height, notches at both ends of its top edge ---------- */
@container cbCards (max-width: 700px) {
    .cbCard {
        --cbStubH: 96px;
        --cbCutA: 0 calc(100% - var(--cbStubH));
        --cbCutB: 100% calc(100% - var(--cbStubH));
        --cbCutInA: -1px calc(100% - var(--cbStubH) + 1px);
        --cbCutInB: calc(100% + 1px) calc(100% - var(--cbStubH) + 1px);
    }
    .cbCardIn { grid-template-columns: 200px minmax(0, 1fr); }
    .cbCardStub {
        grid-column: 1 / -1; flex-direction: row; align-items: center; height: var(--cbStubH); padding: 14px 16px;
        background-image: linear-gradient(to right, var(--cbLineStrong) 0 6px, transparent 6px 12px);
        background-size: 12px 2px; background-repeat: repeat-x;
    }
    .cbCardDates { text-align: left; }
    .cbCardDays { padding-top: 2px; font-size: 24px; }
    .cbCardCta { flex: none; }
}

/* ---------- Phones: compact card, small square photo, one 14px inset on every side ---------- */
@container cbCards (max-width: 520px) {
    .cbCardList > li + li { margin-top: 12px; }
    .cbCard { --cbStubH: 70px; }
    .cbCardIn { grid-template-columns: 84px minmax(0, 1fr); column-gap: 12px; padding: 14px 14px 0; min-height: 0; }
    .cbCardPhoto { width: 84px; height: 84px; margin-bottom: 14px; border-radius: 10px; }
    .cbCardPhoto::after, .cbCardPlace { display: none; }
    .cbCardHotels { top: auto; bottom: 5px; left: 5px; padding: 3px 7px 3px 5px; font-size: 10.5px; gap: 3px; }
    .cbCardHotels .cbIcon { width: 11px; height: 11px; }
    .cbCardBody { padding: 0 0 14px; gap: 4px; }
    .cbCardTop { justify-content: flex-start; }
    .cbCardWhen { display: none; }
    .cbCardField { padding: 2px 6px; font-size: 10.5px; }
    .cbCardTitle { margin-top: 2px; font-size: 18px; line-height: 1.2; }
    .cbCardFull { display: none; }
    .cbCardLines { gap: 2px; margin-top: 0; padding-top: 2px; }
    .cbCardLine { align-items: flex-start; font-size: 13px; }
    .cbCardLine .cbIcon { margin-top: 2px; }
    .cbCardLine > span { white-space: normal; }
    .cbCardVenue { display: none; }
    .cbCardCity { display: flex; }
    .cbCardLong { display: none; }
    /* The stub runs the full card width; its content lines up with the photo */
    .cbCardStub { margin: 0 -14px; padding: 12px 14px; gap: 12px; }
    .cbCardDates { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 5px; row-gap: 1px; min-width: 0; }
    .cbCardDays { order: 1; padding-top: 0; font-size: 16px; letter-spacing: -.01em; }
    .cbCardMonth { order: 2; font-size: 16px; letter-spacing: -.01em; text-transform: none; color: var(--cbInk); }
    .cbCardWeekdays { order: 3; flex-basis: 100%; font-size: 12.5px; font-weight: 600; }
    .cbCardSoon { display: inline; }
    .cbCardCta { min-height: 44px; padding: 0 16px; border-radius: 9px; font-size: 14px; }
}

/* ---------- Pagination under the listing (the shared app.partials.pagination markup, styled here only) ---------- */
.cbPager .pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 4px 0 0; padding: 0; list-style: none; }
.cbPager .page-item { margin: 0; }
.cbPager .page-link,
.cbPager .page-item:first-child .page-link,
.cbPager .page-item:last-child .page-link {
    display: grid; place-items: center; min-width: 40px; height: 40px; padding: 0 8px; margin: 0;
    border: 1px solid var(--cbLine); border-radius: 8px; background: var(--cbCard); box-shadow: none;
    color: var(--cbInk2); font-size: 14px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; text-decoration: none;
    transition: border-color .2s ease, color .2s ease;
}
.cbPager a.page-link:hover { border-color: var(--cbLineStrong); color: var(--cbInk); background: var(--cbCard); text-decoration: none; }
.cbPager a.page-link:focus-visible { outline: 3px solid var(--cbPlum); outline-offset: 2px; }
.cbPager .page-item.active .page-link { border-color: var(--cbSun); background: var(--cbSun); color: var(--cbInk); }
.cbPager .page-item.disabled .page-link { color: #b3b9c4; background: var(--cbCard); }
/* The "…" between page numbers is a gap, not a button */
.cbPager .page-item.disabled:not(:first-child):not(:last-child) .page-link { min-width: 20px; padding: 0; border-color: transparent; background: none; }

@media (prefers-reduced-motion: reduce) {
    .cbCard, .cbCardItem, .cbCardPhoto img, .cbCardCta, .cbCardCta .cbIcon, .cbPager .page-link { transition: none; }
}
