
.eightd-page {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: calc(100vh - 76px);
  padding: var(--space-6) clamp(var(--space-4), 3vw, var(--space-6)) var(--space-12);
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  color: var(--text-primary);
  padding-top: max(6.75rem, calc(var(--space-6) + 4.5rem));

  &--guest {
    padding-top: max(7.5rem, calc(var(--space-10) + 5rem));
  }

  .container {
    max-width: var(--tool-page-max-width, 1100px);
  }
}

.eightd-header {
  text-align: center;
  margin-bottom: var(--space-6);

  h1 {
    color: var(--text-primary);
    font-weight: 800;
    margin-bottom: var(--space-2);
    font-size: clamp(2rem, 3.6vw, 2.85rem);
    line-height: 1.1;

    &::after {
      content: '';
      display: block;
      width: 60px;
      height: 4px;
      background: var(--primary);
      border-radius: 999px;
      margin: var(--space-2) auto 0;
    }
  }

  .lead {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 780px;
    margin: 0 auto;
    line-height: 1.7;
  }
}

.eightd-notice {
  border-radius: var(--radius-2xl);
  border: 1px solid rgba(148, 163, 184, 0.22);
  padding: var(--space-5);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.14) 0%, rgba(168, 85, 247, 0.12) 100%);
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-lg);

  h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  p {
    margin: 0;
    line-height: 1.65;
  }
}

/* Parcours unique D0–D8 (remplace grille + nav + frise redondantes) */
.eightd-journey {
  margin-bottom: var(--space-6);
  padding: var(--space-5);
  border-radius: var(--radius-2xl);
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: var(--bg-primary);
  box-shadow: var(--shadow-lg);
}

.eightd-journey__intro {
  margin-bottom: var(--space-4);
}

.eightd-journey__title {
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
  font-weight: 800;
  margin: 0 0 var(--space-2);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.eightd-journey__lede {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 52rem;
}

.eightd-journey__rail {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  margin: 0 calc(-1 * var(--space-2));
  padding: var(--space-2) var(--space-2) var(--space-1);
  mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 12px), transparent);
}

.eightd-journey__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  min-width: min-content;
}

.eightd-journey__item {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex: 0 0 auto;
  scroll-snap-align: start;
}

.eightd-journey__connector {
  width: 10px;
  height: 2px;
  margin: 0 2px;
  flex-shrink: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(129, 140, 248, 0.35), rgba(99, 102, 241, 0.65));
}

.eightd-journey__step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-width: 4.5rem;
  padding: 0.65rem 0.5rem 0.55rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.98) 0%, rgba(241, 245, 249, 0.92) 100%);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.15;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease, background 0.2s ease;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
}

.eightd-journey__step:hover {
  border-color: rgba(99, 102, 241, 0.55);
  box-shadow: 0 6px 20px -10px rgba(79, 70, 229, 0.45);
  transform: translateY(-1px);
}

.eightd-journey__step:focus-visible {
  outline: 3px solid rgba(129, 140, 248, 0.45);
  outline-offset: 2px;
}

.eightd-journey__code {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--primary);
}

.eightd-journey__short {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.eightd-controls {
  margin-bottom: var(--space-5);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-primary);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(148, 163, 184, 0.25);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  position: relative;
  z-index: 2;

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 0.65rem 1.4rem !important;
    border-radius: 999px !important;
    border: none;
    font-weight: 600;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 14px 28px -18px rgba(15, 23, 42, 0.35);
    font-size: 0.95rem;

    &:focus-visible {
      outline: 3px solid rgba(79, 70, 229, 0.35);
      outline-offset: 2px;
    }

    &:hover:not(:disabled) {
      transform: translateY(-2px);
      box-shadow: 0 18px 36px -20px rgba(37, 99, 235, 0.45);
    }
  }

  .btn-primary,
  .btn-info {
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%) !important;
    color: #fff !important;
  }

  .btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: #fff !important;
  }

  .btn-outline-danger {
    background: #fff;
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.45) !important;

    &:hover {
      background: rgba(239, 68, 68, 0.08);
      color: #b91c1c;
    }
  }

  .btn-outline-secondary {
    background: #fff;
    color: var(--text-primary);
    border: 1px solid rgba(148, 163, 184, 0.55) !important;

    &:hover {
      background: rgba(148, 163, 184, 0.12);
      color: var(--primary);
    }
  }

  .btn-outline-primary {
    background: #fff;
    color: var(--primary);
    border: 1px solid rgba(79, 70, 229, 0.45) !important;

    &:hover {
      background: rgba(79, 70, 229, 0.08);
      color: var(--primary-dark);
    }
  }

  .dropdown-menu {
    border-radius: var(--radius-lg);
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.15);
    padding: var(--space-2) 0;
  }

  .dropdown-item {
    padding: var(--space-3) var(--space-5);
    font-weight: 500;
    color: var(--text-primary);

    &:hover {
      background: rgba(79, 70, 229, 0.08);
      color: var(--primary);
    }
  }
}

