/* ==========================================================================
   Blog archive — ported from the Prestige Blog reference build.

   The reference kept layout inline on elements; it lives here as classes so it
   can be re-laid-out at breakpoints. Values come from prestige-tokens.css.

   Scoped to [data-b] and to .prestige-blog so nothing leaks into other pages.
   ========================================================================== */

/* No page-wide anchor reset here, deliberately.
 *
 * This page previously carried `.prestige-blog #pr-main a { color: var(--ink) }`,
 * carried over from the reference helmet. An ID selector scores 1-2-1 and so
 * outranked every shared component that sets its own link colour — including
 * `.pr-crumbs a` at 0-2-1 — which made the banner breadcrumbs render black on
 * this page and white on every other one.
 *
 * It turned out to be unnecessary: every anchor on this template already
 * carries a component class that owns its colour (.pr-photocard, .pr-lift,
 * .pr-btn, .pr-crumbs). If a bare anchor is ever added here, give it a
 * component class rather than reinstating a blanket reset. */
/* The heading/paragraph margin reset that was here is gone too: theme.css
 * already zeroes them globally, and the ID selector outranked shared
 * components — it beat `.pr-prose blockquote > p` and reinstated a margin
 * inside quotes on this template only. */

/* --- Banner -------------------------------------------------------------- */
/* The header renders above #pr-main, so the banner starts beneath it and the
   photo runs the full band height — same mechanism as the homepage hero.
   0.62 flat wash over the photo: the measured floor for white banner copy. */

[data-b="banner"] {
  /* The header is fixed and out of flow, so only the padding is needed to
     start the content below it — no negative margin to cancel. */
  padding-top: var(--pr-header-height, 0px);
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0.62)),
    var(--pr-banner-image);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

/* --- Featured post ------------------------------------------------------- */

[data-b="featuresection"] {
  background: var(--paper);
  padding: var(--section-pad) var(--gutter-page) 0;
}

[data-b="feature"] {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(24px, 2.8vw, 54px);
  align-items: center;
  padding: clamp(20px, 2vw, 34px);
  /* The home Service Area card: paper, the large radius, a shadow and no
     outline (BugHerd #132), the photo's corner following the card's. */
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  /* The card ends its section; above the next one, so that section's paper
     does not cut its shadow off in a straight line along the bottom. */
  position: relative;
  z-index: 1;
}
[data-b="feature"] [data-b="featureshotframe"] { border-radius: calc(var(--radius-lg) - clamp(8px, 0.8vw, 14px)); }

[data-b="featureshotframe"] {
  overflow: hidden;
  border-radius: var(--radius-sm);
  aspect-ratio: 16 / 10;
}

[data-b="feature"] [data-b="shot"] {
  width: 100%;
  height: 100%;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  background-color: var(--surface);
}

