/* ==========================================
   Search screen (P4 Task 3) — markup + styles only, inert this commit.
   Source mockups: docs/superpowers/specs/2026-07-18-redesign-mockups/
   search-s1-search-home.html (idle layout) and search-s2-smart-query.html
   (the sq-input/sq-chip smart query card, nested inside .s-inputrow's
   .s-input here). Linked from index.html only, after browse.css.

   Colours come from tokens.css. The one variant the palette has no token
   for -- the "site" chip's periwinkle -- gets its own --peri-soft/
   --peri-deep pair defined below (tokens.css itself is not touched).
   ========================================== */

:root {
    --peri-soft: #e8eaf2;
    --peri-deep: #4d5a86;
}

[data-theme="dark"] {
    --peri-soft: #2b2f3d;
    --peri-deep: #aab4d8;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --peri-soft: #2b2f3d;
        --peri-deep: #aab4d8;
    }
}

/* ==========================================
   Screen shell
   Covers #app-main's content but NOT the topnav: .hd was raised to z-index
   50 so the nav stays visible and tappable while the screen is open (Home
   and Cancel/Escape are all exits). Still below .filter-sheet (70), which
   the screen's own Filters button opens on top.
   ========================================== */
.search-screen {
    position: fixed;
    /* Starts below the header rather than padding itself down: the box's own
       top edge is the scrollport top, which is what .s-head's `top: 0` sticks
       against -- pad instead and the sticky input parks itself underneath the
       header. --hd-h is measured by main.js's syncHeaderHeightVar(); the 0px
       fallback only applies before the first measurement. .hd carries the iOS
       status-bar inset itself (styles.css), so this screen no longer adds one. */
    top: var(--hd-h, 0px);
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 45;
    overflow-y: auto;
    background: var(--bg);
    /* Only needs the home indicator + breathing room -- nothing is fixed at
       the bottom since compact-chrome (2026-08-05). */
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.search-screen.hidden {
    display: none;
}

/* ==========================================
   Input card (S2 smart query bar, wrapped in S1's row + Cancel button)
   ========================================== */
.s-head {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg);
    padding: 14px 16px 10px;
}

.s-inputrow {
    display: flex;
    align-items: center;
    gap: 10px;
}

.s-input {
    flex: 1;
    min-width: 0;
    background: var(--card);
    border: 1.5px solid var(--sage);
    border-radius: 18px;
    box-shadow: 0 0 0 4px var(--sage-soft);
    padding: 12px 14px;
}

.s-input-row1 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.s-input-row1 svg {
    flex: none;
    stroke: var(--sage-deep);
}

.s-input-row1 input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: none;
    font-family: var(--mono);
    font-size: .88rem;
    color: var(--ink);
}

.s-input-row1 input::placeholder {
    color: var(--dim);
    font-family: var(--font-ui);
}

.s-clear {
    flex: none;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: var(--sage-soft);
    color: var(--dim);
    font-size: .75rem;
    line-height: 1;
    cursor: pointer;
    display: none;
}

.s-clear.show {
    display: block;
}

/* Filters entry point (2026-08-05 compact-chrome): opens the same
   #filter-sheet as the browse header's button, from inside search. Same
   44px-circle face as browse.css's .fbtn, restated here rather than shared
   because the compact-chrome work deletes that browse-only chrome. */
.s-filter {
    position: relative;
    flex: none;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--card);
    box-shadow: var(--shadow);
    color: var(--sage-deep);
    display: grid;
    place-items: center;
    cursor: pointer;
}

.s-filter .n {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: var(--clay);
    color: #fff;
    font-family: var(--mono);
    font-size: .6rem;
    display: grid;
    place-items: center;
}

.s-cancel {
    flex: none;
    border: none;
    background: none;
    color: var(--dim);
    font: inherit;
    font-size: .84rem;
    font-weight: 700;
    cursor: pointer;
}

/* Chips row lives inside the input card, under a dashed divider (S2) */
.sq-parsed {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
}

.sq-parsed.empty {
    display: none;
}

.sq-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    border: none;
    border-radius: 999px;
    padding: 5px 6px 5px 12px;
    font-family: var(--font-ui);
    font-size: .72rem;
    font-weight: 700;
    cursor: pointer;
}

.sq-chip small {
    font-weight: 400;
    opacity: .65;
    font-size: .62rem;
}

.sq-chip .x {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .08);
    display: grid;
    place-items: center;
    font-size: .6rem;
}

.sq-chip.kw {
    background: var(--sage-soft);
    color: var(--sage-deep);
}

.sq-chip.price {
    background: var(--honey-soft);
    color: var(--clay);
}

.sq-chip.time {
    background: var(--clay-soft);
    color: var(--clay);
}

.sq-chip.site {
    background: var(--peri-soft);
    color: var(--peri-deep);
}

/* ==========================================
   Idle sections: saved searches / recent / browse by category
   ========================================== */
.s-section {
    padding: 16px 16px 4px;
}

/* "Show all live items" -- the idle screen's route to the full list, for
   members who won't discover that Enter works on an empty box. Borrows
   .saved's card shape at full width; the sage accent marks it as the
   affirmative action on a screen of otherwise neutral cards. */
