Horizontal Chip Filter Rail + Slide-Up Facet Sheet
Horizontally scrollable category chip rail paired with a slide-up multi-facet filter sheet showing live match counts.
Inspired by Airbnb ↗
WHY THIS AESTHETIC IS UNIQUE
Separates instant one-tap category browsing from deep multi-criteria filtering, keeping the browse header compact while delivering full search power on demand.
BEST FOR
TAGS
COLOR PALETTE (CLICK TO COPY HEX)
TYPOGRAPHY
- Display
- Plus Jakarta Sans
- Body
- Inter
- Mono
- JetBrains Mono
- Scale
- Compact 12-13px icon chip labels, crisp 16px listing titles, and bold price callouts.
ARCHITECTURE & MOBILE NOTES
LAYOUT
Sticky top horizontal icon-chip rail with pinned Filters pill on the right, responsive card grid below, and a modal/slide-up facet sheet with sticky footer CTA.
INTERACTION
Tapping any category chip filters listings immediately; opening Filters lets users combine price ceiling, bedrooms, instant-book, and amenities while the footer CTA updates live ('Show N stays').
MOBILE
Smooth momentum-scrolling chip rail with active filter count badge and a bottom-anchored facet sheet that stays within thumb reach.
AI AGENT GUARDRAILS
DO
- Display a live active-filter badge on the Filters button and a one-tap Clear All reset inside the sheet
- Update the primary sheet CTA with the exact matching result count before applying
- Keep the Filters button pinned or always reachable so users never have to scroll to the end of the chip rail
DON'T
- Do not wrap 10+ filter chips into 4 tall vertical rows that push listings below the fold on mobile
- Do not discard active chip selection when applying secondary facets inside the sheet
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Habitat — Horizontal Chip Filter Rail & Slide-Up Facet Sheet</title>
<style>
:root {
--canvas: #FFFFFF;
--surface: #F7F7F7;
--ink: #1A1A1A;
--accent: #E11D48;
--accent-hover: #BE123C;
--accent-soft: #FFF1F2;
--muted: #717171;
--border: #E5E5E5;
--radius: 16px;
--font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
background: var(--canvas);
color: var(--ink);
font-family: var(--font);
line-height: 1.45;
-webkit-font-smoothing: antialiased;
overflow-x: clip;
}
/* Sticky Top Header + Chip Rail */
.sticky-bar {
position: sticky;
top: 0;
z-index: 20;
background: rgba(255, 255, 255, 0.96);
backdrop-filter: blur(8px);
border-bottom: 1px solid var(--border);
}
.bar-inner {
max-width: 1220px;
margin: 0 auto;
padding: 12px 14px 10px;
}
@media (min-width: 768px) {
.bar-inner { padding: 14px 28px 12px; }
}
.brand-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.brand-lockup {
display: flex;
align-items: center;
gap: 9px;
font-weight: 800;
font-size: 1.1rem;
letter-spacing: -0.02em;
color: var(--accent);
}
.brand-lockup span { color: var(--ink); }
.match-summary {
font-size: 0.82rem;
font-weight: 600;
color: var(--muted);
}
/* Chip Rail + Pinned Filter Button */
.rail-row {
display: flex;
align-items: center;
gap: 10px;
}
.chip-rail {
display: flex;
align-items: center;
gap: 8px;
overflow-x: auto;
scrollbar-width: none;
flex: 1;
min-width: 0;
padding: 2px 0;
}
.chip-rail::-webkit-scrollbar { display: none; }
.cat-chip {
min-height: 46px;
padding: 6px 14px;
border-radius: 999px;
border: 1.5px solid var(--border);
background: var(--canvas);
color: var(--muted);
font-size: 0.82rem;
font-weight: 650;
font-family: inherit;
cursor: pointer;
white-space: nowrap;
display: inline-flex;
align-items: center;
gap: 7px;
transition: all 0.16s;
}
.cat-chip:hover {
border-color: #BDBDBD;
color: var(--ink);
}
.cat-chip.active {
background: var(--ink);
border-color: var(--ink);
color: #FFFFFF;
}
.filters-pill {
min-height: 46px;
padding: 0 15px;
border-radius: 999px;
border: 1.5px solid var(--ink);
background: var(--canvas);
color: var(--ink);
font-size: 0.84rem;
font-weight: 700;
font-family: inherit;
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 7px;
flex-shrink: 0;
position: relative;
transition: background 0.15s, color 0.15s;
}
.filters-pill:hover { background: var(--surface); }
.filter-badge {
min-width: 20px;
height: 20px;
padding: 0 6px;
border-radius: 999px;
background: var(--accent);
color: #FFFFFF;
font-size: 0.72rem;
font-weight: 800;
display: none;
place-items: center;
}
.filter-badge.show { display: grid; }
/* Listings Grid */
.directory {
max-width: 1220px;
margin: 0 auto;
padding: 18px 14px 56px;
}
@media (min-width: 768px) {
.directory { padding: 26px 28px 64px; }
}
.active-tags {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-bottom: 16px;
}
.active-tags:empty { display: none; }
.active-tag {
min-height: 34px;
padding: 0 11px;
border-radius: 999px;
background: var(--accent-soft);
color: var(--accent-hover);
border: 1px solid #FECDD3;
font-size: 0.78rem;
font-weight: 650;
display: inline-flex;
align-items: center;
gap: 6px;
cursor: pointer;
}
.stays-grid {
display: grid;
grid-template-columns: 1fr;
gap: 20px;
}
@media (min-width: 640px) {
.stays-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 980px) {
.stays-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
}
.stay-card {
display: flex;
flex-direction: column;
gap: 10px;
}
.stay-art {
position: relative;
aspect-ratio: 4 / 3;
border-radius: var(--radius);
overflow: hidden;
background: var(--surface);
}
.stay-art svg {
width: 100%;
height: 100%;
display: block;
transition: transform 0.35s ease;
}
.stay-card:hover .stay-art svg { transform: scale(1.03); }
.instant-pill {
position: absolute;
top: 12px;
left: 12px;
background: rgba(255, 255, 255, 0.94);
color: var(--ink);
font-size: 0.7rem;
font-weight: 750;
padding: 4px 9px;
border-radius: 999px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.heart-btn {
position: absolute;
top: 6px;
right: 6px;
width: 44px;
height: 44px;
border: none;
background: transparent;
color: #FFFFFF;
cursor: pointer;
display: grid;
place-items: center;
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.32));
}
.heart-btn.saved { color: var(--accent); }
.stay-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 8px;
}
.stay-title {
font-size: 0.96rem;
font-weight: 700;
color: var(--ink);
}
.stay-rating {
font-size: 0.84rem;
font-weight: 650;
display: inline-flex;
align-items: center;
gap: 3px;
flex-shrink: 0;
}
.stay-sub {
font-size: 0.83rem;
color: var(--muted);
}
.stay-price {
font-size: 0.94rem;
margin-top: 2px;
}
.stay-price strong { font-weight: 750; }
.empty-box {
grid-column: 1 / -1;
text-align: center;
padding: 48px 20px;
border-radius: var(--radius);
background: var(--surface);
color: var(--muted);
}
/* Slide-Up Multi-Facet Bottom Sheet */
.sheet-backdrop {
position: fixed;
inset: 0;
background: rgba(26, 26, 26, 0.48);
backdrop-filter: blur(2px);
z-index: 40;
opacity: 0;
pointer-events: none;
transition: opacity 0.24s ease;
display: flex;
align-items: flex-end;
justify-content: center;
}
@media (min-width: 720px) {
.sheet-backdrop { align-items: center; padding: 24px; }
}
.sheet-backdrop.open {
opacity: 1;
pointer-events: auto;
}
.facet-sheet {
width: 100%;
max-width: 560px;
max-height: 88dvh;
background: var(--canvas);
border-radius: 22px 22px 0 0;
display: flex;
flex-direction: column;
overflow: hidden;
transform: translateY(100%);
transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
}
@media (min-width: 720px) {
.facet-sheet {
border-radius: 22px;
transform: translateY(28px) scale(0.98);
}
}
.sheet-backdrop.open .facet-sheet {
transform: translateY(0) scale(1);
}
.sheet-head {
padding: 12px 16px;
border-bottom: 1px solid var(--border);
display: flex;
align-items: center;
justify-content: space-between;
}
.sheet-head h2 {
font-size: 1rem;
font-weight: 750;
}
.icon-close {
width: 44px;
height: 44px;
border: none;
border-radius: 50%;
background: transparent;
color: var(--ink);
cursor: pointer;
display: grid;
place-items: center;
}
.icon-close:hover { background: var(--surface); }
.sheet-body {
padding: 18px 20px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 22px;
}
.facet-block h3 {
font-size: 0.92rem;
font-weight: 700;
margin-bottom: 10px;
}
.price-readout {
display: flex;
justify-content: space-between;
font-size: 0.85rem;
color: var(--muted);
margin-bottom: 10px;
}
.price-readout strong { color: var(--ink); font-size: 1rem; }
.range-slider {
width: 100%;
accent-color: var(--accent);
height: 6px;
cursor: pointer;
}
.bed-pills {
display: flex;
gap: 8px;
flex-wrap: wrap;
}
.bed-btn {
min-height: 44px;
min-width: 56px;
padding: 0 14px;
border-radius: 999px;
border: 1.5px solid var(--border);
background: var(--canvas);
color: var(--ink);
font-size: 0.84rem;
font-weight: 650;
font-family: inherit;
cursor: pointer;
}
.bed-btn.active {
background: var(--ink);
border-color: var(--ink);
color: #FFFFFF;
}
.toggle-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 12px 14px;
border-radius: 14px;
background: var(--surface);
}
.toggle-row p { font-size: 0.78rem; color: var(--muted); }
.switch-btn {
width: 52px;
height: 32px;
border-radius: 999px;
border: none;
background: #D4D4D4;
position: relative;
cursor: pointer;
flex-shrink: 0;
transition: background 0.2s;
}
.switch-btn::after {
content: "";
position: absolute;
top: 3px;
left: 3px;
width: 26px;
height: 26px;
border-radius: 50%;
background: #FFFFFF;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
transition: transform 0.2s;
}
.switch-btn.on { background: var(--accent); }
.switch-btn.on::after { transform: translateX(20px); }
.amenity-grid {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.amenity-chip {
min-height: 44px;
padding: 0 14px;
border-radius: 11px;
border: 1.5px solid var(--border);
background: var(--canvas);
color: var(--ink);
font-size: 0.83rem;
font-weight: 600;
font-family: inherit;
cursor: pointer;
}
.amenity-chip.active {
border-color: var(--accent);
background: var(--accent-soft);
color: var(--accent-hover);
}
.sheet-foot {
padding: 12px 20px 16px;
border-top: 1px solid var(--border);
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.btn-clear {
min-height: 44px;
padding: 0 12px;
border: none;
background: transparent;
color: var(--ink);
font-size: 0.88rem;
font-weight: 700;
text-decoration: underline;
cursor: pointer;
}
.btn-apply {
min-height: 46px;
padding: 0 22px;
border: none;
border-radius: 12px;
background: var(--accent);
color: #FFFFFF;
font-size: 0.9rem;
font-weight: 700;
font-family: inherit;
cursor: pointer;
}
.btn-apply:hover { background: var(--accent-hover); }
</style>
</head>
<body>
<header class="sticky-bar">
<div class="bar-inner">
<div class="brand-row">
<div class="brand-lockup">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round"><path d="M3 10.5L12 3l9 7.5"/><path d="M5 9.5V20h14V9.5"/><path d="M9.5 20v-6h5v6"/></svg>
<span>Habitat</span>
</div>
<span id="matchSummary" class="match-summary">9 architectural stays</span>
</div>
<div class="rail-row">
<nav id="chipRail" class="chip-rail" aria-label="Stay categories"></nav>
<button id="openFilters" class="filters-pill" type="button">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><line x1="4" y1="6" x2="20" y2="6"/><line x1="7" y1="12" x2="17" y2="12"/><line x1="10" y1="18" x2="14" y2="18"/></svg>
Filters
<span id="filterBadge" class="filter-badge">0</span>
</button>
</div>
</div>
</header>
<main class="directory">
<div id="activeTags" class="active-tags"></div>
<section id="staysGrid" class="stays-grid" aria-label="Architectural stays"></section>
</main>
<!-- Slide-Up Facet Sheet -->
<div id="sheetBackdrop" class="sheet-backdrop" role="dialog" aria-modal="true" aria-label="Filter stays">
<div class="facet-sheet">
<div class="sheet-head">
<button id="closeSheet" class="icon-close" type="button" aria-label="Close filters">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
</button>
<h2>Filters</h2>
<span style="width:44px"></span>
</div>
<div class="sheet-body">
<div class="facet-block">
<h3>Max nightly price</h3>
<div class="price-readout">
<span>Up to</span>
<strong id="priceVal">$650 / night</strong>
</div>
<input id="priceSlider" class="range-slider" type="range" min="160" max="650" step="10" value="650" aria-label="Maximum nightly price">
</div>
<div class="facet-block">
<h3>Bedrooms</h3>
<div id="bedPills" class="bed-pills">
<button class="bed-btn active" data-beds="0" type="button">Any</button>
<button class="bed-btn" data-beds="1" type="button">1+</button>
<button class="bed-btn" data-beds="2" type="button">2+</button>
<button class="bed-btn" data-beds="3" type="button">3+</button>
<button class="bed-btn" data-beds="4" type="button">4+</button>
</div>
</div>
<div class="facet-block">
<div class="toggle-row">
<div>
<strong style="font-size:0.9rem">Instant Book</strong>
<p>Confirm immediately without waiting for host approval</p>
</div>
<button id="instantToggle" class="switch-btn" type="button" role="switch" aria-checked="false" aria-label="Instant Book only"></button>
</div>
</div>
<div class="facet-block">
<h3>Amenities</h3>
<div id="amenityGrid" class="amenity-grid"></div>
</div>
</div>
<div class="sheet-foot">
<button id="clearAllBtn" class="btn-clear" type="button">Clear all</button>
<button id="applySheetBtn" class="btn-apply" type="button">Show 9 stays</button>
</div>
</div>
</div>
<script>
(function () {
const CATEGORIES = [
{ id: "all", label: "All Stays", icon: `<path d="M3 10.5L12 3l9 7.5M5 9.5V20h14V9.5"/>` },
{ id: "cabin", label: "A-Frame Cabins", icon: `<polygon points="12 3 3 20 21 20 12 3"/><line x1="12" y1="12" x2="12" y2="20"/>` },
{ id: "glass", label: "Glass Houses", icon: `<rect x="3" y="5" width="18" height="14" rx="2"/><line x1="9" y1="5" x2="9" y2="19"/><line x1="15" y1="5" x2="15" y2="19"/>` },
{ id: "desert", label: "Desert Modern", icon: `<circle cx="17" cy="7" r="2.5"/><path d="M2 18h20M4 18l5-7 4 5 3-3 4 5"/>` },
{ id: "coastal", label: "Coastal", icon: `<path d="M2 15c2-2 4-2 6 0s4 2 6 0 4-2 6 0"/><path d="M2 19c2-2 4-2 6 0s4 2 6 0 4-2 6 0"/><path d="M12 4v7"/>` },
{ id: "nordic", label: "Nordic Timber", icon: `<path d="M12 3l7 8h-4l5 7H4l5-7H5l7-8z"/>` }
];
const AMENITIES = ["Pool", "Fireplace", "Sauna", "EV Charger", "Workspace", "Ocean View"];
const STAYS = [
{ id: "s1", title: "Glass Pavilion in the Pines", loc: "Big Sur, California", cat: "glass", price: 420, beds: 3, rating: 4.96, instant: true, amenities: ["Fireplace", "Ocean View", "EV Charger"], palette: ["#DCEEFB", "#60A5FA", "#1E3A5F"] },
{ id: "s2", title: "Cedar A-Frame & Cedar Sauna", loc: "Hood River, Oregon", cat: "cabin", price: 245, beds: 2, rating: 4.92, instant: true, amenities: ["Fireplace", "Sauna", "Workspace"], palette: ["#E8F3E8", "#34D399", "#14532D"] },
{ id: "s3", title: "Cantilevered Adobe Villa", loc: "Joshua Tree, California", cat: "desert", price: 360, beds: 3, rating: 4.89, instant: false, amenities: ["Pool", "EV Charger", "Workspace"], palette: ["#FDE8D7", "#F59E0B", "#7C2D12"] },
{ id: "s4", title: "Cliffside Concrete Horizon", loc: "Carmel, California", cat: "coastal", price: 540, beds: 4, rating: 4.98, instant: true, amenities: ["Pool", "Ocean View", "Fireplace"], palette: ["#E0F2FE", "#0284C7", "#0F172A"] },
{ id: "s5", title: "Fjord Mirror Cabin", loc: "Lofoten, Norway", cat: "nordic", price: 290, beds: 1, rating: 4.95, instant: false, amenities: ["Sauna", "Ocean View", "Fireplace"], palette: ["#E2E8F0", "#64748B", "#1E293B"] },
{ id: "s6", title: "Sunlit Courtyard Atrium", loc: "Scottsdale, Arizona", cat: "desert", price: 310, beds: 2, rating: 4.87, instant: true, amenities: ["Pool", "Workspace"], palette: ["#FEF3C7", "#EA580C", "#431407"] },
{ id: "s7", title: "Forest Canopy Glass Loft", loc: "Catskills, New York", cat: "glass", price: 215, beds: 1, rating: 4.91, instant: true, amenities: ["Fireplace", "Workspace", "EV Charger"], palette: ["#DCFCE7", "#16A34A", "#14532D"] },
{ id: "s8", title: "Black-Timber Pine Retreat", loc: "Bozeman, Montana", cat: "cabin", price: 380, beds: 3, rating: 4.94, instant: false, amenities: ["Fireplace", "Sauna", "EV Charger"], palette: ["#F1F5F9", "#475569", "#0F172A"] },
{ id: "s9", title: "Minimalist Dune House", loc: "Comporta, Portugal", cat: "coastal", price: 460, beds: 4, rating: 4.97, instant: true, amenities: ["Pool", "Ocean View", "Workspace"], palette: ["#FEF9C3", "#0EA5E9", "#0C4A6E"] }
];
const state = {
category: "all",
maxPrice: 650,
minBeds: 0,
instantOnly: false,
amenities: new Set(),
saved: new Set(["s1", "s4"])
};
const els = {
chipRail: document.getElementById("chipRail"),
staysGrid: document.getElementById("staysGrid"),
matchSummary: document.getElementById("matchSummary"),
filterBadge: document.getElementById("filterBadge"),
activeTags: document.getElementById("activeTags"),
openFilters: document.getElementById("openFilters"),
sheetBackdrop: document.getElementById("sheetBackdrop"),
closeSheet: document.getElementById("closeSheet"),
priceSlider: document.getElementById("priceSlider"),
priceVal: document.getElementById("priceVal"),
bedPills: document.getElementById("bedPills"),
instantToggle: document.getElementById("instantToggle"),
amenityGrid: document.getElementById("amenityGrid"),
clearAllBtn: document.getElementById("clearAllBtn"),
applySheetBtn: document.getElementById("applySheetBtn")
};
function archSvg(stay) {
const [bg, mid, dark] = stay.palette;
if (stay.cat === "cabin" || stay.cat === "nordic") {
return `<svg viewBox="0 0 320 240" preserveAspectRatio="xMidYMid slice">
<rect width="320" height="240" fill="${bg}"/>
<circle cx="256" cy="54" r="22" fill="#FFFFFF" opacity="0.75"/>
<path d="M0 185 Q80 150 160 180 T320 170 L320 240 L0 240 Z" fill="${mid}" opacity="0.35"/>
<polygon points="160,56 76,192 244,192" fill="${dark}"/>
<polygon points="160,78 102,192 218,192" fill="#FFFBEB" opacity="0.24"/>
<rect x="142" y="138" width="36" height="54" fill="#FDE68A" opacity="0.9"/>
</svg>`;
}
if (stay.cat === "desert") {
return `<svg viewBox="0 0 320 240" preserveAspectRatio="xMidYMid slice">
<rect width="320" height="240" fill="${bg}"/>
<circle cx="80" cy="64" r="28" fill="${mid}" opacity="0.6"/>
<path d="M0 175 L320 162 L320 240 L0 240 Z" fill="${mid}" opacity="0.32"/>
<rect x="64" y="112" width="192" height="68" rx="4" fill="${dark}"/>
<rect x="44" y="102" width="218" height="14" rx="2" fill="${dark}"/>
<rect x="82" y="128" width="66" height="42" fill="#FEF3C7" opacity="0.88"/>
<rect x="162" y="128" width="76" height="42" fill="#FEF3C7" opacity="0.72"/>
</svg>`;
}
return `<svg viewBox="0 0 320 240" preserveAspectRatio="xMidYMid slice">
<rect width="320" height="240" fill="${bg}"/>
<rect x="0" y="170" width="320" height="70" fill="${mid}" opacity="0.35"/>
<rect x="52" y="88" width="216" height="90" rx="5" fill="${dark}"/>
<rect x="64" y="100" width="90" height="66" fill="#FFFFFF" opacity="0.82"/>
<rect x="164" y="100" width="92" height="66" fill="#FEF3C7" opacity="0.85"/>
<line x1="109" y1="100" x2="109" y2="166" stroke="${dark}" stroke-width="3"/>
<line x1="210" y1="100" x2="210" y2="166" stroke="${dark}" stroke-width="3"/>
</svg>`;
}
function activeFacetCount() {
let n = 0;
if (state.maxPrice < 650) n++;
if (state.minBeds > 0) n++;
if (state.instantOnly) n++;
n += state.amenities.size;
return n;
}
function filteredStays() {
return STAYS.filter((s) => {
if (state.category !== "all" && s.cat !== state.category) return false;
if (s.price > state.maxPrice) return false;
if (s.beds < state.minBeds) return false;
if (state.instantOnly && !s.instant) return false;
for (const a of state.amenities) {
if (!s.amenities.includes(a)) return false;
}
return true;
});
}
function renderRail() {
els.chipRail.innerHTML = CATEGORIES.map((c) => `
<button class="cat-chip ${state.category === c.id ? "active" : ""}" data-cat="${c.id}" type="button">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${c.icon}</svg>
${c.label}
</button>
`).join("");
}
function renderSheetControls() {
els.priceSlider.value = state.maxPrice;
els.priceVal.textContent = `$${state.maxPrice} / night`;
els.instantToggle.classList.toggle("on", state.instantOnly);
els.instantToggle.setAttribute("aria-checked", String(state.instantOnly));
els.bedPills.querySelectorAll("[data-beds]").forEach((btn) => {
btn.classList.toggle("active", Number(btn.dataset.beds) === state.minBeds);
});
els.amenityGrid.innerHTML = AMENITIES.map((a) => `
<button class="amenity-chip ${state.amenities.has(a) ? "active" : ""}" data-amenity="${a}" type="button">${a}</button>
`).join("");
}
function renderActiveTags() {
const tags = [];
if (state.maxPrice < 650) tags.push({ key: "price", label: `Up to $${state.maxPrice}` });
if (state.minBeds > 0) tags.push({ key: "beds", label: `${state.minBeds}+ bedrooms` });
if (state.instantOnly) tags.push({ key: "instant", label: "Instant Book" });
state.amenities.forEach((a) => tags.push({ key: "am:" + a, label: a }));
els.activeTags.innerHTML = tags.map((t) => `
<button class="active-tag" data-remove="${t.key}" type="button">${t.label} ×</button>
`).join("");
}
function renderStays() {
const list = filteredStays();
const count = activeFacetCount();
els.filterBadge.textContent = count;
els.filterBadge.classList.toggle("show", count > 0);
els.matchSummary.textContent = `${list.length} architectural stay${list.length === 1 ? "" : "s"}`;
els.applySheetBtn.textContent = `Show ${list.length} stay${list.length === 1 ? "" : "s"}`;
renderActiveTags();
if (list.length === 0) {
els.staysGrid.innerHTML = `<div class="empty-box"><strong>No stays match all active filters</strong><p style="margin-top:6px">Try raising the max price or removing an amenity filter.</p></div>`;
return;
}
els.staysGrid.innerHTML = list.map((s) => {
const saved = state.saved.has(s.id);
return `
<article class="stay-card">
<div class="stay-art">
${archSvg(s)}
${s.instant ? `<span class="instant-pill">⚡ Instant Book</span>` : ""}
<button class="heart-btn ${saved ? "saved" : ""}" data-heart="${s.id}" type="button" aria-label="Save ${s.title}">
<svg width="22" height="22" viewBox="0 0 24 24" fill="${saved ? "currentColor" : "rgba(0,0,0,0.35)"}" stroke="#FFFFFF" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>
</button>
</div>
<div>
<div class="stay-row">
<span class="stay-title">${s.title}</span>
<span class="stay-rating">★ ${s.rating.toFixed(2)}</span>
</div>
<div class="stay-sub">${s.loc} · ${s.beds} bed${s.beds > 1 ? "s" : ""} · ${s.amenities.slice(0, 2).join(", ")}</div>
<div class="stay-price"><strong>$${s.price}</strong> <span style="color:var(--muted)">night</span></div>
</div>
</article>
`;
}).join("");
}
function renderAll() {
renderRail();
renderSheetControls();
renderStays();
}
// Events
els.chipRail.addEventListener("click", (e) => {
const btn = e.target.closest("[data-cat]");
if (!btn) return;
state.category = btn.dataset.cat;
renderAll();
});
els.openFilters.addEventListener("click", () => els.sheetBackdrop.classList.add("open"));
els.closeSheet.addEventListener("click", () => els.sheetBackdrop.classList.remove("open"));
els.applySheetBtn.addEventListener("click", () => els.sheetBackdrop.classList.remove("open"));
els.sheetBackdrop.addEventListener("click", (e) => {
if (e.target === els.sheetBackdrop) els.sheetBackdrop.classList.remove("open");
});
els.priceSlider.addEventListener("input", (e) => {
state.maxPrice = Number(e.target.value);
els.priceVal.textContent = `$${state.maxPrice} / night`;
renderStays();
});
els.bedPills.addEventListener("click", (e) => {
const btn = e.target.closest("[data-beds]");
if (!btn) return;
state.minBeds = Number(btn.dataset.beds);
renderSheetControls();
renderStays();
});
els.instantToggle.addEventListener("click", () => {
state.instantOnly = !state.instantOnly;
renderSheetControls();
renderStays();
});
els.amenityGrid.addEventListener("click", (e) => {
const btn = e.target.closest("[data-amenity]");
if (!btn) return;
const a = btn.dataset.amenity;
if (state.amenities.has(a)) state.amenities.delete(a);
else state.amenities.add(a);
renderSheetControls();
renderStays();
});
els.clearAllBtn.addEventListener("click", () => {
state.maxPrice = 650;
state.minBeds = 0;
state.instantOnly = false;
state.amenities.clear();
renderAll();
});
els.activeTags.addEventListener("click", (e) => {
const btn = e.target.closest("[data-remove]");
if (!btn) return;
const key = btn.dataset.remove;
if (key === "price") state.maxPrice = 650;
else if (key === "beds") state.minBeds = 0;
else if (key === "instant") state.instantOnly = false;
else if (key.startsWith("am:")) state.amenities.delete(key.slice(3));
renderAll();
});
els.staysGrid.addEventListener("click", (e) => {
const heart = e.target.closest("[data-heart]");
if (!heart) return;
const id = heart.dataset.heart;
if (state.saved.has(id)) state.saved.delete(id);
else state.saved.add(id);
renderStays();
});
document.addEventListener("keydown", (e) => {
if (e.key === "Escape") els.sheetBackdrop.classList.remove("open");
});
renderAll();
})();
</script>
</body>
</html>