/* Blog: index, article pages and cards. Ported by hand from the prototype
   blog (elos-blog/src/styles/: blog.css, editorial.css, library.css,
   refinements.css), keeping only what the static pages use. Needs base.css
   first; templates/DESIGN.md documents the tokens. */

:root {
  /* The index title is larger than any page title (prototype: 72 → 126 px). */
  --text-display: clamp(3.75rem, 2.6rem + 5.7vw, 7.5rem);
  /* Card and cover image ratio; crops use the manifest's focal point. */
  --card-ratio: 3 / 2;
  --cover-ratio: 3 / 2;
  /* Lime bar under prose headings and on source cards. */
  --accent-bar: var(--space-1);

  /* Index: featured carousel and "More articles" (prototype sizes). */
  --hero-height: 26.25rem;                  /* 420 */
  --hero-basis: 100%;
  --radius-hero: 32px;
  --radius-post: 26px;
  --hero-corner: 30px;                      /* the caption's inverted corners */
  --hero-split-image: 12.5rem;              /* 200 */
  --post-image-height: 12.5rem;             /* 200 */
  --post-list-image: 5.625rem;              /* 90 */
  --text-hero-title: clamp(1.8125rem, 1.2rem + 1.9vw, 2.625rem); /* 29 → 42 */
  --border-post: 1px solid #bec8bb;         /* pine 26 % on cream */
  --scrollbar-track: #24423618;
  --related-card: 18.75rem;                 /* 300 */
  --related-image: 6.25rem;                 /* 100 */
}

@media (min-width: 768px) {
  :root {
    --hero-height: 35rem;                   /* 560 */
    --hero-basis: 70%;
    --hero-split-image: 15rem;              /* 240 */
    --post-list-image: 15rem;               /* 240 */
  }
}

@media (min-width: 1024px) {
  :root {
    --hero-basis: calc(44% - var(--space-5) / 2);
  }
}

/* --- Shared ---------------------------------------------------------------- */

.blog-main {
  padding-top: var(--header-clearance);
  padding-bottom: var(--section-space);
}

.eyebrow {
  display: block;
  color: var(--pine);
  font-size: var(--text-sm);
  font-weight: 650;
  line-height: 1.5;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.blog-section + .blog-section {
  margin-top: var(--space-8);
}

.section-heading {
  margin-bottom: var(--space-5);
  color: var(--pine);
  font-size: var(--text-h2-prose);
  letter-spacing: -0.02em;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--target-min);
  color: var(--purple);
  font-weight: 600;
  text-decoration-thickness: 1px;
  transition: color var(--duration-fast) var(--ease);
}

.text-link:hover {
  color: var(--purple-bright);
  text-decoration-thickness: 2px;
}

.rss-follow {
  margin-top: var(--space-8);
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
}

/* Focal points from media/manifest.json (covers and cards). */
.focus-brazil-pilot { object-position: 55% 52%; }
.focus-elos-questions,
.focus-small-business-resources-brazil { object-position: 50% 58%; }
.focus-nonprofit-resources-brazil { object-position: 50% 45%; }
.focus-nonprofit-resources-eu { object-position: 50% 55%; }

/* --- Index ------------------------------------------------------------------ */

.index-intro {
  margin-bottom: var(--space-7);
}

.index-intro h1 {
  display: inline-block;
  padding: 0 var(--space-2) var(--space-1) 0;
  background: linear-gradient(transparent 78%, var(--lime) 78%, var(--lime) 92%, transparent 92%);
  color: var(--pine);
  font-size: var(--text-display);
  font-weight: 650;
  line-height: 1;
  letter-spacing: -0.06em;
}

.heading-dot {
  color: var(--purple);
}

.index-lead {
  max-width: 48ch;
  margin-top: var(--space-5);
  font-size: var(--text-lead);
  line-height: var(--leading-body);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.filter-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--target-min);
  padding: var(--space-2) var(--space-4);
  border: var(--border-hairline);
  border-radius: var(--radius-pill);
  background: var(--cream);
  color: var(--pine);
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: var(--tracking-ui);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease),
    transform var(--duration-fast) var(--ease);
}

.filter-button:hover {
  border-color: var(--pine);
  background: var(--pine-a7);
}

.filter-button:active {
  transform: translateY(1px);
}

.filter-button[aria-pressed='true'] {
  border-color: var(--pine);
  background: var(--lime);
}

.filter-count {
  font-variant-numeric: tabular-nums;
}

.filter-status {
  margin-bottom: var(--space-5);
  color: var(--muted);
  font-size: var(--text-base);
}

