/*
 * Text and media split — the logo panel only. Figma 10079:6342, rows
 * 10079:6344 / 6359 / 6383 / 6442.
 * Plain CSS: block.css is served from source, never compiled by Vite.
 *
 * WRAPPED FLEX, NOT GRID — the same fix logo-wall carries, for the same
 * defect. A grid with a fixed track count puts a short final row in tracks
 * 1..n and leaves the rest empty, so the tenth logo sat hard left while the
 * comp's own trailing row (10079:6442) is a justify-center row holding one
 * mark. Wrapping items at a fixed basis with centred justification centres
 * every line, including a partial one, and the basis is exactly the width the
 * grid track had, so the column geometry is unchanged.
 *
 * The mark is capped by HEIGHT in block.php, not fitted to the cell. These
 * SVGs report naturalWidth 0 in the browser, so a cell-fitted image took the
 * cell's own proportions: Tesla drew 159x32 against the comp's 250x50 and
 * Hotmail 76x70 against its 54x50 — two marks at completely different optical
 * weights. A shared height cap is what makes marks of different proportions
 * read alike, which is how 10079:6342 draws them.
 */

/* THE INTRO ABOVE THIS ROW. The fourth use of one pattern, not a fourth hack:
   team-grid, featured-clients and graduated-clients each set the intro's bottom
   padding from their OWN block.css, because the gap belongs to the pairing
   rather than to either block. Modelled on graduated-clients, which is the same
   number derived the same way.

   10717:3597 holds BOTH — the intro group (10717:3598) ends at y 275 and the
   rows group (10717:3601) starts at 307, so the comp draws 32 between them.
   The Services frame's own 96 stays on the intro's TOP, which is what keeps the
   seam above it exact; a symmetric py-* preset cannot draw 96 over 32, and the
   top/bottom pair was declined twice.

   Unlayered, so it outranks the Tailwind md:py-24 utility on the intro. */
.section-intro:has(+ .text-media-split) {
  padding-bottom: 1rem;
}

@media (width >= 48rem) {
  .section-intro:has(+ .text-media-split) {
    padding-bottom: 2rem; /* 32 */
  }
}

/* THE TWO ENDS OF A RUN OF COMPACT ROWS. Services 9673:999 stacks its four
   rows inside ONE comp frame, 9677:2245 (y 864, h 2760), which owns all the
   spacing: the first row sits at y 96, the last ends 96 above the frame's
   bottom, and the rows are 48 apart (9677:2249 ends 702, 9679:3867 starts 750).
   The row frames declare no padding of their own.

   Block padding is symmetric, so each row carries 24 and the 24 + 24 between
   two rows IS the comp's 48. These two rules restore the wrapper's own 96 at
   the ends of the run, where a symmetric preset cannot reach.

   The 96 above goes on the ROW, never on the hero: the hero paints the yellow
   band, so padding there would extend the band rather than open paper.

   The 96 below is written as 72 because the section-intro underneath carries
   its own 24 — the value its byte-identical Home instance carries — and
   72 + 24 is the comp's 96.

   Keyed on --compact so neither rule can reach a feature-scale row: Ethos's
   hero is followed by a feature split, and Home's second feature split is
   followed by a section-intro. Both were measured unchanged.

   Unlayered, so they outrank the Tailwind py-* utilities on the row. */
.hero + .text-media-split--compact {
  padding-top: 3rem; /* 48 */
}

.text-media-split--compact:has(+ .section-intro) {
  padding-bottom: 2.25rem; /* 36 */
}

@media (width >= 48rem) {
  .hero + .text-media-split--compact {
    padding-top: 6rem; /* 96 */
  }

  .text-media-split--compact:has(+ .section-intro) {
    padding-bottom: 4.5rem; /* 72, + the intro's own 24 = the comp's 96 */
  }
}

/* A LIST ITEM AND THE NEXT ONE ARE SEPARATE POINTS. The four Services rows are
   the only lists the design draws, and 9679:3874, 9697:899 and 9697:910 all put
   a blank 24px line between every item. 9677:2278 is the same list with one pair
   authored inside a single Figma <ul> and so drawn tight — an authoring slip,
   not a fourth spacing. base.css spaces block-level siblings but not list
   items, so the gap is declared here.

   THIS RULE REACHES ONE OTHER PAGE and that is deliberate: page 52,
   /tms-verification/, the private phase-4 fixture, carries a two-item version
   of the same "Set up." copy and grows by exactly 1lh. Scoping to --compact
   would not spare it (that split is compact), and keying the rule to one page
   would make it a page hack. Reported rather than absorbed. */
