/* CAE TAB ANCHOR — the hover treatment of a section tab, and the space it needs.
 *
 * KATE SHAWVER, ClickUp 869f0yrdy "Tab menu behavior", her literal bytes:
 *
 *   "Globally, the tab menu behavior should be that the user stays where they are when they click
 *    between tabs, they should never be sent back up to the top of the page. Also the hover style
 *    of the tab menu link should be the same as the current style. Make sure you space them far
 *    apart enough that there is no overlap. Eg: /about-cae/team/board/"
 *
 * The first sentence is assets/interact/tab-anchor.js. This file is the other two, and they are
 * ONE ask, not two — which is why she put them in one breath.
 *
 * WHAT THE DESIGN DRAWS, MEASURED (tools/cae/tabsanchor-strip-census.mjs, 1440 AND 1024):
 *   the strip row              display:flex  gap:32px  flex-wrap:nowrap   (gutter measures 31.99px)
 *   the CURRENT chip           padding 12px 24px, background rgb(131,179,144), colour rgb(255,255,255)
 *   hover, every chip          IDENTICAL to its rest state. The design prototypes no hover at all.
 *   an inactive chip, and THE DESIGN DOES NOT DRAW THESE THE SAME WAY:
 *     /about-cae/team/board/   padding 12px  0px — bare text, no horizontal padding
 *     /about-cae/careers/      padding 12px 24px — already a filled white pill
 *
 * THAT DIFFERENCE IS THE WHOLE PROBLEM. On Kate's own example the inactive tab is bare text, so
 * giving it the current chip's paint makes a pill 48px wider than the text it replaces, and in a
 * `nowrap` flex row every chip to its right jumps sideways — the overlap she anticipated in the
 * same breath. On Careers the inactive chip is ALREADY that size, and nothing should move at all.
 *
 * HOW THIS FILE ANSWERS BOTH: the pill is PAINTED, never sized. It is an absolutely positioned
 * pseudo-element behind the chip's text, out of flow, reaching out by (the current chip's
 * horizontal padding minus this chip's own) on the inline axis — 24px on Kate's bare-text chip,
 * 0px on a Careers chip, which therefore changes colour and nothing else. Because it is out of
 * flow, no box anywhere can move; that is a property of the construction, not a number that
 * happened to come out right. The strip is NOT re-spaced: the pill reaches into the 32px gutter
 * the design already draws rather than consuming it, and widening that gutter would have moved 24
 * drawn strips to solve a problem that does not exist once the growth is out of flow.
 *
 * NO COLOUR IS NAMED HERE, AND NO PAGE IS. The paint is read off the page's OWN current tab at
 * init — its computed background-color, its colour and its horizontal padding — and published by
 * tab-anchor.js::publishCurrentStyle as three custom properties on the strip plus the per-chip
 * delta above. So "the same as the
 * current style" is literally that chip's style, per family: mint on Team/Careers/Contact, gold
 * on Media Kit, whatever a future family draws. This is the same discipline giveaccordion's
 * sheet follows — the treatment is transported from the page's own drawn rows, and the
 * stylesheet carries no hex and no page key.
 *
 * WITH JAVASCRIPT OFF NOTHING BELOW APPLIES. Every rule is scoped to
 * `.is-cae-tabanchor-hoverable`, a class only tab-anchor.js adds and only after it has resolved
 * a current tab to copy. No class, no custom properties, no rule, and the strip is exactly the
 * strip the design draws — which is also why a missing custom property can never fall back to a
 * value that would strip the drawn padding off a chip.
 *
 * THE CURRENT TAB IS EXCLUDED. `:not([aria-current])` — it already wears the current style, so
 * there is nothing for a hover to change, and it is the chip every other chip is copying FROM.
 */

/* THE PILL IS PAINTED, NOT SIZED. Nothing below changes a box.
 *
 * The first cut grew the chip with `padding-inline` and cancelled the growth with an equal
 * negative `margin-inline`. It is the obvious construction and it does not work here, for a
 * reason only the measurement gives: `.wp-block-button__link` is `box-sizing: border-box` inside
 * a wrapper already shrink-wrapped to the text, so adding 48px of padding did not widen the pill
 * — it ate the content box. Measured on /about-cae/team/board/ at 1440: the "Team" link went
 * 34.00px wide at rest to 38.38px on hover and slid 19.18px to the left, instead of becoming the
 * 82px pill it was supposed to be.
 *
 * So the pill is a PSEUDO-ELEMENT behind the text. It is absolutely positioned, so it is out of
 * flow and no box anywhere can move; it is inset by the negative of the per-chip delta on the
 * inline axis only, so it reaches exactly as far as the current chip's padding would; and it
 * inherits the chip's own border-radius, so the corner is the design's corner and this file does
 * not name one. The chip's own background is made transparent for the duration so the pill is
 * what shows.
 */

