/*
 * ebms.app blog — the stylesheet for the rendered body (EC_BLOG_POST.BODY_HTML,
 * services/blog_html.py). A storefront links it once and sets its own look with
 * the custom properties below, on .ebms-blog or anything around it (:root too):
 *
 *   .ebms-blog { --ebms-blog-accent: #8b1a2a; --ebms-blog-ink: #1c1f24; }
 *
 * The defaults sit on :root at no specificity, so a site's value wins wherever
 * it is set and in whichever order the stylesheets load.
 *
 * Everything is scoped under .ebms-blog, so the page around it is untouched;
 * the type face is the page's own. Breakpoints: md 48rem, lg 64rem.
 */

:where(:root) {
  --ebms-blog-text: #514c4a; /* body copy */
  --ebms-blog-ink: #1c1f24; /* headings, strong words, questions */
  --ebms-blog-subtle: #9a9390; /* captions, labels */
  --ebms-blog-line: #e6e2dd; /* rules and frames */
  --ebms-blog-accent: #8b1a2a; /* links, markers, buttons */
  --ebms-blog-accent-hover: #6d1420;
  --ebms-blog-on-accent: #ffffff; /* text on a button */
  --ebms-blog-card: #ffffff; /* card and download backgrounds */
  --ebms-blog-soft: #f4f1ee; /* code, placeholders */
  --ebms-blog-radius: 0.75rem;
}

.ebms-blog {
  display: flex;
  flex-direction: column;
  color: var(--ebms-blog-text);
  font-size: 1rem;
  line-height: 1.7;
  overflow-wrap: break-word;
}

.ebms-blog :where(h2, h3, h4, h5, h6, p, ul, ol, figure, blockquote, hr) {
  margin: 0;
}

.ebms-blog :where(img) {
  display: block;
  max-width: 100%;
}

.ebms-blog-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* ── The column of blocks ─────────────────────────────────────────────── */

/* A loose block at the top gets half a gap above and below; the bands (a
   top-level grid, the call to action) carry their own rules and padding. */
.ebms-blog > :not(.ebms-blog-band) {
  margin-block: 0.875rem;
}

.ebms-blog-cell {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1.75rem;
}

/* ── Layouts ──────────────────────────────────────────────────────────── */

.ebms-blog-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

.ebms-blog-band {
  gap: 1.75rem;
  padding-block: 2.25rem;
  border-top: 1px solid var(--ebms-blog-line);
}

.ebms-blog-band:last-child {
  border-bottom: 1px solid var(--ebms-blog-line);
}

.ebms-blog-flex {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 48rem) {
  .ebms-blog-grid {
    grid-template-columns: var(--cols);
  }

  .ebms-blog-grid > .ebms-blog-cell {
    grid-column: span var(--span, 1);
    grid-row: span var(--rows, 1);
  }

  .ebms-blog-band {
    gap: 4rem;
    padding-block: 3.5rem;
  }

  .ebms-blog-flex--row {
    flex-direction: row;
  }

  .ebms-blog-flex--row > .ebms-blog-cell {
    flex: 1 1 0;
  }
}

/* ── Text ─────────────────────────────────────────────────────────────── */

.ebms-blog-heading {
  color: var(--ebms-blog-ink);
  font-weight: 700;
}

