/* ==========================================================================
   1 Poultry — History
   Figma: "History - Desktop" (351:11413), 1440 x 3597
   Sections: full-bleed hero → claret timeline ("Frame 161", 364:24925)
             → closing band ("Frame 33", 351:11419) → shared footer.

   The Figma lays the timeline out as an editorial scatter: six beats placed
   on an invisible twelve-column field, each one a date, an optional label,
   a short body and a photograph. Every absolute coordinate below has been
   converted to a real grid placement on that field.

   Two client revisions are folded in:
   1. the body copy of each beat is held at opacity 0 until that beat is
      hovered or focused — the "On-Hover" variant the Figma carries on
      "Headline text 1" (283:17413 → 283:17415) is a straight opacity fade
      in place, no travel, so that is what is reproduced here;
   2. the connector runs down the page's horizontal centre, not down the
      timeline's own column, with the beats laid out either side of it.
   ========================================================================== */


.history {
  /* Page-scoped steps the shared scale doesn't carry. The vw value hits the
     Figma size exactly at 1440px, the same way tokens.css does it. */
  --fs-date:    clamp(1.75rem, calc(2.778vw * var(--s)), 2.5rem);   /* Figma dates/labels, 40 @1440 */

  /* Frame 161's fill. Identical to the panel claret already named in
     building.css — flagged to the lead as a candidate for tokens.css. */

  /* The timeline field starts at x=122 in the Figma, not at --pad-x. */
  --hist-inset: clamp(1.25rem, calc(8.3333vw * var(--s)), 7.5rem);
  --hist-field: 74.75rem;                       /* 1440 − 2 × 122 */
  --hist-gap:   clamp(2.8125rem, calc(5.5556vw * var(--s)), 5rem);   /* Figma gaps run 69–119px */
  --hist-stack: clamp(0.75rem, calc(1.53vw * var(--s)), 1.375rem);    /* Figma leaves ~21px in-beat */

  /* The empty row the connector falls through, between the opening title
     and the first plate. Figma "Frame 161": the title's box ends at y=243
     and the map starts at y=416, so the two are 173px apart — that is this
     drop plus the row gap above and below it (22 + 129 + 22 at 1440). */
  --hist-drop:  clamp(3.875rem, calc(8.958vw * var(--s)), 8.0625rem);
}

/* ---------- 1. Hero (351:11414 image + 351:11417 tagline) -------------
   The Figma composes this as one 1440 x 1024 screen, so it rides the
   shared .screen / .screen__stage contract: the photograph is full-bleed
   media outside the stage, the type is the stage and scales with --fit. */
/* Two classes, not one: below 860 components.css zeroes min-height on any
   .screen that is not a .bleed, and this hero is a .screen carrying its own
   scrims rather than a .bleed. At one class it lost that match and the
   photograph collapsed to the height of its tagline. */
.hist-hero.screen {
  min-height: var(--vh-hero);      /* holds the full screen below 860 too */
  background: var(--c-black);
}

/* Overscan the bed so the parallax has somewhere to travel */
.hist-hero .screen__media { inset: -8% 0; }

/* Figma stacks a "Gradient Top" and a "Gradient Bottom" rect across the
   whole plate, and the centred type needs the middle held down as well.
   Three layers: the two shared scrims, then the wash between them. */
.hist-wash {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    var(--grad-scrim-top),
    var(--grad-scrim-bottom),
    linear-gradient(180deg,
      rgba(0, 0, 0, 0.00)  0%,
      rgba(0, 0, 0, 0.40) 38%,
      rgba(0, 0, 0, 0.40) 62%,
      rgba(0, 0, 0, 0.00) 100%);
}

.hist-hero__stage {
  display: grid;
  place-items: center;
  padding-inline: var(--pad-x);
}

/* Inside a stage the composition is the Figma one at 1440 and --fit is the
   only responsive step, so the fluid type scale is pinned to the sizes the
   file specifies — otherwise the clamp and the scale compound and the type
   arrives at half size on a short screen. Below 860 the stage is released
   and the fluid scale takes over again. */
