/* ==========================================================================
   Amine Krefa — Portfolio
   Design system : tokens, base, layout, composants
   ========================================================================== */

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

  /* Surfaces */
  --bg:            #F8FAFC;
  --bg-alt:        #F1F5F9;
  --surface:       #FFFFFF;
  --surface-2:     #FFFFFF;
  --ink-invert-bg: #0F172A;

  /* Texte */
  --ink:    #0F172A;  /* 16.8:1 sur --bg */
  --ink-2:  #334155;  /*  9.9:1 sur --bg */
  --ink-3:  #475569;  /*  7.4:1 sur --bg — plancher AA pour les labels */
  --on-dark:    #F8FAFC;
  --on-dark-2:  #CBD5E1;
  --on-dark-3:  #A9B7C9;

  /* Accent */
  --accent:      #1E3A8A;  /* 10.4:1 sur --bg */
  --accent-2:    #2563EB;  /*  5.6:1 sur --bg — AA texte normal */
  --accent-soft: #EEF2FF;
  --accent-line: #C7D2FE;

  /* Lignes */
  --line:        #E2E8F0;
  --line-strong: #CBD5E1;

  /* Typographie — piles web-safe, aucune webfont, aucun CLS */
  --font-sans: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* Échelle typographique fluide */
  --fs-display: clamp(2.5rem, 1.4rem + 4.6vw, 5rem);
  --fs-h1:      clamp(2rem, 1.3rem + 2.9vw, 3.5rem);
  --fs-h2:      clamp(1.65rem, 1.2rem + 1.9vw, 2.5rem);
  --fs-h3:      clamp(1.15rem, 1rem + 0.7vw, 1.5rem);
  --fs-lead:    clamp(1.0625rem, 1rem + 0.5vw, 1.3125rem);
  --fs-body:    1.0625rem;
  --fs-sm:      0.9375rem;
  --fs-xs:      0.8125rem;
  --fs-label:   0.75rem;

  /* Rythme */
  --space-1: 4px;   --space-2: 8px;   --space-3: 12px;  --space-4: 16px;
  --space-5: 24px;  --space-6: 32px;  --space-7: 48px;  --space-8: 64px;
  --space-9: 96px;  --space-10: 128px;

  --container: 1200px;
  --gutter: clamp(20px, 5vw, 64px);

  --radius-sm: 6px;
  --radius:    12px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow:    0 4px 20px -6px rgba(15, 23, 42, .10), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .22), 0 2px 8px rgba(15, 23, 42, .05);

  --ease: cubic-bezier(.22, .61, .36, 1);
  --dur:  .45s;

  --nav-h: 68px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg:            #0B1120;
  --bg-alt:        #0F172A;
  --surface:       #111C33;
  --surface-2:     #16233D;
  --ink-invert-bg: #060B16;

  --ink:    #F1F5F9;
  --ink-2:  #D3DCE7;
  --ink-3:  #A9B7C9;  /* 8.4:1 sur --bg */
  --on-dark:    #F1F5F9;
  --on-dark-2:  #CBD5E1;
  --on-dark-3:  #A9B7C9;

  --accent:      #A5C0FF;
  --accent-2:    #8AB0FF;
  --accent-soft: #16233D;
  --accent-line: #2A3E63;

  --line:        #1E293B;
  --line-strong: #2A3A52;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow:    0 4px 20px -6px rgba(0, 0, 0, .55);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .7);
}

