/* ============================================================
   Timeline Hero – Frontend CSS  v2.1
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400&family=Playfair+Display:wght@400;700&display=swap');

:root {
  --th-accent:      #e8c97a;
  --th-accent-rgb:  232, 201, 122;
  --th-text:        #f5f0e8;
  --th-ctrl-bg:     rgba(8, 8, 8, .72);
  --th-ctrl-border: rgba(255, 255, 255, .08);
  --th-font-title:  'Playfair Display', Georgia, serif;
  --th-font-ui:     'DM Mono', 'Courier New', monospace;
  --th-strong-color:   #ffffff;
  --th-strong-family:  'DM Mono', monospace;
}

/* ── Contenitore ─────────────────────────────────────────── */
.timeline-hero {
  position: relative;
  width: 100%;
  height: var(--th-height, 100vh);
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: flex-end;
  container-type: inline-size;
}

.timeline-hero.alignfull  { width: 100vw; margin-left: calc(50% - 50vw); }
.timeline-hero.alignwide  { width: 100%; }

/* ── Media Stack ─────────────────────────────────────────── */
.th-media-stack {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.th-media-item {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(1.06);
  will-change: opacity, transform;
}
.th-media-item.is-active { opacity: 1; transform: scale(1); }

.th-image,
.th-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  pointer-events: none;
  user-select: none;
}

.th-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(0,0,0,.6) 100%);
  pointer-events: none;
}

/* ── Testi ───────────────────────────────────────────────── */
.th-content-wrap {
  position: relative;
  z-index: 10;
  width: 100%;
  padding: 0 5% 156px;
  pointer-events: none;
  text-align: var(--th-text-align, left);
}

.th-labels {
  position: relative;
  min-height: 8rem;
}

.th-label {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  will-change: opacity, transform;
}

.th-label.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.th-title {
  /*font-family: var(--th-font-title);*/
  font-size: clamp(2.4rem, 7cqi, 5.5rem);
  font-weight: 700;
  color: var(--th-text);
  line-height: 1.08;
  letter-spacing: -.02em;
  margin: 0;
  text-shadow: 0 2px 24px rgba(0,0,0,.55);
}

.th-subtitle {
  font-family: var(--th-font-ui);
  font-size: clamp(.8rem, 1.8cqi, 1.05rem);
  font-weight: 300;
  color: var(--th-accent);
  letter-spacing: .2em;
  text-transform: uppercase;
  margin: 0;
}

.th-title strong {
  color:       var(--th-strong-color, #fff);
  font-family: var(--th-strong-family);
  font-weight: 400;
}

.th-subtitle strong {
  color:       var(--th-strong-color, #fff);
  font-family: var(--th-font-title);
  font-weight: 700;
  font-style:  italic;
  letter-spacing: 0;
}

/* ── Controller ──────────────────────────────────────────── */
.th-controller {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: 20px 5% 28px;
  background: var(--th-ctrl-bg);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border-top: 1px solid var(--th-ctrl-border);
}

/* ── Steps nav wrapper ───────────────────────────────────── */
.th-steps-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

/* Scroll container — nasconde l'overflow */
.th-steps-scroll {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Fade bordi quando scrollabile */
.th-steps-scroll.has-overflow::before,
.th-steps-scroll.has-overflow::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 32px;
  pointer-events: none;
  z-index: 2;
}
.th-steps-scroll.has-overflow::before {
  left: 0;
  background: linear-gradient(to right, var(--th-ctrl-bg), transparent);
}
.th-steps-scroll.has-overflow::after {
  right: 0;
  background: linear-gradient(to left, var(--th-ctrl-bg), transparent);
}

/* ── Step row ────────────────────────────────────────────── */
.th-steps-row {
  display: flex;
  align-items: flex-end;
  /* larghezza btn impostata via JS in base agli slot */
}

/* ── Step buttons ────────────────────────────────────────── */
.th-step-btn {
  flex: 0 0 auto;
  /* width impostata via JS */
  background: none;
  border: none;
  padding: 0 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,.3);  /* fisso — gestisce GSAP */
  font-family: var(--th-font-ui);
  font-size: clamp(.58rem, 1.4cqi, .76rem);
  letter-spacing: .1em;
  text-transform: uppercase;
  outline: none;
}

.th-step-btn:focus-visible { outline: 1px solid var(--th-accent); }

/* Dot — layer base grigio fisso */
.th-step-dot {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.3);  /* NON currentColor */
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

/* Dot fill — layer dorato animato da GSAP */
.th-step-dot__fill {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--th-accent);
  transform: scaleX(0);
  transform-origin: left center;
}

/* Label */
.th-step-label {
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  max-width: 100%;
}

.th-step-label__base {
  display: block;
  color: rgba(255,255,255,.3);
  text-overflow: ellipsis;
  overflow: hidden;
}

/* Label fill — layer dorato animato da GSAP */
.th-step-label__fill {
  position: absolute;
  inset: 0;
  color: var(--th-accent);
  clip-path: inset(0 100% 0 0);
  white-space: nowrap;
  pointer-events: none;
}

/* ── Frecce navigazione ──────────────────────────────────── */
.th-steps-arrow {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--th-ctrl-border);
  color: rgba(255,255,255,.5);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .2s, border-color .2s, opacity .2s;
  padding: 0;
}
.th-steps-arrow:hover      { color: var(--th-accent); border-color: var(--th-accent); }
.th-steps-arrow.is-hidden  { opacity: 0; pointer-events: none; }

/* ── Track a segmenti ────────────────────────────────────── */
.th-slider-wrap {
  position: relative;
  height: 4px;
  display: flex;
  align-items: center;
  overflow: hidden;   /* ← nasconde il track che va fuori */
}

.th-track {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 4px;
  pointer-events: none;
  z-index: 0;
  /* larghezza totale = 100% * (total / slots) quando overflow */
  width: 100%;
}

.th-track-segment {
  flex: 1;
  height: 100%;
  background: rgba(255,255,255,.15);
  border-radius: 2px;
  overflow: hidden;
}

.th-track-segment__fill {
  height: 100%;
  width: 100%;
  background: var(--th-accent);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left center;
}

/* ── Slider ──────────────────────────────────────────────── */
.th-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: transparent;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  position: relative;
  z-index: 1;
  margin: 0;
}

.th-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--th-accent);
  border: 3px solid rgba(0,0,0,.55);
  box-shadow: 0 0 0 0 rgba(var(--th-accent-rgb), .35);
  cursor: pointer;
  transition: box-shadow .25s, transform .25s;
  display: none;
}

.th-slider:hover::-webkit-slider-thumb,
.th-slider:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 8px rgba(var(--th-accent-rgb), .18);
  transform: scale(1.15);
}

.th-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--th-accent);
  border: 3px solid rgba(0,0,0,.55);
  cursor: pointer;
}

.th-slider::-moz-range-track {
  background: transparent;
  height: 4px;
}

/* ── Admin notice ────────────────────────────────────────── */
.timeline-hero-notice {
  padding: 1rem 1.5rem;
  background: #fff3cd;
  border-left: 4px solid #ffc107;
  font-family: sans-serif;
  font-size: .9rem;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 767px) {
  .th-content-wrap  { padding-bottom: 148px; }
  .th-controller    { padding: 14px 4% 22px; }
}

@media (max-width: 480px) {
  /* Su mobile nasconde label dei btn non attivi */
  .th-step-btn:not(.is-active) .th-step-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .th-media-item { transition: none !important; }
}