/*
 * Zoey Made — the shared page introduction (VS-005).
 *
 * `inc/content/page-intro.php` is the renderer, the variants and the long form of what was
 * consolidated here and what deliberately was not. This file is the appearance, and it is the
 * appearance of **three markups**, because only one of the three surfaces is rendered by this
 * theme's own PHP:
 *
 *   .zoey-page-intro__*        zoey_made_page_intro() — the shop archive calls it
 *   .zoey-home-hero__*         core blocks in templates/front-page.html
 *   .zoey-make-welcome__line   core blocks saved into the Make page from patterns/make-landing.php
 *
 * Each shared role below is **one rule with every name that wears it**. That is what makes this
 * one implementation rather than three that agree today: changing the supporting line's size
 * changes it on the shop, the homepage and Make in one edit, and there is no second place where
 * a different answer could be written.
 *
 * It is not a rename. The homepage's markup and Make's *saved content* keep the class names they
 * were accepted with — editing a pattern does not update a page already saved from it, and
 * rewriting published content to tidy a selector is not a trade this project makes. What moved
 * is where the declaration lives.
 *
 * Each surface's own band, breakpoints and artwork sizes stay with that surface: `homepage.css`,
 * `make-landing.css`, `shop-archive.css`. §5 — layouts own grids.
 */

/* --- The shared roles -------------------------------------------------------------------- */

/*
 * The eyebrow: a short label above the heading.
 *
 * The uppercase letterspaced small label both approved references put above a page title. The
 * homepage's `zoey-home-hero__station` pair is **not** this role and is not in this list — see
 * the renderer's header for why.
 */