/* --- 2. Reset & base ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 24px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.65;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.028em;
  text-wrap: balance;
}
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); letter-spacing: -0.018em; line-height: 1.3; }
p  { margin: 0 0 1.1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent-2); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }

img, svg { max-width: 100%; height: auto; display: block; }
ul, ol { margin: 0 0 1.1em; padding-left: 1.15em; }
li { margin-bottom: .4em; }
li::marker { color: var(--ink-3); }
strong { font-weight: 700; color: var(--ink); }

hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-8) 0; }

::selection { background: var(--accent-2); color: #fff; }

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

.skip-link {
  position: absolute; left: var(--space-4); top: var(--space-4);
  transform: translateY(-200%);
  z-index: 200;
  background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: var(--fs-sm); font-weight: 600; text-decoration: none;
  transition: transform .2s var(--ease);
}
.skip-link:focus { transform: translateY(0); color: #fff; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* --- 3. Layout ----------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--narrow { max-width: 820px; }

.section { padding-block: clamp(64px, 9vw, 128px); }
.section--tight { padding-block: clamp(48px, 6vw, 88px); }
.section--metrics { padding-top: 0; }
.section--alt { background: var(--bg-alt); }
.section--dark {
  background: var(--ink-invert-bg);
  color: var(--on-dark);
}
.section--dark h2, .section--dark h3, .section--dark strong { color: var(--on-dark); }
.section--dark p { color: var(--on-dark-2); }

.section-head { max-width: 760px; margin-bottom: clamp(40px, 5vw, 64px); }
.section-head p { color: var(--ink-2); font-size: var(--fs-lead); margin-top: var(--space-4); }
.section--dark .section-head p { color: var(--on-dark-2); }

.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--space-4);
}
.eyebrow::before {
  content: ""; width: 24px; height: 1px; background: var(--line-strong); flex: none;
}
.section--dark .eyebrow { color: var(--on-dark-3); }
.section--dark .eyebrow::before { background: #33415C; }

.lead { font-size: var(--fs-lead); color: var(--ink-2); line-height: 1.6; }

/* --- 4. Navigation ------------------------------------------------------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid transparent;
  transition: background-color .3s var(--ease), border-color .3s var(--ease), box-shadow .3s var(--ease);
}
@supports (backdrop-filter: blur(1px)) {
  .nav { backdrop-filter: saturate(180%) blur(16px); }
}
.nav.is-stuck {
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom-color: var(--line);
}
.nav__inner {
  width: 100%; max-width: var(--container); margin-inline: auto;
  padding-inline: var(--gutter);
  display: flex; align-items: center; gap: var(--space-5);
}
.nav__brand {
  font-weight: 700; font-size: 1rem; letter-spacing: -0.02em;
  color: var(--ink); text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 10px;
}
.nav__brand:hover { color: var(--accent-2); }
.nav__mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0;
  font-family: var(--font-mono);
}
[data-theme="dark"] .nav__mark { background: var(--accent-2); color: #0B1120; }

.nav__links {
  display: flex; align-items: center; gap: var(--space-2);
  margin: 0 auto 0 var(--space-6); padding: 0; list-style: none;
}
.nav__links li { margin: 0; }
.nav__link {
  position: relative;
  display: inline-block;
  padding: 8px 12px;
  font-size: var(--fs-sm); font-weight: 500;
  color: var(--ink-2); text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color .2s var(--ease);
}
.nav__link:hover { color: var(--ink); }
.nav__link::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 2px;
  height: 2px; border-radius: 2px; background: var(--accent-2);
  transform: scaleX(0); transform-origin: left;
  transition: transform .3s var(--ease);
}
.nav__link:hover::after { transform: scaleX(.4); }
.nav__link.is-active { color: var(--ink); font-weight: 600; }
.nav__link.is-active::after { transform: scaleX(1); }

.nav__tools { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; }

.lang {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 2px; background: var(--surface);
}
.lang a {
  font-family: var(--font-mono);
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em;
  padding: 4px 10px; border-radius: 999px;
  color: var(--ink-3); text-decoration: none; line-height: 1.4;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.lang a:hover { color: var(--ink); }
.lang a[aria-current="true"] { background: var(--ink); color: var(--bg); }

.icon-btn {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); color: var(--ink-2);
  cursor: pointer;
  transition: color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); transform: translateY(-1px); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.nav__burger { display: none; }

.nav__progress {
  position: absolute; left: 0; bottom: -1px; height: 2px;
  background: var(--accent-2); width: 0;
  transition: width .1s linear;
}

/* --- 5. Boutons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px;
  padding: 13px 24px;
  border: 1px solid transparent; border-radius: 999px;
  font-family: inherit; font-size: var(--fs-sm); font-weight: 600;
  letter-spacing: -0.005em;
  text-decoration: none; cursor: pointer;
  transition: background-color .25s var(--ease), color .25s var(--ease),
              border-color .25s var(--ease), transform .25s var(--ease),
              box-shadow .25s var(--ease);
}
.btn svg { width: 16px; height: 16px; flex: none; transition: transform .3s var(--ease); }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn--primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--accent-2); color: #fff; box-shadow: var(--shadow); }
.btn--primary:hover svg { transform: translateX(3px); }
[data-theme="dark"] .btn--primary { background: var(--accent-2); color: #0B1120; }
[data-theme="dark"] .btn--primary:hover { background: #B8CEFF; color: #0B1120; }

.btn--ghost { border-color: var(--line-strong); color: var(--ink); background: transparent; }
.btn--ghost:hover { border-color: var(--ink); color: var(--ink); background: var(--surface); }

.btn--light { background: #fff; color: #0F172A; }
.btn--light:hover { background: #E2E8F0; color: #0F172A; }
.btn--outline-light { border-color: #33415C; color: var(--on-dark); }
.btn--outline-light:hover { border-color: var(--on-dark); color: var(--on-dark); }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }

.link-arrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: var(--fs-sm);
  text-decoration: none; color: var(--accent-2);
}
.link-arrow svg { width: 15px; height: 15px; transition: transform .3s var(--ease); }
.link-arrow:hover svg { transform: translateX(4px); }

/* --- 6. Hero ------------------------------------------------------------- */
.hero {
  position: relative;
  padding-top: calc(var(--nav-h) + clamp(56px, 9vw, 120px));
  padding-bottom: clamp(40px, 5vw, 72px);
  overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; z-index: 0;
  top: -18%; right: -12%; width: min(760px, 78vw); aspect-ratio: 1;
  background: radial-gradient(circle at 50% 50%,
              color-mix(in srgb, var(--accent-2) 13%, transparent) 0%,
              transparent 68%);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }

.hero__grid {
  display: grid; gap: clamp(40px, 5vw, 72px);
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  align-items: start;
}

.status {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 6px 14px 6px 11px;
  border: 1px solid var(--accent-line); border-radius: 999px;
  background: var(--accent-soft);
  font-size: var(--fs-xs); font-weight: 600; color: var(--accent);
  margin-bottom: var(--space-6);
}
[data-theme="dark"] .status { color: var(--accent); }
.status__dot {
  width: 7px; height: 7px; border-radius: 50%; background: #059669; flex: none;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, .18);
}
[data-theme="dark"] .status__dot { background: #34D399; }

.hero h1 { font-size: var(--fs-display); letter-spacing: -0.04em; }
.hero__role {
  margin-top: var(--space-5);
  font-size: var(--fs-h3); font-weight: 600; color: var(--ink);
  letter-spacing: -0.02em; line-height: 1.35;
}
.hero__pitch {
  margin-top: var(--space-5);
  font-size: var(--fs-lead); color: var(--ink-2); max-width: 60ch; line-height: 1.62;
}
.hero .btn-row { margin-top: var(--space-7); }

.hero__aside {
  border-left: 1px solid var(--line);
  padding-left: clamp(20px, 3vw, 40px);
  padding-top: 6px;
}
.hero__aside dl { margin: 0; display: grid; gap: var(--space-5); }
.hero__aside dt {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);
  margin-bottom: 5px;
}
.hero__aside dd { margin: 0; font-size: var(--fs-sm); color: var(--ink); font-weight: 500; }
.hero__aside dd a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.hero__aside dd a:hover { color: var(--accent-2); border-color: var(--accent-2); }

