.res-filters,
.res-filters * { box-sizing: border-box; }

.res-filters {
  position: relative;
  max-width: var(--res-max, 1600px);
  margin: 0 auto;
  padding: 0 var(--res-gutter, 32px);
}

/* Hide the originals — checkboxes drive them */
.res-filters__source { display: none; }
.res-filters .form-actions { display: none; }

[data-res-filters] select[multiple],
[data-res-filters] select[name="sort_by"],
[data-res-filters] select[name="sort_order"],
[data-res-filters] .form-actions {
  display: none;
}

.res-filters__toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #0B3B4C;
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 8px 18px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.res-filters__toggle::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  flex: none;
  background-color: currentColor;
  -webkit-mask: url("../images/filter.svg") no-repeat center / contain;
  mask: url("../images/filter.svg") no-repeat center / contain;
}

.res-filters__sort {
  position: absolute;
  top: 0;
  right: var(--res-gutter, 32px);
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
}

.res-filters__panel {
  flex: 0 0 264px;
  align-self: flex-start;
  padding: 20px;
  background: #003346;          /* audit vs Figma */
  border-radius: 12px;
  color: #fff;
  font-family: 'Roboto', sans-serif;
}

.res-filters__panel-head,
.res-filters__group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.res-filters__panel-title { font-size: 20px; font-weight: 600; }
.res-filters__group-title { font-size: 14px; font-weight: 600; }

.res-filters__clear {
  background: none;
  border: 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

.res-filters__group {
  padding: 16px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
.res-filters__group:last-child { border-bottom: 0; }

.res-filters__options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.res-filters__option {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  cursor: pointer;
}
.res-filters__option input { accent-color: #00AEEF; }

/* Sort — custom dropdown */
.res-filters__sort {
  position: absolute;
  top: 0;
  right: var(--res-gutter, 32px);
  font-family: 'Roboto', sans-serif;
}

.res-filters__sort-btn {
  position: relative;
  z-index: 21;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 0;
  padding: 8px 4px;
  color: #fff;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.res-filters__sort-btn::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.2s ease;
}

.res-filters__sort.is-open .res-filters__sort-btn::after {
  transform: translateY(2px) rotate(-135deg);
}

.res-filters__sort-menu {
  position: absolute;
  top: -8px;
  right: -12px;
  z-index: 20;
  min-width: 200px;
  padding: 40px 0 8px;
  background: #0B2B38;
  /* audit vs Figma */
  border-radius: 10px;
  display: flex;
  flex-direction: column;
}

.res-filters__sort-menu[hidden] {
  display: none;
}

.res-filters__sort-opt {
  background: none;
  border: 0;
  padding: 8px 20px;
  text-align: left;
  color: #fff;
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  cursor: pointer;
}

.res-filters__sort-opt:hover {
  background: rgba(255, 255, 255, 0.08);
}

.res-filters__sort-opt.is-active {
  background: #00AEEF;
  /* audit vs Figma */
  font-weight: 600;
}

.res-filters__toggle:hover {
  background: #00AEEF;
}

@media (max-width: 767px) {

  /* Panel leaves the flex row and floats over the grid */
  .resources__body {
    display: block;
  }

  .res-filters__panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 50;
    flex: none;
    width: min(340px, calc(100vw - 32px));
    max-height: 80vh;
    overflow-y: auto;
  }

  .res-filters__sort-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    z-index: 50;
    width: min(340px, calc(100vw - 32px));
    padding: 8px 0;
  }

  /* Blurred scrim behind either overlay */
  body.res-filters-open::before,
  body.res-sort-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 20, 27, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }

  body.res-filters-open,
  body.res-sort-open {
    overflow: hidden;
  }
}
