/**
 * @file
 * Program Search — Facets 3.x exposed-filter layout.
 *
 * Layout:
 *   Row 1 (form): keyword search bar — full width
 *   Row 2 (form): PEOPLE | TOPICS — equal columns
 *   Row 3 (form): Has Audio / Has Transcript — full-width button bar
 *   Hidden (form): sort_by + sort_order selects (read by programSortHandler.js)
 *   Sort bar (section.search_filter_sort): A-Z dropdown + layout switcher
 */

/* =============================================
   OUTER WRAPPER
   ============================================= */

.keyword--program-search .keyword__search {
  border: none;
}

/* Override main.css absolute label inside input_placeholder — scoped to the
   program-search keyword wrapper (works for both block and inline rendering).
   Excludes the keyword search label which stays absolute for the floating placeholder. */
.keyword--program-search .input_placeholder label {
  position: relative !important;
}
#views-exposed-form-program-search-page-1 > span:first-of-type label {
  position: absolute !important;
  top: 0;
  left: 0;
}

/* =============================================
   EXPOSED FORM — FLEX CONTAINER
   ============================================= */

#views-exposed-form-program-search-page-1 {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
}

/* =============================================
   ROW 1 — KEYWORD SEARCH BAR
   ============================================= */

#views-exposed-form-program-search-page-1 > span:first-of-type {
  flex: 0 0 100%;
  border: solid 1px #ccc;
  position: relative;
  margin-bottom: 20px;
  box-sizing: border-box;
}

#views-exposed-form-program-search-page-1 > span:first-of-type input[type="text"],
#views-exposed-form-program-search-page-1 > span:first-of-type label {
  font-size: 30px;
  padding: 10px;
  width: 100%;
  text-align: left;
  box-sizing: border-box;
}

#views-exposed-form-program-search-page-1 > span:first-of-type input[type="text"] {
  border: none;
  outline: none;
  background: transparent;
  display: block;
  padding-right: 170px;
}

#views-exposed-form-program-search-page-1 > span:first-of-type label {
  pointer-events: none;
  color: #999;
}

/* =============================================
   HIDDEN — sort_by / sort_order selects
   Remain in the form so programSortHandler.js
   can read their values, but are invisible.
   ============================================= */

#views-exposed-form-program-search-page-1 > .program-sort-element {
  display: none !important;
  flex: 0 0 0;
}

/* =============================================
   ROW 2 — PEOPLE + TOPICS ACCORDION PANELS
   flex-basis: 40% gives them real width so that
   Has Audio (flex-basis 100%) wraps to row 3.
   ============================================= */

#views-exposed-form-program-search-page-1 > fieldset.fieldgroup {
  flex: 1 1 40%;
  min-width: 0;
  margin-right: 17px;
  margin-bottom: 0;
  background-color: #000;
  position: relative;
  border: none;
  padding: 0;
  box-sizing: border-box;
}

/* Remove right margin from the last accordion panel (Topics) */
#views-exposed-form-program-search-page-1 > fieldset.fieldgroup:nth-last-of-type(2) {
  margin-right: 0;
}

/* =============================================
   LEGEND — accordion trigger (People / Topics)
   ============================================= */

#views-exposed-form-program-search-page-1 fieldset.fieldgroup > legend {
  display: block;
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
  padding: 16px 20px 14px;
  color: #fff;
  text-transform: uppercase;
  font-size: 16px;
  position: relative;
  background-color: #000;
  user-select: none;
  -webkit-user-select: none;
}

/* Arrow — open */
#views-exposed-form-program-search-page-1 fieldset.fieldgroup > legend .fieldset-legend::after {
  font-family: 'icomoon' !important;
  speak: none;
  font-style: normal;
  font-weight: normal;
  content: "\e90d"; /* icon-arrow-up */
  position: absolute;
  right: 20px;
  top: 18px;
  color: #999;
  font-size: 12px;
}

/* Arrow — closed */
#views-exposed-form-program-search-page-1 fieldset.fieldgroup:not(.open) > legend .fieldset-legend::after {
  content: "\e90c"; /* icon-arrow-down */
}

