/*
 * Public discovery pages: discover, the shared campaign list, and categories.
 *
 * These pages reuse the homepage design system rather than defining a second
 * one -- .cfx-grid, .cfx-card, .cfx-empty, .cfx-btn and the .cfx token block
 * all come from crowdfunding-home.css, which is why every page here opens with
 * a .cfx wrapper. Only what is genuinely specific to a listing page is below,
 * under .cfd-.
 *
 * Nothing here declares a min-height or a fixed height. A short results page
 * is a short page: the empty state renders only when there are genuinely no
 * results, and the filter bar's Clear link and the count above it both
 * disappear when they have nothing to report.
 */

/* ------------------------------- Page head ------------------------------- */

.cfd-head {
    padding-block: clamp(1.5rem, 4vw, 2.5rem) 0;
    background:
        radial-gradient(70% 120% at 80% 0%, hsl(var(--base) / 0.09), transparent 62%),
        hsl(var(--white));
}

.cfd-head__body {
    padding-block: clamp(1.25rem, 3vw, 2rem);
}

.cfd-head__title {
    font-family: var(--heading-font);
    font-size: clamp(1.75rem, 4vw, 2.75rem);
    line-height: 1.1;
    color: var(--cfx-ink);
    text-wrap: balance;
    margin: 0;
}

.cfd-head__sub {
    margin: 0.65rem 0 0;
    color: var(--cfx-ink-soft);
    max-width: 60ch;
}

.cfd-head__count {
    margin: 0.75rem 0 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: hsl(var(--base-d-200));
    font-variant-numeric: tabular-nums;
}

/* ---------------------------- Discovery nav ------------------------------ */

/*
 | A horizontal scroller on small screens rather than a wrapping pile of
 | chips: seven links wrapping to three rows pushes the actual page content
 | below the fold on a phone.
 */
.cfd-nav {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.35rem;
    scrollbar-width: thin;
    /* Edge-to-edge scroll on mobile, without the container's padding clipping it. */
    scroll-snap-type: x proximity;
}

.cfd-nav::-webkit-scrollbar { height: 4px; }
.cfd-nav::-webkit-scrollbar-thumb {
    background: hsl(var(--base) / 0.25);
    border-radius: 999px;
}

.cfd-nav__link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
    scroll-snap-align: start;
    padding: 0.5rem 0.95rem;
    border: 1px solid var(--cfx-line);
    border-radius: 999px;
    background: var(--cfx-surface);
    color: var(--cfx-ink-soft);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: border-color 0.18s ease, color 0.18s ease, background-color 0.18s ease;
}

.cfd-nav__link:hover,
.cfd-nav__link:focus-visible {
    border-color: hsl(var(--base));
    color: hsl(var(--base-d-200));
}

.cfd-nav__link--here {
    background: hsl(var(--base));
    border-color: hsl(var(--base));
    color: hsl(var(--white));
}

.cfd-nav__link--here:hover,
.cfd-nav__link--here:focus-visible {
    background: hsl(var(--base-d-200));
    border-color: hsl(var(--base-d-200));
    color: hsl(var(--white));
}

/* ------------------------------- Filter bar ------------------------------ */

.cfd-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.85rem;
    padding: 1.15rem;
    margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
    background: var(--cfx-surface);
    border: 1px solid var(--cfx-line);
    border-radius: var(--cfx-radius);
}

.cfd-filter__field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    /* Each control takes what it needs and wraps rather than being squeezed. */
    flex: 1 1 11rem;
    min-width: 0;
}

.cfd-filter__field--grow { flex: 2 1 16rem; }

.cfd-filter__label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--cfx-ink-soft);
}

.cfd-filter__actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex: 0 0 auto;
}

