/**
 * Projects Listing shortcode [clune_projects_listing]
 * Only loaded on pages that contain the shortcode.
 * Filter dropdowns styled like News mobile filter.
 */

.clune-projects-listing {
  --projects-filter-border: #e5e5e5;
  --projects-filter-bg: #fff;
  --projects-filter-bg-hover: #f9f9f9;
  --projects-filter-text: #333;
  --projects-filter-primary: #d22d1f;
  --projects-filter-dark: #1a1a1a;
  --clune-filter-gap: 1rem;
  position: relative;
}

.clune-projects-filters {
  padding: 0 0 2rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--projects-filter-border);
}

.clune-projects-filters-form .clune-projects-filters-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--clune-filter-gap);
}

.clune-projects-filter-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.clune-projects-filter-group.clune-projects-filter-dropdown-wrap {
  min-width: 180px;
}

/* Hidden native select (kept for form and JS) */
.clune-projects-filter-select-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
}

/* Dropdown trigger – same style as news mobile filter */
.clune-projects-filter-dropdown {
  position: relative;
}

.clune-projects-filter-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 180px;
  padding: 14px 16px;
  background: var(--projects-filter-bg);
  border: 1px solid var(--projects-filter-border);
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--projects-filter-text);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  text-align: left;
}

.clune-projects-filter-dropdown-btn:hover {
  border-color: var(--projects-filter-dark);
}

.clune-projects-filter-dropdown-btn.open {
  border-color: var(--projects-filter-dark);
  box-shadow: 0 0 0 1px var(--projects-filter-dark);
}

.clune-projects-filter-dropdown-btn .filter-icon {
  flex-shrink: 0;
  opacity: 0.8;
}

.clune-projects-filter-dropdown-btn .clune-projects-filter-dropdown-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clune-projects-filter-dropdown-btn .dropdown-arrow {
  margin-left: auto;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.clune-projects-filter-dropdown-btn.open .dropdown-arrow {
  transform: rotate(180deg);
}

/* Dropdown panel */
.clune-projects-filter-dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  min-width: 100%;
  max-height: 280px;
  overflow-y: auto;
  background: var(--projects-filter-bg);
  border: 1px solid var(--projects-filter-border);
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  z-index: 100;
  min-width: 240px;
}

.clune-projects-filter-dropdown-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.clune-projects-filter-dropdown-panel[hidden] {
  display: block !important;
}

.clune-projects-filter-dropdown-panel:not(.open)[hidden] {
  display: none !important;
}

.clune-projects-filter-option {
  display: block;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--projects-filter-border);
  font-size: 1rem;
  color: var(--projects-filter-text);
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease;
}

.clune-projects-filter-option:last-child {
  border-bottom: none;
}

.clune-projects-filter-option:hover {
  background: var(--projects-filter-bg-hover);
}

.clune-projects-filter-dropdown-panel .clune-projects-filter-option.active {
  color: var(--projects-filter-primary);
  font-weight: 600;
}

/* Reset link */
.clune-projects-filter-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.clune-projects-filter-reset {
  padding: 10px 16px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--projects-filter-text);
  text-decoration: none;
  border: 1px solid var(--projects-filter-border);
  border-radius: 8px;
  background: var(--projects-filter-bg);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.clune-projects-filter-reset:hover {
  border-color: var(--projects-filter-dark);
  background: var(--projects-filter-bg-hover);
}

.clune-projects-no-results {
  padding: 2rem;
  text-align: center;
}

.clune-projects-listing-footer {
  margin-top: 2rem;
  text-align: center;
}

.clune-projects-load-more-wrap {
  display: flex;
  justify-content: center;
}

.clune-projects-load-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.clune-projects-load-more-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.clune-projects-load-more-btn .btn-spinner svg {
  display: block;
  animation: clune-projects-spin 1s linear infinite;
}

@keyframes clune-projects-spin {
  to {
    transform: rotate(360deg);
  }
}

.clune-projects-listing-content {
  position: relative;
  transition: opacity 0.2s ease;
}

.clune-projects-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.7);
  pointer-events: none;
  z-index: 10;
}

.clune-projects-loading-spinner {
  display: block;
  animation: clune-projects-spin 1s linear infinite;
  color: var(--projects-filter-primary, #d22d1f);
}

@media (max-width: 500px) {
  .clune-projects-filter-group.clune-projects-filter-dropdown-wrap {
    min-width: 0;
    width: 100%;
  }

  .clune-projects-filter-dropdown-btn {
    min-width: 0;
    width: 100%;
  }

  .clune-projects-filters-form .clune-projects-filters-inner {
    flex-direction: column;
  }

  .clune-projects-filter-actions {
    width: 100%;
  }

  .clune-projects-filter-reset {
    width: 100%;
    text-align: center;
  }
}
