/* The pages around the ballot: the opening announcement, the rules, the participation board and the « Vote clos » page. */

/* Page card: the title card of a page that goes on under it, so it does not fill the screen. */
.page-card {
    display: grid;
    gap: var(--space-6);
    padding: var(--space-8) 0 var(--space-7);
}

/* Segment title: the heading of each part under a page card. */
.segment-title {
    font-stretch: var(--wide);
    font-size: var(--size-lead);
    font-weight: var(--weight-super);
    letter-spacing: 0.01em;
    line-height: 1.15;
    text-transform: uppercase;
    text-wrap: balance;
}

/* « Vote bientôt »: the opening title card with the anthem on stage beside it, the band running on behind
   its cover. The super shrinks to keep « bientôt » clear of the cover: --fit is that word's width in em. */
.premiere {
    --art: min(36rem, 34vw, calc(100dvh - var(--masthead) - 2 * var(--space-8) - 4rem));
    --fit: 5.75;

    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--art) var(--safe);
    grid-template-rows: 1fr auto auto auto 1fr;
    min-height: calc(100dvh - var(--masthead));
    padding: var(--space-7) 0;
}

.premiere__super {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: min(var(--size-super), (100vw - var(--art) - 2 * var(--safe) - var(--space-7)) / var(--fit));
}

.premiere .premiere__super > * {
    padding-right: calc(var(--art) + var(--safe) + var(--space-7));
}

.premiere__tier {
    grid-column: 1;
    grid-row: 3;
}

.premiere__tier time {
    color: var(--text);
}

.premiere__art {
    position: relative;
    z-index: 1;
    grid-column: 2;
    grid-row: 1 / -1;
    align-self: center;
    container-type: inline-size;
}

.premiere__cover {
    --step: 3;

    position: relative;
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--ink-1);
}

/* The lower third hangs from the cover's bottom-left corner, over no more than its bottom sliver. */
.premiere .premiere__credits {
    position: relative;
    left: auto;
    bottom: auto;
    max-width: calc(100% + var(--space-4));
    margin: -3cqw 0 0 calc(-1 * var(--space-4));
}

.premiere .lower-third__name span {
    animation-delay: calc(8 * var(--stagger));
}

.premiere .lower-third__tier {
    animation-delay: calc(10 * var(--stagger));
}

.premiere__action {
    --step: 11;

    grid-column: 1;
    grid-row: 4;
    margin-top: var(--space-7);
}

/* Stacked: the statement, then the anthem stepped in from the margin its lower third keeps. */
@media (max-width: 60rem) {
    .premiere {
        --art: min(24rem, 100vw - 2 * var(--safe) - var(--space-4), max(12rem, 100dvh - var(--masthead) - 30rem));

        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 1fr auto auto auto auto 1fr;
    }

    .premiere__super {
        font-size: var(--size-super);
    }

    .premiere .premiere__super > * {
        padding-right: var(--safe);
    }

    .premiere__art {
        grid-column: 1;
        grid-row: 4;
        width: var(--art);
        margin: var(--space-7) 0 0 calc(var(--safe) + var(--space-4));
    }

    .premiere__action {
        grid-row: 5;
    }
}

/* Règles: a running order of the rules, each heading beside its copy. */
.rules {
    padding-bottom: var(--space-8);
}

.rule {
    display: grid;
    gap: var(--space-4);
    max-width: 58rem;
    margin: 0 var(--safe);
    padding: var(--space-6) 0;
    box-shadow: inset 0 var(--hairline) 0 var(--rule);
}

.rule__body {
    display: grid;
    align-content: start;
    gap: var(--space-4);
    max-width: 40rem;
}

.rule__body b {
    font-weight: var(--weight-strong);
}

.rule__body time {
    font-weight: var(--weight-strong);
    white-space: nowrap;
}

.rules__end {
    margin: var(--space-6) var(--safe) 0;
}

