/* ============================================================================
   Notre histoire — the scroll-driven photo album.

   This file adds NO colours and NO typefaces. Every value below is either a
   token from the site's design system (--teal-txt, --serif, --s4, --rhythm …)
   or geometry.

   Three deliberate exceptions, all of them already the system's own values:
     • #fff and rgba(255,255,255,…) — the white of a photographic print, used
       exactly as the design system uses it.
     • the #19776D → #0A2621 gradient on the album cover — copied verbatim from
       the footer, so the cover and the footer are the same cloth.
     • color-mix() on --clay for the shaded side of a pushpin.
   Anything else that is a raw hex or a font-family is a bug.

   Classes are prefixed h- where the design system already owns the name.
   .pin, .wrap, .kick, .btn, .rv are deliberately the system's, not ours.
   ========================================================================= */

body.hist {
  background-color: var(--cream);
  /* the paper ground: a fibre texture, barely there */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='260' height='260' filter='url(%23p)' opacity='0.055'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='700' height='700'%3E%3Cfilter id='q'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.008' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='700' height='700' filter='url(%23q)' opacity='0.05'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- layering */
.hist main { position: relative; z-index: 2; }
.hist footer { position: relative; z-index: 2; }
.h-year {
  position: fixed; inset: 0; z-index: 0; display: grid; place-items: center;
  pointer-events: none; overflow: hidden;
}
.h-year i {
  font-style: normal; display: flex; gap: .01em;
  font-family: var(--serif); font-weight: 500;
  font-size: min(44vw, 560px); line-height: .78;
  letter-spacing: -.05em; color: transparent;
  -webkit-text-stroke: 2px var(--ink); opacity: .07;
  font-variant-numeric: tabular-nums;
}
.h-yd { display: block; height: .78em; overflow: hidden; width: .58em; }
.h-yd b {
  display: block; font-weight: inherit;
  transition: transform 1.05s cubic-bezier(.2, .7, .3, 1);
}
.h-yd b span { display: block; height: .78em; text-align: center; }

/* -------------------------------------------------------- the album cover */
/* pin height + travel, so the cover finishes opening exactly as the section
   ends. Anything taller leaves a blank stretch after it. */
.h-alb { position: relative; height: calc(100svh + 540px); z-index: 3; }
/* A long perspective. At 2400px a full-viewport panel rotating about its left
   edge is magnified so hard that it leaves the screen by about 50 degrees;
   at 6000px it turns like a cover instead of exploding past the camera. */
.h-alb .pin { background: transparent; display: block; perspective: 6000px; }
.h-cov {
  position: absolute; inset: 0; transform-origin: left center;
  /* -82deg, not -100: the cover is edge-on well before a right angle, and past
     66 degrees there is nothing left to see; the rest is the physical scroll. It is never faded out — once it
     has finished opening the pin releases and the cover physically scrolls
     away, which is what stops a blank screen appearing behind it. */
  transform: rotateY(calc(var(--o, 0) * -66deg));
  background:
    radial-gradient(110% 80% at 18% 0%, rgba(255, 255, 255, .12) 0%, transparent 58%),
    linear-gradient(150deg, #19776D 0%, #14655C 22%, #0F4B44 54%, #0B3A34 80%, #0A2621 100%);
  display: grid; place-items: center; text-align: center;
  box-shadow: var(--e2);
}
/* the spine, and the shadow the opening cover throws across the page beneath */
.h-cov::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 26px;
  background: linear-gradient(90deg, rgba(0, 0, 0, .38), rgba(0, 0, 0, 0));
}
.h-cov::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, .34) 0%, rgba(0, 0, 0, 0) 34%);
  opacity: calc(var(--o, 0) * 1);
}
.h-covin { position: relative; z-index: 2; padding: 0 var(--gut); }
.h-covin .lbl { color: rgba(255, 255, 255, .68); }
.h-covtitle {
  font-family: var(--serif); font-weight: 500; color: #fff;
  font-size: var(--t-h1); line-height: var(--lh-display);
  letter-spacing: var(--ls-tight); margin: var(--s4) 0 0;
}
.h-covhint {
  position: absolute; left: 0; right: 0; bottom: var(--s6); z-index: 3;
  text-align: center; color: rgba(255, 255, 255, .72);
  font: 500 var(--t-micro)/1 var(--mono);
  letter-spacing: var(--ls-wider); text-transform: uppercase;
  opacity: calc(1 - var(--o, 0) * 2.6);
}
.h-covhint s { display: block; width: 1px; height: 34px; margin: 12px auto 0;
  background: rgba(255, 255, 255, .5); border: 0; }

