/* ==========================================================================
   Market Movers: the tape (2026-09-04)
   One grouped ledger, no cards. Smooth glass and frosted midnight distinguish dark desktop rows.
   Quiet-precision grammar: one accent, tabular numerals, brackets for the
   active filter, translucency nowhere on inline chrome. Groups are told
   apart by color (rails + chip titles), never by section labels. After the
   close a second, quieter block carries the regular-session recap; it is
   quieted by weight and bar opacity, never by hue, so the rails keep meaning.
   ========================================================================== */

.mm-page [hidden] { display: none !important; }

/* Phones retain one quiet sheet. Desktop separates the intro backing from
   the translucent tape so the silk rows can reveal the animated field. */
#marketMoversPage.mm-page {
    padding: 1.25rem 1.5rem 2rem;
    border-radius: var(--r-md);
    background: color-mix(in srgb, var(--field-page) 88%, transparent);
}

.mm-intro { display: contents; }

/* ---- Session strip ---------------------------------------------------- */

.mm-session {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.25rem 1.5rem;
    padding: 0.5rem 0 1rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--stroke-1);
}

.mm-session-main { min-width: 0; }

.mm-session-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.01em;
    color: var(--text-1);
}

.mm-session-clock,
.mm-session-criteria {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

.mm-session-criteria { text-align: right; }

.mm-criteria-line { display: block; }
.mm-criteria-sub { color: var(--text-4); }

.mm-flag {
    display: inline-block;
    margin-left: 0.6rem;
    padding: 0.1rem 0.45rem;
    vertical-align: 0.35em;
    border: 1px solid var(--stroke-2);
    border-radius: var(--r-xs);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
}

.mm-flag-stale { border-color: var(--status-warn); color: var(--text-2); }

/* ---- Filter chips ------------------------------------------------------ */

.mm-filters {
    display: flex;
    gap: 0.125rem;
    margin: 0 -0.75rem 0.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.mm-filters::-webkit-scrollbar { display: none; }

.mm-filter {
    position: relative;
    flex: none;
    padding: 0.4rem 0.95rem;
    border: 0;
    border-radius: var(--r-control);
    background: none;
    font: inherit;
    font-size: 0.9rem;
    color: var(--text-3);
    cursor: pointer;
    transition: color var(--dur-fast) var(--ease-out);
}

.mm-filter:hover { color: var(--text-1); }

.mm-filter:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.mm-filter[aria-selected="true"] {
    color: var(--text-1);
    font-weight: 600;
}

/* Accent brackets mark the active chip, matching the main nav's active tab. */
.mm-filter[aria-selected="true"]::before,
.mm-filter[aria-selected="true"]::after {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent);
    font-weight: 400;
    font-size: 0.85rem;
    pointer-events: none;
}

.mm-filter[aria-selected="true"]::before { content: '['; left: 4px; }
.mm-filter[aria-selected="true"]::after { content: ']'; right: 4px; }

/* Chip titles carry the group color at all times; brackets alone mean selected.
   Reporting is a cross-cut, not a group: neutral text, no rail of its own. */
.mm-filter[data-filter="gainers"] { color: var(--status-gain-strong); }
.mm-filter[data-filter="losers"] { color: var(--status-loss-strong); }
.mm-filter[data-filter="reporting"] { color: var(--text-2); }
.mm-filter[data-filter="gainers"]:hover,
.mm-filter[data-filter="gainers"][aria-selected="true"] { color: var(--status-gain-strong); }
.mm-filter[data-filter="losers"]:hover,
.mm-filter[data-filter="losers"][aria-selected="true"] { color: var(--status-loss-strong); }
.mm-filter[data-filter="reporting"]:hover,
.mm-filter[data-filter="reporting"][aria-selected="true"] { color: var(--text-1); }

.mm-count {
    margin-left: 0.2rem;
    font-weight: 400;
    color: var(--text-4);
    font-variant-numeric: tabular-nums;
}

/* Live count first; the recap's count trails in the quietest ink. */
.mm-count-recap { color: var(--text-4); opacity: 0.75; }

/* ---- The tape ------------------------------------------------------------ */

.mm-tape-wrap { position: relative; }

.mm-tape {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.mm-tape th,
.mm-tape td {
    padding: 0 0.75rem 0 0;
    vertical-align: middle;
}

.mm-tape th:last-child,
.mm-tape td:last-child { padding-right: 0; }

/* Column labels only, where the columns change. */
.mm-tape .mm-head th {
    padding-top: 1.25rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--stroke-2);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-4);
    white-space: nowrap;
}

