/* ==========================================================================
   El Mehdi Issouani — feuille de style unique
   1. Polices   2. Jetons et tons   3. Base   4. Navigation   5. Accueil
   6. Recherche et figures   7. Frise   8. Sections claires   9. Pied de page
   10. Arabe (droite à gauche)   11. Mouvement   12. Impression
   ========================================================================== */

/* 1. Polices (auto-hébergées, aucun appel externe) ------------------------- */
@font-face {
  font-family: "Plex Sans"; font-style: normal; font-weight: 100 700; font-display: swap;
  src: url("../fonts/plex-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+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Plex Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/plex-sans-greek-400.woff2") format("woff2");
  unicode-range: U+0370-03FF;
}
@font-face {
  font-family: "Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/plex-mono-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2212;
}
@font-face {
  font-family: "Newsreader"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/newsreader-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("../fonts/newsreader-latin-400-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2212;
}
@font-face {
  font-family: "Plex Sans Arabic"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/plex-sans-arabic-400.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Plex Sans Arabic"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("../fonts/plex-sans-arabic-600.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

/* 2. Jetons et tons -------------------------------------------------------- */
:root {
  --sans: "Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: "Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --display: var(--serif);
  --display-weight: 400;

  --ease: cubic-bezier(.22, 1, .36, 1);
  --fast: 150ms;
  --nav-h: 64px;
  --gutter: clamp(20px, 5vw, 48px);
  --wrap: 1160px;
  --block: clamp(72px, 10vw, 128px);

  /* palette du zellige : réservée à la frise et aux figures */
  --z-cobalt: #2350c4; --z-teal: #1f8a7d; --z-saffron: #e8a13a; --z-clay: #b5532a; --z-ivory: #f3ecdd;

  --hz-from: #0e1d1f; --hz-to: #f1e3cf; --frieze-ink: #8c9189;
  color-scheme: dark;
}

/* Nuit : la lanterne (safran) éclaire */
:root, .tone-night, .tone-canopy,
:root[data-theme="dark"] :is(.tone-dawn, .tone-day, .tone-beach) {
  --bg: #0a1013; --surface: #10181c; --raised: #18232a;
  --ink: #e9efec; --ink-2: #a7b4b1; --ink-3: #82908e;
  --line: rgb(233 239 236 / .11); --line-2: rgb(233 239 236 / .22);
  --accent: #e8a13a; --on-accent: #17120a; --accent-ink: #efb357;
  --shadow: none;
}
.tone-canopy { --bg: #0e1d1f; --surface: #142628; --raised: #1d3134; }
:root[data-theme="dark"] .tone-dawn { --bg: #0e1d1f; --surface: #142628; --raised: #1d3134; }

/* Jour : la mer (cobalt) répond */
.tone-dawn, .tone-day, .tone-beach,
:root[data-theme="light"], :root[data-theme="light"] :is(.tone-night, .tone-canopy) {
  --bg: #efeae0; --surface: #f8f4ec; --raised: #e5ded0;
  --ink: #1c1915; --ink-2: #554e43; --ink-3: #6b6357;
  --line: rgb(28 25 21 / .13); --line-2: rgb(28 25 21 / .26);
  --accent: #2350c4; --on-accent: #ffffff; --accent-ink: #1d44a8;
  --shadow: 0 1px 2px rgb(28 25 21 / .05), 0 10px 28px rgb(28 25 21 / .06);
}
/* l'aube est plus chaude que le jour : le passage se voit sans palier de plus */
.tone-dawn { --bg: #f1e3cf; --surface: #f8efe1; --raised: #e6d5bc; --ink-3: #625a4e; }
:root[data-theme="light"] .tone-dawn { --bg: #efeae0; --surface: #f8f4ec; --raised: #e5ded0; --ink-3: #6b6357; }
.tone-day { --bg: #f4efe5; --surface: #fbf8f1; --raised: #e9e2d4; }
.tone-beach { --bg: #faf5ea; --surface: #fffdf7; --raised: #efe8d9; }
:root[data-theme="light"] .tone-night { --bg: #f4efe5; --surface: #fbf8f1; --raised: #e9e2d4; }
:root[data-theme="light"] .tone-canopy { --bg: #efeae0; --surface: #f8f4ec; --raised: #e5ded0; }

:root[data-theme="dark"] { --hz-to: #0e1d1f; }
:root[data-theme="light"] { --hz-from: #efeae0; color-scheme: light; }

/* 3. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html {
  background: var(--bg); color: var(--ink);
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px);
  scrollbar-color: #7c8785 transparent;
}
body {
  margin: 0; font: 400 1.0625rem/1.6 var(--sans); color: var(--ink);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-synthesis-weight: none;
}
[class*="tone-"] { background-color: var(--bg); color: var(--ink); }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3 { font-family: var(--display); font-weight: var(--display-weight); text-wrap: balance; }
h1 { font-size: clamp(3rem, 1.5rem + 6.6vw, 6rem); line-height: 1.02; letter-spacing: -.025em; }
h2 { font-size: clamp(2.125rem, 1.35rem + 3.1vw, 3.5rem); line-height: 1.08; letter-spacing: -.02em; max-width: 18ch; }
h3 { font-size: clamp(1.75rem, 1.35rem + 1.5vw, 2.375rem); line-height: 1.15; letter-spacing: -.015em; }
p { text-wrap: pretty; }
a { color: inherit; text-underline-offset: .22em; text-decoration-thickness: 1px; }
b, strong { font-weight: 500; }
sup { font-size: .68em; line-height: 0; }
i.math { font-family: var(--serif); font-style: italic; font-size: 1.06em; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: calc(var(--wrap) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
main > section { padding-block: var(--block); }
.lead { font-size: clamp(1.125rem, 1rem + .6vw, 1.375rem); line-height: 1.5; color: var(--ink-2); max-width: 44ch; margin-top: 24px; }
.sprite { position: absolute; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.skip { position: absolute; inset-inline-start: 16px; top: -64px; z-index: 100; padding: 10px 16px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-weight: 500; text-decoration: none; }
.skip:focus { top: 12px; }

/* boutons et liens */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding-inline: 20px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 500; font-size: 1rem; line-height: 1.2; text-decoration: none; white-space: nowrap;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: color-mix(in oklab, var(--accent) 88%, var(--ink)); }
.btn-ghost { border-color: var(--line-2); }
.btn-ghost:hover { background: var(--raised); border-color: var(--ink-3); }
.btn .icon { transition: transform var(--fast) var(--ease); }
.btn:hover .i-down, .btn:hover .i-file { transform: translateY(2px); }
.btn-sm { min-height: 36px; padding-inline: 14px; border-radius: 8px; font-size: .9375rem; border-color: var(--line-2); }
.btn-sm:hover { background: var(--raised); border-color: var(--ink-3); }

.more {
  display: inline-flex; align-items: center; gap: 6px; color: var(--accent-ink); font-weight: 500; text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size 260ms var(--ease); padding-block: 2px;
}
.more:hover { background-size: 100% 1px; }
.more .icon { width: 16px; height: 16px; transition: transform var(--fast) var(--ease); }
.more:hover .i-out { transform: translate(2px, -2px); }
.more:hover .i-file { transform: translateY(2px); }

.tool { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--ink-2); transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease); }
.tool:hover { background: var(--raised); color: var(--ink); }
.tool:active { transform: scale(.94); }

/* 4. Navigation ------------------------------------------------------------ */
.nav {
  position: sticky; top: 0; z-index: 50; height: var(--nav-h);
  background-color: color-mix(in oklab, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid transparent;
  transition: background-color 320ms var(--ease), color 320ms var(--ease), border-color 320ms var(--ease);
}
.nav.is-scrolled { border-bottom-color: var(--line); }
.nav-row { display: flex; align-items: center; gap: 24px; height: 100%; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.mark { width: 28px; height: 28px; color: var(--ink); stroke-linecap: butt; stroke-linejoin: miter; }
.nav-links { margin-inline-start: auto; }
.nav-links ul { display: flex; gap: 4px; }
.nav-links a { display: block; padding: 8px 12px; border-radius: 8px; font-size: .9375rem; color: var(--ink-2); text-decoration: none; transition: color var(--fast) var(--ease), background-color var(--fast) var(--ease); }
.nav-links a:hover { color: var(--ink); background: var(--raised); }
.nav-links a[aria-current] { color: var(--ink); }
.nav-tools { display: flex; align-items: center; gap: 8px; }
.langs { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 9px; }
.langs a { display: grid; place-items: center; min-width: 34px; height: 30px; padding-inline: 8px; border-radius: 6px; font-size: .8125rem; font-weight: 500; color: var(--ink-2); text-decoration: none; transition: color var(--fast) var(--ease), background-color var(--fast) var(--ease); }
.langs a:hover { color: var(--ink); }
.langs a[aria-current] { background: var(--raised); color: var(--ink); }
.langs a[lang="ar"] { font-family: "Plex Sans Arabic", var(--sans); font-size: .9375rem; }
.theme-btn .icon { display: none; }
:root[data-theme="journey"] .t-journey, :root[data-theme="light"] .t-light, :root[data-theme="dark"] .t-dark { display: block; }
.menu-btn { display: none; }
.nav-progress { position: absolute; inset-inline: 0; bottom: -1px; height: 1px; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; }
[dir="rtl"] .nav-progress { transform-origin: 100% 50%; }

.menu {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; border: 0;
  padding: calc(var(--nav-h) + 24px) var(--gutter) 32px; overflow: auto;
  opacity: 0; translate: 0 -12px;
  transition: opacity 240ms var(--ease), translate 240ms var(--ease), display 240ms allow-discrete, overlay 240ms allow-discrete;
}
.menu:popover-open { opacity: 1; translate: 0 0; }
@starting-style { .menu:popover-open { opacity: 0; translate: 0 -12px; } }
/* très petits écrans : l'étoile seule, le nom reste dans le titre de la page */
@media (max-width: 400px) { .brand > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } }
/* navigateur sans popover : pas de couche invisible par-dessus la page */
@supports not selector(:popover-open) { .menu, .menu-btn { display: none; } }
.menu nav a { display: block; padding-block: 10px; font: var(--display-weight) 2rem/1.2 var(--display); text-decoration: none; }
.menu-tools { display: flex; align-items: center; gap: 12px; margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); }
.menu-tools .theme-btn { width: auto; padding-inline: 12px; gap: 10px; display: inline-flex; border: 1px solid var(--line-2); font-size: .9375rem; }
.menu-close { position: absolute; top: 14px; inset-inline-end: var(--gutter); }

@media (max-width: 1099px) {
  .nav-links { display: none; }
  .nav-tools { margin-inline-start: auto; }
  .menu-btn { display: inline-grid; }
}
@media (max-width: 639px) {
  .nav .theme-btn, .nav .btn-sm { display: none; }
  .nav-row { gap: 12px; }
}

/* 5. Accueil --------------------------------------------------------------- */
.hero { padding-block: clamp(32px, 6vw, 72px); min-height: calc(100svh - var(--nav-h)); display: grid; align-items: center; overflow: clip; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr); gap: clamp(32px, 5vw, 80px); align-items: center; }
.hero-lead { margin-top: 28px; max-width: 34ch; font-size: clamp(1.1875rem, 1rem + .7vw, 1.4375rem); line-height: 1.45; color: var(--ink-2); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 36px; }
.facts { margin-top: 44px; padding-top: 20px; border-top: 1px solid var(--line); display: grid; gap: 6px; font-size: .9375rem; color: var(--ink-3); max-width: 46ch; }
.hero-figure { justify-self: end; width: 100%; max-width: 560px; }
.rosette { width: 100%; height: auto; overflow: visible; color: var(--ink); }
.rosette-spin { transform-origin: 0 0; transform: rotate(var(--rot, 0deg)); transition: transform 900ms var(--ease); }
.rosette .ring { fill: none; stroke: currentColor; stroke-opacity: .16; stroke-width: 1; vector-effect: non-scaling-stroke; }
.chord { fill: none; stroke: currentColor; stroke-width: 1; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chord.c1 { stroke-opacity: .5; }
.chord.c2 { stroke-opacity: .26; }
.chord.c3 { stroke-opacity: .13; }
.dot { fill: var(--accent); }

@media (max-width: 899px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-figure { order: -1; justify-self: start; max-width: min(64vw, 320px); margin-inline-start: -8px; }
  .hero-lead { margin-top: 20px; }
  .actions { margin-top: 28px; }
  .actions .btn { flex: 1 1 100%; }
  .facts { margin-top: 32px; }
}

/* 6. Recherche et figures -------------------------------------------------- */
.intro { padding-block-end: clamp(24px, 4vw, 48px); }
.intro h2 { max-width: 16ch; }
.intro .lead { max-width: 52ch; }
.station { padding-block: clamp(56px, 8vw, 104px); }
.station-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(32px, 6vw, 96px); align-items: center; }
.station-copy p { margin-top: 20px; color: var(--ink-2); max-width: 46ch; }
.terms { display: flex; flex-wrap: wrap; gap: 6px 0; margin-top: 28px; font-size: .875rem; color: var(--ink-3); }
.terms li:not(:last-child)::after { content: "·"; margin-inline: 10px; color: var(--line-2); }
.station-copy .more { margin-top: 28px; }

.fig { padding: clamp(20px, 3vw, 32px); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); min-width: 0; }
.controls { display: grid; gap: 14px; margin-top: 20px; }
.ctl { display: grid; grid-template-columns: minmax(8.5rem, auto) 1fr 3.2rem; gap: 14px; align-items: center; font-size: .9375rem; color: var(--ink-2); }
.ctl output { font: 400 .8125rem var(--mono); color: var(--ink); text-align: end; font-variant-numeric: tabular-nums; }
.readout { display: flex; flex-wrap: wrap; gap: 6px 24px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); font: 400 .8125rem/1.5 var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.readout b { color: var(--ink); font-weight: 400; }
.readout i.math { font-size: 1.15em; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; margin: 0; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; border-radius: 2px; background: var(--ink-3); }
input[type="range"]::-moz-range-track { height: 2px; border-radius: 2px; background: var(--ink-3); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -8px; border-radius: 50%; background: var(--accent); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); transition: transform var(--fast) var(--ease); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }

.btn-quiet { justify-self: start; display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding-inline: 12px; border-radius: 8px; border: 1px solid var(--line-2); font-size: .875rem; color: var(--ink-2); transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease); }
.btn-quiet:hover { background: var(--raised); color: var(--ink); }
.btn-quiet:active { transform: scale(.97); }
.btn-quiet .icon { width: 16px; height: 16px; }

/* spectre */
.spec-plot { width: 100%; height: auto; overflow: visible; }
.spec-bars rect { fill: var(--accent); transform-box: fill-box; transform-origin: 50% 100%; transition: transform 360ms var(--ease); }
.spec-law { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; transition: opacity 240ms var(--ease); }
.spec-truth { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.spec-base { stroke: var(--line-2); stroke-width: 1; vector-effect: non-scaling-stroke; }
.spec-axis text { font: 400 10px var(--mono); fill: var(--ink-3); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 12px; font-size: .8125rem; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.sw { display: inline-block; flex: none; }
.sw-bar { width: 10px; height: 10px; border-radius: 2px; background: var(--accent); }
.sw-line { width: 18px; border-top: 1.5px solid var(--ink); }
.sw-dash { width: 18px; border-top: 1.5px dashed var(--ink-2); }

/* étiquetage */
.pos-line { display: flex; flex-wrap: wrap; gap: 8px 4px; }
.tok { display: grid; justify-items: center; gap: 10px; padding: 12px 12px 10px; border: 1px solid transparent; border-radius: 10px; cursor: default; transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease); }
.tok:hover, .tok:focus-visible { background: var(--raised); border-color: var(--line); }
.tok-w { font: var(--display-weight) clamp(1.625rem, 1.1rem + 1.7vw, 2.375rem)/1.1 var(--display); }
.tok-t { padding: 2px 7px; border: 1px solid var(--line-2); border-radius: 6px; font: 400 .75rem/1.5 var(--mono); color: var(--accent-ink); }
.pos-note { min-height: 3.2em; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .9375rem; color: var(--ink-2); }

/* k-mers */
.fig { container-type: inline-size; }
.seq { display: grid; grid-template-columns: repeat(20, minmax(0, 1fr)); row-gap: 2px; font: 400 .9375rem/1 var(--mono); color: var(--ink-3); }
.seq span { padding-block: 6px; text-align: center; border-radius: 3px; transition: background-color 120ms linear, color 120ms linear; }
.seq span.done { color: var(--ink); }
.seq span.on { background: var(--accent); color: var(--on-accent); }
.kmer-body { display: grid; gap: 4px 28px; margin-top: 24px; }
.kgrid { display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: 3px; width: min(100%, 280px); }
@container (min-width: 500px) {
  .seq { grid-template-columns: repeat(40, minmax(0, 1fr)); font-size: .875rem; }
  .kmer-body { grid-template-columns: 240px minmax(0, 1fr); align-items: end; }
  .kmer-body .controls { margin-top: 0; }
  .kmer-body .seg { grid-template-columns: 1fr; gap: 8px; }
}
.kgrid[data-k="4"] { gap: 2px; }
.cell { display: grid; place-items: center; aspect-ratio: 1; border-radius: 3px; background: color-mix(in oklab, var(--accent) calc(var(--v, 0) * 100%), var(--raised)); transition: background-color 240ms var(--ease); }
.cell-n { font: 400 .75rem var(--mono); color: var(--ink-2); }
.cell.hot .cell-n { color: var(--on-accent); }
.seg { grid-template-columns: minmax(8.5rem, auto) 1fr; }
.seg-set { justify-self: start; display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line-2); border-radius: 9px; }
.seg-set button { width: 38px; height: 30px; border-radius: 6px; font: 400 .8125rem var(--mono); color: var(--ink-2); transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease); }
.seg-set button:hover { color: var(--ink); }
.seg-set button[aria-pressed="true"] { background: var(--raised); color: var(--ink); }

@media (max-width: 899px) {
  .station-grid { grid-template-columns: 1fr; }
  .ctl { grid-template-columns: 1fr 3.2rem; }
  .ctl .ctl-name { grid-column: 1 / -1; }
  .seg { grid-template-columns: 1fr; }
}

/* 7. Frise : la lisière entre la nuit et le jour ---------------------------- */
.horizon { background: linear-gradient(var(--hz-from) 50%, var(--hz-to) 50%); }
.frieze { position: relative; height: 112px; }
.frieze-line, .frieze-color { position: absolute; inset: 0; }
.frieze-line { background: var(--frieze-ink); -webkit-mask: url("../img/frieze-line.svg") center / auto 100% repeat-x; mask: url("../img/frieze-line.svg") center / auto 100% repeat-x; }
.frieze-color { background: url("../img/frieze-color.svg") center / auto 100% repeat-x; }
/* le soir, au bord de la mer : la même frise referme la journée, plus basse */
.horizon-end { background: var(--bg); padding-top: clamp(48px, 8vw, 96px); }
.horizon-end .frieze { height: 64px; }
.horizon-end + .footer { border-top: 0; }

/* 8. Sections claires ------------------------------------------------------ */
.pub-list { margin-top: 48px; border-top: 1px solid var(--line); }
.pub { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 8px 24px; padding-block: 28px; border-bottom: 1px solid var(--line); }
.pub-year, .row-when, .t-when, .feature-when { font: 400 .8125rem/1.6 var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pub-year { padding-top: .45rem; }
.pub-title { font-size: clamp(1.3125rem, 1.15rem + .6vw, 1.625rem); line-height: 1.25; letter-spacing: -.01em; max-width: 36ch; }
.pub-authors { margin-top: 10px; font-size: .9375rem; color: var(--ink-2); max-width: 70ch; }
.pub-venue { margin-top: 2px; font-size: .9375rem; color: var(--ink-3); }
.pub-links { display: flex; flex-wrap: wrap; gap: 6px 24px; margin-top: 14px; font-size: .9375rem; }

.feature { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 8px 24px; margin-top: 48px; padding: clamp(24px, 3.5vw, 40px); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.feature-when { padding-top: .5rem; }
.feature h3 { grid-column: 2; }
.feature > p:not(.feature-when) { grid-column: 2; margin-top: 4px; color: var(--ink-2); max-width: 58ch; }
.feature > .more { grid-column: 2; justify-self: start; margin-top: 10px; }
.rows { margin-top: 32px; border-top: 1px solid var(--line); }
.rows li { display: grid; grid-template-columns: 6.5rem minmax(0, 1.25fr) minmax(0, 1fr); gap: 4px 24px; padding-block: 14px; border-bottom: 1px solid var(--line); align-items: baseline; }
.row-where { font-size: .9375rem; color: var(--ink-2); }
.talks > .wrap > .more { margin-top: 28px; }

.two { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(32px, 6vw, 96px); align-items: start; }
.two-copy p { margin-top: 20px; color: var(--ink-2); max-width: 46ch; }
.two-copy .more { margin-top: 28px; }
.courses { border-top: 1px solid var(--line); margin-top: 12px; }
.courses li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 24px; padding-block: 14px; border-bottom: 1px solid var(--line); }
.courses li span:last-child { font-size: .9375rem; color: var(--ink-3); }

.code { padding-top: 0; }
.code .lead { max-width: 58ch; }
.code-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px clamp(32px, 6vw, 96px); margin-top: 48px; align-items: start; }
.code-group h3 { font: 500 1.0625rem/1.4 var(--sans); letter-spacing: 0; }
.files { margin-top: 12px; border-top: 1px solid var(--line); }
.files li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 20px; padding-block: 11px; border-bottom: 1px solid var(--line); font-size: .9375rem; }
.file-name { color: var(--ink-2); }
.file-links { display: inline-flex; gap: 14px; font-size: .875rem; }
.file-links a { color: var(--accent-ink); text-decoration-color: color-mix(in oklab, currentColor 35%, transparent); transition: text-decoration-color var(--fast) var(--ease); }
.file-links a:hover { text-decoration-color: currentColor; }
.code > .wrap > .more { margin-top: 32px; }

.about-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 48px clamp(32px, 6vw, 96px); align-items: start; }
.about-copy p { margin-top: 20px; color: var(--ink-2); max-width: 52ch; }
.about-copy p:first-of-type { margin-top: 28px; font-size: clamp(1.125rem, 1rem + .5vw, 1.3125rem); line-height: 1.5; color: var(--ink); }
.portrait { grid-column: 2; grid-row: 1 / span 2; border-radius: 16px; overflow: hidden; background: var(--raised); box-shadow: var(--shadow); }
.portrait img { width: 100%; height: auto; }
.timeline { border-top: 1px solid var(--line); }
.timeline li { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 4px 24px; padding-block: 18px; border-bottom: 1px solid var(--line); }
.t-when { padding-top: .2rem; }
.timeline h3 { font: 500 1.0625rem/1.4 var(--sans); letter-spacing: 0; }
.timeline p { margin-top: 4px; font-size: .9375rem; color: var(--ink-2); max-width: 60ch; }

.contact { padding-top: 0; }
.contact-list { margin-top: 40px; border-top: 1px solid var(--line); }
.contact-list li { display: grid; grid-template-columns: 14rem minmax(0, 1fr); gap: 2px 24px; padding-block: 18px; border-bottom: 1px solid var(--line); align-items: baseline; }
.c-label { font-size: .9375rem; color: var(--ink-3); }
.contact-list a { justify-self: start; font: var(--display-weight) clamp(1.25rem, 1.1rem + .7vw, 1.625rem)/1.25 var(--display); color: var(--ink); text-decoration: none; overflow-wrap: anywhere; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size 260ms var(--ease), color var(--fast) var(--ease); }
.contact-list a:hover { background-size: 100% 1px; color: var(--accent-ink); }

@media (max-width: 899px) {
  .two, .code-groups, .about-grid { grid-template-columns: 1fr; }
  .code-group:first-child { grid-row: auto; }
  .portrait { grid-column: 1; grid-row: auto; max-width: 420px; }
  .rows li { grid-template-columns: 6.5rem minmax(0, 1fr); }
  .row-where { grid-column: 2; }
}
@media (max-width: 599px) {
  .pub, .feature, .rows li, .timeline li, .contact-list li { grid-template-columns: 1fr; }
  .feature > h3, .feature > p:not(.feature-when), .feature > .more, .row-where { grid-column: 1; }
  .pub-year, .feature-when, .t-when { padding-top: 0; }
}

/* 9. Pied de page ---------------------------------------------------------- */
.footer { padding-block: 40px 56px; border-top: 1px solid var(--line); font-size: .875rem; color: var(--ink-3); }
.footer-row { display: grid; grid-template-columns: auto 1fr; gap: 16px 32px; align-items: center; }
.footer-rights { display: inline-flex; align-items: center; gap: 10px; color: var(--ink-2); }
.footer-rights .mark { width: 22px; height: 22px; color: inherit; }
.footer-langs { justify-self: end; display: flex; gap: 20px; }
.footer-langs a { text-decoration: none; padding-block: 6px; }
.footer-langs a:hover, .footer-langs a[aria-current] { color: var(--ink); }
.footer-colophon { grid-column: 1 / -1; max-width: 76ch; }
@media (max-width: 599px) {
  .footer-row { grid-template-columns: 1fr; }
  .footer-langs { justify-self: start; }
}

/* 10. Arabe : la page se lit de droite à gauche ----------------------------- */
:lang(ar) {
  --sans: "Plex Sans Arabic", "Plex Sans", "Segoe UI", Tahoma, sans-serif;
  --display: "Plex Sans Arabic", "Plex Sans", "Segoe UI", Tahoma, sans-serif;
  --display-weight: 600;
}
:lang(ar) body { line-height: 1.8; }
:lang(ar) :is(h1, h2, h3, .pub-title, .tok-w, .menu nav a, .contact-list a) { letter-spacing: 0; line-height: 1.4; }
:lang(ar) h1 { font-size: clamp(2.75rem, 1.4rem + 5.6vw, 5.25rem); line-height: 1.3; }
:lang(ar) :is(.code-group h3, .timeline h3, b, strong, .btn, .more, .brand) { font-weight: 600; }
:lang(ar) :is(.pub-year, .row-when, .t-when, .feature-when, .tok-t, .readout, .cell-n) { font-family: var(--sans); }
:lang(ar) :is(.pub-title, .row-title, .feature h3, .timeline p) bdi[lang] { font-family: var(--serif); font-weight: 400; }
:lang(ar) :is(.contact-list a, .brand) bdi { font-family: var(--serif); font-weight: 400; }
[dir="rtl"] .i-out { transform: scaleX(-1); }
[dir="rtl"] .more:hover .i-out { transform: scaleX(-1) translate(2px, -2px); }
[dir="rtl"] .more { background-position: 100% 100%; }
[dir="rtl"] .contact-list a { background-position: 100% 100%; }

/* 11. Mouvement ------------------------------------------------------------ */
@media (prefers-reduced-motion: no-preference) { @view-transition { navigation: auto; } }
.vt-theme::view-transition-old(root), .vt-theme::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
.vt-theme::view-transition-new(root) { z-index: 1; }

@media (prefers-reduced-motion: no-preference) {
  /* l'entrée : le bruit s'ordonne, puis le texte se pose */
  .dot { animation: settle 1600ms var(--ease) both; animation-delay: var(--dl, 0ms); }
  .chord, .rosette .ring { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 2400ms var(--ease) forwards; }
  .rosette .ring { animation-delay: 700ms; }
  .chord.c1 { animation-delay: calc(900ms + var(--o, 0) * 200ms); }
  .chord.c2 { animation-delay: calc(1300ms + var(--o, 0) * 200ms); }
  .chord.c3 { animation-delay: calc(1700ms + var(--o, 0) * 200ms); }
  .hero-copy > * { animation: rise 800ms var(--ease) both; }
  .hero-copy > :nth-child(2) { animation-delay: 80ms; }
  .hero-copy > :nth-child(3) { animation-delay: 160ms; }
  .hero-copy > :nth-child(4) { animation-delay: 240ms; }

  /* les étiquettes se posent une à une quand la phrase entre à l'écran */
  .js .fig-pos:not(.is-in) .tok-t { opacity: 0; transform: translateY(-6px); }
  .fig-pos.is-in .tok-t { transition: opacity 320ms var(--ease), transform 320ms var(--ease); transition-delay: calc(200ms + var(--i) * 90ms); }
  .cell.hit { animation: hit 420ms var(--ease); }

  @supports (animation-timeline: view()) {
    .nav-progress { animation: progress linear both; animation-timeline: scroll(root block); }
    .hero-figure { animation: recede linear both; animation-timeline: view(); animation-range: exit 0% exit 90%; }
    .frieze-color { animation: daybreak linear both; animation-timeline: view(); animation-range: entry 55% cover 62%; }
    [dir="rtl"] .frieze-color { animation-name: daybreak-rtl; }
    .horizon-end .frieze-color { animation-range: entry 10% entry 100%; }
    /* ce qu'on lit se pose à mesure qu'on avance, sans rien cacher à qui saute directement à une ancre */
    main > section:not(.hero) > .wrap > :is(h2, .lead, .feature, .rows, .pub-list, .code-groups, .contact-list, .station-copy, .fig, .two-copy, .courses, .about-copy, .portrait, .timeline) {
      animation: arrive linear both; animation-timeline: view(); animation-range: entry 0% entry 160px;
    }
  }
}
@keyframes settle { from { transform: translate(var(--dx), var(--dy)); opacity: 0; } 30% { opacity: 1; } to { transform: translate(0, 0); opacity: 1; } }
/* à la fin, plus de tirets : le tracé est fermé (sinon un petit bout manque au raccord) */
@keyframes draw { 99% { stroke-dashoffset: 0; stroke-dasharray: 1; } 100% { stroke-dashoffset: 0; stroke-dasharray: none; } }
@keyframes arrive { from { opacity: 0; translate: 0 28px; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes hit { from { box-shadow: 0 0 0 2px var(--ink); } to { box-shadow: 0 0 0 2px transparent; } }
@keyframes progress { to { transform: scaleX(1); } }
@keyframes recede { to { transform: rotate(14deg) scale(.9); opacity: .25; } }
@keyframes daybreak { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes daybreak-rtl { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0 0 0 0); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* 12. Impression ----------------------------------------------------------- */
@media print {
  *, *::before, *::after { animation: none !important; }
  .nav, .menu, .hero-figure, .horizon, .controls, .skip { display: none !important; }
  [class*="tone-"] { background: #fff !important; color: #000 !important; }
  main > section { padding-block: 16pt; }
}