.eightd-problem-card {
  background: var(--bg-primary);
  border-radius: var(--radius-2xl);
  border: 1px solid rgba(148, 163, 184, 0.22);
  padding: var(--space-5);
  box-shadow: var(--shadow-lg);
  margin-bottom: var(--space-5);

  h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: var(--space-4);
    color: var(--text-primary);
  }
}

.eightd-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);

  label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
  }

  .helper {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
  }

  input,
  textarea,
  select {
    width: 100%;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(248, 250, 252, 0.95);
    padding: 0.85rem 1rem;
    font-size: 0.96rem;
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;

    &:focus {
      border-color: var(--primary);
      box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.15);
      background: #fff;
      outline: none;
    }
  }

  textarea {
    min-height: 120px;
    resize: vertical;
  }
}

.eightd-discipline {
  background: var(--bg-primary);
  border-radius: var(--radius-2xl);
  border: 1px solid rgba(148, 163, 184, 0.22);
  padding: var(--space-5);
  box-shadow: var(--shadow-lg);
  margin-bottom: var(--space-5);
  position: relative;
  overflow: hidden;
  scroll-margin-top: max(5.5rem, calc(var(--space-6) + 3rem));

  &__header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  }

  &__badge {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.4rem;
    box-shadow: var(--shadow-md);
  }

  &__title {
    flex: 1;

    h3 {
      font-size: 1.2rem;
      font-weight: 700;
      margin-bottom: var(--space-2);
      color: var(--text-primary);
    }

    p {
      margin: 0;
      color: var(--text-secondary);
      line-height: 1.6;
    }
  }
}

.eightd-team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-3);

  input {
    min-width: 0;
  }
}

.eightd-team-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.eightd-member-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: var(--space-2);
  align-items: center;

  input {
    min-width: 0;
  }

  .btn-remove {
    min-width: 46px;
    max-width: 46px;
    height: 38px;
    border: 2px solid #ef4444 !important;
    color: #ef4444 !important;
    font-weight: 600;
    background: #fff !important;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;

    &:hover {
      background: #ef4444 !important;
      color: #fff !important;
      border-color: #dc2626 !important;
      transform: scale(1.05);
    }

    &:focus-visible {
      outline: 3px solid rgba(239, 68, 68, 0.35);
      outline-offset: 2px;
    }

    i {
      font-size: 0.9rem;
    }
  }
}

.eightd-add-member-wrapper {
  display: flex;
  justify-content: center;
  margin-top: var(--space-3);

  .btn {
    padding: 0.5rem 1rem !important;
    font-size: 0.875rem;
    min-height: 38px;
  }
}

.eightd-results {
  background: var(--bg-primary);
  border-radius: var(--radius-2xl);
  border: 1px solid rgba(148, 163, 184, 0.22);
  padding: var(--space-5);
  box-shadow: var(--shadow-xl);
  margin-bottom: var(--space-8);
}

.eightd-progress {
  margin-bottom: var(--space-5);

  h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: var(--space-2);
    color: var(--text-primary);
  }

  &__bar {
    height: 32px;
    border-radius: var(--radius-xl);
    background: rgba(148, 163, 184, 0.25);
    overflow: hidden;
    display: flex;
    align-items: center;
  }

  &__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #22c55e);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    transition: width 0.4s ease;
  }
}

.eightd-timeline {
  position: relative;
  padding-left: var(--space-6);
  margin-bottom: var(--space-5);

  &::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, rgba(129, 140, 248, 0.7), rgba(79, 70, 229, 0.7));
  }

  &__item {
    position: relative;
    margin-bottom: var(--space-4);
    padding: var(--space-3);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(248, 250, 252, 0.95);
    box-shadow: var(--shadow-sm);

    &::before {
      content: '';
      position: absolute;
      left: -38px;
      top: 14px;
      width: 22px;
      height: 22px;
      border-radius: 50%;
      background: linear-gradient(135deg, var(--primary), var(--primary-light));
      box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.25);
    }

    h4 {
      margin: 0 0 var(--space-2) 0;
      font-size: 1rem;
      font-weight: 700;
      color: var(--text-primary);
    }

    p {
      margin: 0;
      color: var(--text-secondary);
      line-height: 1.6;
    }
  }
}