/* The index, as in the prototype: the filters, a featured carousel (four
   large cards in three styles, two at a time from 1024 px, stacked on
   phones), then "More articles" in a grid or a list. Choosing a category
   hides the carousel and lists every matching article (blog.js). Without
   JavaScript the featured cards stack and "More articles" lists the rest. */
.browse-toolbar {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-7);
}

/* The filters, the carousel buttons and the view switch carry
   data-pending until blog.js has set them up. Until then (or without it)
   they keep their space but are invisible and unreachable, so nothing
   shifts as the page loads. ([hidden] can't do this: base.css forces it to
   display: none.) */
[data-pending] {
  visibility: hidden;
}

.browse-toolbar .filters,
.browse-toolbar .filter-status {
  margin: 0;
}

.filter-button {
  border-radius: var(--radius-md);
}

.filter-button .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* --- Featured carousel --- */

.featured-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.featured-heading {
  color: var(--pine);
  font-size: var(--text-h3);
  line-height: 1.2;
}

.hero-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Phones stack the featured cards: no carousel buttons. */
@media (max-width: 767px) {
  .hero-controls {
    display: none;
  }
}

.hero-controls p {
  margin-right: var(--space-2);
  color: var(--pine);
  font-size: var(--text-base);
}

.hero-prev,
.hero-next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-width: 2.875rem;
  min-height: 2.875rem;
  border: 1px solid var(--pine);
  border-radius: var(--radius-pill);
  background: var(--cream);
  color: var(--pine);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease);
}

.hero-prev .icon,
.hero-next .icon {
  width: 20px;
  height: 20px;
}

.hero-prev .icon {
  transform: rotate(180deg);
}

.hero-next {
  padding-inline: var(--space-5);
  border-color: var(--purple);
  background: var(--purple);
  color: var(--cream);
  font-size: var(--text-md);
  font-weight: 700;
}

.hero-prev:not(:disabled):hover {
  background: var(--lime);
}

.hero-next:not(:disabled):hover {
  border-color: var(--pine);
  background: var(--pine);
}

:is(.hero-prev, .hero-next):disabled {
  cursor: default;
  opacity: 0.4;
}

