/* ============================================================
   Category Listing Filters  (flow: Category Listing with modal)
   Figma: COAST / Homepage - Filter (desktop 470:9094, mobile 493:16998)

   Authored MOBILE-FIRST: the base rules ARE the bottom-sheet state.
   The centred desktop dialog + two-column rows apply from 768px up.
   All values are read from the Figma frames via MCP get_design_context;
   no eyeballed numbers. Colours/sizes/radii live in the .cf token block.
   ============================================================ */

.cf {
  /* ---- Colour tokens ---- */
  --cf-white: #ffffff;
  --cf-accent: #bf6aad;          /* Show button bg, Clear-all text */
  --cf-accent-strong: #92297c;   /* selected pill/ceilidh border + text, open control border */
  --cf-accent-soft: #eac7e2;     /* Clear-all border */
  --cf-ink: #000000;
  --cf-ink-2: #2d3036;           /* section labels, some control text */
  --cf-ink-muted: #4b4b4b;       /* unselected pill text */
  --cf-placeholder: #6c757d;     /* search placeholder */
  --cf-border: #ced4da;          /* control + divider borders */
  --cf-scrim: rgba(0, 0, 0, 0.6);

  /* ---- Radii ---- */
  --cf-r-modal: 30px;
  --cf-r-sheet: 24px;
  --cf-r-input: 16px;
  --cf-r-pill: 12px;
  --cf-r-show: 20px;
  --cf-r-check: 6px;

  /* ---- Shadows ---- */
  --cf-shadow-panel: 0 4px 10px rgba(0, 0, 0, 0.2);
  --cf-shadow-modal: 0 20px 40px rgba(11, 10, 114, 0.2);

  /* ---- Type ---- */
  --cf-fs-label: 14px;
  --cf-fs-control: 16px;

  /* ---- Metrics ---- */
  --cf-h-control: 56px;

  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-family: Manrope, "Nunito Sans", ui-sans-serif, system-ui, sans-serif;
}

.cf[hidden] {
  display: none;
}

.cf__scrim {
  position: absolute;
  inset: 0;
  background: var(--cf-scrim);
  animation: cfScrimIn 0.2s ease both;
}

/* ---- Shell: mobile bottom sheet ---- */
.cf__shell {
  position: relative;
  width: 100%;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
  background: var(--cf-white);
  border-radius: var(--cf-r-sheet) var(--cf-r-sheet) 0 0;
  box-shadow: 0 -18px 50px -12px rgba(27, 27, 28, 0.4);
  animation: cfSheetIn 0.26s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

/* Scroll on an inner wrapper so rounded corners clip the scrollbar. */
.cf__scroll {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  box-sizing: border-box;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---- Header ---- */
.cf__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cf__title {
  margin: 0;
  font-family: Inter, Manrope, ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
  font-size: 20px;
  line-height: 1;
  color: var(--cf-ink);
}

.cf__close {
  width: 44px;
  height: 44px;
  margin: -10px -10px -10px 0; /* keep 44px hit area without shifting the visual X */
  border: none;
  background: none;
  color: #181819;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 10px;
}

.cf__close svg {
  width: 24px;
  height: 24px;
}

.cf__close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(191, 106, 173, 0.5);
}

/* ---- Field group + labels ---- */
.cf__group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cf__label {
  margin: 0;
  padding: 0;
  border: 0;
  font-weight: 500;
  font-size: var(--cf-fs-label);
  line-height: normal;
  color: var(--cf-ink);
}

.cf__label--muted {
  color: var(--cf-ink-2);
}

/* ---- Search field (Band name) ---- */
.cf__search {
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  height: var(--cf-h-control);
  padding: 0 16px;
  background: var(--cf-white);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-r-input);
}

.cf__search:focus-within {
  border-color: var(--cf-accent-strong);
}

.cf__search-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.cf__search-input {
  flex: 1 1 auto;
  align-self: stretch; /* fill the 56px field so the input hit area is >=44px */
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: var(--cf-fs-control); /* 16px: no iOS focus zoom */
  color: var(--cf-ink);
  -webkit-appearance: none;
  appearance: none;
}

.cf__search-input::placeholder {
  color: var(--cf-placeholder);
  opacity: 1;
}

.cf__search-clear {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin-right: -10px; /* keep 44px hit area without stretching the field */
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--cf-placeholder);
  cursor: pointer;
  padding: 0;
}

.cf__search.is-filled .cf__search-clear {
  display: flex;
}

.cf__search-clear svg {
  width: 18px;
  height: 18px;
}

/* ---- Pill groups (Band size, Vocals) ---- */
.cf__pills {
  display: flex;
  gap: 12px;
}

