/* ==========================================
   Soft Scanner browse screen (P3 Task 4)
   Source mockup: docs/superpowers/specs/2026-07-18-redesign-mockups/softc-1-browse.html
   in auctionviewer. Linked from index.html only, after styles.css, so nothing
   here reaches the other four pages (their shared .topnav chrome lives in
   styles.css -- compact-chrome, 2026-08-05).

   Colours come from tokens.css -- the mockup's literal hex values are only
   used where a value has no token (the row-hover shadow) or is deliberately
   theme-independent (white text on the sage swipe layer).
   ========================================== */

/* styles.css used to pad <main> for the old bottom nav; nothing is fixed at
   the bottom anymore (compact-chrome, 2026-08-05) -- only the home-indicator
   safe area plus breathing room needs reserving. The .hd sticky wrapper and
   the .topnav chrome itself live in styles.css, shared by all five pages. */
#app-main {
    padding: 0;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

/* ==========================================
   Segmented pill (Task 6; moved into the filter sheet 2026-08-05)

   Shared by #scope-pill (Distance) and #window-pill (Time window), both now
   inside #filter-sheet. A segmented control, not a checklist -- exactly one
   .scope-seg carries aria-pressed="true" at a time, kept in sync with
   getPrefs().radiusScope / the staged window value by js/main.js.
   ========================================== */
.scope-pill {
    display: flex;
    gap: 2px;
    margin-top: 8px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.scope-seg {
    flex: 1 1 0;
    min-width: 0;
    min-height: 34px;
    padding: 8px 6px;
    border: none;
    border-radius: 999px;
    background: none;
    color: var(--dim);
    font-family: var(--font-ui);
    font-size: .74rem;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.scope-seg[aria-pressed="true"] {
    background: var(--sage-soft);
    color: var(--sage-deep);
}

/* Active-filter chips (Task 7 populates .tokens; empty must not reserve
   space). A direct child of .hd since compact-chrome removed the .hdinner
   wrapper, so it carries its own side padding. */
.tokens {
    display: flex;
    gap: 7px;
    padding: 8px 16px 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.tokens:empty {
    display: none;
}

.tokens::-webkit-scrollbar {
    display: none;
}

.token {
    flex: none;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border: none;
    border-radius: 999px;
    background: var(--sage-soft);
    color: var(--sage-deep);
    font-family: inherit;
    font-size: .74rem;
    font-weight: 700;
    cursor: pointer;
}

.token span {
    opacity: .55;
}

.token.add {
    background: none;
    border: 1.5px dashed var(--line);
    color: var(--dim);
}

/* ==========================================
   Bottom filter sheet (Task 7)

   Full-viewport overlay so the scrim (anything outside .filter-sheet-content)
   reads as "outside" for handleClickOutside's containment check in
   js/main.js -- there is no separate scrim click handler.
   ========================================== */
.filter-sheet {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 70;
}

.filter-sheet.open {
    display: block;
}

.filter-sheet::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .35);
}

.filter-sheet-content {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    padding: 16px;
    border-radius: 20px 20px 0 0;
    background: var(--card);
    box-shadow: 0 -10px 30px rgba(52, 58, 54, .2);
}

.filter-sheet-title {
    margin: 0 0 12px;
    color: var(--ink);
    font-size: 1rem;
    font-weight: 800;
}

.filter-sheet-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.filter-section-label {
    display: block;
    margin-bottom: 6px;
    color: var(--dim);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.filter-price-row {
    display: flex;
    gap: 8px;
}

.filter-price-row input,
#sheet-category {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    color: var(--ink);
    font-family: inherit;
    font-size: .9rem;
}

.filter-price-row input {
    flex: 1;
    min-width: 0;
}

.house-bulk-actions {
    display: flex;
    gap: 14px;
    margin: 2px 0 6px;
}

.house-bulk-btn {
    border: none;
    background: none;
    padding: 0;
    color: var(--ink);
    font-size: .8rem;
    text-decoration: underline;
    cursor: pointer;
    opacity: .75;
}

.house-bulk-btn:hover {
    opacity: 1;
}

.house-checklist {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 220px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow-y: auto;
}

.house-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
}

.house-row:hover {
    background: var(--bg);
}

.house-row input[type="checkbox"] {
    flex: none;
    width: 16px;
    height: 16px;
    accent-color: var(--sage);
}

