/* =========================================================================
   Timeline — [yk_timeline]
   Infographic-style horizontal timeline: text nodes hung below a single
   horizontal spine line, with optional header trim and an optional keyword
   footer.

   Layering (unchanged from the original build):
   1. BASE (this file, no JS): usable on its own. Desktop = horizontally
      scrollable row; mobile (<768px) = vertical stack with a vertical line.
   2. ENHANCEMENT (.is-pinned, added by assets/js/timeline.js): the section
      grows tall and the viewport sticks while the track is scrubbed
      horizontally by vertical scroll. Purely additive.

   Colour rule: every colour is a theme.json token (var(--wp--preset--color--…)),
   never a raw hex here. Node accent = --tl-node-color (set inline per <li>).
   ========================================================================= */

.yk-timeline {
  /* Layout tokens — tune spacing/sizing here, not in JS. */
  --tl-node-w: clamp(220px, 22vw, 300px);
  --tl-gap: clamp(2rem, 5vw, 5rem);
  --tl-inline-pad: clamp(1.5rem, 6vw, 6rem);
  --tl-block-pad: clamp(3rem, 8vh, 6rem);

  /* theme.json colour tokens (with safe fallbacks). */
  --tl-ink: var(--wp--preset--color--ink, #0a0a0a);
  --tl-mute: var(--wp--preset--color--mute, #6b6b6b);
  --tl-paper: var(--wp--preset--color--paper, #f6f3ec);
  --tl-white: var(--wp--preset--color--white, #ffffff);
  --tl-dark: var(--wp--preset--color--timeline-dark, #053B06);
  /* Node accent — overridden inline on each <li> (--tl-node-color). */
  --tl-node-color: var(--wp--preset--color--timeline-dark, #053B06);

  /* Own your layout: render at the theme's Gutenberg wide-width, NOT the parent
     block's width. `--wp--style--global--wide-size` is theme.json's
     settings.layout.wideSize (1200px here; kept as a fallback). We break out of
     whatever wrapper we're in with the classic `50% - 50vw` term, then re-centre
     a wideSize-wide box in the VIEWPORT. Result: a bare shortcode, a `default`
     group, and a `constrained` group all resolve to the SAME width, so the pin's
     fit-test stays honest — viewport.clientWidth is always min(wideSize, 100vw),
     never collapsed to a narrow parent, and track.scrollWidth (intrinsic
     max-content) vs viewport.clientWidth fires the pin identically everywhere.
     Capped at 100vw so it never exceeds the screen (full width on mobile). */
  --tl-wide: var(--wp--style--global--wide-size, 1200px);
  width: min(var(--tl-wide), 100vw);
  margin-inline: calc(50% - 50vw + (100vw - min(var(--tl-wide), 100vw)) / 2);

  position: relative;
  /* Transparent: the backdrop is controlled by the Gutenberg block/group
     background (or a CSS override). Nodes/badges/line keep their own colours. */
  background: transparent;
  color: var(--tl-ink);
}

/* --- Viewport: the scroll/clip container ------------------------------- */
.yk-timeline__viewport {
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* keep the track at its intrinsic width */
  gap: clamp(1.75rem, 4vh, 3rem);
  overflow-x: auto;
  overflow-y: hidden;
  /* Cosmetic top/bottom breathing room only — NOT an input to the pin height
     (JS drives scroll length from window height + track/viewport WIDTHS). Top is
     halved per team feedback ("too much space above"); bottom keeps the full
     token. Both stay responsive via the clamp in --tl-block-pad. */
  padding-top: calc(var(--tl-block-pad) / 2);
  padding-bottom: var(--tl-block-pad);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  overscroll-behavior-x: contain;
}

/* --- Header trim (centered; stays put while the row scrolls) ----------- */
.yk-timeline__head {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 100%;
  padding-inline: var(--tl-inline-pad);
  text-align: center;
}

.yk-timeline__heading {
  margin: 0;
  color: var(--tl-dark);
  font-family: var(--wp--preset--font-family--heading);
  font-size: var(--wp--preset--font-size--x-large);
  font-weight: 600;
  line-height: 3.6rem;
  letter-spacing: 0.01em;
}

.yk-timeline__subheading {
  display: flex;
  flex-wrap: wrap; /* let the rules/text drop to the next line on narrow screens */
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1rem;
  margin: 0.75rem 0 0;
  color: var(--tl-dark);
}

.yk-timeline__subheading-text {
  /* Fluid: comfortable on desktop (caps at the theme's "small" preset), smaller
     floor on mobile. No nowrap — the line wraps to 2 lines on narrow screens
     instead of overflowing the full-bleed section and forcing page scroll. */
  max-width: 100%;
  font-family: var(--wp--preset--font-family--heading);
  font-size: clamp(0.7rem, 0.58rem + 0.7vw, var(--wp--preset--font-size--small));
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.125em;
  text-transform: uppercase;
  text-wrap: balance; /* even 2-line wrapping where supported */
}

/* decorative flanking rules with a dot at the inner end
.yk-timeline__rule {
  position: relative;
  height: 2px;
  width: clamp(2rem, 10vw, 8rem);
  background: currentColor;
  opacity: 0.85;
}
.yk-timeline__rule::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  transform: translateY(-50%);
}
.yk-timeline__rule:first-child::after {
  right: -3px;
}
.yk-timeline__rule:last-child::after {
  left: -3px;
}
   */

/* --- Track + list: the row of nodes and the connecting line ------------ */
.yk-timeline__track {
  flex: 0 0 auto;
  width: max-content;
  min-width: 100%;
}

.yk-timeline__list {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--tl-gap);
  margin: 0;
  padding: 0 var(--tl-inline-pad);
  list-style: none;
}

/* The single solid connecting line — a horizontal "spine" across the top of
   the row of nodes (the node bodies hang below it). */
.yk-timeline__list::before {
  content: "";
  position: absolute;
  left: var(--tl-inline-pad);
  right: var(--tl-inline-pad);
  top: 0;
  height: 3px;
  background: #D4A03D;
  z-index: 0;
}

/* --- Node -------------------------------------------------------------- */
.yk-timeline__node {
  position: relative;
  z-index: 1;
  flex: 0 0 var(--tl-node-w);
  width: var(--tl-node-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* icon is knocked out (white) on the colored badge, driven by currentColor
.yk-timeline__icon {
  display: grid;
  place-items: center;
  width: 48%;
  height: 48%;
  color: #D4A03D;
}
.yk-timeline__icon svg {
  display: block;
  width: 100%;
  height: 100%;
}
  */

.yk-timeline__body {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.yk-timeline__label {
  margin: 0 0 0.25rem;
  color: var(--tl-dark);
  font-family: var(--wp--preset--font-family--sans, system-ui, sans-serif);
  font-size: var(--wp--preset--font-size--sm, 14px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.yk-timeline__title {
  margin: 0 0 0.75rem;
  color: var(--tl-dark);
  font-family: var(--wp--preset--font-family--heading);
  font-size: var(--wp--preset--font-size--large);
  font-weight: 600;
  line-height: 1.15em;
  letter-spacing: 0.02em;
  white-space: pre-line;
}

.yk-timeline__desc {
  margin: 0;
  color: var(--tl-ink);
  font-size: var(--wp--preset--font-size--sm, 14px);
  line-height: 1.6;
  white-space: pre-line;
}

/* --- Optional sub-sections (e.g. STAY / MEALS) ------------------------- */
.yk-timeline__sections {
  margin: 1.25rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.yk-timeline__section {
  margin: 0;
}
.yk-timeline__section-label {
  margin: 0 0 0.25rem;
  color: var(--tl-dark);
  font-family: var(--wp--preset--font-family--sans, system-ui, sans-serif);
  font-size: var(--wp--preset--font-size--xs, 12px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.yk-timeline__section-value {
  margin: 0;
  color: var(--tl-ink);
  font-size: var(--wp--preset--font-size--sm, 14px);
  line-height: 1.5;
  white-space: pre-line;
}

/* --- Keyword footer strip --------------------------------------------- */
.yk-timeline__foot {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 100%;
  padding-inline: var(--tl-inline-pad);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}
.yk-timeline__keywords {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.yk-timeline__keyword {
  position: relative;
  color: var(--tl-dark);
  font-family: var(--wp--preset--font-family--sans, system-ui, sans-serif);
  font-size: var(--wp--preset--font-size--sm, 14px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.yk-timeline__keyword + .yk-timeline__keyword::before {
  content: "";
  position: absolute;
  left: -0.7rem;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  transform: translateY(-50%);
}
/* decorative wavy end rules */
.yk-timeline__wave {
  flex: 1 1 0;
  min-width: 2rem;
  max-width: 16rem;
  height: 8px;
  background:
    radial-gradient(
      circle at 25% 120%,
      transparent 70%,
      currentColor 71% 78%,
      transparent 79%
    ),
    radial-gradient(
      circle at 75% -20%,
      transparent 70%,
      currentColor 71% 78%,
      transparent 79%
    );
  background-size: 32px 16px;
  background-repeat: repeat-x;
  opacity: 0.9;
}
.yk-timeline__wave--left {
  color: var(--wp--preset--color--timeline-green, #2f7d40);
}
.yk-timeline__wave--right {
  color: var(--wp--preset--color--timeline-blue, #2b6e9f);
}

/* Keyboard/focus affordance. */
.yk-timeline__node:focus-visible {
  outline: 2px solid var(--tl-node-color);
  outline-offset: 6px;
  border-radius: 6px;
}

/* =========================================================================
   ENHANCEMENT — pinned horizontal scroll (desktop, JS adds .is-pinned)
   ========================================================================= */
/* --yk-header-h is set by the JS: the live overlap of whatever is actually
   covering the top of the viewport (measured by hit-testing, so it works for a
   fixed <div>/<nav>/<header> alike), so the pinned timeline never hides under a
   fixed/sticky site header. To override the auto-measurement on a site with an
   unusual header, set --yk-timeline-offset-top (a px length) on the section or
   :root. */
.yk-timeline.is-pinned .yk-timeline__viewport {
  position: sticky;
  top: var(--yk-header-h, 0px);
  height: calc(100vh - var(--yk-header-h, 0px));
  overflow: hidden; /* JS drives the transform instead of native scroll */
  justify-content: center;
}

.yk-timeline.is-pinned .yk-timeline__track {
  will-change: transform;
}

/* =========================================================================
   MOBILE (<768px) — vertical stack; also the natural no-JS fallback.
   ========================================================================= */
@media (max-width: 767px) {
  .yk-timeline__viewport {
    overflow: visible;
    padding-inline: clamp(1.25rem, 6vw, 2rem);
    gap: clamp(1.5rem, 6vw, 2.5rem);
  }

  .yk-timeline__track {
    width: 100%;
    min-width: 0;
  }

  .yk-timeline__head,
  .yk-timeline__foot {
    position: static;
    padding-inline: 0;
  }

  .yk-timeline__list {
    flex-direction: column;
    align-items: stretch;
    gap: clamp(2rem, 8vw, 3rem);
    padding: 0;
  }

  /* spine becomes a vertical rail down the left of the stacked nodes */
  .yk-timeline__list::before {
    left: 0;
    right: auto;
    top: 0;
    bottom: 0;
    width: 3px;
    height: auto;
  }

  .yk-timeline__node {
    flex: 0 0 auto;
    width: 100%;
    align-items: flex-start;
    padding-left: 1.5rem; /* clear the vertical rail */
    text-align: left;
  }

  .yk-timeline__body {
    margin-top: 0;
    align-items: flex-start;
    text-align: left;
  }

  .yk-timeline__foot {
    margin-top: 0.5rem;
    flex-wrap: wrap;
  }
  .yk-timeline__wave {
    display: none;
  }
}

/* =========================================================================
   Reduced motion — never pin/scrub; fall back to the plain base layout.
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  .yk-timeline.is-pinned {
    height: auto !important;
  }
  .yk-timeline.is-pinned .yk-timeline__viewport {
    position: static;
    height: auto;
    overflow-x: auto;
    justify-content: flex-start;
  }
  .yk-timeline.is-pinned .yk-timeline__track {
    transform: none !important;
    will-change: auto;
  }
}