.cf__pill {
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  padding: 12px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cf-white);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-r-pill);
  font-family: inherit;
  font-weight: 500;
  font-size: var(--cf-fs-control);
  line-height: 24px;
  color: var(--cf-ink-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.cf__pill[aria-pressed="true"] {
  border-color: var(--cf-accent-strong);
  color: var(--cf-accent-strong);
}

/* ---- Select-style triggers (Instrumentation, Location, DJ, Daytime) ---- */
.cf__row {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Mobile stacks Daytime Options BEFORE DJ Set (mobile frame order); desktop
   restores DJ | Daytime side by side. Single DOM order, CSS handles the swap. */
.cf__row--swap .cf__col--daytime {
  order: -1;
}

.cf__select {
  position: relative;
}

.cf__select-trigger {
  width: 100%;
  box-sizing: border-box;
  height: var(--cf-h-control);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--cf-white);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-r-input);
  font-family: inherit;
  font-size: var(--cf-fs-control);
  color: var(--cf-ink);
  cursor: pointer;
  text-align: left;
}

.cf__select.is-open .cf__select-trigger {
  border-color: var(--cf-accent-strong);
}

.cf__select-trigger:focus-visible {
  outline: none;
  border-color: var(--cf-accent-strong);
  box-shadow: 0 0 0 3px rgba(146, 41, 124, 0.25);
}

.cf__select-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
}

.cf__select-divider {
  width: 1px;
  height: 26px;
  flex: 0 0 auto;
  background: var(--cf-border);
}

.cf__select-value {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cf__select-value.is-placeholder {
  color: var(--cf-ink);
}

/* Down caret (generic affordance; the frame arrow is a plain chevron) */
.cf__caret {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border-right: 1.6px solid var(--cf-ink-2);
  border-bottom: 1.6px solid var(--cf-ink-2);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.18s ease;
}

.cf__select.is-open .cf__caret {
  transform: rotate(-135deg) translate(-2px, -2px);
}

/* ---- Dropdown panel (option list / checkbox list) ---- */
.cf__panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 5;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--cf-white);
  border-radius: var(--cf-r-input);
  box-shadow: var(--cf-shadow-panel);
}

.cf__panel[hidden] {
  display: none;
}

.cf__opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  padding: 16px;
  margin: 0;
  border: none;
  background: none;
  font-family: inherit;
  font-weight: 500;
  font-size: var(--cf-fs-control);
  line-height: 24px;
  color: var(--cf-ink);
  text-align: left;
  cursor: pointer;
}

.cf__opt:hover,
.cf__opt.is-active {
  background: #faf3f8;
}

.cf__opt[aria-selected="true"] {
  color: var(--cf-accent-strong);
}

/* Checkbox (multi-select instrumentation) rendered from a real input */
.cf__check {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin: 0;
  border: 1.5px solid var(--cf-border);
  border-radius: var(--cf-r-check);
  background: var(--cf-white);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  display: inline-block;
  position: relative;
}

.cf__check:checked {
  background: var(--cf-accent);
  border-color: var(--cf-accent);
}

.cf__check:checked::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 4px;
  width: 6px;
  height: 11px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.cf__check:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(146, 41, 124, 0.3);
}

/* ---- Ceilidh icon cards ---- */
.cf__ceilidh {
  display: flex;
  gap: 12px;
}

.cf__ceilidh-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--cf-ink-muted);
  font-family: inherit;
}

.cf__ceilidh-card {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-r-pill);
  transition: border-color 0.15s ease;
}

/* State-tinted icon: the exported SVG drives the shape via mask; the card
   colour (grey default / pink selected) drives the fill. */
.cf__ceilidh-icon {
  width: 48px;
  height: 48px;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.cf__ceilidh-icon--prerecorded {
  -webkit-mask-image: url("/assets/figma/icon-pre-recorded-tracks.svg");
  mask-image: url("/assets/figma/icon-pre-recorded-tracks.svg");
}

.cf__ceilidh-icon--fullylive {
  -webkit-mask-image: url("/assets/figma/icon-fully-live.svg");
  mask-image: url("/assets/figma/icon-fully-live.svg");
}

.cf__ceilidh-icon--mixture {
  -webkit-mask-image: url("/assets/figma/icon-mixture-tracks-live.svg");
  mask-image: url("/assets/figma/icon-mixture-tracks-live.svg");
}

.cf__ceilidh-label {
  font-weight: 500;
  font-size: var(--cf-fs-control);
  line-height: 20px;
  text-align: center;
  color: inherit;
}

.cf__ceilidh-item[aria-pressed="true"] {
  color: var(--cf-accent-strong);
}

.cf__ceilidh-item[aria-pressed="true"] .cf__ceilidh-card {
  border-color: var(--cf-accent-strong);
}

/* ---- Footer actions ---- */
.cf__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cf__clear {
  box-sizing: border-box;
  height: var(--cf-h-control);
  padding: 12px 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cf-white);
  border: 1px solid var(--cf-accent-soft);
  border-radius: var(--cf-r-input);
  font-family: inherit;
  font-weight: 700;
  font-size: var(--cf-fs-control);
  line-height: 24px;
  color: var(--cf-accent);
  cursor: pointer;
}