/* ------------------------------------------------------------- l'ouverture */
.h-ouv { padding: var(--s6) 0 var(--rhythm); text-align: center; }
.h-ouv h1 {
  font-family: var(--serif); font-weight: 500; color: var(--ink);
  font-size: var(--t-h1); line-height: var(--lh-display);
  letter-spacing: -.035em; margin: var(--s4) 0 0;
}
.h-ouv p {
  margin: var(--s5) auto 0; max-width: 30ch;
  font-size: var(--t-h4); font-weight: 300; line-height: var(--lh-snug);
  color: var(--ink2);
}
.h-ouv .kick { justify-content: center; }

/* ------------------------------------------------------------- a chapter */
.h-ch { position: relative; height: var(--h, 300vh); }
.h-ch .pin {
  background: transparent; display: block; overflow: visible;
  height: 100svh; padding: 0;
}
/* width:100% is load-bearing. Without it the grid is sized from its tracks'
   max-content and the whole chapter shrink-wraps to about 920px. */
.h-in {
  width: 100%; height: 100%; max-width: var(--max); margin: 0 auto;
  padding: 0 var(--gut);
  display: grid; grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
  gap: clamp(32px, 4.4vw, 78px); align-items: center;
}
.h-ch.rev .h-in { grid-template-columns: minmax(0, 1.14fr) minmax(0, 0.86fr); }
.h-ch.rev .h-tx { order: 2; }
/* the two collage chapters give the pinboard more room than the prose */
.h-ch.coll .h-in { grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.35fr); }

/* the text column */
.h-tx { position: relative; }
.h-meta {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font: 500 var(--t-micro)/1 var(--mono);
  letter-spacing: var(--ls-wider); text-transform: uppercase; color: var(--teal-txt);
}
.h-meta s { text-decoration: none; height: 1px; width: 34px; background: var(--hair); }
.h-tx h2 {
  font-family: var(--serif); font-weight: 500; color: var(--ink);
  font-size: var(--t-h2); line-height: var(--lh-head); letter-spacing: -.034em;
  margin: var(--s3) 0 0; max-width: 15ch;
}
.h-body { margin-top: var(--s5); max-width: 46ch; }
.h-body p {
  font-size: var(--t-body); line-height: var(--lh-body); font-weight: 300;
  color: var(--ink2);
}
.h-body p + p { margin-top: var(--s3); }
.h-body strong { font-weight: 600; color: var(--ink); }
/* each rendered line is wrapped by the script, then lifted in on scroll */
.h-l { display: block; opacity: 0; transform: translateY(14px);
  transition: opacity .5s cubic-bezier(.2, .7, .3, 1), transform .5s cubic-bezier(.2, .7, .3, 1); }
.h-l.on { opacity: 1; transform: none; }

/* --------------------------------------------------------- the ink stamp */
.h-stamp {
  position: absolute; z-index: 6; top: calc(-1 * var(--s6)); left: -6px;
  transform: rotate(var(--srot, -7deg)) scale(var(--ss, 1));
  opacity: var(--so, 0);
  padding: 9px 16px 8px; color: var(--teal-txt);
  font: 500 var(--t-micro)/1 var(--mono);
  letter-spacing: var(--ls-wider); text-transform: uppercase;
  will-change: transform, opacity;
}
/* the frame is eroded like a rubber stamp; the word itself stays solid, so the
   contrast figure in HISTOIRE-NOTES.md is the one the reader actually gets */
