/* ==========================================================================
   Portfolio V7 — Dan Greisner
   Système de design en tokens. Aucune dépendance. CSS 2026 en amélioration
   progressive : tout ce qui est derrière @supports dégrade proprement.
   ========================================================================== */

/* ---------- 1. Tokens ---------------------------------------------------- */
:root {
  color-scheme: light dark;

  /* Couleurs (oklch) — chaud, calme, une seule couleur d'accent */
  --paper:   light-dark(oklch(97.5% 0.008 85), oklch(16% 0.008 70));
  --paper-2: light-dark(oklch(95% 0.010 85),   oklch(19% 0.009 70));
  --ink:     light-dark(oklch(20% 0.010 70),   oklch(93% 0.010 85));
  --ink-2:   light-dark(oklch(45% 0.012 70),   oklch(68% 0.012 80));
  --line:    light-dark(oklch(20% 0.01 70 / 0.12), oklch(93% 0.01 85 / 0.12));
  --accent:  light-dark(oklch(58% 0.085 70),   oklch(78% 0.085 75));
  --accent-ink: light-dark(oklch(98% 0.005 85), oklch(16% 0.008 70));
  --accent-soft: color-mix(in oklch, var(--accent) 14%, transparent);
  --focus:   light-dark(oklch(55% 0.16 250),   oklch(78% 0.13 250));
  --ok:      light-dark(oklch(55% 0.14 150),   oklch(75% 0.14 150));
  --danger:  light-dark(oklch(55% 0.17 25),    oklch(75% 0.14 25));

  /* Typographie */
  --f-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --t-xs: 0.6875rem;   /* 11 */
  --t-sm: 0.8125rem;   /* 13 */
  --t-md: 1rem;        /* 16 */
  --t-lg: clamp(1.0625rem, 0.95rem + 0.5vw, 1.25rem);
  --t-xl: clamp(1.375rem, 1.1rem + 1.4vw, 2rem);
  --t-2xl: clamp(1.75rem, 1.2rem + 2.6vw, 3.25rem);
  --t-3xl: clamp(2.5rem, 1.4rem + 5.5vw, 6.5rem);

  /* Espacement (échelle 4) */
  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem; --s-5: 1.5rem;
  --s-6: 2rem; --s-7: 3rem; --s-8: 4.5rem; --s-9: 7rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --measure: 62ch;

  /* Forme & mouvement */
  --r-sm: 6px; --r-md: 12px; --r-lg: 20px; --r-pill: 999px;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur-1: 160ms; --dur-2: 320ms; --dur-3: 640ms;

  /* Cibles tactiles (WCAG 2.2 — 2.5.8) */
  --target: 44px;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

@media (prefers-reduced-motion: reduce) {
  :root { --dur-1: 0ms; --dur-2: 0ms; --dur-3: 0ms; }
}

/* ---------- 2. Base ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--t-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, video { max-width: 100%; height: auto; display: block; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--accent); }
::selection { background: var(--accent); color: var(--accent-ink); }

h1, h2, h3 { font-family: var(--f-display); font-weight: 300; line-height: 1.05; letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
h1 { font-size: var(--t-3xl); font-variation-settings: "opsz" 144; }
h2 { font-size: var(--t-2xl); font-variation-settings: "opsz" 96; }
h3 { font-size: var(--t-xl); font-weight: 400; }
p { margin: 0; text-wrap: pretty; }
em { font-style: italic; font-weight: 500; color: var(--accent); }

/* Focus visible : anneau contrasté, jamais supprimé (WCAG 2.2 — 2.4.11) */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--r-sm); }
:focus:not(:focus-visible) { outline: none; }