@media (min-width: 861px) {
  .hist-hero__stage,
  .hist-close__stage {
    --fs-display: 3.4375rem;
    --fs-lead:    2rem;
    --fs-body:    1.5625rem;
    --fs-small:   1.25rem;
    --fs-xs:      1.125rem;
    --fs-micro:   1rem;
  }
}
/* data-hero-fade writes a transform, so it sits on this wrapper rather
   than on the stage, whose transform belongs to --fit. */
.hist-hero__type { text-align: center; }

.hist-hero__title {
  /* em so the two-line hero break survives the type scale — as px it
     collapsed to one line at 1024 and 768. */
  max-width: 11.6em;                /* Figma tagline box: 522px, 55/100% */
  margin-inline: auto;
}

/* ---------- 2. Timeline ("Frame 161", 364:24925) ---------------------- */
.hist-time {
  background: var(--c-claret);
  color: var(--c-white);
  padding-block: clamp(5rem, calc(11.1111vw * var(--s)), 10rem);
  padding-inline: var(--hist-inset);
  overflow-x: clip;
}

/* The field is centred inside a section that is padded equally, so its own
   centre line is the page's centre line — which is where the connector
   has to sit. It is also the containing block for that connector. */
.hist-field {
  position: relative;
  max-width: var(--hist-field);
  margin-inline: auto;
}

.hist-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: var(--hist-gap);
}

/* Every beat sits on the same twelve-column field. */
.hist-row {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gutter);
  align-items: start;
  row-gap: var(--hist-stack);
  outline-offset: 0.375rem;
}

/* ---- the connector (Frame 162, 364:24930) ---------------------------
   One 1.2px hairline on the page's horizontal centre, from just under the
   opening title (Frame 162 starts at y=264, 21px below the title's box) to
   the foot of the last beat. It runs BEHIND the photographs — the plates
   cross it, it does not cross them — and behind the type, both of which are
   lifted above it. Everywhere it is uncovered it reads against the claret. */
.hist-spine {
  position: absolute;
  left: 50%;
  translate: -50%;
  top: calc(var(--fs-date) * 1.22 * 2 + var(--hist-stack));
  bottom: 0;
  width: 1.2px;
  z-index: 0;
  pointer-events: none;
}
.hist-spine > span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--c-white);
  transform-origin: 50% 0;
}
/* Drawn by the page script. Without it (or with motion turned down) it
   simply stands at full height. */
html.hist-motion .hist-spine > span { transform: scaleY(0); }

/* ---- shared parts ---------------------------------------------------- */
.hist-date,
.hist-label,
.hist-copy,
.hist-note,
.hist-open__title {
  position: relative;
  z-index: 2;                      /* type reads over the connector */
}

.hist-date,
.hist-label {
  font-size: var(--fs-date);
  line-height: var(--lh-tight);
  will-change: transform;
}
.hist-date  > span { display: inline-block; }
.hist-date  > span,
.hist-label > span { --reveal-delay: 0ms; }
.hist-label > span { --reveal-delay: 110ms; }

/* ---- body copy: the beat's "On-Hover" state -------------------------
   Every beat component in the Figma holds its 20px body at opacity 0 and
   its On-Hover variant simply raises it to 1 — same box, same position,
   no travel. Dates, labels and photographs are untouched by the state.
   The copy is never display:none and never aria-hidden, so it stays in
   the accessibility tree and in find-in-page at all times. */
.hist-copy,
.hist-note {
  font-size: var(--fs-small);
  line-height: var(--lh-ui);
  max-width: 30ch;                 /* Figma bodies run 244–353px wide */
  opacity: 0;
  transition: opacity var(--dur-md) var(--ease-out-expo);
}
.hist-copy--right { text-align: right; margin-inline-start: auto; }

