/*!
 * Copyright (c) 2025 Kenneth Raymond
 * All rights reserved.
 *
 * Part of the expertsincmt WordPress theme.
 * Do not copy, modify, or redistribute without permission.
 *
 * ------------------------------------------------------------
 * GENES DB — FILTER UI
 * ------------------------------------------------------------
 * Styles for:
 *   • Genes Database filter bar
 *   • Sort toolbar
 *   • Responsive layout
 *
 * Scope:
 *   .genesdb-filter-wrap
 */

/* =========================================================
   Genes DB — FILTER UI
   Scope: .genesdb-filter-wrap only
   ========================================================= */

.genesdb-filter-wrap {
  position: relative;
  left: 50%;
  z-index: 2;
  width: 100vw;
  max-width: 1180px;
  transform: translateX(-50%);
  margin-top: -32px;
  padding-inline: 12px;
}

.genesdb-filter-wrap .genes-filter {
  margin: 0 0 28px;
}

.genesdb-filter-wrap .genes-filter__bar {
  max-width: 1180px;
  margin-inline: auto;
  padding: 1.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 28px 0 28px 28px;
  box-shadow: 0 10px 30px rgb(14 42 84 / 5%);
}

/* Previous 2×2 grid layout preserved for reference.
.genesdb-filter-wrap .genes-filter__row {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: end;
}
*/

.genesdb-filter-wrap .genes-filter__row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Force the taxonomy selects onto their own line, regardless of
   how much horizontal space the search field + actions leave behind. */
.genesdb-filter-wrap .genes-filter__row::after {
  content: "";
  flex-basis: 100%;
  order: 1;
  height: 0;
}

.genesdb-filter-wrap .genes-filter__field:not(.genes-filter__field--search) {
  order: 2;
}

.genesdb-filter-wrap .genes-filter__field {
  flex: 1 1 0;
  min-width: 150px;
  position: relative;
}

.genesdb-filter-wrap .genes-filter__field--search {
  flex: 1 1 320px;
  min-width: 320px;
}

.genesdb-filter-wrap .genes-filter__hr {
  display: none;
}

/* Previous desktop 2×2 select layout preserved for reference.
@media (min-width: 768px) {
  .genesdb-filter-wrap .genes-filter__hr {
    display: none;
  }

  .genesdb-filter-wrap .genes-filter__field:nth-of-type(1) {
    grid-column: 1 / span 6;
  }
  .genesdb-filter-wrap .genes-filter__field:nth-of-type(2) {
    grid-column: 7 / span 6;
  }
  .genesdb-filter-wrap .genes-filter__field:nth-of-type(3) {
    grid-column: 1 / span 6;
  }
  .genesdb-filter-wrap .genes-filter__field:nth-of-type(4) {
    grid-column: 7 / span 6;
  }
  .genesdb-filter-wrap .genes-filter__field--search {
    grid-column: 1 / -1;
  }
}
*/

/* Labels (visually hidden, still accessible) */
.genesdb-filter-wrap .genes-filter__label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Inputs */
.genesdb-filter-wrap .genes-filter select,
.genesdb-filter-wrap .genes-filter input[type="search"] {
  width: 100%;
  height: 48px;
  min-height: 48px;
  padding: 10px 38px 10px 14px;
  border: 1px solid #d6d9de;
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
  outline: none;
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238E97A3' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
}

.genesdb-filter-wrap .genes-filter input[type="search"] {
  padding-right: 14px;
  background-image: none;
}

.genesdb-filter-wrap .genes-filter input[type="search"]::placeholder {
  color: #8e97a3;
}

