/* =================================================================
   Riopele · 100 Years - TIMELINE, second half (1966 → 2026)
   Proposal layer. Loads AFTER css/styles.css and adds only:
     1. a unit + anchor system (--tl-u) that replaces the 0.xxx magic numbers
     2. the dormant generic kit (.tl-dark/.tl-cream/.tl-fig) revived and
        re-expressed height-relative so it scales with the bespoke panels
     3. three new archetypes - figure panel, register panel, era marker
     4. one thread rule: strokes at a fixed 50% of native, the invariant every
        segment of 1927–1963 already obeys, so the hairline weighs the same
   No panel carries a background - every page is the white of the rail.
   Merge into styles.css once approved; delete this file to revert.
   ================================================================= */

/* -----------------------------------------------------------------
   1 · UNIT + ANCHOR SYSTEM
   The existing panels all measure against a Figma canvas 900px tall,
   written as calc(var(--tl-h) * 0.341). One unit token makes the same
   value readable as the design number it came from: 307u.
   ----------------------------------------------------------------- */
.tl {
  --tl-u: calc(var(--tl-h) / 900); /* 1 Figma px */

  /* The rail gutter was the last viewport-relative measure in an otherwise
     height-relative system (clamp(2.5rem, 5vw, 7rem)). That is what stopped
     the thread joining cleanly: a segment spans "its panel + one gutter", so
     when the gutter drifts against the artboard the seam moves with it.
     Height-relative, the gutter is a constant 110 artboard px and every join
     is exact at every viewport. Visually it lands within ~17px of the old
     value at any width. */
  --tl-gap: calc(var(--tl-u) * 110);

  /* the invisible baseline grid the first half already obeys */
  --tl-top: calc(var(--tl-u) * 80); /* year row          (y 80)  */
  --tl-mid: calc(var(--tl-u) * 355); /* the 1958 mid-line (y 355) */
  --tl-foot: calc(var(--tl-u) * 40); /* copy foot         (y 860) */
  --tl-col: max(calc(var(--tl-u) * 280), 16rem); /* narrow copy column */
  --tl-col-w: max(calc(var(--tl-u) * 307), 17rem); /* wide copy column   */
}

/* -----------------------------------------------------------------
   2 · PANEL BASE
   Width comes from an inline --p-w in Figma px, so a panel's size lives
   next to its content instead of in a bespoke CSS block.
   ----------------------------------------------------------------- */
/* No panel carries a background: every page is the white of the rail, exactly
   like 1927–1963. */
.tl-p {
  width: calc(var(--tl-u) * var(--p-w, 1100));
  color: var(--p-ink, var(--ink));
}

/* The one exception, and it is not a panel colour: 2025 is a full-bleed
   photograph, so its copy sits ON the image and has to be light. */
.tl-p--onphoto {
  --p-ink: var(--bg);
  --p-dim: rgba(240, 237, 231, 0.78);
  --p-rule: rgba(240, 237, 231, 0.24);
}

/* absolute stage: children carry their own Figma coordinates.
   Replaces the per-panel percentage tables used by 1952 / 1953 / 1963. */
.tl-p--stage > *:not(.tl-fio) {
  position: absolute;
}
.tl-xy {
  left: calc(var(--tl-u) * var(--x, 0));
  top: calc(var(--tl-u) * var(--y, 0));
  width: calc(var(--tl-u) * var(--w, 280));
}
.tl-xy--r {
  left: auto;
  right: calc(var(--tl-u) * var(--r, 0));
}
.tl-xy--b {
  top: auto;
  bottom: calc(var(--tl-u) * var(--b, 0));
}

/* Copy rides above the thread. Stage children are already absolute and come
   after the fio in the DOM, so they paint above it; flex/grid children are
   statically positioned, which puts them BELOW a positioned fio and lets the
   yarn strike through the type. Same fix .tl-c1962__body already applies. */