.hist-row:hover       .hist-copy,
.hist-row:hover       .hist-note,
.hist-row:focus-visible .hist-copy,
.hist-row:focus-visible .hist-note,
.hist-row:focus-within  .hist-copy,
.hist-row:focus-within  .hist-note { opacity: 1; }

/* Anything without a hovering pointer gets the copy outright — it must
   never be a state a touch user cannot reach. */
@media (hover: none) {
  .hist-copy,
  .hist-note { opacity: 1; }
}

/* ---- photographs -----------------------------------------------------
   A layer above the connector, below the type: each plate occludes the
   hairline where the two meet, which is the paint order the Figma shows. */
.hist-media { position: relative; z-index: 1; }

.hist-figure {
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--ar, 3 / 2);
  background: rgba(255, 255, 255, 0.07);
  transition: transform var(--dur-md) var(--ease-out-expo);
}
.hist-figure img {
  position: absolute;
  left: 0;
  top: -9%;
  width: 100%;
  height: 118%;                    /* headroom for the parallax */
  max-width: none;                 /* beat base.css's img { max-width:100% } */
  object-fit: cover;
  will-change: transform;
}
.hist-row:hover .hist-figure,
.hist-row:focus-visible .hist-figure { transform: scale(1.014); }

/* Claret curtain that draws off each plate as it arrives. Only armed once
   site.js is alive, so a script-less page still shows the photographs. */
.hist-figure::after {
  content: "";
  position: absolute;
  inset: -1px;
  background: var(--c-claret);
  transform: scaleY(0);
  transform-origin: 50% 100%;
  transition: transform var(--dur-xl) var(--ease-out-expo);
  pointer-events: none;
}
html.js-ready .hist-media .hist-figure::after         { transform: scaleY(1); }
html.js-ready .hist-media.is-in .hist-figure::after   { transform: scaleY(0); }

/* ---- the opening beat: AD 47 + 1746 share a row ---------------------- */
/* Figma: heading x=562 y=145, rule x=730 y=264, note x=128 y=416,
   map x=518 y=416 (635x421), "1746" x=1184 y=416, its copy y=746.
   Row 2 is the empty drop the connector falls through. */
.hist-open { grid-template-rows: auto var(--hist-drop) auto minmax(0, 1fr) auto; }

.hist-open__title { grid-column: 5 / 10;  grid-row: 1; font-size: var(--fs-date); line-height: var(--lh-snug); }
.hist-open__l    { display: block; }   /* Figma sets these as two text nodes */
.hist-open .hist-note { grid-column: 1 / 4;  grid-row: 3; }
.hist-open .hist-media{ grid-column: 4 / 10;  grid-row: 3 / 6; }
.hist-open .hist-date { grid-column: 10 / 13; grid-row: 3; }
.hist-open .hist-copy { grid-column: 10 / 13; grid-row: 5; }

/* ---- b — 1840s to 1920s (Component 3, 364:24933) --------------------- */
/* Figma: image x=128 (635x319), date x=796 y=0, copy y=253 */
.hist-entry--b { grid-template-rows: auto minmax(0, 1fr) auto; }
.hist-entry--b .hist-media { grid-column: 1 / 7;  grid-row: 1 / 4; }
.hist-entry--b .hist-date  { grid-column: 7 / 11; grid-row: 1; }
.hist-entry--b .hist-copy  { grid-column: 7 / 11; grid-row: 3; }

/* ---- c — 1960s/70s (Component 4, 364:24932) -------------------------- */
/* Figma: date x=122, copy x=423 right-aligned, image x=783 (301x421),
   label x=1108 */
.hist-entry--c { grid-template-rows: auto minmax(0, 1fr) auto; }
.hist-entry--c .hist-date  { grid-column: 1 / 4;   grid-row: 1; }
.hist-entry--c .hist-copy  { grid-column: 3 / 7;   grid-row: 3; }
.hist-entry--c .hist-media { grid-column: 7 / 10;  grid-row: 1 / 4; }
.hist-entry--c .hist-label { grid-column: 10 / 13; grid-row: 1; }

