/*
 * Zoey Made — hero decoration.
 *
 * SL-006's `G1`. Where a decorative mark sits, how large it is, and what happens to it on a phone
 * and at a reader's enlarged text settings. Three things, and nothing else:
 *
 *   the artwork    components/doodle.css — the mask, the shape, the Safari prefix
 *   the colour     a has-{slug}-color palette class, put on the element by the renderer
 *   the placement  this file
 *
 * That split is deliberate and it is the same one the three world marks already use: the doodle
 * family draws, and the surface that places it decides where. What `G1` adds is that *this* file is
 * shared, so the later section-landing pass positions its marks by wearing these rules rather than
 * writing a fourth set of its own.
 *
 * ## The group is the containing block, and that is the safety property
 *
 * A mark positioned against "the hero" would in practice be positioned against whichever ancestor
 * happened to establish a containing block — which is how decoration ends up on top of a control
 * at a width nobody measured. So `zoey_made_decoration_group()` emits one positioned layer, the
 * surface decides where that layer goes, and a mark can only ever be placed inside it. Nothing in
 * this file positions anything against an ancestor it does not own.
 *
 * ## Inert, in three independent ways
 *
 * `pointer-events: none` on the layer and on every mark, `aria-hidden` from the renderer, and no
 * text content and no focusable element anywhere. Any one of the three would be enough; all three
 * are stated because a decoration that becomes reachable is an unlabelled control, and this is the
 * one property that must not be able to regress quietly.
 *
 * ## Forced colors and print
 *
 * Both drop these marks, and that is correct rather than a limitation. A mask paints with
 * `background-color`, which forced colors replaces with the canvas — so the shape is simply not
 * painted, and nothing is lost because nothing here carries meaning. `components/doodle.css`
 * records the boundary at length: a shape whose *recognition* matters is an inline SVG with a real
 * fill and stroke, which is what every discovery object is. The Shop design contract permits
 * exactly this suppression for purely decorative marks.
 *
 * Design values come from theme.json. See docs/CSS-AND-ASSETS.md.
 */

/*
 * ## `SL-008`'s two adopted marks
 *
 * The Cart's totals panel is WooCommerce's React and cannot be given a `<span>` — `G1` measured
 * server-rendered children of that region destroyed at hydration — so its required star and heart
 * are pseudo-elements that wear these rules rather than restating them. They are named on the four
 * rules that decide what a mark *is*: absolute and inert, the doodle family's size knob, the
 * `small` step, and the phone reduction. `components/doodle.css` adopts them for the artwork and
 * the mask; `components/commerce.css` supplies only `content` and the two insets, because only the
 * Cart knows where its own figures have gone.
 *
 * **They are inert in two of the three independent ways the rendered marks are**, and the third is
 * not replaced by a stronger guarantee — it is simply absent, which is worth saying plainly.
 * `pointer-events: none` is above, and a pseudo-element holds no focus and no DOM node, so there is
 * nothing to put `aria-hidden` on.
 *
 * What makes that acceptable here is **what these particular pseudo-elements contain**: `content`
 * is the empty string, and the shape is a `mask-image` painted with `background-color`. There is no
 * generated *text* for an accessibility API to expose. That is narrower than "a pseudo-element is
 * never in the accessibility tree" — which is not true, because browsers do expose generated text
 * from `content` — and it is the claim `SL-008` actually measured: zero elements added to the
 * panel, `content` computing to `""`, and a pointer at the checkout action's centre still landing
 * on the anchor. **No screen reader was run**, so what any assistive technology announces here is
 * untested and is named as deferred evidence rather than assumed.
 *
 * Forced colors needs no rule and has none, for the pair and for the family: a mask paints with
 * `background-color`, which forced-colors replaces with the canvas, so these marks simply are not
 * drawn. That is the suppression the Shop design contract permits for decoration.
 */

