/* Keep the wide season table inside its own scroll area on Wellness pages. */
body.wl #main .wl-cal-scroll {
  min-width: 0; max-width: 100%; contain: layout paint;
}

/* Shared directory controls: compact search and aligned filter fields. */
body:not(.wl) #main .directory-toolbar-slim,
body:not(.wl) #main .directory-toolbar-slim:has(.provider-city-filter) {
  grid-template-columns: minmax(0, 4fr) minmax(0, 3fr);
  max-width: none;
  gap: 8px 12px;
  align-items: end;
}
body:not(.wl) #main .directory-toolbar-slim:has(.provider-city-filter) {
  grid-template-columns: minmax(0, 4fr) minmax(0, 3fr) minmax(0, 3fr);
}
body:not(.wl) #main .directory-toolbar-slim > :is(.filter-bar,.provider-city-filter,.medical-treatment-specialty) {
  grid-column: auto;
  grid-row: auto;
  min-width: 0;
  margin: 0;
}
body:not(.wl) #main .directory-toolbar-slim > .filter-bar { order: 0; }
body:not(.wl) #main .directory-toolbar-slim > .provider-city-filter { order: 1; }
body:not(.wl) #main .directory-toolbar-slim > .medical-treatment-specialty { order: 2; }
body:not(.wl) #main .directory-toolbar-slim > .medical-result-status {
  order: 3;
  grid-column: 1 / -1;
}
body:not(.wl) #main .directory-toolbar-slim .provider-city-filter label {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
body:not(.wl) #main .directory-toolbar-slim :is(.search-input-wrap,.medical-select-trigger,select) {
  height: 44px !important;
  min-height: 44px !important;
  max-height: 44px;
  box-sizing: border-box;
}
body:not(.wl) #main .directory-toolbar-slim .search-input-wrap .icon {
  width: 16px; height: 16px; flex: 0 0 16px;
}
body:not(.wl) #main .directory-toolbar-slim > [hidden] { display: none !important; }
@media (max-width: 768px) {
  body:not(.wl) #main .directory-toolbar-slim,
  body:not(.wl) #main .directory-toolbar-slim:has(.provider-city-filter) {
    grid-template-columns: minmax(0, 1fr);
  }
  body:not(.wl) #main .directory-toolbar-slim > :is(.filter-bar,.provider-city-filter,.medical-treatment-specialty,.medical-result-status),
  body:not(.wl) #main .directory-toolbar-slim:has(.provider-city-filter) > :is(.provider-city-filter,.medical-treatment-specialty,.medical-result-status) {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}

/* Consolidated from homepage-hospital-mobile.css */
/* Only the homepage hospital preview changes; directory and desktop stay intact. */
@media (max-width: 768px) {
  body:not(.wl) #main .medical-hospital-carousel:has(#hospRail) {
    min-width: 0;
    max-width: 100%;
    padding: 0;
  }
  body:not(.wl) #main #hospRail {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 12px;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    padding: 4px 0 12px;
    overscroll-behavior-x: contain;
  }
  body:not(.wl) #main #hospRail > .rd-hcard {
    flex: 0 0 calc(100% - 28px);
    width: calc(100% - 28px);
    min-width: 0;
    height: auto;
    scroll-snap-align: start;
    box-sizing: border-box;
  }
  body:not(.wl) #main .medical-hospital-carousel:has(#hospRail) .rd-rail-btns {
    display: flex;
    position: static;
    order: -1;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 8px;
    pointer-events: auto;
  }
  body:not(.wl) #main .medical-hospital-carousel:has(#hospRail) .rd-rail-btns button {
    position: static;
    transform: none;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
  }
}

/* Consolidated from care-way-icons.css */
/* A consistent Massvaa teal line style, scoped to the homepage information cards. */
body:not(.wl) #main .massvaa-care-links .massvaa-care-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #cbdfe5;
  background: #eef6f8;
  color: #145e7a;
  box-sizing: border-box;
}
.massvaa-care-icon { width: 24px; height: 24px; flex-shrink: 0; }
body:not(.wl) #main .massvaa-care-links > .rd-brand-card > span { color: #145e7a; }

/* Consolidated from layout-alignment.css */
/* Shared alignment corrections. Keep each theme's colours, type and section rhythm. */
body #main :is(.rd-explorer,.content-grid,.rd-split,.rd-contact-grid,.rd-est-grid,.wl-page-grid,.wl-faq) > * {
  min-width: 0;
}
body #main :is(.rd-head,.section-heading,.wl-programme-head) > * { min-width: 0; }
body:not(.wl) #main .rd-head { align-items: flex-start; }
body:not(.wl) #main .rd-head > div > .rd-h2 { margin-bottom: 0; }
body:not(.wl) #main .rd-head > .rd-lead { margin-block: 0; }

