/* DM Sans and Instrument Sans (SIL Open Font License, see fonts/OFL-*.txt), served by the
   site itself: one variable file per family and character range. */
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(fonts/dm-sans-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(fonts/dm-sans-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400 600;
  font-stretch: 100%;
  font-display: swap;
  src: url(fonts/instrument-sans-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400 600;
  font-stretch: 100%;
  font-display: swap;
  src: url(fonts/instrument-sans-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --bg: #F2F0EC;
  --text: #141312;
  --text-2: #5A5854;
  --text-3: #6E6B68;
  --rule: #D3CFC8;
  --rule-soft: #E4E1DB;
  --select: rgba(20, 19, 18, 0.12);

  --font-display: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
  --font-text: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif;

  --rail: 7.5rem;
  --gutter: 3.5rem;
  --measure: 37rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141312;
    --text: #ECEBE8;
    --text-2: #A09F9C;
    --text-3: #858381;
    --rule: #363432;
    --rule-soft: #292725;
    --select: rgba(236, 235, 232, 0.12);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141312;
  --text: #ECEBE8;
  --text-2: #A09F9C;
  --text-3: #858381;
  --rule: #363432;
  --rule-soft: #292725;
  --select: rgba(236, 235, 232, 0.12);
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.65;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-inline: clamp(16px, 5vw, 72px);
}

::selection { background: var(--select); }

.essay {
  max-width: 68rem;
  margin-inline: auto;
  padding-block: clamp(40px, 9vh, 96px) clamp(32px, 6vh, 64px);
  display: flex;
  flex-direction: column;
}

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

.rail {
  min-width: 0;
  justify-self: end;
  width: min(var(--rail), 100%);
  text-align: right;
}
.col { min-width: 0; }

.masthead {
  padding-block: 0 clamp(2.5rem, 8vh, 4.5rem);
}

.masthead .col {
  display: flex;
  justify-content: center;
}

.masthead h1 {
  margin: 0;
  line-height: 0;
}

.lockup {
  display: block;
  width: clamp(9rem, 7rem + 5vw, 12rem);
  height: auto;
  color: var(--text);
}

.coda {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.break {
  width: 2.25rem;
  height: 0;
  margin: 1.4em 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.signoff {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--text-2);
}

.body {
  display: flex;
  flex-direction: column;
  gap: 1.35em;
}

.body p {
  margin: 0;
  text-wrap: pretty;
  hyphens: manual;
}

.closing {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.25rem, 1.05rem + 0.8vw, 1.625rem);
  line-height: 1.25;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

.closing span { display: block; }
.coda .closing { text-wrap: balance; }

.colophon {
  margin-top: clamp(3.5rem, 10vh, 6rem);
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule-soft);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem 2.5rem;
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  width: 100%;
  gap: 0.25rem 2rem;
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.meta a {
  color: var(--text-2);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: color 120ms ease, border-color 120ms ease;
}

.meta a:hover { color: var(--text); border-color: var(--text-3); }

.place {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}

.pin {
  width: 0.95em;
  height: 0.95em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.meta a:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 2px;
}

.rights {
  display: inline-flex;
  align-items: center;
  gap: 0.75em;
}

/* Theme button: one glyph at the end of the colophon; without scripts it is not shown */
.theme-toggle {
  position: relative;
  display: inline-flex;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  border-radius: 2px;
  transition: color 120ms ease;
}
.theme-toggle::after { content: ""; position: absolute; left: 50%; top: 50%; width: 24px; height: 24px; transform: translate(-50%, -50%); }
.theme-toggle:hover { color: var(--text); }
.theme-toggle:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.theme-toggle svg { width: 0.95em; height: 0.95em; fill: none; stroke: currentColor; stroke-width: 1.6; }
.theme-toggle svg .half { fill: currentColor; stroke: none; }
:root:not(.js) .theme-toggle { display: none; }

@media (min-width: 52rem) {
  body { font-size: 1.0625rem; }
}

@media (max-width: 51.999rem) {
  .row {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 1.75rem;
  }
  .rail:empty { display: none; }
  .meta { flex-direction: column; align-items: flex-start; gap: 0.35rem; }
  .rail { justify-self: start; width: auto; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .meta a, .theme-toggle { transition: none; }
}

@media print {
  @page { size: A4; margin: 22mm 24mm 20mm; }

  :root,
  :root:not([data-theme="light"]),
  :root[data-theme="dark"] {
    color-scheme: light;
    --bg: #FFFFFF;
    --text: #141312;
    --text-2: #3A3936;
    --text-3: #5A5854;
    --rule: #BDBAB4;
    --rule-soft: #D3CFC8;
  }

  body { font-size: 10.5pt; line-height: 1.55; padding-inline: 0; }
  .essay { max-width: none; padding-block: 0; }
  .row { grid-template-columns: minmax(0, 1fr); column-gap: 0; }
  .rail { display: none; }
  .masthead { padding-block: 0 12mm; }
  .lockup { width: 40mm; }
  .body { gap: 0.9em; }
  .body p { orphans: 3; widows: 3; }
  .coda { break-inside: avoid; }
  .closing { font-size: 14pt; }
  .colophon { margin-top: 10mm; max-width: none; break-inside: avoid; }
  .meta a { color: var(--text-2); border-bottom: 0; }
  .theme-toggle { display: none; }
}


/* 1. Entrée typographique */
@keyframes enter-rise {
  from { opacity: 0; transform: translateY(0.5rem); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .enter {
    animation: enter-rise 560ms cubic-bezier(0, 0, 0.2, 1) both;
    animation-delay: calc(120ms + var(--i, 0) * 90ms);
  }
  .enter.i1 { --i: 1; }
  .enter.i2 { --i: 2; }
  .enter.i3 { --i: 3; }
  .enter.i4 { --i: 4; }
  .enter.i5 { --i: 5; }
  .enter.i6 { --i: 6; }
  .enter.i7 { --i: 7; }
  .enter.i8 { --i: 8; }
}

/* Terms that open a note (shared by 2 and 3) */
.term {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline dotted;
  text-decoration-color: var(--text-3);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-color 200ms ease;
}

.term[aria-expanded="true"] { text-decoration-color: var(--text); }

.term:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 2px;
}

:root:not(.js) #term-dr,
:root:not(.js) #term-lop,
:root:not(.js) #term-adopt,
:root:not(.js) #term-clock {
  text-decoration: none;
  cursor: text;
  pointer-events: none;
}

/* Collapsible block: grid rows 0fr -> 1fr */
.reveal {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  visibility: hidden;
  transition: grid-template-rows 280ms cubic-bezier(0, 0, 0.2, 1), opacity 280ms ease, visibility 0s linear 280ms;
}

.reveal.open {
  grid-template-rows: 1fr;
  opacity: 1;
  visibility: visible;
  transition: grid-template-rows 280ms cubic-bezier(0, 0, 0.2, 1), opacity 280ms ease, visibility 0s;
}
.reveal-inner { overflow: hidden; min-height: 0; }

/* 2. Note : prix unique */
.with-note { position: relative; }

.sidenote-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-width: 26rem;
  padding-top: 1rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-2);
}

.sidenote-body p { margin: 0; }

.sidenote-kicker {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.lop-canvas {
  display: block;
  width: 100%;
  height: 8.25rem;
}

@media (min-width: 80rem) {
  .sidenote {
    position: absolute;
    top: var(--note-top, 0);
    left: calc(100% + 3rem);
    width: 16.5rem;
    grid-template-rows: 1fr;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity 260ms ease, transform 260ms cubic-bezier(0, 0, 0.2, 1), visibility 0s linear 260ms;
  }
  .sidenote.open { transform: none; pointer-events: auto; transition: opacity 260ms ease, transform 260ms cubic-bezier(0, 0, 0.2, 1), visibility 0s; }
  .sidenote .sidenote-body { padding-top: 0; }
  /* references sit in the left margin; the dotted-term notes stay on the right */
  #note-bis, #note-lt, #note-ecb { left: auto; right: calc(100% + 3rem); width: 15rem; }
}

/* 4. Montage : adoption institutionnelle */
.montage {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-height: 4.2rem;
}

.montage-date {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.montage-line { color: var(--text); }

.milestones {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
  flex-direction: column;
  gap: 0.45rem;
}

.milestones li { display: flex; flex-direction: column; gap: 0.05rem; }
.milestones time { font-size: 0.6875rem; letter-spacing: 0.04em; color: var(--text-3); font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .montage { display: none; }
  .milestones { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; }
}

/* 8. Note de référence (BRI) */
sup { line-height: 0; }
.fn-ref {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.68em;
  color: var(--text-3);
  background: none;
  border: 0;
  padding: 0 0.12em;
  cursor: pointer;
  transition: color 200ms ease;
}
.fn-ref { position: relative; }
.fn-ref::after { content: ""; position: absolute; left: 50%; top: 50%; width: 24px; height: 24px; transform: translate(-50%, -50%); }
.fn-ref:hover, .fn-ref[aria-expanded="true"] { color: var(--text); }
.fn-ref:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 2px; }
:root:not(.js) sup.fn { display: none; }
.note-quote { color: var(--text); }
.note-source a {
  color: var(--text-2);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.note-source a:hover { color: var(--text); border-color: var(--text-3); }

/* 9. Empreinte de la signature */
.sign { cursor: default; border-radius: 2px; transition: color 200ms ease; }
.js .sign:hover, .sign[aria-expanded="true"] { color: var(--text); }
.sign:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
:root:not(.js) .sign { pointer-events: none; }
.fingerprint-body {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.7rem;
  padding-top: 0.55rem;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.fp-label {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.fp-hash { color: var(--text-2); letter-spacing: 0.03em; word-spacing: 0.2em; }
@media print { .fingerprint { display: none; } }

/* 5. Petites capitales d'ouverture */
.lead-in {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.8em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* 6. Horloge des marchés */
.sessions { display: block; width: 100%; height: auto; overflow: visible; }
.sessions .label { font-family: var(--font-text); font-size: 10px; fill: var(--text-3); }
.sessions .tick { font-family: var(--font-text); font-size: 9px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.sessions .now-label { font-family: var(--font-display); font-weight: 500; font-size: 9.5px; fill: var(--text); font-variant-numeric: tabular-nums; }
.sessions .base { stroke: var(--rule); stroke-width: 1; }
.sessions .bar { fill: var(--text-3); opacity: 0.55; }
.sessions .bar.live { fill: var(--text); opacity: 0.9; }
.sessions .now { stroke: var(--text); stroke-width: 1; }

/* 3. Définition en réserve */
.coda { gap: 0; }
.coda .signoff { margin-top: 1.5rem; }

.definition-body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-width: 30rem;
  padding: 1rem 0 0.35rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-2);
}

.definition-body p { margin: 0; }
.definition-body .def-head + p { margin-bottom: 0.55rem; }
.definition-body p:last-child { margin-bottom: 0; }

.def-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.6rem;
}

.def-head .hw {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--text);
}

.def-head .pron, .def-head .pos { color: var(--text-3); }
.def-head .pos { font-size: 0.75rem; }
.definition-body i { font-style: normal; color: var(--text-2); }

@media (prefers-reduced-motion: reduce) {
  .reveal, .sidenote, .term { transition: none; }
}

/* Impression : l'essai et sa note, rien d'interactif */
@media print {
  .enter { animation: none !important; opacity: 1 !important; transform: none !important; }
  .term { text-decoration: none; }
  .sidenote, .definition { display: none; }
  #note-bis, #note-lt, #note-ecb { display: grid; position: static; grid-template-rows: 1fr; opacity: 1; visibility: visible; transform: none; margin-top: 0.5em; }
  #note-bis .sidenote-body, #note-lt .sidenote-body, #note-ecb .sidenote-body { padding-top: 0; max-width: none; font-size: 8.5pt; gap: 0.2em; }
  .note-source a::after { content: " · " attr(data-short); }
  .fn-ref { color: var(--text-2); }
}

/* 10. Logo : fragmentation, puis message caché */
.masthead .col { position: relative; }
.logo-hit {
  display: block;
  border-radius: 3px;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.logo-hit:focus-visible { outline: 2px solid var(--text); outline-offset: 6px; }
:root:not(.js) .logo-hit { pointer-events: none; }
.logo-hit .lockup { transition: opacity 320ms ease; }
.logo-hit.is-shattered .lockup { visibility: hidden; }
.shatter-canvas { position: absolute; display: none; pointer-events: none; }
.shatter-canvas.on { display: block; }
.sealed {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  margin: 0;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 320ms ease, visibility 0s linear 320ms;
}
.sealed.on { opacity: 1; visibility: visible; transition: opacity 320ms ease, visibility 0s; }
/* Same type as the fingerprint under the signature; shrinks just enough to stay on one line */
.sealed-hex {
  margin: 0;
  font-size: min(0.75rem, 2.05vw);
  line-height: 1.5;
  color: var(--text-2);
  letter-spacing: 0.03em;
  word-spacing: 0.2em;
  font-variant-numeric: tabular-nums;
}
.sealed-hex .ch { transition: opacity 180ms ease; }
.sealed-hex .ch.off { opacity: 0; }
.sealed.instant .ch { transition: none; }
@media print { .shatter-canvas, .sealed { display: none; } }

/* 404 */
.lost a {
  color: var(--text-2);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.lost a:hover { color: var(--text); border-color: var(--text-3); }
.lost a:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; border-radius: 2px; }
