/*
 * Zoey Made — world mode.
 *
 * The canonical presentation of one of the three ways to experience Zoey Made: Make,
 * Play and Discover. zoey_made_world_mode_panel() in functions.php builds the markup,
 * this file gives it its appearance, and the surface that renders panels owns only how
 * many fit across — the same division the product card and the Collection tile use.
 * There is one implementation of this component. STORE-008 §51.
 *
 * The rule the design is written against is STORE-008 §21:
 *
 *   With all three destinations still reserved, the section must read as "here are three
 *   kinds of things this world is about" — never as three disabled buttons.
 *
 * So a panel is a flat tinted surface with an emblem and a sentence, and there is nothing
 * on it that a visitor could mistake for a control they are not allowed to press: no
 * border, no button shape, no pointer cursor, no greying, no "coming soon". It is content.
 *
 * Two states, one component (§18). While a mode's route is reserved the panel is exactly
 * that content. When the route publishes, the same panel gains a link over its whole
 * surface and an arrow beside its name, and everything else about it is unchanged — the
 * homepage template does not know the difference and does not have to be redesigned for
 * it (§54).
 *
 * Against its two homepage neighbours (§25, §26): Collection tiles are bordered white
 * cards carrying a photograph and a link into the catalogue; these are flat tinted panels
 * carrying a drawn mark and, usually, no link at all. Nothing here uses the product card's
 * geometry, and there is no price, count or badge anywhere in the file.
 *
 * The panel owns no grid. Every measurement here is relative and there is not a single
 * width in the file. See docs/CSS-AND-ASSETS.md.
 */

.zoey-world-mode {
  /*
   * The two colours a mode is dressed in, as knobs rather than constants: the pale panel
   * and the saturated emblem behind its mark. STORE-008 §33 pairs them — Make pink, Play
   * aqua, Discover lavender — and the modifiers below are the whole of that mapping.
   *
   * Lavender is the default because a panel rendered alone, on some later surface with no
   * modifier on it, should still have a colour.
   *
   * Both are theme.json tokens. The pale ones are the palette STORE-007 promoted, so
   * nothing here mixes a tint of its own: docs/DESIGN-TOKENS.md, and §34.
   */
  --zoey-world-mode-tint: var(--wp--preset--color--zoey-lavender-pale);
  --zoey-world-mode-accent: var(--wp--preset--color--zoey-lavender);

  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--wp--preset--spacing--40);
  align-items: center;
  padding: var(--wp--preset--spacing--50);
  border-radius: var(--wp--custom--radius--large);
  background-color: var(--zoey-world-mode-tint);
  transition:
    transform 150ms ease,
    box-shadow 150ms ease;
}

.zoey-world-mode--make {
  --zoey-world-mode-tint: var(--wp--preset--color--zoey-pink-pale);
  --zoey-world-mode-accent: var(--wp--preset--color--zoey-pink);
}

.zoey-world-mode--play {
  /*
   * **Sky, not aqua, since SL-012** — `DESIGN-CONTRACT.md` §2's mapping is Make/blush,
   * Learn/pale yellow, Play/sky, Discover/mint, and `D6` approved the family. Both are palette
   * tokens STORE-007 promoted; nothing here mixes a tint of its own.
   */
  --zoey-world-mode-tint: var(--wp--preset--color--zoey-sky-pale);
  --zoey-world-mode-accent: var(--wp--preset--color--zoey-sky);
}

/*
 * Learn, added by `SL-012` `D6`, and **its tint is not a new token.**
 *
 * The approved direction asks for pale yellow and the pale palette has none: the family is
 * pink 18%, lavender 32%, aqua 26%, mint 45% and sky 30%, so blush, sky and mint all resolve to a
 * token and Learn does not. `D6`'s instruction was to *use the existing soft-paper yellow
 * initially and show the rendered result before proposing another token*, so this is
 * **`surface.css`'s own soft paper**: Zoey Yellow at the 8% strength that file declares, written as
 * the same mix rather than as a number repeated here.
 *
 * 8% is far paler than the other four, which is exactly the thing Product asked to see rendered
 * before deciding. If it reads too weak beside blush and mint, the answer is a `zoey-yellow-pale`
 * token in `theme.json` — a design-system decision, which is why this story does not take it.
 */
.zoey-world-mode--learn {
  --zoey-world-mode-tint: color-mix(in srgb, var(--wp--preset--color--zoey-yellow) 8%, var(--wp--preset--color--surface));
  --zoey-world-mode-accent: var(--wp--preset--color--zoey-yellow);
}

.zoey-world-mode--discover {
  --zoey-world-mode-tint: var(--wp--preset--color--zoey-mint-pale);
  --zoey-world-mode-accent: var(--wp--preset--color--zoey-mint);
}

