/* ========================================
   INTERACTIVE TIMELINE WIDGET - CSS v3.0
   ======================================== */

/* ── Core layout ── */
.interactive-timeline {
  display: flex;
  gap: 30px;
  align-items: stretch;
  font-family: Arial, sans-serif;
  position: relative;
  width: 100%;
}

.interactive-timeline.layout-left  { flex-direction: row; }
.interactive-timeline.layout-right { flex-direction: row-reverse; }

/* ── Container ratio presets
   NOTE: PHP generates "layout-ratio-{value}" e.g. layout-ratio-50-50
   ── */
.interactive-timeline.layout-ratio-50-50 .timeline-media  { flex: 0 0 50%; max-width: 50%; }
.interactive-timeline.layout-ratio-50-50 .timeline-content { flex: 0 0 50%; max-width: 50%; }

.interactive-timeline.layout-ratio-40-60 .timeline-media  { flex: 0 0 40%; max-width: 40%; }
.interactive-timeline.layout-ratio-40-60 .timeline-content { flex: 0 0 60%; max-width: 60%; }

.interactive-timeline.layout-ratio-60-40 .timeline-media  { flex: 0 0 60%; max-width: 60%; }
.interactive-timeline.layout-ratio-60-40 .timeline-content { flex: 0 0 40%; max-width: 40%; }

/* ══════════════════════════════════════
   MEDIA AREA
   position:relative + overflow:hidden
   are set here; JS runtime CSS also sets
   them as a safety net (no conflict).
══════════════════════════════════════ */
.timeline-media {
  flex: 0 0 50%;
  max-width: 50%;
  position: relative;         /* stacking context for absolute images */
  overflow: hidden;
  background: transparent;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* aspect-ratio set inline by PHP/JS from widget settings */
}

/* ── Image layers
   IMPORTANT: Do NOT define transition or opacity here.
   All image animation states are owned by the JS runtime CSS
   (injected once on page load), keyed off [data-animation].
   Defining transitions here would create specificity races.
   The only safe defaults are structural/layout properties.
── */
.timeline-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* opacity / visibility / transition → JS runtime CSS */
}

.timeline-image.active {
  pointer-events: auto;
  /* opacity:1 / visibility:visible → JS runtime CSS */
}

/* No-JS fallback: if JS never runs, show first image */
.no-js .timeline-image:first-child {
  opacity: 1;
  visibility: visible;
}

.timeline-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  max-width: 100%;
  max-height: 100%;
}

/* ══════════════════════════════════════
   CONTENT AREA
══════════════════════════════════════ */
.timeline-content {
  flex: 0 0 50%;
  max-width: 50%;
  background: transparent;
  display: flex;
  flex-direction: column;
}

.timeline-content ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* ══════════════════════════════════════
   STEP ITEMS
══════════════════════════════════════ */
.timeline-step {
  padding: 15px 20px;
  cursor: pointer;
  border-radius: 6px;
  margin-bottom: 10px;
  outline: none;
  position: relative;
  background-color: transparent;
  border: 1px solid transparent;
  transition:
    background-color 0.25s ease,
    border-color     0.25s ease,
    transform        0.2s  ease;
}

.timeline-step:last-child {
  margin-bottom: 0;
}

.timeline-step:hover {
  background-color: #e6f0ff;
  transform: translateX(4px);
}

.timeline-step.active {
  background-color: #e6f0ff;
  border-color: #003a8c;
}

.timeline-step:focus-visible {
  outline: 2px solid #003a8c;
  outline-offset: 2px;
}

/* ── Title wrapper ── */
.timeline-step-title-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

/* ── Title ── */
.timeline-step h4 {
  margin: 0;
  color: #003a8c;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.4;
}

/* ── Description ── */
.timeline-step p {
  margin: 0;
  color: #555;
  font-size: 14px;
  line-height: 1.6;
}

/* ══════════════════════════════════════
   ICONS
══════════════════════════════════════ */
.timeline-step-icon {
  object-fit: contain;
  display: inline-block;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.timeline-step.active .timeline-step-icon {
  transform: scale(1.1);
}

/* ══════════════════════════════════════
   ACCESSIBILITY
══════════════════════════════════════ */
.timeline-step[role="tab"] {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

.timeline-step[role="tab"]:focus {
  position: relative;
  z-index: 1;
}

/* Reduced motion: override both static and JS runtime transitions */
@media (prefers-reduced-motion: reduce) {
  .timeline-image,
  .timeline-image.active,
  .timeline-image.leaving,
  .timeline-step,
  .timeline-step-icon {
    transition: none !important;
    animation:  none !important;
  }
}

/* ══════════════════════════════════════
   LOADING SHIMMER (empty src)
══════════════════════════════════════ */
.timeline-image img[src=""],
.timeline-image img:not([src]) {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: tl-shimmer 1.5s infinite;
}

@keyframes tl-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 768px) {
  .interactive-timeline.layout-left,
  .interactive-timeline.layout-right {
    flex-direction: column !important;
    gap: 20px;
  }

  /* All ratio variants → full width on mobile */
  .interactive-timeline .timeline-media,
  .interactive-timeline .timeline-content {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  .timeline-media {
    aspect-ratio: 16 / 9;
  }

  .timeline-step {
    padding: 12px 16px;
  }

  /* Disable the hover translateX nudge on touch */
  .timeline-step:hover {
    transform: none;
  }
}

@media (max-width: 480px) {
  .timeline-media  { aspect-ratio: 4 / 3; }

  .timeline-step h4 { font-size: 14px; }
  .timeline-step p  { font-size: 13px; }
}

/* ══════════════════════════════════════
   DARK MODE
══════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
  .timeline-step:hover,
  .timeline-step.active {
    background-color: rgba(0, 58, 140, 0.2);
  }

  .timeline-step h4 { color: #6ba3ff; }
  .timeline-step p  { color: #ccc; }
}

/* ══════════════════════════════════════
   RTL
══════════════════════════════════════ */
[dir="rtl"] .interactive-timeline.layout-left  { flex-direction: row-reverse; }
[dir="rtl"] .interactive-timeline.layout-right { flex-direction: row; }
[dir="rtl"] .timeline-step:hover               { transform: translateX(-4px); }
[dir="rtl"] .timeline-step-title-wrapper       { flex-direction: row-reverse; }

/* ══════════════════════════════════════
   PRINT
══════════════════════════════════════ */
@media print {
  .interactive-timeline { display: block; }

  .timeline-media,
  .timeline-content {
    width: 100%;
    flex: none;
  }

  /* Show all images in print (stacked) */
  .timeline-image {
    position: static;
    opacity: 1 !important;
    visibility: visible !important;
    page-break-inside: avoid;
  }

  .timeline-step {
    page-break-inside: avoid;
    background: transparent !important;
  }
}