/* Article and catalog templates. */

/* Article template: breadcrumbs, chapter list beside the text, meta row, related articles. */
.template-article main,
.template-catalog main {
  max-width: var(--wrap);
}
/* Articles and lessons: a smaller h1 on wide screens than the site default (50 px); phones keep theirs. */
.template-article h1:not(:where(#app *)) {
  font-size: clamp(2.125rem, 1.4rem + 3.4vw, 2.5rem);
}

.breadcrumbs {
  margin: 0 0 24px;
  font-size: 0.9375rem;
}
.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.breadcrumbs li {
  display: inline-flex;
  align-items: center;
  font-size: inherit;
}
.breadcrumbs li + li::before {
  content: '';
  width: 6px;
  height: 6px;
  margin: 0 12px;
  border-top: 1.5px solid var(--muted);
  border-right: 1.5px solid var(--muted);
  transform: rotate(45deg);
}
.breadcrumbs a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
}
.breadcrumbs [aria-current] {
  color: var(--muted);
}

.article-layout {
  display: grid;
  gap: 24px 48px;
  align-items: start;
}
.article-main {
  min-width: 0;
  max-width: 820px;
}
.article-aside {
  min-width: 0;
}
.article-toc__title {
  display: none;
  margin: 0 0 8px;
  font-weight: 700;
  color: var(--ink);
}
.article-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
}
.article-toc a {
  display: block;
  padding: 10px 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.35;
  text-decoration: none;
}
/* The chapter being read (site.js). */
.article-toc a[aria-current] {
  color: var(--accent-ink);
  font-weight: 600;
}
.article-toc a:hover,
.article-toc a:focus-visible {
  color: var(--accent-ink);
  text-decoration: underline;
}
.article-toc summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}
.article-toc summary::after {
  content: '';
  flex: none;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}
.article-toc details[open] summary::after {
  transform: rotate(-135deg);
}
.article-toc summary:focus-visible {
  outline: 3px solid var(--accent-ink);
  outline-offset: 2px;
}

@media (min-width: 960px) {
  .article-layout:not(.article-layout--single) {
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  }
  .article-aside {
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
  }
  .article-layout--single .article-main {
    margin-inline: auto;
  }
}

/* Narrow screens: a one-line bar under the breadcrumbs that stays at the top while reading;
   the chapters open as a panel under it, so the title and the text come first. */
@media (max-width: 959px) {
  .article-aside {
    position: sticky;
    top: 0;
    z-index: 30;
    margin: 0 calc(var(--gutter) * -1);
    padding: 8px var(--gutter);
    background: var(--surface);
  }
  .article-toc {
    position: relative;
  }
  .article-toc details[open] ol {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: min(60vh, 28rem);
    overflow-y: auto;
    padding: 8px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .article-toc li + li a {
    border-top: 1px solid #eeeeee;
  }
}

/* Wide screens: the chapter list is always open beside the text. */
@media (min-width: 960px) {
  .js .article-toc__title {
    display: block;
  }
  .js .article-toc summary {
    display: none;
  }
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 32px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
}
.article {
  margin-top: 0;
}
.article h2[id],
.article h3[id] {
  scroll-margin-top: 24px;
}
.article p {
  margin: 0 0 1em;
}
.article ul,
.article ol {
  margin: 0 0 1.25em;
  padding-left: 1.5em;
}
.article ul {
  list-style: disc;
}
.article ol {
  list-style: decimal;
}
.article li {
  margin-bottom: 0.4em;
}
/* Text inside a chapter reads as one block: short gaps between paragraphs and list items; the big gap is kept for
   chapter headings (below). No panels, so the only highlighted block in the text is the tip. */
.article > p {
  margin-bottom: 0.7em;
}
.article > ul,
.article > ol {
  margin: 0 0 0.9em;
}
.article > ul > li,
.article > ol > li {
  margin-bottom: 0.25em;
}
.article > ul > li:last-child,
.article > ol > li:last-child {
  margin-bottom: 0;
}
.article li > p {
  margin: 0 0 0.35em;
}
.article li > p:last-child {
  margin-bottom: 0;
}
.article li :where(ul, ol) {
  margin: 0.35em 0 0;
}
/* Chapters: a thin rule and more air above every chapter heading, so the sections are visible at a glance. */
.article > h2 {
  margin-top: 2.25em;
  padding-top: 0.9em;
  border-top: 1px solid #e6e6e6;
}
.article figure {
  margin: 1.5em 0;
}
.article figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9375rem;
}
.article img {
  max-width: 100%;
  height: auto;
}
.article table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}
.article th,
.article td {
  padding: 8px 12px;
  border: 1px solid var(--line);
  text-align: left;
}

