/* ==========================================================================
   CGM — système de design commun (celestingm.fr + rdv.celestingm.fr)
   Brutalisme hybride : grille suisse, filets visibles, grotesque étendue,
   métadonnées mono, un seul accent magenta, grain subtil.
   Ce fichier est identique dans les deux dépôts : le modifier aux deux endroits.
   ========================================================================== */

/* Polices auto-hébergées (sous-ensemble latin, variables, licence OFL dans /fonts). */
@font-face {
  font-family: "Archivo"; font-style: normal; font-weight: 100 900; font-stretch: 100% 125%; font-display: swap;
  src: url("/fonts/archivo-latin.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap;
  src: url("/fonts/jetbrains-mono-latin.woff2") format("woff2");
}

:root {
  --paper: #ecEAe4;
  --paper-2: #e2dfd8;
  --ink: #0e0e10;
  --muted: #5e5b57;
  --rule: #0e0e10;
  --rule-soft: rgba(14, 14, 16, .18);
  --accent: #9a1bd9;
  --accent-ink: #fbf8ff;
  --grain-opacity: .07;
  --scan-opacity: .035;

  --display: "Archivo", "Arial Black", "Helvetica Neue", sans-serif;
  --body: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gutter: clamp(16px, 3vw, 40px);
  --pad: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d0d0f; --paper-2: #161619; --ink: #eceae4; --muted: #8f8c87; --rule: #eceae4;
    --rule-soft: rgba(236, 234, 228, .18);
    --accent: #c77dff; --accent-ink: #120518; --grain-opacity: .09; --scan-opacity: .05;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0d0d0f; --paper-2: #161619; --ink: #eceae4; --muted: #8f8c87; --rule: #eceae4;
  --rule-soft: rgba(236, 234, 228, .18);
  --accent: #c77dff; --accent-ink: #120518; --grain-opacity: .09; --scan-opacity: .05;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--paper); color: var(--ink);
  font: 400 16px/1.55 var(--body); -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Structure : un cadre, des filets ---------- */
.site { position: relative; padding-inline: var(--gutter); padding-block: 0 48px; overflow-x: clip; }
.frame { max-width: 1320px; margin: 0 auto; border-inline: 1px solid var(--rule); }
.frame.narrow { max-width: 760px; }
.rule-b { border-bottom: 1px solid var(--rule); }
.cells { display: grid; gap: 1px; background: var(--rule); }
.cells > * { background: var(--paper); }

/* ---------- Typographie ---------- */
.display {
  font-family: var(--display); font-stretch: 125%; font-weight: 900;
  text-transform: uppercase; letter-spacing: -.04em; line-height: .9;
}
.d-xl { font-size: clamp(1.75rem, 8.2vw, 8.4rem); line-height: .88; letter-spacing: -.045em; }
.d-l { font-size: clamp(2rem, 5vw, 4rem); }
.d-m { font-size: clamp(1.5rem, 3vw, 2.4rem); line-height: .95; }
.d-s { font-size: clamp(1.1rem, 2vw, 1.6rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.02; }

/* ---------- Barre d'état ---------- */
.bar {
  display: flex; align-items: stretch; border-bottom: 1px solid var(--rule);
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--paper);
}
.bar > * { padding: 14px var(--pad); display: flex; align-items: center; gap: 10px; }
.bar > * + * { border-left: 1px solid var(--rule); }
.bar .grow { flex: 1; }
.logo { font-family: var(--display); font-stretch: 125%; font-weight: 900; font-size: 1.05rem; letter-spacing: -.02em; text-decoration: none; }
.bar-btn { font: inherit; background: none; border: 0; color: inherit; cursor: pointer; text-decoration: none; }
.bar > .bar-btn { padding: 14px var(--pad); }
.bar-btn:hover { color: var(--accent); }
.dot { width: 8px; height: 8px; background: var(--accent); display: inline-block; flex: none; }

/* Couleur d'accent au choix du visiteur (panneau construit par cgm.js). */
.cgm-swatch { width: 12px; height: 12px; background: var(--accent); border: 1px solid var(--rule); display: inline-block; }
.cgm-accent-panel {
  position: fixed; z-index: 70; width: 280px; max-width: calc(100vw - 16px);
  background: var(--paper); color: var(--ink); border: 1px solid var(--rule); padding: 14px; display: grid; gap: 12px;
}
.cgm-accent-panel[hidden] { display: none; }
.cgm-accent-panel .cgm-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cgm-swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.cgm-swatches button { aspect-ratio: 1; padding: 0; border: 1px solid var(--rule); background: var(--c); cursor: pointer; }
.cgm-swatches button[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.cgm-hex { display: grid; grid-template-columns: 1fr 46px; gap: 6px; }
.cgm-hex input[type="color"] { height: 100%; min-height: 40px; padding: 2px; border: 1px solid var(--rule); background: var(--paper); cursor: pointer; }

/* ---------- Boutons ---------- */
.btn {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 13px 18px; border: 1px solid var(--rule); border-radius: 0;
  background: transparent; color: var(--ink); text-decoration: none; cursor: pointer;
  transition: background-color .12s steps(2), color .12s steps(2), border-color .12s steps(2);
}
.btn:hover, .btn:focus-visible { background: var(--ink); color: var(--paper); outline: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover, .btn.primary:focus-visible { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.danger { color: var(--accent); border-color: var(--accent); }
.btn.danger:hover, .btn.danger:focus-visible { background: var(--accent); color: var(--accent-ink); }
.btn.sm { padding: 7px 11px; font-size: .7rem; }
.btn.ghost { border-color: transparent; }
.link { font: inherit; background: none; border: 0; padding: 0; color: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.link:hover { color: var(--accent); }

/* ---------- Formulaires ---------- */
.field { display: grid; gap: 6px; }
.field label, .label { font-family: var(--mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.field .opt { text-transform: none; letter-spacing: 0; }
input, select, textarea {
  font: 500 1rem/1.3 var(--body); width: 100%; padding: 11px 12px;
  border: 1px solid var(--rule); border-radius: 0; background: var(--paper); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[aria-invalid="true"] { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
textarea { min-height: 100px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: center; font-size: .92rem; cursor: pointer; }

/* ---------- Étiquettes ---------- */
.chip { font-family: var(--mono); font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--rule); padding: 3px 7px; white-space: nowrap; display: inline-block; }
/* Statuts : la forme porte le sens (plein = acquis, accent = à traiter, barré = annulé). */
.status { font-family: var(--mono); font-size: .66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 4px 8px; white-space: nowrap; display: inline-block; border: 1px solid var(--rule); }
.status.confirmed { background: var(--ink); color: var(--paper); }
.status.proposed { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.status.cancelled { color: var(--muted); border-color: var(--muted); text-decoration: line-through; }
.status.past { color: var(--muted); border-style: dashed; border-color: var(--muted); }

.notice { font-family: var(--mono); font-size: .76rem; letter-spacing: .04em; padding: 12px 14px; border: 1px solid var(--rule); display: flex; gap: 10px; }
.notice.error { border-color: var(--accent); color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.notice.ok { background: var(--ink); color: var(--paper); }

/* ---------- Message flottant ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 80;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); border: 1px solid var(--ink);
  font-family: var(--mono); font-size: .76rem; letter-spacing: .06em; text-transform: uppercase;
  padding: 12px 16px; transition: transform .2s steps(3), opacity .2s steps(3);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Fenêtres ---------- */
dialog { border: 1px solid var(--rule); border-radius: 0; background: var(--paper); color: var(--ink); padding: 0; width: min(620px, calc(100vw - 32px)); }
dialog::backdrop { background: color-mix(in srgb, var(--ink) 55%, transparent); }
.dialog-head { padding: 16px var(--pad); border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-body { padding: var(--pad); display: grid; gap: 14px; }
.dialog-foot { padding: 14px var(--pad); border-top: 1px solid var(--rule); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Chargement ---------- */
.skeleton { display: grid; gap: 8px; }
.skeleton span { height: 44px; background: repeating-linear-gradient(90deg, var(--paper-2) 0 12px, transparent 12px 24px); border: 1px dashed var(--rule-soft); }

/* ---------- Utilitaires typographiques (en dernier : priment sur les composants) ---------- */
.meta, .mono { font-family: var(--mono); font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; line-height: 1.35; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.lede { color: var(--muted); max-width: 62ch; }

/* ==========================================================================
   EFFETS — activés par classes sur <body>, coupés par html[data-fx="off"]
   ========================================================================== */

/* Grain */
.fx-grain::after {
  content: ""; position: fixed; inset: -50%; pointer-events: none; z-index: 90; opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .5  0 0 0 0 .5  0 0 0 0 .5  0 0 0 1.4 -.2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: cgm-grain 1.2s steps(6) infinite;
}
@keyframes cgm-grain { 0%{transform:translate(0,0)} 20%{transform:translate(-3%,2%)} 40%{transform:translate(2%,-3%)} 60%{transform:translate(-2%,-1%)} 80%{transform:translate(3%,3%)} 100%{transform:translate(0,0)} }

/* Lignes d'écran */
.fx-scan::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 89;
  background: repeating-linear-gradient(0deg, transparent 0 2px, color-mix(in srgb, var(--ink) calc(var(--scan-opacity) * 100%), transparent) 2px 3px);
}

/* Titre révélé par balayage (ligne par ligne) */
.fx-reveal .reveal-lines .line { animation: cgm-wipe .9s cubic-bezier(.7,0,.2,1) both; }
.fx-reveal .reveal-lines .line:nth-child(2) { animation-delay: .12s; }
.fx-reveal .reveal-lines .line:nth-child(3) { animation-delay: .24s; }
@keyframes cgm-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.reveal-lines .line { display: block; width: fit-content; }

/* Glitch léger au survol des éléments .glitch-hover */
.fx-glitch .glitch-hover:hover .glitch-target, .fx-glitch .glitch-hover:focus-visible .glitch-target { animation: cgm-glitch .35s steps(3) 1; }
@keyframes cgm-glitch {
  0% { text-shadow: 3px 0 var(--accent), -3px 0 color-mix(in srgb, var(--accent) 40%, transparent); transform: translateX(-2px); }
  50% { text-shadow: -4px 0 var(--accent), 2px 0 color-mix(in srgb, var(--accent) 40%, transparent); transform: translateX(2px); }
  100% { text-shadow: none; transform: none; }
}
/* Glitch court sur le mot accentué du titre */
.fx-bigglitch .headline:hover .hl { animation: cgm-softglitch .45s steps(3) 1; }
@keyframes cgm-softglitch {
  0% { text-shadow: 3px 0 var(--ink); clip-path: inset(0 0 45% 0); }
  50% { text-shadow: -3px 0 var(--ink); clip-path: inset(35% 0 0 0); }
  100% { text-shadow: none; clip-path: none; }
}

/* Croix de repère aux intersections (sur .cross) */
.fx-cross .cross { position: relative; }
.fx-cross .cross::before, .fx-cross .cross::after { content: "+"; position: absolute; font-family: var(--mono); font-size: 14px; line-height: 1; color: var(--accent); pointer-events: none; }
.fx-cross .cross::before { top: -8px; left: -5px; }
.fx-cross .cross::after { bottom: -8px; right: -5px; }

/* Trame demi-teinte sur un monogramme géant */
.halftone { display: none; }
.fx-halftone .halftone {
  display: block; position: absolute; z-index: 0; pointer-events: none;
  font-family: var(--display); font-stretch: 125%; font-weight: 900; line-height: .8; letter-spacing: -.06em;
  color: transparent; opacity: .32;
  background-image: radial-gradient(circle, var(--accent) 1px, transparent 1.3px); background-size: 6px 6px;
  -webkit-background-clip: text; background-clip: text;
}
@media (max-width: 900px) { .fx-halftone .halftone { display: none; } }

/* Défilement */
.ticker { overflow: hidden; white-space: nowrap; background: var(--ink); color: var(--paper); border-bottom: 1px solid var(--rule); }
.ticker .track { display: inline-flex; gap: 40px; padding: 11px 0; }
.ticker span { font-family: var(--mono); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; }
.ticker b { color: var(--accent); }
.fx-marquee .ticker .track { animation: cgm-marquee 38s linear infinite; }
@keyframes cgm-marquee { to { transform: translateX(-50%); } }

/* Curseur clignotant */
.caret { display: none; }
.fx-blink .caret { display: inline-block; width: .55em; height: 1em; background: var(--accent); vertical-align: -.12em; animation: cgm-blink 1s steps(1) infinite; }
@keyframes cgm-blink { 50% { opacity: 0; } }

/* Viseur (pointeur fin uniquement) */
.crosshair { display: none; }
@media (pointer: fine) {
  .fx-cursor { cursor: crosshair; }
  .fx-cursor .crosshair { display: block; position: fixed; inset: 0; pointer-events: none; z-index: 88; }
}
.crosshair i { position: absolute; background: var(--accent); opacity: .16; }
.crosshair .h { left: 0; right: 0; height: 1px; top: var(--y, -10px); }
.crosshair .v { top: 0; bottom: 0; width: 1px; left: var(--x, -10px); }
.crosshair .xy { position: absolute; left: calc(var(--x, -200px) + 10px); top: calc(var(--y, -200px) + 10px); font-family: var(--mono); font-size: 10px; letter-spacing: .08em; color: var(--accent); }

/* Interrupteur global : html[data-fx="off"] coupe tout, et reduced-motion coupe le mouvement. */
html[data-fx="off"] body::before, html[data-fx="off"] body::after,
html[data-fx="off"] .halftone, html[data-fx="off"] .crosshair, html[data-fx="off"] .caret,
html[data-fx="off"] .cross::before, html[data-fx="off"] .cross::after { display: none !important; }
html[data-fx="off"] *, html[data-fx="off"] *::before, html[data-fx="off"] *::after { animation: none !important; }
html[data-fx="off"] body { cursor: auto; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .crosshair { display: none !important; }
}

.bar > * { white-space: nowrap; }
@media (max-width: 700px) {
  :root { --pad: 14px; }
  .bar > *, .bar > .bar-btn { padding: 12px var(--pad); }
  .bar .hide-sm { display: none; }
}
@media (max-width: 440px) {
  .bar > *, .bar > .bar-btn { padding: 12px 9px; }
  .bar .meta { font-size: .66rem; letter-spacing: .04em; }
  .bar > :first-child { flex: 1; }
}