/*
 * The layer.
 *
 * `absolute` rather than `fixed`, over the region a surface nominates, and inert. It reserves no
 * space, so adding or removing decoration cannot move a single word — which is the property that
 * lets `DESIGN-CONTRACT.md`'s *"must not overlap text, Bubble, controls or focus rings"* be
 * answered by placement rather than by layout.
 *
 * `overflow: clip` is the horizontal-scroll guard, and it is the one rule here that exists because
 * of a measured failure mode rather than a design intent: a mark placed against the trailing edge
 * at a narrow width, with a reader's text at 200%, grows in `rem` and can reach past the layer's
 * own box. Clipping the layer means the worst case is a mark that is partly drawn, never a page
 * that scrolls sideways. `clip` rather than `hidden` because it creates no scroll container of its
 * own.
 */
/*
 * **`inset: 0` is a default a consuming surface is expected to replace**, and a surface that
 * replaces it needs **two classes** to do so.
 *
 * This file is enqueued after the feature stylesheets that use it, so a single-class rule on a
 * surface's own group class loses this declaration on source order. `SL-006` paid for that twice in
 * one hero — the layer spanning a whole phone viewport instead of the content column, and the marks
 * painting at the doodle family's default size — and both are fixed the same way:
 * `.zoey-decoration-group.my-surface-class`, not `.my-surface-class`.
 */
.zoey-decoration-group {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: clip;
  pointer-events: none;
}

/*
 * A mark.
 *
 * The size is a named step's length, written onto the doodle family's own `--zoey-doodle-size` so
 * the mask sizing stays declared in exactly one place. `block` rather than the family's
 * `inline-block`, because a positioned mark is not sitting in a line of text.
 */
.zoey-decoration,
.woocommerce-cart .wc-block-cart__sidebar > .wp-block-woocommerce-cart-order-summary-block::before,
.woocommerce-cart .wc-block-cart__submit::after,
.zoey-checkout .wp-block-woocommerce-checkout-totals-block .wc-block-components-checkout-order-summary__title::before,
.zoey-checkout .wp-block-woocommerce-checkout-totals-block .wc-block-components-checkout-order-summary__title::after {
  --zoey-decoration-scale: 1;

  position: absolute;
  display: block;
  pointer-events: none;
}

/*
 * The size, and **the two-class selector is load-bearing rather than stylistic**.
 *
 * `components/doodle.css` declares `--zoey-doodle-size: 1.5em` on `.zoey-doodle`, and every mark
 * here wears both classes. Two single-class declarations of one property on one element are decided
 * by **source order**, and the order these two files print in is an enqueue detail — so the first
 * version of this rule lost to the doodle family's own default and every accent painted at 24px
 * whatever size it asked for. Measured in the browser: a `large` star that should have been 48px.
 *
 * Restating the doodle class beats it on specificity, which is the same trick — and the same
 * reasoning — `components/product-card.css` records for its focus ring: a rule that wins by source
 * order is a rule that breaks the day the list is reordered.
 *
 * One derived value, so the phone step below is a single declaration: the size classes set
 * `--zoey-decoration-step`, the query changes `--zoey-decoration-scale`, and this is the only place
 * the doodle family's own knob is written.
 */
.zoey-decoration.zoey-doodle,
.woocommerce-cart .wc-block-cart__sidebar > .wp-block-woocommerce-cart-order-summary-block::before,
.woocommerce-cart .wc-block-cart__submit::after,
.zoey-checkout .wp-block-woocommerce-checkout-totals-block .wc-block-components-checkout-order-summary__title::before,
.zoey-checkout .wp-block-woocommerce-checkout-totals-block .wc-block-components-checkout-order-summary__title::after {
  --zoey-doodle-size: calc(var(--zoey-decoration-step) * var(--zoey-decoration-scale));
}

.zoey-decoration--size-small,
.woocommerce-cart .wc-block-cart__sidebar > .wp-block-woocommerce-cart-order-summary-block::before,
.woocommerce-cart .wc-block-cart__submit::after,
.zoey-checkout .wp-block-woocommerce-checkout-totals-block .wc-block-components-checkout-order-summary__title::before,
.zoey-checkout .wp-block-woocommerce-checkout-totals-block .wc-block-components-checkout-order-summary__title::after {
  --zoey-decoration-step: 1.25rem;
}

.zoey-decoration--size-medium {
  --zoey-decoration-step: 2rem;
}

