/*
 * Year, month, block, birthday, luck and sub-category filters (filters.js) on the collection
 * pages, and the birthday page (birthday.js). Built on app.css's tokens:
 * light, dark and auto alike.
 */

/* ------------------------------------------------------------ the panel */

.flt {
    display: grid;
    gap: 8px;
    padding: 10px 16px 4px;
}

.flt-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    min-width: 0;
}

.flt-label {
    flex: none;
    min-width: 64px;
    color: var(--ink-2);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.flt-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.flt-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 12.5px;
    line-height: 26px;
    cursor: pointer;
    white-space: nowrap;
}

.flt-chip:hover {
    background: var(--hover);
}

.flt-chip:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
}

.flt-chip[aria-pressed="true"] {
    border-color: var(--series-1);
    background: var(--wash);
    color: var(--ink);
    font-weight: 600;
}

.flt-count {
    color: var(--ink-2);
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
    font-weight: 400;
}

.flt-none {
    color: var(--ink-2);
    font-size: 12.5px;
}

.flt-date {
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--control-border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}

/* Luck ≥ (a minimum): one compact select, its counts in the options. */
.flt-select {
    height: 30px;
    max-width: 100%;
    padding: 0 6px;
    border: 1px solid var(--control-border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.flt-row--luck .flt-label,
.flt-row--month .flt-label {
    cursor: help;
}

/* A month: one select, the months grouped by year. */
.flt-select--month {
    min-width: 8.5em;
}

/* Blocks: From and To heights, Apply (and Clear); wraps on a phone. */
.flt-row--blocks .flt-label {
    cursor: help;
}

.flt-blocks {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    min-width: 0;
    margin: 0;
}

.flt-sublabel {
    color: var(--ink-2);
    font-size: 12.5px;
}

.flt-num {
    width: 7.5em;
    min-width: 0;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--control-border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.flt-num[aria-invalid="true"] {
    border-color: var(--critical);
    box-shadow: inset 0 0 0 1px var(--critical);
}

.flt-error {
    flex-basis: 100%;
    margin: 0;
    color: var(--critical);
    font-size: 12.5px;
}

.flt-error[hidden] {
    display: none;
}

.flt-check {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--ink-2);
    font-size: 12.5px;
    cursor: pointer;
}

.flt-link {
    font-size: 12.5px;
}

.flt-row--summary {
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: var(--radius);
    background: var(--sunken);
}

.flt-summary {
    font-size: 12.5px;
    font-weight: 600;
}

/* Folded on a phone: the summary says what is on. */
.flt-fold > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 0;
    color: var(--ink-2);
    font-size: 12.5px;
    cursor: pointer;
}

.flt-fold > summary::-webkit-details-marker {
    display: none;
}

.flt-fold > summary::before {
    content: "\25B8";
    color: var(--ink-2);
}

.flt-fold[open] > summary::before {
    content: "\25BE";
}

.flt-fold > summary .flt-summary {
    color: var(--ink);
}

/* Wider screens show the panel whole. */
@media (min-width: 720px) {
    .flt-fold > summary {
        display: none;
    }
}

@media (max-width: 719.98px) {
    .flt-fold > summary {
        padding: 8px 12px 2px;
    }
}

/* Which sat of a bundle the filter matched. */
.flt-match {
    color: var(--ink-2);
    font-size: 11.5px;
    overflow-wrap: anywhere;
}

.lcard-match {
    min-width: 0;
}

.coll-match {
    margin-top: 2px;
}

/* ------------------------------------------------------- birthday page */

.panes.is-birthday {
    display: flex;
}

.panes.is-birthday > .pane:not(.pane--birthday),
.panes:not(.is-birthday) > .pane--birthday {
    display: none;
}

/* The page scrolls as one: the head (the day and its controls) goes up
   with the sections. */
.pane--birthday {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.pane--birthday > .bday-head {
    flex: none;
}

.bday-head {
    display: grid;
    gap: 6px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--grid);
}

.pane--birthday .bday-head h2 {
    font-size: 20px;
}

.bday-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}

.bday-body {
    padding-bottom: 16px;
}

.bday-section {
    display: grid;
    gap: 8px;
    padding: 14px 0 0;
}

.bday-section > h3,
.bday-section > p,
.bday-section > ul,
.bday-section > .addr-state {
    margin: 0;
    padding: 0 16px;
}

.bday-section > h3 {
    font-size: 14px;
    font-weight: 650;
}

.bday-n {
    color: var(--ink-2);
    font-weight: 500;
}

.bday-section > .lcard-grid {
    padding-top: 0;
}

.bday-section > .table-x {
    padding: 0 16px;
}

.bday-counts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 6px;
    list-style: none;
}

.bday-count {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--sunken);
    color: inherit;
    text-decoration: none;
}

.bday-count:hover,
.bday-count:focus-visible {
    background: var(--hover);
}

