:root {
  color-scheme: light dark;
  --bg: #f7f5f0;
  --surface: #ffffff;
  --fg: #1b1a17;
  --muted: #5f5b53;
  --rule: #e3dfd6;
  --accent: #c2410c;
  --accent-soft: #fbe7dc;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --wrap: 68rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12110f;
    --surface: #1b1a17;
    --fg: #ece9e3;
    --muted: #a19c92;
    --rule: #2e2c28;
    --accent: #fb923c;
    --accent-soft: #3a2416;
  }
}

/* Palette « sous-sol » : toujours sombre, quel que soit le thème */
.night {
  color-scheme: dark;
  --bg: #12110f;
  --surface: #1b1a17;
  --fg: #ece9e3;
  --muted: #a19c92;
  --rule: #2e2c28;
  --accent: #fb923c;
  --accent-soft: #3a2416;
  background: var(--bg);
  color: var(--fg);
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule); }
a:hover { text-decoration-color: currentColor; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }

/* En-tête */
.site-header { border-bottom: 1px solid var(--rule); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 4rem; }
.site-header.overlay { position: absolute; top: 0; left: 0; right: 0; z-index: 2; background: transparent; border-bottom-color: rgba(236, 233, 227, .12); }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 650; letter-spacing: -0.01em; text-decoration: none; }
.brand-mark { width: 1.6rem; height: 1.6rem; display: block; }
.nav { display: flex; align-items: center; gap: 1.5rem; font-size: .95rem; }
.nav a { text-decoration: none; color: var(--muted); }
.nav a:hover { color: var(--fg); }
.nav a.lang { font: 500 .8rem/1 var(--mono); padding: .35rem .45rem; border: 1px solid var(--rule); color: var(--fg); }
.nav a.lang:hover { border-color: currentColor; }

/* Ouverture : le serveur, au sous-sol */
.opening { position: relative; min-height: 100vh; min-height: 100svh; display: flex; align-items: flex-end; overflow: hidden; }
.opening-bg { position: absolute; inset: 0; background: #12110f; }
.opening-lamps {
  position: absolute; top: 4rem; right: 0; width: min(54vw, 780px); aspect-ratio: 2 / 1;
  background: url("img/lustres.jpg") center / cover no-repeat;
  -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent), linear-gradient(to right, transparent, #000 35%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to bottom, #000 45%, transparent), linear-gradient(to right, transparent, #000 35%);
  mask-composite: intersect;
  pointer-events: none;
}
.opening .wrap { position: relative; width: 100%; padding-top: 8rem; padding-bottom: 5rem; }
.eyebrow { font: 500 .8rem/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 0 0 1.5rem; }
.opening h1 { font-size: clamp(2.4rem, 6.5vw, 4.6rem); line-height: 1.04; letter-spacing: -0.035em; font-weight: 750; margin: 0 0 1.75rem; max-width: 17ch; }
.opening h1 span { color: var(--accent); }
.lead { font-size: 1.2rem; color: var(--muted); max-width: 38rem; margin: 0; }
.scroll-hint { margin-top: 3rem; font: 500 .75rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: inline-flex; align-items: center; gap: .6rem; }
.scroll-hint::after { content: ""; width: 1px; height: 2.5rem; background: linear-gradient(var(--accent), transparent); }

/* Chapitres : image collée, texte qui défile */
.chapter { border-top: 1px solid var(--rule); }
.chapter .wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 4rem; align-items: start; }
.chapter.flip .visual { order: 2; }
.visual {
  position: sticky; top: 7vh; height: 86vh; margin: 0;
  border: 1px solid var(--rule);
  background-color: var(--surface);
  background-position: center; background-size: cover; background-repeat: no-repeat;
  display: flex; align-items: flex-end;
}
.visual figcaption { font: 500 .75rem/1.4 var(--mono); color: var(--muted); padding: 1rem 1.1rem; background: linear-gradient(transparent, rgba(18, 17, 15, .85)); width: 100%; }
.v-sous-sol { background-image: url("img/sous-sol.jpg"); }
.v-atelier { background-image: url("img/atelier.jpg"); background-position: 58% center; }
.v-reveil { background-image: url("img/reveil.jpg"); }
.story { min-height: 125vh; padding: 22vh 0; display: flex; flex-direction: column; justify-content: center; gap: 1.4rem; }
.num { font: 500 .8rem/1 var(--mono); color: var(--accent); }
.story h2 { font-size: clamp(1.8rem, 3.6vw, 2.6rem); letter-spacing: -0.025em; line-height: 1.12; margin: 0; }
.story p { color: var(--muted); margin: 0; font-size: 1.08rem; }
.story p strong { color: var(--fg); font-weight: 600; }

