/*
 * Zoey Made — the study-set card (VS-005).
 *
 * `inc/content/study-card.php` is the renderer, the two kinds, and the long form of the four
 * things this component is not. This file is the appearance, from the approved Learn prototype's
 * `.studycard`.
 *
 * ## It draws no paper of its own
 *
 * The reference's card is `panel paper cream tape` — a tinted sheet with a strip of tape across
 * it — and that is `zoey_made_surface()`'s `soft-paper`, which VS-004 built and Product approved.
 * So this component draws the card's **contents** and the caller wraps it in a surface. Two
 * consequences worth stating:
 *
 *   - There is no background, no border, no radius and no padding in this file. A study card is a
 *     composition of a chip, a heading, two lines and an action, and it looks the way it does
 *     because of what it is placed on.
 *   - The tape in the reference is **optional here**, and the story is explicit that tape and
 *     torn edges must not be added to every card. A caller asks for it or does not; the showcase
 *     shows one of each, so the decision stays visible.
 *
 * ## The action is pinned to the bottom
 *
 * The reference does this with `margin-top: auto` in a flex column, and it is the one piece of
 * layout here that earns its complexity: two cards side by side with different amounts of summary
 * text should still have their buttons on the same line. A grid row would do it too and would
 * require the surface to be a grid, which is not this component's to decide.
 */

.zoey-study-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--wp--preset--spacing--30);

  /*
   * No fixed height — §5, *"avoid fixed content heights"* — but a minimum, so a set with no
   * summary is still a card rather than a strip. It is in `rem` so it grows with a reader's text
   * rather than clipping it, which is the opposite trade from an artwork cap.
   */
  min-block-size: 11rem;
  block-size: 100%;
}

/*
 * The optional illustration — SL-002.
 *
 * A bounded 3:2 region at the top of the card, and *bounded* is the word that matters: the
 * picture is decoration about the kind of set, and the card must still be a card when it is
 * missing, when it is enormous, and when a reader has doubled their text size.
 *
 * `aspect-ratio` rather than a height, so the box scales with the column and there is no fixed
 * dimension on this card — the component's own header is explicit that it has none. The ratio is
 * the one the activity card and the shop's Collection tile already use, so three surfaces agree
 * about what a card's picture is shaped like without sharing an implementation.
 *
 * **No background, no border, no radius, no tint.** The card already sits on the caller's
 * soft-paper surface, and a second ground inside it would be a second sheet — which is the thing
 * `COMPONENT-MAP.md` warns about by name. A missing picture therefore leaves nothing behind
 * rather than a coloured panel, which is the opposite of the activity card's fallback and is
 * correct for the opposite reason: there, a short card in a row of peers reads as broken; here, a
 * card without an illustration is the accepted design and has been since VS-005.
 *
 * **The ratio is the bound, and it is the only one.** A `max-block-size` was tried first and is
 * wrong: with `inline-size: 100%` the height is *derived* from the width, so capping the height
 * does not shrink the box — it stops honouring the ratio and leaves the picture wider than 3:2.
 * The ratio alone already bounds the region to two thirds of the column it is in, at every width
 * and at every text size, which is what §6's *bounded* asks for. The approved desktop board shows
 * the illustration spanning the card's full width, so a narrower cap would also be the wrong
 * design.
 */
.zoey-study-card__media {
  align-self: stretch;
  inline-size: 100%;
  aspect-ratio: 3 / 2;
}

/*
 * The picture fills the region, and the region is what bounds it. This is a **descendant**
 * selector on purpose: the caller hands in a `<figure>` wrapping an `<img>`, and SL-001 learned
 * the expensive way that a child selector sizes the wrapper and leaves the picture at its
 * intrinsic ratio, where `object-fit` has nothing to do.
 */
.zoey-study-card__media :is(figure, img) {
  display: block;
  margin: 0;
  inline-size: 100%;
  block-size: 100%;
}

.zoey-study-card__media img {
  max-inline-size: 100%;
  max-block-size: 100%;
  object-fit: contain;
}

/*
 * `cover` is supported and is not what this card expects. A study illustration is a group of
 * props — blocks, a pencil, a stack of cards — and cropping one cuts a prop in half.
 */
.zoey-study-card__media--cover img {
  object-fit: cover;
}

/*
 * Print: the words and the dates are the point, and a decorative illustration is the single most
 * expensive thing on this card to put on paper. The same call `activity-card.css` makes, for the
 * same reason, in §11's economical ink.
 */
@media print {
  .zoey-study-card__media {
    display: none;
  }
}

/*
 * The chip: which window this set is.
 *
 * Yellow at 40% with Ink on it, which is the same chip the Make feature card's eyebrow already
 * draws, at the same strength, from the same mix — so a label that says *what this card is* looks
 * the same whether the card is an activity or a study set. Measured there at 13.4:1, which makes
 * it the most readable thing on the card rather than the faintest.
 *
 * A chip is as wide as its label, which in a flex column is `align-self`.
 */