.zoey-decoration--size-large {
  --zoey-decoration-step: 3rem;
}

/*
 * The named corners.
 *
 * Logical properties throughout, so the treatment follows writing direction rather than baking in
 * one. The inset is a spacing token rather than a number, which is what keeps a mark's distance
 * from the edge the same distance the surfaces around it use.
 */
.zoey-decoration--at-top-end {
  inset-block-start: var(--wp--preset--spacing--20);
  inset-inline-end: var(--wp--preset--spacing--20);
}

.zoey-decoration--at-top-start {
  inset-block-start: var(--wp--preset--spacing--20);
  inset-inline-start: var(--wp--preset--spacing--20);
}

.zoey-decoration--at-bottom-end {
  inset-block-end: var(--wp--preset--spacing--20);
  inset-inline-end: var(--wp--preset--spacing--20);
}

.zoey-decoration--at-bottom-start {
  inset-block-end: var(--wp--preset--spacing--20);
  inset-inline-start: var(--wp--preset--spacing--20);
}

.zoey-decoration--at-middle-end {
  inset-block-start: 50%;
  inset-inline-end: var(--wp--preset--spacing--20);
  transform: translateY(-50%);
}

/*
 * The phone step.
 *
 * One rule rather than a second size table: every mark drops one step's worth below 720px, which is
 * the same threshold the section hero's own character cap uses. `DESIGN-CONTRACT.md` asks for a
 * *"visible modest star/heart composition, repositioned in safe hero space rather than omitted"* on
 * mobile — so this reduces and never hides, and the repositioning is the consuming surface's,
 * because only the surface knows where its own copy has gone.
 *
 * Expressed as a multiplier on the step rather than as three overrides, so a step added above
 * needs nothing added here.
 */
@media (max-width: 719px) {
  .zoey-decoration,
  .woocommerce-cart .wc-block-cart__sidebar > .wp-block-woocommerce-cart-order-summary-block::before,
  .woocommerce-cart .wc-block-cart__submit::after,
  .zoey-checkout .wp-block-woocommerce-checkout-totals-block .wc-block-components-checkout-order-summary__title::before,
  .zoey-checkout .wp-block-woocommerce-checkout-totals-block .wc-block-components-checkout-order-summary__title::after {
    --zoey-decoration-scale: 0.7;
  }
}

/*
 * Reduced motion needs no rule and gets none: these are static in v1, which is
 * `DESIGN-CONTRACT.md`'s own word. The absence is recorded here because an absence is hard to read
 * as a decision — if a later story animates a mark, this is where the preference is honoured.
 */

/*
 * Print. Decoration is not information, and a mask prints as a solid block in engines that
 * rasterise backgrounds — so it goes, by the same established convention the scallop frame and the
 * world marks already follow.
 */
@media print {
  .zoey-decoration-group,
  .woocommerce-cart .wc-block-cart__sidebar > .wp-block-woocommerce-cart-order-summary-block::before,
  .woocommerce-cart .wc-block-cart__submit::after,
  .zoey-checkout .wp-block-woocommerce-checkout-totals-block .wc-block-components-checkout-order-summary__title::before,
  .zoey-checkout .wp-block-woocommerce-checkout-totals-block .wc-block-components-checkout-order-summary__title::after {
    display: none;
  }
}


/* --- The section landings' corner layer — SL-010 -------------------------------------------- */

/*
 * One motif, or a pair of them, in the upper trailing corner of a section hero.
 *
 * **Why a layer and not a row beside the heading.** `R3` asked for flowing placement and this
 * story built it first: a flex row holding the `h1` and the group, which cannot overlap a glyph
 * because the two divide one line box. It was withdrawn on its own measurements. A flex item takes
 * width, so the heading lost the mark's 20px plus the gap, and a heading that had been using its
 * full measure then wrapped onto an extra line — Discover at 1440 went from one line to two and
 * pushed its whole collection down 45px, and Make and Play did the same at 320. The design
 * contract settles that case in one sentence: *content wins*, and nothing may be squeezed to
 * preserve a doodle. A positioned layer reserves no space at all, so every heading wraps on
 * exactly the word it wrapped on before this story and nothing below the hero moves by a pixel.
 * The implementation report's *Deviation D1* carries the full before/after table.
 *
 * **Two classes, because `inset: 0` is declared above in this same file.** A single-class modifier
 * would be decided by source order against it rather than by specificity — the trap this file
 * already documents twice.
 *
 * The marks inside are laid out rather than positioned, which is what makes a pair read as one
 * composition instead of two marks that happen to share a layer; `components/shop-archive.css`
 * makes the same adoption at its narrow width. A surface supplies `position: relative` on the hero
 * it wants this over, and nothing here positions itself against an ancestor it does not own.
 */
