/**
 * CMT Search — colour-first header search.
 *
 * Ported from the "Red 0 Chill Product Page" design (search.css), with the
 * design's paper/ink tokens remapped onto the live site's palette and fonts.
 * Every rule is namespaced under .cs-* so nothing leaks into the theme.
 */

:root {
    --cs-paper: #f4f1ea;
    --cs-paper-2: #ece8df;
    --cs-ink: #141210;
    --cs-ink-2: #3d3936;
    --cs-ink-3: #6b6760;
    --cs-line: #d8d2c5;
    --cs-accent: #3fa6d4;
    --cs-sans: "Inter Tight", Inter, system-ui, sans-serif;
    --cs-serif: "Fraunces", Georgia, serif;
    --cs-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --cs-z: 99990;
}

/* ------------------------------------------------------------- the trigger */

.cs-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font-family: var(--cs-sans);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    line-height: 1;
    cursor: pointer;
}

.cs-trigger:hover,
.cs-trigger:focus-visible {
    color: var(--cs-accent);
}

.cs-trigger .cs-key {
    padding: 2px 5px;
    border: 1px solid var(--cs-line);
    color: var(--cs-ink-3);
    font-family: var(--cs-mono);
    font-size: 9px;
    letter-spacing: 0.08em;
}

@media (max-width: 780px) {
    .cs-trigger .cs-key { display: none; }
}

/* --------------------------------------------------------------- the shell */

.cs-scrim {
    position: fixed;
    inset: 0;
    z-index: var(--cs-z);
    background: rgba(14, 13, 12, 0.38);
    backdrop-filter: blur(1.5px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}

.cs-scrim.open {
    opacity: 1;
    pointer-events: auto;
}

.cs-wrap {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: calc(var(--cs-z) + 1);
    max-height: 0;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
    background: var(--cs-paper);
    border-bottom: 0;
    color: var(--cs-ink);
    font-family: var(--cs-sans);
    transition: max-height 0.34s cubic-bezier(0.65, 0, 0.35, 1);
}

.cs-wrap.open {
    max-height: 88vh;
    visibility: visible;
    pointer-events: auto;
    border-bottom: 1px solid var(--cs-ink);
}

.cs-wrap *,
.cs-wrap *::before,
.cs-wrap *::after { box-sizing: border-box; }

/* ----------------------------------------------------------------- the bar */

.cs-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 32px;
}

.cs-bar .cs-ico {
    display: flex;
    flex: 0 0 auto;
    color: var(--cs-ink-3);
}

