/* contributions.css — Contributions page */

/* --------------------------------------------------------------------------
   1. PAGE
   -------------------------------------------------------------------------- */
.contrib {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1.5rem var(--gutter) 1.25rem;
}

.contrib__count {
    margin: 0;
    font-size: .72rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--glow);
    white-space: nowrap;
}

.contrib__title {
    flex: none;
    margin: .6rem 0 .5rem;
    /* One line, sized on the column width (cqi, see .contrib__main). Wraps on a phone. */
    font-size: clamp(1.1rem, 2.5cqi, 2.25rem);
    font-weight: 800;
    line-height: 1.16;
    text-transform: uppercase;
    color: var(--text-bright);
    text-wrap: balance;
}

.contrib__subtitle {
    flex: none;
    margin: 0 0 1.4rem;
    font-size: .9rem;
    color: var(--text-muted);
}

/* --- 2. TOOLBAR --- */
.toolbar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 1rem 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.6rem;
}

.toolbar__search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 0 100%;
}

.toolbar__icon {
    position: absolute;
    left: 14px;
    width: 16px;
    height: 16px;
    color: var(--text);
    pointer-events: none;
}

/* Search field at text size; 16px minimum to avoid the iOS zoom. */
.toolbar__search .field {
    padding-left: 42px;
    font-size: 1rem;
}

.toolbar__search .field::placeholder {
    color: var(--text);   /* same grey as the card text */
}

.field {
    width: 100%;
    padding: 12px 13px;
    background: #070b13;
    border: 1px solid rgba(var(--star-rgb), .2);
    border-radius: 3px;
    color: var(--text);
    font-family: var(--sans);
    font-size: .78rem;
    outline: none;
    transition: border-color .2s ease;
}

.field:focus {
    border-color: rgba(var(--glow-rgb), .55);
}

.field::placeholder {
    color: var(--text-muted);
}

/* Submit button for browsers without JavaScript; contributions.js hides it. */
.toolbar__submit {
    padding: 11px 16px;
    background: transparent;
    border: 1px solid rgba(var(--glow-rgb), .4);
    border-radius: 3px;
    color: var(--glow);
    font-family: var(--sans);
    font-size: .72rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    cursor: pointer;
}

.toolbar__clear {
    color: var(--text-muted);
    font-size: .72rem;
    letter-spacing: .1em;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color .2s ease, border-color .2s ease;
}

.toolbar__clear:hover,
.toolbar__clear:focus-visible {
    color: var(--glow-soft);
    border-bottom-color: var(--glow-soft);
}

/* Keeps its space when hidden, so the row does not shift. */
.toolbar__clear[hidden] {
    display: inline !important;
    visibility: hidden;
}

/* Under 1600px the label takes its own line above the pills. */
@media (max-width: 1599px) {
    .filters__legend {
        flex: 1 1 100%;
        margin-right: 0;
    }
}

/* Below 1600px the clear link only takes space when shown. */
@media (max-width: 1599px) {
    .toolbar__clear[hidden] {
        display: none !important;
    }
}

/* Less padding in the name field when the row is tight. */
@media (max-width: 1279px) {
    .filter--text:not(.filter--active) .field {
        padding-left: 14px;
        padding-right: 14px;
    }
}

/* --- 3. FILTERS --- */
.filters {
    /* Full row width; the name field grows into the remaining space. */
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}

