/* ==========================================================================
   Slab Finder — the filter deck, sheet and photo grid used on /slabs and the
   home page. Namespaced .sf-* so it never fights Bootstrap or the home page.
   Tokens follow craftmilled.css: cream ground, slate primary, clay links,
   forest-green price. Kanit for the count sentence, Inter for everything else.
   ========================================================================== */
.sf {
  --sf-bg: #fcf9f5; --sf-bg-2: #f3ede4; --sf-bg-3: #e9e1d5;
  --sf-ink: #2b2622; --sf-ink-2: #5f5750; --sf-ink-3: #8a8178;
  --sf-line: #ddd3c6; --sf-line-2: #c9bdad;
  --sf-slate: #4a5a6d; --sf-slate-2: #3c4958; --sf-slate-soft: rgba(74, 90, 109, .12);
  --sf-clay: #6d4c4a; --sf-forest: #33691e;
  --sf-card: #ffffff;
  --sf-shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 6px 18px rgba(60, 40, 20, .08);
  --sf-ring: #4a5a6d;
  color: var(--sf-ink);
}
.sf *, .sf *::before, .sf *::after { box-sizing: border-box; }
.sf h1, .sf h2, .sf h3 { font-family: Kanit, ui-sans-serif, system-ui, sans-serif; font-weight: 600; margin: 0; text-wrap: balance; color: var(--sf-ink); }
.sf a { text-decoration: none; }
:where(.sf) button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.sf button:focus-visible, .sf input:focus-visible, .sf a:focus-visible, .sf label:focus-within { outline: 2px solid var(--sf-ring); outline-offset: 2px; }
.sf p { margin: 0 !important; }