.genesdb-filter-wrap .genes-filter select:focus,
.genesdb-filter-wrap .genes-filter input[type="search"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

/* ------------------------------------------------------------
   Gene group flags (checkbox facets)
   Mitochondrial involvement / ARS genes
   ------------------------------------------------------------ */
.genesdb-filter-wrap .genes-filter__field--flags {
  flex: 1 1 220px;
  min-width: 220px;
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
}

.genesdb-filter-wrap .genes-filter__check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 1.25;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.genesdb-filter-wrap .genes-filter__checkbox {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  border-radius: 5px;
  accent-color: var(--primary);
  cursor: pointer;
}

.genesdb-filter-wrap .genes-filter__check.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.genesdb-filter-wrap .genes-filter__check.is-disabled .genes-filter__checkbox {
  cursor: not-allowed;
}

.genesdb-filter-wrap .genes-filter__checkbox:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

/* Variant mechanism flags (LoF / GoF): the second/last flag fieldset in
   the filter, laid side by side on its own full-width line. Scoped by
   :last-of-type so no extra markup class is needed. */
.genesdb-filter-wrap fieldset.genes-filter__field--flags:last-of-type {
  flex-basis: 100%;
  min-width: 100%;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 6px 22px;
}

@media (max-width: 767px) {
  .genesdb-filter-wrap .genes-filter__field--flags {
    flex: 1 1 100%;
    min-width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px 18px;
  }
}

/* Actions row */
.genesdb-filter-wrap .genes-filter__actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: flex-end;
  margin-top: 0;
}

/* Apply Button */
.genesdb-filter-wrap .genes-filter__btn {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  border-radius: 16px;
  padding: 0 1.5em;
  line-height: 1.2;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  transition: background-color 0.15s ease, color 0.15s ease,
    border-color 0.15s ease, box-shadow 0.25s ease;
}

.genesdb-filter-wrap .genes-filter__btn:hover,
.genesdb-filter-wrap .genes-filter__btn:focus {
  background-color: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Reset Button */
.genesdb-filter-wrap .genes-filter__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0 1.5em;
  line-height: 1.2;
  min-block-size: 48px;
  border-radius: 16px;
  border: 1.5px solid #f1bbbb;
  background: #fff5f5;
  color: #8b1b1b;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease,
    border-color 0.15s ease;
}

.genesdb-filter-wrap .genes-filter__link:hover,
.genesdb-filter-wrap .genes-filter__link:focus {
  background-color: #fbecec;
  border-color: #d33;
}

/* Anchor offset */
#genes-filter {
  scroll-margin-top: 90px;
}

/* NOTE: A `.genesdb-filter-wrap .genes-sort*` block was removed here as
   dead CSS. The sort toolbar (`.genes-sort--results`) is emitted by the
   separate [genes_loop] shortcode OUTSIDE `.genesdb-filter-wrap`, so
   these scoped rules never matched; the toolbar is styled by the
   unscoped `.genes-sort--results` rules in main.css. */

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 900px) {
  .genesdb-filter-wrap .genes-filter__row {
    flex-wrap: wrap;
  }

  .genesdb-filter-wrap .genes-filter__field {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 0;
  }

  .genesdb-filter-wrap .genes-filter__field--search {
    flex: 1 1 100%;
    min-width: 0;
  }

  .genesdb-filter-wrap .genes-filter__actions {
    flex: 1 1 100%;
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .genesdb-filter-wrap {
    margin-top: -20px;
    padding-inline: 0;
  }

  .genesdb-filter-wrap .genes-filter__bar {
    padding: 1rem;
    border-radius: 22px;
  }

  .genesdb-filter-wrap .genes-filter__row {
    display: grid;
    gap: 14px;
    grid-template-columns: 1fr;
  }

  .genesdb-filter-wrap .genes-filter__field,
  .genesdb-filter-wrap .genes-filter__field--search,
  .genesdb-filter-wrap .genes-filter__actions {
    width: 100%;
    min-width: 0;
  }

  .genesdb-filter-wrap .genes-filter__actions {
    justify-content: center;
  }

  .genesdb-filter-wrap .genes-filter select,
  .genesdb-filter-wrap .genes-filter input[type="search"] {
    height: 44px;
    min-height: 44px;
    font-size: 14px;
  }

  .genesdb-filter-wrap .genes-filter__btn,
  .genesdb-filter-wrap .genes-filter__link {
    padding: 0 1.5em !important;
    min-height: 44px !important;
    line-height: 1.2 !important;
  }

  .genesdb-filter-wrap .genes-sort {
    justify-content: center;
    gap: 8px;
  }

  .genesdb-filter-wrap .genes-sort__label {
    font-size: 0.85rem;
  }

  .genesdb-filter-wrap .genes-sort__select {
    height: 42px;
    font-size: 14px;
  }

  .genesdb-filter-wrap .genes-sort__clear {
    min-block-size: 36px;
    font-size: 13px;
  }
}