.skip {
  position: absolute; inset-inline-start: var(--s-4); top: -100px;
  padding: var(--s-3) var(--s-4); background: var(--ink); color: var(--paper);
  border-radius: var(--r-md); z-index: 1000; font-family: var(--f-mono); font-size: var(--t-sm);
}
.skip:focus { top: var(--s-4); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 3. Primitives ------------------------------------------------ */
.wrap { max-width: 1200px; margin-inline: auto; padding-inline: var(--gutter); }
.narrow { max-width: 900px; }

.kicker {
  font-family: var(--f-mono); font-size: var(--t-xs); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-2); display: inline-flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4);
}
.kicker::before { content: ""; width: 20px; height: 1px; background: var(--accent); }

.mono { font-family: var(--f-mono); font-size: var(--t-sm); letter-spacing: 0.02em; }
.muted { color: var(--ink-2); }
.lede { color: var(--ink-2); font-size: var(--t-lg); max-width: var(--measure); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--target); padding: 0 var(--s-5);
  border-radius: var(--r-pill); border: 1px solid var(--line);
  font-family: var(--f-mono); font-size: var(--t-sm); letter-spacing: 0.04em;
  background: transparent; color: var(--ink); text-decoration: none;
  transition: background var(--dur-1) var(--ease-out), border-color var(--dur-1), color var(--dur-1), transform var(--dur-1);
}
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: color-mix(in oklch, var(--accent) 88%, var(--ink)); color: var(--accent-ink); border-color: transparent; }
.btn-ghost { border-color: transparent; padding-inline: var(--s-3); }
.btn[aria-busy="true"] { opacity: 0.6; pointer-events: none; }

.chip {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 var(--s-4);
  border-radius: var(--r-pill); border: 1px solid var(--line);
  font-family: var(--f-mono); font-size: var(--t-xs); letter-spacing: 0.04em; color: var(--ink-2);
  background: transparent; transition: all var(--dur-1) var(--ease-out);
}
.chip[aria-pressed="true"], .chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip:hover:not([aria-pressed="true"]) { border-color: var(--ink-2); color: var(--ink); }

.field { display: grid; gap: var(--s-2); }
.field > span { font-family: var(--f-mono); font-size: var(--t-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.field input, .field textarea {
  width: 100%; min-height: var(--target); padding: var(--s-3) 2px;
  background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  transition: border-color var(--dur-1);
}
.field input:focus-visible, .field textarea:focus-visible { outline: none; border-bottom-color: var(--accent); box-shadow: 0 1px 0 var(--accent); }
.field textarea { resize: vertical; min-height: 96px; }
.form-error { font-family: var(--f-mono); font-size: var(--t-sm); color: var(--danger); }
.form-error:empty { display: none; }

.rule { height: 1px; background: var(--line); border: 0; margin: 0; }

section { padding-block: var(--s-9); scroll-margin-top: 72px; }
@media (max-width: 720px) { section { padding-block: var(--s-8); } }

/* ---------- 4. Barre de progression + nav -------------------------------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 2px; background: var(--accent); transform-origin: 0 50%; transform: scaleX(var(--p, 0)); z-index: 60; }
@supports (animation-timeline: scroll()) {
  .progress { animation: progress linear both; animation-timeline: scroll(root); transform: none; }
  @keyframes progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
}

.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-3) var(--gutter);
  background: color-mix(in oklch, var(--paper) 82%, transparent);
  backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-2);
}
.nav.is-stuck { border-bottom-color: var(--line); }
.brand { font-family: var(--f-mono); font-size: var(--t-sm); letter-spacing: 0.1em; text-decoration: none; white-space: nowrap; }
.nav .btn, .nav-links a { white-space: nowrap; }
/* Liens isolés : cible ≥ 24 px (WCAG 2.2 — 2.5.8) même pour du texte */
.brand, .case-meta a, #contact-linkedin { display: inline-flex; align-items: center; min-height: 24px; }
.nav-links { display: flex; gap: var(--s-1); list-style: none; margin: 0; padding: 0; }
.nav-links a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--s-3); border-radius: var(--r-pill); font-family: var(--f-mono); font-size: var(--t-xs); letter-spacing: 0.06em; color: var(--ink-2); text-decoration: none; }
.nav-links a:hover, .nav-links a[aria-current="true"] { color: var(--ink); background: var(--paper-2); }
.nav-tools { display: flex; align-items: center; gap: var(--s-2); }
.icon-btn { width: var(--target); height: var(--target); display: inline-grid; place-items: center; border-radius: var(--r-pill); border: 1px solid transparent; background: transparent; color: var(--ink-2); }
.icon-btn:hover { color: var(--ink); background: var(--paper-2); }
.icon-btn svg { width: 18px; height: 18px; }
.kbd { font-family: var(--f-mono); font-size: 10px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink-2); }
@media (max-width: 1080px) { .nav-links { display: none; } }