.bday-count-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.bday-count-n {
    flex: none;
    font-size: 13px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.bday-famous {
    display: grid;
    gap: 6px;
    font-size: 13.5px;
}

.bday-sales td {
    vertical-align: top;
}

@media (max-width: 719.98px) {
    .flt {
        padding: 8px 12px 2px;
    }

    .flt-label {
        min-width: 0;
        width: 100%;
    }

    .flt-row--luck .flt-label,
    .flt-row--month .flt-label {
        width: auto;
    }

    /* Two boxes a line beside their labels, never wider than the screen. */
    .flt-num {
        width: 6.5em;
    }

    .bday-section > h3,
    .bday-section > p,
    .bday-section > ul,
    .bday-section > .addr-state,
    .bday-section > .table-x {
        padding: 0 12px;
    }

    .bday-counts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .bday-count {
        padding: 6px 8px;
    }

    /* The tab names other panes; this page keeps its heading (the day). */
    .pane--birthday .pane-head h2 {
        position: static;
        width: auto;
        height: auto;
        overflow: visible;
        clip-path: none;
        white-space: normal;
        font-size: 18px;
    }
}

/* ------------------------------------------- activity rows on a phone */

/* A collection's Activity and the birthday page's sales, seven columns
   (event, price, unit price, sats, seller → buyer, when, transaction), are
   one compact card a row on a phone, never wider than the screen:
     event            price
     sats         unit price
     seller → buyer
     when       transaction                                              */
@media (max-width: 719.98px) {
    .coll-scroll > .table-x:has(> .coll-activity),
    .bday-section > .table-x:has(> .coll-activity) {
        overflow-x: visible;
    }

    .data-table.coll-activity {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .data-table.coll-activity thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .data-table.coll-activity tbody {
        display: block;
    }

    .data-table.coll-activity tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 2px 12px;
        padding: 8px 0;
        border-bottom: 1px solid var(--grid);
    }

    .data-table.coll-activity td {
        display: block;
        min-width: 0;
        padding: 0;
        border: 0;
        white-space: normal;
        overflow-wrap: anywhere;
        text-align: left;
    }

    .data-table.coll-activity td:nth-child(1) { grid-area: 1 / 1; }
    .data-table.coll-activity td:nth-child(2) { grid-area: 1 / 2; text-align: right; }
    .data-table.coll-activity td:nth-child(3) { grid-area: 2 / 2; text-align: right; color: var(--ink-2); }
    .data-table.coll-activity td:nth-child(4) { grid-area: 2 / 1; }
    .data-table.coll-activity td:nth-child(5) { grid-area: 3 / 1 / 4 / 3; }
    .data-table.coll-activity td:nth-child(6) { grid-area: 4 / 1; color: var(--ink-2); }
    .data-table.coll-activity td:nth-child(7) { grid-area: 4 / 2; text-align: right; }

    /* A name-forward collection (bounty3 names) leads with the name. */
    .data-table.coll-activity--named td:nth-child(1) { grid-area: 1 / 1 / 2 / 3; font-weight: 600; }
    .data-table.coll-activity--named td:nth-child(2) { grid-area: 2 / 1; text-align: left; }
    .data-table.coll-activity--named td:nth-child(3) { grid-area: 2 / 2; text-align: right; color: var(--ink); }
    .data-table.coll-activity--named td:nth-child(4) { grid-area: 3 / 2; text-align: right; color: var(--ink-2); }
    .data-table.coll-activity--named td:nth-child(5) { grid-area: 3 / 1; }
    .data-table.coll-activity--named td:nth-child(6) { grid-area: 4 / 1 / 5 / 3; }
    .data-table.coll-activity--named td:nth-child(7) { grid-area: 5 / 1; color: var(--ink-2); text-align: left; }
    .data-table.coll-activity--named td:nth-child(8) { grid-area: 5 / 2; text-align: right; }

    .data-table.coll-activity .sale-parties {
        flex-wrap: wrap;
        white-space: normal;
    }
}

/* ------------------------------------------------- statistics by year */

/* The Statistics' year chips, month and luck selects (app.js), over its
   table: the selects beside the chips when they fit, under them when not. */
.year-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 20px;
    padding: 0 16px 8px;
}

.year-filter > .flt-row--years {
    flex: 0 1 auto;
    min-width: 0;
}

.year-filter > .year-note {
    flex: 1 0 100%;
}

.year-filter[hidden] {
    display: none;
}

.year-note {
    margin: 0;
}

/* A collection's Holders & stats tab: the chips and luck over its numbers. */
.coll-years {
    flex: none;
    padding-top: 0;
}

.coll-years > .flt-row--luck,
.coll-years > .flt-row--month {
    margin-top: 6px;
}

.coll-bar + .year-note {
    padding: 0 16px 8px;
}

.coll-years-note {
    padding: 12px 16px 16px;
}

/* A section head's note: "Sales of sats mined in 2009". */
.th-note {
    color: var(--ink-2);
    font-weight: 400;
}

/* The numbers of other years being read: the old ones stay, dimmed. */
.table-scroll.is-loading,
.coll-scroll.is-loading {
    opacity: 0.55;
    transition: opacity 0.2s ease;
}

/* On a phone the year chips scroll sideways in one line, not the page. */
@media (max-width: 719.98px) {
    .flt-row--years {
        flex-wrap: nowrap;
    }

    .flt-row--years .flt-label {
        width: auto;
    }

    .year-filter {
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 6px;
        padding: 0 12px 8px;
    }

    .flt-row--years .flt-chips {
        flex: 1 1 0;
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .flt-row--years .flt-chips::-webkit-scrollbar {
        display: none;
    }
}