.s-showall {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 11px;
    width: 100%;
    padding: 13px 14px;
    border: 1.5px solid var(--sage);
    border-radius: 14px;
    background: var(--card);
    box-shadow: var(--shadow);
    color: var(--sage-deep);
    font-family: inherit;
    font-size: .82rem;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: transform .12s;
}

.s-showall:hover {
    transform: translateY(-1px);
}

.s-showall .c {
    flex: none;
    color: var(--dim);
    font-family: var(--mono);
    font-size: .72rem;
    font-weight: 400;
}

.s-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 9px;
    color: var(--dim);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.s-label-edit {
    border: none;
    background: none;
    color: var(--sage);
    font-family: inherit;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
}

.savedgrid {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.saved {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform .12s;
}

.saved:hover {
    transform: translateY(-1px);
}

.saved .ico {
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--sage-soft);
    display: grid;
    place-items: center;
    font-size: 1.05rem;
}

.saved .t {
    flex: 1;
    min-width: 0;
}

.saved .t b {
    display: block;
    font-size: .85rem;
}

.saved .t span {
    color: var(--dim);
    font-family: var(--mono);
    font-size: .62rem;
}

.saved .new {
    flex: none;
    border-radius: 999px;
    padding: 4px 9px;
    background: var(--clay-soft);
    color: var(--clay);
    font-family: var(--mono);
    font-size: .62rem;
    font-weight: 700;
}

.saved .bell {
    flex: none;
    color: var(--honey);
    cursor: pointer;
    /* Pad the 16px glyph out to a ~40px hit area (negative margin keeps the
       row layout unchanged) so tapping the bell doesn't mis-fire the row's
       own navigate-to-search handler. */
    box-sizing: content-box;
    padding: 12px;
    margin: -12px;
}

.saved .bell.off {
    color: var(--line);
}

.recents {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding-bottom: 8px;
}

.recent {
    display: flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 14px;
    background: var(--card);
    color: var(--dim);
    font: inherit;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
}

.recent svg {
    opacity: .5;
}

.browsegrid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding-bottom: 10px;
}

.bcat {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 6px;
    background: var(--card);
    box-shadow: var(--shadow);
    text-align: center;
    cursor: pointer;
}

.bcat .e {
    font-size: 1.3rem;
}

.bcat .n {
    margin-top: 4px;
    font-size: .7rem;
    font-weight: 700;
}

.bcat .c {
    color: var(--dim);
    font-family: var(--mono);
    font-size: .6rem;
}

/* ==========================================
   Live results
   ========================================== */
#search-results.hide {
    display: none;
}

.lr-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 16px 8px;
    color: var(--dim);
    font-size: .72rem;
}

.lr-meta b {
    color: var(--sage-deep);
    font-family: var(--mono);
}

.lr-savechip {
    border: none;
    border-radius: 999px;
    padding: 6px 12px;
    background: var(--sage-soft);
    color: var(--sage-deep);
    font: inherit;
    font-size: .7rem;
    font-weight: 800;
    cursor: pointer;
}

.lr-savechip.saved-state {
    background: var(--honey-soft);
    color: var(--clay);
}

.lrows {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 0 14px;
}

.lrow {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card);
    box-shadow: var(--shadow);
    cursor: pointer;
}

.lrow .th {
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
}

.lrow .t {
    flex: 1;
    min-width: 0;
    font-size: .82rem;
    font-weight: 700;
}

.lrow .t .ttl {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lrow .t small {
    display: block;
    margin-top: 2px;
    color: var(--dim);
    font-family: var(--mono);
    font-weight: 400;
    font-size: .62rem;
}

.lrow .t small .hot {
    color: var(--clay);
    font-weight: 700;
}

.lrow .p {
    flex: none;
    font-family: var(--mono);
    font-size: .8rem;
    font-weight: 700;
}

.lrow mark,
.saved mark {
    border-radius: 3px;
    padding: 0 1px;
    background: var(--honey-soft);
    color: inherit;
}

/* Truncation notice under a capped results list -- see renderSearchResults.
   Quiet on purpose: it explains the cap, it isn't an action. */
.lr-more {
    padding: 14px 20px 4px;
    color: var(--dim);
    text-align: center;
    font-size: .72rem;
}

.noresult {
    padding: 26px 20px;
    color: var(--dim);
    text-align: center;
    font-size: .8rem;
}

.noresult b {
    display: block;
    margin-bottom: 4px;
    color: var(--ink);
    font-size: .9rem;
}

.noresult button {
    margin-top: 12px;
    border: none;
    border-radius: 999px;
    padding: 8px 16px;
    background: var(--sage-soft);
    color: var(--sage-deep);
    font: inherit;
    font-size: .74rem;
    font-weight: 800;
    cursor: pointer;
}

/* ==========================================
   Desktop
   ========================================== */
@media (min-width: 820px) {
    .s-head,
    .s-section,
    #search-results {
        max-width: 760px;
        margin-left: auto;
        margin-right: auto;
    }
}
