/* ==========================================================================
   AVENIR — WordPress adaptations

   Every WordPress-caused deviation from the prototype lives here, and nowhere else, so
   assets/css/styles.css can stay a verbatim copy of the prototype (TECH-003). Its scope is
   fixed at the four categories below. It is not a place to redesign anything.

   BINDING RULE (TECH-003): this stylesheet may never contain a selector that can
   out-specify styles.css. Anything that neutralises a WordPress default must be written at
   specificity (0,0,0) — wrap it in :where() — so it loses to every prototype rule while
   still beating core, which this file is enqueued after. A selector here that outweighs the
   prototype does not "adapt" the design, it silently overrides it, and the damage is
   invisible in this file: it shows up as missing spacing somewhere in styles.css. The only
   exemptions are rules that target markup the prototype does not style at all — the
   .admin-bar offsets and the .avenir-inner fallback chrome below. A rule whose purpose is
   to beat styles.css is not an adaptation and does not belong here either; it belongs in
   assets/css/deviations.css under TECH-019's admission rule.
   ========================================================================== */

/* ---------- 1. neutralise WordPress wrapper styling ---------- */

/* Core wraps every block template in .wp-site-blocks and gives its children vertical
   rhythm. The prototype's sections own their own spacing, so it is zeroed out.

   Wrapped in :where() to force specificity (0,0,0). Without it the selectors weigh (0,2,0)
   and beat the prototype's own single-class margins — and because logical and physical
   properties cascade together, margin-block-start: 0 silently overrode rules such as
   .section__head { margin-bottom } (styles.css:94), .eyebrow { margin-bottom }
   (styles.css:101-106) and .section__lede { margin-top } (styles.css:92) on every section.
   At zero specificity the rule still beats core's own :where()-based injections, because
   this file is enqueued after core's global styles, while losing to every prototype rule. */
:where(.wp-site-blocks) > *,
:where(.wp-block-group.is-layout-flow) > *,
:where(.wp-block-template-part) > * {
	margin-block-start: 0;
	margin-block-end: 0;
}

/* core/template-part always emits a wrapper element around the header and footer. It is
   referenced with tagName "div" and left untransformed, so it creates no containing block
   for their position: fixed; this only strips the margin WordPress would give it. */
.wp-block-template-part {
	margin: 0;
}

/* ---------- 2. admin-bar offset for the fixed header ---------- */

/* The header is position: fixed at the top of the viewport, so for a logged-in user the
   admin bar sits on top of it. It shifts down by the admin bar's height, plus whatever
   styles.css:1440 already offsets it by. The + var(--topbar-h) term is kept deliberately:
   it makes the rule correct for any value of the token, and CN-04 / TECH-021 set that token
   to 0px in deviations.css. Hard-coding the sum here would couple this rule to the current
   value — the shape of hidden coupling that made assumption A-04 fail. The demo topbar's
   own offset was removed here by CN-04, together with the notice; if a top bar is ever
   reinstated, styles.css still carries its presentation rules and only that one .admin-bar
   rule needs restoring. */
.admin-bar .header {
	top: calc(var(--wp-admin--admin-bar--height, 32px) + var(--topbar-h));
}

/* This override returns the header to its prototype position at the widths where the admin
   bar scrolls away with the page, so there is nothing fixed above the header to clear.
   The breakpoint is the admin bar's *positioning* breakpoint, not its height breakpoint:
   core sets #wpadminbar { position: absolute } inside @media (max-width: 600px) only
   (wp-includes/css/admin-bar.css:1111), while the 46px height starts at 782px. The query was
   written at 782px, so between 601px and 782px a still-fixed 46px bar covered 46 of the
   header's 68px: a 22px strip stayed visible, but the brand and the nav toggle had their
   centres inside the covered band and hit-tested to the admin bar, so the header's controls
   were unreachable — ISSUE-CN04-01, measured at 782, 760, 700 and 601px;
   pre-existing (10px covered when --topbar-h was 36px) and widened to 46px by CN-04. Narrowed
   to 600px here, which is the whole fix: between 601px and 782px the rule above applies on its
   own and computes calc(46px + 0px), because core sets --wp-admin--admin-bar--height: 46px
   at <=782px (admin-bar.css:787). The offset stays token-driven — never hard-code the sum. */
@media screen and (max-width: 600px) {
	.admin-bar .header {
		top: var(--topbar-h);
	}
}

/* ---------- 3. prototype inline styles that block attributes cannot carry ---------- */

/* Replaces style="margin-inline:auto" on the team section's lede: core/paragraph has no
   attribute for it, and the prototype centres the lede in every centred section head. */
.section__head--center .section__lede {
	margin-inline: auto;
}

/* CN-06 / TECH-028: the per-card description paragraph added to patterns/section-services.php
   exists for the mobile services stack only; above the breakpoint it would print over the
   coverflow art. Its default has to be an unconditional rule, and the mobile layer in
   deviations.css may contain nothing outside a max-width query, so the default lives here and
   the mobile layer switches it back on below 899px. This does not weaken the binding rule
   above: .cover__desc is a class the prototype's styles.css has never declared, so there is
   nothing here for it to out-specify — it styles markup the prototype does not style, exactly
   like the .admin-bar and .avenir-inner exemptions. */
.cover__desc {
	display: none;
}

/* ---------- 4. minimal chrome for the fallback templates ---------- */

/* index / page / single / search / 404 are not designed by the prototype (inner pages are
   out of scope). This gives their content the prototype's container width and clears the
   fixed header, so no URL renders unstyled or underneath it. The + var(--topbar-h) term is
   kept for the same reason as the .admin-bar rule above: correct for any token value, and
   0px since CN-04. */
.avenir-inner {
	max-width: var(--container);
	margin-inline: auto;
	padding-inline: var(--gutter);
	padding-block: calc(var(--topbar-h) + 140px) var(--section-y);
}

/* styles.css:74 zeroes the margin on every heading and paragraph, which is right for the
   designed sections but would run post content together on the fallback templates. */
.avenir-inner > * + * {
	margin-block-start: 1.5rem;
}