.hero-track {
  display: grid;
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.hero-track:focus-visible {
  outline: var(--focus-width) solid var(--focus-ring);
  outline-offset: 3px;
}

.hero-item {
  display: flex;
  min-width: 0;
}

/* The caption colours are variables so the inverted corners follow them. */
.hero-card {
  --caption-bg: var(--cream);
  --caption-fg: var(--pine);
  position: relative;
  isolation: isolate;
  display: flex;
  width: 100%;
  min-height: var(--hero-height);
  overflow: hidden;
  border-radius: var(--radius-hero);
  background: var(--pine);
  color: var(--pine);
}

.hero-card:has(.card-link:focus-visible) {
  outline: var(--focus-width) solid var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.hero-card picture {
  display: contents;
}

.hero-image {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-caption {
  position: relative;
  width: 88%;
  padding: var(--space-5);
  background: var(--caption-bg);
  color: var(--caption-fg);
  transition: background-color var(--duration-base) var(--ease), color var(--duration-base) var(--ease);
}

.hero-title {
  margin-top: var(--space-3);
  color: inherit;
  font-size: var(--text-hero-title);
  font-weight: 650;
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.hero-card .eyebrow {
  color: inherit;
}

/* Photo: the caption sits in the bottom-left corner of the photo, with two
   inverted rounded corners joining it to the image. */
.hero-photo {
  align-items: flex-end;
}

.hero-photo .hero-caption {
  margin-bottom: -1px;
  border-radius: 0 32px 0 0;
}

.hero-photo .hero-caption::before,
.hero-photo .hero-caption::after {
  content: '';
  position: absolute;
  width: var(--hero-corner);
  height: var(--hero-corner);
  border-radius: 0 0 0 28px;
  box-shadow: -12px 12px 0 10px var(--caption-bg);
  transition: box-shadow var(--duration-base) var(--ease);
}

.hero-photo .hero-caption::before {
  top: calc(-1 * var(--hero-corner));
  left: 0;
}

.hero-photo .hero-caption::after {
  right: calc(-1 * var(--hero-corner));
  bottom: 0;
}

/* Panel: the caption hangs from the top-right corner. */
.hero-panel {
  flex-direction: column;
  align-items: flex-end;
}

.hero-panel .hero-caption {
  border-radius: 0 0 0 32px;
}

/* Split: the photo on top, the purple caption below. */
.hero-split {
  flex-direction: column;
  justify-content: flex-end;
  background: var(--purple);
  --caption-bg: var(--purple);
  --caption-fg: var(--cream);
}

.hero-split .hero-image {
  position: relative;
  z-index: 0;
  height: var(--hero-split-image);
  object-position: center 40%;
}

.hero-split .hero-caption {
  flex: 1;
  width: 100%;
}

@media (hover: hover) {
  .hero-card:is(.hero-photo, .hero-panel):hover {
    --caption-bg: var(--purple);
    --caption-fg: var(--cream);
  }
}

.hero-card:is(.hero-photo, .hero-panel):focus-within {
  --caption-bg: var(--purple);
  --caption-fg: var(--cream);
}

html.high-contrast .hero-card {
  --caption-bg: var(--cream);
  --caption-fg: var(--ink);
  outline: 2px solid var(--pine);
}

/* Date, reading time and the call to action, on every card. */
.post-tail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-4);
  font-size: var(--text-md);
}

.post-tail > span:first-child::after {
  content: '·';
  margin-left: var(--space-2);
}

.post-tail .read-label {
  font-weight: 650;
}

.post-tail .read-arrow {
  width: 20px;
  height: 20px;
  margin-left: auto;
}

:is(.hero-card, .post-card):hover .read-label {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* From 768 px the featured cards scroll sideways, one card per step. */
@media (min-width: 768px) {
  .hero-track {
    display: flex;
    gap: var(--space-5);
    padding-bottom: var(--space-3);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-color: var(--purple) var(--scrollbar-track);
  }

  .hero-item {
    flex: 0 0 var(--hero-basis);
    scroll-snap-align: start;
  }
}

/* --- More articles --- */

.more-posts {
  margin-top: var(--space-8);
}

.featured-posts[hidden] + .more-posts {
  margin-top: 0;
}

.more-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.more-heading .section-heading {
  margin: 0;
}

.view-switch {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  border: var(--border-post);
  border-radius: var(--radius-lg);
}


.view-switch button {
  display: grid;
  place-items: center;
  min-width: var(--target-min);
  min-height: var(--target-min);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--pine);
  cursor: pointer;
}

.view-switch button[aria-pressed='false']:hover {
  background: var(--pine-a7);
}

.view-switch button[aria-pressed='true'] {
  background: var(--pine);
  color: var(--cream);
}

.view-switch .icon {
  width: 20px;
  height: 20px;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-item {
  display: flex;
  min-width: 0;
}

.post-item[hidden] {
  display: none;
}

.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  border: var(--border-post);
  border-radius: var(--radius-post);
  background: var(--cream);
  color: var(--pine);
}

.post-card:has(.card-link:focus-visible) {
  outline: var(--focus-width) solid var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.post-card picture {
  display: block;
}

.post-image {
  display: block;
  width: 100%;
  height: var(--post-image-height);
  object-fit: cover;
  background: var(--line);
}

.post-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: var(--space-5);
  transition: background-color var(--duration-base) var(--ease), color var(--duration-base) var(--ease);
}

.post-card .eyebrow {
  color: inherit;
}

.post-title {
  margin-top: var(--space-3);
  color: inherit;
  font-size: var(--text-h3);
  font-weight: 650;
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.post-summary {
  margin-top: var(--space-3);
  font-size: var(--text-base);
  line-height: 1.5;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.post-tags span:not(.visually-hidden) {
  padding: var(--space-1) var(--space-2);
  border: 1px solid currentColor;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  line-height: 1.4;
}

.post-card .post-tail {
  margin-top: auto;
  padding-top: var(--space-5);
}

/* Date and reading time on the first line; the call to action and its
   arrow below, the arrow at the right edge. */
.post-card .read-label {
  flex: 1 0 calc(100% - var(--space-7));
}

/* List view: the image beside the text, one article per row. */
.post-grid[data-view='list'] {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
}

.post-grid[data-view='list'] .post-card {
  display: grid;
  grid-template-columns: var(--post-list-image) minmax(0, 1fr);
}

/* The image fills its column; the text decides the row height. */
.post-grid[data-view='list'] .post-card picture {
  position: relative;
}

.post-grid[data-view='list'] .post-image {
  position: absolute;
  inset: 0;
  height: 100%;
}

.post-grid[data-view='list'] .post-title {
  font-size: var(--text-h2-prose);
}

.post-grid[data-view='list'] .post-summary {
  max-width: 70ch;
}

/* The list keeps date, reading time and the call to action on one line. */
.post-grid[data-view='list'] .read-label {
  flex: 0 1 auto;
}

/* Hover, in the grid and the list: the text panel turns purple with cream
   text and the call to action is underlined (the prototype does this in the
   list only). Keyboard focus does the same. */
@media (hover: hover) {
  .post-card:hover .post-body {
    background: var(--purple);
    color: var(--cream);
  }
}

.post-card:focus-within .post-body {
  background: var(--purple);
  color: var(--cream);
}

html.high-contrast .post-card .post-body {
  background: var(--cream);
  color: var(--ink);
}

@media (max-width: 767px) {
  .post-grid[data-view='list'] .post-body {
    padding: var(--space-4);
  }

  .post-grid[data-view='list'] .post-title {
    font-size: var(--text-h4);
  }

  .post-grid[data-view='list'] .post-tags,
  .post-grid[data-view='list'] .read-arrow {
    display: none;
  }
}

html.high-contrast .post-card {
  border: var(--border-strong);
}

/* --- Cards ------------------------------------------------------------------ */

.card-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
  margin: 0;
  padding: 0;
  list-style: none;
}

.card-item {
  display: flex;
  min-width: 0;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  border: var(--border-hairline);
  border-radius: var(--radius-xl);
  background: var(--cream);
  transition:
    border-color var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease),
    transform var(--duration-fast) var(--ease);
}

.card:hover {
  border-color: var(--pine);
  box-shadow: var(--shadow-button);
  transform: translateY(-2px);
}

.card:active {
  transform: translateY(0);
}

/* The title link covers the whole card; the focus ring goes on the card. */
.card:has(.card-link:focus-visible) {
  outline: var(--focus-width) solid var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.card-link {
  color: inherit;
  text-decoration: none;
}

.card-link::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}

.card-link:focus-visible {
  outline: none;
}

.card:hover .card-link {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

.card picture {
  display: block;
}

.card-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: var(--card-ratio);
  object-fit: cover;
  background: var(--line);
}

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
}

.card-title {
  color: var(--pine);
  font-size: var(--text-h3);
  font-weight: 650;
  line-height: var(--leading-heading);
  letter-spacing: -0.02em;
}

.card-summary {
  font-size: var(--text-base);
  line-height: var(--leading-body);
}

/* Dates sit on one line at the bottom, so cards in a row align. */
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-4);
  margin-top: auto;
  padding-top: var(--space-2);
  color: var(--muted);
  font-size: var(--text-base);
}