/* Before the opening, « Aller voter » gives way to a locked note: the same height, never a key. */
.opens {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: fit-content;
    min-height: var(--control);
    padding: var(--space-2) var(--space-5) var(--space-2) var(--space-4);
    background: var(--ink-1);
    color: var(--text-muted);
    line-height: 1.3;
}

.opens time {
    color: var(--text);
    font-weight: var(--weight-strong);
    white-space: nowrap;
}

.criteria {
    gap: var(--space-6);
}

.criterion {
    display: grid;
    gap: var(--space-2);
}

.criterion__name {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--size-lead);
    font-weight: var(--weight-strong);
    line-height: 1.2;
}

.criterion__name .icon {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--text-muted);
}

.criterion__summary {
    margin-top: calc(-1 * var(--space-1));
    color: var(--text-muted);
}

.rules__note {
    padding: var(--space-3) var(--space-4);
    background: var(--ink-1);
    color: var(--text-muted);
}

/* The scale as a key: each value in the cell colour it takes once chosen. */
.scale-key {
    display: grid;
    gap: 3px;
}

.scale-key__row {
    position: relative;
    display: grid;
    align-content: center;
    gap: 2px;
    min-height: var(--cell);
    padding: var(--space-2) var(--space-4) var(--space-2) calc(var(--cell) + var(--space-4));
    background: var(--ink-1);
}

.scale-key__cell {
    position: absolute;
    inset: 0 auto 0 0;
    display: grid;
    place-items: center;
    width: var(--cell);
    background: var(--sign);
    color: var(--on-sign);
    font-stretch: var(--narrow);
    font-size: var(--size-cell);
    font-weight: var(--weight-strong);
}

.scale-key__label {
    font-weight: var(--weight-strong);
    line-height: 1.3;
}

.scale-key__meaning {
    color: var(--text-muted);
    font-size: var(--size-small);
    line-height: 1.4;
}

/* The jokers as the bar shows them: one pair per criterion. */
.joker-set {
    display: flex;
    flex-wrap: wrap;
    justify-self: start;
    gap: var(--space-3) var(--space-5);
    padding: var(--space-3) var(--space-4);
    background: var(--ink-1);
    list-style: none;
}

.joker-set li {
    display: flex;
    align-items: center;
    gap: 3px;
}

.joker-set .icon {
    width: 1rem;
    height: 1rem;
    margin-right: 3px;
    color: var(--text-muted);
}

/* The method: three steps, numbered like the running order. */
.method {
    display: grid;
    gap: var(--space-4);
    padding: 0;
    list-style: none;
    counter-reset: step;
}

.method li {
    position: relative;
    padding-left: var(--space-7);
    counter-increment: step;
}

.method li::before {
    content: counter(step, decimal-leading-zero);
    position: absolute;
    top: -0.1em;
    left: 0;
    color: var(--ink-6);
    font-stretch: var(--narrow);
    font-size: var(--size-lead);
    font-weight: var(--weight-strong);
}

@media (min-width: 64rem) {
    .rule {
        grid-template-columns: 15rem minmax(0, 40rem);
        column-gap: var(--space-7);
        padding: var(--space-7) 0;
    }

    .rule__title {
        position: sticky;
        top: calc(var(--masthead) + var(--space-5));
        align-self: start;
    }

    .rules__end {
        margin-left: calc(var(--safe) + 15rem + var(--space-7));
    }
}

/* Participation: who is in and how far along. Ink rows like the ballot map, never a leaderboard. */
.board-page {
    display: grid;
    gap: var(--space-6);
    max-width: calc(52rem + 2 * var(--safe));
    padding: var(--space-7) var(--safe) var(--space-8);
}

.board-page__title {
    justify-self: start;
}

.board {
    display: grid;
    gap: var(--space-4);
}

/* The board's clock: big figures, the tier under them. */
.board [data-clock] {
    --figure: var(--size-name);
    --unit: var(--size-lead);

    display: flex;
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: var(--space-2);
}