/* ---- deck ---------------------------------------------------------------- */
.sf-deck { padding: 18px 0 8px; }
.sf-head { padding: 0 16px; display: flex; flex-direction: column; gap: 2px; }
.sf-head h1 { font-size: 26px; line-height: 1.1; }
.sf-live { font-family: Kanit, ui-sans-serif, system-ui, sans-serif; font-weight: 400; font-size: 17px; color: var(--sf-ink-2); min-height: 1.45em; }
.sf-live b { color: var(--sf-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.sf-guide { font-size: 13.5px; color: var(--sf-clay); margin-top: 4px !important; }
.sf-guide:hover { text-decoration: underline; }

.sf-rail { display: flex; gap: 10px; overflow-x: auto; padding: 14px 16px 6px; scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.sf-rail::-webkit-scrollbar { display: none; }
.sf-rail > * { scroll-snap-align: start; flex: 0 0 auto; }

/* species swatch: end-grain rings in the wood's own tone, pure CSS */
.sf-disc {
  display: inline-block; width: var(--sz, 60px); height: var(--sz, 60px); border-radius: 50%; position: relative;
  background:
    radial-gradient(circle at 38% 42%, rgba(255, 255, 255, .22) 0 6%, transparent 30%),
    repeating-radial-gradient(circle at 38% 42%, rgba(0, 0, 0, 0) 0 4.5px, rgba(45, 22, 8, .16) 4.5px 5.6px, rgba(0, 0, 0, 0) 5.6px 8.5px, rgba(45, 22, 8, .08) 8.5px 9.2px),
    var(--tone, #b08a5c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14), 0 1px 3px rgba(60, 40, 20, .18);
}
.sf-disc.sf-disc-sm { --sz: 14px; background: radial-gradient(circle at 40% 40%, rgba(255,255,255,.25) 0 15%, transparent 45%), var(--tone, #b08a5c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }

.sf-sw { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; width: 72px; color: var(--sf-ink-2); }
.sf-sw > * { align-self: center; }
.sf-sw .sf-disc { transition: transform .15s ease, box-shadow .15s ease; }
.sf-sw-all .sf-disc { background: var(--sf-bg-2); box-shadow: inset 0 0 0 1.5px var(--sf-line-2); }
.sf-sw-all .sf-disc svg { position: absolute; inset: 0; margin: auto; width: 26px; height: 26px; stroke: var(--sf-ink-2); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sf-sw .sf-lbl { font-size: 12px; line-height: 1.15; text-align: center; white-space: normal; max-width: 72px; color: var(--sf-ink-2); }
.sf-sw .sf-lbl span { display: block; font-size: 11px; color: var(--sf-ink-3); font-variant-numeric: tabular-nums; }
.sf-sw:hover .sf-disc { transform: translateY(-1px); }
.sf-sw.is-on .sf-disc { box-shadow: 0 0 0 2px var(--sf-bg), 0 0 0 4px var(--sf-ring), 0 2px 6px rgba(60, 40, 20, .2); transform: scale(1.04); }
.sf-sw.is-on .sf-lbl { color: var(--sf-ink); font-weight: 600; }
.sf-sw.is-on .sf-disc::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%; background: var(--sf-ring) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12.5l4.5 4.5L19 7.5'/></svg>") center / 12px no-repeat; box-shadow: 0 0 0 2px var(--sf-bg); }
.sf-sw.is-off { opacity: .38; pointer-events: none; }

/* chips: cut shapes on the rail, radio/checkbox chips inside the sheet */
.sf-chip { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px 0 11px; border-radius: 999px; border: 1px solid var(--sf-line-2); background: var(--sf-card); color: var(--sf-ink); font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer; transition: background .15s ease, border-color .15s ease, color .15s ease; position: relative; }
.sf-chip svg { width: 20px; height: 20px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sf-chip .sf-n { font-size: 12px; color: var(--sf-ink-3); font-variant-numeric: tabular-nums; font-weight: 400; }
.sf-chip.is-on, .sf-chip:has(input:checked) { background: var(--sf-slate); border-color: var(--sf-slate); color: #fff; }
.sf-chip.is-on .sf-n, .sf-chip:has(input:checked) .sf-n { color: rgba(255, 255, 255, .75); }
.sf-chip.is-off { opacity: .4; pointer-events: none; }
.sf-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.sf-chip.sf-chip-sm { height: 34px; font-size: 13.5px; padding: 0 12px; }

/* quick pills open the sheet */
.sf-quick { display: flex; gap: 8px; padding: 10px 16px 4px; overflow-x: auto; scrollbar-width: none; }
.sf-quick::-webkit-scrollbar { display: none; }
.sf-quick .sf-spacer { flex: 1; }
.sf-pill { background: var(--sf-bg-2); border-color: transparent; }
.sf-pill.is-on { background: var(--sf-slate-soft); border-color: var(--sf-slate); color: var(--sf-slate-2); }
.sf-pill .sf-caret { width: 14px; height: 14px; margin-left: -2px; opacity: .7; }

/* active filter tags */
.sf-active { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px 0; }
.sf-active:empty { display: none; }
.sf-tag { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px 0 10px; border-radius: 999px; background: var(--sf-slate-soft); color: var(--sf-slate-2); font-size: 13px; font-weight: 500; }
.sf-tag a { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; color: inherit; }
.sf-tag a:hover { background: rgba(0, 0, 0, .08); }
.sf-tag a svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; }
.sf-tag-clear { background: transparent; color: var(--sf-clay); padding: 0 6px; text-decoration: underline; text-underline-offset: 3px; }

/* ---- grid ---------------------------------------------------------------- */
.sf-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 14px 16px 0; }
@media (min-width: 640px) { .sf-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 1024px) { .sf-grid { grid-template-columns: repeat(4, 1fr); gap: 18px; } }
@media (min-width: 1400px) { .sf-grid { grid-template-columns: repeat(5, 1fr); } }
.sf-card { background: var(--sf-card); border-radius: 10px; overflow: hidden; box-shadow: var(--sf-shadow); display: flex; flex-direction: column; position: relative; transition: transform .2s ease, box-shadow .2s ease; }
.sf-card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(60, 40, 20, .08), 0 12px 28px rgba(60, 40, 20, .14); }
.sf-card .lc { background: var(--sf-bg-3); }
.sf-sp { position: absolute; left: 8px; bottom: 8px; z-index: 3; display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 5px; border-radius: 999px; background: rgba(252, 249, 245, .92); color: #2b2622; font-size: 11.5px; font-weight: 600; backdrop-filter: blur(4px); pointer-events: none; max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-cut { position: absolute; right: 8px; top: 8px; z-index: 3; height: 22px; padding: 0 8px; border-radius: 999px; background: rgba(43, 38, 34, .72); color: #fff; font-size: 11px; font-weight: 500; display: flex; align-items: center; gap: 5px; pointer-events: none; }
.sf-cut svg { width: 14px; height: 14px; stroke: #fff; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sf-dist { position: absolute; left: 8px; top: 8px; z-index: 3; height: 22px; padding: 0 8px; border-radius: 999px; background: rgba(252, 249, 245, .92); color: var(--sf-slate-2); font-size: 11px; font-weight: 600; display: flex; align-items: center; pointer-events: none; }
.sf-body { padding: 9px 10px 11px; display: flex; flex-direction: column; gap: 4px; flex: 1; color: inherit; }
.sf-title { font-size: 13.5px; font-weight: 500; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--sf-ink); }
.sf-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: auto; }
.sf-price { font-family: Kanit, ui-sans-serif, system-ui, sans-serif; font-weight: 600; font-size: 16px; color: var(--sf-forest); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sf-price small { font: 400 11px Inter, ui-sans-serif, system-ui, sans-serif; color: var(--sf-ink-3); margin-left: 3px; }
.sf-price.sf-ask { font: 500 12.5px Inter, ui-sans-serif, system-ui, sans-serif; color: var(--sf-ink-2); }
.sf-loc { font-size: 12px; color: var(--sf-ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sf-admin { padding: 0 10px 10px; }

.sf-pager { display: flex; justify-content: center; padding: 28px 16px 0; }
.sf-empty { padding: 48px 24px; text-align: center; color: var(--sf-ink-2); }
.sf-empty h2 { font-size: 20px; margin-bottom: 6px; }
.sf-empty .sf-chip { margin-top: 14px; }
.sf-empty-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }

/* ---- floating filters button --------------------------------------------- */
.sf-fab { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 0); height: 46px; padding: 0 20px 0 16px; border-radius: 999px; background: var(--sf-slate); color: #fff; font-weight: 600; font-size: 14px; box-shadow: 0 8px 24px rgba(30, 20, 10, .28); display: flex; align-items: center; gap: 8px; z-index: 1030; transition: transform .2s ease, opacity .2s ease; }
.sf-fab.is-hidden { opacity: 0; transform: translate(-50%, 80px); pointer-events: none; }
.sf-fab svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sf-fab .sf-n { background: rgba(255, 255, 255, .22); border-radius: 999px; padding: 1px 8px; font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---- bottom sheet ---------------------------------------------------------- */
.sf-scrim { position: fixed; inset: 0; background: rgba(43, 38, 34, .45); opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 1040; }
.sf-scrim.is-on { opacity: 1; pointer-events: auto; }
.sf-sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 88vh; max-height: 88dvh; background: var(--sf-bg); border-radius: 18px 18px 0 0; box-shadow: 0 -6px 30px rgba(0, 0, 0, .2); transform: translateY(104%); transition: transform .28s cubic-bezier(.32, .72, .2, 1); z-index: 1041; display: flex; flex-direction: column; color: var(--sf-ink); }
.sf-sheet.is-on { transform: none; }
.sf-sheet form { display: contents; }
.sf-grab { width: 38px; height: 4px; border-radius: 2px; background: var(--sf-line-2); margin: 10px auto 0; flex: 0 0 auto; }
.sf-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 18px 10px; flex: 0 0 auto; }
.sf-sheet-head h2 { font-size: 20px; }
.sf-sheet-head a { color: var(--sf-clay); font-weight: 500; font-size: 14px; }
.sf-sheet-scroll { overflow-y: auto; padding: 0 18px 18px; display: flex; flex-direction: column; gap: 22px; }
.sf-sheet-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--sf-line); display: flex; gap: 10px; flex: 0 0 auto; }
.sf-btn { height: 46px; border-radius: 12px; font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: center; flex: 1; gap: 8px; }
.sf-btn-primary { background: var(--sf-slate); color: #fff !important; }
.sf-btn-primary span { color: #fff !important; }
.sf-chip.is-on span, .sf-chip:has(input:checked) span { color: #fff !important; }
.sf-chip.is-on .sf-n, .sf-chip:has(input:checked) .sf-n { color: rgba(255, 255, 255, .75) !important; }
.sf-fab span { color: #fff !important; }
.sf-btn-primary:hover { background: var(--sf-slate-2); }
.sf-btn-ghost { background: transparent; color: var(--sf-ink-2) !important; border: 1px solid var(--sf-line-2); flex: 0 0 auto; padding: 0 18px; }
.sf-f { display: flex; flex-direction: column; gap: 9px; scroll-margin-top: 12px; }
.sf-f h3 { font-size: 15px; font-weight: 600; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sf-f h3 small { font: 400 12.5px Inter, ui-sans-serif, system-ui, sans-serif; color: var(--sf-ink-3); }
.sf-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.sf-seg { display: flex; background: var(--sf-bg-2); border-radius: 10px; padding: 3px; }
.sf-seg label { flex: 1; height: 36px; border-radius: 8px; font-size: 13.5px; font-weight: 500; color: var(--sf-ink-2); display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.sf-seg label:has(input:checked) { background: var(--sf-card); color: var(--sf-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.sf-seg input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.sf-inrow { display: flex; gap: 8px; align-items: center; }
.sf-in { height: 44px; border: 1px solid var(--sf-line-2) !important; border-radius: 10px !important; padding: 0 12px; background: var(--sf-card) !important; width: 100%; font-size: 15px; color: var(--sf-ink) !important; box-shadow: none !important; }
.sf-in::placeholder { color: var(--sf-ink-3); }
.sf-in.sf-zip { max-width: 140px; letter-spacing: .04em; }
.sf-tilde { color: var(--sf-ink-3); }
.sf-hint { font-size: 12.5px; color: var(--sf-ink-3); }
.sf-hint.is-err { color: #b3261e; }
.sf-link { color: var(--sf-clay); font-weight: 500; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.sf-link svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---- wider screens: the sheet becomes a panel, the deck one block ------- */
@media (min-width: 768px) {
  .sf-head { padding: 0 24px; }
  .sf-rail, .sf-quick, .sf-active, .sf-grid, .sf-pager { padding-left: 24px; padding-right: 24px; }
  .sf-sheet { left: auto; right: 24px; bottom: 24px; width: 420px; border-radius: 18px; max-height: min(80vh, 720px); }
  .sf-grab { display: none; }
  .sf-fab { left: auto; right: 24px; transform: none; }
  .sf-fab.is-hidden { transform: translateY(80px); }
}
@media (min-width: 1024px) {
  .sf-deck { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "head head" "species species" "shapes quick" "active active"; align-items: center; }
  .sf-head { grid-area: head; }
  .sf-species { grid-area: species; }
  .sf-shapes { grid-area: shapes; }
  .sf-quick { grid-area: quick; padding-top: 14px; }
  .sf-active { grid-area: active; }
}
@media (prefers-reduced-motion: reduce) {
  .sf *, .sf-sheet, .sf-scrim, .sf-fab { transition: none !important; }
}

/* ---- home page: the same deck as an entry point ----------------------------- */
.sf-home .sf-deck { padding: 0; }
.sf-home .sf-head, .sf-home .sf-rail, .sf-home .sf-quick { padding-left: 0; padding-right: 0; }
.sf-home .sf-quick { flex-wrap: wrap; overflow: visible; }
.sf-home .sf-near { display: flex; gap: 8px; align-items: center; background: var(--sf-card); border: 1px solid var(--sf-line-2); border-radius: 999px; padding: 4px 4px 4px 14px; height: 46px; max-width: 420px; }
.sf-home .sf-near input { border: 0; background: transparent; font-size: 15px; width: 100%; min-width: 0; outline: none; box-shadow: none !important; color: var(--sf-ink) !important; }
.sf-home .sf-near select { border: 0; background: transparent; font-size: 14px; color: var(--sf-ink-2); box-shadow: none !important; padding-right: 4px; }
.sf-home .sf-near button { height: 38px; padding: 0 16px; border-radius: 999px; background: var(--sf-slate); color: #fff; font-weight: 600; font-size: 14px; flex: 0 0 auto; }
.sf-home .sf-near svg { width: 18px; height: 18px; stroke: var(--sf-ink-3); fill: none; stroke-width: 1.8; flex: 0 0 auto; }