/* A centred heading needs a centred paragraph too, even when it has a text measure. */
body:not(.wl) #main .rd-est-grid > div:first-child:not(.rd-est) > .rd-lead {
  margin-inline: auto;
}
body:not(.wl) #main #estimator .rd-est { max-width: none; }
body:not(.wl) #main .rd-est-grid > .rd-est { align-self: stretch; min-width: 0; }

/* Preserve the asymmetric navigation/content proportions, but align their outer edges. */
@media (min-width: 1101px) {
  body:not(.wl) #main #specialties.medical-specialty-redesign .rd-explorer { align-items: stretch; }
  body:not(.wl) #main #specialties.medical-specialty-redesign .rd-explorer > div:has(> .rd-panel) {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  body:not(.wl) #main #specialties.medical-specialty-redesign .rd-panel:not([hidden]),
  body:not(.wl) #main #specialties.medical-specialty-redesign .rd-panel-body {
    display: flex;
    flex-direction: column;
    flex: 1;
  }
  body:not(.wl) #main #specialties.medical-specialty-redesign .rd-panel-actions { margin-top: auto; }
  body:not(.wl) #main #specialties.medical-specialty-redesign .medical-specialty-sidebar {
    display: flex;
    flex-direction: column;
    padding: 20px;
    border: 1px solid var(--rd-line);
    border-radius: 26px;
    background: #fff;
    box-sizing: border-box;
  }
  body:not(.wl) #main #specialties.medical-specialty-redesign .medical-specialty-sidebar .medical-more-button {
    margin-top: auto;
  }
  body:not(.wl) #main #specialties.medical-specialty-redesign .rd-spec-list { margin-bottom: 14px; }
}
body:not(.wl) #main #specialties.medical-specialty-redesign .medical-specialty-overview {
  grid-template-columns: minmax(0,1fr) 120px;
  gap: 20px;
  margin-bottom: 16px;
}
body:not(.wl) #main #specialties.medical-specialty-redesign .rd-panel-art { width: 120px; height: 120px; }
body:not(.wl) #main #specialties.medical-specialty-redesign .rd-panel-actions > a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  box-sizing: border-box;
}

/* Let content grow without moving neighbouring cards' actions to different heights. */
body #main :is(.rd-hcard,.rd-doc,.wl-prog):not([hidden]) { display: flex; flex-direction: column; }
body #main :is(.rd-hcard-body,.rd-doc-body,.wl-prog-body) {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
body #main :is(.rd-hcard-img,.rd-doc-img,.wl-prog-band) { flex-shrink: 0; }
body #main :is(.rd-hcard-actions,.rd-txcard-actions) { margin-top: auto; }
body:not(.wl) #main :is(.hospital-card,.doctor-card) > .provider-card-actions { margin-top: auto; }
body:not(.wl) #main .doctor-card > div:last-child { margin-top: auto; }
body.wl #main .wl-prog-body > .wl-tags { margin-top: auto; }
body #main .rd-brand-cards > .rd-brand-card { display: flex; flex-direction: column; min-width: 0; }
body #main .rd-brand-cards > .rd-brand-card > span:last-child { margin-top: auto; padding-top: 10px; }
body #main :is(.rd-hcard-body,.rd-doc-body,.wl-prog-body,.wl-card-body) :is(h3,p) { overflow-wrap: anywhere; }
body #main :is(.rd-panel-actions,.wl-prog-actions) { flex-wrap: wrap; }
body #main :is(.rd-panel-actions,.wl-prog-actions) > a { max-width: 100%; min-width: 0; }

@media (max-width: 768px) {
  body:not(.wl) #main .rd-head > .rd-lead { margin-top: 10px; }
  body:not(.wl) #main #specialties.medical-specialty-redesign .medical-specialty-overview {
    grid-template-columns: minmax(0,1fr) 88px;
    gap: 12px;
    align-items: start;
  }
  body:not(.wl) #main #specialties.medical-specialty-redesign .rd-panel-art { width: 88px; height: 88px; }
  body:not(.wl) #main #specialties.medical-specialty-redesign .rd-panel-actions { align-items: stretch; }
}
/* Discovery artwork scales with the wider cards across Medical routes. */
body:not(.wl).medical-refined #main .medical-task-links .medical-task-sticker {
  width: 100%;
  max-width: 100%;
  height: clamp(144px, 12vw, 216px);
  object-fit: contain;
  justify-self: center;
}
@media (min-width: 769px) {
  body:not(.wl).medical-refined #main .medical-task-links a {
    min-height: 0;
    grid-template-rows: auto auto;
    align-content: start;
  }
}
@media (max-width: 768px) {
  body:not(.wl).medical-refined #main .medical-task-links .medical-task-sticker {
    width: clamp(88px, 24vw, 128px);
    height: clamp(88px, 24vw, 128px);
    flex: 0 0 auto;
  }
}
@media (max-width: 380px) {
  body:not(.wl) #main #specialties.medical-specialty-redesign .medical-specialty-overview { grid-template-columns: minmax(0,1fr); }
  body:not(.wl) #main #specialties.medical-specialty-redesign .rd-panel-art { justify-self: center; }
}
