/*
 * The site chrome: the header and, at the end, the footer.
 *
 * The header: every rule for its layout and its parts (index.html
 * <header class="topbar">; behaviour in header.js, the status text in
 * app.js, the cart in trade.js, the wallet control in wallet-ui.js).
 * Colours are app.css's theme tokens, so light, dark and auto follow.
 *
 * Two rows of fixed height, and nothing in them wraps: each width drops
 * detail instead.
 *
 *   ≥ 1280  desktop  brand · status (indicator, its name, block, age) ·
 *                    search (≤ 420) · theme with its name · cart · wallet
 *   ≥ 1024  tablet   the same, the theme an icon, the search narrower and
 *                    the age in the status panel only
 *   ≥ 768   tablet   the status is the indicator and the block number
 *   <  768  phone    brand · indicator · search button (an overlay over the
 *                    row) · theme · cart · wallet, all icons
 *
 * The nav row under it scrolls sideways where it does not fit, faded at an
 * edge with more (app.js syncNavStrip). Its last item, Statistics, is a
 * menu button (header.js) whose list drops below the row. Live text has reserved widths and
 * tabular numerals; the status and the wallet have fixed widths, so a new
 * block, a ticking age, a connected wallet or a badge never moves anything.
 */

.topbar {
    --hdr-row: 52px;
    --hdr-nav: 40px;
    --hdr-pad: 16px;
    --hdr-gap: 10px;
    --hdr-icon: 32px;
    --status-w: 344px;
    --wallet-w: 160px;
    --search-max: 420px;
    flex: none;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

/* ------------------------------------------------------------ top row */

.topbar-row {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: var(--hdr-gap);
    height: var(--hdr-row);
    padding: 0 var(--hdr-pad);
}

.topbar-row > * {
    flex: none;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.brand-mark {
    width: 20px;
    height: 20px;
    flex: none;
}

.brand-mark circle:first-child {
    stroke: var(--ink);
}

.brand-mark circle:last-child {
    fill: var(--ink);
}

.brand-link {
    color: inherit;
    text-decoration: none;
}

.brand-link:hover {
    text-decoration: underline;
    text-decoration-color: var(--underline);
    text-underline-offset: 3px;
}

/* An icon-only button of the row: the theme (narrow), the search, the cart. */
.header-icon,
.topbar .trade-cart-btn {
    position: relative;
    width: var(--hdr-icon);
    height: var(--hdr-icon);
    padding: 0;
    justify-content: center;
    color: var(--ink-2);
}

.header-icon:hover,
.topbar .trade-cart-btn:hover {
    color: var(--ink);
}

.header-icon svg,
.address-search-icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
}

.btn.header-icon svg path,
.btn.header-icon svg circle {
    fill: none;
}

/* ------------------------------------------------------------- status */

.status {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    width: var(--status-w);
    min-width: 0;
    font-size: 13px;
    white-space: nowrap;
}

/* The indicator: the worse of the fork's and the stream's states, as an
   icon whose shape carries it (app.js statusIcon) and a short name of a
   reserved width. A button: it opens the panel. */
.live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: none;
    height: 28px;
    padding: 0 8px 0 6px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
}

.live:hover,
.status.is-open .live {
    border-color: var(--border);
    background: var(--hover);
}

.live:focus-visible {
    outline-offset: 0;
}

.live-icon {
    display: inline-flex;
    flex: none;
    width: 14px;
    height: 14px;
}

.live-icon .pill-icon {
    width: 14px;
    height: 14px;
}

.live-label {
    display: inline-block;
    width: 7.2em;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
}

.live--critical .live-label,
.live--serious .live-label {
    font-weight: 600;
}

/* The tip: "Block 969,608 · 3 min ago", every part a fixed width. */
.tip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

.tip-height {
    display: inline-block;
    min-width: 7ch;
    color: var(--ink);
    font-weight: 600;
}

.ago {
    display: inline-block;
    width: 13ch;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
}

/* The details: both states in full, the block's time, a backfill. Shown
   while the pointer is over the status, while the indicator has keyboard
   focus (a tooltip), or pinned by a click (header.js); Esc hides it. */
.status-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 40;
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    width: max-content;
    max-width: min(360px, calc(100vw - 2 * var(--hdr-pad)));
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--ink);
    white-space: normal;
}

/* The gap between the indicator and the panel still counts as over it. */
.status-panel::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 10px;
}

.status.is-open .status-panel,
.status:not(.is-dismissed):has(.live:focus-visible) .status-panel {
    display: flex;
}

@media (hover: hover) {
    .status:not(.is-dismissed):hover .status-panel {
        display: flex;
    }
}

.status-note {
    color: var(--ink-2);
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.status-panel .backfill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ink-2);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.status-panel .backfill[hidden],
.status-note[hidden] {
    display: none;
}

