/* Media card: a picture and its text on ONE surface (owner 2026-11-29, ui.media_cards, docs/media-card.md).
   The picture is the top of the card (same width, no gap, the card's rounded top corners), the text sits inside the same
   card on its opaque fill. Also: one content width for media, text cards and dividers on a page (.mpage), the article
   type scale, the spacing scale and a balanced ambient background. Built here first; a site sets --mc-* tokens only.

   Markup (app/templates/_media_card.html):  .mcard > .mcard__media + .mcard__body (.mcard__title .mcard__text ...)
   Page:  .mpage > .mcard--hero + .prose   (the prose, its dividers and its pictures all take --mc-w)

   Colours are the site's own tokens (--surface-raised --surface --border --text-1/--ink --text-2/--ink-soft --accent),
   the amarbaro dark values last. No url(), no filter, no blur; transform-only motion inside the opt-in query. */

:root {
  --mc-w: 43rem;                       /* the one content width: media, cards, prose, dividers (about 70 characters at 18 px) */
  --mc-radius: 16px;                   /* card corner; in-article pictures use the same */
  --mc-pad: clamp(20px, 2.4vw, 28px);  /* text padding inside a card */
  --mc-accent: var(--accent, #9DAE51);
  --mc-ink: var(--text-1, var(--ink, #F3F6FA));
  --mc-dim: color-mix(in srgb, var(--text-2, var(--ink-soft, #94A3B8)) 70%, var(--mc-ink)); /* secondary text, nudged up: 4.5:1 and more on the fill */
  --mc-line: var(--border, #1E2736);
  --mc-fill-top: var(--surface-raised, var(--surface, #141A25));
  --mc-fill-bottom: var(--surface, #0F141D);
  --mc-fill: linear-gradient(180deg, var(--mc-fill-top), var(--mc-fill-bottom));
  --mc-glow: color-mix(in srgb, var(--mc-accent) 12%, transparent);
  /* spacing scale: every gap on an article or showcase page is one of these five */
  --mc-s1: 8px;
  --mc-s2: 16px;
  --mc-s3: 24px;
  --mc-s4: 40px;
  --mc-s5: 64px;
  --mc-ratio: 1200 / 630;              /* the plates' own ratio: a squarer crop cuts the wordmark */
}

/* ── the card ─────────────────────────────────────────────────────────── */
.mcard {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;                /* a site's grid or centring rule on the card must not shrink the body */
  min-width: 0;
  padding: 0;
  gap: 0;
  overflow: hidden;                    /* the picture takes the card's rounded top corners */
  color: var(--mc-ink);
  text-decoration: none;
  background: var(--mc-fill);
  border: 1px solid var(--mc-line);
  border-radius: var(--mc-radius);
}
.mcard::before {                       /* the 1 px top glow line of the house card family */
  content: "";
  position: absolute;
  z-index: 2;
  top: 0;
  left: var(--mc-radius);
  right: var(--mc-radius);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--mc-accent), transparent);
  pointer-events: none;
}
.mcard > .mcard__media {
  display: block;
  position: relative;
  margin: 0;
  padding: 0;
  width: 100%;
  aspect-ratio: var(--mc-ratio);
  overflow: hidden;
  background: var(--bg-subtle, #0C1017);
  border: 0;
  border-bottom: 1px solid var(--mc-line);
  border-radius: 0;
}
.mcard__media picture { display: block; width: 100%; height: 100%; }
/* the picture fills its box whatever height rule the site gave the img (a 2:1 thumbnail left a dark band under a 1.9:1 box) */
.mcard > .mcard__media > img,
.mcard > .mcard__media picture > img { position: absolute; inset: 0; width: 100%; height: 100%; }
.mcard__media img,
img.mcard__media {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  max-height: none;                    /* a site's own thumbnail cap would crop the plate and leave a band below it */
  object-fit: cover;
  border: 0;
  border-radius: 0;
}
img.mcard__media { height: auto; }
.mcard > .mcard__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--mc-s1);
  min-width: 0;
  align-self: stretch;
  padding: var(--mc-pad);
  background: radial-gradient(90% 110% at 50% 0, var(--mc-glow), transparent 70%);
}
.mcard__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px var(--mc-s2);
  margin: 0;
  font: 500 max(0.8125rem, var(--fs-min, 0px)) / 1.3 var(--font-mono, ui-monospace, monospace);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mc-dim);
}
.mcard__meta a { color: inherit; }
.mcard__title {
  margin: 0;
  font: 700 clamp(1.125rem, 1.05rem + 0.3vw, 1.3125rem) / 1.3 var(--font-sans, inherit);
  letter-spacing: -0.01em;
  text-wrap: balance;
  color: var(--mc-ink);
}
.mcard__title a { color: inherit; }
.mcard__text {
  margin: 0;
  font-size: max(0.9375rem, var(--fs-min, 0px));
  line-height: 1.55;
  text-wrap: pretty;
  color: var(--mc-dim);
}
.mcard__foot { margin-top: auto; padding-top: var(--mc-s1); }

/* a whole-card link: the title link stretches over the card */
.mcard--link .mcard__title a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
a.mcard:focus-visible,
.mcard:has(.mcard__title a:focus-visible) { outline: 2px solid var(--mc-accent); outline-offset: 2px; }
.mcard--link:hover,
a.mcard:hover { border-color: var(--border-accent, color-mix(in srgb, var(--mc-accent) 35%, transparent)); }

/* the hero card of a post or a showcase page: cover, title, meta and lead in one card */
.mcard--hero .mcard__body { padding: var(--mc-s3) var(--mc-pad) var(--mc-pad); gap: var(--mc-s2); }
.mcard--hero .mcard__title { font-size: clamp(1.625rem, 1.2rem + 1.9vw, 2.375rem); line-height: 1.15; letter-spacing: -0.02em; }
.mcard__lead {
  margin: 0;
  max-width: none;                     /* text width = card width */
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  line-height: 1.65;
  text-align: start;
  text-wrap: pretty;
  color: var(--mc-ink);
}
.mcard__lead .postClaim { margin: 0; padding: 0; border: 0; font-size: inherit; line-height: inherit; color: inherit; } /* no left stripe on a rounded card */
.mcard__body > .seedPill { margin: 0; }          /* the body gap is the rhythm: no extra margin under the badge */
.mcard__lead > p { margin: 0 0 var(--mc-s2); }
.mcard__lead > :last-child { margin-bottom: 0; }
.mcard__label { margin: 0; font: 700 max(0.75rem, var(--fs-min, 0px)) / 1.3 var(--font-mono, ui-monospace, monospace); letter-spacing: 0.1em; text-transform: uppercase; color: var(--mc-accent); }

/* side by side on a wide card: the picture fills the left column to the card's edge, no gap */
@media (min-width: 70rem) {
  .mcard--side { flex-direction: row; }
  .mcard--side > .mcard__media { flex: 0 0 50%; width: auto; aspect-ratio: auto; align-self: stretch; border-bottom: 0; border-right: 1px solid var(--mc-line); }
  .mcard--side .mcard__body { justify-content: center; }
}

/* a screenshot card (site or shop tile): the screenshot's own ratio, a row body with a small mark */
.mcard--shot { --mc-ratio: 16 / 10; }
.mcard__body--row { flex-direction: row; align-items: flex-start; gap: var(--mc-s2); }
.mcard__col { display: flex; flex-direction: column; gap: var(--mc-s1); min-width: 0; flex: 1; }
.mcard__icon--blank { display: grid; place-items: center; font: 700 1.125rem/1 var(--font-mono, ui-monospace, monospace); color: var(--mc-accent); background: var(--accent-soft, color-mix(in srgb, var(--mc-accent) 12%, transparent)); border: 1px solid var(--border-accent, var(--mc-line)); text-transform: uppercase; }
.mcard__icon { flex: none; width: 40px; height: 40px; max-width: 40px; margin: 0; border-radius: 9px; }
.mcard > .mcard__body > .bentoMiddle, .mcard > .mcard__body > .bentoTop, .mcard > .mcard__body > .bentoBottom { margin: 0; }

/* phone panel: an opening block of mark and words (a home hero) is one card on phones and tablets; from 48 rem it keeps the page's own layout */
@media (max-width: 47.99rem) {
  .mcard--panel {
    position: relative;
    overflow: hidden;
    margin-inline: var(--gutter, 16px);
    color: var(--mc-ink);
    background: var(--mc-fill);
    border: 1px solid var(--mc-line);
    border-radius: var(--mc-radius);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--mc-accent) 45%, transparent);
  }
}

/* card grids: one rhythm */
.mcards { display: grid; gap: var(--mc-s3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 17.5rem), 1fr)); margin: var(--mc-s3) 0 0; padding: 0; list-style: none; }

/* ── the page: one content width for media, text cards and dividers ───── */
.mpage {
  box-sizing: border-box;
  width: 100%;
  max-width: calc(var(--mc-w) + 2 * var(--gutter, 24px));
  margin-inline: auto;                 /* centred, never a left strip */
  padding: clamp(var(--mc-s3), 5vw, var(--mc-s5)) var(--gutter, 24px) var(--mc-s5);
}
.mpage { --measure: none; }          /* mobile.css caps every paragraph at 65ch: here the column is the measure, so text, card and dividers end on one edge */
.mpage > * { max-width: var(--mc-w); margin-inline: auto; }
.mpage--wide { max-width: 72rem; }
.mpage--wide > * { max-width: none; }
.mpage--wide > .mpage__intro { max-width: var(--mc-w); margin-inline: 0; }
.mpage--wide .mpage__intro { max-width: var(--mc-w); }
.mpage > * + * { margin-top: var(--mc-s3); }
.mpage > .mcard--hero + * { margin-top: var(--mc-s4); }
.mpage :is(h1, h2, h3, h4, [id], .mcard__media) { scroll-margin-top: 5.5rem; } /* under the sticky header */

.mpage .prose, .mpage .postProse {
  --mc-prose-ink: color-mix(in srgb, var(--mc-ink) 86%, var(--mc-dim));       /* body text: 7:1 and more on the page background */
  max-width: var(--mc-w);              /* same right edge as the card and the pictures */
  font-size: clamp(1.0625rem, 1rem + 0.25vw, 1.125rem);   /* 17 to 18 px */
  line-height: 1.7;
  color: var(--mc-prose-ink);
}
.mpage .prose > :first-child { margin-top: 0; }
.mpage .prose p { margin: 0 0 var(--mc-s2); }
.mpage .prose :is(ul, ol) { margin: 0 0 var(--mc-s2); padding-left: var(--mc-s3); }
.mpage .prose li { margin-bottom: var(--mc-s1); }
.mpage .prose strong, .mpage .prose :is(h1, h2, h3, h4) { color: var(--mc-ink); }
.mpage .prose h2 { margin: var(--mc-s4) 0 var(--mc-s2); padding-top: var(--mc-s3); border-top: 1px solid var(--mc-line); }
.mpage .prose h2:first-of-type { margin-top: var(--mc-s4); }
.mpage .prose h3 { margin: var(--mc-s4) 0 var(--mc-s1); }
.mpage .prose hr { width: 100%; margin: var(--mc-s4) 0; border: 0; border-top: 1px solid var(--mc-line); }
.mpage .prose a { color: var(--accent, var(--mc-accent)); text-underline-offset: 0.2em; }
/* in-article pictures: the content width, the card radius, a gap above and below */
.mpage .prose :is(img, picture, figure):not(.mcard *) { display: block; width: 100%; max-width: 100%; height: auto; margin: var(--mc-s3) 0; }
.mpage .prose img:not(.mcard *) { border-radius: var(--mc-radius); border: 1px solid var(--mc-line); }
.mpage .prose p:has(> img:only-child) { margin: var(--mc-s3) 0; }
.mpage .prose p > img:only-child { margin: 0; }
.mpage .prose figcaption { margin-top: var(--mc-s1); font-size: max(0.875rem, var(--fs-min, 0px)); color: var(--mc-dim); text-align: center; }
/* inline code: 14 px and more, a readable fill (not code blocks: code-block.css) */
.mpage .prose :not(pre) > code {
  font-size: max(0.875rem, 0.88em);
  padding: 0.12em 0.45em;
  color: var(--mc-ink);
  background: color-mix(in srgb, var(--mc-ink) 9%, var(--mc-fill-bottom));
  border: 1px solid color-mix(in srgb, var(--mc-ink) 18%, var(--mc-fill-bottom));
  border-radius: 6px;
  white-space: nowrap;                 /* a short chip never splits at its hyphen or slash */
}
.mpage .prose pre { margin: var(--mc-s3) 0; max-width: 100%; }
.mpage .prose table { margin: var(--mc-s3) 0; }

/* ── balanced ambient background: a glow at the top left AND the top right ─ */
.wrapper:has(.mpage) .backgroundOrbs .orb1 { top: -12%; left: -8%; width: min(700px, 90vw); height: min(700px, 90vw); }
.wrapper:has(.mpage) .backgroundOrbs .orb2 { top: -12%; left: auto; right: -8%; width: min(700px, 90vw); height: min(700px, 90vw); background: radial-gradient(circle, color-mix(in srgb, var(--emerald, #22C55E) 17%, transparent) 0%, transparent 70%); }

@media (max-width: 30rem) {
  .mcard { --mc-radius: 14px; }
}

@media (prefers-reduced-motion: no-preference) {
  .mcard--link { transition: border-color 150ms cubic-bezier(0.23, 1, 0.32, 1), transform 200ms cubic-bezier(0.23, 1, 0.32, 1); }
  @media (hover: hover) and (pointer: fine) {
    .mcard--link:hover, a.mcard:hover { transform: translateY(-2px); }
  }
}
