/* ============================================
   OKVRN Resource Finder - Styles
   Mobile-first, no framework
   ============================================ */

/* --- Custom Properties --- */
:root {
  /* Brand palette (from palette.scss) */
  --prussian-blue: #112135;
  --crushed-berry: #871B1C;
  --bone: #E4DCCA;
  --graphite: #363232;
  --slate-grey: #7D8993;

  /* Semantic aliases */
  --navy: var(--prussian-blue);
  --navy-light: #1A3050;
  --accent: var(--crushed-berry);
  --accent-hover: #6E1516;
  --white: #FFFFFF;
  --light-gray: #F5F5F5;
  --mid-gray: #E5E7EB;
  --body-text: var(--graphite);
  --text-muted: #6B7280;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.2);
  --radius: 8px;
  --radius-sm: 4px;
  --transition: 0.2s ease;
  --font-heading: 'Barlow Condensed', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  /* Focus ring */
  --focus-ring: 0 0 0 3px rgba(17,33,53,0.25);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--body-text);
  background: var(--white);
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--navy);
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
}

/* --- Screen Reader Only --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Skip Link --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 8px;
  background: var(--navy);
  color: var(--white);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  z-index: 10000;
  font-weight: 600;
}
.skip-link:focus {
  top: 8px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: background var(--transition), transform var(--transition);
  min-height: 44px;
  min-width: 44px;
  white-space: nowrap;
}
.btn:active {
  transform: scale(0.97);
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.btn-primary {
  background: var(--accent);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-secondary {
  background: var(--navy);
  color: var(--white);
}
.btn-secondary:hover {
  background: var(--navy-light);
}

/* --- Crisis Banner --- */
.crisis-banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #f5f5f5;
  color: var(--body-text);
  text-align: center;
}

.crisis-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 16px;
  color: var(--body-text);
  font-weight: 600;
  font-size: 0.85rem;
  min-height: 36px;
}

.crisis-chevron {
  transition: transform var(--transition);
}
.crisis-toggle[aria-expanded="true"] .crisis-chevron {
  transform: rotate(180deg);
}

.crisis-links {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 0 16px 10px;
}
.crisis-links.open {
  display: flex;
}

.crisis-link {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--white);
  border-radius: var(--radius);
  color: var(--body-text);
  min-height: 44px;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid var(--mid-gray);
}
.crisis-link:hover,
.crisis-link:focus {
  box-shadow: var(--shadow-sm);
  border-color: var(--navy);
}
.crisis-link-logo {
  height: 24px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}
.crisis-label {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--body-text);
}

/* --- Hero --- */
.hero {
  background: var(--bone);
  color: var(--graphite);
  padding: 46px 24px 53px;
  text-align: center;
  min-height: 47.5vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-content {
  max-width: 680px;
}

.hero-logo {
  max-height: 80px;
  margin: 0 auto 24px;
}

.hero-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 1.2;
  margin-bottom: 12px;
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--slate-grey);
  margin-bottom: 28px;
  line-height: 1.6;
}

.hero-cta {
  font-size: 1.1rem;
  padding: 14px 32px;
}

/* --- Category Cards --- */
.categories-section {
  background: var(--light-gray);
  padding: 15px 0;
  overflow: hidden;
  position: sticky;
  top: 36px;
  z-index: 600;
}

.categories-label {
  display: block;
  padding: 0 16px 8px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--slate-grey);
}

.categories-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 16px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.categories-scroll::-webkit-scrollbar {
  display: none;
}

.categories-wrapper {
  display: flex;
  align-items: center;
}

.carousel-btn {
  display: none;
  flex-shrink: 0;
  width: 32px;
  align-self: stretch;
  background: var(--white);
  border: 1px solid var(--mid-gray);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--primary);
  transition: box-shadow var(--transition), color var(--transition);
  line-height: 1;
}

.carousel-btn:hover:not(:disabled) {
  box-shadow: var(--shadow-md);
  color: var(--accent);
}

.carousel-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.carousel-btn-left {
  border-radius: var(--radius) 0 0 var(--radius);
}

.carousel-btn-right {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.category-card {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  scroll-snap-align: start;
  min-width: 130px;
  min-height: 44px;
  transition: box-shadow var(--transition), transform var(--transition);
  border: 2px solid transparent;
}
.category-card:hover,
.category-card:focus {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.category-card.active {
  border-color: var(--accent);
}

.category-card-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.category-card-icon svg {
  width: 16px;
  height: 16px;
}
img.category-card-icon {
  border-radius: 0;
  object-fit: contain;
  background: none;
  display: block;
}

.category-card-name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 0.3px;
  color: var(--body-text);
}

.category-card-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Filter Bar --- */
.filter-bar {
  background: var(--white);
  border-bottom: 1px solid var(--mid-gray);
  padding: 12px 16px;
  position: sticky;
  top: 36px;
  z-index: 500;
}

.filter-bar-inner {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1;
  min-width: 180px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 36px 10px 36px;
  border: 1px solid var(--mid-gray);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font-body);
  min-height: 44px;
  transition: border-color var(--transition);
}
.search-input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(11,29,58,0.1);
}

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--text-muted);
  border-radius: 50%;
}
.search-clear:hover,
.search-clear:focus-visible {
  background: var(--light-gray);
}
.search-clear:focus-visible {
  box-shadow: var(--focus-ring);
}