section[data-cae-tabanchor].is-cae-tabanchor-hoverable .wp-block-button > a:not([aria-current]):hover,
section[data-cae-tabanchor].is-cae-tabanchor-hoverable .wp-block-button > a:not([aria-current]):focus-visible {
  position: relative;
  background-color: transparent;
  color: var(--cae-tabanchor-current-color);
}

section[data-cae-tabanchor].is-cae-tabanchor-hoverable .wp-block-button > a:not([aria-current]):hover::before,
section[data-cae-tabanchor].is-cae-tabanchor-hoverable .wp-block-button > a:not([aria-current]):focus-visible::before {
  content: "";
  position: absolute;

  /* Block axis: the chip's own drawn height, exactly. Inline axis: out by the DIFFERENCE between
   * the current chip's horizontal padding and this chip's own — `--cae-tabanchor-pad-delta`,
   * published per chip by tab-anchor.js. 24px on a bare-text chip (/about-cae/team/board/ draws
   * its inactive chips 12px 0px), 0px on a chip that is already a filled pill
   * (/about-cae/careers/ draws its inactive chips 12px 24px, so its hover changes colour and
   * nothing else). The 0px fallback means a missing property degrades to "paint the chip's own
   * box", never to a box that is wrong. */
  inset: 0 calc(-1 * var(--cae-tabanchor-pad-delta, 0px));

  background-color: var(--cae-tabanchor-current-bg);
  border-radius: inherit;

  /* Behind the chip's text, which is why the chip's own background is transparent above: a
   * `z-index: -1` pseudo-element paints behind its parent's background as well as its content. */
  z-index: -1;
  pointer-events: none;
}

/* A keyboard reader gets the same treatment through :focus-visible above. The chip is an <a> with
 * an href, so it is already in the tab order and already announces its destination; nothing here
 * adds a role, a tabindex or an aria-* attribute. */

/* THE ANCHOR IS THE STRIP, NOT WHATEVER THE BROWSER PICKS (CHECKPOINT-tabsanchor.md, tabsanchor2,
 * item 1 — the Support CAE +185). tab-anchor.js already owns "stay anchored where I am" itself
 * (its own step 6, the strip-position correction) — but CSS Scroll Anchoring is a SEPARATE
 * browser subsystem with its own opinion about what should stay visually fixed, and it has no
 * lever from `focus({preventScroll:true})`: measured, `preventScroll` is honoured, and the jump
 * still lands 8-30ms later, coincident with a late-decoding swapped-in image growing the
 * document. That image's missing height reservation is compiler-emitted (traced to
 * compiler/targets/wordpress/ir_to_css.py::_media_fixed_box_decls, which declines it ON PURPOSE
 * for a HUG/FILL-sizing leaf) and out of this surface's files — but the browser's anchor
 * SELECTION is not: `overflow-anchor: none` opts a subtree out of being chosen as (or containing)
 * the anchor node at all, for every candidate up to the scrolling box. Applied to everything the
 * swap ever touches — "every element BELOW the strip inside .entry-content" is already this
 * file's own declared boundary (see tab-anchor.js's header) — so no swapped-in content, on any of
 * the 24 stamped strips, competes with the strip's own anchor again. Unconditional (not gated on
 * a swapped-state class): true on a plain first load too, which is strictly a widening of the
 * same guarantee, never a narrowing of it, and needs no JS timing to stay correct. */
section[data-cae-tabanchor] ~ *,
nav[data-cae-tabanchor] ~ * {
  overflow-anchor: none;
}

