{
  "id": 111,
  "slug": "chip-rail-facet-sheet",
  "name": "Horizontal Chip Filter Rail + Slide-Up Facet Sheet",
  "kind": "ui",
  "family": "Search & Filtering",
  "sourceSite": {
    "name": "Airbnb",
    "url": "https://www.airbnb.com",
    "verifiedStatus": 200
  },
  "tagline": "Horizontally scrollable category chip rail paired with a slide-up multi-facet filter sheet showing live match counts.",
  "whyUnique": "Separates instant one-tap category browsing from deep multi-criteria filtering, keeping the browse header compact while delivering full search power on demand.",
  "theme": "light",
  "mobileStrength": "native-first",
  "tags": [
    "chip-rail",
    "facet-sheet",
    "filter-drawer",
    "marketplace-ui",
    "live-count"
  ],
  "bestFor": [
    "Travel & accommodation marketplaces",
    "E-commerce category pages",
    "Restaurant & venue finders",
    "Job boards"
  ],
  "palette": [
    {
      "role": "canvas",
      "hex": "#FFFFFF",
      "name": "Gallery White"
    },
    {
      "role": "surface",
      "hex": "#F7F7F7",
      "name": "Soft Stone"
    },
    {
      "role": "ink",
      "hex": "#1A1A1A",
      "name": "Ink Black"
    },
    {
      "role": "accent",
      "hex": "#E11D48",
      "name": "Rose Coral"
    },
    {
      "role": "muted",
      "hex": "#717171",
      "name": "Neutral Ash"
    }
  ],
  "typography": {
    "display": "Plus Jakarta Sans",
    "body": "Inter",
    "mono": "JetBrains Mono",
    "googleFontsUrl": "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500&family=Plus+Jakarta+Sans:wght@700&display=swap",
    "scaleNotes": "Compact 12-13px icon chip labels, crisp 16px listing titles, and bold price callouts."
  },
  "layoutNotes": "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.",
  "interactionNotes": "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').",
  "mobileNotes": "Smooth momentum-scrolling chip rail with active filter count badge and a bottom-anchored facet sheet that stays within thumb reach.",
  "agentGuardrails": {
    "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"
    ],
    "dont": [
      "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"
    ]
  },
  "demoFile": "demos/chip-rail-facet-sheet.html",
  "thumbDesktop": "thumbs/chip-rail-facet-sheet-desktop.webp",
  "thumbMobile": "thumbs/chip-rail-facet-sheet-mobile.webp",
  "urls": {
    "page": "https://templates.michaelpitts.net/t/chip-rail-facet-sheet",
    "markdown": "https://templates.michaelpitts.net/t/chip-rail-facet-sheet.md",
    "api": "https://templates.michaelpitts.net/api/templates/chip-rail-facet-sheet",
    "demo": "https://templates.michaelpitts.net/demos/chip-rail-facet-sheet.html",
    "thumbDesktop": "https://templates.michaelpitts.net/thumbs/chip-rail-facet-sheet-desktop.webp",
    "thumbMobile": "https://templates.michaelpitts.net/thumbs/chip-rail-facet-sheet-mobile.webp"
  },
  "agentPrompt": "Design & build using template #111 \"Horizontal Chip Filter Rail + Slide-Up Facet Sheet\" (ui / Search & Filtering, light theme).\nFull AI blueprint & standalone starter code: https://templates.michaelpitts.net/t/chip-rail-facet-sheet.md\nLive demo: https://templates.michaelpitts.net/demos/chip-rail-facet-sheet.html\nReal-world inspiration: Airbnb (https://www.airbnb.com)\n\nCore aesthetic: Separates instant one-tap category browsing from deep multi-criteria filtering, keeping the browse header compact while delivering full search power on demand.\nPalette: canvas: #FFFFFF (Gallery White), surface: #F7F7F7 (Soft Stone), ink: #1A1A1A (Ink Black), accent: #E11D48 (Rose Coral), muted: #717171 (Neutral Ash)\nTypography: Display=\"Plus Jakarta Sans\", Body=\"Inter\", Mono=\"JetBrains Mono\"\nLayout: 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.\nInteractions: 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').\nMobile: Smooth momentum-scrolling chip rail with active filter count badge and a bottom-anchored facet sheet that stays within thumb reach.\n\nGuardrails:\n- DO: Display a live active-filter badge on the Filters button and a one-tap Clear All reset inside the sheet\n- DO: Update the primary sheet CTA with the exact matching result count before applying\n- DO: Keep the Filters button pinned or always reachable so users never have to scroll to the end of the chip rail\n- DON'T: Do not wrap 10+ filter chips into 4 tall vertical rows that push listings below the fold on mobile\n- DON'T: Do not discard active chip selection when applying secondary facets inside the sheet",
  "sourceCode": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>Habitat — Horizontal Chip Filter Rail &amp; Slide-Up Facet Sheet</title>\n<style>\n  :root {\n    --canvas: #FFFFFF;\n    --surface: #F7F7F7;\n    --ink: #1A1A1A;\n    --accent: #E11D48;\n    --accent-hover: #BE123C;\n    --accent-soft: #FFF1F2;\n    --muted: #717171;\n    --border: #E5E5E5;\n    --radius: 16px;\n    --font: \"Inter\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n  }\n\n  * { box-sizing: border-box; margin: 0; padding: 0; }\n\n  html, body {\n    background: var(--canvas);\n    color: var(--ink);\n    font-family: var(--font);\n    line-height: 1.45;\n    -webkit-font-smoothing: antialiased;\n    overflow-x: clip;\n  }\n\n  /* Sticky Top Header + Chip Rail */\n  .sticky-bar {\n    position: sticky;\n    top: 0;\n    z-index: 20;\n    background: rgba(255, 255, 255, 0.96);\n    backdrop-filter: blur(8px);\n    border-bottom: 1px solid var(--border);\n  }\n\n  .bar-inner {\n    max-width: 1220px;\n    margin: 0 auto;\n    padding: 12px 14px 10px;\n  }\n\n  @media (min-width: 768px) {\n    .bar-inner { padding: 14px 28px 12px; }\n  }\n\n  .brand-row {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    margin-bottom: 12px;\n  }\n\n  .brand-lockup {\n    display: flex;\n    align-items: center;\n    gap: 9px;\n    font-weight: 800;\n    font-size: 1.1rem;\n    letter-spacing: -0.02em;\n    color: var(--accent);\n  }\n\n  .brand-lockup span { color: var(--ink); }\n\n  .match-summary {\n    font-size: 0.82rem;\n    font-weight: 600;\n    color: var(--muted);\n  }\n\n  /* Chip Rail + Pinned Filter Button */\n  .rail-row {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n  }\n\n  .chip-rail {\n    display: flex;\n    align-items: center;\n    gap: 8px;\n    overflow-x: auto;\n    scrollbar-width: none;\n    flex: 1;\n    min-width: 0;\n    padding: 2px 0;\n  }\n\n  .chip-rail::-webkit-scrollbar { display: none; }\n\n  .cat-chip {\n    min-height: 46px;\n    padding: 6px 14px;\n    border-radius: 999px;\n    border: 1.5px solid var(--border);\n    background: var(--canvas);\n    color: var(--muted);\n    font-size: 0.82rem;\n    font-weight: 650;\n    font-family: inherit;\n    cursor: pointer;\n    white-space: nowrap;\n    display: inline-flex;\n    align-items: center;\n    gap: 7px;\n    transition: all 0.16s;\n  }\n\n  .cat-chip:hover {\n    border-color: #BDBDBD;\n    color: var(--ink);\n  }\n\n  .cat-chip.active {\n    background: var(--ink);\n    border-color: var(--ink);\n    color: #FFFFFF;\n  }\n\n  .filters-pill {\n    min-height: 46px;\n    padding: 0 15px;\n    border-radius: 999px;\n    border: 1.5px solid var(--ink);\n    background: var(--canvas);\n    color: var(--ink);\n    font-size: 0.84rem;\n    font-weight: 700;\n    font-family: inherit;\n    cursor: pointer;\n    display: inline-flex;\n    align-items: center;\n    gap: 7px;\n    flex-shrink: 0;\n    position: relative;\n    transition: background 0.15s, color 0.15s;\n  }\n\n  .filters-pill:hover { background: var(--surface); }\n\n  .filter-badge {\n    min-width: 20px;\n    height: 20px;\n    padding: 0 6px;\n    border-radius: 999px;\n    background: var(--accent);\n    color: #FFFFFF;\n    font-size: 0.72rem;\n    font-weight: 800;\n    display: none;\n    place-items: center;\n  }\n\n  .filter-badge.show { display: grid; }\n\n  /* Listings Grid */\n  .directory {\n    max-width: 1220px;\n    margin: 0 auto;\n    padding: 18px 14px 56px;\n  }\n\n  @media (min-width: 768px) {\n    .directory { padding: 26px 28px 64px; }\n  }\n\n  .active-tags {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 8px;\n    margin-bottom: 16px;\n  }\n\n  .active-tags:empty { display: none; }\n\n  .active-tag {\n    min-height: 34px;\n    padding: 0 11px;\n    border-radius: 999px;\n    background: var(--accent-soft);\n    color: var(--accent-hover);\n    border: 1px solid #FECDD3;\n    font-size: 0.78rem;\n    font-weight: 650;\n    display: inline-flex;\n    align-items: center;\n    gap: 6px;\n    cursor: pointer;\n  }\n\n  .stays-grid {\n    display: grid;\n    grid-template-columns: 1fr;\n    gap: 20px;\n  }\n\n  @media (min-width: 640px) {\n    .stays-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }\n  }\n\n  @media (min-width: 980px) {\n    .stays-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }\n  }\n\n  .stay-card {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n  }\n\n  .stay-art {\n    position: relative;\n    aspect-ratio: 4 / 3;\n    border-radius: var(--radius);\n    overflow: hidden;\n    background: var(--surface);\n  }\n\n  .stay-art svg {\n    width: 100%;\n    height: 100%;\n    display: block;\n    transition: transform 0.35s ease;\n  }\n\n  .stay-card:hover .stay-art svg { transform: scale(1.03); }\n\n  .instant-pill {\n    position: absolute;\n    top: 12px;\n    left: 12px;\n    background: rgba(255, 255, 255, 0.94);\n    color: var(--ink);\n    font-size: 0.7rem;\n    font-weight: 750;\n    padding: 4px 9px;\n    border-radius: 999px;\n    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n  }\n\n  .heart-btn {\n    position: absolute;\n    top: 6px;\n    right: 6px;\n    width: 44px;\n    height: 44px;\n    border: none;\n    background: transparent;\n    color: #FFFFFF;\n    cursor: pointer;\n    display: grid;\n    place-items: center;\n    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.32));\n  }\n\n  .heart-btn.saved { color: var(--accent); }\n\n  .stay-row {\n    display: flex;\n    align-items: baseline;\n    justify-content: space-between;\n    gap: 8px;\n  }\n\n  .stay-title {\n    font-size: 0.96rem;\n    font-weight: 700;\n    color: var(--ink);\n  }\n\n  .stay-rating {\n    font-size: 0.84rem;\n    font-weight: 650;\n    display: inline-flex;\n    align-items: center;\n    gap: 3px;\n    flex-shrink: 0;\n  }\n\n  .stay-sub {\n    font-size: 0.83rem;\n    color: var(--muted);\n  }\n\n  .stay-price {\n    font-size: 0.94rem;\n    margin-top: 2px;\n  }\n\n  .stay-price strong { font-weight: 750; }\n\n  .empty-box {\n    grid-column: 1 / -1;\n    text-align: center;\n    padding: 48px 20px;\n    border-radius: var(--radius);\n    background: var(--surface);\n    color: var(--muted);\n  }\n\n  /* Slide-Up Multi-Facet Bottom Sheet */\n  .sheet-backdrop {\n    position: fixed;\n    inset: 0;\n    background: rgba(26, 26, 26, 0.48);\n    backdrop-filter: blur(2px);\n    z-index: 40;\n    opacity: 0;\n    pointer-events: none;\n    transition: opacity 0.24s ease;\n    display: flex;\n    align-items: flex-end;\n    justify-content: center;\n  }\n\n  @media (min-width: 720px) {\n    .sheet-backdrop { align-items: center; padding: 24px; }\n  }\n\n  .sheet-backdrop.open {\n    opacity: 1;\n    pointer-events: auto;\n  }\n\n  .facet-sheet {\n    width: 100%;\n    max-width: 560px;\n    max-height: 88dvh;\n    background: var(--canvas);\n    border-radius: 22px 22px 0 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    transform: translateY(100%);\n    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);\n    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);\n  }\n\n  @media (min-width: 720px) {\n    .facet-sheet {\n      border-radius: 22px;\n      transform: translateY(28px) scale(0.98);\n    }\n  }\n\n  .sheet-backdrop.open .facet-sheet {\n    transform: translateY(0) scale(1);\n  }\n\n  .sheet-head {\n    padding: 12px 16px;\n    border-bottom: 1px solid var(--border);\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n  }\n\n  .sheet-head h2 {\n    font-size: 1rem;\n    font-weight: 750;\n  }\n\n  .icon-close {\n    width: 44px;\n    height: 44px;\n    border: none;\n    border-radius: 50%;\n    background: transparent;\n    color: var(--ink);\n    cursor: pointer;\n    display: grid;\n    place-items: center;\n  }\n\n  .icon-close:hover { background: var(--surface); }\n\n  .sheet-body {\n    padding: 18px 20px;\n    overflow-y: auto;\n    display: flex;\n    flex-direction: column;\n    gap: 22px;\n  }\n\n  .facet-block h3 {\n    font-size: 0.92rem;\n    font-weight: 700;\n    margin-bottom: 10px;\n  }\n\n  .price-readout {\n    display: flex;\n    justify-content: space-between;\n    font-size: 0.85rem;\n    color: var(--muted);\n    margin-bottom: 10px;\n  }\n\n  .price-readout strong { color: var(--ink); font-size: 1rem; }\n\n  .range-slider {\n    width: 100%;\n    accent-color: var(--accent);\n    height: 6px;\n    cursor: pointer;\n  }\n\n  .bed-pills {\n    display: flex;\n    gap: 8px;\n    flex-wrap: wrap;\n  }\n\n  .bed-btn {\n    min-height: 44px;\n    min-width: 56px;\n    padding: 0 14px;\n    border-radius: 999px;\n    border: 1.5px solid var(--border);\n    background: var(--canvas);\n    color: var(--ink);\n    font-size: 0.84rem;\n    font-weight: 650;\n    font-family: inherit;\n    cursor: pointer;\n  }\n\n  .bed-btn.active {\n    background: var(--ink);\n    border-color: var(--ink);\n    color: #FFFFFF;\n  }\n\n  .toggle-row {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    gap: 12px;\n    padding: 12px 14px;\n    border-radius: 14px;\n    background: var(--surface);\n  }\n\n  .toggle-row p { font-size: 0.78rem; color: var(--muted); }\n\n  .switch-btn {\n    width: 52px;\n    height: 32px;\n    border-radius: 999px;\n    border: none;\n    background: #D4D4D4;\n    position: relative;\n    cursor: pointer;\n    flex-shrink: 0;\n    transition: background 0.2s;\n  }\n\n  .switch-btn::after {\n    content: \"\";\n    position: absolute;\n    top: 3px;\n    left: 3px;\n    width: 26px;\n    height: 26px;\n    border-radius: 50%;\n    background: #FFFFFF;\n    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);\n    transition: transform 0.2s;\n  }\n\n  .switch-btn.on { background: var(--accent); }\n  .switch-btn.on::after { transform: translateX(20px); }\n\n  .amenity-grid {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 8px;\n  }\n\n  .amenity-chip {\n    min-height: 44px;\n    padding: 0 14px;\n    border-radius: 11px;\n    border: 1.5px solid var(--border);\n    background: var(--canvas);\n    color: var(--ink);\n    font-size: 0.83rem;\n    font-weight: 600;\n    font-family: inherit;\n    cursor: pointer;\n  }\n\n  .amenity-chip.active {\n    border-color: var(--accent);\n    background: var(--accent-soft);\n    color: var(--accent-hover);\n  }\n\n  .sheet-foot {\n    padding: 12px 20px 16px;\n    border-top: 1px solid var(--border);\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    gap: 12px;\n  }\n\n  .btn-clear {\n    min-height: 44px;\n    padding: 0 12px;\n    border: none;\n    background: transparent;\n    color: var(--ink);\n    font-size: 0.88rem;\n    font-weight: 700;\n    text-decoration: underline;\n    cursor: pointer;\n  }\n\n  .btn-apply {\n    min-height: 46px;\n    padding: 0 22px;\n    border: none;\n    border-radius: 12px;\n    background: var(--accent);\n    color: #FFFFFF;\n    font-size: 0.9rem;\n    font-weight: 700;\n    font-family: inherit;\n    cursor: pointer;\n  }\n\n  .btn-apply:hover { background: var(--accent-hover); }\n</style>\n</head>\n<body>\n<header class=\"sticky-bar\">\n  <div class=\"bar-inner\">\n    <div class=\"brand-row\">\n      <div class=\"brand-lockup\">\n        <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>\n        <span>Habitat</span>\n      </div>\n      <span id=\"matchSummary\" class=\"match-summary\">9 architectural stays</span>\n    </div>\n\n    <div class=\"rail-row\">\n      <nav id=\"chipRail\" class=\"chip-rail\" aria-label=\"Stay categories\"></nav>\n      <button id=\"openFilters\" class=\"filters-pill\" type=\"button\">\n        <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>\n        Filters\n        <span id=\"filterBadge\" class=\"filter-badge\">0</span>\n      </button>\n    </div>\n  </div>\n</header>\n\n<main class=\"directory\">\n  <div id=\"activeTags\" class=\"active-tags\"></div>\n  <section id=\"staysGrid\" class=\"stays-grid\" aria-label=\"Architectural stays\"></section>\n</main>\n\n<!-- Slide-Up Facet Sheet -->\n<div id=\"sheetBackdrop\" class=\"sheet-backdrop\" role=\"dialog\" aria-modal=\"true\" aria-label=\"Filter stays\">\n  <div class=\"facet-sheet\">\n    <div class=\"sheet-head\">\n      <button id=\"closeSheet\" class=\"icon-close\" type=\"button\" aria-label=\"Close filters\">\n        <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>\n      </button>\n      <h2>Filters</h2>\n      <span style=\"width:44px\"></span>\n    </div>\n\n    <div class=\"sheet-body\">\n      <div class=\"facet-block\">\n        <h3>Max nightly price</h3>\n        <div class=\"price-readout\">\n          <span>Up to</span>\n          <strong id=\"priceVal\">$650 / night</strong>\n        </div>\n        <input id=\"priceSlider\" class=\"range-slider\" type=\"range\" min=\"160\" max=\"650\" step=\"10\" value=\"650\" aria-label=\"Maximum nightly price\">\n      </div>\n\n      <div class=\"facet-block\">\n        <h3>Bedrooms</h3>\n        <div id=\"bedPills\" class=\"bed-pills\">\n          <button class=\"bed-btn active\" data-beds=\"0\" type=\"button\">Any</button>\n          <button class=\"bed-btn\" data-beds=\"1\" type=\"button\">1+</button>\n          <button class=\"bed-btn\" data-beds=\"2\" type=\"button\">2+</button>\n          <button class=\"bed-btn\" data-beds=\"3\" type=\"button\">3+</button>\n          <button class=\"bed-btn\" data-beds=\"4\" type=\"button\">4+</button>\n        </div>\n      </div>\n\n      <div class=\"facet-block\">\n        <div class=\"toggle-row\">\n          <div>\n            <strong style=\"font-size:0.9rem\">Instant Book</strong>\n            <p>Confirm immediately without waiting for host approval</p>\n          </div>\n          <button id=\"instantToggle\" class=\"switch-btn\" type=\"button\" role=\"switch\" aria-checked=\"false\" aria-label=\"Instant Book only\"></button>\n        </div>\n      </div>\n\n      <div class=\"facet-block\">\n        <h3>Amenities</h3>\n        <div id=\"amenityGrid\" class=\"amenity-grid\"></div>\n      </div>\n    </div>\n\n    <div class=\"sheet-foot\">\n      <button id=\"clearAllBtn\" class=\"btn-clear\" type=\"button\">Clear all</button>\n      <button id=\"applySheetBtn\" class=\"btn-apply\" type=\"button\">Show 9 stays</button>\n    </div>\n  </div>\n</div>\n\n<script>\n(function () {\n  const CATEGORIES = [\n    { id: \"all\", label: \"All Stays\", icon: `<path d=\"M3 10.5L12 3l9 7.5M5 9.5V20h14V9.5\"/>` },\n    { 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\"/>` },\n    { 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\"/>` },\n    { 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\"/>` },\n    { 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\"/>` },\n    { id: \"nordic\", label: \"Nordic Timber\", icon: `<path d=\"M12 3l7 8h-4l5 7H4l5-7H5l7-8z\"/>` }\n  ];\n\n  const AMENITIES = [\"Pool\", \"Fireplace\", \"Sauna\", \"EV Charger\", \"Workspace\", \"Ocean View\"];\n\n  const STAYS = [\n    { 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\"] },\n    { 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\"] },\n    { 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\"] },\n    { 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\"] },\n    { 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\"] },\n    { 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\"] },\n    { 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\"] },\n    { 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\"] },\n    { 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\"] }\n  ];\n\n  const state = {\n    category: \"all\",\n    maxPrice: 650,\n    minBeds: 0,\n    instantOnly: false,\n    amenities: new Set(),\n    saved: new Set([\"s1\", \"s4\"])\n  };\n\n  const els = {\n    chipRail: document.getElementById(\"chipRail\"),\n    staysGrid: document.getElementById(\"staysGrid\"),\n    matchSummary: document.getElementById(\"matchSummary\"),\n    filterBadge: document.getElementById(\"filterBadge\"),\n    activeTags: document.getElementById(\"activeTags\"),\n    openFilters: document.getElementById(\"openFilters\"),\n    sheetBackdrop: document.getElementById(\"sheetBackdrop\"),\n    closeSheet: document.getElementById(\"closeSheet\"),\n    priceSlider: document.getElementById(\"priceSlider\"),\n    priceVal: document.getElementById(\"priceVal\"),\n    bedPills: document.getElementById(\"bedPills\"),\n    instantToggle: document.getElementById(\"instantToggle\"),\n    amenityGrid: document.getElementById(\"amenityGrid\"),\n    clearAllBtn: document.getElementById(\"clearAllBtn\"),\n    applySheetBtn: document.getElementById(\"applySheetBtn\")\n  };\n\n  function archSvg(stay) {\n    const [bg, mid, dark] = stay.palette;\n    if (stay.cat === \"cabin\" || stay.cat === \"nordic\") {\n      return `<svg viewBox=\"0 0 320 240\" preserveAspectRatio=\"xMidYMid slice\">\n        <rect width=\"320\" height=\"240\" fill=\"${bg}\"/>\n        <circle cx=\"256\" cy=\"54\" r=\"22\" fill=\"#FFFFFF\" opacity=\"0.75\"/>\n        <path d=\"M0 185 Q80 150 160 180 T320 170 L320 240 L0 240 Z\" fill=\"${mid}\" opacity=\"0.35\"/>\n        <polygon points=\"160,56 76,192 244,192\" fill=\"${dark}\"/>\n        <polygon points=\"160,78 102,192 218,192\" fill=\"#FFFBEB\" opacity=\"0.24\"/>\n        <rect x=\"142\" y=\"138\" width=\"36\" height=\"54\" fill=\"#FDE68A\" opacity=\"0.9\"/>\n      </svg>`;\n    }\n    if (stay.cat === \"desert\") {\n      return `<svg viewBox=\"0 0 320 240\" preserveAspectRatio=\"xMidYMid slice\">\n        <rect width=\"320\" height=\"240\" fill=\"${bg}\"/>\n        <circle cx=\"80\" cy=\"64\" r=\"28\" fill=\"${mid}\" opacity=\"0.6\"/>\n        <path d=\"M0 175 L320 162 L320 240 L0 240 Z\" fill=\"${mid}\" opacity=\"0.32\"/>\n        <rect x=\"64\" y=\"112\" width=\"192\" height=\"68\" rx=\"4\" fill=\"${dark}\"/>\n        <rect x=\"44\" y=\"102\" width=\"218\" height=\"14\" rx=\"2\" fill=\"${dark}\"/>\n        <rect x=\"82\" y=\"128\" width=\"66\" height=\"42\" fill=\"#FEF3C7\" opacity=\"0.88\"/>\n        <rect x=\"162\" y=\"128\" width=\"76\" height=\"42\" fill=\"#FEF3C7\" opacity=\"0.72\"/>\n      </svg>`;\n    }\n    return `<svg viewBox=\"0 0 320 240\" preserveAspectRatio=\"xMidYMid slice\">\n      <rect width=\"320\" height=\"240\" fill=\"${bg}\"/>\n      <rect x=\"0\" y=\"170\" width=\"320\" height=\"70\" fill=\"${mid}\" opacity=\"0.35\"/>\n      <rect x=\"52\" y=\"88\" width=\"216\" height=\"90\" rx=\"5\" fill=\"${dark}\"/>\n      <rect x=\"64\" y=\"100\" width=\"90\" height=\"66\" fill=\"#FFFFFF\" opacity=\"0.82\"/>\n      <rect x=\"164\" y=\"100\" width=\"92\" height=\"66\" fill=\"#FEF3C7\" opacity=\"0.85\"/>\n      <line x1=\"109\" y1=\"100\" x2=\"109\" y2=\"166\" stroke=\"${dark}\" stroke-width=\"3\"/>\n      <line x1=\"210\" y1=\"100\" x2=\"210\" y2=\"166\" stroke=\"${dark}\" stroke-width=\"3\"/>\n    </svg>`;\n  }\n\n  function activeFacetCount() {\n    let n = 0;\n    if (state.maxPrice < 650) n++;\n    if (state.minBeds > 0) n++;\n    if (state.instantOnly) n++;\n    n += state.amenities.size;\n    return n;\n  }\n\n  function filteredStays() {\n    return STAYS.filter((s) => {\n      if (state.category !== \"all\" && s.cat !== state.category) return false;\n      if (s.price > state.maxPrice) return false;\n      if (s.beds < state.minBeds) return false;\n      if (state.instantOnly && !s.instant) return false;\n      for (const a of state.amenities) {\n        if (!s.amenities.includes(a)) return false;\n      }\n      return true;\n    });\n  }\n\n  function renderRail() {\n    els.chipRail.innerHTML = CATEGORIES.map((c) => `\n      <button class=\"cat-chip ${state.category === c.id ? \"active\" : \"\"}\" data-cat=\"${c.id}\" type=\"button\">\n        <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>\n        ${c.label}\n      </button>\n    `).join(\"\");\n  }\n\n  function renderSheetControls() {\n    els.priceSlider.value = state.maxPrice;\n    els.priceVal.textContent = `$${state.maxPrice} / night`;\n    els.instantToggle.classList.toggle(\"on\", state.instantOnly);\n    els.instantToggle.setAttribute(\"aria-checked\", String(state.instantOnly));\n\n    els.bedPills.querySelectorAll(\"[data-beds]\").forEach((btn) => {\n      btn.classList.toggle(\"active\", Number(btn.dataset.beds) === state.minBeds);\n    });\n\n    els.amenityGrid.innerHTML = AMENITIES.map((a) => `\n      <button class=\"amenity-chip ${state.amenities.has(a) ? \"active\" : \"\"}\" data-amenity=\"${a}\" type=\"button\">${a}</button>\n    `).join(\"\");\n  }\n\n  function renderActiveTags() {\n    const tags = [];\n    if (state.maxPrice < 650) tags.push({ key: \"price\", label: `Up to $${state.maxPrice}` });\n    if (state.minBeds > 0) tags.push({ key: \"beds\", label: `${state.minBeds}+ bedrooms` });\n    if (state.instantOnly) tags.push({ key: \"instant\", label: \"Instant Book\" });\n    state.amenities.forEach((a) => tags.push({ key: \"am:\" + a, label: a }));\n\n    els.activeTags.innerHTML = tags.map((t) => `\n      <button class=\"active-tag\" data-remove=\"${t.key}\" type=\"button\">${t.label} &times;</button>\n    `).join(\"\");\n  }\n\n  function renderStays() {\n    const list = filteredStays();\n    const count = activeFacetCount();\n    els.filterBadge.textContent = count;\n    els.filterBadge.classList.toggle(\"show\", count > 0);\n    els.matchSummary.textContent = `${list.length} architectural stay${list.length === 1 ? \"\" : \"s\"}`;\n    els.applySheetBtn.textContent = `Show ${list.length} stay${list.length === 1 ? \"\" : \"s\"}`;\n\n    renderActiveTags();\n\n    if (list.length === 0) {\n      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>`;\n      return;\n    }\n\n    els.staysGrid.innerHTML = list.map((s) => {\n      const saved = state.saved.has(s.id);\n      return `\n        <article class=\"stay-card\">\n          <div class=\"stay-art\">\n            ${archSvg(s)}\n            ${s.instant ? `<span class=\"instant-pill\">&#9889; Instant Book</span>` : \"\"}\n            <button class=\"heart-btn ${saved ? \"saved\" : \"\"}\" data-heart=\"${s.id}\" type=\"button\" aria-label=\"Save ${s.title}\">\n              <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>\n            </button>\n          </div>\n          <div>\n            <div class=\"stay-row\">\n              <span class=\"stay-title\">${s.title}</span>\n              <span class=\"stay-rating\">&#9733; ${s.rating.toFixed(2)}</span>\n            </div>\n            <div class=\"stay-sub\">${s.loc} &middot; ${s.beds} bed${s.beds > 1 ? \"s\" : \"\"} &middot; ${s.amenities.slice(0, 2).join(\", \")}</div>\n            <div class=\"stay-price\"><strong>$${s.price}</strong> <span style=\"color:var(--muted)\">night</span></div>\n          </div>\n        </article>\n      `;\n    }).join(\"\");\n  }\n\n  function renderAll() {\n    renderRail();\n    renderSheetControls();\n    renderStays();\n  }\n\n  // Events\n  els.chipRail.addEventListener(\"click\", (e) => {\n    const btn = e.target.closest(\"[data-cat]\");\n    if (!btn) return;\n    state.category = btn.dataset.cat;\n    renderAll();\n  });\n\n  els.openFilters.addEventListener(\"click\", () => els.sheetBackdrop.classList.add(\"open\"));\n  els.closeSheet.addEventListener(\"click\", () => els.sheetBackdrop.classList.remove(\"open\"));\n  els.applySheetBtn.addEventListener(\"click\", () => els.sheetBackdrop.classList.remove(\"open\"));\n  els.sheetBackdrop.addEventListener(\"click\", (e) => {\n    if (e.target === els.sheetBackdrop) els.sheetBackdrop.classList.remove(\"open\");\n  });\n\n  els.priceSlider.addEventListener(\"input\", (e) => {\n    state.maxPrice = Number(e.target.value);\n    els.priceVal.textContent = `$${state.maxPrice} / night`;\n    renderStays();\n  });\n\n  els.bedPills.addEventListener(\"click\", (e) => {\n    const btn = e.target.closest(\"[data-beds]\");\n    if (!btn) return;\n    state.minBeds = Number(btn.dataset.beds);\n    renderSheetControls();\n    renderStays();\n  });\n\n  els.instantToggle.addEventListener(\"click\", () => {\n    state.instantOnly = !state.instantOnly;\n    renderSheetControls();\n    renderStays();\n  });\n\n  els.amenityGrid.addEventListener(\"click\", (e) => {\n    const btn = e.target.closest(\"[data-amenity]\");\n    if (!btn) return;\n    const a = btn.dataset.amenity;\n    if (state.amenities.has(a)) state.amenities.delete(a);\n    else state.amenities.add(a);\n    renderSheetControls();\n    renderStays();\n  });\n\n  els.clearAllBtn.addEventListener(\"click\", () => {\n    state.maxPrice = 650;\n    state.minBeds = 0;\n    state.instantOnly = false;\n    state.amenities.clear();\n    renderAll();\n  });\n\n  els.activeTags.addEventListener(\"click\", (e) => {\n    const btn = e.target.closest(\"[data-remove]\");\n    if (!btn) return;\n    const key = btn.dataset.remove;\n    if (key === \"price\") state.maxPrice = 650;\n    else if (key === \"beds\") state.minBeds = 0;\n    else if (key === \"instant\") state.instantOnly = false;\n    else if (key.startsWith(\"am:\")) state.amenities.delete(key.slice(3));\n    renderAll();\n  });\n\n  els.staysGrid.addEventListener(\"click\", (e) => {\n    const heart = e.target.closest(\"[data-heart]\");\n    if (!heart) return;\n    const id = heart.dataset.heart;\n    if (state.saved.has(id)) state.saved.delete(id);\n    else state.saved.add(id);\n    renderStays();\n  });\n\n  document.addEventListener(\"keydown\", (e) => {\n    if (e.key === \"Escape\") els.sheetBackdrop.classList.remove(\"open\");\n  });\n\n  renderAll();\n})();\n</script>\n</body>\n</html>\n"
}