.cs-field {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.cs-chip {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 7px;
    padding: 5px 8px 5px 6px;
    border: 1px solid var(--cs-ink);
    background: var(--cs-ink);
    color: var(--cs-paper);
    font-family: var(--cs-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
}

.cs-chip .sw {
    width: 12px;
    height: 12px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 999px;
}

.cs-chip .x {
    opacity: 0.6;
    font-family: var(--cs-sans);
    font-size: 12px;
    letter-spacing: 0;
}

.cs-chip:hover .x { opacity: 1; }

.cs-input {
    flex: 1;
    min-width: 120px;
    padding: 3px 9px;
    border: solid 2px #f1e8a2;
    background: transparent;
    outline: none;
    color: var(--cs-ink);
    font-family: var(--cs-serif);
    font-size: 30px;
    font-weight: 400;
    letter-spacing: -0.02em;
}

.cs-input::placeholder {
    color: var(--cs-ink-3);
    font-style: italic;
}

.cs-close {
    flex: 0 0 auto;
    padding: 7px 10px;
    border: 1px solid var(--cs-line);
    background: none;
    color: var(--cs-ink-3);
    font-family: var(--cs-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
}

.cs-close:hover {
    border-color: var(--cs-ink);
    color: var(--cs-ink);
}

/* --------------------------------------------------------------- the panel */

.cs-panel {
    max-height: calc(88vh - 150px);
    padding: 6px 0 0;
    overflow: auto;
    border-top: 1px solid var(--cs-line);
}

.cs-sec { padding: 14px 32px 8px; }
.cs-sec + .cs-sec { border-top: 1px solid var(--cs-line); }

.cs-sec-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 10px;
}

.cs-sec-head .t,
.cs-sec-head .n {
    font-family: var(--cs-mono);
    font-size: 10px;
    color: var(--cs-ink-3);
}

.cs-sec-head .t {
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.cs-sec-head .n { letter-spacing: 0.08em; }

/* rows */

.cs-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 -12px;
    padding: 9px 12px;
    border: 1px solid transparent;
    color: var(--cs-ink);
    text-decoration: none;
    cursor: pointer;
}

.cs-row.on {
    background: var(--cs-paper-2);
    border-color: var(--cs-line);
}

.cs-row .grow { flex: 1; min-width: 0; }

.cs-row .nm {
    display: block;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.25;
}

.cs-row .sub {
    margin-top: 3px;
    color: var(--cs-ink-3);
    font-family: var(--cs-mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.cs-row .px {
    font-family: var(--cs-serif);
    font-size: 15px;
    font-weight: 600;
}

.cs-row .go {
    flex: 0 0 auto;
    opacity: 0;
    color: var(--cs-accent);
    font-family: var(--cs-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.cs-row.on .go { opacity: 1; }

.cs-row mark {
    background: transparent;
    color: var(--cs-accent);
    font-weight: 700;
}

.cs-thumb {
    position: relative;
    flex: 0 0 auto;
    width: 52px;
    height: 64px;
    overflow: hidden;
    border: 1px solid var(--cs-line);
}

.cs-thumb img {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: translate(-50%, -50%);
}

.cs-dot {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border: 1px solid var(--cs-line);
    border-radius: 999px;
    box-shadow: inset 0 0 0 2px var(--cs-paper);
}

.cs-glyph {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--cs-line);
    background: var(--cs-paper-2);
    font-family: var(--cs-serif);
    font-size: 15px;
    font-weight: 800;
}

/* swatch grid */

.cs-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Each button is as wide as its own label — "Tan" stays short, "Turquoise"
   grows to fit rather than spilling past its border. */
.cs-sw {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border: 1px solid var(--cs-line);
    background: transparent;
    color: var(--cs-ink);
    font-family: var(--cs-sans);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}

.cs-sw:hover,
.cs-sw.on {
    border-color: var(--cs-ink);
    background: var(--cs-paper-2);
}

.cs-sw .sw {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 999px;
}

.cs-sw .l { font-size: 12px; font-weight: 500; }

/* With the button sized to its content there is no slack for `margin-left:auto`
   to eat, so the gap before the count is set explicitly. */
.cs-sw .c {
    margin-left: 4px;
    color: var(--cs-ink-3);
    font-family: var(--cs-mono);
    font-size: 9px;
}

/* top sellers */

.cs-top {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 150px));
    gap: 12px;
}

.cs-top-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--cs-ink);
    font-family: var(--cs-sans);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.cs-top-card .img {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border: 1px solid var(--cs-line);
}

.cs-top-card .img img {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: translate(-50%, -50%);
    transition: transform 0.4s ease;
}

.cs-top-card:hover .img { border-color: var(--cs-ink); }
.cs-top-card:hover .img img { transform: translate(-50%, -50%) scale(1.06); }

.cs-top-card .rank {
    position: absolute;
    top: 0;
    left: 0;
    padding: 3px 6px;
    background: var(--cs-ink);
    color: var(--cs-paper);
    font-family: var(--cs-mono);
    font-size: 9px;
    letter-spacing: 0.1em;
}

.cs-top-card .nm { font-size: 13px; font-weight: 500; line-height: 1.25; }

.cs-top-card .mt {
    color: var(--cs-ink-3);
    font-family: var(--cs-mono);
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* quick chips */

.cs-quick { display: flex; flex-wrap: wrap; gap: 8px; }

.cs-quick button {
    padding: 7px 11px;
    border: 1px solid var(--cs-line);
    background: transparent;
    color: var(--cs-ink-2);
    font-family: var(--cs-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
}

.cs-quick button:hover {
    border-color: var(--cs-ink);
    background: var(--cs-ink);
    color: var(--cs-paper);
}

/* states */

.cs-empty { padding: 34px 32px 40px; text-align: center; }

.cs-empty .h {
    font-family: var(--cs-serif);
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
}

.cs-empty .h em {
    color: var(--cs-accent);
    font-style: italic;
    font-weight: 300;
}

.cs-empty .p { margin-top: 10px; color: var(--cs-ink-3); font-size: 13px; }

.cs-loading {
    padding: 26px 32px 30px;
    color: var(--cs-ink-3);
    font-family: var(--cs-mono);
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

/* ---------------------------------------------------------------- the foot */

.cs-foot {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 12px 32px;
    border-top: 1px solid var(--cs-ink);
    background: var(--cs-paper-2);
    color: var(--cs-ink-3);
    font-family: var(--cs-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.cs-foot .kbd {
    padding: 2px 5px;
    border: 1px solid var(--cs-line);
    background: var(--cs-paper);
}

.cs-foot .all {
    margin-left: auto;
    color: var(--cs-ink);
    text-decoration: none;
    cursor: pointer;
}

.cs-foot .all:hover { color: var(--cs-accent); }

/* -------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
    .cs-bar { padding: 14px 20px; }
    .cs-sec { padding: 12px 20px 6px; }
    .cs-foot { padding: 11px 20px; }
    .cs-input { font-size: 24px; }
    .cs-top { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .cs-wrap.open {
        inset: 0;
        max-height: none;
        display: flex;
        flex-direction: column;
        border-bottom: 0;
    }
    .cs-panel { max-height: none; flex: 1; }
    .cs-input { font-size: 22px; }
    .cs-thumb { width: 44px; height: 54px; }
    .cs-foot .kbd,
    .cs-foot .hint { display: none; }
    .cs-top { grid-template-columns: 1fr 1fr; }
    .cs-row .go { display: none; }
}

/* stop the page scrolling behind the open panel */
body.cs-locked { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
    .cs-scrim,
    .cs-wrap,
    .cs-top-card .img img { transition: none; }
}