.cfd-filter__clear {
    font-size: 0.875rem;
    color: var(--cfx-ink-soft);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cfd-filter__clear:hover { color: hsl(var(--base-d-200)); }

/* --------------------------------- Body ---------------------------------- */

.cfd-body {
    padding-block: clamp(1.75rem, 4vw, 3rem) clamp(3rem, 6vw, 5rem);
}

.cfd-body__head { margin-bottom: 1.25rem; }

.cfd-featured {
    padding-block: clamp(1.75rem, 4vw, 3rem);
    background: hsl(var(--base) / 0.04);
}

.cfd-pages { margin-top: clamp(2rem, 4vw, 3rem); }

.cfd-empty__hint {
    margin: 0.85rem 0 0;
    font-size: 0.9rem;
}

.cfd-empty__hint a { color: hsl(var(--base-d-200)); font-weight: 600; }

/* ------------------------------- Categories ------------------------------ */

.cfd-tiles {
    display: grid;
    gap: var(--cfx-gap);
    /* auto-fill, so a handful of categories do not stretch to fill a 4-up row. */
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
}

.cfd-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.75rem 1.25rem;
    text-align: center;
    text-decoration: none;
    background: var(--cfx-surface);
    border: 1px solid var(--cfx-line);
    border-radius: var(--cfx-radius);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.cfd-tile:hover,
.cfd-tile:focus-visible {
    transform: translateY(-3px);
    border-color: hsl(var(--base) / 0.45);
    box-shadow: var(--cfx-shadow);
}

.cfd-tile__icon {
    display: grid;
    place-items: center;
    width: 3.25rem;
    aspect-ratio: 1;
    border-radius: 50%;
    background: hsl(var(--base) / 0.1);
    color: hsl(var(--base));
    font-size: 1.5rem;
}

.cfd-tile__name {
    font-weight: 600;
    color: var(--cfx-ink);
    line-height: 1.35;
}

.cfd-tile__count {
    font-size: 0.8125rem;
    color: var(--cfx-ink-soft);
    font-variant-numeric: tabular-nums;
}


/* ============================== Marketplace ============================== */

/*
 | The catalogue of delivered products, and a product's own page.
 |
 | Products get their own card rather than the campaign card. A campaign is
 | asking for money and leads with a progress bar and time remaining; a
 | delivered product is finished, and putting a funding bar on it would say
 | something untrue.
 |
 | Loaded with the rest of the discovery styles, which every public
 | crowdfunding page pulls in through the style partial.
 */

.cfm-grid {
    display: grid;
    gap: var(--cfx-gap);
    grid-template-columns: 1fr;
}

@media (min-width: 576px) { .cfm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 992px) { .cfm-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.cfm-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--cfx-surface);
    border: 1px solid var(--cfx-line);
    border-radius: var(--cfx-radius);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.cfm-card:hover,
.cfm-card:focus-within {
    transform: translateY(-3px);
    border-color: hsl(var(--base) / 0.45);
    box-shadow: var(--cfx-shadow-lift);
}

.cfm-card__media { position: relative; overflow: hidden; }

.cfm-card__media img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 400 / 220;
    object-fit: cover;
}

.cfm-card__cat {
    position: absolute;
    left: 0.75rem;
    top: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: hsl(var(--white) / 0.92);
    color: hsl(var(--base-two));
    font-size: 0.7rem;
    font-weight: 600;
}

.cfm-card__body {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 1.15rem 1.25rem 1.35rem;
    /* Pushes the meta row to the bottom so cards align across a row. */
    flex: 1 1 auto;
}

.cfm-card__title {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.35;
    text-wrap: balance;
}

.cfm-card__title a { color: var(--cfx-ink); text-decoration: none; }
.cfm-card__title a:hover { color: hsl(var(--base-d-200)); }

.cfm-card__text {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--cfx-ink-soft);
}

.cfm-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-top: auto;
    padding-top: 0.6rem;
    font-size: 0.8125rem;
    color: var(--cfx-ink-soft);
}