.cf__apply {
  box-sizing: border-box;
  height: var(--cf-h-control);
  padding: 8px 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cf-accent);
  border: none;
  border-radius: var(--cf-r-show);
  font-family: Inter, Manrope, ui-sans-serif, system-ui, sans-serif;
  font-weight: 600;
  font-size: var(--cf-fs-control);
  line-height: 20px;
  color: var(--cf-white);
  cursor: pointer;
}

/* ============================================================
   Filters trigger on the listing page (badge + active dot)
   ============================================================ */
.cf-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 16px 20px;
  border: 1px solid var(--cf-border, #c3c3c3);
  border-radius: 16px;
  background: var(--cf-white, #fff);
  font-weight: 500;
  font-size: 16px;
  color: #000;
  cursor: pointer;
}

.cf-trigger__icon {
  width: 24px;
  height: 24px;
}

.cf-trigger__dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #bf6aad;
  display: none;
}

.cf-trigger.is-active .cf-trigger__dot {
  display: block;
}

/* ============================================================
   Active filter chips above the listing grid
   ============================================================ */
.cf-showing {
  --cf-ink-muted: #4b4b4b;

  margin-top: 4px;
  font-family: Manrope, "Nunito Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  color: var(--cf-ink-muted);
}

.cf-chips {
  --cf-accent: #bf6aad;
  --cf-accent-strong: #92297c;
  --cf-accent-soft: #eac7e2;
  --cf-white: #ffffff;
  --cf-ink: #000000;
  --cf-r-pill: 12px;

  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.cf-chips[hidden] {
  display: none;
}

.cf-chip {
  box-sizing: border-box;
  min-height: 44px;
  padding: 8px 12px 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--cf-white);
  border: 1px solid var(--cf-accent-soft);
  border-radius: var(--cf-r-pill);
  font-family: Manrope, "Nunito Sans", ui-sans-serif, system-ui, sans-serif;
  font-weight: 500;
  font-size: 14px;
  line-height: 20px;
  color: var(--cf-accent-strong);
  cursor: pointer;
}

.cf-chip__label {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  max-width: 16rem;
  overflow: hidden;
  white-space: nowrap;
}

.cf-chip__group {
  flex: 0 0 auto;
  margin-right: 0.25em;
  font-weight: 500;
  font-size: inherit;
  line-height: inherit;
}

.cf-chip__value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cf-chip svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.cf-chip--clear {
  border-color: transparent;
  background: transparent;
  color: var(--cf-accent);
  font-weight: 700;
  padding-left: 8px;
  padding-right: 8px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cf-chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(146, 41, 124, 0.3);
}

.cf-chip:active {
  border-color: var(--cf-accent-strong);
}