/* ---- d — Late 1980s (Component 5, 364:24934) -------------------------
   Label and copy start at column 7 rather than 6, so the centre lane
   stays clear of type. */
.hist-entry--d { grid-template-rows: auto minmax(0, 1fr) auto auto; }
.hist-entry--d .hist-media { grid-column: 1 / 6;  grid-row: 1 / 5; }
.hist-entry--d .hist-date  { grid-column: 7 / 11; grid-row: 1; }
.hist-entry--d .hist-label { grid-column: 7 / 11; grid-row: 3; }
.hist-entry--d .hist-copy  { grid-column: 7 / 11; grid-row: 4; }

/* ---- e — 1992 and 1997 flank one plate (Component 6, 364:24935) ------ */
/* Figma: "1992" x=203 y=0 with its copy below; image x=673 (301x421);
   "A landmark is born" x=1010 y=0; "1997" x=1005 y=74%; copy y=90.7% */
.hist-entry--e { grid-template-rows: auto auto minmax(0, 1fr) auto auto; }
.hist-entry--e .hist-date.is-l  { grid-column: 2 / 6;   grid-row: 1; }
.hist-entry--e .hist-copy.is-l  { grid-column: 2 / 6;   grid-row: 2; }
.hist-entry--e .hist-media      { grid-column: 6 / 9;   grid-row: 1 / 6; }
.hist-entry--e .hist-label      { grid-column: 10 / 13; grid-row: 1; }
.hist-entry--e .hist-date.is-r  { grid-column: 10 / 13; grid-row: 4; }
.hist-entry--e .hist-copy.is-r  { grid-column: 10 / 13; grid-row: 5; }

/* ---- f — 2016 (Component 7, 364:24936) ------------------------------- */
/* Figma: date x=137, image x=269 (301x421), label x=592 y=66.7%,
   copy x=592 y=83.1% — again pushed to column 7 to clear the connector. */
.hist-entry--f { grid-template-rows: auto minmax(0, 1fr) auto auto; }
.hist-entry--f .hist-date  { grid-column: 1 / 3;  grid-row: 1; }
.hist-entry--f .hist-media { grid-column: 3 / 6;  grid-row: 1 / 5; }
.hist-entry--f .hist-label { grid-column: 7 / 11; grid-row: 3; }
.hist-entry--f .hist-copy  { grid-column: 7 / 11; grid-row: 4; }

/* ---------- 3. Closing band ("Frame 33", 351:11419) -------------------
   The Figma frame is an empty black rectangle — a placeholder. Filled with
   the closing pattern every other page ends on, on the black it specifies,
   and held to one screen by the shared .screen contract. Flagged to the
   lead.                                                                  */
.hist-close {
  background: var(--c-black-true);
  color: var(--c-white);
}
.hist-close__stage {
  display: grid;
  place-items: center;
  padding-inline: var(--pad-x);
}
.hist-close__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.25rem, calc(2.0833vw * var(--s)), 1.875rem);
  text-align: center;
}
.hist-close__title { max-width: 47.5rem; }
.hist-close .btn { will-change: transform; }

/* ---------- Responsive ------------------------------------------------ */
@media (max-width: 1200px) {
  /* the field tightens, so the right-aligned copy gets a column back */
  .hist-entry--c .hist-copy { grid-column: 2 / 7; }
}

/* Below the desktop field the scatter has nowhere to go: every beat becomes
   one column — plate, then date, label and copy beneath it. The connector
   stays on the page's centre and the stacked blocks pass in front of it. */
