/* AidReady Help Finder - design tokens
   Deliberately dark, warm, and specific (ink-navy + amber + clay-red) rather than
   the blue-on-white / purple-gradient palette most AI-generated UIs default to. */
:root {
  /* palette - exact values only, no other colors used anywhere in this file */
  --bg: #12182B;
  --surface: #1C2440;
  --surface-raised: #232C4E;
  --accent-primary: #E8A33D;
  --accent-primary-hover: #F0B35C;
  --accent-secondary: #3FA796;
  --accent-danger: #C25B4A;
  --text: #F1EDE4;
  --text-muted: #ACA79A;
  --border: rgba(241, 237, 228, 0.12);
  --border-strong: rgba(241, 237, 228, 0.24);

  /* type - warm slab display for headings, geometric sans for everything else */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.0625rem;
  --text-lg: 1.25rem;
  --text-xl: 1.75rem;
  --text-2xl: 2.25rem;

  /* spacing - keeps things consistent */
  --gap-small: 0.5rem;
  --gap-medium: 1rem;
  --gap-large: 1.5rem;

  --radius: 0.5rem;
  --radius-lg: 1rem;

  --transition-fast: 150ms ease;
  --transition-base: 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* respect the user's OS-level motion preference across the whole app, in
   addition to the specific static fallbacks defined further down */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* reset so the browser doesn't mess with spacing */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: var(--text-base);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
}

/* skip link for accessibility - hidden til you tab to it */
.skip-link {
  position: fixed;
  top: 0;
  left: 0;
  transform: translateY(-100%);
  background-color: var(--accent-primary);
  color: var(--bg);
  padding: var(--gap-medium) var(--gap-large);
  text-decoration: none;
  font-weight: 600;
  z-index: 100;
  border-radius: 0 0 var(--radius) var(--radius);
  transition: transform var(--transition-base);
}

.skip-link:focus {
  transform: translateY(0);
}

header {
  padding: var(--gap-large);
  background-color: var(--surface);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--gap-medium);
  flex-wrap: wrap;
}

header h1 {
  font-size: var(--text-xl);
}

header .tagline {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-top: 0.25rem;
}

.header-nav {
  padding-top: 0.25rem;
}

.header-link {
  color: var(--accent-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: var(--text-sm);
  padding: var(--gap-small) 0;
  transition: color var(--transition-base);
}

.header-link:hover {
  color: var(--accent-primary);
  text-decoration: underline;
}

main {
  padding: var(--gap-large);
}

section {
  padding: var(--gap-large);
  margin-bottom: var(--gap-large);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

section h2 {
  font-size: var(--text-lg);
  margin-bottom: var(--gap-large);
  color: var(--text);
}

footer {
  text-align: center;
  padding: var(--gap-large);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* keyboard accessibility - a visible amber ring, not the browser default */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(232, 163, 61, 0.25);
}

/* form stuff */
.form-group {
  margin-bottom: var(--gap-large);
  display: flex;
  flex-direction: column;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-medium);
  margin-bottom: var(--gap-medium);
}

label {
  margin-bottom: var(--gap-small);
  font-weight: 500;
  color: var(--text);
}

input,
select,
textarea {
  padding: var(--gap-medium);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: inherit;
  background-color: var(--surface-raised);
  color: var(--text);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

input::placeholder {
  color: var(--text-muted);
}

input:hover,
select:hover {
  border-color: var(--border-strong);
}

/* deliberate flash on facility-type change, so a select swap reads as a
   change you made rather than an instant, unnoticed snap */
select.select-flash {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 4px rgba(232, 163, 61, 0.22);
}

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: var(--gap-medium) var(--gap-large);
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
  /* 44px minimum touch target - this has to work one-handed in a hurry */
  min-height: 44px;
  transition: background-color var(--transition-base), transform var(--transition-fast), box-shadow var(--transition-base);
}

.btn-icon {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
  transition-duration: 80ms;
}

.btn:disabled {
  background-color: var(--surface-raised);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn--primary {
  background-color: var(--accent-primary);
  color: var(--bg);
}

.btn--primary:hover:not(:disabled) {
  background-color: var(--accent-primary-hover);
}

.btn--secondary {
  background-color: transparent;
  color: var(--accent-secondary);
  border: 1px solid var(--accent-secondary);
}

.btn--secondary:hover:not(:disabled) {
  background-color: rgba(63, 167, 150, 0.12);
}

/* status / error messaging under the search form */
.search-status {
  margin-top: var(--gap-small);
  font-size: var(--text-sm);
  color: var(--text-muted);
  min-height: 1.5em;
}

.search-status--error {
  color: var(--accent-danger);
  font-weight: 500;
}

/* map */
#map {
  height: 300px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--surface-raised);
  color: var(--text);
}