.tl-p--num > :not(.tl-fio),
.tl-p--list > :not(.tl-fio),
.tl-p--twin > :not(.tl-fio),
.tl-p--flow > :not(.tl-fio) {
  position: relative;
  z-index: 1;
}

/* ---- columns: ONE anchor per column, contents flow ------------------
   Pinning two copy blocks in the same column - one at a fixed --y, one at a
   fixed --b - looks right at --tl-h 760 and collides at 540: the artboard
   compresses but the type does not (it is clamped against vw, not height).
   A column pinned top AND bottom distributes its own contents instead, which
   is exactly what .tl-c1962__body and .tl-c1965__col already do.
   Rule for new panels: never give two siblings in the same column separate
   vertical anchors - give the column one anchor and let it flow. */
.tl-col {
  left: calc(var(--tl-u) * var(--x, 0));
  top: calc(var(--tl-u) * var(--t, 80));
  bottom: calc(var(--tl-u) * var(--b, 40));
  width: calc(var(--tl-u) * var(--w, 300));
  display: flex;
  flex-direction: column;
  justify-content: var(--j, flex-start);
  gap: calc(var(--tl-u) * var(--g, 36));
}
.tl-col--between {
  --j: space-between;
}
.tl-col--end {
  --j: flex-end;
}
/* a child may be narrower than its column */
.tl-col > * {
  max-width: calc(var(--tl-u) * var(--cw, 4000));
}
.tl-row {
  display: flex;
  gap: calc(var(--tl-u) * var(--g, 40));
}

/* flow panel: a row of slots, gutters in Figma px */
.tl-p--flow {
  display: flex;
  align-items: flex-start;
}
.tl-p--flow > * {
  flex: 0 0 auto;
}
.tl-gut-24 {
  margin-left: calc(var(--tl-u) * 24);
}
.tl-gut-40 {
  margin-left: calc(var(--tl-u) * 40);
}
.tl-gut-100 {
  margin-left: calc(var(--tl-u) * 100);
}
.tl-gut-240 {
  margin-left: calc(var(--tl-u) * 240);
}
.tl-drop {
  margin-top: var(--tl-mid);
} /* land on the y355 mid-line */

/* -----------------------------------------------------------------
   3 · TYPE - the same three voices the first half uses, named once
   ----------------------------------------------------------------- */
.tl-y {
  /* the canonical 56px year */
  --w: 210; /* a year box only ever holds four digits - keeps it from
               reserving the 280u default and colliding to its right */
  font-weight: 300;
  font-size: clamp(2.5rem, 3.9vw, 3.5rem);
  line-height: 1;
  letter-spacing: 0;
}
/* 2026 - photos that sit in front of the one they overlap or touch */
.tl-p__fig--front {
  z-index: 2;
  /* where it overlaps the photo behind, the two show through each other -
     the multiply the 1952 plates use. On the white rail it changes nothing.
     Set on the figure, not the img: its z-index makes it a stacking context,
     so an img-level blend would only see the figure itself. */
  mix-blend-mode: multiply;
}
/* a year set on a photograph (2026) - light, lifted off the image */
.tl-y--onphoto {
  z-index: 2;
  color: var(--white);
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.45);
}
.tl-lead {
  /* the 24px opening sentence */
  font-size: clamp(1.05rem, 1.67vw, 1.5rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.tl-note {
  font-size: var(--fs-sm);
  line-height: 1.25;
}
.tl-note + .tl-note {
  margin-top: 1.5rem;
}
.tl-note strong,
.tl-strong {
  font-weight: 500;
}
.tl-dim {
  color: var(--p-dim, var(--gray));
}
.tl-brow {
  font-size: var(--fs-nav);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* -----------------------------------------------------------------
   4 · FIGURE + PLACEHOLDER
   No archive photography exists yet for 1966 → 2026. A figure with no
   <img> renders as a layout-true block printing its own brief, so the
   composition is reviewable now and dropping the photo in later is a
   one-line edit (uncomment the <img>).
   ----------------------------------------------------------------- */
.tl-p__fig {
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--ar, 3 / 4);
}
/* a figure that sits under copy in a .tl-col and takes the height that is
   left - it can never collide with the text, at any --tl-h (2015) */
.tl-p__fig--fill {
  aspect-ratio: auto;
  flex: 1 1 0;
  min-height: calc(var(--tl-u) * 160);
}
.tl-p__fig img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1s var(--ease);
}
.tl-p__fig:hover img {
  transform: scale(1.04);
}
/* .tl-p__fig is an aspect box with overflow:hidden, so it cannot carry a
   <figcaption> inside. Captions go next to it as a sibling .tl-brow -
   see 2007 ("Aged five, on the factory floor"). */

/* the brief, drawn in place of a missing photo */
.tl-p__fig:not(:has(img)) {
  display: grid;
  place-items: center;
  padding: 1.25rem;
  border: 1px solid var(--p-rule, var(--line));
  background-image: repeating-linear-gradient(
    45deg,
    rgba(27, 27, 27, 0.05) 0 6px,
    rgba(27, 27, 27, 0) 6px 13px
  );
}
.tl-p--onphoto .tl-p__fig:not(:has(img)) {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.07) 0 6px,
    rgba(255, 255, 255, 0) 6px 13px
  );
}
.tl-p__fig:not(:has(img))::after {
  content: attr(data-ph);
  font-size: var(--fs-nav);
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-align: center;
  text-wrap: balance;
  color: var(--p-dim, var(--gray-soft));
}