/* Name over city, so the city reads as a subtitle rather than competing with
   the house name for the same line. */
.house-text {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    gap: 1px;
}

.house-name {
    min-width: 0;
    overflow: hidden;
    color: var(--ink);
    font-size: .84rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.house-city {
    min-width: 0;
    overflow: hidden;
    color: var(--dim);
    font-size: .72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.house-count {
    flex: none;
    color: var(--dim);
    font-family: var(--mono);
    font-size: .72rem;
}

/* A house between sales. Dimmed rather than hidden: the point of listing it is
   that "quiet" and "not tracked" stop looking the same. It stays fully
   interactive, because hiding a house that is currently quiet is exactly the
   thing that was not expressible before. */
.house-row-quiet .house-name,
.house-row-quiet .house-count {
    color: var(--dim);
}

.house-row-quiet .house-count {
    font-style: italic;
}

.filter-sheet-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.filter-sheet-actions .btn {
    flex: 1;
}

/* ==========================================
   Group dividers
   ========================================== */
.divider {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px 8px;
}

.divider .pill {
    padding: 5px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    box-shadow: var(--shadow);
    color: var(--ink);
    font-family: var(--mono);
    font-size: .64rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.divider .pill em {
    font-style: normal;
    color: var(--clay);
    margin-left: 6px;
}

.divider .rule {
    flex: 1;
    height: 1px;
    background: var(--line);
}

/* Catalog status in the FIRST divider only -- "212 live · 12m ago", or
   "87 of 212 · 12m ago" when filters narrow the list. Written by
   updateLiveCount() (js/main.js); replaced the header .livecount row and the
   filterbar's match count (2026-08-05 compact-chrome). */
.divider .dstatus {
    flex: none;
    color: var(--dim);
    font-family: var(--mono);
    font-size: .64rem;
    white-space: nowrap;
}

/* ==========================================
   Rows
   ========================================== */
.list {
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.row {
    position: relative;
    display: grid;
    grid-template-columns: 62px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--card);
    box-shadow: var(--shadow);
    overflow: hidden;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
    /* Task 8's swipe gesture must never steal vertical scrolling. */
    touch-action: pan-y;
    /* A row is a tap target, not a reading surface. Without this, a long press
       raises the platform text-selection or link callout UI on top of the
       quick-action sheet. */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Row the long-press quick sheet is currently anchored to. */
.row.qopen {
    border-color: var(--sage);
    box-shadow: 0 0 0 3px var(--sage-soft);
}

.rthumb {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.65rem;
    overflow: visible;
}

.rthumb img {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    object-fit: cover;
}

/* Fallback thumbnail tints, rotated across rows */
.m1 { background: #e7eee4; }
.m2 { background: #f6ecdc; }
.m3 { background: #e8eaf2; }
.m4 { background: #f6e5dc; }

[data-theme="dark"] .m1 { background: #2b332a; }
[data-theme="dark"] .m2 { background: #37301f; }
[data-theme="dark"] .m3 { background: #2a2e38; }
[data-theme="dark"] .m4 { background: #3a2c25; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .m1 { background: #2b332a; }
    :root:not([data-theme="light"]) .m2 { background: #37301f; }
    :root:not([data-theme="light"]) .m3 { background: #2a2e38; }
    :root:not([data-theme="light"]) .m4 { background: #3a2c25; }
}

.heart {
    position: absolute;
    right: -5px;
    bottom: -5px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--card);
    box-shadow: var(--shadow);
    display: grid;
    place-items: center;
    cursor: pointer;
}

.heart svg {
    stroke: var(--dim);
    fill: none;
}

.heart.on svg {
    stroke: var(--clay);
    fill: var(--clay);
}

.rmain {
    min-width: 0;
}

.rtitle {
    font-size: .86rem;
    font-weight: 700;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rtags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.rtag {
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--bg);
    color: var(--dim);
    font-size: .62rem;
    font-weight: 700;
}

.rtag.site {
    background: var(--sage-soft);
    color: var(--sage-deep);
}

.rtag.watch {
    background: var(--clay-soft);
    color: var(--clay);
}

.rloc {
    margin-top: 4px;
    color: var(--dim);
    font-size: .62rem;
}

.rside {
    text-align: right;
}

.rprice {
    font-family: var(--mono);
    font-size: .94rem;
    font-weight: 700;
}

.rtime {
    margin-top: 3px;
    color: var(--dim);
    font-family: var(--mono);
    font-size: .66rem;
}

.rtime.hot {
    color: var(--clay);
    font-weight: 700;
}

.rbids {
    margin-top: 2px;
    color: var(--dim);
    font-family: var(--mono);
    font-size: .62rem;
}

.rbids .up { color: var(--clay); }
.rbids .dn { color: var(--sage-deep); }

/* ==========================================
   Swipe-to-watch layer (markup + gesture: Task 8)
   ========================================== */
.swipelayer {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 18px;
    border-radius: var(--r);
    background: var(--sage);
    color: #fff;
    font-size: .78rem;
    font-weight: 800;
    transform: translateX(-100%);
    transition: transform .3s;
    /* The layer covers the whole row, including the heart, and lingers for the
       length of its exit transition -- it must never intercept a tap. */
    pointer-events: none;
}

.swipelayer.on {
    transform: translateX(0);
}

/* While the finger is driving the layer directly, the transition would make it
   lag behind. finishSwipeLayer() removes this so the release animates. */
.swipelayer.dragging {
    transition: none;
}

/* ==========================================
   Long-press quick-action sheet (behavior: Task 8)
   ========================================== */
/* Inserted as a sibling immediately after the pressed row, inside .list -- so
   the 12px inset the mockup got from its .qwrap comes from .list's padding here
   and the sheet lines up with the row's edges. */
/* scroll-margin-top clears the sticky .hd (topnav ~57px incl. its border,
   plus the chips row when filters are active) so the sheet's scrollIntoView()
   in browse-gestures.js can lift a top-row sheet fully into view. Nothing is
   fixed at the bottom anymore (compact-chrome, 2026-08-05), so the bottom
   margin only needs the safe area plus breathing room. */
.qsheet {
    position: relative;
    z-index: 5;
    margin: -2px 0 0;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--card);
    box-shadow: 0 10px 30px rgba(52, 58, 54, .16);
    scroll-margin-bottom: calc(16px + env(safe-area-inset-bottom));
    scroll-margin-top: 110px;
}

/* Arrow pointing back up at the row it belongs to. */
.qsheet::before {
    content: "";
    position: absolute;
    top: -7px;
    left: 50%;
    width: 12px;
    height: 12px;
    transform: translateX(-50%) rotate(45deg);
    border-left: 1px solid var(--line);
    border-top: 1px solid var(--line);
    background: var(--card);
}

.qrow {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border: none;
    border-radius: 12px;
    background: none;
    color: inherit;
    font-family: inherit;
    font-size: .84rem;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.qrow:hover {
    background: var(--bg);
}

.qrow svg {
    flex: none;
}

.qrow .sub {
    display: block;
    margin-top: 1px;
    color: var(--dim);
    font-size: .68rem;
    font-weight: 400;
}

.qrow.sage { color: var(--sage-deep); }
.qrow.clay { color: var(--clay); }

/* ==========================================
   Mobile density (Task 8)

   Trims the chrome above the row list so more auction cards fit above the
   fold on a phone. Scoped below the desktop breakpoint so every rule here
   is additive on top of the mobile-first base styles above -- desktop reads
   those base values unchanged, same as before this block existed.
   ========================================== */
@media (max-width: 819.98px) {
    .scope-pill {
        margin-top: 4px;
        padding: 2px;
    }

    .scope-seg {
        min-height: 36px;
        padding: 6px 5px;
        font-size: .7rem;
    }

    /* buildRow() still emits this -- desktop has the vertical room for it,
       a phone doesn't. */
    .rloc {
        display: none;
    }

    .row {
        padding: 8px 12px;
    }
}

/* ==========================================
   Desktop
   ========================================== */
@media (min-width: 820px) {
    .hd > .tokens,
    .list {
        max-width: 760px;
        margin-left: auto;
        margin-right: auto;
    }

    .divider {
        max-width: 784px;
        margin-left: auto;
        margin-right: auto;
    }

    /* Without this the sheet stretches edge to edge on a wide window while
       everything above it sits in a 760px column. */
    .filter-sheet-content {
        max-width: 760px;
        margin-inline: auto;
    }

    .row:hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 18px rgba(52, 58, 54, .1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .row {
        transition: none;
    }

    .row:hover {
        transform: none;
    }

    .swipelayer {
        transition: none;
    }
}