.ebms-blog-h1,
.ebms-blog-h2 {
  font-size: clamp(1.375rem, 2.4vw, 1.875rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.ebms-blog-h3 {
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.ebms-blog-h4,
.ebms-blog-h5,
.ebms-blog-h6 {
  font-size: 0.875rem;
}

.ebms-blog-text,
.ebms-blog-quote p,
.ebms-blog-accordion-answer,
.ebms-blog-stack p,
.ebms-blog-cta p,
.ebms-blog-card-body p {
  white-space: pre-line;
}

.ebms-blog a:where(:not([class])),
.ebms-blog-richtext a {
  color: var(--ebms-blog-accent);
  text-decoration: underline;
  transition: color 150ms;
}

.ebms-blog a:where(:not([class])):hover,
.ebms-blog-richtext a:hover {
  color: var(--ebms-blog-accent-hover);
}

/* Bold in a paragraph, a list or an answer reads as it does in rich text. */
.ebms-blog :where(.ebms-blog-text, .ebms-blog-list, .ebms-blog-accordion-answer) :where(b, strong) {
  color: var(--ebms-blog-ink);
  font-weight: 600;
}

.ebms-blog-link {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 0.25rem;
  color: var(--ebms-blog-accent);
  font-weight: 600;
  text-decoration: none;
  transition: color 150ms;
}

.ebms-blog-link:hover {
  color: var(--ebms-blog-accent-hover);
}

.ebms-blog-quote {
  padding-left: 1.25rem;
  border-left: 2px solid var(--ebms-blog-accent);
}

.ebms-blog-quote p {
  color: var(--ebms-blog-ink);
  font-size: 1.125rem;
  line-height: 1.6;
}

.ebms-blog-quote footer {
  margin-top: 0.5rem;
  color: var(--ebms-blog-subtle);
  font-size: 0.875rem;
}

.ebms-blog-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-left: 1.25rem;
}

ul.ebms-blog-list {
  list-style: disc;
}

ol.ebms-blog-list {
  list-style: decimal;
}

.ebms-blog-list li::marker {
  color: var(--ebms-blog-accent);
}

.ebms-blog-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0;
  list-style: none;
  line-height: 1.6;
}

.ebms-blog-checklist li {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
}

.ebms-blog-checklist .ebms-blog-icon {
  margin-top: 0.25rem;
  color: var(--ebms-blog-accent);
}

/* Rich text: the sanitised HTML's own elements. */
.ebms-blog-richtext {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ebms-blog-richtext :where(b, strong) {
  color: var(--ebms-blog-ink);
  font-weight: 600;
}

.ebms-blog-richtext h2 {
  color: var(--ebms-blog-ink);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
}

.ebms-blog-richtext :where(h3, h4) {
  color: var(--ebms-blog-ink);
  font-weight: 700;
}

.ebms-blog-richtext h3 {
  font-size: 1rem;
}

.ebms-blog-richtext h4 {
  font-size: 0.875rem;
}

.ebms-blog-richtext :where(ul, ol) {
  padding-left: 1.25rem;
}

.ebms-blog-richtext ul {
  list-style: disc;
}

.ebms-blog-richtext ol {
  list-style: decimal;
}

.ebms-blog-richtext li {
  margin-top: 0.25rem;
}

.ebms-blog-richtext li::marker {
  color: var(--ebms-blog-accent);
}

.ebms-blog-richtext blockquote {
  padding-left: 1.25rem;
  border-left: 2px solid var(--ebms-blog-accent);
  color: var(--ebms-blog-ink);
}

.ebms-blog-richtext hr,
.ebms-blog-divider {
  height: 0;
  border: 0;
  border-top: 1px solid var(--ebms-blog-line);
}

.ebms-blog-richtext img {
  height: auto;
  border-radius: var(--ebms-blog-radius);
}

.ebms-blog-richtext table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.ebms-blog-richtext :where(th, td) {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--ebms-blog-line);
  text-align: left;
}

.ebms-blog-richtext th {
  color: var(--ebms-blog-ink);
  font-weight: 600;
}

.ebms-blog-richtext code {
  padding-inline: 0.25rem;
  border-radius: 0.25rem;
  background: var(--ebms-blog-soft);
  font-size: 0.875rem;
}

.ebms-blog-richtext pre {
  overflow-x: auto;
  padding: 1rem;
  border-radius: 0.5rem;
  background: var(--ebms-blog-soft);
}

/* ── Photos, files, video ─────────────────────────────────────────────── */

.ebms-blog-figure,
.ebms-blog-video {
  min-width: 0;
}

.ebms-blog figcaption {
  margin-top: 0.5rem;
  padding-left: 0.125rem;
  color: var(--ebms-blog-subtle);
  font-size: 0.75rem;
  line-height: 1.5;
}

.ebms-blog-photo {
  overflow: hidden;
  border-radius: var(--ebms-blog-radius);
  background: var(--ebms-blog-soft);
}

.ebms-blog-photo img {
  width: 100%;
  height: auto;
}

/* Equal 16:9 tiles, the edges cut; `whole` keeps each photo's proportions. */
.ebms-blog-photo--crop {
  aspect-ratio: 16 / 9;
}

.ebms-blog-photo--crop img {
  height: 100%;
  object-fit: cover;
}

.ebms-blog-gallery {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

@media (min-width: 48rem) {
  .ebms-blog-gallery--2,
  .ebms-blog-gallery--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ebms-blog-gallery--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 64rem) {
  .ebms-blog-gallery--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.ebms-blog-downloads {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.ebms-blog-download {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--ebms-blog-line);
  border-radius: var(--ebms-blog-radius);
  background: var(--ebms-blog-card);
  color: inherit;
  text-decoration: none;
  transition: border-color 150ms;
}

.ebms-blog-download:hover {
  border-color: var(--ebms-blog-accent);
}

.ebms-blog-download .ebms-blog-icon {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--ebms-blog-accent);
}

.ebms-blog-download-name {
  overflow: hidden;
  min-width: 0;
  flex: 1;
  color: var(--ebms-blog-ink);
  font-size: 0.875rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ebms-blog-download-type {
  color: var(--ebms-blog-subtle);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
}

.ebms-blog-video-frame {
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: var(--ebms-blog-radius);
  background: var(--ebms-blog-ink);
}

.ebms-blog-video-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ── Cards ────────────────────────────────────────────────────────────── */

.ebms-blog-card {
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
}

.ebms-blog-card:not(.ebms-blog-card--framed) {
  overflow: hidden;
  border: 1.5px solid var(--ebms-blog-line);
  border-radius: var(--ebms-blog-radius);
  background: var(--ebms-blog-card);
}

.ebms-blog-card--link {
  transition:
    transform 180ms,
    box-shadow 180ms;
}

.ebms-blog-card--link:hover {
  transform: translateY(-0.125rem);
  box-shadow: 0 8px 32px rgb(0 0 0 / 0.09);
}

.ebms-blog-card-image {
  overflow: hidden;
  flex-shrink: 0;
  background: var(--ebms-blog-soft);
}

.ebms-blog-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* On a tint the photo is contained: cut-outs and icons sit on the colour. */
.ebms-blog-card-image--tinted img {
  padding: 0.75rem;
  object-fit: contain;
}

.ebms-blog-card-body {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.5rem;
}

.ebms-blog-card-body h3 {
  color: var(--ebms-blog-ink);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.5;
}

.ebms-blog-card-body p {
  font-size: 0.875rem;
  line-height: 1.65;
}

/* media: the photo full-bleed on top · icon: ~48px at the top left · row: a
   small round photo beside the text · framed: the photo in a rounded frame,
   no card box around it. */
.ebms-blog-card--media .ebms-blog-card-image,
.ebms-blog-card--framed .ebms-blog-card-image {
  aspect-ratio: 4 / 3;
}

.ebms-blog-card--media .ebms-blog-card-body {
  padding: 1.25rem;
}

.ebms-blog-card--icon,
.ebms-blog-card--framed {
  gap: 0.75rem;
}

.ebms-blog-card--icon,
.ebms-blog-card--row {
  padding: 1.25rem;
}

.ebms-blog-card--icon .ebms-blog-card-image {
  width: 3rem;
  height: 3rem;
  border-radius: 0.5rem;
}

.ebms-blog-card--row {
  flex-direction: row;
  align-items: flex-start;
  gap: 1rem;
}

.ebms-blog-card--row .ebms-blog-card-image {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 9999px;
}

.ebms-blog-card--framed .ebms-blog-card-image {
  border-radius: var(--ebms-blog-radius);
}

.ebms-blog-card-link {
  align-self: flex-start;
  color: var(--ebms-blog-accent);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: color 150ms;
}

.ebms-blog-card-link:hover {
  color: var(--ebms-blog-accent-hover);
}

.ebms-blog-button {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  background: var(--ebms-blog-accent);
  color: var(--ebms-blog-on-accent);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.5;
  text-decoration: none;
  transition: background-color 150ms;
}

.ebms-blog-button:hover,
.ebms-blog-card--link:hover .ebms-blog-button {
  background: var(--ebms-blog-accent-hover);
}

.ebms-blog-button .ebms-blog-icon {
  transition: transform 150ms;
}

.ebms-blog-button:hover .ebms-blog-icon {
  transform: translateX(0.25rem);
}

/* The first editor's stacked cards: chip, heading, paragraph. */
.ebms-blog-stack {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.ebms-blog-stack-item {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.ebms-blog-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.25rem;
  color: var(--ebms-blog-accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ebms-blog-chip::before {
  content: '';
  width: 1rem;
  height: 0.125rem;
  border-radius: 9999px;
  background: currentColor;
}

.ebms-blog-stack h3 {
  margin-bottom: 0.5rem;
  color: var(--ebms-blog-ink);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ── Call to action: label left, paragraph and button right ───────────── */

.ebms-blog-cta {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ebms-blog-cta.ebms-blog-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.ebms-blog-cta > div:last-child {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.ebms-blog-cta-label {
  color: var(--ebms-blog-subtle);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ebms-blog-cta.ebms-blog-band > div:first-child {
  padding-top: 0.25rem;
}

@media (min-width: 48rem) {
  .ebms-blog-cta.ebms-blog-band {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  }
}

/* ── Divider, spacer, accordion ───────────────────────────────────────── */

/* Empty space on top of the gap between blocks: 8 / 16 / 32 / 48 px on a
   phone, twice that from md up. */
.ebms-blog-spacer {
  flex-shrink: 0;
}

.ebms-blog-spacer--s {
  height: 0.5rem;
}

.ebms-blog-spacer--m {
  height: 1rem;
}

.ebms-blog-spacer--l {
  height: 2rem;
}

.ebms-blog-spacer--xl {
  height: 3rem;
}

@media (min-width: 48rem) {
  .ebms-blog-spacer--s {
    height: 1rem;
  }

  .ebms-blog-spacer--m {
    height: 2rem;
  }

  .ebms-blog-spacer--l {
    height: 4rem;
  }

  .ebms-blog-spacer--xl {
    height: 6rem;
  }
}

.ebms-blog-accordion {
  border-block: 1px solid var(--ebms-blog-line);
}

.ebms-blog-accordion-item + .ebms-blog-accordion-item {
  border-top: 1px solid var(--ebms-blog-line);
}

.ebms-blog-accordion-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1rem;
  color: var(--ebms-blog-ink);
  cursor: pointer;
  font-weight: 600;
  line-height: 1.5;
  list-style: none;
  transition: color 150ms;
}

.ebms-blog-accordion-item summary::-webkit-details-marker {
  display: none;
}

.ebms-blog-accordion-item summary:hover {
  color: var(--ebms-blog-accent);
}

.ebms-blog-accordion-item summary .ebms-blog-icon {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--ebms-blog-accent);
  transition: transform 200ms;
}

.ebms-blog-accordion-item[open] summary .ebms-blog-icon {
  transform: rotate(180deg);
}

.ebms-blog-accordion-answer {
  padding: 0 2.25rem 1.25rem 0;
}

/* A retired block a storefront may fill with its own product cards. */
.ebms-blog-products:empty {
  display: none;
}