/* Subtitle read-more expander on the listing header */
.cf-subtitle {
  --cf-subtitle-prose-gap: 0.75em;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.cf-subtitle__text {
  margin: 0;
  min-width: 0;
  flex: 1 1 auto;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* RTE often wraps copy in block tags; flatten them so line-clamp
   measures two lines of text rather than two child boxes. */
.cf-subtitle:not(.is-expanded) .cf-subtitle__text :is(p, h1, h2, h3, h4, h5, h6, ul, ol, li, blockquote) {
  display: inline;
}

.cf-subtitle:not(.is-expanded) .cf-subtitle__text > * + *::before {
  content: " ";
}

.cf-subtitle.is-expanded .cf-subtitle__text {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

.cf-subtitle.is-expanded .cf-subtitle__text > * + * {
  margin-top: var(--cf-subtitle-prose-gap);
}

.cf-subtitle.is-expanded .cf-subtitle__text p {
  /*margin: 0;*/
}

.cf-subtitle.is-expanded .cf-subtitle__text a {
  color: inherit;
  text-decoration: underline;
}

.cf-subtitle.is-expanded .cf-subtitle__text ul,
.cf-subtitle.is-expanded .cf-subtitle__text ol {
  margin: 0;
  padding-inline-start: 1.25em;
}

.cf-subtitle.is-expanded .cf-subtitle__text strong,
.cf-subtitle.is-expanded .cf-subtitle__text b {
  font-weight: 600;
}

.cf-subtitle__toggle {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin: -10px 0; /* 44px hit area, 24px visual glyph */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--c-ink-2);
  cursor: pointer;
  padding: 0;
}
.cf-subtitle__text li {
     list-style-type: disc;
}
.cf-subtitle__toggle[hidden] {
    display: none;
}

.cf-subtitle__toggle svg {
  width: 24px;
  height: 24px;
  transition: transform 0.18s ease;
}

.cf-subtitle.is-expanded .cf-subtitle__toggle svg {
  transform: rotate(180deg);
}

/* Hide non-matching cards during client-side filtering. */
.cf-card[hidden] {
  display: none;
}

/* Filtered-empty message — sits in the grid area when 0 cards match. */
.cf-empty {
  --cf-empty-pad-y: var(--c-callback-pad-y, 40px);
  --cf-empty-gap: var(--c-gap-head, 20px);
  --cf-empty-max: 22rem;

  grid-column: 1 / -1;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--cf-empty-gap);
  padding-block: var(--cf-empty-pad-y);
  max-width: var(--cf-empty-max);
  margin-inline: auto;
}

.cf-empty[hidden] {
  display: none;
}

.cf-empty__heading {
  margin: 0;
  color: var(--c-ink, var(--cf-ink, #181819));
}

.cf-empty__text {
  margin: 0;
  font-family: Manrope, "Nunito Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: var(--cf-fs-control, 16px);
  line-height: var(--c-field-lh, 24px);
  font-weight: 400;
  color: var(--c-ink-2, var(--cf-ink-muted, #44474d));
}

/* URL-restore: hide the listing until filters are applied so Back/share
   don't flash the unfiltered grid. Removed by category-filter.js. */
html.cf-await-filters [data-cf-grid],
html.cf-await-filters [data-cf-showing],
html.cf-await-filters [data-cf-chips],
html.cf-await-filters [data-cf-trigger-count],
html.cf-await-filters [data-cf-empty] {
  visibility: hidden;
}

/* ============================================================
   Desktop: centred dialog + two-column rows (>=768px)
   ============================================================ */
@media (min-width: 768px) {
  .cf {
    align-items: center;
    padding: 24px;
  }

  .cf__shell {
    width: min(764px, 100%);
    max-height: 90dvh;
    border-radius: var(--cf-r-modal);
    box-shadow: var(--cf-shadow-modal);
    animation: cfModalIn 0.2s ease both;
  }

  .cf__scroll {
    padding: 24px;
    gap: 30px;
  }

  .cf__title {
    font-weight: 500;
    font-size: 16px;
  }

  /* Instrumentation | Location  and  DJ Set | Daytime Options */
  .cf__row {
    flex-direction: row;
  }

  .cf__row > * {
    flex: 1 1 0;
    min-width: 0;
  }

  .cf__row--swap .cf__col--daytime {
    order: 0;
  }

  /* Ceilidh cards are fixed-ish and left-aligned on desktop */
  .cf__ceilidh {
    gap: 20px;
    justify-content: flex-start;
  }

  .cf__ceilidh-item {
    flex: 0 0 148px;
  }

  .cf__ceilidh-label {
    line-height: 24px;
  }
}

/* Hover affordances only where a real pointer exists. */
@media (hover: hover) and (pointer: fine) {
  .cf__pill:hover {
    border-color: var(--cf-accent-strong);
  }

  .cf__ceilidh-item:hover .cf__ceilidh-card {
    border-color: var(--cf-accent-strong);
  }

  .cf__clear:hover {
    background: #faf3f8;
  }

  .cf__apply:hover {
    filter: brightness(1.03);
  }

  .cf-trigger:hover {
    background: #fafbff;
  }

  .cf-chip:hover {
    border-color: var(--cf-accent-strong);
    background: #faf3f8;
  }

  .cf-chip--clear:hover {
    border-color: transparent;
    background: transparent;
    color: var(--cf-accent-strong);
  }
}

/* Touch feedback */
.cf__pill:active,
.cf__ceilidh-item:active .cf__ceilidh-card {
  border-color: var(--cf-accent-strong);
}

@media (prefers-reduced-motion: reduce) {
  .cf__scrim,
  .cf__shell {
    animation: none;
  }

  .cf__caret,
  .cf-subtitle__toggle svg {
    transition: none;
  }
}

@keyframes cfScrimIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes cfSheetIn {
  from { transform: translateY(100%); }
  to { transform: none; }
}

@keyframes cfModalIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