@media (min-width: 768px) {
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .card-grid:not(.featured-grid) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* --- Article ------------------------------------------------------------------ */

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-2);
  margin: 0 0 var(--space-6);
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: var(--text-base);
}

.breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.breadcrumb li + li::before {
  content: '/';
  color: var(--muted);
}

.breadcrumb a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--target-min);
  min-height: var(--target-min);
  color: var(--purple);
  text-decoration-thickness: 1px;
}

.breadcrumb a:hover {
  color: var(--purple-bright);
  text-decoration-thickness: 2px;
}

/* The current page's crumb repeats the <h1> right below; phones skip it. */
.breadcrumb [aria-current='page'] {
  display: none;
  max-width: 40ch;
}

@media (min-width: 768px) {
  .breadcrumb [aria-current='page'] {
    display: inline-flex;
  }
}

.article-hero {
  display: grid;
  gap: var(--space-6);
  align-items: center;
}

/* Titles break between words only: auto-hyphenation split PT titles
   ("gru-po", "pe-quenas"). Long words still wrap (overflow-wrap in base.css). */
.article-title,
.card-title,
.section-heading {
  hyphens: manual;
}

.article-title {
  margin-top: var(--space-3);
  color: var(--pine);
  font-weight: 650;
}

.article-summary {
  max-width: 48ch;
  margin-top: var(--space-5);
  font-size: var(--text-lead);
  line-height: var(--leading-body);
}

.article-byline {
  display: flex;
  max-width: 48ch;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin-top: var(--space-5);
  color: var(--muted);
  font-size: var(--text-base);
}

.article-byline .author {
  color: var(--pine);
  font-weight: 650;
}

.article-cover picture {
  display: block;
  overflow: hidden;
  border-radius: var(--radius-dialog);
  background: var(--line);
}

.article-cover img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: var(--cover-ratio);
  object-fit: cover;
}

.article-cover figcaption {
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: var(--text-md);
  line-height: 1.5;
  text-align: right;
}

.article-cover figcaption a {
  color: inherit;
  text-decoration-thickness: 1px;
}

.article-cover figcaption a:hover {
  color: var(--purple-bright);
}

.article-reading {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
  margin-top: var(--space-7);
}

/* "In this article": a <details> list, a sticky rail from 1024 px. */
.article-contents {
  border: var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: 0 var(--space-4);
}