/* ---------- 6. Hero ------------------------------------------------------ */
.hero { min-height: calc(100svh - 120px); display: grid; align-content: center; gap: var(--s-6); padding-block: var(--s-8) var(--s-7); }
.hero h1 { max-width: 15ch; }
.hero .lede { max-width: 54ch; }
.hero-ctas { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.hero-meta { display: flex; gap: var(--s-6); flex-wrap: wrap; font-family: var(--f-mono); font-size: var(--t-xs); letter-spacing: 0.06em; color: var(--ink-2); text-transform: uppercase; }
.status { display: inline-flex; align-items: center; gap: var(--s-2); width: fit-content; padding: var(--s-2) var(--s-4); border: 1px solid var(--line); border-radius: var(--r-pill); font-family: var(--f-mono); font-size: var(--t-xs); letter-spacing: 0.04em; color: var(--ink-2); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 color-mix(in oklch, var(--ok) 50%, transparent); animation: pulse 2.4s var(--ease-out) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--ok) 45%, transparent); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .status::before { animation: none; } }

/* ---------- 7. Révélation au défilement (explique, ne performe pas) ------ */
.reveal { opacity: 1; }
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .reveal { animation: reveal both; animation-timeline: view(); animation-range: entry 0% entry 28%; }
    @keyframes reveal { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
  }
}

/* ---------- 8. TL;DR ----------------------------------------------------- */
.tldr { border-block: 1px solid var(--line); }
.tldr-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-5); flex-wrap: wrap; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); margin-top: var(--s-7); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.grid-3 > div { background: var(--paper); padding: var(--s-6) var(--s-5); }
.grid-3 .n { font-family: var(--f-mono); font-size: var(--t-xs); color: var(--accent); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: var(--s-4); }
.grid-3 p { font-family: var(--f-display); font-size: var(--t-xl); font-weight: 400; line-height: 1.3; }
@media (max-width: 860px) { .grid-3 { grid-template-columns: 1fr; } }

/* ---------- 9. Étude de cas --------------------------------------------- */
.case { padding-block: 0; }
.case-hero { position: relative; min-height: 62svh; display: grid; align-content: end; padding: var(--s-9) var(--gutter) var(--s-7); overflow: hidden; isolation: isolate; }
.case-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; opacity: 0.32; }
.case-hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, color-mix(in oklch, var(--paper) 30%, transparent), var(--paper) 92%); }
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .case-hero img { animation: parallax linear both; animation-timeline: view(); animation-range: entry 0% exit 100%; }
    @keyframes parallax { from { transform: scale(1.12) translateY(-4%); } to { transform: scale(1) translateY(4%); } }
  }
}
.case-hero h2 { font-size: var(--t-3xl); max-width: 14ch; }
.case-meta { display: flex; flex-wrap: wrap; gap: var(--s-6) var(--s-8); padding: var(--s-6) var(--gutter); font-family: var(--f-mono); font-size: var(--t-sm); border-bottom: 1px solid var(--line); }
.case-meta dt { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); margin-bottom: var(--s-1); }
.case-meta dd { margin: 0; }
.case-body { max-width: 1000px; margin-inline: auto; }
.chapter { display: grid; grid-template-columns: 96px 1fr; gap: var(--s-5); padding: var(--s-7) var(--gutter); border-bottom: 1px solid var(--line); }
.chapter .num { font-family: var(--f-mono); font-size: var(--t-sm); color: var(--ink-2); padding-top: 6px; }
.chapter p:not(.kicker) { font-family: var(--f-display); font-weight: 300; font-size: var(--t-xl); line-height: 1.3; max-width: 62ch; }
.chapter .kicker { margin-bottom: var(--s-3); }
.chapter.impact p:not(.kicker) { font-style: italic; font-weight: 400; border-inline-start: 2px solid var(--accent); padding-inline-start: var(--s-5); }
@media (max-width: 720px) { .chapter { grid-template-columns: 1fr; gap: var(--s-2); } }