.board [data-clock] .tier {
    color: var(--text-muted);
}

.board [data-clock] time {
    font-stretch: var(--narrow);
    font-weight: var(--weight-super);
    letter-spacing: -0.01em;
    line-height: 1;
    white-space: nowrap;
}

.board [data-clock] .countdown__unit {
    letter-spacing: 0.04em;
}

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

.board__note {
    padding: var(--space-3) var(--space-4);
    background: var(--ink-1);
}

.board__table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 2px;
    margin-top: var(--space-2);
}

.board__table thead th {
    padding: 0 var(--space-4) var(--space-1);
    color: var(--text-muted);
    font-weight: inherit;
    text-align: left;
    vertical-align: bottom;
}

.board__row > * {
    padding: var(--space-3) var(--space-4);
    background: var(--ink-1);
    text-align: left;
}

.board__name {
    width: 38%;
    font-stretch: var(--narrow);
    font-size: var(--size-small);
    font-weight: var(--weight-strong);
    letter-spacing: 0.01em;
    line-height: 1.3;
}

/* Your own row: your name on the edition slab, as the current entry in the map. */
.board__row[aria-current] .board__name span {
    margin-left: -0.35em;
    padding: 0.1em 0.35em;
    background: var(--edition);
    color: var(--on-edition);
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

.board__completion {
    white-space: nowrap;
}

.board__meter {
    display: inline-block;
    width: calc(100% - 4rem);
    height: var(--punch);
    border: 0;
    background: var(--ink-3);
    vertical-align: middle;
    -webkit-appearance: none;
    appearance: none;
}

.board__meter::-webkit-progress-bar {
    background: var(--ink-3);
}

.board__meter::-webkit-progress-value {
    background: var(--ink-10);
}

.board__meter::-moz-progress-bar {
    background: var(--ink-10);
}

.board__percent {
    display: inline-block;
    width: 3.25rem;
    font-stretch: var(--narrow);
    font-weight: var(--weight-strong);
    text-align: right;
}

.board__table .board__jokers {
    text-align: right;
}

.board__row .board__jokers {
    color: var(--text-muted);
    font-stretch: var(--narrow);
    font-weight: var(--weight-medium);
    white-space: nowrap;
}

/* Jokers left as punches: spotlight while unused, an outline once spent. */
.board__punches {
    display: inline-grid;
    grid-template-columns: repeat(4, var(--punch));
    gap: 2px;
    margin-right: var(--space-3);
    vertical-align: middle;
}

.board__punches .punch--left {
    background: var(--spotlight);
    box-shadow: none;
}

@media (min-width: 48rem) {
    .board {
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: var(--space-6);
    }

    .board > * {
        grid-column: 1 / -1;
    }

    /* The count stands on the clock's tier line. */
    .board > [data-clock] {
        grid-column: 2;
        grid-row: 1;
        align-self: end;
        align-items: flex-end;
    }

    .board > .board__count {
        grid-column: 1;
        grid-row: 1;
        align-self: end;
    }

    .board > .board__note {
        grid-column: 1;
        justify-self: start;
    }
}

@media (max-width: 30rem) {
    .joker-set {
        display: grid;
        grid-template-columns: repeat(2, auto);
    }

    .board__table thead th,
    .board__row > * {
        padding-inline: var(--space-3);
    }

    .board__meter {
        display: block;
        width: 100%;
    }

    .board__percent {
        display: block;
        width: auto;
        margin-top: var(--space-1);
        font-size: var(--size-small);
        text-align: left;
    }

    .board__punches {
        display: none;
    }
}

/* « Vote clos »: the statement, then the frozen board. */
.closed {
    padding-bottom: var(--space-8);
}

.closed__heading,
.closed .board {
    max-width: 52rem;
    margin-inline: var(--safe);
}

.closed .board {
    margin-top: var(--space-4);
}
