/* -------------------------------- 

File#: _2_table-of-contents
Title: Table of Contents
Descr: A navigation with a list of links to the main sections of the page 
Usage: codyhouse.co/license

-------------------------------- */
:root {
  --toc-border-width: 1px;
  /* static version only */
}

/* #region (style affecting collapsed + static versions) 👇 */
.toc {
  --space-unit: 1rem;
  /* use rem units for spacing */
}

.toc__list {
  position: relative;
}
.toc__list .toc__list .toc__link {
  padding-left: calc(var(--space-sm) * 2);
  /* offset sub nav */
}

.toc__link,
.toc__label {
  padding: var(--space-xxxs) var(--space-sm);
}

.toc__link {
  position: relative;
  color: var(--color-contrast-medium);
  text-decoration: none;
}
.toc__link::before {
  /* left mark */
  content: "";
  width: var(--toc-border-width);
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
}
.toc__link:hover {
  color: var(--color-contrast-high);
}

.toc__link--selected {
  color: var(--color-primary);
}
.toc__link--selected:hover {
  color: var(--color-primary);
}

.toc__label {
  /* label style */
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: var(--text-sm);
}

.toc__control {
  /* control button */
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toc__control-text {
  /* text inside control button */
  position: relative;
}
.toc__control-text > * {
  display: inline-block;
  transition: opacity 0.4s, -webkit-transform 0.4s var(--ease-out);
  transition: opacity 0.4s, transform 0.4s var(--ease-out);
  transition: opacity 0.4s, transform 0.4s var(--ease-out), -webkit-transform 0.4s var(--ease-out);
}
.toc__control-text > *:last-child {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  pointer-events: none;
  -webkit-transform: translateY(-10px);
          transform: translateY(-10px);
}

.toc__icon-arrow {
  /* arrow icon  */
}
.toc__icon-arrow .icon__group {
  will-change: transform;
  -webkit-transform-origin: 8px 8px;
          transform-origin: 8px 8px;
  transition: -webkit-transform 0.3s var(--ease-out);
  transition: transform 0.3s var(--ease-out);
  transition: transform 0.3s var(--ease-out), -webkit-transform 0.3s var(--ease-out);
}
.toc__icon-arrow .icon__group > * {
  -webkit-transform-origin: 8px 8px;
          transform-origin: 8px 8px;
  stroke-dasharray: 17;
  -webkit-transform: translateY(3px);
          transform: translateY(3px);
  transition: stroke-dashoffset 0.3s, -webkit-transform 0.3s;
  transition: transform 0.3s, stroke-dashoffset 0.3s;
  transition: transform 0.3s, stroke-dashoffset 0.3s, -webkit-transform 0.3s;
  transition-timing-function: var(--ease-out);
}
.toc__icon-arrow .icon__group > *:first-child {
  stroke-dashoffset: 10;
}
.toc__icon-arrow .icon__group > *:last-child {
  stroke-dashoffset: 10;
}

.toc-content__target {
  scroll-margin-top: var(--space-xxxxs);
}

/* #endregion */
/* #region (collapsed version only - mobile 👇) */
.toc:not(.toc--static) {
  border-radius: var(--radius-md);
  background-color: var(--color-bg-light);
  box-shadow: var(--inner-glow), var(--shadow-sm);
  transition: 0.3s;
}
.toc:not(.toc--static):hover {
  box-shadow: var(--inner-glow), var(--shadow-md);
}
.toc:not(.toc--static) .toc__nav {
  /* navigation */
  display: none;
  margin: var(--space-xxs) 0;
}
.toc:not(.toc--static) .toc__list {
  padding-bottom: var(--space-xs);
}
.toc:not(.toc--static) .toc__label {
  display: none;
}
.toc:not(.toc--static) .toc__link {
  display: flex;
}
.toc:not(.toc--static).toc--expanded .toc__control-text > *:first-child {
  -webkit-transform: translateY(10px);
          transform: translateY(10px);
  opacity: 0;
  pointer-events: none;
}
.toc:not(.toc--static).toc--expanded .toc__control-text > *:last-child {
  opacity: 1;
  pointer-events: auto;
  -webkit-transform: translateY(0);
          transform: translateY(0);
}
.toc:not(.toc--static).toc--expanded .toc__nav {
  display: block;
  -webkit-animation: toc-entry-animation 0.4s var(--ease-out);
          animation: toc-entry-animation 0.4s var(--ease-out);
}
.toc:not(.toc--static).toc--expanded .toc__icon-arrow .icon__group {
  /* animate arrow icon */
  -webkit-transform: rotate(-90deg);
          transform: rotate(-90deg);
}
.toc:not(.toc--static).toc--expanded .toc__icon-arrow .icon__group > *:first-child, .toc:not(.toc--static).toc--expanded .toc__icon-arrow .icon__group *:last-child {
  stroke-dashoffset: 0;
  -webkit-transform: translateY(0px);
          transform: translateY(0px);
}

/* #endregion */
/* #region (static version only - desktop 👇) */
.toc--static {
  box-shadow: inset var(--toc-border-width) 0 0 var(--color-contrast-lower);
  /* left border */
}
.toc--static[class*=position-sticky] {
  top: var(--space-md);
  /* used if position = sticky */
  max-height: calc(100vh - var(--space-md) * 2);
  /* set max height */
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.toc--static .toc__label {
  font-size: var(--text-xs);
}
.toc--static .toc__link {
  display: inline-flex;
  font-size: var(--text-sm);
}
.toc--static .toc__link--selected::before {
  background-color: var(--color-primary);
}
.toc--static .toc__control {
  /* control - static version only */
  display: none;
}

.toc-content--toc-static *:target {
  -webkit-animation: toc-target 2s;
          animation: toc-target 2s;
  /* highlight section on target */
}

/* #endregion */
@-webkit-keyframes toc-target {
  0%, 50% {
    outline: 2px solid hsla(var(--color-primary-h), var(--color-primary-s), var(--color-primary-l), 0.5);
  }
  100% {
    outline: 2px solid hsla(var(--color-primary-h), var(--color-primary-s), var(--color-primary-l), 0);
  }
}
@keyframes toc-target {
  0%, 50% {
    outline: 2px solid hsla(var(--color-primary-h), var(--color-primary-s), var(--color-primary-l), 0.5);
  }
  100% {
    outline: 2px solid hsla(var(--color-primary-h), var(--color-primary-s), var(--color-primary-l), 0);
  }
}
@-webkit-keyframes toc-entry-animation {
  from {
    opacity: 0;
    -webkit-transform: translateY(-10px);
            transform: translateY(-10px);
  }
  to {
    opacity: 1;
    -webkit-transform: translateY(0px);
            transform: translateY(0px);
  }
}
@keyframes toc-entry-animation {
  from {
    opacity: 0;
    -webkit-transform: translateY(-10px);
            transform: translateY(-10px);
  }
  to {
    opacity: 1;
    -webkit-transform: translateY(0px);
            transform: translateY(0px);
  }
}
/* used in JS - detect when the TOC needs to switch from a collapsed to a static version */
[class*=toc--static]::before {
  display: none;
  content: "collapsed";
}

@media (min-width: 32rem) {
  .toc--static\@xs::before {
    content: "static";
  }
}
@media (min-width: 48rem) {
  .toc--static\@sm::before {
    content: "static";
  }
}
@media (min-width: 64rem) {
  .toc--static\@md::before {
    content: "static";
  }
}
@media (min-width: 80rem) {
  .toc--static\@lg::before {
    content: "static";
  }
}
@media (min-width: 90rem) {
  .toc--static\@xl::before {
    content: "static";
  }
}