/* ============================================
   HORIZONTAL TIMELINE
   Stacked editorial timeline. Top rail is a horizontal
   row of numbered chapter markers connected by a
   hairline. The detail spread sits below and cross-fades
   when a marker is activated. Auto-scroll cycles markers
   on a settable interval; user click pauses the loop,
   hover suspends it. Mirrors vertical-timeline behavior
   with the axes flipped.
   Swiss-Grid Editorial × Mediterranean warmth.
   ============================================ */

.htl {
  position: relative;
  overflow: hidden;
}

/* ─── Header ────────────────────────────────────────────── */
.htl__header {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 720px;
  margin: 0 0 var(--space-2xl);
}

@media (min-width: 1024px) {
  .htl__header {
    gap: var(--space-md);
    margin-bottom: var(--space-3xl);
  }
}

.htl__eyebrow {
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--clr-primary);
  line-height: 1.4;
}

.htl__heading {
  margin: 0;
  font-size: clamp(2rem, 4.5vw + 0.5rem, 3.75rem);
  line-height: 1.0;
  letter-spacing: 0.015em;
  color: var(--clr-primary);
  display: flex;
  flex-direction: column;
  text-wrap: balance;
}

.htl__heading-line1 {
  display: block;
  text-transform: uppercase;
  font-weight: 600;
}

.htl__heading-line2 {
  display: block;
  font-weight: 400;
  letter-spacing: 0;
  font-size: 0.85em;
  line-height: 1.05;
  margin-top: 4px;
}

.htl__body {
  margin: 0;
  font-size: var(--font-size-base);
  font-weight: 300;
  line-height: 1.65;
  color: var(--clr-text-secondary);
  text-wrap: pretty;
  max-width: 60ch;
}

@media (min-width: 1024px) {
  .htl__body { font-size: var(--font-size-lg); }
}

/* ─── Layout ───────────────────────────────────────────── */
.htl__layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

@media (min-width: 1024px) {
  .htl__layout {
    gap: var(--space-2xl);
  }
}

/* ============================================
   RAIL — horizontal row of numbered markers
   ============================================ */
.htl__rail {
  list-style: none;
  margin: 0;
  padding: var(--space-md) 0;
  position: relative;
  display: flex;
  align-items: flex-start;
  /* Even spacing across the full width on desktop; mobile scrolls. */
  gap: var(--space-md);
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.htl__rail::-webkit-scrollbar { display: none; }

@media (min-width: 768px) {
  .htl__rail {
    justify-content: space-between;
    overflow-x: visible;
    gap: var(--space-sm);
  }
}

/* Connecting hairline — sits behind the dots, runs the full rail. */
.htl__rail::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  /* Aligned with the dot's vertical center. Padding-top of the rail
     is var(--space-md) and the dot is 15px tall, so center sits at
     (--space-md + 7.5px). */
  top: calc(var(--space-md) + 7px);
  height: 1px;
  background: rgba(60, 66, 46, 0.18);
  z-index: 0;
}

.htl__rail-item {
  margin: 0;
  padding: 0;
  position: relative;
  flex: 1 1 0;
  /* On mobile keep a minimum tap-target width so the rail is
     comfortably scrollable. */
  min-width: 110px;
}

@media (min-width: 768px) {
  .htl__rail-item {
    min-width: 0;
  }
}

.htl__marker {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  text-align: center;
  cursor: pointer;
  color: var(--clr-text-muted);
  transition: color 0.3s ease;
  position: relative;
  z-index: 1;
}

.htl__marker:hover {
  color: var(--clr-primary);
}

.htl__marker:focus-visible {
  outline: 2px solid var(--clr-brand-accent);
  outline-offset: 4px;
  border-radius: 2px;
}

/* Dot sits on top of the connecting hairline. */
.htl__marker-dot {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--clr-bg, #fff);
  border: 1px solid rgba(60, 66, 46, 0.4);
  position: relative;
  z-index: 1;
  transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}

.htl__marker-dot::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--clr-primary);
  transform: scale(0);
  transition: transform 0.3s ease;
}

.htl__marker.is-active .htl__marker-dot {
  border-color: var(--clr-primary);
  transform: scale(1.05);
}

.htl__marker.is-active .htl__marker-dot::after {
  transform: scale(1);
}

.htl__marker-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  line-height: 1.25;
  color: inherit;
  transition: color 0.3s ease;
  white-space: nowrap;
}

@media (min-width: 1024px) {
  .htl__marker-label { font-size: 14px; }
}

