/*
 * Address pages (address.js): /address/<address> shows one pane, the
 * address's UTXOs holding rare sats, with a filter panel by sat type on the
 * left (above the table on a narrow screen, folded on a phone). Built on
 * app.css's tokens, light, dark and auto; the badges are badges.css's.
 */

/* The address pane alone, whatever the width (app.css lays the overview's
   panes out as tabs, or side by side from 1600 px). */
.panes.is-address {
    display: flex;
}

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

/* ------------------------------------------------------------- header */

.addr-head {
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--grid);
}

.addr-line {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
}

.addr-id {
    min-width: 0;
    font-size: 13.5px;
    overflow-wrap: anywhere;
}

.addr-copy-btn {
    width: 28px;
    height: 28px;
}

.addr-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 6px;
    flex-basis: 100%;
    /* A line kept while the summary loads: the tab bar below doesn't move. */
    min-height: 1.4em;
}

.addr-meta .sep {
    color: var(--muted);
}

.addr-asof {
    color: var(--ink-2);
}

/* ------------------------------------------------------------- layout */

.addr-body {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
}

.addr-body.has-filters {
    grid-template-columns: 288px minmax(0, 1fr);
}

.addr-main {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    transition: opacity 0.2s ease;
}

/* A page of a big address is being read: the old rows dim, nothing jumps. */
.addr-main.is-loading {
    opacity: 0.55;
}

.addr-notice {
    flex: none;
    padding: 8px 16px;
    border-bottom: 1px solid var(--grid);
    background: var(--sunken);
    color: var(--ink-2);
    font-size: 12.5px;
}

.addr-scroll {
    flex: 1 1 auto;
}

/* Over the table: the "Columns" menu (core/columns.js), at the right. */
.addr-tools {
    flex: none;
    display: flex;
    justify-content: flex-end;
    padding: 6px 16px;
    border-bottom: 1px solid var(--grid);
}

.addr-tools[hidden] {
    display: none;
}

.addr-block {
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

a.addr-block {
    text-decoration: underline;
    text-decoration-color: var(--underline);
    text-underline-offset: 2px;
}

/* ------------------------------------------------------------ filters */

.addr-filters {
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 12px;
    border-right: 1px solid var(--grid);
    background: var(--sunken);
}

.addr-filters-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.addr-kicker {
    color: var(--ink-2);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.addr-filters h3 {
    margin-top: 2px;
    font-size: 13.5px;
    font-weight: 650;
}

/* Only a narrow screen folds the list away. */
.addr-filter-toggle {
    display: none;
    height: 28px;
    font-size: 12.5px;
}

.addr-type-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.addr-type {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}

.addr-type:hover {
    background: var(--hover);
}

.addr-type[aria-pressed="true"] {
    border-color: var(--series-1);
    background: var(--wash);
    box-shadow: inset 0 0 0 1px var(--series-1);
}

.addr-type .sat-badges {
    flex: none;
}

.addr-type-text {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.addr-type-name {
    font-weight: 600;
    line-height: 1.25;
}

.addr-type--all .addr-type-name {
    flex: 1 1 auto;
}

.addr-type-sub {
    color: var(--ink-2);
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
}

.addr-type-count {
    flex: none;
    color: var(--ink-2);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}

.addr-type[aria-pressed="true"] .addr-type-name,
.addr-type[aria-pressed="true"] .addr-type-count {
    color: var(--ink);
}

/* -------------------------------------------------------------- table */

.addr-table {
    min-width: 820px;
}

.addr-table th,
.addr-table td {
    padding-left: 8px;
    padding-right: 8px;
}

.addr-table td {
    padding-top: 7px;
    padding-bottom: 7px;
    vertical-align: top;
}

.addr-table tbody tr:hover > td {
    background: var(--hover);
}

/* The rest of the first row's height, so short cells line up with chips. */
.addr-table td:not(.col-rare) {
    line-height: 24px;
}

.addr-muted {
    color: var(--ink-2);
}

/* A UTXO's type combinations: a chip each, its badges overlapping, "×N". */
.addr-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    white-space: normal;
}

.addr-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px 2px 2px;
    border-radius: 9999px;
    background: var(--chip);
}

/* The chip is the capsule already: a capsule of badges inside it drops its
   own outline and ground (badges.css), so there is one outline, not two. */
.addr-chip .sat-badges--group {
    border: 0;
    background: none;
}

.addr-chip-count {
    color: var(--ink-2);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

/* An inscribed sat in the combination: a small ring at the chip's end. */
.addr-chip-insc {
    width: 7px;
    height: 7px;
    margin-left: 1px;
    border: 1.5px solid var(--series-2);
    border-radius: 50%;
}

/* Text that copies itself on a click: the sat range, the outpoint. */
.addr-copy {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink);
    font: inherit;
    line-height: inherit;
    text-align: left;
    cursor: copy;
}

.addr-copy.mono {
    color: var(--ink-2);
    font-family: var(--mono);
    font-size: 12px;
}

.addr-copy:hover {
    color: var(--series-1);
}

.addr-copy.is-copied,
.addr-copy-btn.is-copied {
    color: var(--good);
}

.addr-copy.is-copy-failed,
.addr-copy-btn.is-copy-failed {
    color: var(--critical);
}

.addr-copy.is-copied::after {
    content: " copied";
    font-family: var(--font);
    font-size: 11px;
}

/* The outpoint, to its UTXO page (utxo.js). */
.addr-utxo-link {
    color: var(--ink-2);
    font-family: var(--mono);
    font-size: 12px;
    text-decoration: underline;
    text-decoration-color: var(--underline);
    text-underline-offset: 2px;
}

a.addr-utxo-link:hover {
    color: var(--series-1);
    text-decoration-color: currentColor;
}

.addr-year {
    display: flex;
    flex-direction: column;
    width: max-content;
    cursor: default;
}

.addr-year-more {
    color: var(--ink-2);
    font-size: 11.5px;
    line-height: 16px;
}

.addr-utxo {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}

.addr-tx {
    color: var(--ink-2);
    font-size: 12px;
    text-decoration: none;
}

.addr-tx:hover {
    color: var(--ink);
}

/* Extracted: a quiet check after the outpoint. */
.addr-ext {
    color: var(--good);
    font-size: 12px;
    font-weight: 700;
    cursor: default;
}

/* ------------------------------------------------------------- states */

.addr-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 240px;
    padding: 24px 16px;
    color: var(--ink-2);
    text-align: center;
}

