:root {
  --blog-toc-offset: 12rem;
}

.blog-article {
  box-sizing: border-box;
  width: min(1360px, calc(100% - 32px));
  margin-inline: auto;
}

.blog-article:not(.blog-article--has-toc) {
  max-width: 1028px;
}

.blog-article > .blog-head {
  margin-bottom: 4rem;
}

.blog-article > .blog-head__img {
  margin-bottom: 32px;
}

.blog-article > .blog__text,
.blog-article > .blog-head,
.blog-article > .blog-after,
.blog-article > .blog-head__img {
  min-width: 0;
}

.blog__text h2[id],
.blog__text h3[id] {
  scroll-margin-top: var(--blog-toc-offset);
}

.blog-toc {
  min-width: 0;
}

.blog-toc__details {
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(20, 20, 20, 0.06);
  color: #141414;
}

.blog-toc__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.blog-toc__summary::-webkit-details-marker {
  display: none;
}

.blog-toc__summary .blog-toc__chevron {
  flex: none;
  transition: transform 0.15s ease;
}

.blog-toc__details[open] > .blog-toc__summary .blog-toc__chevron {
  transform: rotate(180deg);
}

.blog-toc__nav {
  padding: 0 8px 12px;
}

.blog-toc__list,
.blog-toc__sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.blog-toc__sub {
  padding-left: 22px;
}

.blog-toc__row {
  display: flex;
  align-items: flex-start;
  gap: 2px;
}

.blog-toc__link {
  display: block;
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 8px;
  color: #141414;
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.blog-toc__sub .blog-toc__link {
  font-weight: 400;
}

.blog-toc__link:hover {
  background: #f6f6f6;
}

.blog-toc__link[aria-current="location"] {
  background: #fdb602;
}

.blog-toc__link[aria-current="location"]:hover {
  background: #fdb602;
}

.blog-toc__subtoggle {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-top: 4px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #141414;
  cursor: pointer;
}

.blog-toc__subtoggle:hover {
  background: #f6f6f6;
}

.blog-toc__subtoggle .blog-toc__chevron {
  width: 16px;
  height: 16px;
  transition: transform 0.15s ease;
}

.blog-toc__item.is-collapsed > .blog-toc__sub {
  display: none;
}

.blog-toc__item.is-collapsed > .blog-toc__row .blog-toc__subtoggle .blog-toc__chevron {
  transform: rotate(-90deg);
}

.blog-toc__link:focus-visible,
.blog-toc__subtoggle:focus-visible,
.blog-toc__summary:focus-visible {
  outline: 2px solid #141414;
  outline-offset: 2px;
}

@media (max-width: 1099px) {
  .blog-article--has-toc {
    display: flex;
    flex-direction: column;
  }

  .blog-article--has-toc > .blog-head {
    order: 1;
  }

  .blog-article--has-toc > .blog-head__img {
    order: 2;
    margin-bottom: 16px;
  }

  .blog-article--has-toc > .blog-toc {
    order: 3;
    margin-bottom: 8px;
  }

  .blog-article--has-toc > .blog__text {
    order: 4;
  }

  .blog-article--has-toc > .blog-after {
    order: 5;
  }

  .blog-toc__sticky {
    position: static;
  }

  .blog-toc__nav {
    max-height: 60vh;
    overflow: auto;
  }
}

@media (min-width: 1100px) {
  .blog-article--has-toc {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    column-gap: 40px;
    align-items: start;
  }

  .blog-article--has-toc > .blog-head {
    grid-column: 1;
    grid-row: 1;
  }

  .blog-article--has-toc > .blog-head__img {
    grid-column: 1;
    grid-row: 2;
  }

  .blog-article--has-toc > .blog-toc {
    grid-column: 2;
    grid-row: 2 / span 2;
    align-self: stretch;
  }

  .blog-article--has-toc > .blog__text {
    grid-column: 1;
    grid-row: 3;
  }

  .blog-article--has-toc > .blog-after {
    grid-column: 1;
    grid-row: 4;
  }

  .blog-article--has-toc .blog-after .blog__container {
    max-width: none;
    width: 100%;
  }

  .blog-toc__sticky {
    position: sticky;
    top: var(--blog-toc-offset);
    z-index: 3;
  }

  .blog-toc__summary {
    display: block;
    padding: 20px 16px 8px;
    cursor: default;
    pointer-events: none;
    font-size: 18px;
  }

  .blog-toc__summary .blog-toc__chevron {
    display: none;
  }

  .blog-toc__details > .blog-toc__nav {
    display: block !important;
    max-height: calc(100vh - var(--blog-toc-offset) - 72px);
    overflow: auto;
    padding: 4px 8px 16px;
    scrollbar-width: thin;
  }
}

@media (max-width: 600px) {
  .blog {
    padding-inline: 16px;
  }

  .blog > .blog-article {
    width: auto;
    margin-inline: 0;
  }

  .blog-article > .blog-head {
    margin-bottom: 1.6rem;
  }
}