.article-contents summary {
  display: flex;
  align-items: center;
  min-height: var(--target-min);
  color: var(--pine);
  font-size: var(--text-base);
  font-weight: 650;
  cursor: pointer;
}

.article-contents ol {
  margin: 0 0 var(--space-3);
  padding: 0 0 0 var(--space-4);
  border-left: 2px solid var(--lime);
  list-style: none;
}

.article-contents a {
  display: flex;
  align-items: center;
  min-height: var(--target-min);
  color: var(--muted);
  font-size: var(--text-base);
  line-height: 1.4;
  text-decoration: none;
}

.article-contents a:hover {
  color: var(--pine);
  text-decoration: underline;
}

.reading-column {
  min-width: 0;
}

/* Running text. Headings sit closer to their own text than to the section
   above; paragraphs keep a readable measure. */
.prose {
  max-width: var(--measure);
  font-size: var(--text-prose);
  line-height: var(--leading-prose);
}

.prose p,
.prose li {
  font-size: var(--text-prose);
}

.prose > * + * {
  margin-top: var(--space-5);
}

.prose li + li {
  margin-top: var(--space-2);
}

.prose ul {
  margin-bottom: 0;
  padding-left: var(--space-5);
}

.prose li::marker {
  color: var(--purple);
}

.prose h2 {
  margin-top: var(--space-7);
  color: var(--pine);
  font-size: var(--text-h2-prose);
  letter-spacing: -0.02em;
  scroll-margin-top: calc(var(--header-offset) + var(--header-height) + var(--space-5));
}

.prose h2::after {
  content: '';
  display: block;
  width: var(--space-8);
  height: var(--accent-bar);
  margin-top: var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--lime);
}

.prose h2 + * {
  margin-top: var(--space-4);
}

.prose > h2:first-child {
  margin-top: 0;
}

.prose strong {
  color: var(--pine);
  font-weight: 650;
}

.prose a,
.reference a,
.article-correction a {
  color: var(--purple);
  text-decoration-thickness: 1px;
  transition: color var(--duration-fast) var(--ease);
}

.prose a:hover,
.reference a:hover,
.article-correction a:hover {
  color: var(--purple-bright);
  text-decoration-thickness: 2px;
}

/* FAQ disclosure kept from the Markdown source. */
.prose .article-faq {
  padding: 0 var(--space-5);
  border: 1px solid var(--purple);
  border-radius: var(--radius-lg);
}

.prose .article-faq > summary {
  display: flex;
  align-items: center;
  min-height: var(--control-min-height);
  color: var(--purple);
  font-weight: 650;
  cursor: pointer;
}

/* display: flex drops the native marker, so both disclosures draw their own. */
.prose .article-faq > summary,
.article-contents summary {
  gap: var(--space-2);
  padding-block: var(--space-2);
  list-style: none;
}

.prose .article-faq > summary::-webkit-details-marker,
.article-contents summary::-webkit-details-marker {
  display: none;
}

.prose .article-faq > summary::before,
.article-contents summary::before {
  content: '▸';
  flex-shrink: 0;
  transition: transform var(--duration-fast) var(--ease);
}

.prose .article-faq[open] > summary::before,
.article-contents details[open] > summary::before {
  transform: rotate(90deg);
}

.prose .article-faq > summary:hover {
  color: var(--purple-bright);
}

.prose .article-faq > :not(summary) {
  margin-top: 0;
  margin-bottom: var(--space-5);
}

/* Tables scroll inside their own region on narrow screens. */
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  border: var(--border-hairline);
  border-radius: var(--radius-lg);
}

.prose table {
  width: 100%;
  min-width: 32rem;
  border-collapse: collapse;
  font-size: var(--text-base);
  line-height: var(--leading-body);
}

.prose th,
.prose td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.prose thead th {
  background: var(--lime);
  color: var(--pine);
  font-weight: 650;
}

.prose tbody th {
  color: var(--pine);
  font-weight: 650;
}

.prose tbody tr:last-child > * {
  border-bottom: 0;
}

/* Inline source card (```elos source block). */
.source-card {
  padding: var(--space-4) var(--space-5);
  border-left: var(--accent-bar) solid var(--lime);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--pine-a7);
}

.prose .source-card p {
  font-size: var(--text-base);
  line-height: var(--leading-body);
}

.source-card .source-provider {
  color: var(--muted);
}

.source-card .source-locator {
  margin-top: var(--space-1);
  color: var(--muted);
}

.prose .source-card a {
  font-weight: 600;
}

