/**
 * Baxi Baxi — Widget 03 · Timeline
 *
 * Anatomia (UX Patterns — timeline axis + markers + content):
 *   .bbx-axis  → faixa do eixo (nós alinhados; trilho no centro vertical)
 *   .bbx-node  → marcador
 *   .bbx-body  → ano + descrição
 *
 * Layout (ResizeObserver → data-bbx-layout):
 *   h ≥ 720px  → horizontal; trilho do centro do 1º nó ao centro do último
 *   v < 720px  → vertical; cards full-width
 */

.bbx-timeline {
  --bbx-red: #c8102e;
  --bbx-navy: #152a5c;
  --bbx-text: #5a6472;
  --bbx-muted: #e0c4c8;
  --bbx-card: #ffffff;
  --bbx-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  --bbx-dot: 18px;
  --bbx-node: 28px;
  --bbx-axis-h: 40px;
  --bbx-rail: 3px;
  --bbx-progress: 1;
  --bbx-count: 5;
  /* Defaults alinhados ao teste Elementor (#F5F5F51F + pad 35/22) */
  --bbx-pad-top: 35px;
  --bbx-pad-bottom: 22px;
  --bbx-pad-x: 22px;

  position: relative;
  display: block;
  width: 100%;
  max-width: none;
  margin: 0;
  /* Glass mais leve (~12%) — deixa o fundo da página aparecer */
  background: rgba(245, 245, 245, 0.12);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 20px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 10px 36px rgba(21, 42, 92, 0.05);
  /* Pad: mais topo; laterais iguais (evita 9px apertando a 1ª coluna) */
  padding: var(--bbx-pad-top) var(--bbx-pad-x) var(--bbx-pad-bottom);
  color: var(--bbx-navy);
  font-family: var(--bbx-font);
  box-sizing: border-box;
}

.bbx-timeline *,
.bbx-timeline *::before,
.bbx-timeline *::after {
  box-sizing: border-box;
}

.bbx-timeline .bbx-wrap {
  /* Sem pad/max-width — laterais no Elementor (lição 6Passos) */
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.bbx-timeline .bbx-tline {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  position: relative;
}

.bbx-timeline .bbx-ti {
  position: relative;
  z-index: 1;
  min-width: 0;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  transition-delay: var(--d, 0s);
}

.bbx-timeline .bbx-ti.is-inview {
  opacity: 1;
  transform: none;
}

.bbx-timeline.bbx-enter {
  transition: none;
}

.bbx-timeline .bbx-axis {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  height: var(--bbx-axis-h);
  flex: 0 0 auto;
}

.bbx-timeline .bbx-node {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  width: var(--bbx-node);
  height: var(--bbx-node);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
}

.bbx-timeline .bbx-node:focus-visible {
  outline: 3px solid var(--bbx-red);
  outline-offset: 3px;
}

.bbx-timeline .bbx-dot {
  width: var(--bbx-dot);
  height: var(--bbx-dot);
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--bbx-red);
  box-shadow: 0 0 0 0 rgba(200, 16, 46, 0);
  transition: transform 0.28s ease, background 0.28s ease, box-shadow 0.28s ease;
}

.bbx-timeline .bbx-ti.is-now .bbx-dot,
.bbx-timeline .bbx-ti.is-active .bbx-dot {
  background: var(--bbx-red);
}

.bbx-timeline .bbx-ti.is-active:not(.is-pulse) .bbx-dot,
.bbx-timeline .bbx-node:hover .bbx-dot {
  transform: scale(1.12);
  box-shadow: 0 0 0 7px rgba(200, 16, 46, 0.14);
}

.bbx-timeline.is-touring .bbx-tline::after {
  transition: none;
}

@keyframes bbx-tl-wave {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(200, 16, 46, 0.42);
  }
  55% {
    transform: scale(1.1);
    box-shadow: 0 0 0 14px rgba(200, 16, 46, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(200, 16, 46, 0);
  }
}

.bbx-timeline .bbx-ti.is-pulse .bbx-dot {
  background: var(--bbx-red);
  animation: bbx-tl-wave 1.15s ease-out infinite;
}

.bbx-timeline .bbx-body {
  min-width: 0;
  width: 100%;
}

.bbx-timeline .bbx-year {
  display: block;
  font: 700 1.35rem/1.15 var(--bbx-font);
  color: var(--bbx-navy);
  margin: 0 0 6px;
  transition: color 0.25s ease;
}

