/*
 * Rathbone 2026 — Direction D base element rules + a11y micro-utilities
 * ======================================================================
 *
 * Sits between gdh-master v3 (parent) and brand-d.css (active brand
 * direction). Everything v3 ships canonically — buttons, cards, hero-
 * split, site-nav, site-footer, accordion, breadcrumb, eyebrow,
 * easy-read, status-pill, eligibility-panel, referral-cta,
 * funder-logo-strip, report-feature, timeline, mission, ways, faq,
 * pull-quote, sr-only, container — is consumed straight from the parent
 * and re-coloured / re-sized via brand-d.css token overrides.
 *
 * This file only owns:
 *   @layer base       Direction D's body / heading / paragraph / link
 *                     element rules (display-scale h1-h4 on bare elements,
 *                     bold-underlined body links, 70ch prose max-width).
 *   @layer utilities  Two Rathbone-only a11y enhancements that v3 doesn't
 *                     ship: external-link screen-reader announcement,
 *                     coarse-pointer 44px touch-target enforcement
 *                     (WCAG 2.5.5).
 *
 * Load order in functions.php:
 *   1. gdh-master.css      (parent — v3.17.0 tokens + components)
 *   2. theme-layout.css    (parent — header/footer scaffolding)
 *   3. rathbone-master.css (this file — base element rules + 2 utilities)
 *   4. brand-d.css         (active brand — :root token overrides + custom tokens)
 *   5. style.css           (page-scoped overrides)
 */

@layer base {

  /* ── Direction D body element rules ──
     Bare h1-h4 land at display size (deliberate — the home / page hero
     uses `.hero-split__h1` for the largest level, but section-leading
     bare h2 / h3 inside content should still feel editorial-large).
     v3's default applies prose sizes to bare h-elements; we re-point
     them at display sizes for Direction D's accessibility-led scale.
     h5 / h6 are treated as eyebrow-like utility headings — uppercase,
     brand-secondary, small. */

  body {
    font-family: var(--font-body);
    font-size: var(--text-1);
    line-height: 1.65;
    color: var(--text-body);
    background: var(--bg-page);
    font-weight: 400;
  }

  h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--text-heading);
    line-height: 1.2;
    letter-spacing: -0.01em;
  }

  h1 { font-size: var(--text-display-h1); font-weight: 700; }
  h2 { font-size: var(--text-display-h2); font-weight: 700; }
  h3 { font-size: var(--text-display-h3); font-weight: 700; }
  h4 { font-size: var(--text-display-h4); font-weight: 700; }

  h5, h6 {
    font-family: var(--font-body);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.9375rem;
    color: var(--brand-secondary);
  }

  p, li, dd {
    color: var(--text-body-soft);
    line-height: 1.7;
    max-width: 70ch;
  }

  /* Utility-text paragraphs (eyebrow / signpost / preheader / lede /
     subheading / micro) aren't prose — drop the 70ch measure so the box
     fills its container and can honour a centered section header. Without
     this an .eyebrow in a `text-align: center` header centres its text
     inside a left-pinned 70ch box, reading as left-aligned. */
  p[class*="eyebrow"], p.signpost, p.preheader,
  p.lede, p.subheading, p.micro {
    max-width: none;
  }

  a {
    color: var(--text-link);
  }
  /* Prose-link treatment — bold + underline + hover — scoped to UNCLASSED
     links so it can't leak into component links. A card is itself an <a>,
     so a base `a { text-decoration: underline; font-weight: 700 }` would
     underline and embolden the WHOLE card (title, summary, status pill).
     Prose links are unclassed; component links (.btn, .site-nav__link,
     .svc-card, …) style themselves. */
  a:not([class]) {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 0.25em;
    text-decoration-thickness: 1.5px;
  }
  a:not([class]):hover {
    color: var(--text-link-hover);
    text-decoration-color: var(--brand-accent);
  }
}


