/* ─────────────────────────────────────────────────────────────────────────
   archive.css — category, tag and author listings.

   Loaded only on is_archive() / is_home() (see functions.php). Scoped under
   .ub-archive so nothing here reaches the homepage or program pages.

   Shares the article surface's ink and rule values so a reader moving from a
   category into a story does not cross a visual seam. Those tokens are
   redeclared rather than imported: article.css does not load on an archive,
   and a var() pointing at an absent custom property silently computes to
   nothing.
   ───────────────────────────────────────────────────────────────────────── */

.ub-archive {
    --arch-ink: #1d2430;
    --arch-ink-soft: #55606d;
    --arch-rule: #e2e6ea;
    --arch-measure: 72rem;

    padding-bottom: clamp(3rem, 7vw, 5.5rem);
    background: #fff;
}

/* ── Archive header ─────────────────────────────────────────────────── */

.ub-archive__head {
    padding-block: clamp(2.25rem, 5vw, 3.75rem);
    background: linear-gradient(180deg, #faf8fc 0%, #fff 100%);
    border-bottom: 1px solid var(--arch-rule);
}

.ub-archive__head-inner,
.ub-archive__body {
    max-width: var(--arch-measure);
    margin-inline: auto;
    padding-inline: 1.5rem;
}

.ub-archive__crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8125rem;
    color: var(--arch-ink-soft);
}

.ub-archive__crumbs a {
    color: var(--arch-ink-soft);
    text-decoration: none;
    transition: color 0.15s ease;
}

.ub-archive__crumbs a:hover,
.ub-archive__crumbs a:focus-visible {
    color: var(--ub-purple, #592d82);
    text-decoration: underline;
}

.ub-archive__crumb-sep { opacity: 0.45; }

.ub-archive__crumb-current {
    color: var(--arch-ink);
    font-weight: 600;
}

.ub-archive__title {
    margin: 0.85rem 0 0;
    font-size: clamp(2rem, 1.4rem + 2.5vw, 3.25rem);
    font-weight: 700;
    line-height: 1.06;
    letter-spacing: -0.022em;
    color: var(--arch-ink);
    text-wrap: balance;
}

.ub-archive__desc {
    max-width: 44rem;
    margin-top: 0.9rem;
    font-size: 1.0625rem;
    line-height: 1.6;
    color: var(--arch-ink-soft);
    text-wrap: pretty;
}

.ub-archive__desc p { margin: 0; }

/* The count is orientation on a 43-page archive: it tells the reader how much
   is behind the listing before they start paging through it. */
.ub-archive__count {
    margin: 1.1rem 0 0;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ub-purple, #592d82);
}

/* ── Grid ───────────────────────────────────────────────────────────── */

.ub-archive__body {
    padding-top: clamp(2rem, 4vw, 3rem);
}

.ub-archive__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(1.25rem, 2.4vw, 2rem);
    margin: 0;
    padding: 0;
    list-style: none;
}

.ub-archive__item { display: flex; }

/* The lead spans the full row and turns horizontal, so the first story reads
   as the entry point instead of one tile among ten. */
.ub-archive__item--lead {
    grid-column: 1 / -1;
    margin-bottom: clamp(0.5rem, 1.5vw, 1.25rem);
    padding-bottom: clamp(1.5rem, 3vw, 2.25rem);
    border-bottom: 1px solid var(--arch-rule);
}

/* ── Card ───────────────────────────────────────────────────────────── */

.ub-card { display: flex; width: 100%; }

.ub-card__link {
    display: flex;
    flex-direction: column;
    width: 100%;
    text-decoration: none;
    color: inherit;
}

.ub-card__media {
    display: block;
    overflow: hidden;
    border-radius: 10px;
    aspect-ratio: 16 / 10;
    background: #eef1f4;
}