.text-media-split__body li + li {
  margin-top: 1lh;
}

.text-media-split__logos {
  --tms-logo-cols: 2;
  --tms-logo-gap: 2rem;

  /*
   * A basis of exactly (100% - gaps) / cols can round a fraction of a pixel
   * over the line at fluid widths and wrap the last item of a full row onto a
   * row of its own. A tenth of a pixel off each item is below perception and
   * cannot round up. Same guard as logo-wall.
   */
  --tms-logo-cell: calc(
    (100% - (var(--tms-logo-cols) - 1) * var(--tms-logo-gap)) /
      var(--tms-logo-cols) - 0.1px
  );

  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: var(--tms-logo-gap);
  row-gap: 1.5rem;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Matches logo-wall's own brand bar: one column below the width where it
   collapses to one, so the panel and the brand bar read the same way on the
   smallest phones. */
@media (width < 24rem) {
  .text-media-split__logos {
    --tms-logo-cols: 1;
  }
}

.text-media-split__logo {
  display: flex;
  flex: 0 0 var(--tms-logo-cell);
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: var(--tms-logo-cell);
  /* block.php caps a mark at 70px tall (90px when there are only one or two
     logos); 20px of air, 10 each side, is the same ratio the row box used
     at the old 50px cap. Held constant across breakpoints, because the cap
     changes with logo count, never with viewport width. */
  height: 5.625rem;
}

.text-media-split__logo-img {
  /* The inline width and height are the drawn size, computed from the
     attachment in block.php. max-* only ever shrinks them, so the height cap
     holds and a wide mark never breaks its cell. */
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  /* max-width can clamp the box narrower than the inline height, which
     holds at its own px value. The mask is a background painted through the
     logo's alpha; mask-size:contain keeps the mark's own aspect ratio inside
     that box. */
  background-color: var(--tms-logo-color, var(--color-primary));
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
}

/* DELIBERATELY LEFT ON lg WHILE THE ROW ITSELF MOVED TO xl, 2026-08-26. This
   is the logo count inside the panel, and it tracks the PANEL's width, not the
   viewport's. Below 1280 the row stacks, so the panel stops being a ~49% column
   and becomes the full container — it gets WIDER, not narrower. Moving this to
   80rem with the flip would drop a 1087px panel to two marks across, which is
   the opposite of what the step is for.

   Three across from the width where the panel is wide enough to hold them —
   the comp's own 3/3/3/1, at its declared 48 gutter. Rows touch: 10079:6343
   stacks four 70-tall rows with no gap and centres the group in the panel, so
   the rhythm between marks is the row box's own air, not a row gap. */
@media (width >= 64rem) {
  .text-media-split__logos {
    --tms-logo-cols: 3;
    --tms-logo-gap: 3rem;

    row-gap: 0;
  }
}

/* DELIBERATE DEVIATION FROM THE COMP, approved by Chris: once the panel
   becomes the xl side column its own width shrinks below what three marks
   can hold legibly, so it drops back to two rather than staying at three
   and cramming the cells. */
@media (width >= 80rem) {
  .text-media-split__logos {
    --tms-logo-cols: 2;
    --tms-logo-gap: 2rem;

    row-gap: 1.5rem;
  }
}

/* One or two logos: a single stacked, centred column with a taller cell
   instead of splitting a lone mark across a row it doesn't fill. Wins at
   any width — the selector's own specificity outranks every column rule
   above, media query or not. */
.text-media-split__logos:not(:has(> .text-media-split__logo:nth-child(3))) {
  --tms-logo-cols: 1;
}

.text-media-split__logos:not(:has(> .text-media-split__logo:nth-child(3)))
  > .text-media-split__logo {
  /* block.php raises the cap to 90px tall for one or two logos; the same
     20px air as the standard cell. */
  height: 6.875rem;
}

/* Flatten the copy column on mobile so the image can sit before the CTA.
   A flex row at xl keeps percentage bleed margins relative to the full row. */
.text-media-split__col {
  display: contents;
}

/* Phone order: copy, image, button — and the image leads when it bleeds, which
   is what both Services rows draw (8509:5595, 8509:5579). */
.text-media-split__media {
  order: 2;
}

.text-media-split__cta {
  order: 3;
}

.text-media-split__row.is-bleed .text-media-split__media {
  order: -1;
}

@media (width >= 80rem) {
  .text-media-split__col {
    display: flex;
    flex-direction: column;
  }

  .text-media-split__media,
  .text-media-split__cta,
  .text-media-split__row.is-bleed .text-media-split__media {
    order: 0;
  }

  /* Keep the desktop button sized to its label inside the copy column. */
  .text-media-split__cta {
    align-self: flex-start;
  }
}

/* The Home mobile treatment is opt-in; desktop keeps the shared component layout. */
@media (width < 80rem) {
  .text-media-split--mobile-home .text-media-split__eyebrow {
    margin-top: 1rem;
    font-size: var(--text-subtitle-lg);
    line-height: var(--text-subtitle--line-height);
    text-transform: none;
  }

  .text-media-split--mobile-home
    .text-media-split__eyebrow
    + .text-media-split__body {
    margin-top: 1rem;
  }

  .text-media-split--mobile-home .text-media-split__body,
  .text-media-split--mobile-home .text-media-split__body p {
    font-size: var(--text-body);
    line-height: var(--text-body--line-height);
  }

  .text-media-split--mobile-home .text-media-split__figure {
    aspect-ratio: 336 / 251;
  }

  .text-media-split--mobile-home .is-bleed .text-media-split__media {
    margin-inline: 0;
  }

  .text-media-split--mobile-home .is-bleed .text-media-split__figure {
    aspect-ratio: 336 / 300;
  }

  .text-media-split--mobile-home .text-media-split__item-heading {
    font-size: var(--text-h2-mobile);
    line-height: var(--text-h2-mobile--line-height);
    letter-spacing: var(--text-h2-mobile--letter-spacing);
  }

  .text-media-split--mobile-home .text-media-split__cta {
    min-height: 2.125rem;
    font-size: var(--text-button-sm);
    line-height: var(--text-button-sm--line-height);
    font-weight: var(--text-button-sm--font-weight);
    letter-spacing: var(--text-button-sm--letter-spacing);
  }
}

/* Inset media keeps the existing split order while honoring content gutters. */
.text-media-split--media-inset .text-media-split__media {
  margin-inline: 0;
}

.text-media-split--media-inset .text-media-split__figure,
.text-media-split--media-inset .text-media-split__panel {
  border-radius: var(--radius-card);
}

.text-media-split--ethos .text-media-split__body p + p {
  margin-top: 1.75rem;
}

.text-media-split--ethos
  .text-media-split__body
  p:has(> strong:only-child)
  + p {
  margin-top: 0;
}

.text-media-split--ethos .text-media-split__panel .logo-wall {
  width: 100%;
}

.text-media-split--ethos .text-media-split__panel .logo-wall__inner {
  width: 100%;
  padding-inline: 0;
}

@media (width < 80rem) {
  .text-media-split--ethos .text-media-split__row {
    gap: 2rem;
  }

  .text-media-split--ethos .text-media-split__heading {
    font-size: var(--text-h1-mobile);
    line-height: 1.05;
    letter-spacing: 0.005em;
    text-wrap: wrap;
  }

  .text-media-split--ethos .text-media-split__eyebrow {
    margin-top: 1rem;
    font-size: var(--text-subtitle-lg);
    line-height: 1;
  }

  .text-media-split--ethos .text-media-split__body,
  .text-media-split--ethos .text-media-split__body p {
    font-size: var(--text-body);
    line-height: var(--text-body--line-height);
  }

  .text-media-split--ethos .text-media-split__body strong {
    font-weight: 600;
  }

  .text-media-split--ethos .text-media-split__body p + p {
    margin-top: 1.3rem;
  }

  .text-media-split--ethos
    .text-media-split__body
    p:has(> strong:only-child)
    + p {
    margin-top: 0.5rem;
  }

  .text-media-split--ethos .text-media-split__figure {
    aspect-ratio: 336 / 300;
  }

  .text-media-split--ethos .is-bleed .text-media-split__media {
    order: 3;
  }

  .text-media-split--ethos .text-media-split__cta {
    order: 2;
    min-height: 2.125rem;
    font-size: var(--text-button-sm);
    line-height: var(--text-button-sm--line-height);
    letter-spacing: var(--text-button-sm--letter-spacing);
  }

  .text-media-split--ethos:has(.text-media-split__panel) {
    padding-bottom: 0;
  }

  .text-media-split--ethos:has(.text-media-split__panel)
    .text-media-split__body {
    margin-top: 1.5rem;
  }

  .text-media-split--ethos .text-media-split__panel {
    aspect-ratio: auto;
  }
}

:is(.text-media-split--services-list, .text-media-split--service-detail)
  .text-media-split__heading {
  font-size: var(--text-h3);
  line-height: 1.08;
  letter-spacing: -0.005em;
  text-wrap: wrap;
}

.text-media-split--services-list .text-media-split__body,
.text-media-split--services-list .text-media-split__body p {
  font-size: var(--text-body);
  line-height: var(--text-body--line-height);
}

.text-media-split--services-list .text-media-split__body strong {
  font-weight: var(--text-body-emphasis--font-weight);
}

.text-media-split--service-detail .text-media-split__body,
.text-media-split--service-detail .text-media-split__body p {
  font-size: var(--text-paragraph-md);
  line-height: var(--text-paragraph-md--line-height);
}

.text-media-split--service-detail .text-media-split__body p + p {
  margin-top: 2.35rem;
}

.text-media-split--service-detail .text-media-split__figure {
  border-radius: 0.5rem;
}

@media (width >= 80rem) {
  .main--under-header > .text-media-split--service-detail:first-of-type {
    padding-top: 2.875rem;
  }

  .text-media-split--service-detail .text-media-split__row {
    align-items: flex-start;
  }

  .text-media-split--service-detail .text-media-split__col {
    padding-top: 5.3125rem;
  }
}

@media (width < 80rem) {
  .hero + .text-media-split--services-list {
    padding-top: 4rem;
  }

  .text-media-split--services-list:has(+ .section-intro) {
    padding-bottom: 3rem;
  }

  :is(.text-media-split--services-list, .text-media-split--service-detail)
    .text-media-split__figure {
    aspect-ratio: 336 / 300;
  }

  .text-media-split--services-list .text-media-split__row {
    gap: 2rem;
  }

  .text-media-split--services-list .text-media-split__col {
    display: flex;
    flex-direction: column;
    gap: 2rem;
  }

  .text-media-split--services-list.text-media-split--gap-64
    .text-media-split__row {
    gap: 4rem;
  }

  .text-media-split--services-list.text-media-split--mobile-before-content
    .text-media-split__media {
    order: -1;
  }

  .text-media-split--services-list.text-media-split--mobile-after-cta
    .text-media-split__media {
    order: 4;
  }

  .text-media-split--services-list.text-media-split--heading-display
    .text-media-split__heading {
    font-size: var(--text-h1-mobile);
    line-height: var(--text-h1-mobile--line-height);
    letter-spacing: var(--text-h1-mobile--letter-spacing);
  }

  .text-media-split--services-list .text-media-split__cta {
    width: 100%;
    min-height: 2.125rem;
    font-size: var(--text-button-sm);
    line-height: var(--text-button-sm--line-height);
    letter-spacing: var(--text-button-sm--letter-spacing);
  }

  .main--under-header > .text-media-split--service-detail:first-of-type {
    padding-top: 3rem;
  }

  .text-media-split--service-detail .text-media-split__row {
    gap: 4rem;
  }
}

.text-media-split--services-list .text-media-split__body li + li {
  margin-top: 1.5rem;
}

@media (width < 80rem) {
  .text-media-split--services-list + .text-media-split--services-list {
    padding-top: 1.25rem;
  }
}

@media (width >= 80rem) {
  .text-media-split--service-detail.text-media-split--detail-compact {
    padding-bottom: 4.125rem;
  }
}

@media (width < 80rem) {
  :is(.text-media-split--services-list, .text-media-split--service-detail)
    .text-media-split__inner {
    padding-inline: 1.6875rem;
  }
}

@media (width >= 80rem) {
  :is(.text-media-split--services-list, .text-media-split--service-detail)
    .text-media-split__inner {
    padding-inline: 5.75rem;
  }
}

/* Each Logo colour option maps to a theme token; yellow is the default. */
.text-media-split__panel--logo-earth {
  --tms-logo-color: var(--color-earth-900);
}

.text-media-split__panel--logo-white {
  --tms-logo-color: var(--color-white);
}
