/* =========================================================
   INNEHÅLLSFÖRTECKNING – JÖNKÖPING
   Modern, responsiv och tillgänglig
   ========================================================= */


/* =========================================================
   YTTRE PLACERING
   ========================================================= */

#jk-innehallsforteckning {
  width: 100%;
  margin: 2rem 0 2.5rem;
}


/* =========================================================
   HELA KOMPONENTEN
   ========================================================= */

.jk-toc {
  width: 100%;
  box-sizing: border-box;

  overflow: hidden;

  border: 1px solid #d8d2c8;
  border-radius: 14px;

  background: #ffffff;
}


/* =========================================================
   UTFÄLLBAR RUBRIK
   ========================================================= */

.jk-toc__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 1rem;

  min-height: 54px;

  box-sizing: border-box;

  padding: 0.95rem 1.1rem;

  background: #EDEAE4;

  color: #202020;

  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;

  cursor: pointer;

  list-style: none;

  transition:
    background-color 0.18s ease;
}


/* Ta bort webbläsarens standardpil */

.jk-toc__summary::-webkit-details-marker {
  display: none;
}

.jk-toc__summary::marker {
  content: "";
}


/* Hover */

.jk-toc__summary:hover {
  background: #e5e1da;
}


/* Tangentbordsfokus */

.jk-toc__summary:focus-visible {
  outline: 3px solid #202020;
  outline-offset: -3px;
}


/* =========================================================
   RUBRIKTEXT
   ========================================================= */

.jk-toc__title {
  display: block;
}


/* =========================================================
   PIL I RUBRIKEN
   ========================================================= */

.jk-toc__icon {
  width: 0.5rem;
  height: 0.5rem;

  flex: 0 0 auto;

  margin-right: 0.15rem;

  border-top: 2px solid #006eb7;
  border-left: 2px solid #006eb7;

  transform: rotate(225deg);

  transition:
    transform 0.2s ease;
}


/* Öppen */

.jk-toc[open] .jk-toc__icon {
  transform: rotate(45deg);
}


/* =========================================================
   NAVIGATION
   ========================================================= */

.jk-toc__nav {
  padding:
    0.35rem
    1.25rem
    0.65rem;

  background: #ffffff;
}


/* =========================================================
   LISTA
   ========================================================= */

.jk-toc__list {
  margin: 0;
  padding: 0;

  list-style: none;
}


/* =========================================================
   LISTRAD
   ========================================================= */

.jk-toc__item {
  position: relative;

  margin: 0;
  padding: 0;

  border-bottom:
    1px solid #e3dfd8;
}


/* Ingen linje efter sista raden */

.jk-toc__item:last-child {
  border-bottom: 0;
}


/* =========================================================
   LÄNK
   ========================================================= */

.jk-toc__link {
  position: relative;

  display: grid;

  grid-template-columns:
    2rem
    minmax(0, 1fr);

  align-items: center;

  column-gap: 0.4rem;

  box-sizing: border-box;

  min-height: 54px;

  padding:
    0.9rem
    2.6rem
    0.9rem
    0.9rem;

  color: #005ea8;

  background: transparent;

  font-size: 1rem;
  font-weight: 500;
  line-height: 1.45;

  text-decoration: none;

  transition:
    background-color 0.18s ease,
    color 0.18s ease;
}


/* =========================================================
   NUMMER
   ========================================================= */

.jk-toc__number {
  color: #202020;

  font-weight: 700;

  font-variant-numeric:
    tabular-nums;

  white-space: nowrap;
}


/* =========================================================
   RUBRIKTEXT I LÄNKEN
   ========================================================= */

.jk-toc__link-text {
  min-width: 0;
}


/* =========================================================
   PIL PÅ VARJE LÄNK
   ========================================================= */

.jk-toc__link::after {
  content: "";

  position: absolute;

  right: 0.9rem;
  top: 50%;

  width: 0.45rem;
  height: 0.45rem;

  border-top:
    1.5px solid currentColor;

  border-right:
    1.5px solid currentColor;

  opacity: 0.55;

  transform:
    translateY(-50%)
    rotate(45deg);

  transition:
    transform 0.18s ease,
    opacity 0.18s ease;
}


/* =========================================================
   HOVER
   ========================================================= */

.jk-toc__link:hover {
  background: #f7f5f2;

  color: #003f73;

  text-decoration: none;
}


/*
 * Understryk endast själva rubriktexten,
 * inte numret.
 */

.jk-toc__link:hover .jk-toc__link-text {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}


.jk-toc__link:hover::after {
  opacity: 1;

  transform:
    translate(2px, -50%)
    rotate(45deg);
}


/* =========================================================
   TANGENTBORDSFOKUS
   ========================================================= */

.jk-toc__link:focus-visible {
  position: relative;

  z-index: 2;

  outline: 3px solid #202020;
  outline-offset: -3px;

  background: #f7f5f2;

  color: #202020;

  text-decoration: none;
}


.jk-toc__link:focus-visible
.jk-toc__link-text {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}


/* =========================================================
   ANKARPOSITION
   Anpassa vid behov efter sticky header
   ========================================================= */

.jk-toc-target {
  scroll-margin-top: 8rem;
}


/* =========================================================
   MOBIL
   ========================================================= */

@media (max-width: 767px) {

  #jk-innehallsforteckning {
    margin:
      1.5rem
      0
      2rem;
  }


  .jk-toc {
    border-radius: 12px;
  }


  .jk-toc__summary {
    min-height: 54px;

    padding:
      0.95rem
      1rem;
  }


  .jk-toc__nav {
    padding:
      0.25rem
      0.85rem
      0.5rem;
  }


  .jk-toc__link {
    grid-template-columns:
      1.8rem
      minmax(0, 1fr);

    column-gap: 0.35rem;

    min-height: 52px;

    padding:
      0.85rem
      2.25rem
      0.85rem
      0.75rem;
  }


  .jk-toc__link::after {
    right: 0.7rem;
  }

}


/* =========================================================
   EXTRA SMALA SKÄRMAR
   ========================================================= */

@media (max-width: 420px) {

  .jk-toc__summary {
    padding:
      0.9rem
      0.9rem;
  }


  .jk-toc__nav {
    padding:
      0.2rem
      0.65rem
      0.45rem;
  }


  .jk-toc__link {
    grid-template-columns:
      1.65rem
      minmax(0, 1fr);

    padding:
      0.85rem
      2rem
      0.85rem
      0.65rem;
  }


  .jk-toc__link::after {
    right: 0.6rem;
  }

}


/* =========================================================
   REDUCERAD RÖRELSE
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

  .jk-toc__summary,
  .jk-toc__icon,
  .jk-toc__link,
  .jk-toc__link::after {
    transition: none;
  }

}