/* PawPath brand integration and defensive map sizing. */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  display: block;
  width: clamp(190px, 18vw, 250px);
  height: auto;
}

.brand-tagline {
  max-width: 150px;
  color: var(--ink-500);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.25;
}

/*
 * Give Leaflet an explicit, stable rectangle. Percentage-only map heights can
 * change after results render, leaving Leaflet with stale tile coordinates.
 */
.discovery-layout {
  height: clamp(620px, 72vh, 780px);
  min-height: 620px;
}

.map-panel {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
}

#map {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  min-height: 0;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  font: inherit;
}

.leaflet-tile-container,
.leaflet-tile {
  will-change: transform;
}

/* Phase 1 mode selector: planning first, urgent access when needed. */
.mode-selector {
  position: relative;
  z-index: 2;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  background: rgba(5, 30, 24, 0.28);
  backdrop-filter: blur(12px);
}

.mode-option {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 74px;
  padding: 12px 15px;
  border: 1px solid transparent;
  border-radius: 15px;
  background: transparent;
  color: rgba(255, 255, 255, 0.76);
  cursor: pointer;
  text-align: left;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.mode-option:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
}

.mode-option.is-active {
  background: var(--white);
  color: var(--forest-950);
  box-shadow: 0 10px 28px rgba(5, 30, 24, 0.18);
}

.mode-option:focus-visible {
  outline: 3px solid rgba(216, 148, 63, 0.72);
  outline-offset: 3px;
}

.mode-option-icon {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 13px;
  font-size: 1.15rem;
  font-weight: 900;
}

.mode-option.is-active .mode-option-icon {
  border-color: rgba(23, 63, 53, 0.16);
  background: var(--sage-100);
  color: var(--forest-900);
}

.mode-option strong,
.mode-option small {
  display: block;
}

.mode-option strong {
  font-size: 0.96rem;
  line-height: 1.2;
}

.mode-option small {
  margin-top: 3px;
  color: inherit;
  font-size: 0.76rem;
  line-height: 1.3;
  opacity: 0.78;
}

.mode-guidance {
  margin: 10px 2px 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.8rem;
}

.sr-only {
  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;
  white-space: nowrap !important;
  border: 0 !important;
}

.hero-panel[data-mode="now"] {
  background:
    radial-gradient(circle at 92% 8%, rgba(216, 148, 63, 0.34), transparent 30%),
    linear-gradient(135deg, #102d26, #285f50);
}

.hero-panel[data-mode="now"] #search-btn {
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}

.hero-panel[data-mode="now"] #search-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.hero-panel[data-mode="now"] #loc-btn {
  border-color: transparent;
  background: var(--amber-500);
  color: var(--forest-950);
}

.hero-panel[data-mode="now"] #loc-btn:hover {
  background: #e2a554;
}

@media (max-width: 780px) {
  .brand-logo {
    width: 176px;
  }

  .brand-tagline {
    display: none;
  }

  .discovery-layout {
    height: auto;
    min-height: 0;
  }

  .map-panel {
    position: relative;
    height: 54vh;
    min-height: 380px;
  }

  .mode-selector {
    border-radius: 17px;
  }

  .mode-option {
    min-height: 68px;
    padding: 10px 12px;
  }

  .mode-option-icon {
    width: 38px;
    height: 38px;
  }
}

@media (max-width: 620px) {
  .mode-selector {
    grid-template-columns: 1fr;
  }

  .mode-option {
    min-height: 62px;
  }
}

@media (max-width: 460px) {
  .brand-logo {
    width: 154px;
  }

  .status-badge {
    display: none;
  }
}

/* Facility detail drawer and transparent confidence presentation. */
.facility-detail {
  width: min(520px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  margin: 16px 16px 16px auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--white);
  color: var(--ink-900);
  box-shadow: -18px 0 60px rgba(16, 45, 38, 0.24);
}

.facility-detail::backdrop {
  background: rgba(8, 25, 21, 0.54);
  backdrop-filter: blur(3px);
}

.facility-detail[open] {
  animation: detail-drawer-in 180ms ease-out;
}

@keyframes detail-drawer-in {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.facility-detail-shell {
  display: flex;
  max-height: calc(100vh - 34px);
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  padding: 26px;
}

.facility-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.facility-detail-header h2 {
  margin: 0;
  color: var(--forest-950);
  font-size: clamp(1.45rem, 4vw, 2rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.icon-button {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--sage-50);
  color: var(--forest-900);
  cursor: pointer;
  font-size: 1.55rem;
  line-height: 1;
}

.icon-button:hover {
  background: var(--sage-100);
}

.icon-button:focus-visible {
  outline: 3px solid rgba(216, 148, 63, 0.55);
  outline-offset: 3px;
}

.facility-detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-badge {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--sage-100);
  color: var(--forest-800);
  font-size: 0.76rem;
  font-weight: 800;
}

.detail-badge[data-care-type="emergency"],
.detail-badge[data-care-type="urgent"] {
  border-color: #efc8c1;
  background: #fae6e2;
  color: var(--danger);
}

.detail-confidence[data-confidence="likely-emergency"] {
  border-color: #eccd9e;
  background: #fff2dc;
  color: #81511c;
}

.detail-confidence[data-confidence="needs-confirmation"] {
  border-color: #d8d0c1;
  background: var(--sand-100);
  color: var(--ink-700);
}

.detail-confidence[data-confidence="demo-verified"] {
  border-color: #b8d8c7;
  background: #e7f5ec;
  color: var(--forest-800);
}

.confidence-explanation {
  margin: -8px 0 0;
  color: var(--ink-700);
  font-size: 0.91rem;
}

.facility-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--border);
}

.facility-facts > div {
  min-width: 0;
  padding: 14px;
  background: var(--white);
}

.facility-facts dt {
  margin-bottom: 4px;
  color: var(--ink-500);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.facility-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink-900);
  font-size: 0.88rem;
}

.facility-facts a {
  color: var(--forest-800);
  font-weight: 750;
}

.source-disclosure {
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--sage-50);
}

.source-disclosure h3 {
  margin: 0 0 7px;
  color: var(--forest-950);
  font-size: 1rem;
}

.source-disclosure p {
  margin: 0;
  color: var(--ink-700);
  font-size: 0.86rem;
}

.source-disclosure .call-ahead-note {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.facility-detail-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  position: sticky;
  bottom: -26px;
  margin: 0 -26px -26px;
  padding: 16px 26px 24px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.facility-detail-actions .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

.detail-action-secondary {
  border-color: var(--border);
  background: var(--white);
  color: var(--forest-800);
}

.detail-action-secondary:hover {
  border-color: var(--forest-700);
  background: var(--sage-50);
}

.facility-detail-actions .is-disabled {
  border-color: var(--border);
  background: var(--sand-100);
  color: var(--ink-500);
  cursor: not-allowed;
  pointer-events: none;
}

@media (max-width: 620px) {
  .facility-detail {
    width: 100vw;
    max-height: 92vh;
    margin: auto 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 24px 24px 0 0;
  }

  .facility-detail[open] {
    animation-name: detail-sheet-in;
  }

  @keyframes detail-sheet-in {
    from {
      opacity: 0;
      transform: translateY(24px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .facility-detail-shell {
    max-height: 92vh;
    padding: 22px 18px;
  }

  .facility-facts {
    grid-template-columns: 1fr;
  }

  .facility-detail-actions {
    grid-template-columns: 1fr;
    bottom: -22px;
    margin: 0 -18px -22px;
    padding: 14px 18px 20px;
  }
}
