:root {
  color-scheme: light;
  --bg: #f4f7fc;
  --surface: #ffffff;
  --surface-soft: #f8faff;
  --text: #0f172a;
  --muted: #5b6b87;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --border: #dbe5f4;
  --shadow: 0 12px 34px rgba(22, 40, 74, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, #e7efff 0%, transparent 32%),
    radial-gradient(circle at 86% 14%, #e6f4ff 0%, transparent 30%),
    var(--bg);
}

.app {
  width: min(960px, 100% - 24px);
  margin: 16px auto 24px;
  padding: 20px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

h1 {
  margin: 0;
  font-family: "Manrope", "Inter", sans-serif;
  font-size: clamp(1.35rem, 5vw, 2.1rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

.search-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #25354f;
}

input,
button,
select {
  font: inherit;
  border-radius: 12px;
  min-height: 50px;
  padding: 12px 14px;
}

.autocomplete-wrap {
  position: relative;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

input::placeholder {
  color: #90a0b8;
}

input:hover {
  border-color: #bfd0eb;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
.suggestion-btn:focus-visible {
  outline: none;
  border-color: #8cb3ee;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 25;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 14px 36px rgba(16, 31, 63, 0.12);
  max-height: 280px;
  overflow-y: auto;
}

.hidden {
  display: none;
}

.suggestion-item + .suggestion-item {
  margin-top: 4px;
}

.suggestion-btn {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  padding: 10px;
  text-align: left;
  color: var(--text);
  line-height: 1.35;
}

.suggestion-btn:hover,
.suggestion-btn:active {
  background: #edf4ff;
}

button {
  width: 100%;
  border: 0;
  background: linear-gradient(180deg, #2d6df0 0%, var(--accent) 100%);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.15s ease;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
}

button:hover {
  background: linear-gradient(180deg, #2963d7 0%, var(--accent-hover) 100%);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.72;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.legend {
  margin-top: 16px;
  padding: 13px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.filters {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  display: grid;
  gap: 10px;
}

.filter-field {
  display: grid;
  gap: 6px;
}

.filter-field label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.clear-filters {
  min-height: 44px;
  padding: 10px 12px;
  font-size: 0.9rem;
  border: 1px solid #c8d8f4;
  background: #eef4ff;
  color: #234f96;
  box-shadow: none;
}

.clear-filters:hover {
  background: #e3edff;
}

.legend-title {
  margin: 0 0 9px;
  font-family: "Manrope", "Inter", sans-serif;
  font-size: 0.96rem;
  font-weight: 700;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.legend-row + .legend-row {
  margin-top: 8px;
}

.legend-label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
}

.status {
  min-height: 24px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

.results {
  margin: 10px 0 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.list-controls {
  margin-top: 10px;
}

.load-more {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #c8d8f4;
  background: #eef4ff;
  color: #234f96;
  box-shadow: none;
}

.load-more:hover {
  background: #e3edff;
}

.map-section {
  margin-top: 16px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.map-title {
  margin: 0 0 10px;
  font-family: "Manrope", "Inter", sans-serif;
  font-size: 1rem;
  line-height: 1.3;
}

.map {
  width: 100%;
  height: 320px;
  border-radius: 12px;
  border: 1px solid #cfdcf3;
  overflow: hidden;
}

.result-item {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fcfdff;
}

.result-item h2 {
  margin: 0 0 8px;
  font-family: "Manrope", "Inter", sans-serif;
  font-size: 1.03rem;
  line-height: 1.35;
}

.meta {
  margin: 5px 0;
  color: #475a79;
  line-height: 1.4;
}

.inline-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.badge,
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.8rem;
  line-height: 1.25;
  font-weight: 700;
  border: 1px solid transparent;
}

.badge-type-lycee {
  background: #e6eeff;
  color: #1849a9;
  border-color: #bfd1fb;
}

.badge-type-college {
  background: #e6f8ee;
  color: #1d6842;
  border-color: #bde4ce;
}

.badge-type-other {
  background: #f1f4f8;
  color: #55657e;
  border-color: #d4ddeb;
}

.badge-source-sport-etudes {
  background: #e8f0ff;
  color: #1c4dab;
  border-color: #c3d4fb;
}

.badge-source-sections {
  background: #e8fbf4;
  color: #17654a;
  border-color: #bfead8;
}

.chips {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-team {
  background: #e3f7f2;
  color: #0e6058;
  border-color: #bae8dd;
}

.chip-combat {
  background: #ffe8eb;
  color: #8a2230;
  border-color: #f3c4cc;
}

.chip-water {
  background: #e5f4ff;
  color: #165d96;
  border-color: #bbdbf5;
}

.chip-winter {
  background: #ececff;
  color: #404097;
  border-color: #c9caf7;
}

.chip-endurance {
  background: #fff4df;
  color: #8b5f10;
  border-color: #efd8ae;
}

.chip-other {
  background: #f1f4f8;
  color: #55657e;
  border-color: #d4ddeb;
}

.links {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.links a {
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
}

.links a:hover {
  text-decoration: underline;
}

.app-footer {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.app-footer a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  .app {
    width: min(960px, 100% - 16px);
    margin: 10px auto 16px;
    padding: 14px;
    border-radius: 16px;
  }

  h1 {
    font-size: clamp(1.2rem, 6vw, 1.55rem);
    line-height: 1.22;
  }

  .subtitle {
    font-size: 0.92rem;
    line-height: 1.42;
    margin-top: 6px;
  }

  .search-form {
    margin-top: 14px;
    gap: 10px;
  }

  input,
  select,
  button {
    min-height: 48px;
    padding: 10px 12px;
  }

  .filters,
  .legend,
  .map-section,
  .result-item {
    margin-top: 12px;
    padding: 10px;
    border-radius: 12px;
  }

  .clear-filters {
    width: 100%;
    min-height: 46px;
  }

  .legend-title,
  .map-title {
    font-size: 0.92rem;
    margin-bottom: 8px;
  }

  .legend-row {
    gap: 6px;
  }

  .legend-label {
    font-size: 0.82rem;
  }

  .badge,
  .chip {
    font-size: 0.74rem;
    padding: 2px 8px;
  }

  .chips {
    gap: 5px;
  }

  .result-item h2 {
    font-size: 0.96rem;
  }

  .meta {
    font-size: 0.89rem;
    line-height: 1.35;
  }

  .links {
    gap: 8px;
  }

  .links a {
    font-size: 0.88rem;
  }

  .map {
    height: 260px;
    border-radius: 10px;
  }

  .app-footer {
    margin-top: 14px;
    padding-top: 10px;
    font-size: 0.8rem;
    line-height: 1.4;
  }
}

@media (min-width: 760px) {
  .app {
    margin: 30px auto;
    padding: 24px;
  }

  .search-form {
    grid-template-columns: 1fr auto;
    align-items: end;
    column-gap: 12px;
  }

  .filters {
    grid-template-columns: 1fr 1fr 1fr 1fr auto;
    align-items: end;
    column-gap: 10px;
  }

  .clear-filters {
    width: auto;
    min-width: 140px;
  }

  label {
    grid-column: 1 / -1;
  }

  button {
    width: auto;
    min-width: 190px;
  }

  .map {
    height: 380px;
  }
}