.category-filter {
  padding: 10px 12px;
  border: 1px solid var(--mid-gray);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font-body);
  background: var(--white);
  min-height: 44px;
  max-width: 220px;
  cursor: pointer;
}
.category-filter:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(11,29,58,0.1);
}

.near-me-btn {
  padding: 10px 16px;
  font-size: 0.85rem;
}

/* Active Filters */
.active-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.result-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.filter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--light-gray);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--body-text);
}
.filter-pill button {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1;
}
.filter-pill button:hover {
  background: var(--mid-gray);
  color: var(--body-text);
}

/* --- Map + List Layout --- */
.map-list-layout {
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 70vh;
}

.map-container {
  width: 100%;
  height: 45vh;
  min-height: 280px;
  z-index: 1;
}

/* --- Resource Panel / Drawer (mobile) --- */
.resource-panel {
  position: relative;
  background: var(--white);
  z-index: 10;
  flex: 1;
  min-height: 200px;
}

.drawer-handle {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
  cursor: grab;
}
.drawer-handle span {
  width: 36px;
  height: 4px;
  background: var(--mid-gray);
  border-radius: 2px;
}

/* Mobile: list-first, map hidden (shown in detail panel instead) */
@media (max-width: 767px) {
  .categories-label {
    padding-bottom: 10px;
  }

  .map-container {
    display: none;
  }

  .drawer-handle {
    display: none;
  }
}

.resource-list {
  overflow-y: auto;
  padding: 8px 16px 24px;
  max-height: calc(100% - 20px);
}

.resource-list-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}

/* --- Resource Card --- */
.resource-card {
  padding: 14px 16px;
  border: 1px solid var(--mid-gray);
  border-radius: var(--radius);
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.resource-card:hover,
.resource-card:focus-within,
.resource-card:focus-visible {
  border-color: var(--navy);
  box-shadow: var(--shadow-sm);
}
.resource-card:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.resource-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(135,27,28,0.2);
}

.resource-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.resource-card-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  line-height: 1.3;
  flex: 1;
}

.resource-card-distance {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  padding-top: 2px;
}

.category-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--white);
  margin-bottom: 6px;
}

.resource-card-address {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.resource-card-desc {
  font-size: 0.85rem;
  color: var(--body-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Detail Panel --- */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  z-index: 2000;
  visibility: hidden;
  pointer-events: none;
}
.detail-panel.open {
  visibility: visible;
  pointer-events: auto;
}

.detail-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.detail-panel.open .detail-panel-backdrop {
  opacity: 1;
}

.detail-panel-content {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: var(--white);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.detail-panel.open .detail-panel-content {
  transform: translateX(0);
}

.detail-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--mid-gray);
  position: relative;
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-muted);
  border-radius: 50%;
}
.detail-close:hover,
.detail-close:focus-visible {
  background: var(--light-gray);
  color: var(--body-text);
}
.detail-close:focus-visible {
  box-shadow: var(--focus-ring);
}

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 44px;
  margin-bottom: 6px;
}

.detail-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  text-transform: uppercase;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}

.detail-county-img {
  height: 28px;
  width: auto;
  flex-shrink: 0;
  object-fit: contain;
  border-radius: 3px;
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.detail-section {
  margin-bottom: 18px;
}
.detail-section:last-child {
  margin-bottom: 0;
}

.detail-label {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-value {
  font-size: 0.9rem;
  line-height: 1.5;
}
.detail-value a {
  color: var(--navy);
  text-decoration: underline;
  word-break: break-all;
}

.detail-phones {
  list-style: none;
}
.detail-phones li {
  margin-bottom: 6px;
}
.detail-phones a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  color: var(--navy);
  font-weight: 500;
  min-height: 44px;
}
.detail-phones .phone-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Detail Map Link */
.detail-map-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 4px 10px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--navy);
  background: var(--light-gray);
  border-radius: 20px;
  transition: background var(--transition);
}
.detail-map-link:hover,
.detail-map-link:focus-visible {
  background: var(--mid-gray);
}

/* Detail Map (embedded in detail body) */
.detail-map {
  width: 100%;
  height: 220px;
  border-radius: var(--radius);
  border: 1px solid var(--mid-gray);
  z-index: 0;
}