/*
 * The emblem.
 *
 * A disc of the mode's saturated colour with the mark drawn on it in Ink, and the reason
 * it exists is contrast rather than decoration. Drawn straight onto the pale panel the
 * marks measure 2.02:1 (pink), 1.40:1 (aqua) and 1.37:1 (lavender) — an artwork nobody
 * can quite see. On the disc they measure 5.54:1, 8.20:1 and 8.25:1, so each mark is
 * unmistakable and the saturated half of §33's colour pairing has a real job.
 *
 * It is an emblem, not a button: no shadow, no ring, no press state, and the mark inside
 * it is aria-hidden, because the name beside it is what carries the meaning (§35).
 */
.zoey-world-mode__mark {
  display: grid;
  place-items: center;
  inline-size: 3.25rem;
  block-size: 3.25rem;
  border-radius: var(--wp--custom--radius--pill);
  background-color: var(--zoey-world-mode-accent);
  /* The mask paints in currentColor, so this is what colours the mark itself. */
  color: var(--wp--preset--color--ink);
}

/* Two classes deliberately: the size this overrides is the doodle component's own single
   class, and the two stylesheets can print in either order. Specificity decides it rather
   than load order. */
.zoey-world-mode__mark .zoey-doodle {
  --zoey-doodle-size: 1.75rem;
}

/*
 * The illustration — `SL-012` `D6`'s additive `art` slot.
 *
 * When a mode carries artwork the emblem stops being a disc: an illustration has its own colour,
 * its own silhouette and its own contrast, and painting it onto a saturated circle would be
 * fighting all three. So the disc's background and fixed size are **unset** here rather than
 * overridden with new numbers, and the picture takes a block cap of 10rem — the one length, matched
 * by the `sizes="10rem"` the renderer declares, so the two cannot drift.
 *
 * The emblem's contrast argument above does not apply and is not weakened: it was about a 1.75rem
 * line drawing in `currentColor` on a pale panel, and this is a full-colour illustration several
 * times that size.
 *
 * A mode with artwork becomes a **stacked card** — picture above the words — because four of these
 * sit in a grid on the homepage rather than three in a wide row, and a 10rem picture beside text in
 * a 13rem column would leave the text nowhere to go.
 */
.zoey-world-mode:has(.zoey-world-mode__art) {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--wp--preset--spacing--30);
  justify-items: center;
  text-align: center;
}

.zoey-world-mode__mark:has(.zoey-world-mode__art) {
  inline-size: auto;
  block-size: auto;
  border-radius: 0;
  background-color: transparent;
}

.zoey-world-mode__art {
  display: block;
  inline-size: auto;
  max-inline-size: 100%;
  /* A cap on the block axis, so the picture scales with the reader's text size rather than being
     pinned to a pixel height the rest of the card does not share. */
  max-block-size: 10rem;
  block-size: auto;
}

/*
 * The name, and the arrow that only a linked panel has.
 *
 * The size is stated rather than inherited from the heading level, so an h3 on the
 * homepage and an h2 on some later surface look identical — the point of having one
 * component. Section Small is a step above the Collection tile's name: this section is
 * meant to be more expressive than the catalogue, and less than the hero (§24).
 */
.zoey-world-mode__name {
  display: flex;
  gap: var(--wp--preset--spacing--30);
  align-items: center;
  margin: 0;
  font-size: var(--wp--preset--font-size--section-small);
  line-height: 1.25;
  overflow-wrap: break-word;
}

.zoey-world-mode__text {
  margin-block-start: var(--wp--preset--spacing--20);
  color: var(--wp--preset--color--ink);
}

/*
 * The emblem steps aside when the words have nowhere to go.
 *
 * At 320px with the reader's text at 200% the panel's padding takes 96px of 280, the emblem
 * 104 and the gap 32, leaving the sentence a 48px column against a 152px longest word — and
 * the panel overflowed the page by 89px. Same defect class as the hero's, found while
 * acceptance-testing the fix for it, resolved on the same principle: at extreme scaling
 * decoration yields space to the content somebody is trying to read. The emblem is
 * aria-hidden and the name beside it carries the meaning.
 *
 * Stacked rather than hidden or shrunk — hiding it takes the section's character away from
 * the reader who needs most help, shrinking it makes the artwork unreadable — and the
 * sentence gets 184px instead of 48.
 *
 * 14rem is measured, not chosen: the container is 17.5rem at 320px and 21.9rem at 390px with
 * normal text, and the same 17.5rem at 400% zoom, against 8.75rem and 10.9rem at 200% text.
 * Naming the container means a panel rendered without one keeps the accepted two columns.
 */
@container zoey-world-panel (max-width: 14rem) {
  .zoey-world-mode {
    grid-template-columns: minmax(0, 1fr);
    justify-items: start;
  }
}