.gallery { display: flex; gap: var(--s-4); padding: var(--s-6) var(--gutter); overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.gallery figure { flex: 0 0 min(78vw, 640px); margin: 0; scroll-snap-align: start; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line); background: var(--paper-2); }
.gallery img { aspect-ratio: 16/9; width: 100%; object-fit: cover; }
.gallery figcaption { font-family: var(--f-mono); font-size: var(--t-xs); color: var(--ink-2); padding: var(--s-3) var(--s-4); }
.tools { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-5); }

/* ---------- 10. Expertises (bento calme) --------------------------------- */
.bento { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4); margin-top: var(--s-7); }
.bento > article { border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); display: grid; gap: var(--s-3); align-content: start; background: var(--paper); transition: border-color var(--dur-2), transform var(--dur-2) var(--ease-out); container-type: inline-size; }
.bento > article:hover { border-color: var(--ink-2); }
.bento .num { font-family: var(--f-mono); font-size: var(--t-xs); color: var(--ink-2); }
.bento h3 { font-size: var(--t-lg); }
.bento .headline { color: var(--accent); font-size: var(--t-sm); }
.bento details { margin-top: auto; }
.bento summary { cursor: pointer; font-family: var(--f-mono); font-size: var(--t-xs); letter-spacing: 0.06em; color: var(--ink-2); list-style: none; min-height: 32px; display: inline-flex; align-items: center; gap: var(--s-2); }
.bento summary::-webkit-details-marker { display: none; }
.bento summary::after { content: "+"; font-size: 14px; }
.bento details[open] summary::after { content: "–"; }
.bento ul { margin: var(--s-3) 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-2); }
.bento li { font-family: var(--f-mono); font-size: var(--t-xs); padding: var(--s-1) var(--s-3); border: 1px solid var(--line); border-radius: var(--r-pill); color: var(--ink-2); }
@media (max-width: 960px) { .bento { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .bento { grid-template-columns: 1fr; } }

/* ---------- 11. Projets -------------------------------------------------- */
.filters { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-top: var(--s-6); }
.filters [role="group"] { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.pgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-5); margin-top: var(--s-5); }
.card { display: grid; gap: var(--s-3); text-align: left; background: none; border: 0; padding: 0; color: inherit; view-transition-name: var(--vt); }
.card .thumb { aspect-ratio: 4/3; border-radius: var(--r-md); overflow: hidden; background: var(--paper-2); position: relative; border: 1px solid var(--line); }
.card img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--dur-3) var(--ease-out); }
.card:hover img { transform: scale(1.03); }
.card .tag { position: absolute; top: var(--s-3); left: var(--s-3); font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.06em; padding: 4px 10px; border-radius: var(--r-pill); background: color-mix(in oklch, var(--paper) 78%, transparent); backdrop-filter: blur(4px); }
.card h3 { font-size: var(--t-lg); }
.card .hook { color: var(--ink-2); font-size: var(--t-sm); }
@media (max-width: 960px) { .pgrid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .pgrid { grid-template-columns: 1fr; } }