.htl__marker.is-active .htl__marker-label {
  color: var(--clr-primary);
}

/* Progress segment — fills between the active dot and the next dot
   over the autoscroll duration. JS positions left/width in pixel-space
   so it tracks the dots even when the rail is horizontally scrolled. */
.htl__progress {
  position: absolute;
  top: calc(var(--space-md) + 6.5px);
  left: 0;
  width: 0;
  height: 2px;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.htl__progress.is-visible { opacity: 1; }

.htl__progress::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--clr-primary);
  transform-origin: left center;
  transform: scaleX(var(--htl-progress, 0));
}

.htl.bg-accent-dark .htl__progress::before {
  background: var(--clr-brand-accent);
}

@media (prefers-reduced-motion: reduce) {
  .htl__progress { display: none; }
}

/* ============================================
   PANELS — detail spread, cross-fades on activation
   ============================================ */
.htl__panels {
  position: relative;
  min-height: 320px;
}

@media (min-width: 960px) {
  .htl__panels {
    min-height: 480px;
  }
}

.htl__panel {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-lg);
  align-content: start;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

@media (min-width: 720px) {
  .htl__panel {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: var(--space-xl);
  }
}

.htl__panel.is-active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  position: relative;
}

.htl__panel-image {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: rgba(60, 66, 46, 0.06);
}

.htl__panel-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.htl__panel-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding-top: var(--space-xs);
}

@media (min-width: 720px) {
  .htl__panel-text {
    gap: var(--space-md);
    padding-top: 0;
    align-self: center;
  }
}

.htl__panel-era {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--clr-brand-alt);
  line-height: 1.4;
}

.htl__panel-title {
  margin: 0;
  font-size: clamp(1.5rem, 2.5vw + 0.5rem, 2.25rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: 0.015em;
  text-transform: uppercase;
  color: var(--clr-primary);
  text-wrap: balance;
}

.htl__panel-body {
  font-size: var(--font-size-base);
  font-weight: 300;
  line-height: 1.7;
  color: var(--clr-text-secondary);
  text-wrap: pretty;
}

.htl__panel-body p {
  margin: 0 0 var(--space-sm);
}

.htl__panel-body p:last-child {
  margin-bottom: 0;
}

.htl__panel-body em {
  font-style: italic;
}

/* ============================================
   DARK BACKGROUND VARIANT — bg-accent-dark
   ============================================ */
.htl.bg-accent-dark .htl__eyebrow {
  color: var(--clr-brand-accent);
}

.htl.bg-accent-dark .htl__heading-line1 {
  color: var(--clr-text-inverse);
}

.htl.bg-accent-dark .htl__heading-line2 {
  color: var(--clr-brand-accent);
}

.htl.bg-accent-dark .htl__body {
  color: var(--clr-text-inverse);
  opacity: 0.82;
}

.htl.bg-accent-dark .htl__rail::before {
  background: rgba(253, 252, 250, 0.18);
}

.htl.bg-accent-dark .htl__marker {
  color: rgba(253, 252, 250, 0.55);
}

.htl.bg-accent-dark .htl__marker:hover,
.htl.bg-accent-dark .htl__marker.is-active {
  color: var(--clr-text-inverse);
}

.htl.bg-accent-dark .htl__marker-dot {
  background: transparent;
  border-color: rgba(253, 252, 250, 0.4);
}

.htl.bg-accent-dark .htl__marker.is-active .htl__marker-dot {
  border-color: var(--clr-brand-accent);
}

.htl.bg-accent-dark .htl__marker.is-active .htl__marker-dot::after {
  background: var(--clr-brand-accent);
}

.htl.bg-accent-dark .htl__marker-label,
.htl.bg-accent-dark .htl__marker.is-active .htl__marker-label {
  color: inherit;
}

.htl.bg-accent-dark .htl__panel-era {
  color: var(--clr-brand-accent);
}

.htl.bg-accent-dark .htl__panel-title {
  color: var(--clr-text-inverse);
}

.htl.bg-accent-dark .htl__panel-body {
  color: var(--clr-text-inverse);
  opacity: 0.78;
}

.htl.bg-accent-dark .htl__panel-image {
  background: rgba(253, 252, 250, 0.05);
}

/* ============================================
   Reduced motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .htl__marker,
  .htl__marker-label,
  .htl__marker-dot,
  .htl__marker-dot::after,
  .htl__panel,
  .htl__rail {
    transition: none;
    scroll-behavior: auto;
  }
}