.mm-tape tbody:first-child .mm-head th,
.mm-tape tbody[hidden] + tbody .mm-head th { padding-top: 0.5rem; }

/* The recap head always breathes, even when a filter hides the tbody above it. */
.mm-tape tbody[data-group="regular-head"] .mm-head th,
.mm-tape tbody[hidden] + tbody[data-group="regular-head"] .mm-head th { padding-top: 1.5rem; }

/* The recap's title lives in the head's lead cell: same head type, plus a
   disclosure chevron. Not a section row. */
.mm-recap-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: var(--text-3);
    cursor: pointer;
}

.mm-recap-toggle:hover { color: var(--text-1); }

.mm-recap-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.mm-recap-toggle::before {
    content: '';
    width: 0.4em;
    height: 0.4em;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-0.1em);
    transition: transform var(--dur-fast) var(--ease-out);
}

.mm-recap-toggle[aria-expanded="false"]::before { transform: rotate(-45deg) translateX(-0.1em); }

.mm-tape .mm-row td {
    height: 44px;
    border-bottom: 1px solid var(--stroke-1);
    color: var(--text-2);
    font-size: 0.9rem;
}

/* Group rails: the only group marker. Same colors as the chip titles. */
.mm-tape .mm-row > td:first-child,
.mm-tape .mm-note > td { padding-left: 0.75rem; }
.mm-tape .mm-gainer > td:first-child { box-shadow: inset 2px 0 0 var(--status-gain); }
.mm-tape .mm-loser > td:first-child { box-shadow: inset 2px 0 0 var(--status-loss); }

/* Seam between gainers and losers: a breath, no header. */
.mm-tape tbody[data-group="losers"] .mm-row:first-child td,
.mm-tape tbody[data-group="losers"] .mm-note:first-child td,
.mm-tape tbody[data-group="regular-losers"] .mm-row:first-child td,
.mm-tape tbody[data-group="regular-losers"] .mm-note:first-child td { padding-top: 0.75rem; }

/* Recap rows read as secondary by weight and bar opacity; rails stay full. */
.mm-tape .mm-row.mm-regular td.mm-price .num,
.mm-tape .mm-row.mm-regular td.mm-cap { color: var(--text-2); font-weight: 400; }
.mm-tape .mm-row.mm-regular .mm-pct { font-weight: 500; }
.mm-tape .mm-row.mm-regular .mm-bar-fill { opacity: 0.55; }

/* Reset the global zebra and accent hover; desktop rows have their own materials. */
#marketMoversPage .mm-tape tbody tr,
#marketMoversPage .mm-tape tbody tr:nth-child(even) { background: transparent; }

#marketMoversPage .mm-tape tbody tr.mm-row:hover {
    background: color-mix(in srgb, var(--text-1) 3%, transparent);
    transition: background-color var(--dur-fast) var(--ease-out);
}

