/* Article-only layer, enqueued for is_singular('post') alone.
   The page shell — hero, reading column, catalog band, footer — lives in
   app.css next to the rest of the site's blocks. What is left here is the
   long-form content furniture that only an article ever renders: the table of
   contents, editorial blocks coming out of the block editor, and the mobile
   treatment of the related-products grid. */

.dm-article-toc {
  padding: 24px;
  border-radius: var(--dm-radius-l);
  background: #fff;
}

.dm-article-toc h2 {
  margin: 0 0 16px;
  color: var(--dm-color-text-secondary);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dm-article-toc ol {
  display: flex;
  margin: 0;
  padding: 0;
  flex-direction: column;
  gap: 2px;
  counter-reset: dm-article-toc;
  list-style: none;
}

.dm-article-toc__item {
  counter-increment: dm-article-toc;
}

.dm-article-toc__level-3 {
  padding-left: 16px;
}

.dm-article-toc a {
  display: block;
  padding: 8px 12px;
  border-left: 2px solid transparent;
  border-radius: 0 var(--dm-radius-m) var(--dm-radius-m) 0;
  color: var(--dm-color-text-secondary);
  font-size: 14px;
  line-height: 20px;
  text-decoration: none;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.dm-article-toc a::before {
  content: counter(dm-article-toc) '. ';
  color: var(--dm-color-text-disabled);
}

.dm-article-toc a:hover {
  border-left-color: var(--dm-color-primary-light);
  background: var(--dm-color-background-body);
  color: var(--dm-color-text-primary);
}

/* Scrollspy state, written by blog-article.js. */
.dm-article-toc__item.is-active > a {
  border-left-color: var(--dm-color-primary);
  background: var(--dm-color-primary-subtle);
  color: var(--dm-color-text-primary);
  font-weight: 500;
}

.dm-article-toc__item.is-active > a::before {
  color: var(--dm-color-primary);
}

.dm-article-body blockquote,
.dm-article-body .wp-block-pullquote,
.dm-article-body .wp-block-group.is-style-alert,
.dm-article-body .wp-block-group.is-style-note,
.dm-article-body .wp-block-group.is-style-warning {
  position: relative;
  margin-right: 0;
  margin-left: 0;
  padding: 24px 28px 24px 56px;
  border: 0;
  border-radius: var(--dm-radius-l);
  background: #f4f6f9;
  color: var(--dm-color-text-primary);
}

.dm-article-body blockquote::before,
.dm-article-body .wp-block-pullquote::before {
  position: absolute;
  top: 22px;
  left: 24px;
  color: var(--dm-color-primary);
  content: '“';
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
}

.dm-article-body blockquote cite,
.dm-article-body .wp-block-pullquote cite {
  display: block;
  margin-top: 12px;
  color: var(--dm-color-text-secondary);
  font-size: 14px;
  font-style: normal;
  line-height: 20px;
}

.dm-article-body pre,
.dm-article-body .wp-block-code {
  max-width: 100%;
  overflow-x: auto;
  padding: 24px;
  border: 0;
  border-radius: var(--dm-radius-l);
  background: #202127;
  color: #f7f8fb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 22px;
  tab-size: 2;
  white-space: pre;
}

.dm-article-body :not(pre) > code {
  padding: 2px 6px;
  border-radius: 5px;
  background: #edf1f6;
  color: #1e3f68;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

/* Mathematical expressions are editorial content, not source code. */
.dm-article-body .dm-formula {
  margin: 28px 0;
  overflow-x: auto;
  padding: 24px 28px;
  border: 1px solid var(--dm-color-border-primary);
  border-left: 4px solid var(--dm-color-primary);
  border-radius: var(--dm-radius-l);
  background: #f7f9fc;
  color: var(--dm-color-text-primary);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(20px, 2.4vw, 28px);
  line-height: 1.45;
  text-align: center;
  white-space: nowrap;
}

.dm-article-body .dm-formula__fraction {
  display: inline-flex;
  min-width: 180px;
  margin: 0 0.2em;
  vertical-align: middle;
  flex-direction: column;
}

.dm-article-body .dm-formula__numerator {
  padding: 0 0.35em 0.12em;
  border-bottom: 1px solid currentColor;
}

.dm-article-body .dm-formula__denominator {
  padding: 0.12em 0.35em 0;
}

.dm-article-body .dm-formula-note {
  margin-top: -16px;
  color: var(--dm-color-text-secondary);
  font-size: 14px;
  line-height: 21px;
  text-align: center;
}

/* Wide tables scroll inside the reading column instead of stretching it. */
.dm-article-body table,
.dm-article-body .wp-block-table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dm-article-body .wp-block-separator {
  border: 0;
  border-top: 1px solid var(--dm-color-border-primary);
}

.dm-article-body .wp-block-image,
.dm-article-body .wp-block-gallery,
.dm-article-body .wp-block-video,
.dm-article-body .wp-block-embed {
  margin-top: 32px;
  margin-bottom: 32px;
}

.dm-article-body figcaption {
  color: var(--dm-color-text-secondary);
  font-size: 14px;
  line-height: 20px;
  text-align: left;
}

@media (max-width: 767px) {
  .dm-article-toc {
    padding: 20px 16px;
  }

  .dm-article-toc h2 {
    margin-bottom: 12px;
  }

  .dm-article-toc a {
    font-size: 13px;
    line-height: 19px;
  }

  .dm-article-body blockquote,
  .dm-article-body .wp-block-pullquote,
  .dm-article-body .wp-block-group.is-style-alert,
  .dm-article-body .wp-block-group.is-style-note,
  .dm-article-body .wp-block-group.is-style-warning {
    padding: 20px 16px 20px 44px;
  }

  .dm-article-body blockquote::before,
  .dm-article-body .wp-block-pullquote::before {
    top: 18px;
    left: 16px;
  }

  .dm-article-body pre,
  .dm-article-body .wp-block-code {
    margin-right: -8px;
    margin-left: -8px;
    padding: 18px;
    border-radius: var(--dm-radius-s);
    font-size: 12px;
    line-height: 19px;
  }

  .dm-article-body .dm-formula {
    margin-right: -8px;
    margin-left: -8px;
    padding: 20px 16px;
    font-size: 18px;
    text-align: left;
  }

  /* One product per row would push the rest of the page a long way down, so
     the catalog band turns into a swipeable rail on phones. */
  .dm-article-products {
    overflow: hidden;
  }

  .dm-article-products__heading p {
    display: none;
  }

  .dm-article-products__grid {
    display: flex;
    width: calc(100% + 16px);
    overflow-x: auto;
    padding-right: 16px;
    gap: 12px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .dm-article-products__grid::-webkit-scrollbar {
    display: none;
  }

  .dm-article-products .dm-product-card {
    width: 190px;
    min-height: 0;
    flex: 0 0 190px;
    scroll-snap-align: start;
  }

  .dm-article-products .dm-product-card__body {
    min-height: 118px;
    padding: 12px 12px 16px;
  }

  .dm-article-products .dm-product-card h3,
  .dm-article-products .dm-product-card__body > a,
  .dm-article-products .dm-product-card__price {
    font-size: 13px;
    line-height: 19px;
  }
}