.punch { margin: .4rem 0 0; font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 750; letter-spacing: -0.03em; line-height: 1.2; color: var(--accent); }
.story p.punch { color: var(--accent); font-size: clamp(1.6rem, 3vw, 2.2rem); }
.punch span { display: block; font-size: 1rem; font-weight: 400; letter-spacing: 0; color: var(--muted); font-style: italic; margin-top: .3rem; }

.beat { list-style: none; margin: .5rem 0; padding: 0; display: grid; gap: .2rem; }
.beat li { font-size: clamp(1.7rem, 3.4vw, 2.4rem); font-weight: 750; letter-spacing: -0.03em; line-height: 1.15; }
.beat li::after { content: "."; color: var(--accent); }

.points { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: 1rem; }
.points li { color: var(--muted); padding-left: 1.4rem; position: relative; }
.points li::before { content: ""; position: absolute; left: 0; top: .6em; width: .5rem; height: .5rem; background: var(--accent); }
.points strong { color: var(--fg); font-weight: 600; }

.cycle { list-style: none; margin: .25rem 0; padding: 0; display: flex; flex-wrap: wrap; gap: .45rem .6rem; counter-reset: step; }
.cycle li { counter-increment: step; display: inline-flex; align-items: center; gap: .45rem; font-weight: 650; }
.cycle li::before { content: counter(step, decimal-leading-zero); font: 500 .72rem/1 var(--mono); color: var(--accent); }
.cycle li:not(:last-child)::after { content: "→"; color: var(--muted); font-weight: 400; margin-left: .2rem; }
.cycle li:last-child { color: var(--accent); }

.frame { padding: 1.25rem 1.5rem; background: var(--accent-soft); border-left: 3px solid var(--accent); }
.frame p { margin: 0; color: var(--fg); font-size: 1rem; }
.frame strong { font-weight: 650; }

/* Sections claires */
section.plain { padding: 5rem 0; border-top: 1px solid var(--rule); }
.section-head { display: grid; gap: .75rem; margin-bottom: 2.5rem; }
.section-head h2 { font-size: 1.9rem; letter-spacing: -0.02em; line-height: 1.2; margin: 0; }
.section-head p { color: var(--muted); margin: 0; max-width: 40rem; }