@media (min-width: 641px) {
    #marketMoversPage.mm-page {
        --mm-silk: rgba(224, 229, 237, 0.50);
        --mm-milk: rgba(250, 249, 247, 0.94);
        --mm-edge: rgba(255, 255, 255, 0.50);
        --mm-edge-active: rgba(255, 255, 255, 0.95);
        --mm-satin: rgba(255, 255, 255, 0.16);
        padding: 0;
        background: transparent;
    }

    [data-mode="dark"] #marketMoversPage.mm-page {
        --mm-silk: color-mix(in srgb, var(--field-page) 42%, transparent);
        --mm-milk: var(--surface-1);
        --mm-edge: rgba(255, 255, 255, 0.13);
        --mm-edge-active: rgba(255, 255, 255, 0.40);
        --mm-satin: rgba(255, 255, 255, 0.035);
    }

    /* The rail color alone marks the group boundary in the continuous desktop tape. */
    .mm-tape tbody[data-group="losers"] .mm-row:first-child td,
    .mm-tape tbody[data-group="regular-losers"] .mm-row:first-child td { padding-top: 0; }

    .mm-tape tbody[data-group="losers"] .mm-note:first-child td,
    .mm-tape tbody[data-group="regular-losers"] .mm-note:first-child td { padding-top: 0.7rem; }

    .mm-intro {
        display: flow-root;
        padding: 1.25rem 1.5rem 0;
        border-radius: var(--r-md) var(--r-md) 0 0;
        background: color-mix(in srgb, var(--field-page) 88%, transparent);
    }

    .mm-tape-wrap {
        padding: 0 1.5rem 2rem;
        border-radius: 0 0 var(--r-md) var(--r-md);
        isolation: isolate;
    }

    /* One shared blur, isolated from row reveal transforms and volume popovers.
       No overflow clipping: volume details can extend beyond the tape. */
    .mm-tape-wrap::before {
        content: '';
        position: absolute;
        inset: 0;
        z-index: -1;
        border-radius: inherit;
        pointer-events: none;
        background: color-mix(in srgb, var(--field-page) 20%, transparent);
        -webkit-backdrop-filter: blur(8px);
        backdrop-filter: blur(8px);
    }

    #marketMoversPage .mm-tape tbody tr.mm-head,
    #marketMoversPage .mm-tape tbody tr.mm-note {
        background: color-mix(in srgb, var(--field-page) 88%, transparent);
    }

    /* Backgrounds span the whole row; text and semantic rails remain opaque. */
    #marketMoversPage .mm-tape tbody tr.mm-row:not([hidden]) {
        --mm-row-fill: var(--mm-silk);
        --mm-row-grain: none;
        --mm-row-satin: var(--mm-satin);
        --mm-row-edge: var(--mm-edge);
        background-color: var(--mm-row-fill);
        background-image: linear-gradient(to bottom,
            var(--mm-row-edge) 0 1px,
            var(--mm-row-satin) 1px, transparent 55%), var(--mm-row-grain);
        background-size: auto, 128px 128px;
        background-repeat: no-repeat, repeat;
        transition: none;
    }

    /* Filtering assigns materials across group boundaries, excluding notes. */
    #marketMoversPage .mm-tape tbody tr.mm-row[data-material="milk"] {
        --mm-row-fill: var(--mm-milk);
        --mm-row-satin: transparent;
    }

    /* Fixed, seamless ~1px frost; pale grain alpha is capped at 16%.
       One reusable background image, beneath ink and the existing edge. */
    [data-mode="dark"] #marketMoversPage .mm-tape tbody tr.mm-row[data-material="milk"] {
        --mm-row-grain: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22128%22%20height%3D%22128%22%20viewBox%3D%220%200%20128%20128%22%3E%3Cfilter%20id%3D%22grain%22%20x%3D%220%22%20y%3D%220%22%20width%3D%22100%25%22%20height%3D%22100%25%22%3E%3CfeTurbulence%20type%3D%22fractalNoise%22%20baseFrequency%3D%220.8%22%20numOctaves%3D%223%22%20seed%3D%2217%22%20stitchTiles%3D%22stitch%22%2F%3E%3CfeColorMatrix%20type%3D%22matrix%22%20values%3D%220%200%200%200%20.949%200%200%200%200%20.957%200%200%200%200%20.984%20.16%200%200%200%200%22%2F%3E%3C%2Ffilter%3E%3Cpath%20fill%3D%22none%22%20filter%3D%22url%28%23grain%29%22%20d%3D%22M0%200h128v128H0z%22%2F%3E%3C%2Fsvg%3E");
    }

    /* Both dark materials inherit the theme's light ink and semantic colors. */
    [data-mode="dark"] #marketMoversPage .mm-row .volume-back {
        background: var(--surface-1);
    }

    #marketMoversPage .mm-tape tbody tr.mm-row:not([hidden]):is(:hover, :focus-within) {
        --mm-row-edge: var(--mm-edge-active);
        /* Reveal animations retain stacking contexts; lift volume popovers
           above neighboring milk rows while their row is active. */
        position: relative;
        z-index: 1;
    }

    @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
        .mm-tape-wrap::before {
            background: color-mix(in srgb, var(--field-page) 45%, transparent);
        }
    }
}