/* ---------- 12. Pourquoi moi / stats ------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; margin-top: var(--s-7); }
.stats > div { background: var(--paper); padding: var(--s-6) var(--s-5); }
.stats .v { font-family: var(--f-display); font-size: var(--t-2xl); color: var(--accent); }
.stats .l { margin-top: var(--s-2); font-size: var(--t-sm); color: var(--ink-2); }
.manifesto { font-family: var(--f-display); font-size: var(--t-xl); font-weight: 300; line-height: 1.35; max-width: 34ch; margin-top: var(--s-6); }
@media (max-width: 860px) { .stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stats { grid-template-columns: 1fr; } }

/* ---------- 13. Parcours ------------------------------------------------- */
.journey-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-5); flex-wrap: wrap; }
.timeline { margin-top: var(--s-7); }
.job { display: grid; grid-template-columns: 180px 1fr; gap: var(--s-6); padding: var(--s-6) 0; border-top: 1px solid var(--line); }
.job .period { font-family: var(--f-mono); font-size: var(--t-sm); color: var(--ink-2); }
.job h3 { font-size: var(--t-xl); }
.job .co { font-family: var(--f-mono); font-size: var(--t-sm); color: var(--accent); margin-top: var(--s-2); }
.job p { margin-top: var(--s-3); color: var(--ink-2); max-width: var(--measure); }
.job ul { margin: var(--s-3) 0 0; padding-inline-start: 1.1em; color: var(--ink-2); font-size: var(--t-sm); display: grid; gap: var(--s-1); }
.job .skills { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-4); }
.job.edu h3 { font-size: var(--t-lg); }
@media (max-width: 720px) { .job { grid-template-columns: 1fr; gap: var(--s-2); } }

/* ---------- 14. Contact -------------------------------------------------- */
.contact-grid { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: var(--s-8); margin-top: var(--s-7); align-items: start; }
.steps { display: grid; }
.step { display: grid; grid-template-columns: 32px 1fr; gap: var(--s-4); padding: var(--s-4) 0; border-top: 1px solid var(--line); }
.step:last-child { border-bottom: 1px solid var(--line); }
.step .num { font-family: var(--f-mono); font-size: var(--t-sm); color: var(--accent); }
.step .d { color: var(--ink-2); font-size: var(--t-sm); margin-top: 2px; }
.contact-direct { margin-top: var(--s-6); display: grid; gap: var(--s-3); }
.email-row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; font-family: var(--f-mono); }
.form { display: grid; gap: var(--s-5); }
.form .intents { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.form-foot { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; }
.ok-box { border: 1px solid color-mix(in oklch, var(--accent) 50%, transparent); border-radius: var(--r-lg); padding: var(--s-7) var(--s-6); text-align: center; display: grid; gap: var(--s-3); justify-items: center; }
.ok-box .check { width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 24px; }
@media (max-width: 860px) { .contact-grid { grid-template-columns: 1fr; gap: var(--s-7); } }

/* ---------- 15. Footer --------------------------------------------------- */
footer { border-top: 1px solid var(--line); padding: var(--s-6) var(--gutter); display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--s-3); font-family: var(--f-mono); font-size: var(--t-xs); letter-spacing: 0.06em; color: var(--ink-2); text-transform: uppercase; }

/* ---------- 16. Dialogs natifs (CV, projet, palette) --------------------- */
dialog { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--paper); color: var(--ink); padding: 0; max-width: min(92vw, 520px); width: 100%; box-shadow: 0 30px 80px rgb(0 0 0 / 0.35); }
body:has(dialog[open]) { overflow: hidden; }
dialog::backdrop { background: color-mix(in oklch, var(--ink) 55%, transparent); backdrop-filter: blur(4px); }
dialog[open] { animation: dialog-in var(--dur-2) var(--ease-out); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(16px); } }
@supports (transition-behavior: allow-discrete) {
  dialog { transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out), overlay var(--dur-2) allow-discrete, display var(--dur-2) allow-discrete; }
  dialog:not([open]) { opacity: 0; transform: translateY(12px); }
  @starting-style { dialog[open] { opacity: 0; transform: translateY(12px); } }
}
.dlg { padding: var(--s-6); display: grid; gap: var(--s-4); }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); }
.dlg h3 { font-size: var(--t-xl); font-weight: 300; }
.dlg .close { width: var(--target); height: var(--target); display: grid; place-items: center; border: 0; background: none; border-radius: var(--r-pill); color: var(--ink-2); margin: calc(var(--s-2) * -1) calc(var(--s-2) * -1) 0 0; }
.dlg .close:hover { background: var(--paper-2); color: var(--ink); }
.dlg form { display: grid; gap: var(--s-4); }
.dlg .two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.dlg .fine { font-family: var(--f-mono); font-size: var(--t-xs); color: var(--ink-2); text-align: center; }