/* Projets */
.projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; margin: 0; padding: 0; list-style: none; }
.project { background: var(--surface); border: 1px solid var(--rule); padding: 1.75rem; display: flex; flex-direction: column; gap: .75rem; }
.project.featured { grid-column: 1 / -1; border-color: var(--accent); }
.project-top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.project h3 { font-size: 1.3rem; letter-spacing: -0.015em; margin: 0; }
.project h3 small { display: block; line-height: 1.4; margin-top: .15rem; font-size: .85rem; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.kind { font: 500 .78rem/1.4 var(--mono); color: var(--muted); margin: 0; }
.project p { margin: 0; color: var(--muted); }
.tag { font: 500 .75rem/1 var(--mono); padding: .4rem .55rem; border: 1px solid var(--rule); color: var(--muted); white-space: nowrap; }
.tag.now { background: var(--accent); border-color: var(--accent); color: var(--bg); }

/* Problèmes → solutions */
.problems { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; margin: 0; padding: 0; list-style: none; }
.problem { background: var(--surface); border: 1px solid var(--rule); padding: 2rem; display: flex; flex-direction: column; gap: 1rem; }
.pain { font-size: clamp(1.2rem, 2vw, 1.45rem); line-height: 1.35; font-weight: 650; letter-spacing: -0.015em; margin: 0; }
.answer { color: var(--accent); font-weight: 600; margin: 0; }
.solution { margin-top: auto; padding-top: 1.25rem; border-top: 1px solid var(--rule); display: grid; gap: .5rem; }
.solution h3 { font-size: 1.15rem; margin: 0; letter-spacing: -0.01em; }
.solution p { color: var(--muted); margin: 0; font-size: .95rem; }
.later { margin: 2.5rem 0 0; max-width: 40rem; font-size: 1.2rem; color: var(--muted); font-style: italic; }
.projects.three { grid-template-columns: repeat(3, 1fr); }
.projects.three .project-top { flex-direction: column; align-items: flex-start; gap: .6rem; }

/* Contact */
.contact .wrap { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; flex-wrap: wrap; }
.contact .section-head { margin: 0; }
.button { display: inline-flex; align-items: center; gap: .6rem; padding: .9rem 1.4rem; background: var(--fg); color: var(--bg); text-decoration: none; font-weight: 600; }
.button:hover { background: var(--accent); color: var(--bg); }

/* Pied de page */
.site-footer { border-top: 1px solid var(--rule); padding: 2rem 0 3rem; font-size: .9rem; color: var(--muted); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* Pages de texte */
.prose { max-width: 42rem; padding: 4rem 0 5rem; }
.prose h1 { font-size: 2.2rem; letter-spacing: -0.025em; line-height: 1.15; margin: 0 0 2.5rem; }
.prose h2 { font-size: 1.15rem; margin: 2.5rem 0 .75rem; }
.prose p, .prose li { color: var(--muted); }
.prose p { margin: 0 0 .9rem; }
.prose dl { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.5rem; margin: 0; }
.prose dt { color: var(--fg); font-weight: 550; }
.prose dd { margin: 0; color: var(--muted); }

a:focus-visible, .button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Animations liées au défilement : bonus pour les navigateurs qui les gèrent */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .opening-lamps { animation: drift linear both; animation-timeline: scroll(root); animation-range: 0 100vh; }
    .reveal { animation: rise linear both; animation-timeline: view(); animation-range: entry 0% entry 70%; }
    .cycle li { animation: glow linear both; animation-timeline: view(); }
    .cycle li:nth-child(1) { animation-range: entry 60% cover 30%; }
    .cycle li:nth-child(2) { animation-range: entry 80% cover 34%; }
    .cycle li:nth-child(3) { animation-range: entry 100% cover 38%; }
    .cycle li:nth-child(4) { animation-range: cover 22% cover 42%; }
    .cycle li:nth-child(5) { animation-range: cover 26% cover 46%; }
  }
}
@keyframes drift { to { transform: translateY(35vh); } }
@keyframes rise { from { opacity: 0; transform: translateY(2rem); } }
@keyframes glow { from { opacity: .25; } }

@media (max-width: 860px) {
  .chapter .wrap { grid-template-columns: 1fr; gap: 0; }
  .chapter.flip .visual { order: 0; }
  .visual { position: relative; top: auto; height: auto; aspect-ratio: 4 / 3; margin-top: 3rem; }
  .story { min-height: 0; padding: 2.5rem 0 3.5rem; }
  .projects, .problems, .projects.three { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .wrap { padding: 0 1rem; }
  .nav { gap: 1rem; }
  .nav a.hide-sm { display: none; }
  .opening .wrap { padding-top: 6rem; padding-bottom: 3.5rem; }
  .opening-lamps { width: 100vw; opacity: .6; }
  .lead { font-size: 1.08rem; }
  section.plain { padding: 3.5rem 0; }
  .project, .problem { padding: 1.35rem; }
  .prose dl { grid-template-columns: 1fr; gap: 0; }
  .prose dd { margin-bottom: .75rem; }
}