.h-stamp::before {
  content: ''; position: absolute; inset: 0; border: 2.5px solid currentColor;
  border-radius: 3px;
  -webkit-mask-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='60'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.34' numOctaves='4'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0.9 0 0 0 0.24'/%3E%3C/filter%3E%3Crect width='120' height='60' filter='url(%23s)'/%3E%3C/svg%3E");
  mask-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='60'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.34' numOctaves='4'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0.9 0 0 0 0.24'/%3E%3C/filter%3E%3Crect width='120' height='60' filter='url(%23s)'/%3E%3C/svg%3E");
  -webkit-mask-size: 120px 60px; mask-size: 120px 60px;
}

/* ------------------------------------------------------------- the prints */
.h-art { position: relative; display: grid; place-items: center; }

.h-print {
  position: relative; margin: 0; background: #fff;
  transform: rotate(var(--rot, 0deg));
  box-shadow: 0 1px 2px rgba(20, 32, 30, .06), 0 22px 44px -22px rgba(6, 20, 18, .34);
  max-width: 100%;
}
.h-print.po { padding: 15px 15px 76px; }          /* Polaroid: deep bottom border */
.h-print.mm { padding: 11px 11px 52px; }          /* 35 mm print: thin border */
.h-print.sm { padding: 9px 9px 40px; }

.h-img {
  position: relative; overflow: hidden; background: var(--sand);
  aspect-ratio: var(--ar, 4 / 3);
}
.h-img > picture, .h-img > .h-ph { position: absolute; inset: 0; display: block; }
.h-img img {
  width: 100%; height: 100%; object-fit: cover;
  object-position: var(--op, 50% 50%); transform: scale(var(--sc, 1));
}
.h-img.fit img { object-fit: contain; background: #fff; }

/* the print developing: a white veil burns off and the image resolves */
.h-dev {
  position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: linear-gradient(170deg, var(--paper) 0%, var(--cream) 60%, var(--sand) 100%);
  opacity: calc(1 - var(--d, 1));
}
.h-img .h-ph, .h-img picture { filter: saturate(calc(.25 + var(--d, 1) * .75))
  contrast(calc(.72 + var(--d, 1) * .28)); }
/* grain, on the print rather than on the page */
.h-img::after {
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  opacity: .09; mix-blend-mode: multiply;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23g)'/%3E%3C/svg%3E");
}

/* the handwriting, sitting on the print's own border */
.h-cap {
  position: absolute; left: 0; right: 0; bottom: 0; height: 76px;
  display: grid; place-items: center; color: var(--ink);
  padding: 0 14px;
}
.h-print.mm .h-cap { height: 52px; }
.h-print.sm .h-cap { height: 40px; }
.h-cap .h-ink { position: absolute; display: block; transform: rotate(var(--crot, -1.2deg)); }
.h-cap .h-ink.b { opacity: 0; }
.h-cap svg { display: block; overflow: visible; }

/* attachments: tape, pushpin, paperclip */
.h-tape {
  position: absolute; z-index: 4; width: 116px; height: 34px;
  background: linear-gradient(180deg, rgba(220, 240, 236, .78), rgba(190, 226, 219, .62));
  border-left: 1px solid rgba(255, 255, 255, .5); border-right: 1px solid rgba(255, 255, 255, .5);
  box-shadow: 0 2px 6px rgba(20, 32, 30, .10);
  /* torn ends */
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 116 34' preserveAspectRatio='none'%3E%3Cpath d='M4 0 L112 2 L108 7 L114 12 L109 18 L114 24 L110 30 L113 34 L6 32 L2 27 L7 21 L1 15 L6 9 L1 4 Z' fill='%23fff'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 116 34' preserveAspectRatio='none'%3E%3Cpath d='M4 0 L112 2 L108 7 L114 12 L109 18 L114 24 L110 30 L113 34 L6 32 L2 27 L7 21 L1 15 L6 9 L1 4 Z' fill='%23fff'/%3E%3C/svg%3E");
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
}
.h-tape.butter { background: linear-gradient(180deg, rgba(246, 231, 180, .80), rgba(233, 208, 137, .64)); }
.h-tape.tl { top: -15px; left: -24px; transform: rotate(-26deg); }
.h-tape.tr { top: -17px; right: -26px; transform: rotate(24deg); }
.h-tape.tc { top: -16px; left: 50%; margin-left: -58px; transform: rotate(-3deg); }
.h-tape.bl { bottom: -14px; left: -22px; transform: rotate(18deg); }