/* ------------------------------------------------------------- search */

.address-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 var(--search-max);
    min-width: 0;
    max-width: var(--search-max);
    margin-left: auto;
}

.topbar-row > .address-search {
    flex: 1 1 var(--search-max);
}

.address-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    color: var(--ink-2);
    pointer-events: none;
}

.address-search input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: 34px;
    padding: 0 12px 0 32px;
    border: 1px solid var(--control-border);
    border-radius: 17px;
    background: var(--page);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}

.address-search input::placeholder {
    color: var(--ink-2);
}

.search-toggle,
.search-close {
    display: none;
}

/* -------------------------------------------------- theme, cart, wallet */

.theme-toggle {
    height: var(--hdr-icon);
    padding: 0 10px;
    color: var(--ink-2);
    font-size: 13px;
}

.theme-toggle:hover {
    color: var(--ink);
}

.theme-toggle svg path {
    stroke: none;
}

/* Auto, Light and Dark take the same room. */
.theme-toggle-label {
    display: inline-block;
    width: 2.7em;
    text-align: left;
}

/* The cart's count sits on its icon, so a count never widens it. */
.topbar .trade-cart-count {
    position: absolute;
    top: 0;
    right: -3px;
    min-width: 16px;
    padding: 0 4px;
    line-height: 16px;
    font-size: 10.5px;
}

/* The wallet control: a fixed width, right-aligned in it, so connecting,
   disconnecting or a note never moves the row. */
.wallet-slot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: var(--wallet-w);
}

.wallet-slot .wallet-connect,
.wallet-slot .wallet-account {
    height: var(--hdr-icon);
}

.wallet-slot .wallet-account-wrap {
    display: flex;
    min-width: 0;
}

.wallet-slot .wallet-account {
    position: relative;
    min-width: 0;
}

.wallet-slot .wallet-account-address {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ----------------------------------------------------------- nav row */

.nav-strip {
    display: flex;
    align-items: stretch;
    gap: 2px;
    height: var(--hdr-nav);
    padding: 0 calc(var(--hdr-pad) - 10px);
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    scroll-padding-inline: 32px;
}

.nav-strip::-webkit-scrollbar {
    display: none;
}

.nav-strip.has-more-end {
    mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
}

.nav-strip.has-more-start {
    mask-image: linear-gradient(to left, #000 calc(100% - 36px), transparent);
}

.nav-strip.has-more-start.has-more-end {
    mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent);
}

/* One weight for every link, the current one too: the active state is
   colour and a bar, so moving between views never shifts the row. */
.nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: none;
    padding: 2px 10px 0;
    border-bottom: 2px solid transparent;
    color: var(--ink-2);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--ink);
}

.nav-link[aria-current] {
    color: var(--ink);
    border-bottom-color: var(--ink);
}

.nav-link:focus-visible {
    outline-offset: -3px;
    border-radius: 4px;
}

/* The Statistics menu: a button (its overview, Transfers, Extractions),
   current on any of the three, and its list under the row. While the list
   is open the strip neither clips nor fades it; four links fit the
   narrowest phone, so the strip has nothing scrolled away then. */
.nav-menu-wrap {
    position: relative;
    display: flex;
    flex: none;
}

.nav-menu-toggle {
    gap: 6px;
    margin: 0;
    padding-right: 12px;
    border-top: 0;
    border-left: 0;
    border-right: 0;
    background: none;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

.nav-menu-chevron {
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
}

.nav-menu-toggle[aria-expanded="true"] .nav-menu-chevron {
    transform: translateY(1px) rotate(-135deg);
}

/* New transfers or extractions not seen: a dot (their counts are in the
   list). It sits in the padding, so it never moves anything. */
.nav-menu-toggle .nav-dot {
    position: absolute;
    top: 9px;
    right: 3px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ink);
    box-shadow: 0 0 0 2px var(--surface);
}

.nav-menu-toggle .nav-dot[hidden] {
    display: none;
}

.nav-strip:has(.nav-menu:not([hidden])) {
    overflow: visible;
    mask-image: none;
}

.nav-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 190px;
    max-width: calc(100vw - 2 * var(--hdr-pad));
    margin: 0;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    list-style: none;
}

.nav-menu[hidden] {
    display: none;
}

.nav-menu .nav-link {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    height: 34px;
    padding: 0 10px;
    border-bottom: 0;
    border-radius: 6px;
    color: var(--ink);
}

.nav-menu .nav-link:hover {
    background: var(--hover);
}

.nav-menu .nav-link[aria-current] {
    background: var(--hover);
    box-shadow: inset 2px 0 0 var(--ink);
}

.nav-menu .nav-link:focus-visible {
    outline-offset: -2px;
}

/* A feed's count of events not seen yet. */
.nav-menu .badge {
    min-width: 18px;
}

.nav-menu .badge[hidden] {
    display: none;
}