/* --- 7. Bandeau de métriques -------------------------------------------- */
.metrics-caption {
  margin-top: var(--space-4);
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.metrics {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.metric {
  display: flex; flex-direction: column;
  padding: clamp(28px, 4vw, 44px) clamp(16px, 2.4vw, 32px);
  border-left: 1px solid var(--line);
}
.metric__label { flex: 1 1 auto; }
.metric:first-child { border-left: 0; }
.metric__value {
  font-size: clamp(1.9rem, 1.2rem + 2.1vw, 3rem);
  font-weight: 700; letter-spacing: -0.04em; line-height: 1;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.metric__value span { color: var(--accent-2); }
.metric__label {
  margin-top: var(--space-3);
  font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.45;
}
.metric__source {
  margin-top: var(--space-2);
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}

/* --- 8. Cartes études de cas -------------------------------------------- */
.cases { display: grid; gap: clamp(20px, 2.5vw, 28px); }

.case-card {
  position: relative;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  gap: clamp(20px, 3vw, 48px);
  align-items: start;
  padding: clamp(28px, 3.4vw, 44px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform .4s var(--ease), box-shadow .4s var(--ease), border-color .4s var(--ease);
}
.case-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
.case-card:focus-within { border-color: var(--accent-2); }

.case-card__index {
  font-family: var(--font-mono); font-size: clamp(1.5rem, 1.1rem + 1.1vw, 2.1rem);
  font-weight: 600; color: var(--ink-3); letter-spacing: -0.02em;
  line-height: 1; padding-top: 4px;
}
.case-card__body h3 { margin-bottom: 10px; }
.case-card__body h3 a { color: var(--ink); text-decoration: none; }
.case-card__body h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.case-card:hover h3 a { color: var(--accent-2); }
.case-card__org {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);
  margin-bottom: var(--space-4); display: block;
}
.case-card__body p { color: var(--ink-2); font-size: var(--fs-sm); max-width: 62ch; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--space-4); list-style: none; padding: 0; }
.tags li { margin: 0; }
.tag {
  display: inline-block;
  padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-size: var(--fs-xs); color: var(--ink-3); background: var(--bg);
  white-space: nowrap;
}

.case-card__cta {
  width: 46px; height: 46px; flex: none; margin-top: 4px;
  display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--line-strong); color: var(--ink-2);
  transition: background-color .35s var(--ease), color .35s var(--ease),
              border-color .35s var(--ease), transform .35s var(--ease);
}
.case-card__cta svg { width: 17px; height: 17px; }
.case-card:hover .case-card__cta {
  background: var(--accent); border-color: var(--accent); color: #fff; transform: translateX(4px);
}
[data-theme="dark"] .case-card:hover .case-card__cta { background: var(--accent-2); color: #0B1120; border-color: var(--accent-2); }

/* --- 9. Grilles génériques ---------------------------------------------- */
.grid { display: grid; gap: clamp(20px, 2.6vw, 32px); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
  padding: clamp(24px, 2.8vw, 34px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .35s var(--ease);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.card h3 { margin-bottom: var(--space-3); }
.card p { color: var(--ink-2); font-size: var(--fs-sm); }
.card__num {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 600;
  letter-spacing: .14em; color: var(--accent-2); display: block; margin-bottom: var(--space-4);
}

.section--dark .card {
  background: #131F36; border-color: #22314D; box-shadow: none;
}
.section--dark .card:hover { border-color: #33455F; }
.section--dark .card p { color: var(--on-dark-2); }
.section--dark .card__num { color: #A5C0FF; }
.section--dark .callout__label { color: var(--on-dark-3); }
.section--dark .tag { background: transparent; border-color: #33415C; color: var(--on-dark-3); }

/* --- 10. Parcours (timeline) -------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: clamp(20px, 3vw, 48px);
  padding: clamp(24px, 3vw, 36px) 0;
  border-top: 1px solid var(--line);
  margin: 0;
}
.timeline > li:last-child { border-bottom: 1px solid var(--line); }
.timeline__when {
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: .06em; color: var(--ink-3); padding-top: 5px;
}
.timeline__when span { display: block; margin-top: 5px; letter-spacing: .02em; font-weight: 400; }
.timeline__role { font-size: var(--fs-h3); margin-bottom: 4px; }
.timeline__org {
  font-size: var(--fs-sm); font-weight: 600; color: var(--accent-2); margin-bottom: var(--space-3);
}
.timeline__desc { color: var(--ink-2); font-size: var(--fs-sm); }
.timeline ul { margin-top: var(--space-3); margin-bottom: 0; padding-left: 1.1em; }
.timeline ul li { color: var(--ink-2); font-size: var(--fs-sm); }

/* --- 11. Compétences ----------------------------------------------------- */
.skills { display: grid; gap: clamp(24px, 3vw, 40px); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.skills__group h3 {
  font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .12em;
  font-family: var(--font-mono); color: var(--ink-3); font-weight: 600;
  margin-bottom: var(--space-4);
}
.skills__group ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.skills__group li { margin: 0; }

/* --- 12. Contact & formulaire ------------------------------------------- */
.contact-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: clamp(40px, 5vw, 80px); align-items: start;
}
.contact-list { list-style: none; padding: 0; margin: var(--space-6) 0 0; display: grid; gap: var(--space-5); }
.contact-list li { margin: 0; }
.contact-list dt,
.contact-list .contact-list__label {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--on-dark-3);
  display: block; margin-bottom: 5px;
}
.contact-list a { color: var(--on-dark); text-decoration: none; border-bottom: 1px solid #33415C; font-weight: 500; }
.contact-list a:hover { color: #fff; border-color: var(--on-dark); }
.contact-list span { color: var(--on-dark-2); }

.form { display: grid; gap: var(--space-5); }
.field { display: grid; gap: 7px; }
.field label { font-size: var(--fs-sm); font-weight: 600; color: var(--on-dark); }
.field .req { color: #FCA5A5; }
.field input, .field textarea {
  width: 100%;
  font-family: inherit; font-size: var(--fs-body); color: var(--on-dark);
  background: #131F36;
  border: 1px solid #2A3A52; border-radius: var(--radius-sm);
  padding: 13px 15px;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.field textarea { min-height: 150px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: #7C8CA4; }
.field input:hover, .field textarea:hover { border-color: #3B4E6B; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; border-color: transparent; }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: #F87171; }
.field .error { font-size: var(--fs-xs); color: #FCA5A5; min-height: 1em; }
.form__note { font-size: var(--fs-xs); color: var(--on-dark-3); }
.form__status { font-size: var(--fs-sm); font-weight: 600; }
.form__status[data-state="ok"]  { color: #6EE7B7; }
.form__status[data-state="err"] { color: #FCA5A5; }
.hp { position: absolute; left: -9999px; opacity: 0; }

/* --- 13. Footer ---------------------------------------------------------- */
.footer {
  background: var(--ink-invert-bg); color: var(--on-dark-2);
  padding-block: var(--space-8) var(--space-6);
  border-top: 1px solid #1B2740;
}
.footer__top {
  display: flex; flex-wrap: wrap; gap: var(--space-6);
  justify-content: space-between; align-items: flex-start;
  padding-bottom: var(--space-7); border-bottom: 1px solid #1B2740;
}
.footer__brand { font-size: var(--fs-h3); font-weight: 700; color: var(--on-dark); letter-spacing: -0.02em; }
.footer__brand span { display: block; font-size: var(--fs-sm); font-weight: 400; color: var(--on-dark-3); margin-top: 6px; letter-spacing: 0; }
.footer__nav { display: flex; flex-wrap: wrap; gap: var(--space-6); }
.footer__col h2 {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--on-dark-3);
  margin-bottom: var(--space-4);
}
.footer__col ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.footer__col li { margin: 0; }
.footer__col a { color: var(--on-dark-2); text-decoration: none; font-size: var(--fs-sm); }
.footer__col a:hover { color: var(--on-dark); text-decoration: underline; text-underline-offset: 3px; }
.footer__bottom {
  padding-top: var(--space-5);
  display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: space-between;
  font-size: var(--fs-xs); color: var(--on-dark-3);
}
.footer__bottom p { margin: 0; }

/* --- 14. Page étude de cas ---------------------------------------------- */
.crumb {
  padding-top: calc(var(--nav-h) + 32px);
  font-size: var(--fs-sm);
}
.crumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; }
.crumb li { margin: 0; color: var(--ink-3); }
.crumb li + li::before { content: "/"; margin-right: 8px; color: var(--line-strong); }
.crumb a { color: var(--ink-3); text-decoration: none; }
.crumb a:hover { color: var(--accent-2); }
.crumb [aria-current="page"] { color: var(--ink-2); }

.case-hero { padding-top: var(--space-6); padding-bottom: clamp(40px, 5vw, 64px); }
.case-hero h1 { max-width: 20ch; }
.case-hero__sub { margin-top: var(--space-5); font-size: var(--fs-lead); color: var(--ink-2); max-width: 68ch; }

.meta {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-5);
  margin-top: clamp(40px, 5vw, 64px);
  padding-top: var(--space-6);
  border-top: 1px solid var(--line);
}
.meta dt {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 7px;
}
.meta dd { margin: 0; font-size: var(--fs-sm); color: var(--ink); font-weight: 500; line-height: 1.5; }

.case-layout {
  display: grid; grid-template-columns: 232px minmax(0, 1fr);
  gap: clamp(40px, 5vw, 88px);
  align-items: start;
}
.toc { position: sticky; top: calc(var(--nav-h) + 32px); }
.toc h2 {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3);
  margin-bottom: var(--space-4);
}
.toc ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.toc li { margin: 0; }
.toc a {
  display: grid; grid-template-columns: 26px 1fr; gap: 4px;
  padding: 9px 12px 9px 0;
  font-size: var(--fs-sm); color: var(--ink-3); text-decoration: none;
  border-left: 2px solid var(--line); padding-left: 14px;
  transition: color .25s var(--ease), border-color .25s var(--ease);
}
.toc a span { font-family: var(--font-mono); font-size: var(--fs-xs); }
.toc a:hover { color: var(--ink); border-color: var(--line-strong); }
.toc a.is-active { color: var(--ink); font-weight: 600; border-color: var(--accent-2); }

.case-body > section { padding-bottom: clamp(48px, 6vw, 88px); }
.case-body > section:last-child { padding-bottom: 0; }
.case-body h2 { margin-bottom: var(--space-5); }
.case-body h3 { margin-top: var(--space-7); margin-bottom: var(--space-3); }
.case-body p, .case-body li { color: var(--ink-2); }
.case-body p { max-width: 72ch; }

.callout {
  margin: var(--space-6) 0;
  padding: clamp(22px, 2.6vw, 30px);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
}
.callout p { margin: 0; color: var(--ink); }
.callout__label {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--accent);
  display: block; margin-bottom: var(--space-3);
}

.quote {
  margin: var(--space-7) 0;
  padding-left: clamp(20px, 2.5vw, 30px);
  border-left: 3px solid var(--accent-2);
}
.quote blockquote { margin: 0; font-size: var(--fs-lead); color: var(--ink); line-height: 1.5; }
.quote figcaption { margin-top: var(--space-3); font-size: var(--fs-sm); color: var(--ink-3); }

.stat-row {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-5); margin: var(--space-6) 0;
}
.stat {
  padding: var(--space-5);
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.stat__value {
  font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.25rem); font-weight: 700;
  letter-spacing: -0.035em; color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums;
}
.stat__label { margin-top: 10px; font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.45; }

.next-case {
  border-top: 1px solid var(--line);
  padding-block: clamp(48px, 6vw, 80px);
}
.next-case a {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-4);
  text-decoration: none;
}
.next-case a h2 { color: var(--ink); transition: color .25s var(--ease); }
.next-case a:hover h2 { color: var(--accent-2); }

/* --- 15. Bouton retour en haut ------------------------------------------ */
.to-top {
  position: fixed; right: clamp(16px, 3vw, 32px); bottom: clamp(16px, 3vw, 32px);
  z-index: 90;
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink); color: var(--bg);
  border: 0; cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: opacity .3s var(--ease), transform .3s var(--ease), visibility .3s;
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.to-top:hover { background: var(--accent-2); color: #fff; }
.to-top svg { width: 18px; height: 18px; }

/* --- 16. Animations d'apparition ---------------------------------------- */
.reveal { opacity: 0; transform: translateY(22px); }
.js .reveal { transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.is-in { opacity: 1; transform: none; }
.reveal[data-delay="1"] { transition-delay: .08s; }
.reveal[data-delay="2"] { transition-delay: .16s; }
.reveal[data-delay="3"] { transition-delay: .24s; }
.reveal[data-delay="4"] { transition-delay: .32s; }
.reveal[data-delay="5"] { transition-delay: .40s; }
html:not(.js) .reveal { opacity: 1; transform: none; }

/* --- 17. Responsive ------------------------------------------------------ */
@media (max-width: 1100px) {
  .hero__grid { grid-template-columns: 1fr; }
  .hero__aside { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; padding-top: var(--space-6); }
  .hero__aside dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .case-layout { grid-template-columns: 1fr; }
  .toc {
    position: static;
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: var(--space-5); background: var(--surface);
  }
  .toc a { border-left: 0; padding-left: 0; }
  .toc a.is-active { border-color: transparent; }
  .meta { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .nav__links {
    position: fixed; inset: var(--nav-h) 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 0;
    margin: 0; padding: var(--space-4) var(--gutter) var(--space-6);
    background: var(--bg); border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateY(-12px); opacity: 0; visibility: hidden;
    transition: opacity .25s var(--ease), transform .25s var(--ease), visibility .25s;
  }
  .nav__links.is-open { transform: none; opacity: 1; visibility: visible; }
  .nav__link { padding: 14px 4px; font-size: 1rem; border-bottom: 1px solid var(--line); border-radius: 0; }
  .nav__link::after { display: none; }
  .nav__burger { display: grid; }
  .nav__tools { margin-left: auto; }

  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric { border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
  .metric:nth-child(-n+2) { border-top: 0; }
  .metric:nth-child(odd) { border-left: 0; }

  .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contact-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr; }
  .timeline > li { grid-template-columns: 1fr; gap: var(--space-3); }
  .timeline__when span { display: inline; margin-left: 8px; }
}

@media (max-width: 640px) {
  :root { --nav-h: 60px; }
  .case-card { grid-template-columns: 1fr; gap: var(--space-4); padding: var(--space-6) var(--space-5); }
  .case-card__index { padding-top: 0; }
  .case-card__cta { display: none; }
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .skills { grid-template-columns: 1fr; }
  .meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero__aside dl { grid-template-columns: 1fr; }
  .btn { width: 100%; }
  .btn-row { flex-direction: column; align-items: stretch; }
  .footer__nav { gap: var(--space-5); width: 100%; }
  .footer__col { min-width: 130px; }
}

@media (min-width: 1600px) {
  :root { --container: 1320px; }
}

/* --- 18. Préférences utilisateur ---------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1 !important; transform: none !important; }
  .btn:hover, .card:hover, .case-card:hover { transform: none; }
}

@media (prefers-contrast: more) {
  :root { --ink-2: #1E293B; --ink-3: #334155; --line: #CBD5E1; --line-strong: #94A3B8; }
}

/* --- 19. Impression ------------------------------------------------------ */
@media print {
  .nav, .to-top, .toc, .footer__nav, .form, .next-case { display: none !important; }
  body { background: #fff; color: #000; }
  .section, .hero { padding-block: 24px; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 11px; color: #555; }
}

/* --- 20. Images : figures, galeries, visionneuse ------------------------- */
.figure { margin: var(--space-7) 0; }
.figure:first-child { margin-top: var(--space-5); }

.figure__frame {
  display: block; position: relative; width: 100%; padding: 0;
  overflow: hidden; cursor: zoom-in;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .35s var(--ease), border-color .35s var(--ease), transform .35s var(--ease);
}
.figure__frame:hover { box-shadow: var(--shadow); border-color: var(--line-strong); transform: translateY(-2px); }
.figure__frame img { display: block; width: 100%; height: auto; }

/* Ratios de cadre par type de visuel — identiques hors et dans une galerie,
   pour que toutes les figures d'une même rangée s'alignent. */
.figure--crop  .figure__frame { aspect-ratio: 16 / 9; }
.figure--photo .figure__frame { aspect-ratio: 16 / 9; }
.figure--tall  .figure__frame { aspect-ratio: 3 / 4; }
.figure--phone .figure__frame { aspect-ratio: 9 / 16; max-width: 280px; margin-inline: auto; border-radius: 20px; }

.figure--crop  .figure__frame img,
.figure--photo .figure__frame img,
.figure--tall  .figure__frame img,
.figure--phone .figure__frame img { height: 100%; object-fit: cover; }

/* Captures d'interface : on garde le coin haut-gauche (navigation + titre) */
.figure--crop .figure__frame img { object-position: top left; }
.figure--tall .figure__frame img,
.figure--phone .figure__frame img { object-position: top center; }
.figure--photo .figure__frame img { object-position: center; }

.figure__zoom {
  position: absolute; right: 10px; bottom: 10px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  color: #fff; font-size: var(--fs-label); font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  opacity: 0; transform: translateY(4px);
  transition: opacity .25s var(--ease), transform .25s var(--ease);
  pointer-events: none;
}
.figure__frame:hover .figure__zoom,
.figure__frame:focus-visible .figure__zoom { opacity: 1; transform: none; }
.figure__zoom svg { width: 13px; height: 13px; }

.figure figcaption {
  margin-top: var(--space-3);
  font-size: var(--fs-sm); color: var(--ink-3); line-height: 1.5;
}
.figure figcaption b { color: var(--ink-2); font-weight: 600; }

/* Galeries */
.gallery { display: grid; gap: clamp(16px, 2vw, 24px); margin: var(--space-7) 0; }
.gallery--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gallery--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gallery--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gallery .figure { margin: 0; display: flex; flex-direction: column; }
.gallery--phones .figure--phone .figure__frame { max-width: none; }

@media (max-width: 900px) {
  .gallery--3, .gallery--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .gallery--2, .gallery--3, .gallery--4 { grid-template-columns: 1fr; }
  .gallery--phones { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .figure--phone .figure__frame { max-width: 240px; }
}

/* Dernière figure d'une section : pas de marge basse superflue */
.case-body > section > .figure:last-child,
.case-body > section > .gallery:last-child { margin-bottom: 0; }

@media (max-width: 900px) {
  .gallery--3, .gallery--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .gallery--2, .gallery--3, .gallery--4 { grid-template-columns: 1fr; }
  .figure--phone .figure__frame { max-width: 240px; }
}

/* Bandeau de logos clients */
.logos {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center; gap: clamp(24px, 4vw, 48px);
  margin-top: var(--space-6);
  padding-block: var(--space-6);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.logos img {
  height: clamp(26px, 3vw, 38px); width: auto; max-width: 100%;
  justify-self: center;
  filter: grayscale(1); opacity: .66;
  transition: filter .3s var(--ease), opacity .3s var(--ease);
}
@media (max-width: 640px) {
  .logos { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6) var(--space-5); }
}
.logos img:hover { filter: none; opacity: 1; }
/* En thème sombre, chaque logo est posé sur une plaque claire :
   c'est la seule façon de rester lisible quelle que soit la marque. */
[data-theme="dark"] .logos img {
  background: #fff; padding: 8px 12px; border-radius: 8px;
  box-sizing: content-box; filter: grayscale(1); opacity: .82;
}
[data-theme="dark"] .logos img:hover { filter: none; opacity: 1; }
.logos__label {
  grid-column: 1 / -1;
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);
  margin: 0;
}

/* Portrait dans le hero */
.hero__portrait {
  width: 100%; max-width: 260px;
  aspect-ratio: 1; overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  margin-bottom: var(--space-6);
  background: var(--bg-alt);
}
.hero__portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Vignette dans les cartes d'étude de cas */
.case-card { grid-template-columns: 168px minmax(0, 1fr) auto; }
.case-card__thumb {
  width: 168px; height: 118px; overflow: hidden;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--bg-alt); position: relative;
}
.case-card__thumb img {
  width: 100%; height: 100%; object-fit: cover; object-position: top center;
  transition: transform .5s var(--ease);
}
.case-card:hover .case-card__thumb img { transform: scale(1.04); }
.case-card__index {
  position: absolute; left: 8px; top: 6px; z-index: 1;
  font-size: var(--fs-label) !important; color: #fff !important;
  background: color-mix(in srgb, var(--ink) 82%, transparent);
  padding: 2px 7px; border-radius: 4px; line-height: 1.5; padding-top: 2px !important;
}
@media (max-width: 640px) {
  .case-card { grid-template-columns: 1fr; }
  .case-card__thumb { width: 100%; height: 150px; }
}

/* Bandeau d'écrans en fin d'étude de cas */
.screens-strip {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr);
  gap: var(--space-4); overflow-x: auto; padding-bottom: var(--space-4);
  scroll-snap-type: x mandatory; scrollbar-width: thin;
  margin: var(--space-6) calc(var(--gutter) * -1) 0;
  padding-inline: var(--gutter);
}
.screens-strip .figure { margin: 0; scroll-snap-align: start; }
.screens-strip .figure__frame { height: 160px; }
.screens-strip .figure__frame img { height: 100%; object-fit: cover; object-position: top center; }
.screens-strip figcaption { font-size: var(--fs-xs); }

/* Visionneuse (lightbox) */
.lightbox {
  border: 0; padding: 0; max-width: 100vw; max-height: 100vh;
  width: 100%; height: 100%;
  background: transparent; color: var(--on-dark);
  overflow: hidden;
}
.lightbox::backdrop { background: rgba(8, 12, 22, .93); }
.lightbox__inner {
  display: grid; grid-template-rows: auto 1fr auto;
  width: 100%; height: 100%;
  padding: clamp(12px, 2vw, 24px);
  gap: var(--space-3);
}
.lightbox__bar { display: flex; align-items: center; gap: var(--space-3); }
.lightbox__count {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  letter-spacing: .08em; color: #9AA8BD; margin-right: auto;
}
.lightbox__btn {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border-radius: 999px; border: 1px solid #33415C;
  background: rgba(255,255,255,.04); color: #E2E8F0; cursor: pointer;
  transition: background-color .2s var(--ease), border-color .2s var(--ease);
}
.lightbox__btn:hover { background: rgba(255,255,255,.12); border-color: #64748B; }
.lightbox__btn svg { width: 18px; height: 18px; }
.lightbox__stage {
  overflow: auto; display: grid; place-items: start center;
  border-radius: var(--radius); background: #0B1120;
  scrollbar-width: thin;
}
.lightbox__stage img { max-width: 100%; height: auto; display: block; border-radius: var(--radius); }
.lightbox__caption {
  font-size: var(--fs-sm); color: #CBD5E1; text-align: center;
  max-width: 80ch; margin-inline: auto; min-height: 1.5em;
}
@media (max-width: 640px) {
  .lightbox__caption { font-size: var(--fs-xs); }
}