.h-punaise {
  position: absolute; z-index: 5; top: -13px; left: 50%; margin-left: -13px;
  width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, var(--teal-lt) 0%, var(--teal) 42%, var(--teal-deep) 100%);
  box-shadow: 0 4px 8px rgba(20, 32, 30, .32), inset 0 -2px 3px rgba(0, 0, 0, .22);
}
.h-punaise.orange {
  background: radial-gradient(circle at 34% 30%, var(--butter) 0%, var(--clay) 52%,
    color-mix(in srgb, var(--clay) 62%, var(--ink)) 100%);
}
.h-trombone {
  position: absolute; z-index: 5; top: -26px; left: 26px; width: 26px; height: 62px;
  transform: rotate(-9deg);
}
.h-trombone svg { width: 100%; height: 100%; display: block; }

/* the two-moment prints of chapters 4 and 6 */
.h-dis { width: min(100%, 600px); }

/* ------------------------------------------------------------ photo credit
   A photograph we did not take. The credit lives INSIDE the .h-ph it belongs
   to, so on a dissolve it fades in and out with that one frame and can never
   end up crediting the other photograph. Paper chip rather than bare text:
   over an unknown photograph, only an opaque ground guarantees the contrast
   (--ink on near-solid --paper, 14:1). No new colour, no new face. */
.h-cred {
  position: absolute; right: 10px; bottom: 10px; z-index: 3;
  background: rgba(253, 251, 247, .92); color: var(--ink);
  border-radius: var(--r-pill); padding: 5px 11px;
  font: 500 var(--t-micro)/1 var(--mono); letter-spacing: var(--ls-snug);
  white-space: nowrap;
}

/* --------------------------------------------------------- the key figure */
.h-kfig {
  position: absolute; z-index: 7; pointer-events: none;
  font-family: var(--serif); font-weight: 500; color: var(--teal-deep);
  font-size: clamp(58px, 7.4vw, 122px); line-height: .84; letter-spacing: -.05em;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  text-shadow: 0 2px 22px rgba(247, 244, 235, .9), 0 0 44px rgba(247, 244, 235, .8);
  transform: rotate(var(--krot, -2deg));
}
.h-kfig u {
  display: block; text-decoration: none; margin-top: 10px;
  font: 500 var(--t-micro)/1.35 var(--mono);
  letter-spacing: var(--ls-wider); text-transform: uppercase;
  color: var(--teal-txt); white-space: normal; max-width: 13ch;
}
.h-kfig.tl { top: -.22em; left: -.30em; }
.h-kfig.bl { bottom: 34px; left: -.34em; }
.h-kfig.br { bottom: 22px; right: -.24em; text-align: right; }
.h-kfig.br u { margin-left: auto; }

/* --------------------------------------------------------- the collages */
.h-coll { position: relative; width: 100%; }
/* room at the top so the key figure sits above the pinboard and only clips
   the edge of the first row, the way a note added later would */
.h-ch.coll .h-coll { margin-top: clamp(38px, 4.4vw, 82px); }
/* An explicit grid, not `columns`. In a multicol container an absolutely
   positioned child (the washi tape) can be orphaned into the next column
   fragment, which strands a strip of tape in mid-air. */
.h-coll.five {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: clamp(16px, 2vw, 34px); align-items: start;
}
.h-coll.five > figure { width: 100%; margin: 0; }
.h-coll.five > figure:nth-of-type(1) { grid-area: 1 / 1; }                    /* le carnet   */
.h-coll.five > figure:nth-of-type(2) { grid-area: 2 / 1; }                    /* les cafés   */
.h-coll.five > figure:nth-of-type(3) { grid-area: 1 / 2; margin-top: 6%; }    /* le téléphone*/
.h-coll.five > figure:nth-of-type(4) { grid-area: 1 / 3 / 3 / 4; align-self: center; } /* le badge */
.h-coll.five > figure:nth-of-type(5) { grid-area: 2 / 2; margin-top: 4%; }    /* la poignée  */
.h-coll.three {
  display: grid; grid-template-columns: 1.25fr 1fr;
  grid-template-rows: auto auto; gap: clamp(18px, 2.4vw, 40px);
  align-items: start;
}
.h-coll.three > figure:nth-of-type(1) { grid-row: 1 / 3; align-self: center; }
/* the key figure lives inside the pinboard so it clips the first print's
   corner rather than floating in the empty column above it */