/* Fiche projet : un parcours, pas une boîte. Desktop = panneau ; mobile = plein écran. */
dialog.project { max-width: min(96vw, 1040px); max-height: 92svh; overflow: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.proj { display: grid; }
.proj-top {
  position: sticky; top: 0; z-index: 3;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: color-mix(in oklch, var(--paper) 86%, transparent); backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.proj-top > .mono { text-align: center; }
.proj-top .short { display: none; }
.proj-nav { display: flex; gap: var(--s-1); justify-content: end; }
.proj-nav .icon-btn { border-color: var(--line); font-family: var(--f-mono); font-size: var(--t-md); }
.proj-nav .icon-btn:disabled { opacity: 0.35; cursor: default; }
.proj-head { padding: var(--s-6) var(--s-6) 0; display: grid; gap: var(--s-3); }
.proj-head h3 { font-size: var(--t-2xl); }
.proj-visual { margin: var(--s-5) var(--s-6) 0; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); background: var(--paper-2); }
.proj-visual img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.proj-body { padding: var(--s-6); max-width: 70ch; color: var(--ink-2); line-height: 1.7; }
.proj-body h3 { font-size: var(--t-xs); font-family: var(--f-mono); font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin: var(--s-5) 0 var(--s-2); }
.proj-body h2 { font-size: var(--t-lg); font-weight: 400; color: var(--ink); margin: 0 0 var(--s-3); }
.proj-body p { margin: 0 0 var(--s-3); }
.proj-gallery { display: grid; gap: var(--s-4); padding: 0 var(--s-6) var(--s-6); }
.proj-gallery img { border-radius: var(--r-md); border: 1px solid var(--line); }
.proj-ask { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: var(--s-7); padding: var(--s-7) var(--s-6); border-top: 1px solid var(--line); align-items: start; }
.proj-ask h3 { font-size: var(--t-xl); margin: var(--s-2) 0; }
.form.compact { gap: var(--s-4); }
.form.compact textarea { min-height: 72px; }

.proj-next {
  display: grid; grid-template-columns: 120px 1fr auto; gap: var(--s-5); align-items: center;
  margin: 0 var(--s-6) var(--s-6); padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-lg);
  text-decoration: none; color: inherit; transition: border-color var(--dur-2), background var(--dur-2);
}
.proj-next:hover { border-color: var(--ink-2); background: var(--paper-2); color: inherit; }
.proj-next .thumb { aspect-ratio: 4/3; border-radius: var(--r-md); overflow: hidden; background: var(--paper-2); }
.proj-next .thumb img { width: 100%; height: 100%; object-fit: cover; }
.proj-next > div { display: grid; gap: 2px; min-width: 0; }
.proj-next .kicker { margin: 0 0 var(--s-1); }
.proj-next strong { font-family: var(--f-display); font-weight: 400; font-size: var(--t-xl); line-height: 1.1; }
.proj-next .muted { font-size: var(--t-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-next .arrow { font-family: var(--f-mono); font-size: var(--t-xl); color: var(--accent); transition: transform var(--dur-2) var(--ease-out); }
.proj-next:hover .arrow { transform: translateX(6px); }

/* Barre d'actions : cachée sur desktop (tout est à portée), collée en bas sur mobile */
.proj-actions { display: none; }

@media (max-width: 720px) {
  dialog.project { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0; padding-bottom: 88px; }
  dialog.project[open] { animation: sheet-in var(--dur-3) var(--ease-out); }
  @keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
  .proj-head, .proj-body, .proj-visual, .proj-gallery, .proj-ask, .proj-next { margin-inline: 0; padding-inline: var(--gutter); }
  .proj-visual { margin-inline: 0; border-radius: 0; border-inline: 0; }
  .proj-visual img { aspect-ratio: 4/3; }
  .proj-ask { grid-template-columns: 1fr; gap: var(--s-5); }
  .proj-next { grid-template-columns: 88px 1fr auto; margin: 0 var(--gutter) var(--s-6); }
  .proj-top .btn-ghost { padding-inline: 0; }
  .proj-top .long { display: none; }
  .proj-top .short { display: inline; }
  .proj-actions {
    position: fixed; inset: auto 0 0 0; z-index: 4;
    display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--s-2);
    padding: var(--s-3) var(--gutter) calc(var(--s-3) + env(safe-area-inset-bottom));
    background: color-mix(in oklch, var(--paper) 88%, transparent); backdrop-filter: blur(14px) saturate(1.2);
    border-top: 1px solid var(--line);
  }
  .proj-actions .btn { padding-inline: var(--s-3); font-size: var(--t-xs); }
  .proj-actions .btn:first-child { justify-self: start; }
  .proj-actions .btn:last-child { justify-self: end; }
}
.nav .short { display: none; }
@media (max-width: 520px) {
  .nav { gap: var(--s-2); }
  .nav .btn-primary { padding-inline: var(--s-4); }
  .nav .long { display: none; }
  .nav .short { display: inline; }
}

/* Palette de commandes (⌘K) — multimodal : clavier, souris, tactile */
dialog.palette { max-width: min(92vw, 600px); margin-top: 10vh; }
.palette-input { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: var(--s-4) var(--s-5); font-size: var(--t-lg); }
.palette-input:focus-visible { outline: none; border-bottom-color: var(--accent); }
.palette-list { list-style: none; margin: 0; padding: var(--s-2); max-height: 50svh; overflow: auto; }
.palette-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); min-height: var(--target); padding: var(--s-2) var(--s-4); border-radius: var(--r-md); cursor: pointer; }
.palette-list li[aria-selected="true"], .palette-list li:hover { background: var(--paper-2); }
.palette-list .k { font-family: var(--f-mono); font-size: var(--t-xs); color: var(--ink-2); letter-spacing: 0.06em; text-transform: uppercase; }
.palette-foot { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line); font-family: var(--f-mono); font-size: 10px; color: var(--ink-2); letter-spacing: 0.06em; }

