/* ----- Base helpers ----- */
.is-hidden { display: none !important; }
.sr-only { position: absolute; left: -9999px; }

/* -----------------------------------------
   Typeahead, hero search
------------------------------------------ */
.tc-search {
  position: relative;
  width: 100%;
  max-width: 620px;
  margin: 0 0 24px;
}

.tc-input {
  width: 80%;
  padding: 12px 14px;
  font-size: 16px;
  color: #fff;
  background: #222;
  border: 1px solid #444;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.tc-input:focus {
  border-color: #3a8ef6;
  box-shadow: 0 0 0 3px rgba(58, 142, 246, 0.3);
}

.tc-list {
  position: absolute;
  z-index: 9999;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-top: none;
  max-height: 280px;
  overflow-y: auto;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
  border-radius: 0 0 6px 6px;
  font-size: 15px;
}
.tc-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: baseline;
  transition: background 0.2s ease;
}
.tc-item .town { font-weight: 600; color: #222; }
.tc-item .sep { opacity: .5; }
.tc-item .county { opacity: .75; }
.tc-item:hover,
.tc-item[aria-selected="true"] { background: #f0f4fa; }
.tc-empty { padding: 10px 14px; color: #777; font-style: italic; }

/* -----------------------------------------
   “Latest Clinics” cards grid
------------------------------------------ */
.half {
  flex: 0 0 100%;
  max-width: 100%;
  margin: 0 0 20px;
  display: flex;
}
@media (min-width: 640px) {
  .half {
    flex: 0 0 48%;
    max-width: 48%;
    margin: 0 1% 30px;
  }
}

/* Card */
.card {
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}
.card-inner {
  display: flex;
  gap: 16px;
  padding: 16px;
  flex: 1;
  min-width: 0; /* prevent overflow in Safari */
}
.card-inner img {
  width: 150px;
  height: auto;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}
.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.card-body h3 {
  font-size: 1.125rem;
  color: #111827;
  margin: 0 0 6px;
  line-height: 1.3;
}
.rating {
  color: #ffc107;
  font-size: 1rem;
  margin-top: 8px;
  text-align: left;
}
.clinic { font-size: 0.95rem; font-weight: 600; color: #6b7280; margin-bottom: 6px; }
.details-list { font-size: 0.95rem; color: #374151; }

.card-footer {
  padding: 12px 16px 16px;
  border-top: 1px solid #eef2f7;
}

/* unified button group */
.button-group {
  display: flex;
  gap: 12px;
  width: 100%;
  align-items: stretch;
}
.button-group > * {
  flex: 1 1 50%;
  display: flex;
  margin: 0;
}
.button-group > * > button,
.button-group > * > a,
.button-group > a {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  width: 100%;
  padding: 0 16px;
  box-sizing: border-box;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  background: #fff;
  color: #111827;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .05s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
}
.button-group > * > button { appearance: none; -webkit-appearance: none; border: 1px solid transparent; font: inherit; color: inherit; }

/* variants */
.button-group > :first-child > button {
  border-color: #28a745;
  background: rgba(40,167,69,0.08);
  color: #1f7a33;
}
.button-group > :first-child > button:hover {
  background: #28a745; color: #fff; box-shadow: 0 4px 12px rgba(40,167,69,.25);
}
.button-group > a,
.button-group > :last-child > a {
  border-color: #663399;
  background: rgba(102,51,153,0.08);
  color: #4b2777;
}
.button-group > a:hover,
.button-group > :last-child > a:hover {
  background: #663399; color: #fff; text-decoration: none; box-shadow: 0 4px 12px rgba(102,51,153,.25);
}
.button-group a:active,
.button-group button:active { transform: translateY(1px); }

/* Responsive tweaks for clinic card */

@media (max-width: 768px) {
  .card-inner { flex-direction: column; align-items: center; text-align: center; }
  .rating { text-align: center; }
  .card-inner img {
    width: 100%;

  }
}

/* -----------------------------------------
   Search filters above counties grid
------------------------------------------ */
.search-filters {
  background: #fff;
  padding: 1.25rem;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 1.5rem;
}
.search-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 220px;
  padding: 0.75rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s ease;
}
.search-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.results-info { margin: 0.75rem 0 1.25rem; }
.results-count { font-size: 0.9rem; color: #64748b; }

/* -----------------------------------------
   Counties grid and cards
------------------------------------------ */
.counties-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 560px) {
  .counties-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }
}
@media (min-width: 900px) {
  .counties-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
  }
}
@media (min-width: 1200px) {
  .counties-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.25rem;
  }
}

/* allow items to shrink within grid tracks across browsers */
.county-card { min-width: 0; }

.county-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.06s ease, border-color 0.2s ease;
}
.county-card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,0.10);
  border-color: #dbe3ef;
}
.county-card:active { transform: translateY(1px); }

.county-header {
  padding: 1.25rem 1.25rem 0.75rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
}
.county-title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.county-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
  text-decoration: none;
  transition: color 0.2s ease;
}
.county-name:hover, .county-name:focus { color: #3b82f6; }
.county-meta { font-size: 0.9rem; color: #64748b; }

/* Towns section inside county card */
.towns-section { padding: 0.85rem 1.25rem 1.25rem 1.25rem; }

.towns-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.75rem;
}

.towns-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.town-tag {
  background: #f8fafc;
  color: #475569;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.05s ease;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  line-height: 1.15;
}
.town-tag:hover,
.town-tag:focus {
  background: #e9eef6;
  color: #374151;
  border-color: #d5deec;
  text-decoration: none;
}
.town-tag:active { transform: translateY(1px); }

/* -----------------------------------------
   Legacy grouped list helpers
------------------------------------------ */
.county-wrap { display: block; width: 100%; }
.county-block { display: block; width: 100%; clear: both; margin: 0 0 24px; }
.county-heading { display: block; width: 100%; clear: both; margin: 0 0 8px; }
.town-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 16px; }
.town-list li { margin: 0; padding: 0; }
.town-list li span { margin-right: 4px; }

/* -----------------------------------------
   Minor header image responsiveness
------------------------------------------ */
@media (max-width: 768px) {
  header .third img {
    width: 100%;
    height: auto;
  }
}

/* -----------------------------------------
   Small visual polish for contrast
------------------------------------------ */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(59,130,246,0.4);
  outline-offset: 2px;
}