.filters__legend {
    margin-right: .4rem;
    font-size: .78rem;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

.filter {
    position: relative;
    flex: none;
}

/* Shared pill style. */
.filter .field,
.filter .calendar__trigger {
    width: auto;
    height: 46px;
    padding: 0 18px;
    background: transparent;
    border: 1px solid rgba(var(--star-rgb), .2);
    border-radius: 3px;
    color: var(--text-muted);
    font-family: var(--sans);
    font-size: .9rem;
    letter-spacing: .1em;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease, background .2s ease;
}

.filter .field:hover,
.filter .calendar__trigger:hover {
    color: var(--text-bright);
}

.filter .field:focus-visible,
.filter .calendar__trigger:focus-visible {
    outline: 2px solid var(--glow);
    outline-offset: 2px;
}

/* Active pill, with room for its ×. */
.filter--active .field,
.filter--active .calendar__trigger {
    padding-right: 2.4rem;
    border-color: rgba(var(--glow-rgb), .6);
    background: rgba(var(--glow-rgb), .1);
    color: var(--glow-soft);
}

.filter__clear {
    position: absolute;
    top: 50%;
    right: .55rem;
    display: grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    transform: translateY(-50%);
    background: none;
    border: 0;
    border-radius: 50%;
    color: var(--glow-soft);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.filter__clear:hover,
.filter__clear:focus-visible {
    background: rgba(var(--glow-rgb), .18);
    outline: none;
}

/* First name field, 7rem to 13rem, shrinking first. */
.filter--text {
    flex: 1 1 7rem;
    min-width: 0;
    max-width: 13rem;
}

.filter--text .field {
    width: 100%;
    cursor: text;
}

.filter--text .field::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

/* Date: the calendar icon is replaced by the × when a day is set. */
.filter.calendar .calendar__trigger {
    gap: .6rem;
}

.filter--active .calendar__icon {
    display: none;
}

/* Selects: gold chevron on the pill, replaced by the × when a value is chosen. */
.filter--select .field {
    padding-right: 2.4rem;
}

.filter--select::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 1rem;
    width: .42rem;
    height: .42rem;
    border-right: 1.5px solid var(--glow);
    border-bottom: 1.5px solid var(--glow);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}

.filter--select.filter--active::after {
    display: none;
}

/* Options get an explicit colour, since the open list uses the system background. */
.filter option {
    background: var(--night);
    color: var(--text-bright);
}

/* --------------------------------------------------------------------------
   4. COLUMNS
   -------------------------------------------------------------------------- */
.contrib__columns {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
    column-gap: clamp(1.5rem, 3.5vw, 3.5rem);
    align-items: stretch;
}

.contrib__main {
    container-type: inline-size;   /* for the title's cqi */
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.contrib__grid {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* --- 5. CARD GRID --- */
.grid {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.grid__empty {
    flex: 1 1 auto;
    display: grid;
    place-items: center;
    margin: 0;
    color: var(--text-muted);
    font-size: .9rem;
    text-align: center;
}

.card {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    min-height: 0;
    overflow: hidden;
    padding: 15px 16px 13px;
    background: var(--night-raised);
    border: 1px solid rgba(var(--glow-rgb), .16);
    border-radius: 4px;
    transition: border-color .2s ease;

    /* Staggered entrance, in reading order. */
    animation: card-in .5s ease both;
    animation-delay: calc(min(var(--index, 0), 12) * 50ms);
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

/* Hover on the card; :focus-within so keyboard focus on the link lights the card too. */
.card:hover,
.card:focus-within {
    border-color: rgba(var(--glow-rgb), .5);
}

.card__kind {
    flex: none;
    margin: 0;
    font-size: .62rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--glow);
}

.card__name {
    flex: none;
    margin: 0;
    font-size: .95rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--glow-soft);
}

.card__link {
    color: inherit;
    text-decoration: none;
}

/* The link's ::after covers the card, so the text stays selectable. */
.card__link::after {
    content: "";
    position: absolute;
    inset: 0;
}

.card {
    position: relative;
}

.card__meta {
    flex: none;
    margin: 0;
    font-size: .66rem;
    letter-spacing: .05em;
    color: var(--text-muted);
}

/* Clamped by CSS, not truncated server-side. */
.card__excerpt {
    /* At most three lines; the excerpt shrinks first. */
    flex: 0 1 auto;
    min-height: 0;
    margin: .15rem 0 0;
    /* Upright, slightly smaller than the message size. */
    font-size: .89rem;   /* 16px */
    line-height: 1.5;
    color: var(--text);
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.card[data-clamped] .card__excerpt {
    /* The last line fades out when clamped. */
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 1.5em), transparent);
            mask-image: linear-gradient(to bottom, #000 calc(100% - 1.5em), transparent);
    /* The mask creates a layer above the link's ::after; let clicks through. */
    pointer-events: none;
}

.card__arrow {
    /* Pushed to the bottom, so the arrows line up across the grid. */
    flex: none;
    margin: auto 0 0;
    padding-top: .25rem;
    text-align: right;
    color: var(--glow);
    font-size: .82rem;
}

.card__more {
    display: none;
    font-size: .7rem;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.card[data-clamped] .card__more {
    display: inline;
}

/* --- 6. PAGINATION --- */
.pager {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    margin-top: .9rem;
}

.pager__page,
.pager__step {
    padding: 3px 8px;
    color: var(--text-muted);
    font-size: .82rem;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color .2s ease, border-color .2s ease;
}

.pager__page:hover,
.pager__step:hover {
    color: var(--glow-soft);
}

.pager__page--current {
    color: var(--glow-soft);
    border-bottom-color: var(--glow);
}

.pager__step--off {
    opacity: .3;
}

.pager__gap {
    padding: 3px 2px;
    color: var(--text-muted);
    font-size: .82rem;
}

/* --- 7. RIGHT COLUMN --- */
.contrib__aside {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    padding: 9.75rem 0 0 clamp(1.5rem, 3.5vw, 3.5rem);
    border-left: 1px solid var(--rule);
}

/* Bleeds into the margins, faded out on all sides. */
.contrib__deco {
    position: absolute;
    top: -1.5rem;
    right: calc(-1 * var(--gutter));
    left: 38%;
    height: 40%;
    background: url("../img/messages-feuilles-deco.webp") top right / cover no-repeat;
    opacity: .8;
    pointer-events: none;
    /* Vignette plus a top-down fade, intersected. */
    -webkit-mask-image:
        radial-gradient(ellipse 55% 50% at 50% 45%, #000 45%, transparent 100%),
        linear-gradient(to bottom, #000 35%, transparent 80%);
    -webkit-mask-composite: source-in;
            mask-image:
        radial-gradient(ellipse 55% 50% at 50% 45%, #000 45%, transparent 100%),
        linear-gradient(to bottom, #000 35%, transparent 80%);
            mask-composite: intersect;
}

.deposit__title,
.deposit__text,
.deposit__button {
    position: relative;   /* above the decoration */
}

.deposit__title {
    margin: 0 0 .9rem;
    font-size: clamp(1rem, 1.25vw, 1.25rem);
    font-weight: 400;
    line-height: 1.3;
    color: var(--text-bright);
    /* Dark halo for readability over the decoration. */
    text-shadow: 0 0 14px rgba(3, 4, 8, .95), 0 1px 3px rgba(3, 4, 8, .9);
}

.deposit__text {
    margin: 0 0 1.4rem;
    font-size: .9rem;   /* same size as .contrib__subtitle */
    line-height: 1.6;
    color: var(--text-muted);
}

.deposit__button {
    flex: none;
    align-self: flex-start;
    /* Vertically centred in the remaining height. */
    margin: auto 0;
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    padding: 15px 26px;
    background: var(--glow);
    border-radius: var(--radius-sm);   /* same radius as the buttons */
    color: var(--night);
    /* Same type as .button in base.css. */
    font-size: .87rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    text-decoration: none;
    transition: background .2s ease;
}

.deposit__button:hover,
.deposit__button:focus-visible {
    background: var(--glow-soft);
}

.deposit__plus {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1;
}

.deposit__button svg {
    width: 15px;
    height: 15px;
}

/* --- Latest contributions --- */
.recent {
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    /* "safe": an overflowing card stays below the button. */
    justify-content: safe center;
    margin-top: 1.75rem;
}

/* The card fits the remaining height: every box down to the text may shrink. */
.recent__frame {
    flex: 0 1 auto;
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: .75rem;
    min-height: 0;
}

.recent__list {
    flex: 1;
    /* All slides in the same grid cell, so the card keeps the height of the tallest one. */
    display: grid;
    grid-template-rows: minmax(0, max-content);
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.recent__card {
    position: relative;
    grid-area: 1 / 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 28px;
    background: rgba(10, 14, 23, .9);
    border: 1px solid rgba(var(--glow-rgb), .5);
    text-align: center;

}

/* Only the content fades; the card stays. */
.recent__card:not([data-hidden]) > * {
    animation: slide-fade .45s ease both;
}

.recent__card[data-hidden] {
    visibility: hidden;
}

@keyframes slide-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Reduced motion: no slide or card animation. */
@media (prefers-reduced-motion: reduce) {
    .recent__card:not([data-hidden]) > *,
    .card {
        animation: none;
    }
}

.recent__mark {
    margin: 0 0 .5rem;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--glow);
}

.recent__text {
    margin: 0;
    font-size: 1rem;
    font-style: italic;
    line-height: 1.55;
    color: var(--text-bright);
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 6;

    /* Shrinks with the card (see .recent__frame). */
    flex: 0 1 auto;
    min-height: 0;
}

/* The last line fades out when clamped. */
.recent__card[data-clamped] .recent__text {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 1.5em), transparent);
            mask-image: linear-gradient(to bottom, #000 calc(100% - 1.5em), transparent);
    /* The mask creates a layer above the link's ::after; let clicks through. */
    pointer-events: none;
}

/* Only when featured.js found the text clamped. */
.recent__more {
    display: none;
    margin: .5rem 0 0;
    font-size: .7rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--glow);
}

.recent__card[data-clamped] .recent__more {
    display: block;
}

.recent__rule {
    width: 44px;
    height: 1px;
    margin: 18px 0 14px;
    background: rgba(var(--glow-rgb), .5);
}

.recent__name {
    margin: 0;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--glow-soft);
}

.recent__link {
    color: inherit;
    text-decoration: none;
}

/* The name is the link; its ::after covers the card. */
.recent__link::after {
    content: "";
    position: absolute;
    inset: 0;
}

.recent__card:hover,
.recent__card:focus-within {
    border-color: var(--glow-soft);
}

.recent__date {
    margin: .25rem 0 0;
    font-size: .7rem;
    letter-spacing: .1em;
    color: var(--text-muted);
}

.recent__arrow {
    flex: none;
    align-self: center;
    padding: 6px;
    background: none;
    border: 0;
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    transition: color .2s ease;
}

.recent__arrow:hover,
.recent__arrow:focus-visible {
    color: var(--glow-soft);
}

.recent__dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 12px 0 0;
}

/* Arrows on each side of the dots. */
.recent__dots .recent__arrow {
    margin: 0 .5rem;
}

.recent__dot {
    width: 7px;
    height: 7px;
    padding: 0;
    background: rgba(var(--star-rgb), .35);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.recent__dot[aria-current] {
    background: var(--glow-soft);
}

/* --- 7b. TALL WINDOWS --- */
/* More lines of excerpt when the rows have the height for them. */
@media (min-height: 1100px) {
    .card__excerpt {
        -webkit-line-clamp: 6;
    }

    .recent__text {
        -webkit-line-clamp: 9;
    }
}

@media (min-height: 1300px) {
    .card__excerpt {
        -webkit-line-clamp: 9;
    }

    .recent__text {
        -webkit-line-clamp: 12;
    }
}

@media (min-height: 1700px) {
    .card__excerpt {
        -webkit-line-clamp: 14;
    }

    .recent__text {
        -webkit-line-clamp: 18;
    }
}

/* --- 8. SHORT WINDOWS --- */
/* The column gives up its top margin first. */
@media (max-height: 960px) {
    .contrib__aside {
        padding-top: 5.6rem;
    }
}

@media (max-height: 820px) {
    .contrib__subtitle {
        margin-bottom: 1rem;
    }

    .toolbar {
        margin-bottom: 1rem;
    }

    .card__excerpt {
        -webkit-line-clamp: 2;
    }

    .contrib__aside {
        padding-top: 5.6rem;
    }

    .recent__text {
        -webkit-line-clamp: 4;
    }
}

@media (max-height: 720px) {
    .contrib__aside {
        padding-top: 3.75rem;
    }

    .recent__text {
        -webkit-line-clamp: 3;
    }
}

@media (max-height: 700px) {
    /* Below this height the excerpt is hidden; the card keeps the name, kind and date. */
    .card__excerpt {
        display: none;
    }
}

/* --- 9. NARROW AND PORTRAIT WINDOWS --- */
/* The page scrolls and the rows take the height of their content. */
@media (max-width: 1000px), (orientation: portrait) {
    .contrib {
        overflow: visible;
        padding-bottom: 2.5rem;
    }

    .contrib__columns {
        grid-template-columns: 1fr;
    }

    /* The rule moves from the side to the top; the decoration is hidden. */
    .contrib__aside {
        margin-top: 2rem;
        padding: 1.6rem 0 0;
        border-left: 0;
        border-top: 1px solid var(--rule);
    }

    .contrib__deco {
        display: none;
    }

    /* The rows take the height of what is in them. */
    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: auto;
    }

    .card__excerpt {
        -webkit-line-clamp: 3;
        display: -webkit-box;
    }
}

@media (max-width: 640px) {
    /* Placeholder at 16px (iOS minimum) with an ellipsis. */
    .toolbar__search .field,
    .toolbar__search .field::placeholder {
        font-size: .9rem;
        text-overflow: ellipsis;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    /* Reset flex-basis, which would become a height in a column layout. */
    .toolbar__search {
        flex: none;
        width: 100%;
        max-width: none;
    }

    /* Pills two by two, half the width each. */
    .filters {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .6rem;
    }

    .filters__legend {
        grid-column: 1 / -1;
    }

    /* Less tracking and padding, so the placeholder fits half a phone. */
    .filter .field,
    .filter .calendar__trigger,
    .filter--text .field {
        width: 100%;
        min-width: 0;
        padding-left: 14px;
        letter-spacing: .04em;
    }

    .filter:not(.filter--active) .calendar__trigger,
    .filter--text:not(.filter--active) .field {
        padding-right: 14px;
    }

    .filter .calendar__trigger {
        justify-content: space-between;
    }

    .toolbar__clear {
        align-self: flex-start;
    }

    .grid {
        grid-template-columns: 1fr;
    }
}

/* --- 10. SINGLE CONTRIBUTION --- */ /* The card (.letter) is in site.css. */
.contrib--one {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    padding-top: 2rem;
    padding-bottom: 3rem;
}

/* 320px phones: slightly smaller type in the pills. */
@media (max-width: 360px) {
    .filter .field,
    .filter .calendar__trigger,
    .filter--text .field {
        padding-left: 10px;
        font-size: .7rem;
        letter-spacing: 0;
    }

    .filter:not(.filter--active) .calendar__trigger,
    .filter--text:not(.filter--active) .field {
        padding-right: 10px;
    }
}

/* Touch screens: no field under 16px, or iOS zooms into it on focus. */
@media (pointer: coarse) {
    .field,
    .filter .field,
    .filter--text .field {
        font-size: 1rem;
    }

    /* Smaller placeholder so it fits half a phone. */
    .field::placeholder {
        font-size: .9rem;
    }

    .toolbar__search .field::placeholder {
        font-size: 1rem;
    }
}

@media (pointer: coarse) and (max-width: 360px) {
    .field::placeholder {
        font-size: .7rem;
    }
}