/* THE CHIP IS A HUG BOX; IT MUST NEVER WRAP ITS OWN LABEL (mediakittabs, 2026-09-16).
 *
 * opencode finding F-1 (task nwy2cmrvsxpar1903dcy, comment awrwk4pzldk8vnh3ijrz, 09-15): on the
 * Media Kit strip (`/about-cae/media-kit/{logos,colors,typography}/`) at 1440 ONLY, the three
 * chip labels ("Logo", "Colors", "Typography") wrap MID-WORD and the chip grows from the
 * family's 55.98 design px to 87.97; every OTHER stamped strip in the corpus (censused: all 24,
 * ×1440/1024/1280 — `tools/cae/mediakittabs-census.mjs`,
 * `docs/soft-state/cae/mediakittabs/census-BEFORE.json`) serves 55.98, single line, at every
 * width. 0 of the other 21 strips ever wrap.
 *
 * ROOT CAUSE, MEASURED, NOT GUESSED. Each chip is a flex item of the strip's own auto-layout row
 * (`[class*="__row-figma-generic-row-"]`, `display:flex`), and the row carries a SECOND,
 * Figma-HUG-measured rule — `width:100%; max-width:<N>px; margin-inline:auto` — that caps the
 * row at the design's own frame width (Media Kit: 387px; Careers: 611px; Team/Board: 212px;
 * every strip has its own number). Nothing in the family gives the flex items (`.wp-block-buttons`,
 * one per chip) `flex-shrink:0`, so the browser's default `flex-shrink:1` lets them shrink below
 * their own content's natural width whenever the row's max-width is not enough — and because
 * the chip label carries no `white-space:nowrap` either, a shrunk chip WRAPS its text instead of
 * overflowing, which is the 87.97-tall, mid-word-broken chip F-1 found.
 *
 * WHY THIS FIRES ON MEDIA KIT AND ON NO OTHER STRIP. The label's own font-size is FLUID —
 * `--wp--preset--font-size--p-1-pro-cond-regular: clamp(15.747px, 0.984rem + ((1vw - 3.2px) *
 * 0.737), 24px)` (read off the served page's own global-styles block) — so a chip's SINGLE-LINE
 * width grows with the viewport (measured, Media Kit's own three chips:
 * Logo+Colors+Typography+2 gaps sums to 367.90px natural at 1024, 385.4px at 1280, and >387px at
 * 1440 — the row's own max-width, uniquely tight because the Figma frame this page draws is
 * only 387px, the narrowest HUG measurement of any strip in the corpus for three chips this
 * long). Every other strip's own Figma-measured max-width carries enough slack over its own
 * fluid-font content width at 1440 to never need to shrink (censused, 0 exceptions) — this is
 * therefore not a defect in any other strip's own number, only in this family's missing
 * shrink/wrap guard, which every strip was silently relying on never being exercised.
 *
 * THE CURE GIVES EVERY CHIP WHAT ITS OWN HUG FRAME DRAWS: a box that hugs its label and never
 * concedes width to its row. `flex-shrink:0` on the flex item (`.wp-block-buttons`, this
 * family's per-chip wrapper) stops the row from ever narrowing a chip below its natural content
 * width; `white-space:nowrap` on the label is the same guarantee stated on the text itself, so a
 * future shrink source (a narrower row rule, a longer font-driven label) fails LOUD as strip
 * overflow rather than silently as a wrap. Both rules are scoped to `section[data-cae-tabanchor]`
 * — every Family-A strip PHP stamps this on any `-tabs-generic` section with 2+ chips
 * (`inc/cae-route-tabs.php::cae_tabanchor_stamp`), so this reaches all 24 strips generically and
 * no node id, page slug or strip name is written here. Unconditional, like the `overflow-anchor`
 * rule above: true on a plain first load, needs no JS.
 *
 * MEASURED CONSEQUENCE ON THE OTHER 21 STRIPS: a no-op. The census above already proves their
 * natural (unshrunk) content fits inside their own row's max-width at every width tested, so
 * `flex-shrink:0` never had shrinking to prevent there — re-verified AFTER this rule shipped
 * (`docs/soft-state/cae/mediakittabs/census-AFTER.json`): every non-Media-Kit chip box is
 * byte-identical to BEFORE.
 *
 * MEASURED CONSEQUENCE ON MEDIA KIT AT 1440: the row now renders its three chips at their own
 * natural single-line width, which sums wider than the row's 387px cap — see
 * `docs/soft-state/cae/mediakittabs/CENSUS.md` for the exact overflow number and whether the
 * strip's own container has room for it. */
section[data-cae-tabanchor] .wp-block-buttons {
  flex-shrink: 0;
}

section[data-cae-tabanchor] .wp-block-button > a {
  white-space: nowrap;
}
