/* Media: the AI-content badge and the image plate (1664x928 source; the srcset
   request lives in .agent-state/hierarchy/N3_APPJS_REQUESTS.md), plus its clean
   degradation when a story has no image. Owned by the media lane.
   Class names are contractual: frontend/app.js emits them, so every selector
   stays defined here even when the element must not be seen. */

/* ============================================================ badge =====
   The compliance mark is production vocabulary, not reader copy. app.js only
   appends it (nothing reads it back), so it stays in the DOM for the client
   and is never drawn. Every selector remains defined, colour token included,
   so a stale build cannot render a half-styled tick pill. */

.badge { display: none; }
.badge--clean { display: none; }
.badge--on-dark { display: none; color: var(--on-dark-muted); }
.badge__glyph { display: none; color: var(--accent); }
.badge__glyph svg { width: 9px; height: 9px; }

/* app.js emits `dot + badge` as the last two children of .article__meta when a
   record carries a compliance status (metaLine). With the badge gone the dot
   would dangle after the time, so it goes too. */
.article__meta > .article__dot:has(+ .badge) { display: none; }

/* =========================================================== media ======
   One plate per item, cut from a 1664x928 (ratio 1.793) source. A photograph
   is the only frame on a card: no border, no plate chrome. The radius is the
   small end of the Ember ramp, the same as every other control. */

.thumb { margin: 0 0 var(--sp-2); min-width: 0; position: relative; }

.thumb__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 0;
  border-radius: var(--r-md);
  background: var(--paper-2) center / cover no-repeat;
}

/* A picture the publisher offers without a reuse licence (pipeline/source_photo.py):
   stored only as a small crop, so the card is deliberately NARROWER than a full-width
   photograph and sits left in the column — the size itself is the honest signal that this
   is a preview, not our lead frame. The "Source: <publisher>" line below it is real text
   (app.js sourceCreditNode), never a background image. */
.thumb--source {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.thumb--source .thumb__img {
  width: min(100%, 22rem);
  border-radius: var(--r-md);
}
.thumb__source {
  display: inline-flex;
  gap: 0.3rem;
  margin-top: 0.35rem;
  font-size: var(--fs-micro);
  line-height: 1.5;
  color: var(--ink-faint);
}
.thumb__source-label { font-weight: 600; letter-spacing: 0.01em; }
.thumb__source-name { overflow-wrap: anywhere; }
/* The hero slot keeps its full width — it is the story's own lead picture and the reader
   opened the page for it — but never grows past the column and always carries the line. */
.thumb--hero.thumb--source .thumb__img { width: 100%; }
.story-figure.thumb--source .thumb__source,
.thumb--hero .thumb__source { display: flex; }

/* No image is a normal state: app/api/images.py `_served` publishes
   assets.title_image_url only when the bytes exist. With no image the frame
   collapses to nothing, so the story starts at its headline instead of losing
   half the first screen to an empty plate.

   The box itself is hidden, and it carries NO TEXT: `mediaPlaceholder` in
   app.js emits the empty element only. The words "Image coming soon" /
   "配图待生成" used to live here, one rule away from a reader: any stale or
   missing stylesheet (an offline shell mid-upgrade, a cached document, a 404)
   painted a grey plate with that sentence over a story whose photograph was
   still arriving. A reserved slot must never make a claim about a picture we
   may not have, so the claim is gone from the markup as well as from the
   pixels — `frontend/tests/image_first_paint.test.mjs` pins that. */
.thumb__empty {
  display: none;
  aspect-ratio: 16 / 9;
  background: var(--paper-2);
}
.thumb:has(> .thumb__empty) { display: none; }

/* The lead plate is 16:9, like the source. Cropping a news photograph to 16:7
   to save height is a worse trade than the height itself; the cap only bites
   on very wide screens, where object-fit keeps the subject centred. */
figure.thumb--lead { margin-bottom: var(--sp-4); }
/* A house graphic is drawn at 1664x928 (1.7931, owned_graphics.py LEAD_SIZE),
   and the 16:9 plate (1.7778) crops about 3px a side under object-fit: cover —
   enough to cut the date and source stamp in the graphic's own footer. Nothing
   here scales or letterboxes: the plate simply takes the graphic's ratio, so
   the full card is shown and no reader loses the credit line (measured
   2026-11-10 on the 1440 feed shot). Photographs keep 16:9. */
.thumb--lead.thumb--house .thumb__img { aspect-ratio: 1664 / 928; }
.thumb--hero.thumb--house .thumb__img { aspect-ratio: 1664 / 928; }
.thumb--lead .thumb__img {
  aspect-ratio: 16 / 9;
  max-height: 26rem;
  object-fit: cover;
}
.thumb--lead .thumb__empty { display: none; }

/* The article's own image panel carries the same empty plate when no image
   exists (detail.css draws it as a ruled band). With the plate gone the panel
   would be a label over nothing, which is the same defect at a smaller size,
   so the panel goes with the plate. An image that fails to load is a different
   state: app.js replaces the plate with .plate__note and this rule stops
   matching. */
.panel:has(> .plate > .thumb__empty) { display: none; }

/* ================================================== in-story images ======
   N2 emits these inside the article body (contract: assets.body_images,
   docs/API.md). The lead plate sits full width above the headline block; the
   in-body figure sits at the reading measure, with the caption as the only
   chrome. No frame, no shadow: a photograph on a page, not a card. */

.thumb--hero {
  margin: 0 0 clamp(1rem, 2vw, 1.5rem);
}
.thumb--hero .thumb__img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--paper-2);
}

.story-figure {
  margin: clamp(1.4rem, 3vw, 2rem) 0;
  max-width: var(--measure);
}
.story-figure .thumb__img,
.story-figure img {
  width: 100%;
  height: auto;
  /* The API sends each picture's OWN `aspect`, and app.js writes it onto the element as
     an inline `aspect-ratio`. A hard 16:9 here fought that: an in-story picture is a 3:2
     card, so it was cropped to 16:9 and lost its bottom fifth. The default below only
     applies to a payload that carried no aspect at all (an older row), which is the one
     case where a guess is better than a zero-height box. */
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--paper-2);
}
.story-figure figcaption {
  margin-top: 0.6rem;
  font-size: var(--fs-label);
  line-height: 1.55;
  color: var(--ink-faint);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
}
/* The AI label is a quiet pill in the caption: metadata, not a warning. */
.story-figure .badge,
.story-figure .ai-label {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink-faint);
  font-size: var(--fs-micro);
  line-height: 1.5;
  white-space: nowrap;
}