/* Card link to another article (```elos article-link block). */
.article-link a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: var(--control-min-height);
  padding: var(--space-4) var(--space-5);
  border: var(--border-hairline);
  border-radius: var(--radius-lg);
  background: var(--pine-a7);
  color: var(--pine);
  font-weight: 650;
  text-decoration: none;
  transition:
    border-color var(--duration-fast) var(--ease),
    color var(--duration-fast) var(--ease);
}

.prose .article-link a:hover {
  border-color: var(--purple-bright);
  color: var(--purple-bright);
  text-decoration: none;
}

.article-link a > span {
  flex-shrink: 0;
  font-size: var(--text-icon);
}

/* Diagram (```elos figure block, rebuilt as HTML so the text reflows). */
.diagram {
  padding: var(--space-5);
  border-radius: var(--radius-xl);
  background: var(--pine-a7);
}

.prose .diagram-title {
  color: var(--pine);
  font-size: var(--text-h3);
  font-weight: 650;
  line-height: var(--leading-heading);
}

.prose .diagram-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
}

.prose .diagram-list li {
  margin: 0;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--cream);
  font-size: var(--text-base);
  line-height: var(--leading-body);
}

.diagram-list strong {
  display: block;
  font-size: var(--text-h4);
}

.prose .diagram-note {
  margin-top: var(--space-4);
  font-size: var(--text-base);
}

.diagram figcaption {
  margin-top: var(--space-3);
  color: var(--muted);
  font-size: var(--text-md);
}

@media (min-width: 540px) {
  .prose .diagram-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* --- Resources guides -------------------------------------------------------- */

/* Sub-sections: one per resource, under the topic's h2. */
.prose h3 {
  margin-top: var(--space-6);
  color: var(--pine);
  font-size: var(--text-h3);
}

.prose h3 + * {
  margin-top: var(--space-3);
}

/* Quick links under the byline. */
.article-start {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-5);
  margin-top: var(--space-4);
}

.article-start a,
.map-text-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--target-min);
  color: var(--purple);
  font-size: var(--text-base);
  font-weight: 600;
  text-decoration-thickness: 1px;
  transition: color var(--duration-fast) var(--ease);
}

.article-start a:hover,
.prose .map-text-link:hover {
  color: var(--purple-bright);
  text-decoration-thickness: 2px;
}

/* Map (```elos map block): an inline SVG whose regions are links. blog.js
   shows the selected region's card; the directory below lists the same
   links. */
.resource-map {
  padding: var(--space-4) var(--space-4) var(--space-5);
  border: var(--border-hairline);
  border-radius: var(--radius-xl);
}

.map-stage {
  position: relative;
  max-width: 42.5rem;
  margin: var(--space-3) auto 0;
}

.map-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.map-region {
  cursor: pointer;
}

.map-region:focus-visible {
  outline: none;
}

.map-land {
  fill: var(--lime);
  stroke: var(--purple);
  stroke-width: 0.55;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  transition: fill var(--duration-fast) var(--ease);
}

.map-leader {
  fill: none;
  stroke: var(--purple);
  stroke-width: 0.65;
  pointer-events: none;
}

.map-label-target {
  fill: transparent;
}

.map-code {
  fill: var(--purple);
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: 700;
  paint-order: stroke;
  stroke: var(--lime);
  stroke-width: 2px;
  stroke-linejoin: round;
  pointer-events: none;
}

.map-region:is(:hover, :focus-visible, [data-selected]) .map-land {
  fill: var(--purple);
}

.map-region:focus-visible .map-land {
  stroke: var(--pine);
  stroke-width: 2.5;
}

.map-region:focus-visible .map-label-target {
  fill: var(--purple);
}

.map-region:is(:hover, :focus-visible, [data-selected]) .map-code {
  fill: var(--cream);
  stroke: var(--purple);
}

/* The card for the selected region; blog.js places it at the region. */
.map-card {
  position: absolute;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2) var(--space-2);
  align-items: start;
  width: min(21.25rem, 100% - var(--space-4));
  padding: var(--space-3) var(--space-2) var(--space-4) var(--space-4);
  border-radius: var(--radius-button) var(--radius-button) var(--radius-button) var(--space-1);
  background: var(--purple);
  box-shadow: var(--shadow-panel);
  color: var(--cream);
}

.map-card[hidden] {
  display: none;
}

.prose .map-card-place {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  margin-top: var(--space-2);
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--lime);
  color: var(--purple);
  font-size: var(--text-base);
  font-weight: 650;
  line-height: var(--leading-body);
}

.prose .map-card-link {
  grid-column: 1 / -1;
  grid-row: 2;
  margin-right: var(--space-3);
  color: var(--cream);
  font-weight: 600;
  line-height: var(--leading-body);
}

.prose .map-card-link:hover {
  color: var(--lime);
}