.addr-state--loading {
    min-height: 360px;
}

.addr-state--error > p:first-child {
    color: var(--critical);
    font-weight: 600;
}

.addr-state-detail {
    max-width: 60ch;
    font-size: 12.5px;
    overflow-wrap: anywhere;
}

.addr-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--grid);
    border-top-color: var(--series-1);
    border-radius: 50%;
    animation: addr-spin 0.8s linear infinite;
}

@keyframes addr-spin {
    to {
        transform: rotate(360deg);
    }
}

.addr-more:empty {
    display: none;
}

/* ------------------------------------------------------------ narrower */

@media (max-width: 1079.98px) {
    /* Narrower, the page scrolls as one (as a collection's): the head goes
       up with the rows and the tabs stay at the top, instead of a window of
       rows under a fixed head. The table scrolls sideways in its own frame
       (its column heads no longer stick: the page, not the frame, scrolls).
       Isolated: the tabs' z-index stays inside the pane. */
    .pane--address {
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        isolation: isolate;
    }

    .pane--address > * {
        flex-shrink: 0;
    }

    .pane--address > .wact-tabs {
        position: sticky;
        top: 0;
        z-index: 4;
        background: var(--surface);
    }

    /* At least the pane's height, so the tabs can always reach the top: a
       short tab doesn't pull the head back in under the reader. */
    .pane--address > .addr-body,
    .pane--address > .wact-panel {
        flex: 1 0 auto;
        min-height: 100%;
    }

    .addr-body {
        grid-template-rows: auto;
    }

    .addr-body.has-filters {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto 1fr;
    }

    .addr-main {
        min-height: auto;
    }

    /* Its frame scrolls sideways only: a vertical wheel or swipe over the
       table goes on to the pane (contain, .table-scroll's, would stop it). */
    .addr-scroll {
        flex: none;
        overflow-y: hidden;
        overscroll-behavior-y: auto;
    }

    .pane--address .wact-scroll {
        flex: none;
        overflow: visible;
    }

    .addr-filters {
        max-height: 45vh;
        padding: 8px 12px;
        border-right: 0;
        border-bottom: 1px solid var(--grid);
    }

    .addr-filters-head {
        align-items: center;
        margin-bottom: 0;
    }

    .addr-filter-toggle {
        display: inline-flex;
    }

    .addr-type-list {
        display: none;
        margin-top: 8px;
    }

    .addr-filters.is-open .addr-type-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (max-width: 719.98px) {
    /* No tab names this pane: its heading stays. */
    .pane--address .pane-head h2 {
        position: static;
        width: auto;
        height: auto;
        overflow: visible;
        clip-path: none;
        white-space: normal;
    }

    .addr-head {
        padding-bottom: 8px;
    }

    .addr-id {
        font-size: 12.5px;
    }

    .addr-kicker {
        display: none;
    }

    .addr-filters h3 {
        margin-top: 0;
    }
}

@media (max-width: 519.98px) {
    /* A phone wraps the summary to two lines: both kept while it loads. */
    .addr-meta {
        min-height: 2.8em;
    }
}

@media (forced-colors: active) {
    .addr-type[aria-pressed="true"] {
        border: 2px solid Highlight;
    }

    .addr-chip {
        border: 1px solid CanvasText;
    }
}

/* Rare sats in a transaction still in the mempool (address.js): on their way
   here (the rows above the UTXOs held), or being sent away. */
.addr-table tr.is-pending td {
    background: color-mix(in srgb, var(--warning) 6%, var(--surface));
}

.addr-pending-cell {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
}

.addr-table tbody.addr-pending + tbody tr:first-child td {
    border-top: 2px solid var(--border);
}
