/* YPS AI Agent — why it was built.
   Two cards in a row: the Building the Alternative cover on the left, and a
   plain neutral grey card (#eaeaea) on the right with the story as four
   columns, titles and text aligned across. The cover is shown whole: its card
   takes the cover's own proportions (296px wide, about 419px tall), and the
   text card stretches to match it. */

.civic-origin {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  gap: var(--civic-card-gap);
  width: min(calc(100% - 80px), 1430px);
  margin: 0 auto 90px;
}

.civic-origin-cover {
  display: block;
  min-width: 0;
  overflow: hidden;
  border-radius: 22px;
  background: #1a1d44;
}

/* The image sets the row's height, so the cover is shown whole. Only if a
   fallback font ever made the text taller than the cover would the card
   stretch, trimming a sliver of the cover's lower edge rather than leaving
   the two cards' bottoms out of line. */
.civic-origin-cover > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.civic-origin-cover:focus-visible {
  outline: 2px solid var(--civic-ink);
  outline-offset: 4px;
}

.civic-origin-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 34px 36px 18px;
  border-radius: 22px;
  background: #eaeaea;
  color: #171719;
}

.civic-origin-text > h2 {
  margin: 0;
  font-size: clamp(26px, 2vw, 32px);
  font-weight: 540;
  letter-spacing: -0.038em;
  line-height: 1.1;
  text-wrap: balance;
}

/* Two tones, as in the hero's "A Private Digital / YPS Advisor." */
.civic-origin-text > h2 > span { color: #8f8f8d; }

.civic-origin-blocks {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px clamp(20px, 2vw, 32px);
  /* 27px, not the narrative's 24px: the titles' tighter line box would
     otherwise sit 3px closer to the heading than other sections' text. */
  margin-top: 27px;
}

/* Each block spans a title row and a text row, so the text starts level
   across the row even when a title runs to two lines. */
.civic-origin-block {
  display: grid;
  min-width: 0;
  grid-row: span 2;
  grid-template-rows: subgrid;
  row-gap: 10px;
}

.civic-origin-block h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 560;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.civic-origin-block p {
  margin: 0;
  color: #50504f;
  font-size: 13px;
  line-height: 1.55;
  text-wrap: pretty;
}

.civic-origin-block strong {
  color: #171719;
  font-weight: 560;
}

.civic-origin-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 24px;
  margin-top: auto;
  padding-top: 12px;
}

.civic-origin-foot > p {
  margin: 0;
  color: #50504f;
  font-size: 12px;
  line-height: 1.5;
  text-wrap: balance;
}

/* A plain text link, like "How it works" in the hero. */
.civic-origin .civic-origin-link {
  width: auto;
  min-height: 36px;
  padding-inline: 0;
  border-color: transparent;
  border-radius: 0;
  background: transparent;
  color: #171719;
}

.civic-origin .civic-origin-link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

/* Dark theme: the text card follows the Contribute card; the cover is unchanged. */
.civic-page.site-dark .civic-origin-text {
  background: var(--civic-card-surface);
  color: #f0eee9;
}

.civic-page.site-dark .civic-origin-block p { color: #b5b5b2; }
.civic-page.site-dark .civic-origin-foot > p { color: #b5b5b2; }
.civic-page.site-dark .civic-origin-text > h2 > span { color: #8f8f8c; }
.civic-page.site-dark .civic-origin-block strong,
.civic-page.site-dark .civic-origin .civic-origin-link { color: #f0eee9; }

/* Stacked once the text would outgrow the cover beside it: the whole cover,
   centred above the text card. */
@media (max-width: 1320px) {
  .civic-origin { grid-template-columns: minmax(0, 1fr); }
  .civic-origin-cover { justify-self: center; width: min(100%, 296px); }
}

/* The cover is for desktops only: below the site's 1024px tablet break, and
   on touch-first screens of any width (a large iPad in landscape is 1366px),
   the text card stands alone. The text link still leads to the report. */
@media (max-width: 1024px), (pointer: coarse) {
  .civic-origin { grid-template-columns: minmax(0, 1fr); }
  .civic-origin-cover { display: none; }
}

/* The capabilities section's own top margin is 24px here; collapse into the page rhythm. */
@media (max-width: 940px) {
  .civic-origin {
    width: calc(100% - 40px);
    margin-bottom: 64px;
  }
}

@media (max-width: 900px) {
  .civic-origin-blocks { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 32px; }
}

@media (max-width: 620px) {
  .civic-origin-text > h2 > span { display: block; }
  .civic-origin-text { padding: 32px 22px 20px; }
  .civic-origin-blocks { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .civic-origin-block { row-gap: 8px; }
  /* Link first, then the credit, both flush left. */
  .civic-origin-foot { flex-direction: column-reverse; align-items: flex-start; padding-top: 14px; }
}
