﻿body.popup-open {
  overflow: hidden;
}

.popup-canvas {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 2rem;
  display: grid;
  place-items: center;
  background: rgba(2, 4, 5, 0.76);
  backdrop-filter: blur(3px);
}

.popup-canvas[hidden] {
  display: none;
}

.popup {
  position: relative;
  width: min(100%, 38rem);
  min-height: 34rem;
  max-height: calc(100dvh - 4rem);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0.5rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #111518;
  color: var(--text);
  box-shadow: 0 1.75rem 5rem rgba(0, 0, 0, 0.58);
}

.popup-header {
  min-height: 4rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.015);
}

.popup-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.2;
  text-align: center;
}

.popup-action {
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.popup-action:hover,
.popup-action:focus-visible {
  color: #6bdd77;
}

.popup-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0.2rem;
}

.popup-cancel {
  justify-self: start;
}

.popup-reset {
  justify-self: end;
}

.popup-content {
  min-height: 0;
  flex: 1;
  padding: 1rem 1rem 6.4rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.popup-material-field {
  position: relative;
  width: 100%;
  height: 2.75rem;
  flex: 0 0 2.75rem;
  border: 1px solid #626b73;
  border-radius: 0.35rem;
  display: block;
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.popup-material-field:hover {
  border-color: #8b949d;
  background: rgba(255, 255, 255, 0.04);
}

.popup-material-field:focus-within {
  border-color: var(--accent);
  background: rgba(72, 200, 87, 0.035);
  box-shadow: 0 0 0 1px var(--accent);
}

.popup-material-label {
  position: absolute;
  top: 0;
  left: 0.8rem;
  z-index: 1;
  padding: 0 0.3rem;
  background: #111518;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1;
  transform: translateY(-50%);
  pointer-events: none;
  transition: color 150ms ease;
}

.popup-material-field:focus-within .popup-material-label {
  color: var(--accent);
}

.popup-material-field input {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0.45rem 1rem 0.3rem;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  caret-color: var(--accent);
}

.location-autocomplete {
  position: relative;
  z-index: 4;
  width: 100%;
}

.location-dropdown {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  left: 0;
  z-index: 10;
  overflow: hidden;
  border: 1px solid #586169;
  border-radius: 0.35rem;
  background: #1a2024;
  box-shadow: 0 0.8rem 1.8rem rgba(0, 0, 0, 0.38);
}

.location-dropdown[hidden] {
  display: none;
}

.location-dropdown ul {
  max-height: 15rem;
  margin: 0;
  padding: 0.35rem 0;
  overflow-y: auto;
  list-style: none;
}

.location-option {
  padding: 0.72rem 1rem;
  color: #d8dde0;
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease;
}

.location-option:hover,
.location-option.active {
  color: #fff;
  background: rgba(72, 200, 87, 0.18);
}

.location-dropdown-message {
  margin: 0;
  padding: 0.9rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.popup-submit-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  padding: 1.4rem 1rem 1rem;
  background: linear-gradient(180deg, rgba(17, 21, 24, 0) 0%, #111518 34%);
  pointer-events: none;
}

.popup-submit {
  width: 100%;
  min-height: 3.35rem;
  padding: 0.7rem 1rem;
  border: 1px solid #52bd5e;
  border-radius: 0.35rem;
  background: linear-gradient(180deg, #4bb257 0%, #369041 100%);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 0.7rem 1.5rem rgba(0, 0, 0, 0.28);
  pointer-events: auto;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.popup-submit:hover,
.popup-submit:focus-visible {
  border-color: #6bd576;
  background: linear-gradient(180deg, #5ac566 0%, #40a04b 100%);
}

.popup-submit:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 0.15rem;
}

.popup-submit:active {
  transform: translateY(1px);
}

.popup-filter-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.popup-filter-group legend {
  margin-bottom: 0.65rem;
  padding: 0;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
}

.popup-option-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}

.popup-option-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.popup-option-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.popup-option-checkbox {
  display: none;
}

.popup-option {
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 0.3rem;
  background: #252a31;
  color: #d9dde2;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.popup-option:hover,
.popup-option:focus-visible {
  border-color: rgba(255, 255, 255, 0.28);
  background: #333a42;
  color: var(--text);
}

.popup-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0.15rem;
}

.popup-option:active {
  transform: translateY(1px);
}

.popup-option-checkbox:checked + .popup-option {
  border-color: #52bd5e;
  background: linear-gradient(180deg, #48a954 0%, #347f3d 100%);
  color: #fff;
}

.popup-option-checkbox:checked + .popup-option:hover {
  border-color: #67d172;
  background: linear-gradient(180deg, #56bd62 0%, #3c9146 100%);
}

.popup-option-checkbox:focus-visible + .popup-option {
  outline: 2px solid var(--accent);
  outline-offset: 0.15rem;
}

.difficulty-range-values {
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.difficulty-range-values output {
  min-width: 1.8rem;
  margin-left: 0.3rem;
  color: var(--text);
  font-weight: 800;
}

.difficulty-range {
  position: relative;
  height: 1.6rem;
  cursor: pointer;
  touch-action: none;
}

.difficulty-range::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 0.3rem;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--grade-3) 0%,
    var(--grade-4-plus) 20%,
    var(--grade-5) 38%,
    var(--grade-6-minus) 54%,
    var(--grade-7) 72%,
    var(--grade-8-plus) 86%,
    var(--grade-10) 100%
  );
  transform: translateY(-50%);
}

.difficulty-range.length-range::before {
  background: var(--accent);
}

.difficulty-range.distance-range::before {
  background: linear-gradient(
    90deg,
    #55a868 0%,
    #e0c341 10.81%,
    #dc812e 14.41%,
    #c83d3d 18.92%,
    #c83d3d 100%
  );
}

.difficulty-range input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  appearance: none;
  background: transparent;
  pointer-events: none;
}

.difficulty-range input[type="range"]::-webkit-slider-runnable-track {
  height: 0.3rem;
  background: transparent;
}

.difficulty-range input[type="range"]::-moz-range-track {
  height: 0.3rem;
  background: transparent;
}

.difficulty-range input[type="range"]::-webkit-slider-thumb {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: -0.43rem;
  border: 0.15rem solid #fff;
  border-radius: 50%;
  appearance: none;
  background: #252a31;
  cursor: grab;
  box-shadow: 0 0.18rem 0.45rem rgba(0, 0, 0, 0.42);
  pointer-events: auto;
}

.difficulty-range input[type="range"]::-moz-range-thumb {
  width: 0.9rem;
  height: 0.9rem;
  border: 0.15rem solid #fff;
  border-radius: 50%;
  background: #252a31;
  cursor: grab;
  box-shadow: 0 0.18rem 0.45rem rgba(0, 0, 0, 0.42);
  pointer-events: auto;
}

.difficulty-range input[type="range"]:focus-visible::-webkit-slider-thumb {
  outline: 2px solid var(--accent);
  outline-offset: 0.15rem;
}

.difficulty-range input[type="range"]:focus-visible::-moz-range-thumb {
  outline: 2px solid var(--accent);
  outline-offset: 0.15rem;
}

.difficulty-range input[type="range"]:active::-webkit-slider-thumb {
  cursor: grabbing;
}

.difficulty-range input[type="range"]:active::-moz-range-thumb {
  cursor: grabbing;
}

@media (max-width: 680px) {
  .popup-canvas {
    padding: 0;
    place-items: stretch;
    background: #111518;
    backdrop-filter: none;
  }

  .popup {
    width: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .popup-header {
    min-height: 3.75rem;
    padding-inline: 0.9rem;
  }

  .popup-content {
    padding: 0.9rem 0.9rem 6.2rem;
  }

  .popup-submit-wrap {
    padding-inline: 0.9rem;
    padding-bottom: max(0.9rem, env(safe-area-inset-bottom));
  }

  .popup-option-grid {
    gap: 0.4rem;
  }

  .popup-option {
    padding-inline: 0.3rem;
    font-size: 0.75rem;
  }
}