@layer utilities {

  /* External-link screen-reader announcement — appends "(opens in new
     tab)" off-screen so screen readers warn the user. v3's @layer
     utilities doesn't include this. */
  a[target="_blank"]::after {
    content: " (opens in new tab)";
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* Touch-target enforcement (WCAG 2.5.5) — coarse pointers get 44px
     minimum on small interactive surfaces v3 doesn't widen by default. */
  @media (pointer: coarse) {
    .btn--sm,
    .audience-tag,
    .theme-tag,
    .page-nav__link {
      min-height: 44px;
      display: inline-flex;
      align-items: center;
    }
  }

  /* Centre the width-capped CTA paragraph. Master's `.cta-text p` sets a
     max-inline-size (32em) but no auto margin, so when its effective cap
     — the smaller of 32em and this theme's `p { max-width: 70ch }` — is
     narrower than the 640px .cta-section__layout, the paragraph pins LEFT
     and reads as off-centre beside the centred heading + buttons. 70ch
     resolves narrower once Atkinson Hyperlegible loads, which is why it
     shows on-device but not with a fallback font. (Upstream fix: master's
     .cta-text p should carry margin-inline: auto.) */
  .cta-text p:not(.eyebrow):not(.signpost):not(.preheader) {
    margin-inline: auto;
  }

  /* "Sunshine on brick" — gold highlight-mark for two-or-three words inside
     a display heading. A hand-swiped band of brand accent behind the text;
     clone keeps the band intact across line wraps. Display sizes only —
     never on body copy. */
  .text-mark {
    background: linear-gradient(transparent 58%, var(--brand-accent) 58% 94%, transparent 94%);
    padding-inline: 0.05em;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }

  /* Text-mark on the mid-teal text-heroes (the secondary/utility tier).
     Gold-over-teal muddies to khaki (near-opposite hues), so here the
     swipe is a LIGHT TEAL instead — analogous to the #3D6863 hero, so it
     reads as a clean tone-on-tone highlight. Heading stays WHITE (same
     swipe shape as the cream pages); the band is lighter than the hero so
     it's visible, but kept mid enough that the white glyphs hold where
     they cross it. */
  .archive-hero .text-mark {
    background: linear-gradient(
      transparent 58%,
      color-mix(in srgb, var(--brand-secondary) 60%, white) 58% 94%,
      transparent 94%);
    color: inherit;      /* keep the white heading colour */
    padding: 0 0.05em;   /* back to the swipe's inline-only padding */
    border-radius: 0;
  }

  /* Section-surface utilities for composing per-page colour rhythm — the
     warm counterparts to master's .surface--light / --dark. Applied to
     <section>s to sequence a page's "score" (cream openings, sage air,
     white reading). Win over component section defaults via layer order. */
  .surface--cream { background-color: var(--bg-surface-warm); }
  .surface--sage  { background-color: var(--bg-surface-alt); }
  .surface--white { background-color: var(--bg-page); }
}


@layer components {

  /* Editor-authored content rhythm. `.post-body` wraps the_content() in
     single.php, single-opportunity.php, single-adult_service.php and
     single-youth_programme.php — but it had no CSS rule anywhere in the
     parent or the child, and master resets `p { margin: 0 }`. Every news
     article therefore rendered as an unbroken wall of text, with headings
     butted straight against the paragraph above them.

     Mirrors master's .flow rhythm using the same tokens rather than
     inventing a second scale. Deliberately NOT `.flow` itself: that also
     sets font-size: var(--text-prose-body), which would override the
     per-template body sizes already set inline (17px on news singles,
     18px on programme bodies). Rhythm only, no type-size change.

     Rule order matters, as in master: the heading-trail rule must come
     after the heading-above rules so an h3 following an h2 gets the tight
     gap, not the section-break one. */
  .post-body > * + * {
    margin-block-start: var(--flow-space);
  }
  .post-body > * + h2 { margin-block-start: var(--flow-space-h2); }
  .post-body > * + h3 { margin-block-start: var(--flow-space-h3); }
  .post-body > :is(h1, h2, h3, h4, h5, h6) + * {
    margin-block-start: var(--flow-space-tight);
  }
  .post-body ul,
  .post-body ol {
    padding-inline-start: var(--space-lg);
  }
  .post-body li + li {
    margin-block-start: var(--space-2xs);
  }

  /* Intro-paragraph gap. Master v3.17.0 line 4442 carries an inverted
     selector: `.intro-text p:not(:has(+ p))` matches the LAST paragraph of a
     run, so the margin lands after it instead of between paragraphs — the
     opposite of what its own comment says. Consecutive paragraphs therefore
     render with no separation at all (measured on For Adults: 0px between
     paragraphs, 16px trailing the last).

     This adds the complement — a gap on paragraphs that ARE followed by a
     paragraph — rather than fighting master's rule, so the two target
     different elements and there is no specificity contest. The :not()
     guards mirror master's so utility paragraphs are left alone.

     The leading half of the same bug (line-height only on the last
     paragraph) is already masked by this file's own p/li/dd rule, so it
     needs nothing here.

     (Upstream fix: canonical gdh-master is corrected in v3.21.4. Rathbone
     vendors v3.17.0 and the 16-release pull is deliberately deferred until
     after launch — v3.17.1 touched CTA centring and v3.17.2 submenu indent,
     both patterns this site uses heavily. Delete this rule when that pull
     lands.) */
  .intro-text p:has(+ p):not(.eyebrow):not(.signpost):not(.preheader) {
    margin-block-end: var(--space-sm);
  }

  /* Hero with no featured image. Master's .hero-split__inner is a 3fr 2fr
     grid whose media half is a background-image at `cover`; with no image
     to show there is nothing to put in that column, so collapse to a single
     full-width text panel rather than painting a placeholder into it.
     Templates add this class when the post has no thumbnail. */
  .hero-split--no-media .hero-split__inner {
    grid-template-columns: 1fr;
  }

  /* SVG logo sizing. v3's .site-nav__logo / .site-footer__logo use
     block-size:auto + max-block-size:48px — fine for a raster PNG (concrete
     intrinsic px) but an SVG that carries only a viewBox (no width/height on
     <svg>) collapses to 0×0 under auto sizing. Pin an explicit height; width
     follows the viewBox aspect ratio. */
  .site-nav__logo,
  .site-footer__logo {
    block-size: 44px;
    max-block-size: none;
    inline-size: auto;
  }

  /* News-card photo crop fix. Master puts aspect-ratio: 4/3 on
     .news-card__photo, but aspect-ratio is only a PREFERRED size — the
     in-flow img's automatic minimum size lets portrait images (e.g. event
     posters) stretch the box taller, so card photos rendered at whatever
     ratio the upload happened to be. Absolutely positioning the media
     inside the frame (master already sets position: relative +
     overflow: clip) makes the 4/3 crop a hard constraint; object-fit:
     cover from master handles the crop. (Upstream fix: master should ship
     this on .news-card__photo's children.) */
  .news-card__photo > img,
  .news-card__photo > div {
    position: absolute;
    inset: 0;
    inline-size: 100%;
    block-size: 100%;
  }

  /* Nav dropdown indent fix. Master's .site-nav__submenu resets margin,
     list-style and padding-BLOCK but never padding-inline, so the <ul>
     keeps the UA's 40px inline-start indent and the sublinks sit shoved
     to the right inside the panel. (Upstream fix: master should add
     padding-inline: 0 to .site-nav__submenu.) */
  .site-nav__submenu {
    padding-inline: 0;
  }

  /* Service / directory card (.svc-card) — used by the adult-service, space,
     youth-programme, opportunity and 404 templates. A no-photo card: a body
     of eyebrow + title + summary + optional status pill, with a trailing
     go-arrow. It was removed in the Phase-3 strip-down but is still
     referenced in ~10 templates, so the cards rendered as unstyled, fully
     underlined links. Redefined here to match the .news-card visual language. */
  .svc-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background-color: var(--bg-page);
    border: 1px solid var(--border-subtle);
    border-radius: var(--card-radius);
    padding: var(--space-lg);
    text-decoration: none;
    color: inherit;
    transition:
      transform var(--transition-base),
      box-shadow var(--transition-base),
      border-color var(--transition-base);
  }
  .svc-card:hover {
    transform: translateY(var(--card-lift-distance));
    box-shadow: var(--shadow-md);
    border-color: transparent;
  }
  .svc-card__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    flex: 1 1 auto;
    min-inline-size: 0;
  }
  .svc-card__title {
    font-family: var(--type-card-heading);
    font-size: var(--text-card-h4);
    font-weight: var(--weight-semibold);
    color: var(--brand-secondary-text);
    margin: 0;
    line-height: var(--leading-snug);
    max-inline-size: none;
    text-wrap: balance;
  }
  .svc-card__arrow {
    flex: none;
    color: var(--brand-secondary-text);
    font-size: 1.25rem;
    line-height: 1;
    transition: transform var(--transition-base);
  }
  .svc-card:hover .svc-card__arrow {
    transform: translateX(4px);
  }

  /* ── "Sunshine on brick" prototype components (direction v1) ──
     Two of the direction's rooms. Colours are deliberate literals, not
     tokens: these are fixed brand surfaces that read identically in light
     and dark mode (deep teal #1e4741 / gold #FFC845, pairings 6.2–10.3:1). */

  /* Hero openings, two registers:
       • Image heroes (.hero-split) open on cream — the photo carries colour.
       • Text-only heroes (.archive-hero) have no image to fill them, so they
         open on mid-teal "daylight" with white text; the colour gives the
         bare text presence. White nav sits crisply above both.
     White on #3D6863 ≈ 5.9:1 (AA all sizes, AAA at the h1's display scale).
     Eyebrow is pale, not gold — gold on mid-teal is only ~4:1, under AA for
     small text. */
  .hero-split {
    background-color: var(--bg-surface-warm);
  }
  .archive-hero {
    background-color: var(--brand-secondary); /* mid-teal #3D6863 */
    color: #ffffff;
  }
  .archive-hero .eyebrow { color: #d9e6e2; }
  .archive-hero h1 { color: #ffffff; }
  /* Match master's own subtitle selector specificity (0,4,1) so this wins
     — a plain `.archive-hero p` (0,1,1) loses to it and the subtitle stayed
     dark muted teal on the teal band. */
  .archive-hero p:not(.eyebrow):not(.signpost):not(.preheader) { color: #e8f0ed; }
  .archive-hero a {
    color: #ffffff;
    text-decoration: underline;
    text-underline-offset: 0.2em;
  }

  /* The sunshine room — the one gold ask-band per page. */
  .cta-section--sunshine {
    background-color: var(--brand-accent);
  }
  .cta-section--sunshine .eyebrow { color: #2a5049; }
  .cta-section--sunshine .cta-text h2 { color: #1e4741; }
  .cta-section--sunshine .cta-text p:not(.eyebrow):not(.signpost):not(.preheader) { color: #2a3f38; }
  .cta-section--sunshine .btn--primary {
    background-color: #1e4741;
    color: #ffffff;
  }
  .cta-section--sunshine .btn--primary:hover,
  .cta-section--sunshine .btn--primary:focus-visible {
    background-color: #14312d;
    color: #ffffff;
  }
  /* Secondary stays the SAME .btn--tint component (1px border, tinted
     chip) — only its tint tokens are retuned so the teal-over-transparent
     mix reads against gold instead of white. No invented variants; the
     brand explicitly has no outline button. */
  .cta-section--sunshine .btn--tint {
    --btn-tint-bg:           color-mix(in oklch, #1e4741 12%, transparent);
    --btn-tint-text:         #1e4741;
    --btn-tint-border:       color-mix(in oklch, #1e4741 35%, transparent);
    --btn-tint-bg-hover:     color-mix(in oklch, #1e4741 22%, transparent);
    --btn-tint-border-hover: color-mix(in oklch, #1e4741 55%, transparent);
  }
  .cta-section--sunshine .btn:focus-visible { outline-color: #1e4741; }

  /* Numerals that shout — mid-page impact band on the evening teal.
     (Never at the top of a page; the footer is the only other dark band.) */
  .stat-strip {
    background-color: #1e4741;
    padding-block: var(--space-struct-y-base, 4rem);
  }
  .stat-strip__header {
    text-align: center;
    max-inline-size: 600px;
    margin: 0 auto var(--space-xl);
  }
  .stat-strip .eyebrow { color: var(--brand-accent); }
  .stat-strip__heading { color: #ffffff; margin: 0; }
  .stat-strip__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-lg);
    max-inline-size: 1000px;
    margin-inline: auto;
  }
  .stat-strip__item { text-align: center; padding: var(--space-md); }
  .stat-strip__number {
    font-family: var(--font-display);
    font-size: clamp(2.75rem, 4.5vw, 4.25rem);
    font-weight: 700; /* Instrument Sans tops out at 700 — avoid synthetic bold */
    line-height: 1;
    color: #ffffff;
    margin: 0 0 var(--space-xs);
    max-inline-size: none;
  }
  .stat-strip__label {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--brand-accent);
    margin: 0;
    max-inline-size: none;
  }

  /* Voices in daylight — the mid-teal band that carries a human (or org)
     voice between sections. White text on #3D6863 reads ~5.9:1 (AA all
     sizes, AAA at this display scale). The kicker stays white — gold on
     mid-teal is only ~4:1, too low for small text — so gold appears here
     only as the decorative quote glyph. */
  .quote-band {
    background-color: #3D6863;
    padding-block: var(--space-2xl);
    text-align: center;
  }
  .quote-band__kicker {
    color: #d9e6e2;
  }
  .quote-band__glyph {
    display: block;
    font-family: var(--font-display);
    font-size: 3.5rem;
    line-height: 0.5;
    color: var(--brand-accent);
    margin-block-end: var(--space-xs);
  }
  .quote-band__text {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.375rem);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: #ffffff;
    text-wrap: balance;
    max-inline-size: 26ch;
    margin: 0 auto;
  }

  /* Paper warmth — the funder trust strip sits on cream, per the score.
     Logos are supplied as rectangles with baked-in white backgrounds;
     multiply blending maths white out to transparent so the cream shows
     through, while the logo inks survive. Composes with master's
     grayscale/opacity filter. Dark mode reverts to normal blending —
     multiply against a dark surface would swallow the logos. */
  .funder-logo-strip {
    background-color: var(--bg-surface-warm);
  }
  .funder-logo-strip__logo {
    mix-blend-mode: multiply;
    /* Full greyscale at rest (master default is 40%) so eight different
       brand palettes read as one calm ink-on-paper row; master's hover
       rule still restores full colour. */
    filter: grayscale(100%) opacity(0.7);
  }
  @media (prefers-color-scheme: dark) {
    .funder-logo-strip__logo { mix-blend-mode: normal; }
  }

  /* Full-bleed auto-scrolling logo marquee — keeps every funder on one
     line at any viewport (no orphaned second row). Two identical sets;
     the track translates -50% and loops seamlessly. The duplicate set is
     aria-hidden and link-free. Pauses on hover AND keyboard focus
     (WCAG 2.2.2 mechanism); reduced-motion gets a static scrollable row. */
  .funder-marquee {
    overflow: hidden;
    margin-block-start: var(--space-md);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  }
  .funder-marquee__track {
    display: flex;
    width: max-content;
    animation: rb-marquee 45s linear infinite;
  }
  .funder-marquee:hover .funder-marquee__track,
  .funder-marquee:focus-within .funder-marquee__track {
    animation-play-state: paused;
  }
  .funder-marquee__set {
    display: flex;
    align-items: center;
    gap: var(--space-2xl);
    padding-inline-end: var(--space-2xl); /* completes the rhythm at the seam */
  }
  @keyframes rb-marquee {
    to { transform: translateX(-50%); }
  }
  @media (prefers-reduced-motion: reduce) {
    .funder-marquee { -webkit-mask-image: none; mask-image: none; overflow-x: auto; }
    .funder-marquee__track { animation: none; width: auto; }
    .funder-marquee__set[aria-hidden="true"] { display: none; }
  }

  /* The window arch — Old Library Victorian-window motif on the space
     cards. The card itself takes the arch (it clips), so no rectangular
     card surface peeks out behind the photo's curve; the photo radii
     match so its own corners follow the same spring line. */
  .news-card--arch {
    border-start-start-radius: 999px;
    border-start-end-radius: 999px;
  }
  .news-card--arch .news-card__photo {
    border-start-start-radius: 999px;
    border-start-end-radius: 999px;
  }
}


/* ================================================================================
   COOKIE CONSENT — CookieYes, brand-aligned
   --------------------------------------------------------------------------------
   The plugin carries its palette as INLINE styles inside a banner HTML template
   stored in wp_options, so the colours are re-mapped to brand tokens there
   (#1863DC/#0056A7 -> deep teal, #212121 -> brand ink, greys -> sage/line).
   What cannot live there is typography and the one button that should read as
   the brand's primary action.

   Deliberately NOT inside an @layer: CookieYes injects its own UNLAYERED
   stylesheet, and unlayered rules beat layered ones whatever the source order.
   These selectors are also two-class specific so they win on their own terms.
   ============================================================================ */

.cky-consent-container,
.cky-modal {
  font-family: var(--font-body);
}

.cky-consent-container .cky-title,
.cky-modal .cky-preference-title {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* NOTE ON GOLD. The obvious "brand" move is a gold Accept All, and it was
   tried. It is deliberately NOT used, for two reasons:
     1. Gold is this brand's single ask-colour — one sunshine CTA per page,
        reserved for the donation ask. Spending it on a compliance dialog
        devalues it everywhere else.
     2. A gold Accept beside a plain Reject is a nudge. ICO guidance is that
        refusing should be as easy as accepting, so the two are given equal
        weight instead: Accept filled deep teal, Reject in the site's
        .btn--tint treatment (sage fill, deep-teal label).
   Both button treatments are set inline in the stored banner template,
   because CookieYes writes its colours as inline styles — which beat any
   stylesheet rule that does not use !important. */

/* The floating "Consent Preferences" bubble sits over page content for the
   life of the site — give it the same deep teal as the footer. */
.cky-btn-revisit-wrapper {
  background-color: var(--brand-primary) !important;
}