.zoey-study-card__chip {
  --zoey-study-card-chip: color-mix(in srgb, var(--wp--preset--color--zoey-yellow) 40%, var(--wp--preset--color--surface));

  align-self: start;
  /*
   * `align-self: start` sizes the chip to its own content, and without a cap that is its
   * *max-content* width — so a three-word window label did not wrap at all. Measured at 320px with
   * a reader's text at 200%: a 235px chip inside a 148px card. The cap is what makes it wrap, and
   * `anywhere` is for the single long word a cap cannot help with.
   */
  max-inline-size: 100%;
  overflow-wrap: anywhere;
  margin: 0;
  padding: var(--wp--preset--spacing--10) var(--wp--preset--spacing--30);
  border-radius: var(--wp--custom--radius--pill);
  background-color: var(--zoey-study-card-chip);
  color: var(--wp--preset--color--ink);
  font-size: var(--wp--preset--font-size--body-small);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/*
 * The heading, with its glyph beside it.
 *
 * The size is stated rather than inherited from the heading level, which is the same call
 * `world-mode.css` makes and for the same reason: an `h2` in the showcase and an `h3` on a later
 * Learn page should be the same card, because that is the point of having one component. §4 — the
 * level follows the document, the size follows the design.
 *
 * `align-items: baseline` rather than `center`, so the glyph sits on the text's baseline the way a
 * letter does. At `center` it floated above the descenders of a two-line heading.
 */
.zoey-study-card__title {
  display: flex;
  align-items: baseline;
  gap: var(--wp--preset--spacing--30);
  margin: 0;
  font-size: var(--wp--preset--font-size--section-title);
}

.zoey-study-card__glyph {
  flex: none;
  /* Baseline alignment on an inline SVG lands it a little low; this lifts it onto the line. */
  translate: 0 0.15em;
}

.zoey-study-card__label {
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

/* --- The two lines ----------------------------------------------------------------------- */

.zoey-study-card__meta {
  display: flex;
  flex-direction: column;
  gap: var(--wp--preset--spacing--10);
  max-inline-size: var(--wp--custom--measure);
}

.zoey-study-card__dates,
.zoey-study-card__summary {
  margin: 0;
  overflow-wrap: anywhere;
}

/*
 * The date range is the stronger of the two lines, because *when* is what a parent is looking for
 * when they open this page, and the summary is context. Ink rather than Ink Soft: a date a reader
 * has to squint at is the one piece of information on this card that has a deadline attached.
 */
.zoey-study-card__dates {
  font-weight: 700;
}

.zoey-study-card__summary {
  color: var(--wp--preset--color--ink-soft);
}

/* --- The action -------------------------------------------------------------------------- */

/*
 * Pinned to the bottom of the card, so a row of cards has its controls on one line whatever their
 * summaries say. `margin-block-start: auto` in a flex column is what does it; the `inline-size` is
 * what lets a full-width control inside it actually be full width.
 */
.zoey-study-card__action {
  margin-block-start: auto;
  inline-size: 100%;
}

/* --- Narrow ------------------------------------------------------------------------------ */

/*
 * A container query, not a media query, and for the reason `surface.css` sets out: a study card
 * lives inside a surface that declares itself a container, so the card reacts to **its own**
 * width. Two cards in a desktop two-column grid are each about 480px and get the roomy
 * treatment; the same card in a narrow column gets the tight one, whatever the window is doing.
 * It also means a reader at 200% text is seen, which a media query never does.
 *
 * The heading steps down to Section Small, because Section Title at 320px is a two-word heading
 * on three lines. Nothing else changes: §5's *"mobile stacks study cards"* is the grid's job, not
 * the card's.
 */
@container zoey-surface (max-width: 26rem) {
  .zoey-study-card {
    min-block-size: 0;
  }

  .zoey-study-card__title {
    font-size: var(--wp--preset--font-size--section-small);
  }

}

/* --- Forced colors ---------------------------------------------------------------------- */

/*
 * The chip is a tint, and a tint is replaced by the system's canvas in forced-colors mode — so
 * without this the chip's label is Ink on Canvas with no chip around it, which reads as a stray
 * line of shouting above the heading. A border puts the chip back as a shape.
 *
 * The glyph needs nothing: it is stroked in `currentColor`, so it is recoloured with the heading
 * it belongs to. That is the whole reason `docs/CSS-AND-ASSETS.md` requires an interface icon to
 * be inline SVG rather than a CSS mask.
 */
@media (forced-colors: active) {
  .zoey-study-card__chip {
    border: 1px solid CanvasText;
  }
}

/* --- Print ------------------------------------------------------------------------------ */

/*
 * §11: readable text, white background, economical ink. The chip loses its fill and keeps its
 * outline, and the card does not break across a page — a study set split over two sheets is a
 * study set somebody has to reassemble.
 *
 * The action is not hidden; `action.css` prints it as its label in a thin outline, because a
 * reader holding the paper should still be able to see what the page offered.
 */
@media print {
  .zoey-study-card {
    min-block-size: 0;
    break-inside: avoid;
  }

  .zoey-study-card__chip {
    border: 1px solid #000;
    background-color: transparent;
  }
}
