:root {
  --border-color: rgba(20, 20, 20, 0.12);
  --chip-bg: #f3f3f3;
  --chip-bg-active: #141414;
  --chip-color-active: #ffffff;
  --pill-bg: #f5f5f5;
  --pill-bg-active: #ffffff;
  --pill-border: rgba(20, 20, 20, 0.18);
  --pill-border-active: #141414;
  --text-muted: rgba(20, 20, 20, 0.6);
}

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.nav-link {
  position: relative;
  color: #141414;
  transition: color 0.2s ease;
}

.nav-link:hover,
.nav-link:focus {
  color: #369eff;
}

.nav-link.active,
.nav-link[aria-current="page"] {
  font-weight: 600;
}

.search-hero {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 28px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  border: none;
  border-bottom: 2px dotted var(--border-color);
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 700;
  padding: 12px 48px 12px 0;
  outline: none;
  background: transparent;
}

.search-input::placeholder {
  color: rgba(20, 20, 20, 0.3);
}

.search-clear {
  position: absolute;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  display: none;
}

.search-clear::before,
.search-clear::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 2px;
  background: #555;
  transform-origin: center;
}

.search-clear::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.search-clear::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.search-clear.visible {
  display: block;
}

.result-count {
  color: var(--text-muted);
  font-size: 16px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.group-label {
  font-size: 14px;
  font-weight: 600;
  margin-right: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.filter-group,
.sort-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 720px;
}

.chip {
  border: none;
  padding: 8px 16px;
  border-radius: 9999px;
  background: var(--chip-bg);
  color: #141414;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.chip-dynamic {
  display: contents;
}

.chip:hover,
.chip:focus {
  background: rgba(20, 20, 20, 0.18);
}

.chip-active {
  background: var(--chip-bg-active);
  color: var(--chip-color-active);
}

.chip-active:hover,
.chip-active:focus {
  background: var(--chip-bg-active);
}

.chip-more {
  background: transparent;
  border: 1px dashed var(--pill-border);
}

.chip-more:hover,
.chip-more:focus {
  background: rgba(20, 20, 20, 0.08);
}

.pill-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.pill {
  min-width: 104px;
  padding: 8px 16px;
  border-radius: 9999px;
  border: 1px solid var(--pill-border);
  background: var(--pill-bg);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.pill:hover,
.pill:focus {
  border-color: #141414;
}

.pill-active {
  background: var(--pill-bg-active);
  border-color: var(--pill-border-active);
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.active-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  font-size: 13px;
  color: #333;
  background: #fff;
}

.active-filter-tag button {
  border: none;
  backdrop-filter: blur(0);
  background: transparent;
  cursor: pointer;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 28px;
}

.result-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-card__image-wrapper {
  position: relative;
  width: 100%;
  padding-top: 66%;
  background: #f5f5f5;
  border-radius: 8px;
  overflow: hidden;
}

.result-card__media-link {
  display: block;
  height: 100%;
}

.result-card__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-card__meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.result-card__location a {
  color: inherit;
  text-decoration: none;
}

.result-card__location a:hover,
.result-card__location a:focus {
  text-decoration: underline;
}

.result-card__authors a {
  color: inherit;
  text-decoration: none;
}

.result-card__authors a:hover,
.result-card__authors a:focus {
  text-decoration: underline;
}

.result-card__title {
  font-size: 18px;
  font-weight: 600;
  color: #141414;
  text-decoration: none;
}

.result-card__title:hover,
.result-card__title:focus {
  text-decoration: underline;
}

.result-card__excerpt {
  font-size: 14px;
  color: #444;
  line-height: 1.5;
}

.loading,
.empty {
  text-align: center;
  font-size: 15px;
  color: var(--text-muted);
  margin: 24px 0;
}

.hidden {
  display: none !important;
}

.sentinel {
  height: 1px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}

.modal-panel {
  background: #fff;
  border-radius: 12px;
  width: min(640px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.modal-header,
.modal-footer {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-body {
  padding: 0 20px 20px 20px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  color: var(--text-muted);
}

.modal-btn {
  border: 1px solid var(--pill-border);
  background: #fff;
  border-radius: 6px;
  padding: 8px 20px;
  font-size: 14px;
  cursor: pointer;
}

.modal-btn--primary {
  background: #141414;
  color: #fff;
  border-color: #141414;
}

.modal-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(20, 20, 20, 0.08);
  border-radius: 8px;
  font-size: 14px;
}

.modal-option input {
  width: 16px;
  height: 16px;
}

.modal-empty {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: 14px;
  padding: 12px 0;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 768px) {
  .controls {
    flex-direction: column;
    align-items: flex-start;
  }
  .search-input {
    font-size: clamp(28px, 8vw, 48px);
  }
  .results-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}
