/*
 * TBR Block Normalizer
 * ====================
 * Strips WordPress core block CSS opinions before the TBR design system loads.
 *
 * LOAD ORDER (enforced in functions.php):
 *   1. wp-block-*/style.min.css  — WordPress (uncontrollable)
 *   2. THIS FILE                 — resets WP defaults to zero
 *   3. tbr-design-system.css    — TBR tokens + components (Fiona)
 *   4. header.css, footer.css… — per-component interaction states (Meera)
 *
 * RULES:
 *   - Use :where() when zero specificity is correct (safe baseline resets).
 *   - Use :is() when we need to match WP's specificity and still win.
 *   - Never use !important here — if something needs !important, the specificity
 *     architecture is wrong. Fix the selector chain instead.
 *   - One block per section. Document WHY each reset exists.
 *
 * FOR FIONA:
 *   Each section is marked [REVIEW] for items that may affect design decisions.
 *   Anything marked [SAFE] is a mechanical reset with no design implication.
 */


/* ─────────────────────────────────────────────────────────────
   NAVIGATION BLOCK  (wp-block-navigation/style.min.css)
   ───────────────────────────────────────────────────────────── */

/*
 * [SAFE] WP sets padding:0 on nav item content via :where() — zero specificity.
 * We reset explicitly with :where() so our component CSS can set padding cleanly
 * without needing extra selectors to win.
 */
:where(.wp-block-navigation .wp-block-navigation-item .wp-block-navigation-item__content) {
    padding: 0;
    color: inherit;
    display: flex;
    align-items: center;
}

/*
 * [SAFE] WP sets font-size and font-weight on the navigation block element
 * via inline global styles. Zero these out so component CSS owns typography.
 */
:where(.wp-block-navigation) {
    font-size: inherit;
    font-weight: inherit;
}

/*
 * [SAFE] WP adds list styles to navigation containers.
 */
:where(.wp-block-navigation ul) {
    list-style: none;
    margin: 0;
    padding: 0;
}

/*
 * [SAFE] Strip WP underline override on nav links.
 */
:where(.wp-block-navigation a) {
    text-decoration: none;
}

/*
 * [SAFE] Reset sub-menu container positioning baseline.
 * Component CSS (header.css) sets the actual values.
 */
:where(.wp-block-navigation__submenu-container) {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
}


/* ─────────────────────────────────────────────────────────────
   BUTTON BLOCK  (wp-block-button/style.min.css)
   ───────────────────────────────────────────────────────────── */

/*
 * [REVIEW — Fiona] WP sets border-radius:9999px (pill) on all buttons by default.
 * TBR buttons use 0.25rem radius via .btn class. Zero out WP's default so .btn
 * doesn't need to fight it.
 *
 * If any page intentionally uses a pill-radius WP button WITHOUT .btn class,
 * this will remove that radius. Flag to Fiona.
 */
:where(.wp-block-button__link) {
    border-radius: 0;
    box-shadow: none;
}

/*
 * [REVIEW — Fiona] WP sets padding: calc(0.667em + 2px) calc(1.333em + 2px) on buttons.
 * TBR .btn class sets its own padding. Zero out to avoid compound padding.
 */
:where(.wp-block-button__link) {
    padding: 0;
}

/*
 * [SAFE] WP sets text-align:center on button links. TBR buttons are inline-flex.
 */
:where(.wp-block-button__link) {
    text-align: left;
}


/* ─────────────────────────────────────────────────────────────
   GROUP BLOCK  (wp-block-group/style.min.css)
   ───────────────────────────────────────────────────────────── */

/*
 * [SAFE] WP sets box-sizing:border-box. Keep this — it's correct.
 * No reset needed for group block.
 */


/* ─────────────────────────────────────────────────────────────
   HEADING BLOCK
   ───────────────────────────────────────────────────────────── */

/*
 * [SAFE] WP inherits browser heading margins. Zero them out so section
 * headers only have spacing where the design system explicitly sets it.
 */
:where(.wp-block-heading) {
    margin-block-start: 0;
    margin-block-end: 0;
}


/* ─────────────────────────────────────────────────────────────
   PARAGRAPH BLOCK
   ───────────────────────────────────────────────────────────── */

/*
 * [SAFE] Browser default paragraph margin. Zero out — DS handles spacing via
 * blockGap and section padding, not paragraph margin.
 */
:where(.wp-block-paragraph) {
    margin-block-start: 0;
    margin-block-end: 0;
}


/* ─────────────────────────────────────────────────────────────
   IMAGE BLOCK
   ───────────────────────────────────────────────────────────── */

/*
 * [SAFE] WP wraps images in figure with browser default margin. Zero it.
 */
:where(.wp-block-image) {
    margin: 0;
}

/*
 * [SAFE] Ensure images are responsive by default.
 */
:where(.wp-block-image img) {
    height: auto;
    max-width: 100%;
}


/* ─────────────────────────────────────────────────────────────
   COLUMNS BLOCK
   ───────────────────────────────────────────────────────────── */

/*
 * [SAFE] WP adds gap via --wp--style--block-gap. Normalise so DS spacing tokens
 * are the only source of gaps in column layouts.
 */
:where(.wp-block-columns) {
    gap: 0;
}

:where(.wp-block-column) {
    flex-basis: auto;
}


/* ─────────────────────────────────────────────────────────────
   GLOBAL LINK HANDLING
   ───────────────────────────────────────────────────────────── */

/*
 * [REVIEW — Fiona] WP global styles often inject color:inherit on links inside
 * blocks. This can override our link colours. Ensure TBR colours cascade from
 * the design system, not WP global styles.
 */
:where(.wp-block-navigation a:not(.wp-element-button)),
:where(.wp-block-group a:not(.wp-element-button)) {
    color: inherit;
}