@media (max-width: 1024px) {
  .hist-time { padding-inline: var(--pad-x); }

  .hist-row,
  .hist-open,
  .hist-entry {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    row-gap: clamp(0.9375rem, calc(1.3889vw * var(--s)), 1.25rem);
  }
  .hist-row > * { grid-column: 1 !important; grid-row: auto !important; }

  /* Stacked, the type is what the connector would otherwise run through.
     A claret backing (the section's own colour, so it is invisible) lets
     each block occlude the line instead of being sliced by it. */
  .hist-date,
  .hist-label,
  .hist-copy,
  .hist-note,
  .hist-open__title {
    background: var(--c-claret);
    padding-block: 2px;
  }

  /* Centre the plates so the connector runs down the middle of each. */
  .hist-open__title { max-width: 22ch; }
  /* Definite width, not max-width: an auto-margined grid item stops
     stretching, so a shrink-to-fit box would collapse the aspect ratio.
     The third term caps the plate by height instead of width, so a whole
     beat still clears the fold on a short screen. */
  .hist-open .hist-media,
  .hist-entry .hist-media {
    width: min(100%, 38.75rem, calc(calc(46svh * var(--s)) * var(--ar)));
    margin-inline: auto;
  }
  .hist-open .hist-media--tall,
  .hist-entry .hist-media--tall { width: min(100%, 22.5rem, calc(calc(46svh * var(--s)) * var(--ar))); }

  /* Stacked there is no grid row to hold the opening drop, so the note
     carries it — the connector still starts in clear space under the
     title rather than on top of it. */
  .history { --hist-drop: clamp(3.5rem, calc(8vw * var(--s)), 6rem); }
  .hist-open .hist-note { margin-top: var(--hist-drop); }

  /* Stacked, every beat reads date → plate → label → copy. The opening
     block already sits in that order in the markup, so it is left alone. */
  .hist-entry .hist-date  { order: 0; }
  .hist-entry .hist-media { order: 1; }
  .hist-entry .hist-label { order: 2; }
  .hist-entry .hist-copy  { order: 3; }

  .hist-copy--right { text-align: left; margin-inline-start: 0; }
  .hist-copy, .hist-note { max-width: 56ch; }

  /* the pair keeps both beats: 1992 and its copy, then the plate, then 1997 */
  .hist-entry--e .hist-date.is-l { order: 0; }
  .hist-entry--e .hist-copy.is-l { order: 1; }
  .hist-entry--e .hist-media     { order: 2; }
  .hist-entry--e .hist-label     { order: 3; }
  .hist-entry--e .hist-date.is-r { order: 4; }
  .hist-entry--e .hist-copy.is-r { order: 5; }
}

@media (max-width: 860px) {
  /* .screen has released its one-screen contract by here, so the closing
     band needs its own breathing room back. */
  .hist-close__stage { padding-block: clamp(5rem, calc(8.3333vw * var(--s)), 7.5rem); }
}

@media (max-width: 768px) {
  .hist-hero .screen__media { inset: -5% 0; }
  .hist-figure img { top: -6%; height: 112%; }
  .hist-time { padding-block: clamp(3.75rem, calc(5.5556vw * var(--s)), 5rem); }
}

@media (max-width: 480px) {
  .hist-close__inner { gap: 1.25rem; }
}

/* A calm page for anyone who asked for one: everything visible, nothing
   moving — the body copy included, since a hover it cannot animate into
   is a hover it should not depend on. */
@media (prefers-reduced-motion: reduce) {
  .hist-figure::after,
  html.js-ready .hist-media .hist-figure::after { transform: scaleY(0) !important; }
  .hist-figure img { top: 0; height: 100%; }
  .hist-spine > span { transform: none !important; }
  .hist-copy,
  .hist-note { opacity: 1 !important; transition: none; }
  .hist-row:hover .hist-figure,
  .hist-row:focus-visible .hist-figure { transform: none; }
}

/* ---------- Vertical rhythm on a phone — see --sec-y ------------------- */
@media (max-width: 860px) {
  .hist-time         { padding-block: var(--sec-y); }
  .hist-close__stage { padding-block: var(--sec-y); }
}