.zoey-page-intro__eyebrow {
  margin: 0;
  color: var(--wp--preset--color--ink-soft);
  font-size: var(--wp--preset--font-size--body-small);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/*
 * The heading.
 *
 * No font size: the size is the heading element's own, from `theme.json`, so §4's rule holds —
 * *"heading semantics follow page hierarchy, independently of visual role"*. A surface that
 * wants a different size is asking for a different heading level or a different design, not for
 * a class here.
 *
 * `text-wrap: balance` keeps a two-line heading from leaving one word on the second line, and is
 * progressive: an engine without it wraps as it always did.
 *
 * `overflow-wrap: anywhere` is the measured one, and it is `anywhere` rather than `break-word`
 * for a reason that took two stories to find. Both break a word that cannot fit on a line; only
 * `anywhere` also tells the layout that the heading's *minimum* width is a character rather than
 * its longest word, which is what a shrink-to-fit column actually asks for. STORE-013 found it on
 * the homepage at 200% text on a 320px screen — 325px of word in a 280px box, 69px of sideways
 * scroll — and PRODUCT-009 found the same thing on a product-category archive, where an ordinary
 * eleven-letter category name overflowed by 106px. A heading whose words already fit is
 * unaffected, so only a reader at very large text ever sees a word split. `hyphens` was ruled out
 * for the opposite reason: it would hyphenate at normal sizes too.
 */
.zoey-page-intro__title,
.zoey-home-hero__title {
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.zoey-page-intro__title {
  margin: 0;
  line-height: 1.2;
}

/*
 * The supporting line.
 *
 * Section Small, so an introduction's one sentence sounds like the rest of the page rather than
 * like a pull quote, and capped at the reading measure so it stays one readable line rather than
 * a band-wide strip of text on a 1440px screen.
 *
 * The same `overflow-wrap` as the heading, and for the same reason on a different kind of text: a
 * product-category description is a merchant's prose and may contain a URL or a long compound,
 * and it must not be able to widen the band it sits in.
 */
.zoey-page-intro__lede,
.zoey-home-hero__lede,
.zoey-make-welcome__line {
  max-inline-size: var(--wp--custom--measure);
  font-size: var(--wp--preset--font-size--section-small);
  overflow-wrap: anywhere;
}

.zoey-page-intro__lede,
.zoey-make-welcome__line {
  margin: 0;
}

/*
 * A `lede_html` lede is a container rather than a paragraph — a filtered term description is
 * whatever the merchant wrote, which may be several paragraphs. Its first and last margins
 * collapse to the introduction's own spacing so the band's padding stays what it asked for.
 */
.zoey-page-intro__lede > :first-child {
  margin-block-start: 0;
}

.zoey-page-intro__lede > :last-child {
  margin-block-end: 0;
}

/* The action region. Spacing only: the controls are components/action.css's, or core's. */
.zoey-page-intro__actions,
.zoey-home-hero__actions {
  margin-block-start: var(--wp--preset--spacing--60);
}

/*
 * The character region.
 *
 * One declaration, and it is the one that is easy to leave out and expensive to leave out: a grid
 * item's automatic minimum is its *min-content* width, so without this the artwork's own width is
 * a floor and the character pushes the readable column sideways at large text sizes. It is inert
 * wherever the artwork already fits, which is every ordinary viewport. The caps on how large each
 * drawing may be are decisions about that drawing and stay with its page.
 */
.zoey-page-intro__media,
.zoey-home-hero__visual {
  min-inline-size: 0;
}

/* --- The three variants -------------------------------------------------------------------- */

/*
 * Compact: one column. The default, and the whole of it — a heading and a line need no layout.
 *
 * The content column is capped at the measure so the words do not run the full width of a wide
 * screen, and the cap is on the *content* rather than on the band, because the band is the
 * surface's own and may want to be full-bleed.
 */
.zoey-page-intro__content,
.zoey-home-hero__content {
  max-inline-size: var(--wp--custom--measure);
  /*
   * A grid item's automatic minimum is its min-content width, which is the other half of the
   * long-word fix on the heading above: without this the column keeps *asking* for 325px in a
   * 280px space, because `margin-inline: auto` makes it shrink-to-fit and shrink-to-fit cannot
   * go below min-content. Measured both ways by STORE-013. No effect wherever the content
   * already fits, which is every ordinary viewport.
   */
  min-inline-size: 0;
}

/*
 * Illustrated: room for a character beside the words, once there is room for two readable
 * columns and not before.
 *
 * 900px, which is where the homepage's arrival stopped fitting comfortably in one row and is also
 * where the site header switches to its desktop layout — so the page changes shape once rather
 * than twice. Below it, and at every width when there is no character, the introduction is one
 * centred column: §86's requirement that a missing character leave a *composition* rather than an
 * empty half.
 *
 * `--has-media` is a class because the renderer knows. The homepage asks the same question with
 * `:has()` in `homepage.css`, because its character comes from a different block and its template
 * cannot know — two mechanisms for one decision, and each is the only one available where it is.
 */
.zoey-page-intro--illustrated {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--wp--preset--spacing--70);
}

@media (min-width: 900px) {
  .zoey-page-intro--illustrated.zoey-page-intro--has-media {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: var(--wp--preset--spacing--80);
  }

  .zoey-page-intro--illustrated.zoey-page-intro--has-media .zoey-page-intro__content {
    margin-inline: 0;
  }
}

/*
 * Section: a small character to the left of the words, at every width she fits.
 *
 * SL-001. A **wrapping flex row rather than a grid with a breakpoint**, and that choice is the
 * whole of this variant. The approved mobile concept board puts Bubble beside the heading and the
 * supporting line on a phone, not above them, and WB-002's accepted Make amendment asks for the
 * same thing in the same words — *Bubble to the left of the line*. What actually runs out on a
 * narrow screen is not the viewport, it is the space left after a rem-sized character; so the
 * arrangement asks that question directly, which is the basis-not-breakpoint mechanism
 * `character.css` and `make-landing.css` both already use and both record as the better one.
 *
 * `flex: 1 1 10rem` on the words is the measurement. At 320px the content column is 280px, the
 * character takes 6rem and the gap 1rem, leaving 168px — above the 160px basis, so the row holds
 * and Bubble stays beside the words on the narrowest phone this site supports. At 200% text the
 * same sum is 320px of column against a 192px character and a 320px basis, so the row **wraps**,
 * which is the design contract's *"stack artwork and text when available space or enlarged text
 * requires it"* happening because it is needed rather than because a breakpoint was crossed.
 *
 * When it wraps, Bubble is still **first and left-aligned** — first because she is first in the
 * document, and left-aligned because of the `margin-inline` below. The character's own two caps
 * are `character.css`'s `section` step; this file never sizes a drawing.
 *
 * `align-items: center` rather than `end`: the board centres her against the words, and a 9rem
 * drawing baselined against two short lines of copy reads as standing on them.
 *
 * No fixed height, no clip, no `overflow`. A long heading wraps — the title's `overflow-wrap:
 * anywhere` above is shared by every variant — and at enlarged text the rem caps grow the drawing
 * with the words rather than against them.
 */
.zoey-page-intro--section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wp--preset--spacing--40);
}