.eightd-summary {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.16), rgba(16, 185, 129, 0.12));
  border-radius: var(--radius-xl);
  border: 1px solid rgba(34, 197, 94, 0.25);
  padding: var(--space-4);
  color: #065f46;

  h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: var(--space-2);
  }

  ul {
    margin: 0;
    padding-left: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);

    li {
      line-height: 1.6;
    }
  }
}

/* ─── Rapport export (PDF / PNG / JPEG) ─────────────────────────────────── */
.eightd-export-report {
  position: fixed;
  left: -99999px;
  top: 0;
  width: 794px;
  z-index: -1;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow: hidden;
  background: #ffffff;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: #0f172a;
  box-sizing: border-box;
}

.eightd-export-report__header {
  border-bottom: 2px solid rgba(245, 158, 11, 0.25);
  padding-bottom: var(--space-3);
}

.eightd-export-report__source {
  margin: 0 0 var(--space-2);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #d97706;
  text-align: center;
}

.eightd-export-report__title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  text-align: center;
}

.eightd-export-report__date {
  margin: var(--space-2) 0 0;
  font-size: 0.875rem;
  color: #64748b;
  text-align: center;
}

.eightd-export-report__meta {
  background: rgba(248, 250, 252, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
}

.eightd-export-report__meta h3 {
  margin: 0 0 var(--space-3);
  font-size: 1rem;
  font-weight: 700;
}

.eightd-export-report__meta-list {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: 0.9rem;
  line-height: 1.55;
}

.eightd-export-report__progress h3 {
  margin: 0 0 var(--space-3);
  font-size: 1rem;
  font-weight: 700;
}

.eightd-export-report__progress-bar {
  height: 1.25rem;
  background: rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.eightd-export-report__progress-fill {
  height: 100%;
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #78350f;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
}

.eightd-export-report__timeline h3,
.eightd-export-report__summary h3 {
  margin: 0 0 var(--space-3);
  font-size: 1rem;
  font-weight: 700;
}

.eightd-export-report__timeline-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.eightd-export-report__timeline-item {
  background: rgba(248, 250, 252, 0.95);
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
}

.eightd-export-report__timeline-item h4 {
  margin: 0 0 var(--space-2);
  font-size: 0.92rem;
  font-weight: 700;
  color: #b45309;
}

.eightd-export-report__timeline-item p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #334155;
  white-space: pre-line;
}

.eightd-export-report__summary {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(74, 222, 128, 0.08));
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
}

.eightd-export-report__summary-list {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.55;
}

.eightd-export-report__footer {
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  padding-top: var(--space-3);
}

.eightd-export-report__stats-line,
.eightd-export-report__branding {
  margin: 0;
  text-align: center;
  color: #64748b;
  font-size: 0.85rem;
}

@media (max-width: 992px) {
  .eightd-page {
    padding: var(--space-6) clamp(var(--space-3), 4vw, var(--space-5)) var(--space-10);
    padding-top: max(6.75rem, calc(var(--space-6) + 4.75rem));
  }

  .eightd-discipline__header {
    flex-direction: column;
    align-items: flex-start;

    .eightd-discipline__badge {
      width: 52px;
      height: 52px;
      font-size: 1.2rem;
      border-radius: 16px;
    }
  }

  .eightd-member-row {
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: var(--space-2);

    .btn-remove {
      grid-column: auto;
      max-width: 46px;
    }
  }

  @media (max-width: 640px) {
    .eightd-member-row {
      grid-template-columns: 1fr;
      gap: var(--space-2);

      .btn-remove {
        grid-column: 1;
        max-width: 100%;
        width: 100%;
      }
    }
  }
}

@media (max-width: 640px) {
  .eightd-page {
    padding: var(--space-5) var(--space-3) var(--space-8);
    padding-top: max(6.75rem, calc(var(--space-6) + 5rem));
  }

  .eightd-controls .btn {
    width: 100%;
  }

  .eightd-timeline {
    padding-left: var(--space-4);

    &::before {
      left: 12px;
    }

    &__item::before {
      left: -28px;
      width: 18px;
      height: 18px;
    }
  }
}