.ub-card__img,
.ub-card__media-fallback {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Posts without a featured image get a tinted panel rather than a broken box
   or a collapsed card — 1,447 attachments cover most, but not all, of the
   corpus. */
.ub-card__media-fallback {
    background:
        radial-gradient(120% 120% at 12% 8%, rgba(89, 45, 130, 0.16) 0%, rgba(89, 45, 130, 0) 58%),
        linear-gradient(140deg, #f0ecf6 0%, #e8eef3 100%);
}

.ub-card__img {
    transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.ub-card__link:hover .ub-card__img,
.ub-card__link:focus-visible .ub-card__img {
    transform: scale(1.04);
}

.ub-card__text {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.95rem;
}

.ub-card__cat {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ub-purple, #592d82);
}

.ub-card__title {
    font-size: 1.0625rem;
    font-weight: 650;
    line-height: 1.32;
    letter-spacing: -0.01em;
    color: var(--arch-ink);
    text-wrap: pretty;
    transition: color 0.15s ease;
}

.ub-card__link:hover .ub-card__title,
.ub-card__link:focus-visible .ub-card__title {
    color: var(--ub-purple, #592d82);
}

.ub-card__summary {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--arch-ink-soft);
    text-wrap: pretty;
}

.ub-card__meta {
    margin-top: auto;
    padding-top: 0.5rem;
    font-size: 0.8125rem;
    color: var(--arch-ink-soft);
}

/* Lead card ---------------------------------------------------------- */

.ub-archive__item--lead .ub-card__link {
    flex-direction: row;
    gap: clamp(1.25rem, 3vw, 2.5rem);
    align-items: center;
}

.ub-archive__item--lead .ub-card__media {
    flex: 0 0 56%;
    aspect-ratio: 16 / 9;
    box-shadow: 0 14px 32px rgba(29, 36, 48, 0.14);
}

.ub-archive__item--lead .ub-card__text {
    flex: 1 1 auto;
    gap: 0.65rem;
    padding-top: 0;
}

.ub-archive__item--lead .ub-card__title {
    font-size: clamp(1.4rem, 1.05rem + 1.5vw, 2.1rem);
    font-weight: 700;
    line-height: 1.14;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

.ub-archive__item--lead .ub-card__summary {
    font-size: 1.0625rem;
    line-height: 1.62;
}

.ub-archive__item--lead .ub-card__meta { margin-top: 0; }

/* ── Pagination ─────────────────────────────────────────────────────── */

.ub-archive .ub-pager {
    margin-top: clamp(2.5rem, 5vw, 4rem);
    padding-top: clamp(1.5rem, 3vw, 2.25rem);
    border-top: 1px solid var(--arch-rule);
}

.ub-archive .ub-pager .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.ub-archive .ub-pager .nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.ub-archive .ub-pager .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.6rem;
    height: 2.6rem;
    padding-inline: 0.75rem;
    border: 1px solid var(--arch-rule);
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--arch-ink);
    text-decoration: none;
    transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.ub-archive .ub-pager a.page-numbers:hover,
.ub-archive .ub-pager a.page-numbers:focus-visible {
    border-color: var(--ub-purple, #592d82);
    background: #f6f1fb;
    color: var(--ub-purple, #592d82);
}

.ub-archive .ub-pager .page-numbers.current {
    background: var(--ub-purple, #592d82);
    border-color: var(--ub-purple, #592d82);
    color: #fff;
}

.ub-archive .ub-pager .page-numbers.dots {
    min-width: 1.5rem;
    padding-inline: 0.2rem;
    border-color: transparent;
    color: var(--arch-ink-soft);
}

/* ── Empty state ────────────────────────────────────────────────────── */

.ub-archive__empty {
    max-width: 32rem;
    margin: clamp(2rem, 6vw, 4rem) auto;
    padding: clamp(2rem, 4vw, 3rem);
    border: 1px solid var(--arch-rule);
    border-radius: 12px;
    text-align: center;
}

.ub-archive__empty h2 {
    margin: 0 0 0.5rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--arch-ink);
}

.ub-archive__empty p {
    margin: 0 0 1.5rem;
    color: var(--arch-ink-soft);
}

.ub-archive__empty-link {
    display: inline-block;
    padding: 0.7rem 1.4rem;
    border-radius: 8px;
    background: var(--ub-purple, #592d82);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.18s ease;
}

.ub-archive__empty-link:hover,
.ub-archive__empty-link:focus-visible {
    background: var(--ub-purple-dark, #3f1d61);
}

/* ── Responsive ─────────────────────────────────────────────────────── */

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

@media (max-width: 760px) {
    /* The lead's side-by-side split stops working before the grid does: the
       text column gets too narrow to hold a 2rem headline. */
    .ub-archive__item--lead .ub-card__link {
        flex-direction: column;
        gap: 0;
        align-items: stretch;
    }

    .ub-archive__item--lead .ub-card__media {
        flex: none;
        width: 100%;
    }

    .ub-archive__item--lead .ub-card__text {
        padding-top: 0.95rem;
    }
}

@media (max-width: 600px) {
    .ub-archive__grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* Below the lead, cards become a scannable list: a full-width 16:10 image
       on every one of ten items turns the page into a long scroll of pictures
       with the headlines pushed apart. */
    .ub-archive__item:not(.ub-archive__item--lead) .ub-card__link {
        flex-direction: row;
        gap: 0.9rem;
        align-items: flex-start;
    }

    .ub-archive__item:not(.ub-archive__item--lead) .ub-card__media {
        flex: 0 0 34%;
        aspect-ratio: 1 / 1;
    }

    .ub-archive__item:not(.ub-archive__item--lead) .ub-card__text {
        padding-top: 0;
        gap: 0.35rem;
    }

    /* The summary is the first thing to go at this width — the headline and
       date carry the scan, and three lines of grey text under each would
       double the page length. */
    .ub-archive__item:not(.ub-archive__item--lead) .ub-card__summary {
        display: none;
    }

    .ub-archive__item:not(.ub-archive__item--lead) .ub-card__title {
        font-size: 0.9875rem;
    }

    .ub-archive .ub-pager .page-numbers {
        min-width: 2.4rem;
        height: 2.4rem;
        padding-inline: 0.55rem;
        font-size: 0.875rem;
    }

    /* "Previous"/"Next" wording is dropped on narrow screens so the row of
       numbers stays on one line; the arrows still carry the meaning. */
    .ub-archive .ub-pager__word {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ub-card__img { transition: none; }
    .ub-card__link:hover .ub-card__img,
    .ub-card__link:focus-visible .ub-card__img { transform: none; }
}