/* a full-bleed photo panel needs its copy to stay legible: the same
   bottom-up gradient .tl-dark::after already uses */
.tl-p__scrim {
  position: absolute;
  inset: 0;
  width: auto;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.78),
    rgba(0, 0, 0, 0) 62%
  );
  pointer-events: none;
}

/* -----------------------------------------------------------------
   5 · ARCHETYPE - FIGURE PANEL
   The second half of the story is told in numbers: €15M, €14M, 1800m²,
   98,4M, 30%, 90 years. The rail already has an oversized-numeral voice
   in .tl-end__num - this borrows it, one size down, so the closing "100"
   still reads as the largest number on the rail.
   ----------------------------------------------------------------- */
.tl-p--num {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--tl-top) calc(var(--tl-u) * 56) var(--tl-foot);
}
.tl-p__num {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(3.4rem, 7.6vw, 6rem);
  line-height: 0.86;
  letter-spacing: -0.03em;
}
.tl-p__num span {
  display: block;
  margin-top: 0.6rem;
  font-family: var(--font-sans);
  font-size: var(--fs-nav);
  font-weight: 500;
  line-height: 1.4; /* not the numeral's 0.86 - a two-line caption would touch */
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--p-ink, var(--ink));
}
.tl-p__nums {
  display: flex;
  flex-direction: column;
  gap: calc(var(--tl-u) * 52);
}
.tl-p--num .tl-note {
  max-width: 34ch;
}

/* -----------------------------------------------------------------
   6 · ARCHETYPE - REGISTER PANEL
   For the years that are a list, not a picture (1997 certifications,
   2018 awards). Hairline rows quoting the .fab__specs treatment.
   ----------------------------------------------------------------- */
.tl-p--list {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--tl-top) calc(var(--tl-u) * 48) var(--tl-foot);
}
.tl-p__reg {
  border-top: 1px solid var(--p-rule, var(--line));
}
.tl-p__reg li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--p-rule, var(--line));
  font-size: var(--fs-sm);
  line-height: 1.25;
  list-style: none;
}
.tl-p__reg li span:first-child {
  flex: 0 0 auto;
  width: 2.5em;
  font-variant-numeric: tabular-nums;
  color: var(--p-dim, var(--gray));
}

/* -----------------------------------------------------------------
   7 · ARCHETYPE - ERA MARKER
   A century in one drag needs rest stops. This is the 98px hairline box
   already used for the 1957 year, turned into a chapter divider: the eye
   gets a beat, and the reader gets told which era they have entered.
   ----------------------------------------------------------------- */
