/* html only — a body fixed at 100% is one screen tall, which stops the sticky
   header (header.css) at the end of the first screen. Body's min-height below
   keeps the footer down on short pages. */
html {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--background-color, #fff);
}

/* <main> takes the spare height, so on short pages (e.g. the 404) the footer
   sits at the bottom of the window rather than riding up under the content. */
main {
  flex: 1;
}

aside {
  width: 100%;
}

.container {
  width: min(100% - calc(var(--space-md) * 2), var(--container-width));
  margin-inline: auto;
}

.container-narrow {
  width: min(100% - calc(var(--space-md) * 2), 62rem);
  margin-inline: auto;
}

.grid {
  display: grid;
  gap: var(--space-md);
}

.stack > * + * {
  margin-top: var(--space-md);
}

.flex {
  display: flex;
  gap: var(--space-sm);
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.center {
  align-items: center;
  justify-content: center;
}

.section {
  /* One value for a section's vertical spacing, stepped up at the breakpoints
     below. A plain section spends it as outer margin; a banded one (grey) as
     inner padding, so its colour runs edge to edge with the same rhythm. */
  --section-space: var(--space-lg);
  margin-top: var(--section-space);
  margin-bottom: var(--section-space);
}

/* ACF page sections (`page-section`, added by wibn_section_classes()): roomier
   below desktop. The gap between them must stay well clear of the gaps INSIDE
   a section (12–20px on phones) — at --space-lg (32px) phone sections ran
   together. The internal pages' header → title band keeps --space-lg. */
.page-section {
  --section-space: var(--space-xl);
}

/* Grey band — the shared `background` option on page sections (set by the
   partial). Adjacent sections' margins still separate it from them. */
.section--grey {
  margin-block: 0;
  padding-block: var(--section-space);
  background: color-mix(in srgb, var(--grey-10) 60%, var(--background-color));
}

/* Consecutive grey sections read as one band: the join loses both sections'
   padding and keeps just an in-section --space-md gap. */
.section--grey:has(+ .section--grey) {
  padding-bottom: 0;
}

.section--grey + .section--grey {
  padding-top: var(--space-md);
}

/* Purple band — same spacing as the grey band, reversed-out text. Headings
   follow the band's white (the component copy colours are reset alongside each
   component, e.g. Media and Text in sections.css). Never joins a neighbour. */
.section--purple {
  margin-block: 0;
  padding-block: var(--section-space);
  background: var(--secondary-color);
  color: var(--white);
}

.section--purple :is(h1, h2, h3, h4, h5, h6) {
  color: inherit;
}

/* A title band in a section of its own — the Page Title section, or a route's
   automatic band split off when its matching Page puts sections above the list
   (route-page.php): the band's own margin sets the gap to the next section, as
   it does down to the content on every other page. */
:is(.page-title-section, .route-page-head) {
  margin-bottom: 0;
}

:is(.page-title-section, .route-page-head) + .section {
  margin-top: 0;
}

/* A Media and Text section that OPENS the page carrying its h1 stands in for
   the title band, so the header → it gap is the band's (the plain section's
   --space-lg) rather than the page section's roomier --space-xl — otherwise
   these pages start 16px lower on phones and tablets than every page with a
   band. Only the gap above changes; from 62rem the two values are the same.
   Grey / purple openers are left alone (they sit on the header and spend the
   space as padding). */
@media (max-width: 61.99rem) {
  #main > .video-text:first-child:has(h1.video-text__heading):not(.section--grey, .section--purple) {
    margin-top: var(--space-lg);
  }
}

/* A route's list on a grey band straight under its title band (route-page.php):
   the band's top padding drops to the same --space-md-lg-d, so title → band
   edge → search field → cards step evenly. Further down a page the list keeps
   the normal section padding. The /meetings/online groups section takes the
   grey band in the list's place (template-meetings.php), so it's here too. */