/*
 * The one link, on the panels that have one.
 *
 * The anchor wraps the name and its ::after stretches over the panel, so the whole panel
 * is the target for a finger while the accessible name stays exactly the mode's name —
 * the single-link pattern STORE-004 established and §23 and §63 ask this component to
 * follow. One anchor per panel: the mark is not a second link, and neither is the arrow.
 *
 * No underline at rest: the panel is the affordance. Hover and focus put it back.
 */
.zoey-world-mode__link {
  color: var(--wp--preset--color--ink);
  text-decoration: none;
}

.zoey-world-mode__link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.zoey-world-mode__link:hover,
.zoey-world-mode__link:focus-visible {
  text-decoration: underline;
}

/*
 * The arrow.
 *
 * Two borders rotated 45 degrees: a chevron with no file, no request and no icon system,
 * the same one the Collection tile uses. It is decoration marked aria-hidden in the
 * markup — the link already says where the panel goes — and it is not the clickable area;
 * the stretched link is (§63).
 *
 * Ink rather than the Collection tile's Zoey Purple, because that purple clears 3:1
 * against Surface and not against a pale tint (2.90–3.03). docs/DESIGN-TOKENS.md.
 */
.zoey-world-mode__go {
  flex: none;
  inline-size: 0.45rem;
  block-size: 0.45rem;
  border-block-start: 2px solid var(--wp--preset--color--ink);
  border-inline-end: 2px solid var(--wp--preset--color--ink);
  rotate: 45deg;
  transition: translate 150ms ease;
}

/*
 * The desktop trio (§41).
 *
 * Below this the panel is the compact composition §39 draws — mark beside the name, one
 * panel per row — which is what keeps three of them from adding a screen and a half to a
 * phone. At the width the section goes three across it stacks and centres instead, so the
 * three read as one unified trio rather than as three wide bars cut into thirds.
 *
 * The breakpoint is the world grid's own, in homepage.css, and the limit is written into
 * both files. A container query would let the panel decide this for itself and is wrong
 * here for the reason collection-card.css records: at these sizes one panel on a tablet
 * and one third of a desktop row are nearly the same width and want opposite layouts.
 */
@media (min-width: 1000px) {
  .zoey-world-mode {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    /* Centred in the panel rather than sitting at the top of it. Three panels in a row are
       the same height whatever their copy, and the mode with the shortest sentence would
       otherwise carry all of the leftover space under it — the artificial blank region §42
       rules out. Centred, the difference is a little air above and below instead. */
    align-content: center;
    padding: var(--wp--preset--spacing--60) var(--wp--preset--spacing--50);
    text-align: center;
  }

  .zoey-world-mode__mark {
    inline-size: 3.75rem;
    block-size: 3.75rem;
  }

  .zoey-world-mode__mark .zoey-doodle {
    --zoey-doodle-size: 2rem;
  }

  .zoey-world-mode__name {
    justify-content: center;
  }
}

/*
 * Hover, and only for a panel that goes somewhere (§57).
 *
 * A reserved panel gets no hover treatment at all, deliberately: a surface that responds
 * to the pointer is a promise that clicking it will do something, and this one has
 * nothing to click. That is the distinction §57 says matters, and it is why every rule
 * below is behind the linked modifier.
 *
 * Behind a hover query as well, so a touch device does not hold the lifted state after a
 * tap. The reduced-motion preference is honoured site-wide in base.css, which collapses
 * the transition rather than the state (§65).
 */
@media (hover: hover) {
  .zoey-world-mode--linked:hover {
    transform: translateY(-2px);
    box-shadow: var(--wp--preset--shadow--lifted);
  }

  .zoey-world-mode--linked:hover .zoey-world-mode__go {
    translate: 3px 0;
  }
}

/*
 * Focus.
 *
 * The site's one ring, moved from the anchor to the panel, because the panel is what the
 * anchor covers (§59). This is base.css's 3px Ink outline, not a component inventing its
 * own. A reserved panel has no anchor, so it has nothing to focus and takes no Tab stop.
 *
 * The @supports guard is why the outline: none is safe — without :has() neither rule
 * applies and the anchor keeps the site ring, so no engine can end up with no ring at all.
 * The second selector is long for the reason product-card.css records: base.css writes the
 * ring through an :is() list carrying more specificity than a class, and a rule that won
 * by source order would behave differently depending on which surface loaded this file.
 */
@supports selector(:has(*)) {
  .zoey-world-mode:has(.zoey-world-mode__link:focus-visible) {
    outline: 3px solid var(--wp--preset--color--ink);
    outline-offset: 2px;
  }

  .zoey-world-mode:has(.zoey-world-mode__link:focus-visible) .zoey-world-mode__link:focus-visible {
    outline: none;
  }
}