.mm-num {
    text-align: right;
    white-space: nowrap;
    width: 1%;
    padding-left: 1.25rem;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

.mm-tape .mm-head th.mm-num { text-align: right; }

/* Name column takes whatever the numeric columns leave; overflow truncates. */
.mm-name {
    width: 100%;
    max-width: 0;
}

.mm-name-line {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    min-width: 0;
}

.mm-ticker {
    flex: none;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--accent-text);
    cursor: pointer;
}

.mm-ticker:hover { text-decoration: underline; }

.mm-company {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-3);
}

.mm-mark {
    flex: none;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-4);
}

.mm-mark-watch { color: var(--accent-text); }

/* Earnings timing is a neutral token: accent stays with the ticker and the
   watch mark, and themed accents never collide with the gain/loss rails. */
.mm-mark-earnings {
    /* The name line aligns on baselines; an SVG has none, so centre the glyph. */
    display: inline-flex;
    align-items: center;
    align-self: center;
    color: var(--text-3);
}

.mm-mark-earnings .icon { width: 14px; height: 14px; }

.mm-detail,
.mm-time,
.mm-est {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.75rem;
    line-height: 1.2;
    color: var(--text-4);
}

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

.mm-tape .mm-row td.mm-price .num,
.mm-tape .mm-row td.mm-cap,
.mm-actual { color: var(--text-1); font-weight: 500; }

/* EPS under the name: label in the quietest ink, actual toned by the tape's
   gain/loss colors, estimate trailing. */
.mm-eps-line { display: flex; align-items: baseline; gap: 0.4rem; }
.mm-eps-label { letter-spacing: 0.06em; text-transform: uppercase; }
.mm-eps-line .mm-result { display: inline-flex; align-items: baseline; gap: 0.4rem; }
.mm-eps-line .mm-actual { font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.mm-eps-line .mm-est { display: inline; margin: 0; }

/* Change: signed number plus a magnitude bar scaled to the session's largest move. */
.mm-change {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
}

.mm-pct {
    min-width: 4.6em;
    text-align: right;
    font-weight: 600;
}

.mm-bar {
    display: inline-block;
    width: 72px;
    height: 4px;
    border-radius: 2px;
    background: color-mix(in srgb, var(--text-1) 8%, transparent);
    overflow: hidden;
}

.mm-bar-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    transform-origin: left center;
}

.mm-bar-gain .mm-bar-fill { background: var(--status-gain); }
.mm-bar-loss .mm-bar-fill { background: var(--status-loss); }

.mm-tape .mm-note td {
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
    border-bottom: 1px solid var(--stroke-1);
    font-size: 0.85rem;
    color: var(--text-3);
}

.mm-tape .mm-note.mm-gainers td { box-shadow: inset 2px 0 0 color-mix(in srgb, var(--status-gain) 45%, transparent); }
.mm-tape .mm-note.mm-losers td { box-shadow: inset 2px 0 0 color-mix(in srgb, var(--status-loss) 45%, transparent); }

/* Regular-hours volume flip card keeps working inside the tape. */
.mm-tape .volume-cell { display: inline-block; }
.mm-tape .volume-help-icon { margin-left: 0.25rem; }