.h-coll > .h-kfig { margin: 0; width: auto; }
.h-ch.coll .h-kfig.tl { top: -.86em; left: -.20em; }

/* ------------------------------------------------------------- la fin */
.h-fin { padding: var(--rhythm) 0 calc(var(--rhythm) + 20px); text-align: center; }
.h-fin h2 {
  font-family: var(--serif); font-weight: 500; color: var(--ink);
  font-size: var(--t-h2); line-height: var(--lh-head); letter-spacing: -.032em;
  max-width: 20ch; margin: var(--s4) auto 0;
}
.h-links {
  display: flex; gap: var(--s2); justify-content: center; flex-wrap: wrap;
  margin-top: var(--s6);
}

/* ------------------------------------------------------- screen-reader text
   Every handwritten caption is also here as real text. */
.vh {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ================================================================ mobile
   No pinning. Chapters stack, the dissolves stay scroll-linked, the collages
   drop to two columns. */
@media (max-width: 1060px) {
  .h-ch { height: auto; }
  .h-ch .pin { position: static; height: auto; padding: var(--rhythm) 0; }
  .h-in {
    grid-template-columns: 1fr !important; gap: var(--s6); align-items: start;
  }
  .h-ch.rev .h-tx { order: 0; }
  .h-stamp { position: static; display: inline-block; margin-bottom: var(--s4);
    transform: rotate(var(--srot, -7deg)); }
  .h-alb { height: 120vh; }
  .h-coll.five { grid-template-columns: 1fr 1fr; }
  .h-coll.five > figure:nth-of-type(n) { grid-area: auto; margin-top: 0; }
  .h-coll.three { grid-template-columns: 1fr 1fr; }
  .h-coll.three > figure:nth-of-type(1) { grid-row: auto; grid-column: 1 / 3; }
  .h-kfig { font-size: clamp(52px, 15vw, 92px); }
  .h-kfig.tl { top: -.18em; left: -.16em; }
  .h-kfig.bl { left: -.18em; }
  .h-kfig.br { right: -.12em; }
  .h-year i { font-size: 62vw; }
  .h-print.po { padding: 11px 11px 58px; }
  .h-cap { height: 58px; }
}

@media (max-width: 600px) {
  .h-coll.five { gap: 14px; }
  .h-tape { width: 86px; height: 26px; }
}

/* ============================================================ motion off
   Everything static. Both halves of each dissolve are shown side by side, so
   nothing is lost by not being able to scrub through time. */
@media (prefers-reduced-motion: reduce) {
  .h-alb { height: auto; }
  .h-alb .pin { position: static; height: auto; perspective: none; }
  .h-cov { position: relative; transform: none; min-height: 62vh; padding: var(--rhythm) 0; }
  .h-cov::after { display: none; }
  .h-covhint { display: none; }
  .h-ch { height: auto; }
  .h-ch .pin { position: static; height: auto; padding: var(--rhythm) 0; }
  .h-l { opacity: 1; transform: none; }
  .h-stamp { opacity: 1; transform: rotate(var(--srot, -7deg)); }
  .h-dev { display: none; }
  .h-img .h-ph, .h-img picture { filter: none; }
  .h-cap .h-ink.b { opacity: 1; }
  /* Both moments of a dissolve, side by side inside the one print. Nobody
     who cannot scrub through time should lose half the story. */
  .h-dis { width: 100%; }
  .h-dis .h-img {
    aspect-ratio: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    background: transparent;
  }
  .h-dis .h-img > .h-ph {
    position: relative; inset: auto; aspect-ratio: 4 / 3; overflow: hidden;
    opacity: 1 !important;
  }
  .h-dis .h-img::after { display: none; }
  .h-dis .h-cap {
    position: relative; left: auto; right: auto; bottom: auto; height: auto;
    padding: 14px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  }
  .h-dis .h-cap .h-ink { position: relative; justify-self: center; }
  .h-dis .h-print.po { padding-bottom: 18px; }
  .h-year i { opacity: .05; }
}