:is(.page-title-section, .route-page-head) + :is(.route-list, .meetings-groups).section--grey {
  padding-top: var(--space-md-lg-d);
}

.space-sm,
.space-md,
.space-md-lg-d {
  display: block;
  width: 100%;
}

.space-sm {
  height: var(--space-sm);
}

.space-md {
  height: var(--space-md);
}

/* List pages: search field → cards, the same gap as title band → field. */
.space-md-lg-d {
  height: var(--space-md-lg-d);
}

@media (min-width: 48rem) {
  .flex {
    flex-wrap: wrap;
  }
}

@media (min-width: 62rem) {
  aside {
    width: 33%;
  }
  .section {
    --section-space: var(--space-xl);
  }
}

@media (min-width: 75rem) {
  .section {
    --section-space: var(--space-xxl);
  }
}

/* Media fill — an image that fills its box, cropped to fit (object-fit: cover).
   The img is absolutely positioned, so it never sets the box's height: the box
   takes the 3:2 ratio below (override per use with --media-fill-ratio), and a
   component can instead stretch it to its neighbour's height by setting
   `aspect-ratio: auto; align-self: stretch` (Media and Text, Story Card). */
.media-fill {
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--media-fill-ratio, 3 / 2);
}

.media-fill img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Internal header — reusable page-title band (icon + h1, with optional actions
   on the right). Owns its own layout and the spacing down to the page content,
   so every template that uses it lines up the same. */

.internal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md-lg-d);
}

/* Page title (page-title.php — every internal page: news, members, groups, search,
   meetings, booking results, group / member singles, map; event uses the same
   markup): icon in a brand disc (.icon-rev), or a member's avatar, beside the
   h1. Sizes, gap and title step are the --page-title-* tokens (vars.css).

   Alignment: the text is centred on the disc while it fits within the disc's
   height, and top-aligned with it once it's taller (a wrapping title, an event's
   "Hosted by" line + status pill) — so the disc never drifts down a tall block.
   Done by top-aligning the row and giving the text a min-height of the disc
   (--page-title-lead) with its content centred inside. */
.page-title {
  --page-title-lead: var(--page-title-icon-size);
  display: flex;
  align-items: flex-start;
  gap: var(--page-title-gap);
  min-width: 0;
}

.page-title:has(> .page-title__avatar) {
  --page-title-lead: var(--page-title-avatar-size);
}

.page-title > h1,
.page-title__text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: var(--page-title-lead);
  min-width: 0;
}

.page-title h1 {
  margin: 0;
  font-size: var(--page-title-fs);
  line-height: var(--page-title-lh);
  letter-spacing: var(--page-title-ls);
}

.page-title__badge {
  flex-shrink: 0;
  display: inline-flex;
  color: var(--primary-color); /* disc colour for .icon-rev */
}

.page-title__badge svg {
  width: var(--page-title-icon-size);
  height: var(--page-title-icon-size);
}

/* A member's avatar in place of the disc (member single). Its own size, not
   the profile cards' (cards.css); initials scale with it. */
.page-title__avatar {
  flex-shrink: 0;
}

.page-title__avatar :is(.avatar, .initials) {
  width: var(--page-title-avatar-size);
  height: var(--page-title-avatar-size);
}

.page-title__avatar .initials {
  font-size: var(--page-title-initials-fs);
}

.page-title__text {
  gap: var(--space-xs);
}

/* The line under the h1: the event's "Hosted by …" (its lead-in italic, the
   group links regular) — --font-sm below desktop. --label = the member's job
   title, a small-uppercase purple label (the .testimonial-card__business look).
   That one sits on a white card; here it's on the off-white page, where plain
   --secondary-color is 4.3:1, so the purple is mixed 30% toward the text
   colour (≈5.8:1, AA) — the same mix as the map card's tinted labels. */
.page-title__subtitle {
  margin: 0;
  font-size: var(--font-sm);
}