[data-b="featuretext"] {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

[data-b="featuretitle"] {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(28px, 2.6vw, 50px);
  line-height: 1.08;
  color: var(--ink);
  text-wrap: pretty;
}

[data-b="featurecta"] { margin-top: 4px; }

/* --- Archive ------------------------------------------------------------- */

[data-b="archive"] {
  background: var(--paper);
  padding: var(--section-pad) var(--gutter-page);
}

/* Filtering fades the results out and the new set in (BugHerd #159). blog.js
   sets data-b-fading on the click and clears it after the swap. The find row
   stays put — it is what the visitor just pressed. */
[data-b="archive"] > :not([data-b="findrow"]) { transition: opacity .25s ease; }
[data-b="archive"][data-b-fading] > :not([data-b="findrow"]) { opacity: 0; }

/* --- Search results ------------------------------------------------------ */

/* The head of a results page: what was searched for, how many matched, and a
   box to search again without going back. Only rendered by search.php. */
[data-b="searchhead"] {
  margin-bottom: clamp(32px, 3.2vw, 58px);
}

[data-b="searchtitle"] {
  margin: 0;
}

[data-b="searchcount"] {
  margin: 10px 0 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 24px;
  color: var(--muted);
}

/* The form sits on one line until there is no room for it. The field takes the
   slack and the button stays its natural width, so the pair never splits with
   a stretched button on its own row. */
[data-b="searchform"] {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: clamp(20px, 2vw, 32px);
  max-width: 620px;
}

[data-b="searchform"] .pr-field {
  flex: 1 1 220px;
  min-width: 0; /* a flex item's min-width:auto would stop it shrinking */
}

[data-b="searchform"] .pr-cta {
  flex: 0 0 auto;
  /* .pr-cta is an underlined link treatment; as a solid submit button that
     underline runs through the label. */
  text-decoration: none;
  /* .pr-cta is an <a> treatment; as a <button> it needs the box reset and the
     52px form floor rather than the link's own height. */
  min-height: 52px;
  padding: 0 clamp(20px, 2vw, 34px);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
}

[data-b="searchform"] .pr-cta:hover,
[data-b="searchform"] .pr-cta:focus-visible {
  background: var(--paper);
  color: var(--ink);
}

/* Chips are real category links here, so they need the inline-flex centring
   .pr-chip gives a <button> and no underline from the anchor reset. */
/* ---------------------------------------------------------------------------
 * Focus ring on the filter row — COMMENTED OUT, not deleted.
 *
 * The ring comes from `.pr-page :focus-visible` in prestige-components.css
 * (2px solid var(--ink), 3px offset) — the theme's keyboard-accessibility
 * baseline, which every other control still uses. It shows here on a MOUSE
 * click too, because Chrome treats text inputs and <select> as focus-visible
 * on click: typing needs a focus cue in a way that clicking a link does not.
 *
 * Suppressed on this row only, at the client's request. Uncommenting the block
 * below restores it.
 *
 * The selector carries .pr-page so it OUT-SCORES the component rule rather
 * than merely tying with it and winning on load order — a tie that a future
 * enqueue reorder would silently flip.
 *
 * WORTH KNOWING: while this is off, a keyboard-only user has no indication of
 * where focus sits on this row, which is WCAG 2.4.7 (Focus Visible, AA) —
 * the one accessibility floor in this theme that is currently not met. The
 * fix, when wanted, is not to re-enable the outline but to mark focus another
 * way: darken the field border, fill the active chip. Both read as design
 * rather than as a browser default.
 * ------------------------------------------------------------------------- */
.pr-page [data-b="findrow"] :focus-visible {
  outline: none;
}

/*
.pr-page [data-b="findrow"] :focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}
*/

/* Filters on the left, search on the right — one row of "narrow this list"
   controls. They stack, search first, once there is no room for both. */
/*
 * Filters and search: one row until 991px, stacked and centred below it.
 *
 * This used to be flex-wrap: wrap with no breakpoint, so the search dropped
 * under the chips at whatever width it happened to run out of room — and both
 * stayed left-aligned, which read as a layout accident rather than a stack.
 * The breakpoint is explicit now, and the stacked state centres.
 */
[data-b="findrow"] {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: clamp(16px, 2vw, 28px);
}

@media (max-width: 991px) {
  [data-b="findrow"] {
    flex-direction: column;
    align-items: center;
  }

  /*
   * Width, not flex-basis. Once the row is a COLUMN, `flex: 1 1 100%` sizes on
   * the cross axis — height — so the search form kept its content width (357px
   * measured) instead of filling the stack. align-self overrides the container's
   * centring only where a full-width control is wanted.
   */
  /* The stacked sizing lives at the END of this file — see "Stacked search
     form". Putting it here did not work: the row rule that sets
     `flex: 0 1 440px` is DEFINED LOWER DOWN at the same specificity, so source
     order beat it and the form stayed 440px tall between 768 and 991px. */
  [data-b="findrow"] > [data-b="searchform"] {
    max-width: 520px;
  }

  /* Centred rather than stretched: a chip row and a search box that each run
     the full width of a tablet look like two unrelated bars. */
  [data-b="findrow"] > [data-b="filters"] {
    flex: 0 0 auto;
    justify-content: center;
  }
}

[data-b="findrow"] > [data-b="filters"] {
  /* Takes the slack so the search box keeps its own width on a wide screen. */
  flex: 1 1 auto;
}

[data-b="findrow"] [data-b="searchform"] {
  /* Overrides the results-page rule, where the form is the only thing on its
     row and may run to 620px. Here it shares the row with the chips.
     440px, not 340: at the narrower width the field and the Search button had
     no room side by side and the button wrapped to its own line under it. */
  flex: 0 1 440px;
  margin-top: 0;
  /* nowrap so the pair can never split again — below 767px the whole form goes
     full width instead, which is where stacking would be right. */
  flex-wrap: nowrap;
}

[data-b="findrow"] [data-b="searchform"] .pr-cta {
  /* .pr-cta carries the underlined-link treatment; as a solid button here that
     rule leaves a stray underline through the word. */
  text-decoration: none;
}

[data-b="filters"] {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
[data-b="filters"] .pr-chip { text-decoration: none; }
[data-b="filters"] .pr-chip:hover { color: var(--ink); }
[data-b="filters"] .pr-chip[aria-pressed="true"]:hover { color: var(--paper); }

@media (max-width: 767px) {
  /* The chip row is replaced by the select here, so the search box matches its
     width instead of holding a 340px column on its own. */
  [data-b="findrow"] [data-b="searchform"] {
    /*
     * width, NOT flex-basis. The container is a column at this width, so
     * `flex: 1 1 100%` is 100% of the HEIGHT — it made the form 440px tall and
     * the Search button stretched to match, which is what left a large empty
     * band above and below the search row.
     *
     * Third time this trap has bitten in this file (see #48 and #70); the rule
     * is: in the stacked layout, size with width and leave flex alone.
     */
    flex: 0 0 auto;
    width: 100%;
    max-width: 520px;
    /* Full width here, so the pair has room on one line again. */
    flex-wrap: nowrap;
  }

  /* The select stands in for the chips at this width, so it is the thing being
     centred — label included. Slightly wider than the search box's own measure
     because a category name plus the chevron needs the room. */
  [data-b="findrow"] [data-b="filterselect"] {
    width: 100%;
    max-width: 520px;
    margin-inline: auto;
    align-items: center;
    text-align: center;
  }

  [data-b="findrow"] [data-b="filterselectrow"] {
    width: 100%;
  }
}

@media (max-width: 576px) {
  /* Full width at phone sizes: the 520px cap leaves the control floating in
     the gutter once the screen is narrower than it. */
  [data-b="findrow"] [data-b="filterselect"],
  [data-b="findrow"] [data-b="searchform"] {
    max-width: none;
  }
}

/* The ≤767px select. Hidden above that; CSS swaps it in, not JS. */
[data-b="filterselect"] { display: none; }
[data-b="filterselectrow"] { display: flex; gap: 12px; align-items: stretch; }
[data-b="filterselectrow"] .pr-field { flex: 1 1 auto; }

/* The no-JS submit button: reachable by keyboard and announced, but out of the
   layout, because blog.js navigates on change for everyone else. */
[data-b="filtergo"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
[data-b="filtergo"]:focus-visible {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip-path: none;
  min-height: 52px;
  padding: 0 20px;
}

/* --- Post grid ----------------------------------------------------------- */

[data-b="grid"] {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(20px, 2vw, 36px);
  margin-top: clamp(26px, 2.6vw, 46px);
}

/* The same shape as the homepage news card (967/607), so a post card is one
   height across the site rather than portrait here and landscape there. The
   grid stays 3-up, so these are simply shorter than the 444/560 they were. */
/*
 * The ratio holds, AND a long title can still grow the card.
 *
 * `aspect-ratio` with `min-height: auto` is exactly this behaviour and needs no
 * spacer: the ratio sets the height from the width, and because a flex column's
 * automatic minimum size is its content, a card whose text does not fit grows
 * instead of clipping. The clipping in #72 came from the card being a flex
 * container whose min-height had been forced to 0 elsewhere.
 *
 * Four hand-rolled attempts sat here before this — a flat min-height (squat
 * cards, #74), a padding-top spacer with a negative margin (cancelled itself),
 * an absolutely positioned body (right ratio, clipping came back) and a
 * shrinkable spacer (no clipping, cards too tall). The built-in pair does both.
 */
[data-b="card"] {
  aspect-ratio: 967 / 607;
  min-height: auto;
}

/* .pr-photocard__shot is the absolutely-positioned photo layer; the <img>
   inside it (so WordPress can emit srcset) fills that layer. */
[data-b="cardshot"] .pr-photocard__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

[data-b="cardmeta"] { font-size: 14px; color: var(--surface); }

[data-b="cardtitle"] {
  font-family: var(--font-editorial);
  font-weight: 500;
  font-size: clamp(20px, 1.6vw, 30px);
  line-height: 1.16;
  color: var(--paper);
  text-wrap: pretty;
  /*
   * Three lines, then an ellipsis.
   *
   * The card holds a fixed 967/607 ratio, so a title long enough to overrun it
   * would have its TOP cut off by the card's overflow — the first line, mid
   * letter, with no sign anything was missing. Three lines is what the card has
   * room for at every width, and -webkit-line-clamp trails off cleanly instead.
   *
   * Earlier attempts let the card grow instead, which cost the rounded corners
   * and then the hover zoom containment; clamping the text keeps every visual
   * detail of the card intact.
   */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
[data-b="card"]:hover [data-b="cardtitle"] { color: var(--paper); }

/* --- Empty state --------------------------------------------------------- */

[data-b="empty"] {
  margin-top: clamp(26px, 2.6vw, 46px);
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: clamp(34px, 4vw, 70px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

[data-b="emptytitle"] {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(24px, 2vw, 36px);
  line-height: 1.1;
  color: var(--ink);
}

/* The empty state's copy is one short muted paragraph, matching the
   reference's .pr-body.pr-body--muted; the prose wrapper keeps it editable. */
[data-b="emptybody"] { max-width: 520px; }
.pr-prose--empty > :first-child { margin-top: 0; }
.pr-prose--empty > :last-child { margin-bottom: 0; }
.pr-prose--empty p { color: var(--muted); }

[data-b="emptycta"] { margin-top: 8px; }

/* --- Pagination ---------------------------------------------------------- */
/* paginate_links() emits .page-numbers anchors and a .current span. The
   reference's 44px circles are reproduced on those, and the disabled arrow
   keeps its muted --surface outline. */

[data-b="pagination"] {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: clamp(34px, 3.4vw, 62px);
}

[data-b="pagination"] .page-numbers,
[data-b="arrow"] {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font-family: var(--font-cta);
  font-weight: 700;
  font-size: 16px;
  background: transparent;
  border: 1px solid var(--surface);
  color: var(--ink);
  text-decoration: none;
}

[data-b="pagination"] .page-numbers:hover {
  border-color: var(--ink);
  color: var(--ink);
}

[data-b="pagination"] .page-numbers.current {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
[data-b="pagination"] .page-numbers.current:hover { color: var(--paper); }

/* The two arrow links: darker outline, like the reference's enabled arrow. */
[data-b="pagination"] .page-numbers.prev,
[data-b="pagination"] .page-numbers.next {
  border-color: var(--ink);
  color: var(--ink);
}

/* An ellipsis is not a control: no circle, no hit-area promise. */
[data-b="pagination"] .page-numbers.dots {
  border-color: transparent;
  color: var(--muted);
  cursor: default;
}
[data-b="pagination"] .page-numbers.dots:hover { border-color: transparent; }

/* Disabled arrow — rendered as a span so it is not a focus stop. */
[data-b="arrow"][data-b-disabled="1"] {
  border-color: var(--surface);
  color: var(--surface);
  cursor: not-allowed;
}

[data-b="pagination"] svg,
[data-b="arrow"] svg { width: 20px; height: 20px; }

/*
 * The count line. 14px is the gap under the PAGINATION, which is what normally
 * sits above it. When there is only one page of results there is no pagination,
 * so the line was landing 14px under the cards themselves — measured, and far
 * too tight against a row of tall cards.
 *
 * Sibling selector rather than a flat larger margin: with pagination present
 * the original 14px is still right, and this only opens the gap in the case
 * that was actually wrong.
 */
[data-b="summary"] {
  margin-top: 14px;
  text-align: center;
  font-size: 15px;
  line-height: 24px;
  color: var(--muted);
}

[data-b="pagination"] + [data-b="summary"] { margin-top: 14px; }

[data-b="grid"] + [data-b="summary"] {
  margin-top: clamp(34px, 3.4vw, 62px);
}

/* paginate_links()'s before_page_number label uses the shared
   .screen-reader-text utility in theme.css — deliberately not redefined here,
   so a fix there applies on this page too. */

/* --- Breakpoints --------------------------------------------------------- */

@media (max-width: 1199px) {
  [data-b="feature"] { grid-template-columns: minmax(0, 1fr); }
  [data-b="featuretext"] {
    text-align: center;
    align-items: center;
  }
  [data-b="grid"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/*
 * Two per row. The card is narrower here than at 3-up on a wide screen, and
 * 967/607 made it SHORTER as well — 197px tall at 768px wide, against a text
 * block that needs 98px on its own. Long titles hit the 3-line clamp and got
 * cut off; measured clipped at 768, 800, 850 and 900px.
 *
 * A taller ratio buys that back. 3/2 gives 209px at 768px and 302px at 1100px,
 * roughly 40px more than before across the band, which clears the clamp.
 *
 * Bounded at both ends on purpose: min-width keeps it out of the one-per-row
 * rule below, which sets an explicit height and no ratio.
 */
@media (min-width: 768px) and (max-width: 1199px) {
  [data-b="card"] { aspect-ratio: 3 / 2; }
}

@media (max-width: 991px) {
  [data-b="filters"] { justify-content: center; }
  [data-b="empty"] { text-align: center; }
}

@media (max-width: 767px) {
  [data-b="grid"] { grid-template-columns: minmax(0, 1fr); }
  [data-b="filters"] { display: none; }
  [data-b="filterselect"] { display: flex; }
  /*
   * One card per row, so the card fills the column and an aspect ratio would
   * scale its HEIGHT with the viewport — at 700px wide, 4/5 meant a 738px tall
   * card, most of the screen for one item. A max-height does not fix that
   * either: while `aspect-ratio` drives the box, capping the height caps the
   * width too and the card stops filling the row.
   *
   * So: no ratio here. Fixed height, width fills the row like any block.
   */
  [data-b="card"] {
    aspect-ratio: auto;
    height: 320px;
  }
}

@media (max-width: 576px) {
  [data-b="pagination"] { gap: 8px; }
}

/*
 * Stacked search form.
 *
 * Last in the file on purpose. [data-b="findrow"] [data-b="searchform"] sets
 * `flex: 0 1 440px` for the single-row layout, and that rule is defined further
 * up at the same specificity — so a reset placed above it loses on source
 * order, which is exactly what left the form 440px TALL once the row became a
 * column (a flex-basis sizes the cross axis there).
 *
 * width, not flex-basis, is what sizes a column child.
 */
@media (max-width: 991px) {
  [data-b="findrow"] > [data-b="searchform"] {
    flex: 0 0 auto;
    width: 100%;
  }

  /* Neither control stretches to whatever height the form ends up. */
  [data-b="findrow"] > [data-b="searchform"] .pr-cta,
  [data-b="findrow"] > [data-b="searchform"] .pr-field {
    align-self: center;
  }
}

/*
 * Desktop find row (BugHerd #133, #134): the category chips run the full
 * width on their first line, and the search box sits at the right end of the
 * line below, beside the chips that wrapped there. The chip group is
 * display: contents so its chips and the form share one wrapping row; the
 * form's auto left margin pushes it to the right edge. The box has a fixed
 * width so the field is never squeezed to a few letters.
 */
@media (min-width: 992px) {
  [data-b="findrow"] {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 12px;
  }
  [data-b="findrow"] > [data-b="filters"] { display: contents; }
  /* Each line of chips fills the full width, the chips sharing the slack. */
  [data-b="findrow"] .pr-chip { flex: 1 0 auto; max-width: 340px; justify-content: center; }
  [data-b="findrow"] > [data-b="searchform"] {
    flex: 0 0 auto;
    width: clamp(340px, 26vw, 440px);
    margin-left: auto;
  }
}

/*
 * Find row controls (BugHerd #134): the search box is filled light grey, and
 * where the category buttons share its row (768px up) the field and the
 * Search button are the buttons' 44px, so the row lines up. A paler grey than
 * --surface: the placeholder's muted grey on --surface fell short of AA.
 */
[data-b="findrow"] [data-b="searchform"] .pr-field {
  background: var(--surface-sunk);
  border-color: var(--surface-sunk);
}
[data-b="findrow"] [data-b="searchform"] .pr-field:focus { border-color: var(--ink); }
@media (min-width: 768px) {
  [data-b="findrow"] [data-b="searchform"] .pr-field,
  [data-b="findrow"] [data-b="searchform"] .pr-cta {
    height: 44px;
    min-height: 44px;
  }
}
