/* ============================================================
   Aura Viva — Timeline (Infinita)
   ============================================================
   Full-screen overlay. Vertical spine: left-edge on phones,
   centered with alternating cards on desktop. Moments fade in
   on scroll (.is-in, IntersectionObserver in timeline.js).

   Style knobs (owner-chosen, applied as classes on .av-tl):
     fonts     av-tl--font-serif | -sans | -hand
     palettes  av-tl--bg-marfil | -lino | -salvia | -rosa | -noche | -carbon
   ============================================================ */

html.av-tl-lock,
html.av-tl-lock body {
  overflow: hidden;
}

.av-tl {
  position: fixed;
  inset: 0;
  /* Android: the first scroll collapses the URL bar and GROWS the viewport —
     an inset:0 overlay lags a few frames and briefly exposes the gallery in
     the new strip at the bottom. Size to the LARGE viewport so the overlay
     always already covers it. (vh ≈ large viewport on Android Chrome; lvh is
     the explicit unit where supported.) */
  height: 100vh;
  height: 100lvh;
  z-index: 1900; /* below the lightbox (2000) so moments open on top */
  background: var(--tl-bg, #f6f1e7);
  color: var(--tl-ink, #2c332f);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.av-tl.is-open { opacity: 1; }

/* ---- Palettes (curated — no free picker) ---- */
.av-tl--bg-marfil { --tl-bg: #F6F1E7; --tl-bg-2: #EFE6D6; --tl-ink: #2C332F; --tl-muted: rgba(44,51,47,0.62); --tl-line: #C79A3F; --tl-card: #FFFFFF; }
.av-tl--bg-lino   { --tl-bg: #F4F1EB; --tl-bg-2: #EAE5DB; --tl-ink: #3A362F; --tl-muted: rgba(58,54,47,0.62);  --tl-line: #8A6D4F; --tl-card: #FFFFFF; }
.av-tl--bg-salvia { --tl-bg: #ECF0E7; --tl-bg-2: #DDE5D6; --tl-ink: #2C3A2A; --tl-muted: rgba(44,58,42,0.62);  --tl-line: #7A9A6E; --tl-card: #FDFDFB; }
.av-tl--bg-rosa   { --tl-bg: #F6EAE8; --tl-bg-2: #EFDCD8; --tl-ink: #3A2A2E; --tl-muted: rgba(58,42,46,0.62);  --tl-line: #A8475B; --tl-card: #FFFDFC; }
.av-tl--bg-noche  { --tl-bg: #232B26; --tl-bg-2: #1A211D; --tl-ink: #F4ECDD; --tl-muted: rgba(244,236,221,0.6); --tl-line: #C79A3F; --tl-card: #2E3731; }
.av-tl--bg-carbon { --tl-bg: #26262A; --tl-bg-2: #1C1C20; --tl-ink: #EFEAE2; --tl-muted: rgba(239,234,226,0.6); --tl-line: #C79A3F; --tl-card: #303036; }

.av-tl {
  background-image: linear-gradient(170deg, var(--tl-bg), var(--tl-bg-2, var(--tl-bg)));
}

/* ---- Fonts ---- */
.av-tl--font-serif { --tl-font: 'EB Garamond', Georgia, 'Times New Roman', serif; --tl-title-weight: 500; }
.av-tl--font-sans  { --tl-font: 'Quattrocento Sans', 'Segoe UI', system-ui, sans-serif; --tl-title-weight: 700; }
.av-tl--font-hand  { --tl-font: 'Caveat', 'Segoe Script', cursive; --tl-title-weight: 600; }
.av-tl { font-family: var(--tl-font, serif); }
/* Handwritten reads small — scale it up a touch. */
.av-tl--font-hand { font-size: 1.15em; }

/* ---- Scroll container ---- */
.av-tl__scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(26px + env(safe-area-inset-top)) 18px calc(40px + env(safe-area-inset-bottom));
}

/* ---- Close ---- */
.av-tl__close {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  width: 42px;
  height: 42px;
  border-radius: 999px;
  /* plain fallbacks first — color-mix lines below win where supported */
  border: 1px solid rgba(127, 127, 127, 0.35);
  background: rgba(127, 127, 127, 0.15);
  border: 1px solid color-mix(in srgb, var(--tl-ink) 22%, transparent);
  background: color-mix(in srgb, var(--tl-bg) 82%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--tl-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 3;
  -webkit-tap-highlight-color: transparent;
}
.av-tl__close svg { width: 20px; height: 20px; }

/* ---- Play/pause (auto-advance every 3s) ---- */
.av-tl__playbtn {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 52px;
  height: 52px;
  border-radius: 999px;
  border: 1px solid rgba(127, 127, 127, 0.35);
  border: 1px solid color-mix(in srgb, var(--tl-line) 55%, transparent);
  background: var(--tl-card, #fff);
  color: var(--tl-line);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 3;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.av-tl__playbtn:hover { transform: translateX(-50%) translateY(-1px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22); }
.av-tl__playbtn.is-playing {
  background: var(--tl-line);
  color: var(--tl-card, #fff);
}
.av-tl__playbtn svg { width: 22px; height: 22px; }

/* ---- Head ---- */
.av-tl__head {
  max-width: 680px;
  margin: 26px auto 8px;
  text-align: center;
  padding: 0 30px;
}
.av-tl__title {
  margin: 0;
  font-family: var(--tl-font);
  font-weight: var(--tl-title-weight, 500);
  font-size: clamp(30px, 6vw, 44px);
  line-height: 1.15;
  letter-spacing: 0.4px;
}
.av-tl__subtitle {
  margin-top: 8px;
  font-size: clamp(15px, 2.6vw, 18px);
  color: var(--tl-muted);
  letter-spacing: 1.6px;
  text-transform: uppercase;
}
.av-tl--font-hand .av-tl__subtitle { text-transform: none; letter-spacing: 0.4px; }
.av-tl__rule {
  width: 56px;
  height: 2px;
  margin: 18px auto 0;
  background: var(--tl-line);
  opacity: 0.85;
  border-radius: 2px;
}

/* ---- Spine + items (phone-first: spine on the left) ---- */
.av-tl__list {
  position: relative;
  max-width: 760px;
  margin: 26px auto 0;
  padding: 10px 0 10px 26px;
}
.av-tl__list::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 7px;
  width: 2px;
  background: var(--tl-line); /* fallback if color-mix is unsupported */
  background: linear-gradient(
    to bottom,
    transparent,
    color-mix(in srgb, var(--tl-line) 55%, transparent) 6%,
    color-mix(in srgb, var(--tl-line) 55%, transparent) 94%,
    transparent
  );
}

.av-tl__item {
  position: relative;
  margin: 0 0 34px;
}
.av-tl__dot {
  position: absolute;
  left: -26px;
  top: 10px;
  width: 12px;
  height: 12px;
  margin-left: 2px;
  border-radius: 50%;
  background: var(--tl-line);
  box-shadow: 0 0 0 4px rgba(127, 127, 127, 0.14);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--tl-line) 18%, transparent);
}

/* Reveal */
.av-tl__item {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 0.9, 0.3, 1);
}
.av-tl__item.is-in {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .av-tl__item { opacity: 1; transform: none; transition: none; }
  .av-tl { transition: none; }
}

/* ---- Card ---- */
.av-tl__card { max-width: 420px; }

.av-tl__date {
  font-size: 15px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--tl-line);
  font-weight: 600;
  margin-bottom: 8px;
}
.av-tl--font-hand .av-tl__date { text-transform: none; letter-spacing: 0.5px; font-size: 19px; }

/* Moment title — the headline under the date label. */
.av-tl__mtitle {
  font-family: var(--tl-font);
  font-weight: var(--tl-title-weight, 500);
  font-size: 22px;
  line-height: 1.2;
  margin: -2px 0 10px;
}
.av-tl--font-hand .av-tl__mtitle { font-size: 27px; }

.av-tl__media {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--tl-card);
  border-radius: 6px;
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.14), 0 14px 34px rgba(0, 0, 0, 0.10);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
/* Polaroid-esque frame around the photo */
.av-tl__media img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 62vh;
  object-fit: cover;
  border: 8px solid var(--tl-card);
  border-radius: 6px;
  box-sizing: border-box;
}
.av-tl__media:active { transform: scale(0.994); }

.av-tl__play,
.av-tl__micbadge {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(20, 20, 22, 0.55);
  color: #fff;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  pointer-events: none;
}
.av-tl__play svg { width: 20px; height: 20px; }
.av-tl__micbadge { width: 32px; height: 32px; }
.av-tl__micbadge svg { width: 17px; height: 17px; }

/* Standalone voice note — a quiet mic medallion */
.av-tl__media--audio {
  aspect-ratio: 5 / 3;
  display: grid;
  place-items: center;
  background: var(--tl-card); /* fallback */
  background:
    radial-gradient(120% 120% at 50% 0%, color-mix(in srgb, var(--tl-line) 14%, transparent), transparent 70%),
    var(--tl-card);
}
.av-tl__mic {
  width: 74px;
  height: 74px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--tl-line);
  border: 2px solid var(--tl-line);
  background: transparent;
  border: 2px solid color-mix(in srgb, var(--tl-line) 55%, transparent);
  background: color-mix(in srgb, var(--tl-line) 8%, transparent);
}
.av-tl__mic svg { width: 34px; height: 34px; }

.av-tl__caption {
  margin-top: 10px;
  font-size: 17px;
  line-height: 1.45;
  color: var(--tl-ink);
}
.av-tl--font-hand .av-tl__caption { font-size: 21px; }

/* ---- Footer flourish ---- */
.av-tl__end {
  text-align: center;
  font-size: 26px;
  color: var(--tl-line);
  opacity: 0.7;
  margin: 8px 0 26px;
}

/* ---- Desktop: centered spine, alternating sides ---- */
@media (min-width: 900px) {
  .av-tl__list {
    padding-left: 0;
    max-width: 980px;
  }
  .av-tl__list::before {
    left: 50%;
    margin-left: -1px;
  }
  .av-tl__item {
    width: 50%;
    padding-right: 54px;
    box-sizing: border-box;
    margin-bottom: 44px;
  }
  .av-tl__item .av-tl__card { margin-left: auto; text-align: right; }
  .av-tl__item .av-tl__dot {
    left: auto;
    right: -7px;
    top: 12px;
    margin-left: 0;
  }
  .av-tl__item--alt {
    margin-left: 50%;
    padding-right: 0;
    padding-left: 54px;
  }
  .av-tl__item--alt .av-tl__card { margin-left: 0; margin-right: auto; text-align: left; }
  .av-tl__item--alt .av-tl__dot { right: auto; left: -7px; }
}