.page-title__lead-in {
  font-style: italic;
}

.page-title__subtitle--label {
  font-weight: 700;
  letter-spacing: var(--label-letter-spacing);
  text-transform: uppercase;
  color: color-mix(in srgb, var(--secondary-color) 70%, var(--text-color));
}

@media (min-width: 62rem) {
  .page-title__subtitle:not(.page-title__subtitle--label) {
    font-size: inherit; /* body size from desktop */
  }
}

/* Single Post layout */

.single-post {
  flex-direction: column;
}

/* NB: WordPress also puts `single-post` on <body> for every single post, so the
   column sizing below MUST be scoped to the article element. */
article.single-post {
  /* The article is the centred column (the same sizing .rich-text uses on its
     own). Only .single-post-content carries .rich-text, so the prose rules —
     underlined links, heading rhythm, etc. — don't reach the intro (breadcrumb,
     title, excerpt, author line). */
  width: min(100% - calc(var(--space-md) * 2), 62rem);
  margin-inline: auto;
}

/* Already inside the sized column — don't apply .rich-text's own width again.
   width: 100%, not auto: the article is a flex column, so a stretched width isn't
   known when the item's height is measured — a width-driven embed inside (a 16:9
   video iframe, see rich-text.css) is measured too short and overflows onto
   whatever follows. Same reason as .single-post-img's width below. */
article.single-post .rich-text {
  width: 100%;
  margin-inline: 0;
}

/* Featured image: a fixed 2:1 frame so every post gets the same hero however
   the thumbnail is shaped. The image is CONTAINED (never cropped — legacy
   thumbnails often have the title baked in), centred over a blurred, scaled copy of itself
   (--hero-bg, set inline in single.php) that fills the rest of the frame. */
.single-post-img {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  /* .single-post is a flex column: a stretched width doesn't feed aspect-ratio there,
     so state the width, and stop the frame shrinking below its ratio. */
  width: 100%;
  flex: none;
  aspect-ratio: 2 / 1;
  margin-block: var(--space-md);
  border-radius: var(--br-md);
  background-color: var(--grey-10);
}

.single-post-img::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--hero-bg) center / cover no-repeat;
  filter: blur(24px);
  transform: scale(1.15); /* hide the blur's soft edge */
}

/* Absolutely placed so the frame's height comes from the ratio alone, not from
   the image's own (intrinsic) size. */
.single-post-img img {
  position: absolute;
  inset: 0;
  margin: auto;
  width: auto;
  max-width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Images already close to the frame's 2:1 (single.php decides) fill it instead —
   a slight crop beats thin blurred bars at the sides. */
.single-post-img--fill img {
  width: 100%;
  object-fit: cover;
}

.single-post-intro {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.single-post-intro p {
  margin-top: 0;
}

/* Metadata row (post meta, card meta, …) */
.meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* .meta-item = a block-level meta entry (use it instead of a span when it holds
   the member-identity avatar, a <div> — a div can't sit inside a span). */
.meta span,
.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-size: var(--font-sm);
}

.single-post-meta-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
}

/* Author avatar in a meta row (blog byline + news cards): the member-identity
   avatar/initials, shrunk to sit beside the name (overrides the 95px card size). Sized in em so it follows the meta text; .initials sets
   its own smaller font-size, so its box is scaled up to match (2.8 × 0.8em ≈ 2.25em). */
.meta .avatar,
.meta .initials {
  width: 2.25em;
  height: 2.25em;
  flex-shrink: 0;
}

.meta .initials {
  font-size: 0.8em;
  width: 2.8em;
  height: 2.8em;
}

.single-post-meta-link {
  transition: color var(--duration) var(--ease);
  color: var(--grey-40);
}

/* Header meta row (post-header.php): byline left; category button, date and read
   time right (a plain .meta row — the button is the shared .button.small.secondary). */
.single-post-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--grey-20); /* same light rule as .post-nav */
}