.bbx-timeline .bbx-ti.is-active .bbx-year {
  color: var(--bbx-red);
}

.bbx-timeline .bbx-desc {
  display: block;
  margin: 0;
  font: 400 0.95rem/1.55 var(--bbx-font);
  color: var(--bbx-text);
}

.bbx-timeline .bbx-reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.bbx-timeline .bbx-reveal.is-inview {
  opacity: 1;
  transform: none;
}

/* =========================================================
 * VERTICAL (default + layout=v)
 * ========================================================= */
.bbx-timeline .bbx-tline,
.bbx-timeline[data-bbx-layout="v"] .bbx-tline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.bbx-timeline .bbx-tline::before,
.bbx-timeline[data-bbx-layout="v"] .bbx-tline::before,
.bbx-timeline .bbx-tline::after,
.bbx-timeline[data-bbx-layout="v"] .bbx-tline::after {
  content: "";
  position: absolute;
  left: calc(var(--bbx-node) / 2 - var(--bbx-rail) / 2);
  top: calc(var(--bbx-axis-h) / 2);
  width: var(--bbx-rail);
  border-radius: 999px;
  pointer-events: none;
  z-index: 0;
}

.bbx-timeline .bbx-tline::before,
.bbx-timeline[data-bbx-layout="v"] .bbx-tline::before {
  bottom: calc(var(--bbx-axis-h) / 2);
  background: linear-gradient(180deg, var(--bbx-muted), var(--bbx-red));
  opacity: 0.5;
}