#views-exposed-form-program-search-page-1 fieldset.fieldgroup > legend:hover .fieldset-legend::after {
  color: #fff;
}

/* =============================================
   DROPDOWN — hidden until .open
   ============================================= */

#views-exposed-form-program-search-page-1 fieldset.fieldgroup > .fieldset-wrapper {
  display: none;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  z-index: 200;
  background-color: #000;
}

#views-exposed-form-program-search-page-1 fieldset.fieldgroup.open > .fieldset-wrapper {
  display: block;
}

/* =============================================
   CHECKBOX LIST — People / Topics
   styledCheckboxes.js PREPENDS span.styled_checkbox
   to each .form-type-checkbox, making it flex item 1.
   We use order to push it right of the label.
   ============================================= */

#views-exposed-form-program-search-page-1 .bef-checkboxes {
  padding: 5px 12px 16px;
  height: 190px;
  overflow-y: auto;
}

#views-exposed-form-program-search-page-1 .bef-checkboxes .form-type-checkbox {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  padding: 0;
}

/* The JS-added styled checkbox span — pushed to the right */
#views-exposed-form-program-search-page-1 .bef-checkboxes .form-type-checkbox span.styled_checkbox {
  order: 2;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin: 3px 0 0 0;
  /* Dark panel appearance — override main.css white background */
  background-color: transparent;
  border-color: #666;
  bottom: 0;
}

#views-exposed-form-program-search-page-1 .bef-checkboxes .form-type-checkbox span.styled_checkbox.checked {
  border-color: #fff;
}

/* The hidden native input — take no layout space */
#views-exposed-form-program-search-page-1 .bef-checkboxes input[type="checkbox"] {
  order: 3;
  flex: 0 0 0;
  width: 0;
  height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

/* Label on the left, wraps naturally */
#views-exposed-form-program-search-page-1 .bef-checkboxes label.option {
  order: 1;
  flex: 1 1 0;
  color: #999;
  font-size: 15px;
  padding-left: 0;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s;
  min-width: 0;
}

#views-exposed-form-program-search-page-1 .bef-checkboxes .form-type-checkbox.is-checked label,
#views-exposed-form-program-search-page-1 .bef-checkboxes .form-type-checkbox:has(input:checked) label,
#views-exposed-form-program-search-page-1 .bef-checkboxes .form-type-checkbox.stylized.ischecked label {
  color: #fff;
}

/* =============================================
   ROW 3 — HAS AUDIO / HAS TRANSCRIPT BUTTONS
   Full-width row; shown as pill buttons, not accordion.
   IMPORTANT: these rules must come AFTER the general
   fieldgroup / legend rules above so they override.
   ============================================= */

#views-exposed-form-program-search-page-1 > fieldset[data-drupal-selector="edit-field-program-includes"] {
  flex: 0 0 100%;
  margin-right: 0;
  margin-top: 12px;
  background: transparent;
  position: static;
}

/* Override the general legend rule — hide it for Has Audio */
#views-exposed-form-program-search-page-1 fieldset.fieldgroup[data-drupal-selector="edit-field-program-includes"] > legend {
  display: none !important;
}

/* Override the general dropdown rule — always show */
#views-exposed-form-program-search-page-1 fieldset.fieldgroup[data-drupal-selector="edit-field-program-includes"] > .fieldset-wrapper {
  display: block !important;
  position: static;
  background: transparent;
  padding: 0;
}

/* Horizontal pill button row */
#views-exposed-form-program-search-page-1 fieldset[data-drupal-selector="edit-field-program-includes"] .bef-checkboxes {
  display: flex;
  flex-direction: row;
  gap: 8px;
  height: auto;
  padding: 0;
  overflow: visible;
  align-items: stretch;
}

/* Each toggle = a button cell */
#views-exposed-form-program-search-page-1 fieldset[data-drupal-selector="edit-field-program-includes"] .bef-checkboxes .form-type-checkbox {
  position: relative;
  padding: 0;
  flex: 0 0 auto;
  display: block;
  gap: 0;
  align-items: initial;
}