/* map markers */
.facility-marker-wrapper,
.origin-marker-wrapper {
  background: transparent !important;
  border: none !important;
}

.facility-marker {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-secondary);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.origin-marker {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 3px solid var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* the one bold visual moment: the nearest facility gets a pulsing glow ring */
.marker-pulse {
  position: relative;
}

.marker-pulse::after {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid var(--accent-primary);
  animation: pulse-glow 1.8s ease-out infinite;
}

@keyframes pulse-glow {
  0% {
    transform: scale(0.6);
    opacity: 0.9;
  }

  70% {
    transform: scale(1.7);
    opacity: 0;
  }

  100% {
    transform: scale(1.7);
    opacity: 0;
  }
}

/* prefers-reduced-motion: swap the animated ring for a static highlight
   instead of just disabling the animation (which would leave no ring at all) */
.marker-pulse-static::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--accent-primary);
  box-shadow: 0 0 0 5px rgba(232, 163, 61, 0.25);
}

@media (prefers-reduced-motion: reduce) {
  .marker-pulse::after {
    animation: none;
  }
}

/* results controls */
.results-controls {
  margin-bottom: var(--gap-large);
  padding-bottom: var(--gap-large);
  border-bottom: 1px solid var(--border);
}

.search-group {
  margin-bottom: var(--gap-large);
}

.search-group label {
  display: block;
}

.search-group input {
  width: 100%;
}

.sort-buttons {
  display: flex;
  gap: var(--gap-small);
  flex-wrap: wrap;
}

.sort-btn {
  padding: var(--gap-small) var(--gap-medium);
  min-height: 44px;
  background-color: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--transition-base), border-color var(--transition-base), transform var(--transition-fast);
}

.sort-btn:hover {
  border-color: var(--accent-primary);
  transform: translateY(-1px);
}

.sort-btn.active {
  background-color: var(--accent-primary);
  color: var(--bg);
  border-color: var(--accent-primary);
}

/* results list - cards, mobile-first since this has to work on a phone in the field */
.results-list {
  list-style: none;
}

.about-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--gap-medium);
}

.about-steps li {
  color: var(--text-muted);
}

.about-steps strong {
  color: var(--text);
}

.result-card {
  background-color: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap-large);
  margin-bottom: var(--gap-medium);
  animation: fadeSlideIn 380ms var(--transition-base) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .result-card {
    animation: none;
  }
}

.result-card-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-md);
  margin-bottom: var(--gap-small);
  color: var(--text);
}

.result-card-address {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--gap-small);
}

.result-card-distance {
  display: inline-block;
  background-color: rgba(63, 167, 150, 0.16);
  color: var(--accent-secondary);
  font-weight: 600;
  font-size: var(--text-sm);
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius);
}

/* state panel - one reusable component for the initial prompt, empty
   results, and every error condition, distinguished visually via data-kind */
.state-panel {
  text-align: center;
  padding: calc(var(--gap-large) * 2) var(--gap-large);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-strong);
}

.state-panel-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto var(--gap-medium);
  color: var(--text-muted);
}

.state-panel-icon svg {
  width: 100%;
  height: 100%;
}

.state-panel-title {
  font-size: var(--text-lg);
  margin-bottom: var(--gap-small);
  color: var(--text);
}

.state-panel-desc {
  color: var(--text-muted);
  max-width: 34em;
  margin: 0 auto;
}

.state-panel-suggestion {
  margin-top: var(--gap-medium);
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: italic;
}

.state-panel-actions {
  display: flex;
  justify-content: center;
  margin-top: var(--gap-large);
}

.state-panel[data-kind="empty-type"] .state-panel-icon,
.state-panel[data-kind="empty-filter"] .state-panel-icon {
  color: var(--accent-secondary);
}

/* genuine errors only - clay-red border + icon, nowhere else in the app */
.state-panel[data-kind^="error-"] {
  border-style: solid;
  border-color: var(--accent-danger);
  background-color: rgba(194, 91, 74, 0.08);
}

.state-panel[data-kind^="error-"] .state-panel-icon {
  color: var(--accent-danger);
}

mark {
  background-color: var(--accent-primary);
  color: var(--bg);
  padding: 0.125rem 0.25rem;
  border-radius: var(--radius);
}

/* responsive stuff - mobile-first, this bumps up for bigger screens */

@media (min-width: 768px) {
  body {
    font-size: var(--text-md);
  }

  section {
    padding: var(--gap-large) calc(var(--gap-large) * 1.5);
  }

  #map {
    height: 420px;
  }

  .results-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--gap-medium);
  }

  .result-card {
    margin-bottom: 0;
  }
}

@media (min-width: 1024px) {
  main {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--gap-large);
  }
}