.tl-era {
  width: calc(var(--tl-u) * 98);
  border-inline: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--tl-top) var(--tl-foot);
}
/* stacked, the way 1958 already stacks 19 / 58 - a horizontal range would
   overflow a 98u box */
.tl-era__span {
  font-weight: 300;
  font-size: var(--fs-nav);
  letter-spacing: 0.1em;
  line-height: 1.6;
  text-align: center;
}
.tl-era__label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: var(--fs-nav);
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gray);
  white-space: nowrap;
}
.tl-era__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink);
}

/* -----------------------------------------------------------------
   8 · ARCHETYPE - TWIN
   1997 and 2002 each carry two separate events in the source deck.
   Rather than repeating a year label on two adjacent panels (which reads
   as a bug), one page splits down a hairline.
   ----------------------------------------------------------------- */
.tl-p--twin {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: calc(var(--tl-u) * 48);
  padding: var(--tl-top) calc(var(--tl-u) * 56) var(--tl-foot);
}
.tl-p__rule {
  background: var(--p-rule, var(--line));
}
.tl-p__half {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}
.tl-p__half .tl-p__fig {
  margin-top: auto;
}

/* -----------------------------------------------------------------
   9 · GENERIC KIT, REVIVED
   .tl-dark / .tl-cream / .tl-fig are already in styles.css but unused -
   left behind when the first half went bespoke. They are a good kit; the
   only thing wrong with them is that they size in viewport px while every
   newer panel sizes against the track height, so they drift out of
   proportion. Re-expressed in --tl-u they slot straight in.
   ----------------------------------------------------------------- */
.tl-dark.tl-p {
  width: calc(var(--tl-u) * var(--p-w, 1100));
  align-items: flex-end;
}
.tl-dark .tl-dark__cap p {
  color: var(--p-dim, rgba(255, 255, 255, 0.82));
  max-width: 32ch;
}
.tl-fig--u img {
  width: calc(var(--tl-u) * var(--fw, 280));
  height: calc(var(--tl-u) * var(--fh, 360));
  object-fit: cover;
}

/* -----------------------------------------------------------------
   10 · THREAD - one rule for every new segment
   The existing 10 segments each need their own CSS block because their
   `left` encodes an absolute Figma x on a 14,000px rail. These anchor to
   their own panel instead, so geometry is declared inline:
       style="--f-w:1180; --f-t:333"
   --f-w is the panel's own width; the segment is then stretched by one
   rail gap so it lands exactly on the next panel's leading edge, and the
   chain hands off with no vertical step.

   Only the 10%-alpha exports are used - the same files as 1927–1963 - and no
   filter, so the yarn reads as the identical faint hairline. (Cream #FAF7F2 at
   10% under mix-blend-mode:difference composites to about #E5E5E3 on white.
   fio-v3.png / fio-1.png ship at full alpha and would render near-black, so
   they are deliberately NOT used here.)

   ENTRY IS PINNED, TOP IS DERIVED. The rail gap is viewport-relative
   (clamp(2.5rem, 5vw, 7rem)) while everything else is height-relative, so a
   segment's rendered height moves with the viewport. Giving each segment a
   fixed `top` therefore shifted every join - and because each join fed the
   next, the error accumulated to ~46px by the end of the rail.
   Instead --f-in fixes the entry height in artboard units and `top` is
   computed back from the actual rendered height, so the entry is exact at any
   viewport and no error can propagate. Residual at the joins: <= 4px across
   the whole gap range.

   --f-in  entry height (u)      --f-w  panel width + overlap (u)
   --f-ar  PNG aspect ratio      --f-p0 where the stroke enters its own box
   ----------------------------------------------------------------- */
