main[data-page="learn"] {
  --offset: 4rem;
  --content-width: 52rem;
  --heading-padding-bottom: 0.5rem;
  --topic-font-size: 2rem;
  --topic-padding-top: 4.5rem;
  --topic-sticky-size: calc(
    var(--topic-padding-top) + var(--topic-font-size) +
      var(--heading-padding-bottom) + 1px
  );
  --detail-font-size: 1.5rem;
  --detail-padding-top: calc(var(--topic-sticky-size) + 0.75rem);
  --detail-padding-bottom: 0.375rem;
  --detail-sticky-size: calc(
    var(--detail-padding-top) + var(--detail-font-size) +
      var(--detail-padding-bottom) + 1px
  );
  --subtopic-font-size: 1rem;
  --subtopic-padding-top: calc(var(--detail-sticky-size) + 0.375rem);
  --subtopic-padding-bottom: 0.25rem;

  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  padding: 0 var(--page-x);
  scroll-padding-top: var(--offset);
  interpolate-size: allow-keywords;

  details::details-content {
    height: 0;
    overflow: clip;
    transition:
      height 1s ease,
      content-visibility 1s ease allow-discrete;
  }

  details[open]::details-content {
    height: auto;
  }

  article {
    counter-reset: theme;
    padding-block: var(--offset);

    &::before {
      content: "";
      position: sticky;
      top: 0;
      z-index: 9;
      display: block;
      height: var(--offset);
      margin-top: calc(-1 * var(--offset));
      margin-inline: auto;
      margin-bottom: calc(-1 * var(--offset));
      background: var(--black);
      pointer-events: none;
    }

    > section {
      counter-reset: topic;
      width: min(100%, var(--content-width));
      margin-inline: auto;
      scroll-margin-top: var(--offset);
    }

    > section:not([data-numbered="false"]) {
      counter-increment: theme;
    }

    > section[data-numbered="false"] {
      display: grid;
      align-content: center;
      min-height: calc(100dvh - var(--offset));

      > h1 {
        position: static;
        max-width: 10ch;
        padding: 0;
        border: 0;
        font-size: 4rem;
      }

      > p {
        max-width: 42rem;
        margin-top: 1.5rem;
        color: var(--white);
        font-size: var(--font-size-base);
        line-height: var(--line-height-base);
      }
    }

    > section + section {
      margin-top: 8rem;
    }

    > section:has(> details:not([open])) + section {
      margin-top: var(--offset);
    }

    section[id] {
      > :is(h1, h2, h3, h4),
      > details > summary > :is(h1, h2, h3, h4) {
        a {
          position: relative;
          display: inline-block;
          color: var(--white);
          text-decoration: none;

          &::before {
            position: absolute;
            top: 50%;
            right: 100%;
            translate: 0 -50%;
            opacity: 0;
            user-select: none;
            text-decoration: none;
          }

          @media (hover: hover) and (pointer: fine) {
            &:hover::before {
              opacity: 0.5;
            }

            &:hover {
              text-decoration: underline;
              text-decoration-thickness: 1px;
              text-underline-offset: 0.125em;
            }
          }

          &:active {
            color: var(--orange);
          }

          &[data-press]::before {
            opacity: 0.5;
          }

          &[data-press] {
            color: var(--white);
            text-decoration: underline;
            text-decoration-thickness: 1px;
            text-underline-offset: 0.125em;
          }
        }
      }
    }

    > section {
      > details > section {
        counter-increment: topic;
        counter-reset: detail;
        scroll-margin-top: var(--offset);

        > details > section {
          counter-increment: detail;
          counter-reset: subtopic;
          scroll-margin-top: var(--offset);

          > details > section {
            counter-increment: subtopic;
            scroll-margin-top: var(--offset);
          }
        }
      }
    }

    section[id]:not([data-numbered="false"]) {
      > details {
        > summary {
          position: relative;
          line-height: 1;
          list-style: none;
          background: var(--black);
          cursor: pointer;

          &::-webkit-details-marker {
            display: none;
          }

          &::after {
            content: "+";
            position: absolute;
            top: 50%;
            right: 0;
            translate: 0 -50%;
            color: var(--gray);
            font-family: var(--font-mono);
            font-size: var(--font-size-sm);
            pointer-events: none;
          }

          > :is(h1, h2, h3, h4) {
            line-height: 1;
          }

          &:has(> h1) {
            z-index: 8;

            > h1 {
              border-bottom: 1px solid var(--gray);
              font-size: 3rem;
            }
          }

          &:has(> h2) {
            z-index: 7;

            > h2 {
              border-bottom: 1px dashed var(--gray);
              font-size: var(--topic-font-size);
            }
          }

          &:has(> h3) {
            z-index: 6;

            > h3 {
              border-bottom: 1px dotted var(--gray);
              font-size: var(--detail-font-size);
            }
          }

          &:has(> h4) {
            z-index: 5;

            > h4 {
              border-bottom: 1px dotted var(--gray);
              font-size: var(--subtopic-font-size);
            }
          }
        }

        &[open] > summary::after {
          content: "-";
        }

        &[open] > summary {
          position: sticky;
          top: var(--offset);

          > h1 {
            padding-bottom: var(--heading-padding-bottom);
          }

          > h2 {
            padding-top: var(--topic-padding-top);
            padding-bottom: var(--heading-padding-bottom);
          }

          > h3 {
            padding-top: var(--detail-padding-top);
            padding-bottom: var(--detail-padding-bottom);
          }

          > h4 {
            padding-top: var(--subtopic-padding-top);
            padding-bottom: var(--subtopic-padding-bottom);
          }
        }
      }

      > details > p {
        margin-top: 1rem;
        color: var(--white);
        font-size: var(--font-size-sm);
        line-height: var(--line-height-sm);
      }

      > details > figure {
        margin-top: 2rem;
        color: var(--gray);
        font-size: var(--font-size-xs);
      }
    }
  }
}
