/**
 * @file
 * Table of Contents (sommaire) component.
 * Figma: Sommaire Desktop (955:3066).
 *
 * White card, rounded-32px, box-shadow, with left orange progress stepper bar.
 * Items are rounded pill links.
 */

.toc {
  background: var(--color-white);
  border-radius: 32px;
  box-shadow: 0 6px 32px rgba(0, 0, 0, 0.12);
  width: 100%;
  overflow: hidden;
  position: relative;
}

/* Left progress stepper bar — on left edge inside card, below border-radius */
.toc__stepper {
  position: absolute;
  left: 0;
  top: 32px;
  bottom: 32px;
  width: 4px;
  z-index: 1;
}

.toc__stepper-track {
  width: 4px;
  height: 100%;
  background: var(--color-orange-light);
  border-radius: 100px;
  position: relative;
}

.toc__stepper-fill {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 4px;
  background: var(--color-orange);
  border-radius: 100px;
  transition: height 0.3s ease;
  height: 0%;
}

/* Wrapper for items */
.toc__wrapper {
  position: relative;
  padding: 16px;
  padding-left: 20px;
}

/* Title removed — Figma doesn't show a "Sommaire" title */
.toc__title {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: -0.03em;
  color: var(--color-blue);
  margin-bottom: 8px;
  display: none; /* Hidden per Figma */
}

/* Item list */
.toc__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Each item — rounded pill, 64px height */
.toc__item a {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  line-height: normal;
  letter-spacing: -0.05em;
  text-transform: uppercase;
  color: var(--color-blue);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  height: 64px;
  border-radius: 100px;
  overflow: hidden;
  transition: background var(--transition-base), color var(--transition-base);
}

/* Arrow icon for each TOC item — ARROW/out 14x14 exported from Figma */
.toc__item a::before {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  background-image: url('../../images/arrow-out.svg');
  background-size: 14px 14px;
  background-repeat: no-repeat;
  background-position: center;
}

.toc__item a:hover {
  background: rgba(233, 243, 255, 0.5);
}

/* Active state — blue-light background */
.toc__item.is-active a {
  background: var(--color-blue-light);
  font-weight: 600;
}

/* ===== MOBILE TOC — Figma 862:9031 ===== */
/* Starts in-flow between .art-hero and .art-bloc1.
   Becomes fixed under header (71px) when scrolled past. */
.toc-mobile {
  display: none;
}

@media (max-width: 1024px) {
  /* In-flow state (before scroll) — overlaps hero like .art-bloc1 does */
  .toc-mobile {
    display: block;
    position: relative;
    z-index: 10;
    background: var(--color-white);
    border-radius: 24px 24px 0 0;
    margin-top: -10px;
    margin-bottom: 25px;
    overflow: hidden;
  }

  /* Fixed state (when scrolled past) — below desktop header (86px) */
  .toc-mobile.is-fixed {
    position: fixed;
    top: 86px;
    left: 0;
    right: 0;
    z-index: 99;
    border-radius: 0;
  }

  /* Header must stay above fixed TOC so TOC slides under it */
  .header {
    z-index: 101;
  }

  /* Hide when past "pour aller plus loin" */
  .toc-mobile.is-hidden-end {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  /* Figma: Scroll container 96px tall, padding 16px, horizontal scroll */
  .toc-mobile__list {
    display: flex;
    gap: 16px;
    padding: 16px;
    height: 96px;
    align-items: center;
    overflow-x: auto;
    overflow-y: clip;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .toc-mobile__list::-webkit-scrollbar {
    display: none;
  }

  /* Figma: Chapitre pill — 64px height, min-width for 2 lines max */
  .toc-mobile__item a {
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    line-height: normal;
    letter-spacing: -0.7px;
    text-transform: uppercase;
    color: var(--color-blue);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 64px;
    min-width: 205px;
    padding: 16px 24px;
    border-radius: 100px;
    background: transparent;
    transition: background var(--transition-base);
    flex-shrink: 0;
    overflow: hidden;
  }

  /* Text inside pill — max 3 lines with ellipsis */
  .toc-mobile__item-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.2;
  }

  /* Figma: ARROW/out icon 14×14 before text */
  .toc-mobile__item a::before {
    content: '';
    display: block;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    background-image: url('../../images/arrow-out.svg');
    background-size: 14px 14px;
    background-repeat: no-repeat;
    background-position: center;
  }

  /* Active item = blue-light bg */
  .toc-mobile__item.is-active a {
    background: var(--color-blue-light);
  }

  .toc-mobile__item a:hover {
    background: rgba(233, 243, 255, 0.5);
  }

  /* Figma: Stepper bar — 4px, orange-light bg, orange fill */
  .toc-mobile__progress {
    height: 4px;
    background: var(--color-orange-light);
  }

  .toc-mobile__progress-fill {
    height: 100%;
    background: var(--color-orange);
    border-radius: 0 100px 100px 0;
    transition: width 0.3s ease;
    width: 0%;
  }

  /* Placeholder keeps space when TOC is fixed */
  .toc-mobile__placeholder {
    background: var(--color-white);
  }
}

@media (max-width: 768px) {
  /* Fixed state on mobile — below mobile header (71px) */
  .toc-mobile.is-fixed {
    top: 71px;
  }
}