.zoey-decoration-group.zoey-decoration-group--hero-end {
  inset-block: var(--wp--preset--spacing--20) auto;
  inset-inline: auto var(--wp--preset--spacing--20);
  display: flex;
  align-items: center;
  gap: var(--wp--preset--spacing--10);
  overflow: visible;
}

.zoey-decoration-group--hero-end .zoey-decoration {
  position: static;
}

/*
 * The section motif is drawn **only where there is room for it**, and that takes two questions,
 * because the space it needs can run out in two unrelated ways.
 *
 * Product asked on 2026-10-16 for these to match the Shop landing's marks — `large`, 48px, beside
 * Shop's own 48px star. A mark that size wants roughly its own width plus the edge inset of clear
 * space in the hero's trailing corner. Whether that exists depends on how wide the hero is *and*
 * on how large the reader's text is, and those two can move in opposite directions. Every number
 * below is measured ink — the layer hidden, the pixels under its rectangle counted — not judgement.
 *
 * **Question one: is the layout wide enough?** Below 1024px the hero *is* the content column, and
 * the heading's first line reaches the corner. At 768 with ordinary text Learn's star sat over
 * **552 pixels** of heading ink, with 35px of trailing slack against the 56px the mark wants. Make,
 * Play and Discover had more slack there and measured clean — but a rule that holds only while
 * today's headings happen to be short breaks the first time a parent retitles a page, so the width
 * governs all four.
 *
 * **Question two: is it wide enough in the reader's own text?** This one cannot be a media query.
 * `rem` and `em` inside a media query resolve against the *initial* font size, not the current
 * one, so a media query is blind to a reader who has enlarged their text — the first version of
 * this rule used `44rem` and silently did nothing, leaving **5,095 pixels** of ink under Learn's
 * star at 1024px with doubled text. A **container** query is the tool that can see it: font-relative
 * units inside one resolve against the query container, so `34em` means thirty-four times whatever
 * the reader is actually reading at. The four heroes are named containers for exactly this, the
 * way `components/shop-archive.css` already names the Shop hero.
 *
 * Measured hero widths in the reader's own units: 77.5em at 1440 and 59em at 1024 with ordinary
 * text, 38.75em at 1440 with doubled text — all clean. 29.5em at 1024 with doubled text — the
 * collision. 34em sits between them with margin on both sides.
 *
 * Together the two admit exactly the cases that measured zero ink and drop every case that did
 * not. `DESIGN-CONTRACT.md` authorises the omission in as many words — *"Heading groups may move
 * to a safe supported position or be omitted if they cannot fit without changing accepted
 * layout"*, and *"content wins"*. There is no safe supported position in the dropped cases: the
 * hero's trailing corner is the heading and its lower corner is the supporting line. Being a
 * layer, an undrawn mark leaves no spacer behind.
 *
 * **Both rules are scoped to `--hero-end`.** The Shop hero, the purchase panel, the Cart and
 * Checkout draw their marks at every width and are required to; `SL-006`'s contract asks for a
 * *"visible modest star/heart composition"* on a phone in as many words. Nothing changes for them.
 */
@media (max-width: 1023.98px) {
  .zoey-decoration-group.zoey-decoration-group--hero-end {
    display: none;
  }
}

@container zoey-section-hero (max-width: 34em) {
  .zoey-decoration-group.zoey-decoration-group--hero-end {
    display: none;
  }
}

@media print {
  .zoey-decoration-group.zoey-decoration-group--hero-end {
    display: none;
  }
}
