/* Minimal adjustments and accessibility helpers */
:root {
  --a11y-font-size: 100%;
  --ruler-top: 40vh;
  --ruler-height: 2.5rem;
}
html.a11y-text-large { --a11y-font-size: 112.5%; }
html.a11y-text-xlarge { --a11y-font-size: 125%; }
html { font-size: var(--a11y-font-size); }

html.a11y-spacing .nhsuk-body, html.a11y-spacing .nhsuk-main-wrapper {
  line-height: 1.9;
}

html.a11y-contrast body {
  filter: contrast(1.2);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
html.a11y-reduced-motion * { animation: none !important; transition: none !important; }

/* Reading ruler */
.a11y-ruler::before {
  content: "";
  position: fixed;
  left: 0; right: 0;
  height: var(--ruler-height, 2.5rem);
  top: var(--ruler-top, 40vh);
  background: rgba(0,0,0,0.08);
  pointer-events: none;
  z-index: 1000;
}

/* Underline links for readability (exclude header nav) */
html.a11y-underline-links .nhsuk-main-wrapper a,
html.a11y-underline-links .nhsuk-footer__list-item-link,
html.a11y-underline-links .nhsuk-card__link { text-decoration: underline; }

/* Limit line length for readability */
/* Limit line length only for text elements, not layout containers */
html.a11y-readable-width .nhsuk-main-wrapper h1,
html.a11y-readable-width .nhsuk-main-wrapper h2,
html.a11y-readable-width .nhsuk-main-wrapper h3,
html.a11y-readable-width .nhsuk-main-wrapper h4,
html.a11y-readable-width .nhsuk-main-wrapper p,
html.a11y-readable-width .nhsuk-main-wrapper blockquote,
html.a11y-readable-width .nhsuk-main-wrapper .nhsuk-details__text,
html.a11y-readable-width .nhsuk-main-wrapper .nhsuk-prose,
html.a11y-readable-width .nhsuk-main-wrapper article {
  max-width: 74ch;
  margin-left: auto;
  margin-right: auto;
}
/* Never constrain grid/card containers */
html.a11y-readable-width .nhsuk-card-group,
html.a11y-readable-width .nhsuk-grid-row,
html.a11y-readable-width .bnpcn-services-list,
html.a11y-readable-width .bnpcn-news-list,
html.a11y-readable-width .bnpcn-practice-list,
html.a11y-readable-width .bnpcn-signpost-list {
  max-width: none !important;
}

/* Inline Listen buttons in reading mode */
.a11y-tts-listen {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  font-size: 0.875rem;
  line-height: 1.2;
  color: #ffffff;
  background: #005eb8;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
}
.a11y-tts-listen:focus-visible { outline: 3px solid #ffbf47; outline-offset: 0; }

/* Floating mini controls shown while reading */
.a11y-tts-fab {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 1001;
  background: #ffffff;
  border: 1px solid #d8dde0;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  padding: 6px;
}
.a11y-tts-fab button {
  margin: 0 4px;
  padding: 6px 10px;
  font-size: 0.95rem;
}
@media (prefers-reduced-motion: reduce) {
  .a11y-tts-fab { transition: none; }
}

.a11y-panel[hidden] { display: none !important; }

/* Keep quick header actions visible and neat */
.nhsuk-header__content {
  margin-left: auto; /* push actions to the right */
  display: flex;
  align-items: center;
}
.bnpcn-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.bnpcn-header-actions .nhsuk-button {
  margin: 0; /* remove default margins so gap controls spacing */
  padding: 4px 10px; /* smaller header buttons */
  font-size: 1rem; /* ~16px for accessibility */
  line-height: 1.3;
}
@media (max-width: 640px) {
  .bnpcn-header-actions {
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: center; /* center quick actions on mobile */
  }
  .bnpcn-header-actions .nhsuk-button {
    display: inline-block;
    padding: 6px 12px; /* a little more space around focus ring */
    font-size: 1rem;
  }
}

/* Also center quick actions on small tablets */
@media (max-width: 1024px) {
  .nhsuk-header__content {
    margin-left: 0; /* undo desktop alignment */
    width: 100%;
    justify-content: center;
  }
  .bnpcn-header-actions {
    width: 100%;
    justify-content: center;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
  }
}

/* Do not change visited link colour globally; keep NHS blue in content */
/* Scope visited colour to main content and footer, not header navigation */
.nhsuk-main-wrapper a:visited,
.nhsuk-link:visited,
.nhsuk-footer__list-item-link:visited {
  color: #1d70b8;
}

/* Ensure top-level header navigation links remain white on the blue header */
.nhsuk-header__navigation-list > .nhsuk-header__navigation-item > .nhsuk-header__navigation-link,
.nhsuk-header__navigation-list > .nhsuk-header__navigation-item > .nhsuk-header__navigation-link:visited {
  color: #ffffff;
}

/* Header logo and service name tweaks */
.nhsuk-header__link--service {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}
.nhsuk-header__organisation-logo {
  height: 40px;
  width: auto;
  display: block;
}
.nhsuk-header__service-name {
  color: #ffffff;
  font-weight: 800;
  font-size: 1.25rem;
  line-height: 1.1;
  letter-spacing: 0.2px;
  text-wrap: balance;
}
@media (min-width: 768px) {
  .nhsuk-header__service-name { font-size: 1.5rem; }
}
@media (min-width: 992px) {
  .nhsuk-header__service-name { font-size: 1.75rem; }
}

/* Maintain clear focus outlines for accessibility */
a:focus-visible, button:focus-visible, [role="button"]:focus-visible {
  outline: 3px solid #ffbf47; /* NHS focus yellow */
  outline-offset: 0;
}

/* Always use dropdown navigation on small screens only */
.nhsuk-header__menu-toggle { cursor: pointer; }
/* Hide Menu button on desktop */
@media (min-width: 1025px) {
  .nhsuk-header__navigation .nhsuk-header__menu { display: none !important; }
}

@media (max-width: 1024px) {
  /* Show the Menu button, hide inline items until opened */
  .nhsuk-header__navigation .nhsuk-header__menu { display: block !important; }
  .nhsuk-header__navigation .nhsuk-header__navigation-item { display: none; }

  /* When open, reveal items (support both our class and NHS class) */
  .nhsuk-header__navigation.is-open .nhsuk-header__navigation-item,
  .nhsuk-header__navigation.nhsuk-header__navigation--open .nhsuk-header__navigation-item { display: block; }

  /* Ensure list becomes a dropdown panel and is scrollable */
  .nhsuk-header__navigation.is-open .nhsuk-header__navigation-list,
  .nhsuk-header__navigation.nhsuk-header__navigation--open .nhsuk-header__navigation-list {
    display: block;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  }

  /* Center the Menu button on small screens and give comfortable hit area */
  .nhsuk-header__navigation .nhsuk-header__menu {
    display: flex !important;
    justify-content: center;
    width: 100%;
  }
  .nhsuk-header__menu-toggle {
    display: inline-block;
    padding: 8px 14px; /* add padding around focus ring */
    border-radius: 4px;
    line-height: 1.4;
  }
  /* Keep Menu button visible while scrolling panel */
  .nhsuk-header__navigation.is-open .nhsuk-header__menu,
  .nhsuk-header__navigation.nhsuk-header__navigation--open .nhsuk-header__menu {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #ffffff;
    border-bottom: 1px solid #d8dde0;
  }
}

/* Mobile and tablet dropdown styling */
@media (max-width: 1024px) {
  /* Dropdown container visuals when open */
  .nhsuk-header__navigation.is-open,
  .nhsuk-header__navigation.nhsuk-header__navigation--open {
    background: #ffffff;
  }
  .nhsuk-header__navigation.is-open .nhsuk-header__navigation-container,
  .nhsuk-header__navigation.nhsuk-header__navigation--open .nhsuk-header__navigation-container {
    padding-left: 1rem; /* equal horizontal spacing */
    padding-right: 1rem;
    box-sizing: border-box;
  }
  .nhsuk-header__navigation.is-open .nhsuk-header__navigation-list,
  .nhsuk-header__navigation.nhsuk-header__navigation--open .nhsuk-header__navigation-list {
    margin: 1rem 0 0; /* horizontal margin via container padding, plus top space */
    padding: 0;
    border: 1px solid #d8dde0; /* light grey divider */
    border-radius: 4px;
    overflow: hidden; /* keep borders tidy */
    background: #ffffff;
  }

  /* Centered items with clear dividers */
  .nhsuk-header__navigation.is-open .nhsuk-header__navigation-item,
  .nhsuk-header__navigation.nhsuk-header__navigation--open .nhsuk-header__navigation-item {
    display: block;
    text-align: center;
    border-top: 1px solid #d8dde0;
  }
  .nhsuk-header__navigation.is-open .nhsuk-header__navigation-item:first-of-type,
  .nhsuk-header__navigation.nhsuk-header__navigation--open .nhsuk-header__navigation-item:first-of-type {
    border-top: 0;
  }

  /* Override header white link colour for dropdown on light background */
  .nhsuk-header__navigation.is-open .nhsuk-header__navigation-list > .nhsuk-header__navigation-item > .nhsuk-header__navigation-link,
  .nhsuk-header__navigation.is-open .nhsuk-header__navigation-list > .nhsuk-header__navigation-item > .nhsuk-header__navigation-link:visited,
  .nhsuk-header__navigation.nhsuk-header__navigation--open .nhsuk-header__navigation-list > .nhsuk-header__navigation-item > .nhsuk-header__navigation-link,
  .nhsuk-header__navigation.nhsuk-header__navigation--open .nhsuk-header__navigation-list > .nhsuk-header__navigation-item > .nhsuk-header__navigation-link:visited {
    display: block;
    padding: 12px 16px;
    color: #1d70b8; /* NHS blue */
    background: #ffffff;
  }
  .nhsuk-header__navigation.is-open .nhsuk-header__navigation-list > .nhsuk-header__navigation-item > .nhsuk-header__navigation-link:hover,
  .nhsuk-header__navigation.nhsuk-header__navigation--open .nhsuk-header__navigation-list > .nhsuk-header__navigation-item > .nhsuk-header__navigation-link:hover {
    background: #f3f2f1; /* light grey hover */
    text-decoration: none;
  }
}

/* Responsive map embed for Find your practice */
.map-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #f3f2f1;
  border: 1px solid #d8dde0;
  border-radius: 4px;
  overflow: hidden;
}
.map-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
@media (max-width: 640px) {
  .map-embed { aspect-ratio: 4 / 3; }
}

/* Static map image wrapper */
.map-static {
  margin: 0; /* use figure spacing from NHS styles where needed */
  padding: 0;
  border: 1px solid #d8dde0;
  border-radius: 4px;
  overflow: hidden;
  background: #f3f2f1;
}
.map-static img {
  display: block;
  width: 100%;
  height: auto;
}

/* Equal-height practice cards and centered last row */
.bnpcn-card-group--center {
  justify-content: center;
}
.bnpcn-practice-list .nhsuk-card-group__item {
  display: flex;
}
.bnpcn-practice-list .nhsuk-card {
  display: flex;
  flex-direction: column;
  width: 100%;
}
.bnpcn-practice-list .nhsuk-card__content {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.bnpcn-practice-list .bnpcn-card-actions {
  margin-top: auto;
  padding-top: 12px; /* ensure a visual gap from preceding content */
  border-top: 1px solid #d8dde0; /* light divider above actions */
}
/* Enforce equal widths for cards at breakpoints */
.bnpcn-practice-list {
  display: flex;
  flex-wrap: wrap;
}
.bnpcn-practice-list .nhsuk-card-group__item {
  flex: 0 1 100%;
  box-sizing: border-box;
}
@media (min-width: 641px) {
  .bnpcn-practice-list .nhsuk-card-group__item { flex: 0 1 50%; }
}
@media (min-width: 1024px) {
  .bnpcn-practice-list .nhsuk-card-group__item { flex: 0 1 33.3333%; }
}

/* Equal-height services cards and tidy desktop spacing */
.bnpcn-services-list { display: flex; flex-wrap: wrap; }
.bnpcn-services-list .nhsuk-card-group__item { display: flex; flex: 0 1 100%; box-sizing: border-box; }
.bnpcn-services-list .nhsuk-card { display: flex; flex-direction: column; width: 100%; }
.bnpcn-services-list .nhsuk-card__content { display: flex; flex-direction: column; flex: 1; }
.bnpcn-services-list .nhsuk-card__description { margin-top: 6px; }
@media (min-width: 641px) {
  .bnpcn-services-list .nhsuk-card-group__item { flex: 0 1 50%; }
}
@media (min-width: 1024px) {
  .bnpcn-services-list .nhsuk-card-group__item { flex: 0 1 33.3333%; }
}

/* Equal-width signpost cards on service pages (2-up on desktop) */
.bnpcn-signpost-list { display: flex; flex-wrap: wrap; }
.bnpcn-signpost-list .nhsuk-card-group__item { display: flex; flex: 0 1 100%; box-sizing: border-box; }
.bnpcn-signpost-list .nhsuk-card { display: flex; flex-direction: column; width: 100%; }
.bnpcn-signpost-list .nhsuk-card__content { display: flex; flex-direction: column; flex: 1; }
@media (min-width: 641px) {
  .bnpcn-signpost-list .nhsuk-card-group__item { flex: 0 1 50%; }
}
@media (min-width: 1024px) {
  .bnpcn-signpost-list .nhsuk-card-group__item { flex: 0 1 50%; }
}

/* Invisible filler maintains equal column width without visual content */
.bnpcn-card-filler { visibility: hidden; pointer-events: none; }
.bnpcn-card-filler .nhsuk-card { background: transparent; border-color: transparent; box-shadow: none; }

/* News cards: airy, legible, equal columns */
.bnpcn-news-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.bnpcn-news-list .nhsuk-card-group__item { display: flex; }
.bnpcn-news-card { display: flex; flex-direction: column; width: 100%; border-top: 4px solid #005eb8; background: #ffffff; }
.bnpcn-news-card .nhsuk-card__content { display: flex; flex-direction: column; flex: 1; padding-top: 16px; }
.bnpcn-news-card .nhsuk-card__img img { width: 100%; height: auto; display: block; }
.bnpcn-news-card .nhsuk-card__img { aspect-ratio: 16 / 9; overflow: hidden; border-bottom: 1px solid #d8dde0; }
.bnpcn-news-card .nhsuk-card__img img { width: 100%; height: 100%; object-fit: cover; }
.bnpcn-news-card .nhsuk-card__heading { margin-bottom: 8px; }
.bnpcn-news-card .nhsuk-card__description { margin-top: 4px; }
.bnpcn-news-card--featured {
  border-top-color: #ffb81c;
  background: linear-gradient(180deg, #fff9e5 0%, #ffffff 82%);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.bnpcn-news-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.bnpcn-news-card__header .nhsuk-card__heading {
  margin-bottom: 0;
  flex: 1 1 auto;
}

.bnpcn-news-card__header .nhsuk-tag {
  margin-top: 4px;
  white-space: nowrap;
}

.bnpcn-news-card--featured .bnpcn-news-featured {
  background-color: #ffb81c;
  color: #212b32;
}
.bnpcn-news-card:hover,
.bnpcn-news-card:focus-within { box-shadow: 0 1px 0 rgba(0,0,0,0.04), 0 6px 20px rgba(0,0,0,0.08); transition: box-shadow .2s ease; }
@media (min-width: 641px) {
  .bnpcn-news-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1280px) {
  .bnpcn-news-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Keep Home page latest news at two columns on wide screens */
@media (min-width: 1280px) {
  .bnpcn-news-list--home { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Featured tag spacing on cards */
.bnpcn-news-featured { margin-right: 4px; }

/* Improve visibility of multi-select controls in admin */
.nhsuk-select[multiple] {
  min-height: 12rem;
}