.map-card-close {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  place-items: center;
  width: var(--target-min);
  height: var(--target-min);
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--lime);
  font-size: var(--text-icon);
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease);
}

.map-card-close:hover {
  background: var(--night-line);
}

.map-card-close:active {
  transform: translateY(1px);
}

.map-card :is(a, button):focus-visible {
  outline-color: var(--focus-ring-on-dark);
  outline-offset: 2px;
}

.resource-map figcaption {
  margin-top: var(--space-4);
  color: var(--muted);
  font-size: var(--text-base);
  line-height: var(--leading-body);
}

/* Directory (```elos directory block): the map's links as a list, one
   disclosure per state or country. The first link of each group is the map
   region's link. */
.directory-groups {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2) var(--space-3);
  align-items: start;
}

.directory-group {
  padding: 0 var(--space-4);
  border: var(--border-hairline);
  border-radius: var(--radius-md);
  scroll-margin-top: calc(var(--header-offset) + var(--header-height) + var(--space-5));
}

.directory-group[open] {
  border-color: var(--purple);
}

.directory-group:target {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

.directory-group > summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--target-min);
  padding-block: var(--space-1);
  color: var(--pine);
  font-size: var(--text-base);
  font-weight: 650;
  line-height: 1.4;
  list-style: none;
  cursor: pointer;
}

.directory-group > summary::-webkit-details-marker {
  display: none;
}

.directory-group > summary::before {
  content: '▸';
  flex-shrink: 0;
  color: var(--purple);
  transition: transform var(--duration-fast) var(--ease);
}

.directory-group[open] > summary::before {
  transform: rotate(90deg);
}

.directory-group > summary:hover {
  color: var(--purple);
}

.prose .directory-group ul {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-5);
}

.prose .directory-group li {
  font-size: var(--text-base);
  line-height: var(--leading-body);
}

@media (min-width: 540px) {
  .directory-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* References (article sources), after the body. */
.references {
  max-width: var(--measure);
  margin-top: var(--space-8);
}

.references .section-heading {
  margin-bottom: var(--space-4);
}

.reference-list {
  display: grid;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.reference {
  padding: var(--space-5);
  border: var(--border-hairline);
  border-top: var(--accent-bar) solid var(--lime);
  border-radius: var(--radius-lg);
}

.reference p {
  font-size: var(--text-base);
}

.reference .source-provider {
  color: var(--muted);
}

.reference h3 {
  margin: var(--space-1) 0 var(--space-2);
  color: var(--pine);
  font-size: var(--text-h4);
  line-height: 1.4;
}

.reference .text-link {
  margin-top: var(--space-1);
}

/* Resource cards (the article's resources): a logo or document symbol, then
   the same content as a reference. */
.references + .resources {
  margin-top: var(--space-7);
}

/* The symbol sits above the text on phones and beside it from 540 px. */
.resource-symbol {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  overflow: hidden;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  background: var(--pine-a7);
  color: var(--pine);
}

.resource-symbol picture {
  display: contents;
}

.resource-symbol img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.resource-copy {
  min-width: 0;
}

@media (min-width: 540px) {
  .resource {
    display: grid;
    grid-template-columns: 3rem minmax(0, 1fr);
    gap: var(--space-4);
    align-items: start;
  }

  .resource-symbol {
    margin-bottom: 0;
  }
}

/* After the article: call to action, correction note, related posts. */
.article-cta {
  display: grid;
  gap: var(--space-4);
  justify-items: start;
  margin-top: var(--space-8);
  padding: var(--space-6);
  border-radius: var(--radius-dialog);
  background: var(--pine);
  color: var(--cream);
}

.article-cta p {
  font-size: var(--text-lead);
  font-weight: 600;
}

.article-cta .button:focus-visible {
  outline-color: var(--focus-ring-on-dark);
}

.article-correction {
  max-width: var(--measure);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--text-base);
}

.related {
  margin-top: var(--space-8);
}

/* Related posts, compact as in the prototype: fixed 300 px cards, a short
   photo inset with rounded corners, the title, the summary (in full: it is
   one or two sentences) and a "Read more" cue. The category and the date stay in the markup (and in the
   landing's cards) but are not shown here. */
.related .card-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--related-card)), var(--related-card)));
  gap: var(--space-4);
}

.related .card {
  padding: var(--space-4);
  border-radius: var(--radius-post);
}

.related .card:hover {
  transform: none;
}

.related .card-image {
  height: var(--related-image);
  aspect-ratio: auto;
  border-radius: var(--radius-md);
}

.related .card-body {
  gap: var(--space-2);
  padding: var(--space-4) 0 0;
}