.tl-fio--x {
  /* Every stroke is placed at exactly HALF its native pixel size, which is the
     invariant all eleven segments of 1927–1963 obey (the PNGs are @2x exports).
     That is what fixes the hairline's THICKNESS - stretching a stroke to fit a
     panel makes the line thicker, and reads as a darker thread. Because the
     scale is fixed, each stroke has a fixed length and height in artboard
     units, so left/top/width/height are all plain numbers and nothing depends
     on the viewport. */
  left: calc(var(--tl-u) * var(--f-l, 0));
  top: calc(var(--tl-u) * var(--f-t));
  width: calc(var(--tl-u) * var(--f-w));
  height: calc(var(--tl-u) * var(--f-h));
}
/* mirrored vertically - doubles the vocabulary without new exports, and lets a
   descending stroke hand over to a climbing one with a matching tangent */
.tl-fio--flip {
  transform: scaleY(-1);
}

.tl-p,
.tl-era {
  position: relative; /* every new panel anchors its own thread */
}
/* 1965 was never given a fio anchor (styles.css only positions .tl-shot,
   .tl-c1957 and .tl-c1958), which is why the yarn dies after 1963 */
.tl-c1965 {
  position: relative;
}

/* -----------------------------------------------------------------
   11 · MOTION - register the new year class with the existing beats
   styles.css lists each year class explicitly (.tl-c1958__year, …) so a
   new panel silently loses its rise unless it is added. One shared class
   means one selector, for all 21 panels.
   ----------------------------------------------------------------- */
.tl.is-threaded .tl-panel .is-in .tl-y,
.tl.is-threaded .tl-panel .is-in .tl-p__num {
  animation: tlYear 0.9s var(--ease) 0.5s backwards;
}
/* a year that is itself a top-level block (1993, 2011, 2015) must keep the
   block's tlFade too - replacing it leaves the base opacity: 0 in force once
   tlYear ends, and the year vanishes */
.tl.is-threaded .tl-panel > .tl-y.is-in,
.tl.is-threaded .tl-panel > .tl-p__num.is-in {
  animation:
    tlFade 0.85s var(--ease) forwards,
    tlYear 0.9s var(--ease) 0.5s backwards;
}
.tl.is-threaded .tl-panel .is-in .tl-era__label {
  animation: tlYear 0.9s var(--ease) 0.35s backwards;
}

@media (prefers-reduced-motion: reduce) {
  .tl.is-threaded .tl-panel .is-in .tl-y,
  .tl.is-threaded .tl-panel > .tl-y.is-in,
  .tl.is-threaded .tl-panel .is-in .tl-p__num,
  .tl.is-threaded .tl-panel > .tl-p__num.is-in,
  .tl.is-threaded .tl-panel .is-in .tl-era__label {
    animation: none;
  }
}

/* -----------------------------------------------------------------
   12 · SMALL SCREENS
   The rail is already a drag surface, so panels keep their geometry; they
   only stop being wider than they need to be.
   ----------------------------------------------------------------- */
@media (max-width: 767px) {
  /* the twin panel keeps its two columns - stacking them would overflow a
     540px-tall rail, and the rail scrolls sideways anyway */
  .tl-p--twin {
    gap: calc(var(--tl-u) * 32);
  }
  /* the vertical label needs a little more room to breathe at small --tl-h */
  .tl-era {
    width: calc(var(--tl-u) * 140);
  }
}

/* -----------------------------------------------------------------
   13 · SHORT SCREENS
   The rail shrinks with the viewport height (--tl-h bottoms out at 540)
   but the type is clamped against the width, so on short laptop screens
   the longer copies - and the Portuguese, ~15% longer - spill out of their
   columns. Tighten the timeline's type there only.
   ----------------------------------------------------------------- */
@media (min-width: 768px) and (max-height: 820px) {
  .tl {
    --fs-sm: 0.78rem;
  }
  .tl-lead,
  .tl-c1957__lead,
  .tl-c1958__lead {
    font-size: clamp(0.95rem, 1.3vw, 1.2rem);
  }
  .tl-p__reg li {
    padding-block: 0.6rem;
  }
}