/* ------------------------------------------------------------ tablets */

@media (max-width: 1279.98px) {
    .topbar {
        --status-w: 200px;
        --wallet-w: 148px;
        --search-max: 320px;
    }

    .theme-toggle {
        width: var(--hdr-icon);
        padding: 0;
        justify-content: center;
    }

    .theme-toggle-label {
        display: none;
    }

    /* The age: in the panel's block line. */
    .tip .ago,
    .tip-word {
        display: none;
    }

    .wallet-connect-more {
        display: none;
    }
}

@media (max-width: 1023.98px) {
    .topbar {
        --hdr-gap: 8px;
        --status-w: 104px;
        --search-max: 280px;
    }

    /* The indicator's name: in its label and the panel. */
    .live-label {
        display: none;
    }

    .live {
        padding: 0 6px;
    }
}

/* ------------------------------------------------------------- phones */

@media (max-width: 767.98px) {
    .topbar {
        --hdr-row: 48px;
        --hdr-pad: 12px;
        --hdr-gap: 4px;
        --status-w: auto;
        --wallet-w: 36px;
    }

    .brand {
        margin-right: 2px;
        font-size: 15px;
    }

    /* The panel spans the row (the indicator is near its left). */
    .status {
        position: static;
        width: auto;
    }

    .tip {
        display: none;
    }

    .live {
        width: var(--hdr-icon);
        padding: 0;
        justify-content: center;
    }

    .status-panel {
        left: var(--hdr-pad);
        right: var(--hdr-pad);
        top: calc(100% + 4px);
        width: auto;
        max-width: none;
    }

    /* The search: a button, then an overlay over the whole row. */
    .search-toggle {
        display: inline-flex;
        margin-left: auto;
    }

    .address-search {
        display: none;
    }

    .topbar.is-searching .address-search {
        position: absolute;
        inset: 0;
        z-index: 20;
        display: flex;
        max-width: none;
        margin: 0;
        padding: 0 calc(var(--hdr-pad) - 4px) 0 var(--hdr-pad);
        background: var(--surface);
    }

    .topbar.is-searching .address-search-icon {
        left: calc(var(--hdr-pad) + 11px);
    }

    .topbar.is-searching .search-close {
        display: inline-flex;
        flex: none;
    }

    .topbar.is-searching .address-search input {
        font-size: 16px; /* no zoom on focus (iOS) */
    }

    /* Icons only; the wallet's state is its mark and a green dot. */
    .wallet-slot .wallet-connect,
    .wallet-slot .wallet-account {
        width: 36px;
        padding: 0;
        justify-content: center;
    }

    .wallet-connect-label,
    .wallet-account-address,
    .wallet-chevron {
        display: none;
    }

    .wallet-account-dot {
        display: inline-block;
        position: absolute;
        top: 5px;
        right: 5px;
        box-shadow: 0 0 0 2px var(--surface);
    }

    .nav-strip {
        padding: 0 2px;
    }

    /* Its button is near the right: the list ends under it. */
    .nav-menu {
        left: auto;
        right: 0;
    }
}

/* The narrowest phones: the brand and the buttons close up. */
@media (max-width: 399.98px) {
    .topbar {
        --hdr-pad: 10px;
        --hdr-gap: 2px;
        --hdr-icon: 30px;
        --wallet-w: 32px;
    }

    .brand {
        gap: 6px;
        font-size: 14px;
    }

    .brand-mark {
        width: 18px;
        height: 18px;
    }

    .wallet-slot .wallet-connect,
    .wallet-slot .wallet-account {
        width: 32px;
    }
}

/* ------------------------------------------------------------- footer */

/* One quiet row of links under the panes, a fixed height at every width:
   API (the docs), Birthday sats, Sat types, Affiliates (while the market
   is on), Attributions. */
.site-footer {
    flex: none;
    display: flex;
    align-items: center;
    height: 32px;
    padding: 0 16px;
    border-top: 1px solid var(--border);
    background: var(--page);
    font-size: 12px;
}

.footer-nav {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 18px;
    min-width: 0;
    white-space: nowrap;
}

.footer-link {
    color: var(--ink-2);
    text-decoration-color: transparent;
}

.footer-link:hover {
    color: var(--ink);
    text-decoration-color: currentColor;
}

.footer-link:focus-visible {
    outline-offset: 1px;
    border-radius: 2px;
}

@media (max-width: 767.98px) {
    .site-footer {
        padding: 0 12px;
    }
}

/* ------------------------------------------------------------- forced colours */

@media (forced-colors: active) {
    .nav-link[aria-current] {
        border-bottom-color: Highlight;
    }

    .nav-menu {
        border-color: CanvasText;
    }

    .nav-menu-toggle .nav-dot {
        background: Highlight;
    }

    .status-panel {
        border-color: CanvasText;
    }
}