.detail-actions {
  padding: 16px 20px;
  border-top: 1px solid var(--mid-gray);
  display: flex;
  gap: 10px;
}
.detail-btn {
  flex: 1;
  text-align: center;
}

/* --- Crisis Lines Panel --- */
.crisis-line-group {
  margin-bottom: 20px;
}
.crisis-line-group:last-child {
  margin-bottom: 0;
}
.crisis-line-group-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--mid-gray);
}
.crisis-line-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--light-gray);
}
.crisis-line-item:last-child {
  border-bottom: none;
}
.crisis-line-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}
.crisis-line-phone a {
  color: var(--navy);
  font-weight: 500;
  font-size: 0.9rem;
}

/* --- Footer --- */
.site-footer {
  background: var(--navy);
  color: var(--white);
  padding: 32px 24px;
  text-align: center;
}

.footer-content {
  max-width: 640px;
  margin: 0 auto;
}

.footer-logo {
  max-height: 40px;
  margin: 0 auto 16px;
  opacity: 0.8;
}

.footer-disclaimer {
  font-size: 0.8rem;
  opacity: 0.7;
  margin-bottom: 12px;
  line-height: 1.5;
}

.footer-meta {
  font-size: 0.75rem;
  opacity: 0.5;
  margin-bottom: 8px;
}

.footer-copyright {
  font-size: 0.75rem;
  opacity: 0.5;
}

/* --- Leaflet Overrides --- */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-md) !important;
}

.leaflet-popup-content {
  margin: 12px 16px !important;
  font-family: var(--font-body) !important;
  font-size: 0.85rem !important;
  line-height: 1.4 !important;
}

.popup-provider {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.popup-address {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.popup-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.popup-actions a {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy);
  padding: 4px 0;
}
.popup-actions a:hover {
  text-decoration: underline;
}

/* Cluster icons */
.marker-cluster {
  background: rgba(11, 29, 58, 0.2) !important;
}
.marker-cluster div {
  background: var(--navy) !important;
  color: var(--white) !important;
  font-family: var(--font-heading) !important;
  font-weight: 700 !important;
}

/* Custom marker */
.custom-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid var(--white);
  box-shadow: var(--shadow-sm);
}
.custom-marker-inner {
  transform: rotate(45deg);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
}

/* User location dot */
.user-location-dot {
  width: 16px;
  height: 16px;
  background: #4285F4;
  border: 3px solid var(--white);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(66,133,244,0.3), var(--shadow-sm);
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(3); opacity: 0; }
}
.user-location-pulse {
  width: 16px;
  height: 16px;
  background: rgba(66,133,244,0.3);
  border-radius: 50%;
  animation: pulse-ring 2s ease-out infinite;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Tablet (768px+) --- */
@media (min-width: 768px) {
  .crisis-toggle {
    display: none;
  }

  .crisis-links {
    display: flex !important;
    flex-direction: row;
    justify-content: center;
    gap: 16px;
    padding: 8px 16px;
  }

  .crisis-link {
    padding: 4px 12px;
  }

  .hero {
    padding: 53px 32px 61px;
    min-height: 52vh;
  }

  .hero-logo {
    max-height: 100px;
  }

  .hero-title {
    font-size: 2.25rem;
  }

  .hero-subtitle {
    font-size: 1.1rem;
  }

  .categories-section {
    top: 40px;
  }

  .filter-bar {
    top: 40px;
    padding: 12px 24px;
  }

  .filter-bar-inner {
    flex-wrap: nowrap;
  }

  .map-container {
    height: 50vh;
  }

  .resource-panel {
    min-height: 300px;
  }

  .drawer-handle {
    display: none;
  }

  .resource-list {
    padding: 16px 24px 32px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

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

  .detail-panel-content {
    width: 480px;
  }
}

/* --- Desktop (1024px+) --- */
@media (min-width: 1024px) {
  .hero-title {
    font-size: 2.75rem;
  }

  .filter-bar {
    padding: 12px 32px;
  }

  .map-list-layout {
    flex-direction: row;
    height: 70vh;
    min-height: 500px;
  }

  .map-container {
    width: 60%;
    height: 100%;
  }

  .resource-panel {
    width: 40%;
    height: 100%;
    min-height: unset;
    border-left: 1px solid var(--mid-gray);
  }

  .resource-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 100%;
    padding: 12px 16px 24px;
  }

  .resource-card {
    margin-bottom: 8px;
  }

  .carousel-btn {
    display: flex;
  }

  .categories-label {
    padding-left: 48px; /* 32px carousel btn + 16px scroll padding = first card edge */
  }

  .categories-scroll {
    cursor: grab;
  }

  .categories-scroll.is-dragging {
    cursor: grabbing;
    user-select: none;
  }

}