.related .card .eyebrow,
.related .card-meta {
  display: none;
}

.related .card-title {
  font-size: var(--text-h4);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.related-more {
  display: none;
}

.related .related-more {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-4);
  color: var(--purple);
  font-size: var(--text-md);
  font-weight: 650;
}

.related .related-more .icon {
  width: 18px;
  height: 18px;
}

.related .card:hover .related-more {
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (min-width: 768px) {
  .article-cta {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }
}

@media (min-width: 1024px) {
  .article-hero {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: var(--space-7);
  }

  .article-reading {
    grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
    gap: var(--space-8);
  }

  .article-contents {
    position: sticky;
    top: calc(var(--header-offset) + var(--header-height) + var(--space-5));
    align-self: start;
    max-height: calc(100vh - var(--header-height) - var(--space-8));
    overflow-y: auto;
    padding: 0;
    border: 0;
  }

  .article-contents summary {
    pointer-events: none;
  }

  .article-contents summary::before {
    content: none;
  }

  .article-contents li + li {
    margin-top: var(--space-2);
  }

  .article-contents a {
    min-height: 0;
    padding-block: var(--space-1);
  }
}

/* --- Reading progress (blog.js shows it; never with reduced motion) ------ */

.reading-meter {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  pointer-events: none;
}

.reading-meter-label {
  display: none;
}

.reading-meter progress {
  display: block;
  width: 100%;
  height: var(--space-1);
  border: 0;
  background: var(--line);
  accent-color: var(--purple);
  appearance: none;
}

.reading-meter progress::-webkit-progress-bar {
  background: var(--line);
}

.reading-meter progress::-webkit-progress-value {
  background: var(--purple);
}

.reading-meter progress::-moz-progress-bar {
  background: var(--purple);
}

@media (min-width: 768px) {
  .reading-meter {
    right: auto;
    bottom: var(--space-4);
    left: 50%;
    width: min(100% - 2 * var(--gutter), 27.5rem);
    padding: var(--space-3) var(--space-4);
    border: var(--border-hairline);
    border-radius: var(--radius-lg);
    background: var(--glass-solid);
    box-shadow: var(--shadow-panel);
    transform: translateX(-50%);
  }

  .reading-meter-label {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-2);
    color: var(--pine);
    font-size: var(--text-md);
  }

  .reading-meter progress {
    border-radius: var(--radius-pill);
  }

  .reading-meter progress::-webkit-progress-bar,
  .reading-meter progress::-webkit-progress-value {
    border-radius: var(--radius-pill);
  }

  .has-reading-meter #site-footer {
    padding-bottom: var(--space-9);
  }
}

@media (prefers-reduced-motion: reduce) {
  .reading-meter {
    display: none !important;
  }
}

html.reduce-motion .reading-meter {
  display: none !important;
}

/* --- Stronger contrast ------------------------------------------------------- */

html.high-contrast .card,
html.high-contrast .reference,
html.high-contrast .resource-map,
html.high-contrast .directory-group,
html.high-contrast .article-link a,
html.high-contrast .table-scroll,
html.high-contrast .filter-button {
  border: var(--border-strong);
}

html.high-contrast .source-card,
html.high-contrast .diagram {
  outline: var(--border-strong);
}

/* --- Print: the article only, with link targets written out ----------------- */

@media print {
  #site-header,
  #site-footer,
  .skip-link,
  .breadcrumb,
  .article-contents,
  .article-cta,
  .article-correction,
  .related,
  .rss-follow,
  .reading-meter,
  .filters,
  .notice-dialog,
  .article-start,
  .map-text-link,
  .map-card {
    display: none !important;
  }

  /* Print every directory group open. */
  .directory-group::details-content {
    content-visibility: visible;
    display: block;
  }

  .blog-main {
    width: auto;
    padding: 0;
  }

  .article-hero,
  .article-reading {
    display: block;
  }

  .article-cover {
    max-width: 60%;
    margin-top: var(--space-5);
  }

  .prose,
  .references {
    max-width: none;
  }

  .prose a[href^='http']::after,
  .reference a[href^='http']::after {
    content: ' (' attr(href) ')';
    color: var(--muted);
    font-size: var(--text-md);
    overflow-wrap: anywhere;
  }

  .table-scroll {
    overflow: visible;
    border: 0;
  }

  .prose table {
    min-width: 0;
  }

  .prose h2,
  .reference,
  .source-card,
  .diagram,
  tr {
    break-inside: avoid;
  }

  .prose h2 {
    break-after: avoid;
  }

  .card {
    break-inside: avoid;
  }
}