.single-post-byline .single-post-meta-link {
  color: var(--text-color);
}

/* Date / read-time are .button.inactive pills but not controls: drop the
   hover/pink state and the white fill. */
.single-post-meta-row .button.inactive {
  pointer-events: none;
  background: transparent;
}

/* Bigger avatar in the post header than the shared .meta size (2.25em). The
   initials keep the shared 2.8em box but on a larger font (1.15 × 2.8 ≈ 3.25em),
   so the letters scale with the circle. */
.single-post-byline .avatar {
  width: 3.25em;
  height: 3.25em;
}

.single-post-byline .initials {
  font-size: 1.15em;
}

.single-post-byline :is(.single-post-meta-link, .meta-item) {
  gap: 0.75em;
}

.single-post-byline .single-post-byline-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.3; /* the two lines read as one label, not two paragraphs */
}

.single-post-byline .single-post-byline-label {
  display: block;
  color: var(--grey-60);
}

.single-post-byline .single-post-byline-name {
  display: block;
  font-weight: 600;
}

@media (min-width: 62rem) {

  .single-post-meta-link:hover {
    text-decoration: none;
    color: var(--primary-color);
  }
}


/* Post navigation */

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  border-top: 1px solid var(--grey-20);
  padding-block: var(--space-md);
}

.post-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.25em;
  flex: 1;
  max-width: 50%;
  color: var(--grey-70);
  transition: color var(--duration) var(--ease);
}

.post-nav-next {
  text-align: right;
  margin-left: auto;
}

.post-nav-label {
  font-size: var(--font-sm);
  text-transform: uppercase;
  letter-spacing: var(--label-letter-spacing);
}

.post-nav-title {
  color: var(--grey-70);
  font-size: var(--font-sm);
}

@media (min-width: 62rem) {
  .post-nav {
    padding-block: var(--space-lg);
  }
  .post-nav-link:hover {
    color: var(--primary-color);
    text-decoration: none;
  }
}

/* --- Visually hidden -----------------------------------------------------
   Off-screen but still read by screen readers — for live-region announcements
   and labels that the visual design carries some other way (e.g. the booking
   wizard's step announcements in template-event.php).
*/
.visually-hidden,
.screen-reader-text { /* WordPress's own class (e.g. the_posts_pagination heading) */
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- Skip link -------------------------------------------------------------
   The first Tab stop on every page (header.php): jumps past the header to
   <main id="main">. Parked above the window until focused; above the sticky
   header and the mobile drawer. */
.skip-link {
  position: fixed;
  top: var(--space-sm);
  left: var(--space-sm);
  z-index: 100001;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--br-sm);
  background: var(--white);
  box-shadow: var(--shadow);
  color: var(--primary-color);
  font-size: var(--font-sm);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(calc(-100% - var(--space-md)));
}

.skip-link:focus {
  transform: none;
}

/* The skip link's target stops below the sticky header, not under it
   (header.js publishes the header's height as --header-offset). */
#main {
  scroll-margin-top: var(--header-offset, 0px);
}

/* --- 404 page ---------------------------------------------------------------
   Everything centred: the title band, the copy, the site search (a form is
   capped at --form-width, so it needs auto margins) and the Home button. The
   search sits the same distance above the button as the band sits above the copy.
*/
/* <main> already fills the spare height (see the top of this file); here it
   also centres the page in it, so the short 404 sits midway between header and
   footer. `error404` is WordPress's body class — the API single routes' missing
   slugs get it too. */
body.error404 main {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.not-found-page .internal-header {
  justify-content: center;
}

.not-found__body {
  text-align: center;
}

.not-found__body > * + * {
  margin-top: var(--space-md);
}

.not-found__body .search-form {
  margin-inline: auto;
  text-align: start; /* keep the typed text left-aligned in the field */
}

.not-found__body .search-form + * {
  margin-top: var(--space-md-lg-d);
}