.bbx-timeline .bbx-tline::after,
.bbx-timeline[data-bbx-layout="v"] .bbx-tline::after {
  height: calc(var(--bbx-progress) * (100% - var(--bbx-axis-h)));
  background: var(--bbx-red);
  transition: height 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.bbx-timeline .bbx-ti,
.bbx-timeline[data-bbx-layout="v"] .bbx-ti {
  display: grid;
  grid-template-columns: var(--bbx-node) minmax(0, 1fr);
  column-gap: 16px;
  /* 1º nó: topo (início da linha) */
  align-items: start;
  width: 100%;
  padding-bottom: 22px;
}

/* Nós do meio: centrados no card (.bbx-body) */
.bbx-timeline .bbx-ti:not(:first-child):not(:last-child),
.bbx-timeline[data-bbx-layout="v"] .bbx-ti:not(:first-child):not(:last-child) {
  align-items: center;
}

/* Último nó: fim da linha */
.bbx-timeline .bbx-ti:last-child,
.bbx-timeline[data-bbx-layout="v"] .bbx-ti:last-child {
  align-items: end;
  padding-bottom: 0;
}

.bbx-timeline .bbx-axis,
.bbx-timeline[data-bbx-layout="v"] .bbx-axis {
  justify-content: center;
  width: var(--bbx-node);
}

.bbx-timeline .bbx-body,
.bbx-timeline[data-bbx-layout="v"] .bbx-body {
  background: var(--bbx-card);
  border: 1px solid rgba(21, 42, 92, 0.08);
  border-radius: 12px;
  padding: 18px 18px 20px;
  box-shadow: 0 10px 28px rgba(21, 42, 92, 0.06);
  margin-top: 0;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.bbx-timeline .bbx-ti:first-child .bbx-body,
.bbx-timeline[data-bbx-layout="v"] .bbx-ti:first-child .bbx-body {
  margin-top: 4px;
}

.bbx-timeline[data-bbx-layout="v"] .bbx-ti.is-active .bbx-body {
  border-color: rgba(200, 16, 46, 0.35);
  box-shadow: 0 14px 32px rgba(200, 16, 46, 0.1);
}

/* =========================================================
 * HORIZONTAL (layout=h)
 * Trilho: centro do 1º nó → centro do último
 * left = 50%/n ; width = (n-1)/n * 100%
 * ========================================================= */
.bbx-timeline[data-bbx-layout="h"] .bbx-tline {
  display: grid;
  grid-template-columns: repeat(var(--bbx-count), minmax(0, 1fr));
  gap: 0;
  align-items: start;
}

.bbx-timeline[data-bbx-layout="h"] .bbx-tline::before,
.bbx-timeline[data-bbx-layout="h"] .bbx-tline::after {
  top: calc(var(--bbx-axis-h) / 2 - var(--bbx-rail) / 2);
  bottom: auto;
  left: calc(100% / var(--bbx-count) / 2);
  width: calc(100% * (var(--bbx-count) - 1) / var(--bbx-count));
  height: var(--bbx-rail);
  opacity: 1;
}

.bbx-timeline[data-bbx-layout="h"] .bbx-tline::before {
  background: linear-gradient(90deg, var(--bbx-muted) 0%, var(--bbx-red) 100%);
  opacity: 0.9;
}

.bbx-timeline[data-bbx-layout="h"] .bbx-tline::after {
  width: calc(
    100% * (var(--bbx-count) - 1) / var(--bbx-count) * var(--bbx-progress)
  );
  max-width: calc(100% * (var(--bbx-count) - 1) / var(--bbx-count));
  background: var(--bbx-red);
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.bbx-timeline[data-bbx-layout="h"] .bbx-ti {
  display: flex;
  flex-direction: column;
  align-items: stretch; /* reseta center/end do layout v */
  width: 100%;
  padding: 0 14px 0 0;
  grid-template-columns: none;
}

.bbx-timeline[data-bbx-layout="h"] .bbx-ti:not(:first-child):not(:last-child),
.bbx-timeline[data-bbx-layout="h"] .bbx-ti:last-child {
  align-items: stretch;
}

.bbx-timeline[data-bbx-layout="h"] .bbx-ti:last-child {
  padding-right: 0;
  padding-bottom: 0;
}

.bbx-timeline[data-bbx-layout="h"] .bbx-axis {
  width: 100%;
  justify-content: center;
}

.bbx-timeline[data-bbx-layout="h"] .bbx-body {
  background: transparent;
  border: 0;
  border-radius: 10px;
  box-shadow: none;
  padding: 14px 12px 16px;
  margin-top: 0;
  text-align: center;
}

.bbx-timeline[data-bbx-layout="h"] .bbx-ti.is-active .bbx-body {
  background: rgba(255, 255, 255, 0.38);
  border: 0;
  box-shadow: none;
  padding: 16px 14px 18px;
}

.bbx-timeline[data-bbx-layout="h"] .bbx-year {
  font-size: clamp(1.15rem, 1.55vw, 1.4rem);
}

.bbx-timeline[data-bbx-layout="h"] .bbx-desc {
  font-size: clamp(0.84rem, 1vw, 0.95rem);
  line-height: 1.5;
  max-width: 28ch;
  margin-inline: auto;
}

@media (max-width: 899px) {
  .bbx-timeline[data-bbx-layout="h"] .bbx-ti {
    padding-right: 8px;
  }

  .bbx-timeline[data-bbx-layout="h"] .bbx-desc {
    font-size: 0.8rem;
    max-width: none;
  }
}

/* Fallback sem data-bbx-layout (antes do JS) */
@media (min-width: 720px) {
  .bbx-timeline:not([data-bbx-layout]) .bbx-tline {
    display: grid;
    grid-template-columns: repeat(var(--bbx-count), minmax(0, 1fr));
    gap: 0;
  }

  .bbx-timeline:not([data-bbx-layout]) .bbx-tline::before,
  .bbx-timeline:not([data-bbx-layout]) .bbx-tline::after {
    top: calc(var(--bbx-axis-h) / 2 - var(--bbx-rail) / 2);
    bottom: auto;
    left: calc(100% / var(--bbx-count) / 2);
    width: calc(100% * (var(--bbx-count) - 1) / var(--bbx-count));
    height: var(--bbx-rail);
  }

  .bbx-timeline:not([data-bbx-layout]) .bbx-tline::after {
    width: calc(
      100% * (var(--bbx-count) - 1) / var(--bbx-count) * var(--bbx-progress)
    );
  }

  .bbx-timeline:not([data-bbx-layout]) .bbx-ti {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0 14px 0 0;
  }

  .bbx-timeline:not([data-bbx-layout]) .bbx-axis {
    width: 100%;
    justify-content: center;
  }

  .bbx-timeline:not([data-bbx-layout]) .bbx-body {
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 14px 12px 16px;
    margin-top: 0;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bbx-timeline:not(.bbx-force-motion) .bbx-ti,
  .bbx-timeline:not(.bbx-force-motion) .bbx-reveal,
  .bbx-timeline:not(.bbx-force-motion) .bbx-tline::after,
  .bbx-timeline:not(.bbx-force-motion) .bbx-dot {
    transition: none !important;
    animation: none !important;
  }

  .bbx-timeline:not(.bbx-force-motion) .bbx-ti,
  .bbx-timeline:not(.bbx-force-motion) .bbx-reveal {
    opacity: 1;
    transform: none;
  }
}