.zoey-page-intro--section .zoey-page-intro__media {
  /*
   * The artwork keeps its intrinsic size and is never the thing squeezed: the words are what
   * wrap. `flex: 0 0 auto` is that, and it is also what makes the wrapped case land Bubble on her
   * own line at her own size rather than shrinking her to fit.
   */
  flex: 0 0 auto;
}

.zoey-page-intro--section .zoey-page-intro__content {
  flex: 1 1 10rem;
  min-inline-size: 0;

  /*
   * A wider readable maximum than the shared one, and the reason is the heading — D7 put it in
   * here. `--wp--custom--measure` is 56 characters *of whatever type it reaches*, which on body
   * text is about 538px; the landing's title at its 44px step wants about 560px, so the shared
   * cap wrapped a two-word-short heading onto a second line while half the band sat empty beside
   * it. 40rem is the smallest round number that holds it on one line at 1440 and is still a
   * maximum rather than a width.
   *
   * It does **not** widen the prose: the supporting line carries its own `--wp--custom--measure`
   * cap from the shared rule above, so the sentence stays at its reading measure inside a column
   * that is allowed to be wider than it.
   */
  max-inline-size: min( 100%, 40rem );

  /*
   * The left edge the design contract asks hero, heading and collection to share — and the guard
   * against core's constrained-layout `margin-inline: auto !important`, which `make-landing.css`
   * measured centring a wrapped character at 200% text on a 390px screen. Stated rather than
   * inherited, because the content column caps at the reading measure and a shrink-to-fit box
   * with auto margins centres itself inside its flex line at wide widths.
   */
  margin-inline: 0;
}

/* Roomier once the character is at its larger cap. 720px is the collection grid's first cutover,
 * so the page changes shape once. */
@media (min-width: 720px) {
  .zoey-page-intro--section {
    gap: var(--wp--preset--spacing--50);
  }
}

/* --- The accent -------------------------------------------------------------------------- */

/*
 * §9's one controlled pastel detail: a short bar under the heading.
 *
 * A pseudo-element rather than markup, because it says nothing — there is no element in a
 * document that exists only to be lavender, and a screen reader should not meet one. It is drawn
 * on the heading's own box, so an introduction with no heading has no accent and needs no rule
 * saying so.
 */
.zoey-page-intro--accent-lavender .zoey-page-intro__title::after,
.zoey-page-intro--accent-pink .zoey-page-intro__title::after {
  content: "";
  display: block;
  inline-size: 3.5rem;
  block-size: 4px;
  margin-block-start: var(--wp--preset--spacing--30);
  border-radius: var(--wp--custom--radius--pill);
}

.zoey-page-intro--accent-lavender .zoey-page-intro__title::after {
  background-color: var(--wp--preset--color--zoey-lavender);
}

.zoey-page-intro--accent-pink .zoey-page-intro__title::after {
  background-color: var(--wp--preset--color--zoey-pink);
}

/*
 * An accent is decoration, and decoration disappears in forced-colors mode — a pastel bar is
 * replaced by nothing at all there. It is not restored: it carried no information, so a reader in
 * high contrast loses a flourish and not a fact. Stated rather than left as an absence, so a later
 * story does not mistake it for an oversight.
 */
@media (forced-colors: active) {
  .zoey-page-intro--accent-lavender .zoey-page-intro__title::after,
  .zoey-page-intro--accent-pink .zoey-page-intro__title::after {
    display: none;
  }
}

/*
 * Print: the accent and the character go, the words stay. §11's economical ink — a pastel bar and
 * a drawing of a character are the two most expensive things in an introduction to print and the
 * two that carry least on paper.
 */
@media print {
  .zoey-page-intro--accent-lavender .zoey-page-intro__title::after,
  .zoey-page-intro--accent-pink .zoey-page-intro__title::after,
  .zoey-page-intro__media {
    display: none;
  }
}