/* ---------- 18. Transitions de vue (thème, filtres) ---------------------- */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: var(--dur-2); }

/* Les cartes ne sont nommées que pour animer les filtres. Une modale ouverte,
   elles rentrent dans le rang : sinon le navigateur les soulève au-dessus de la
   fiche pendant la transition projet → projet (flash des vignettes). */
body:has(dialog[open]) .card { view-transition-name: none; }

/* La fiche projet fond sur elle-même, indépendamment du reste de la page. */
#project-dialog[open] .proj { view-transition-name: project-panel; }
::view-transition-old(project-panel) { animation: vt-out var(--dur-2) var(--ease-out) both; }
::view-transition-new(project-panel) { animation: vt-in var(--dur-2) var(--ease-out) both; }
@keyframes vt-out { to { opacity: 0; transform: translateX(calc(-12px * var(--vt-dir, 1))); } }
@keyframes vt-in { from { opacity: 0; transform: translateX(calc(12px * var(--vt-dir, 1))); } }
html[data-vt-dir="-1"] { --vt-dir: -1; }
::view-transition-group(project-panel) { animation-duration: var(--dur-2); }

/* ---------- 19. Impression ----------------------------------------------- */
@media print {
  .nav, .progress, .hero-ctas, .filters, dialog, footer, .cv-btn { display: none !important; }
  section { padding-block: 1.2cm; break-inside: avoid; }
  body { background: #fff; color: #000; }
}