/* The styled_checkbox span is hidden inside the button — the label IS the button */
#views-exposed-form-program-search-page-1 fieldset[data-drupal-selector="edit-field-program-includes"] .bef-checkboxes span.styled_checkbox {
  display: none;
}

/* The real checkbox — covers the whole button invisibly */
#views-exposed-form-program-search-page-1 fieldset[data-drupal-selector="edit-field-program-includes"] .bef-checkboxes input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
  z-index: 1;
  flex: initial;
  order: initial;
  overflow: visible;
}

/* Label styled as a pill button */
#views-exposed-form-program-search-page-1 fieldset[data-drupal-selector="edit-field-program-includes"] .bef-checkboxes label.option {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  background: #000;
  color: #e1dfdf;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  line-height: 1.2;
  border: 1px solid #444;
  white-space: nowrap;
  order: initial;
  flex: initial;
  min-width: 0;
  margin-left: 0;
}

/* Active state — full inversion */
#views-exposed-form-program-search-page-1 fieldset[data-drupal-selector="edit-field-program-includes"] .bef-checkboxes .form-type-checkbox.is-checked label,
#views-exposed-form-program-search-page-1 fieldset[data-drupal-selector="edit-field-program-includes"] .bef-checkboxes .form-type-checkbox:has(input:checked) label {
  color: #000;
  background: #fff;
  border: 2px solid #000;
}

#views-exposed-form-program-search-page-1 fieldset[data-drupal-selector="edit-field-program-includes"] .bef-checkboxes label.option:hover {
  color: #fff;
}

/* =============================================
   SORT BAR
   ============================================= */

.search_filter_sort--program-search {
  padding: 10px 0 6px;
  margin-top: 12px;
}

.search_filter_sort--program-search .width_holder {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search_filter_sort--program-search .col-4.search_layout_pref {
  flex: 0 0 auto;
  text-align: right;
  margin-top: 0;
}

/* =============================================
   ACTIVE FILTER CHIPS — views_filters_summary
   Rendered in the view header below the result count.
   ============================================= */

/* Matches the legacy .applied_filters chip styling from main.css. */
.view-id-program_search .views-filters-summary {
  clear: both;
  margin-top: 10px;
  float: left;
  width: 100%;
}

.view-id-program_search .views-filters-summary a.remove-filter {
  background-color: #efefef;
  padding: 6px 24px 6px 8px;
  font-size: 14px;
  border-radius: 3px;
  color: #000;
  cursor: pointer;
  display: inline-block;
  margin-top: 8px;
  margin-right: 4px;
  transition: background-color .2s, color .2s;
  position: relative;
  text-decoration: none;
}

.view-id-program_search .views-filters-summary a.remove-filter:hover {
  background-color: #888;
  color: #fff;
}

/* Neutralize the module CSS on the inner label span (red border etc.) */
.view-id-program_search .views-filters-summary a.remove-filter .value {
  display: inline;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: inherit;
  font-weight: normal;
}

.view-id-program_search .views-filters-summary a.remove-filter .remove-icon {
  font-size: 10px;
  color: #666;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  line-height: 1;
  transition: color .2s;
}

.view-id-program_search .views-filters-summary a.remove-filter:hover .remove-icon {
  color: #fff;
}

.view-id-program_search .views-filters-summary .prefix {
  display: none;
}

/* =============================================
   RESPONSIVE — 800px
   ============================================= */

@media screen and (max-width: 800px) {
  #views-exposed-form-program-search-page-1 > fieldset.fieldgroup {
    flex: 0 0 100%;
    margin-right: 0;
    margin-bottom: 4px;
  }

  #views-exposed-form-program-search-page-1 > fieldset[data-drupal-selector="edit-field-program-includes"] {
    margin-top: 4px;
  }

  #views-exposed-form-program-search-page-1 > span:first-of-type input[type="text"],
  #views-exposed-form-program-search-page-1 > span:first-of-type label {
    font-size: 22px;
  }

  #views-exposed-form-program-search-page-1 .bef-checkboxes label.option {
    font-size: 13px;
  }

  #views-exposed-form-program-search-page-1 fieldset.fieldgroup > .fieldset-wrapper {
    position: static;
  }

  .scrollbar-outer {
    height: 150px;
  }
}