/* ---- Motion: one staggered reveal on first render ---------------------- */

@keyframes mm-enter {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

@keyframes mm-grow {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

.mm-row.mm-enter {
    animation: mm-enter var(--dur-slow) var(--ease-out) var(--mm-delay, 0ms) both;
}

.mm-row.mm-enter .mm-bar-fill {
    animation: mm-grow var(--dur-slow) var(--ease-out) calc(var(--mm-delay, 0ms) + 120ms) both;
}

@media (prefers-reduced-motion: reduce) {
    .mm-row.mm-enter,
    .mm-row.mm-enter .mm-bar-fill { animation: none; }
    .mm-filter,
    .mm-recap-toggle::before,
    #marketMoversPage .mm-tape tbody tr.mm-row:hover { transition: none; }
}

/* ---- Compact widths ----------------------------------------------------- */

@media (max-width: 900px) {
    .mm-session-criteria { text-align: left; flex-basis: 100%; }
    .mm-bar { width: 48px; }
}

@media (max-width: 640px) {
    .mm-session-title { font-size: 1.4rem; }

    .mm-tape,
    .mm-tape tbody,
    .mm-tape tr,
    .mm-tape th,
    .mm-tape td { display: block; }

    .mm-tape .mm-head { display: none; }

    /* The recap needs a boundary on phones: keep its lead cell (the title),
       drop the numeric column labels. */
    .mm-tape tbody[data-group="regular-head"] .mm-head { display: block; margin-top: 1.25rem; }
    .mm-tape tbody[data-group="regular-head"] .mm-head th { display: none; }
    .mm-tape tbody[data-group="regular-head"] .mm-head th.mm-head-lead {
        display: block;
        padding: 0 0 0.4rem 0.75rem;
        border-top: 1px solid var(--stroke-2);
        padding-top: 0.75rem;
    }

    .mm-tape .mm-row {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "name lead"
            "meta meta";
        column-gap: 1rem;
        row-gap: 0.35rem;
        padding: 0.65rem 0 0.65rem 0.75rem;
        border-bottom: 1px solid var(--stroke-1);
    }

    .mm-tape .mm-row td,
    .mm-tape .mm-row > td:first-child {
        height: auto;
        padding: 0;
        border: 0;
        width: auto;
        max-width: none;
        box-shadow: none;
    }

    .mm-tape .mm-gainer { box-shadow: inset 2px 0 0 var(--status-gain); }
    .mm-tape .mm-loser { box-shadow: inset 2px 0 0 var(--status-loss); }
    .mm-tape tbody[data-group="losers"] .mm-row:first-child,
    .mm-tape tbody[data-group="regular-losers"] .mm-row:first-child { margin-top: 0.5rem; }
    .mm-tape tbody[data-group="losers"] .mm-row:first-child td,
    .mm-tape tbody[data-group="regular-losers"] .mm-row:first-child td { padding-top: 0; }

    .mm-tape .mm-row .mm-name { grid-area: name; min-width: 0; }
    .mm-tape .mm-row .mm-name-line { flex-wrap: wrap; row-gap: 0.15rem; }
    .mm-tape .mm-row .mm-change-cell { grid-area: lead; align-self: center; }

    .mm-tape .mm-row .mm-price,
    .mm-tape .mm-row .mm-vol,
    .mm-tape .mm-row .mm-cap {
        grid-area: auto;
        grid-column: 1 / -1;
        display: flex;
        justify-content: flex-end;
        align-items: baseline;
        gap: 0.5rem;
        font-size: 0.8rem;
        text-align: right;
    }

    .mm-tape .mm-row td[data-label]:not(.mm-change-cell)::before {
        content: attr(data-label);
        margin-right: auto;
        font-size: 0.7rem;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--text-4);
    }

    .mm-tape .mm-row .mm-time { display: inline; margin-left: 0.4rem; }
    .mm-tape .mm-note td { display: block; }
}