/* A released version number, wherever it appears. */
.cfm-ver {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    background: hsl(var(--base) / 0.1);
    color: hsl(var(--base-d-200));
    font-size: 0.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.cfm-by { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------- A product's page --------------------------- */

.cfm-show { padding-block: clamp(2rem, 5vw, 4rem) clamp(3rem, 6vw, 5rem); }

.cfm-show__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(1.5rem, 4vw, 2.5rem);
    align-items: start;
}

@media (min-width: 992px) {
    .cfm-show__grid { grid-template-columns: minmax(0, 1.7fr) minmax(18rem, 0.9fr); }
    .cfm-show__side { position: sticky; top: 1.5rem; }
}

.cfm-show__main { min-width: 0; }

.cfm-show__cover {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1180 / 600;
    object-fit: cover;
    border-radius: var(--cfx-radius);
    margin-bottom: 1.5rem;
}

.cfm-show__title {
    margin: 0 0 0.5rem;
    font-family: var(--heading-font);
    font-size: clamp(1.6rem, 3.5vw, 2.4rem);
    line-height: 1.15;
    color: var(--cfx-ink);
    text-wrap: balance;
}

.cfm-show__tagline {
    margin: 0 0 1.25rem;
    font-size: 1.05rem;
    color: var(--cfx-ink-soft);
    max-width: 62ch;
}

.cfm-prose { color: var(--cfx-ink-soft); line-height: 1.7; max-width: 68ch; }
.cfm-prose :is(h2, h3, h4) { color: var(--cfx-ink); margin-top: 1.6rem; }
.cfm-prose img { max-width: 100%; height: auto; border-radius: var(--cfx-radius-sm); }

/* Author-written HTML can carry a wide table; it scrolls rather than the page. */
.cfm-prose :is(table, pre) { display: block; max-width: 100%; overflow-x: auto; }

.cfm-show__origin {
    margin: 1.5rem 0 0;
    padding-top: 1.25rem;
    border-top: 1px solid var(--cfx-line);
    font-size: 0.925rem;
    color: var(--cfx-ink-soft);
}

.cfm-show__origin a { color: hsl(var(--base-d-200)); font-weight: 600; }

/* --------------------------------- Panel --------------------------------- */

.cfm-panel {
    padding: 1.35rem;
    background: var(--cfx-surface);
    border: 1px solid var(--cfx-line);
    border-radius: var(--cfx-radius);
}

.cfm-panel__title {
    margin: 0 0 1rem;
    font-size: 1.05rem;
    color: var(--cfx-ink);
}

.cfm-version {
    padding-bottom: 1.1rem;
    margin-bottom: 1.1rem;
    border-bottom: 1px solid var(--cfx-line);
}

.cfm-version:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }

.cfm-version__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.cfm-version__head time { font-size: 0.75rem; color: var(--cfx-ink-soft); }

.cfm-version__title { margin: 0 0 0.35rem; font-weight: 600; color: var(--cfx-ink); }

.cfm-version__log {
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--cfx-ink-soft);
    margin-bottom: 0.75rem;
}

.cfm-version__log :is(ul, ol) { padding-left: 1.1rem; margin: 0.35rem 0; }

/*
 | The locked state. It explains how access is earned rather than showing a
 | disabled button — a greyed-out Download implies the file is there and being
 | withheld, when the real answer is that access comes from backing.
 */
.cfm-version__locked {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0;
    padding: 0.7rem 0.85rem;
    border-radius: var(--cfx-radius-sm);
    background: hsl(var(--base) / 0.05);
    font-size: 0.8125rem;
    line-height: 1.55;
    color: var(--cfx-ink-soft);
}

.cfm-version__locked i { color: hsl(var(--base)); flex-shrink: 0; margin-top: 0.15rem; }

.cfm-notsale {
    margin: 1rem 0 0;
    padding: 0.9rem 1.1rem;
    border-left: 3px solid hsl(var(--base) / 0.45);
    border-radius: var(--cfx-radius-sm);
    background: hsl(var(--base) / 0.04);
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--cfx-ink-soft);
}

@media (prefers-reduced-motion: reduce) {
    .cfm-card:hover { transform: none; }
}

/* ----------------------------- Housekeeping ------------------------------ */

.cfd { overflow-x: clip; }

@media (prefers-reduced-motion: reduce) {
    .cfd-tile:hover { transform: none; }
}
