/* Timeline — couloir horizontal, pas de défilement vertical */

html:has(body.tl-layout) {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body.tl-layout {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body.tl-layout .site-header {
  flex-shrink: 0;
}

body.tl-layout main.tl-page.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
}

/* ——— Porte d’accès ——— */
.tl-gate {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-items: center;
  padding: 1rem var(--space-page) max(0.75rem, env(safe-area-inset-bottom));
}

.tl-gate__card {
  grid-row: 2;
  align-self: center;
  width: min(22rem, 100%);
  padding: 1.35rem 1.25rem 1.45rem;
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, rgba(34, 27, 52, 0.92), rgba(18, 18, 22, 0.96));
  border: 1px solid rgba(155, 140, 255, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 18px 40px -28px rgba(99, 78, 219, 0.45);
}

/* Porte d’accès : invisible dès que la frise est débloquée ([hidden] ou classe gone). */
.tl-gate[hidden],
.tl-gate.tl-gate--gone,
.tl-gate[hidden].tl-gate--gone {
  display: none !important;
  flex: 0 0 0 !important;
  height: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.tl-gate__title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: rgba(243, 236, 255, 0.98);
  text-align: center;
}

.tl-gate__prompt {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: rgba(226, 214, 255, 0.82);
  text-wrap: balance;
  text-align: center;
  max-width: 36ch;
  margin-left: auto;
  margin-right: auto;
}

.tl-gate__field {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.tl-date-row {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.tl-date-row__inputs {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.tl-date-sep {
  font-size: 1.15rem;
  font-weight: 600;
  color: rgba(234, 225, 255, 0.55);
  user-select: none;
  padding: 0 0.05rem;
}

.tl-date-part {
  width: 3.1rem;
  padding: 0.65rem 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(155, 140, 255, 0.35);
  background: rgba(10, 10, 14, 0.65);
  color: var(--text);
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

.tl-date-part--year {
  width: 5.1rem;
}

.tl-date-part:focus-visible {
  outline: 2px solid rgba(155, 140, 255, 0.55);
  outline-offset: 2px;
}

.tl-date-part:disabled {
  opacity: 0.45;
}

.tl-gate__actions {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.tl-gate__submit {
  width: 100%;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(155, 140, 255, 0.55);
  background: linear-gradient(180deg, rgba(155, 140, 255, 0.22), rgba(155, 140, 255, 0.08));
  color: rgba(250, 248, 255, 0.96);
  font-weight: 620;
  font-size: 0.95rem;
  cursor: pointer;
}

.tl-gate__submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tl-gate__msg {
  min-height: 1.25rem;
  margin: 0;
  font-size: 0.84rem;
  color: rgba(255, 176, 32, 0.92);
  text-align: center;
}

.tl-gate__msg--ok {
  color: rgba(120, 220, 180, 0.95);
}

.tl-gate .foot-note {
  grid-row: 3;
  align-self: end;
  justify-self: center;
  margin-top: 0;
  padding-top: 0.5rem;
  text-align: center;
}

.tl-main[hidden] {
  display: none !important;
}

.tl-main:not([hidden]) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  justify-content: center;
}

/* Défilement depuis la gauche : 1re carte entièrement visible (padding latéral). */
.tl-scroll {
  flex: 0 0 auto;
  max-height: 100%;
  width: 100%;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: none;
  -ms-overflow-style: none;
  display: block;
  text-align: start;
  white-space: nowrap;
  line-height: 0;
  padding-left: max(1.15rem, env(safe-area-inset-left));
  padding-right: max(1.15rem, env(safe-area-inset-right));
  scroll-padding-left: max(1.15rem, env(safe-area-inset-left));
  scroll-padding-right: max(15rem, 38vw);
}

.tl-scroll::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.tl-scroll:focus-visible {
  outline: none;
}

.tl-track {
  --tl-node-min: clamp(11rem, 28vw, 16rem);
  --tl-dot-size: 18px;
  --tl-dot-r: calc(var(--tl-dot-size) / 2);
  --tl-connector-w: 2px;
  --tl-rail-h: 4px;
  display: inline-flex;
  vertical-align: middle;
  width: max-content;
  min-height: min(78dvh, 36rem);
  flex-direction: row;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  text-align: start;
  white-space: normal;
  line-height: normal;
}

/* Tige : insets mesurés en JS (1er / dernier nœud de largeur variable). */
.tl-nodes-wrap {
  --tl-rail-left: calc(var(--tl-node-min) / 2);
  --tl-rail-right: calc(var(--tl-node-min) / 2);
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

.tl-rail {
  position: absolute;
  left: var(--tl-rail-left);
  right: var(--tl-rail-right);
  top: 50%;
  height: var(--tl-rail-h);
  transform: translateY(-50%);
  border-radius: 999px;
  /* Violet → lavande → rose/rouge doux → corail → orange (transitions plus longues) */
  background: linear-gradient(
    90deg,
    #7d6ee8 0%,
    #8f82f0 10%,
    #9b8cff 22%,
    #b89cff 34%,
    #c894d8 44%,
    #d888b0 52%,
    #e0808a 60%,
    #e8886e 72%,
    #f09850 84%,
    #ffb020 100%
  );
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 0 20px rgba(155, 140, 255, 0.22),
    0 0 28px rgba(232, 120, 130, 0.12),
    0 0 22px rgba(255, 176, 32, 0.1);
  pointer-events: none;
  z-index: 0;
}

.tl-nodes {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: clamp(2rem, 6vw, 3.75rem);
  z-index: 1;
}

/* Marge après le dernier point (carte visible) sans prolonger le fil */
.tl-nodes__spacer {
  flex: 0 0 auto;
  width: max(15rem, 38vw);
  height: 1px;
  pointer-events: none;
}

.tl-node {
  position: relative;
  flex: 0 0 auto;
  width: max-content;
  min-width: var(--tl-node-min);
  /* Occupe davantage la hauteur utile : dates plus haut / plus bas */
  height: min(78dvh, 36rem);
}

.tl-node__dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--tl-dot-size);
  height: var(--tl-dot-size);
  margin-left: calc(-1 * var(--tl-dot-r));
  margin-top: calc(-1 * var(--tl-dot-r));
  border-radius: 50%;
  background: #9488e4;
  box-shadow: 0 0 0 2px rgba(12, 10, 22, 0.92);
  z-index: 2;
}

.tl-node__connector {
  position: absolute;
  left: 50%;
  width: var(--tl-connector-w);
  margin-left: calc(var(--tl-connector-w) / -2);
  border-radius: 999px;
  z-index: 1;
}

.tl-node__btn {
  position: absolute;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.9rem 1.2rem 0.95rem;
  width: max-content;
  min-width: 10rem;
  max-width: min(26rem, 90vw);
  border-radius: var(--radius-md);
  border: 1px solid rgba(155, 140, 255, 0.52);
  background: linear-gradient(
    165deg,
    rgba(42, 34, 68, 0.88) 0%,
    rgba(22, 18, 34, 0.92) 45%,
    rgba(14, 12, 22, 0.94) 100%
  );
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  text-align: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 6px 22px -10px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transition:
    border-color 0.25s var(--ease-out),
    box-shadow 0.25s var(--ease-out),
    transform 0.2s var(--ease-out);
}

.tl-node__date {
  display: block;
  color: rgba(248, 242, 255, 0.98);
  font-size: clamp(1.08rem, 3.6vw, 1.38rem);
  font-weight: 640;
  letter-spacing: 0.04em;
  line-height: 1.25;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}

.tl-node__headline {
  display: block;
  color: rgba(220, 208, 255, 0.82);
  font-size: clamp(0.98rem, 3vw, 1.15rem);
  font-weight: 520;
  letter-spacing: 0.02em;
  line-height: 1.35;
  text-shadow: none;
  white-space: normal;
  text-wrap: balance;
  max-width: 24rem;
}

.tl-node__btn:hover {
  border-color: rgba(255, 200, 120, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 0 1px rgba(255, 176, 32, 0.15),
    0 12px 28px -14px rgba(255, 176, 32, 0.38);
  transform: translate(-50%, -1px);
}

.tl-node__btn:hover .tl-node__date {
  color: #fff;
}

.tl-node__btn:hover .tl-node__headline {
  color: rgba(255, 236, 220, 0.92);
}

.tl-node__btn:focus-visible {
  outline: 2px solid rgba(155, 140, 255, 0.65);
  outline-offset: 3px;
}

.tl-node--up .tl-node__connector {
  bottom: calc(50% + var(--tl-dot-r));
  height: clamp(3.25rem, 18vh, 13rem);
  background: linear-gradient(
    0deg,
    rgba(155, 140, 255, 0.18) 0%,
    rgba(190, 150, 230, 0.55) 32%,
    rgba(220, 120, 160, 0.65) 58%,
    rgba(240, 140, 95, 0.55) 82%,
    rgba(255, 176, 32, 0.42) 100%
  );
}

.tl-node--up .tl-node__btn {
  bottom: calc(50% + var(--tl-dot-r) + clamp(3.25rem, 18vh, 13rem) + calc(var(--tl-rail-h) / 2 + 0.2rem));
}

.tl-node--down .tl-node__connector {
  top: calc(50% + var(--tl-dot-r));
  height: clamp(3.25rem, 18vh, 13rem);
  background: linear-gradient(
    180deg,
    rgba(155, 140, 255, 0.18) 0%,
    rgba(190, 150, 230, 0.55) 32%,
    rgba(220, 120, 160, 0.65) 58%,
    rgba(240, 140, 95, 0.55) 82%,
    rgba(255, 176, 32, 0.42) 100%
  );
}

.tl-node--down .tl-node__btn {
  top: calc(50% + var(--tl-dot-r) + clamp(3.25rem, 18vh, 13rem) + calc(var(--tl-rail-h) / 2 + 0.2rem));
}

/* ——— Modale ——— */
.tl-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: rgba(4, 4, 8, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.tl-modal[hidden] {
  display: none;
}

.tl-modal__card {
  width: min(32rem, calc(100vw - 2rem));
  max-height: min(78dvh, calc(100dvh - 2.5rem));
  overflow: auto;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.25rem 1.35rem;
  background: linear-gradient(165deg, rgba(40, 32, 62, 0.96), rgba(14, 14, 18, 0.98));
  border: 1px solid rgba(155, 140, 255, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 0 0 1px rgba(155, 140, 255, 0.12),
    0 28px 60px -30px rgba(0, 0, 0, 0.65),
    0 0 40px rgba(155, 140, 255, 0.18);
  transform-origin: 50% 35%;
  animation: tl-modal-in 0.42s var(--ease-out) both;
}

.tl-modal__head {
  display: flex;
  justify-content: flex-end;
  margin: -0.15rem -0.15rem 0.35rem 0;
}

@keyframes tl-modal-in {
  from {
    opacity: 0;
    transform: scale(0.88) translateY(12px);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
}

.tl-modal__close {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.tl-modal__close:focus-visible {
  outline: 2px solid rgba(155, 140, 255, 0.65);
  outline-offset: 2px;
}

.tl-modal__date {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 176, 32, 0.88);
}

.tl-modal__title {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 680;
  color: rgba(248, 244, 255, 0.98);
}

.tl-modal__body {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.55;
  color: rgba(226, 214, 255, 0.88);
}

.tl-modal__figure {
  margin: 1rem 0 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(155, 140, 255, 0.28);
  background: linear-gradient(135deg, rgba(155, 140, 255, 0.12), rgba(255, 176, 32, 0.08));
  min-height: 8rem;
  display: grid;
  place-items: center;
}

.tl-modal__figure--has-img {
  min-height: 0;
  padding: 0;
  background: #0c0b12;
}

.tl-modal__figure-btn {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: #0c0b12;
  cursor: zoom-in;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  max-height: min(52dvh, 30rem);
}

.tl-modal__figure-btn:focus-visible {
  outline: 2px solid rgba(155, 140, 255, 0.65);
  outline-offset: 2px;
}

/* Aperçu : remplit le cadre (léger recadrage). Lightbox : image entière. */
.tl-modal__figure-btn img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  object-position: center 30%;
  display: block;
}

.tl-modal__figure--empty {
  color: rgba(234, 225, 255, 0.45);
  font-size: 0.88rem;
}

/* Visionneuse plein écran */
.tl-lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right))
    max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  background: rgba(4, 4, 8, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.tl-lightbox[hidden] {
  display: none;
}

.tl-lightbox__close {
  position: absolute;
  top: max(0.65rem, env(safe-area-inset-top));
  right: max(0.65rem, env(safe-area-inset-right));
  z-index: 1;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.tl-lightbox__close:focus-visible {
  outline: 2px solid rgba(155, 140, 255, 0.65);
  outline-offset: 2px;
}

.tl-lightbox__img {
  max-width: min(100%, 56rem);
  max-height: min(100dvh - 2rem, 100%);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.75);
}

@media (prefers-reduced-motion: reduce) {
  .tl-modal__card {
    animation: none;
  }
}