.article-related {
  margin-top: 64px;
}
.article-related__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.article-related__head h2 {
  margin: 0;
}
.carousel-controls {
  display: flex;
  gap: 8px;
}
.carousel-controls[hidden] {
  display: none;
}
html .carousel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
html .carousel-btn:hover:not(:disabled) {
  border-color: var(--accent-ink);
  color: var(--accent-ink);
}
.carousel-btn:focus-visible {
  outline: 3px solid var(--accent-ink);
  outline-offset: 2px;
}
.carousel-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.article-related__track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 72px) / 4);
  gap: 24px;
  margin: 24px 0 0;
  padding: 0 0 8px;
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
}
.article-related__track > li {
  scroll-snap-align: start;
}
.js .article-related__track {
  scrollbar-width: none;
}
.js .article-related__track::-webkit-scrollbar {
  display: none;
}
@media (max-width: 1099px) {
  .article-related__track {
    grid-auto-columns: calc((100% - 24px) / 2);
  }
}
@media (max-width: 599px) {
  .article-related__track {
    grid-auto-columns: 82%;
  }
}

/* Catalog: list of child pages with paging */
.catalog {
  list-style: none;
  margin: 1.5rem 0;
  padding: 0;
  display: grid;
  gap: 32px 24px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
}
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
  margin: 2rem 0;
}
.pagination a,
.pagination span {
  padding: .4rem .75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  text-decoration: none;
}
.pagination [aria-current] {
  font-weight: 700;
  background: #f2f2f2;
}

/* A light tip inside the text of a long article: one or two sentences that tie the paragraph above to a tool, and a
   small trial button. Markup: <div class="article-tip" role="note"><p>…</p><div class="trial-slot"><a class="button
   button--trial article-tip__button free-trial…" href="#free-trial…">…</a></div></div>. */
.article-tip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  margin: 28px 0;
  padding: 16px 20px;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-soft);
}
.article-tip p {
  flex: 1 1 320px;
  min-width: 0;
  margin: 0;
}
.article-tip .trial-slot {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}
/* On a phone the button takes the full width under the text, and a long label wraps instead of widening the page. */
@media (max-width: 639px) {
  .article-tip .trial-slot,
  .article-tip .article-tip__button {
    width: 100%;
  }
}
.article-tip .article-tip__button {
  min-height: 44px;
  padding: 8px 20px;
  font-size: 1rem;
  color: var(--accent-ink);
  background: #ffffff;
  border: 1.5px solid var(--accent-ink);
  box-shadow: none;
  white-space: normal;
  text-align: center;
}
.article-tip .article-tip__button:hover {
  color: #ffffff;
  background: var(--accent-ink);
}

/* Call to action before the related articles */
.article-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 32px;
  margin-top: 56px;
  padding: 28px 32px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #1a0b2b 0%, #13284f 100%);
  color: #ffffff;
}
/* Text on the left, the button on the right; on narrow screens the button goes under the text, full width. */
.article-cta__text {
  flex: 1 1 420px;
  min-width: 0;
}
.article-cta .trial-slot {
  flex: none;
}
@media (max-width: 639px) {
  .article-cta .trial-slot,
  .article-cta .trial-slot .button {
    width: 100%;
  }
}
.article-cta h2 {
  margin: 0 0 8px;
  color: #ffffff;
  font-size: clamp(1.375rem, 1.1rem + 1.2vw, 2rem);
}
.article-cta p {
  margin: 0;
  color: #e6e6ef;
  font-size: 1rem;
}

/* Links inside a sentence stay inline (WCAG 2.5.8 inline exception); a 44 px box would open gaps between lines. */
.article p a,
.article li a,
.article figcaption a {
  display: inline;
  min-height: 0;
  min-width: 0;
}

/* Chapters land below the sticky bar on narrow screens. */
@media (max-width: 959px) {
  .article h2[id],
  .article h3[id] {
    scroll-margin-top: 88px;
  }
}

/* Tap-to-expand pictures (narrow screens; site.js wraps them in a button) */
html .img-zoom {
  position: relative;
  display: block;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}
.img-zoom img {
  display: block;
  width: 100%;
  height: auto;
}
.img-zoom::after {
  content: '';
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(25, 11, 40, 0.8) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7'/%3E%3C/svg%3E") center / 20px no-repeat;
  pointer-events: none;
}
.img-zoom:focus-visible {
  outline: 3px solid var(--accent-ink);
  outline-offset: 2px;
}

html .lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(10, 4, 18, 0.98);
  color: #ffffff;
}
.lightbox::backdrop {
  background: rgba(10, 4, 18, 0.98);
}
.lightbox__scroll {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: auto;
  touch-action: pan-x pan-y pinch-zoom;
}
.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 0;
  cursor: zoom-in;
}
.lightbox.is-full .lightbox__scroll {
  display: block;
}
.lightbox.is-full .lightbox__img {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}
html .lightbox__close {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--ink);
  color: #ffffff;
  cursor: pointer;
}
.lightbox__close:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
html:has(dialog.lightbox[open]) {
  overflow: hidden;
}
