/*
 * T46 — Styles PARTAGÉS par l'accueil (`index.html`, avant `accueil.css`) et les guides et
 * comparatifs (`scripts/lib/seo.ts`, après `legal.css`) : en-tête commun (marque, liens) et
 * composant avant/après à curseur et loupe (`src/accueil/compare.ts`). Servi tel quel depuis
 * `public/` (adresse stable, écrite par les gabarits des pages générées). Jetons (`--bg`,
 * `--surface`, `--text`, `--muted`, `--border`, `--accent`) : ceux des deux feuilles, identiques,
 * clair et sombre.
 */

/* --- Gabarit ---------------------------------------------------------------- */
.wrap {
  box-sizing: border-box;
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 24px;
}
.wrap.narrow {
  max-width: 48rem;
}
@media (max-width: 600px) {
  .wrap {
    padding: 0 16px;
  }
}

/* --- En-tête ---------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
}
.header-row {
  display: flex;
  align-items: center;
  gap: 32px;
  height: var(--header-h, 60px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.0625rem;
  text-decoration: none;
}
.brand-mark {
  display: block;
  flex: none;
}
.nav-main {
  display: flex;
  gap: 24px;
}
.nav-main a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
}
.nav-main a:hover,
.nav-main a[aria-current] {
  color: var(--text);
}
/* Guides et comparatifs : trois liens, toujours visibles (pas de menu mobile). */
.nav-site {
  margin-left: auto;
}
@media (max-width: 480px) {
  .header-row {
    gap: 12px;
  }
  .nav-site {
    gap: 16px;
  }
}
@media (max-width: 360px) {
  .nav-site .brand-name {
    display: none;
  }
}

/* --- Avant/après à curseur et loupe ×6 -------------------------------------- */
.compare {
  margin: 0;
}
/* Les images sont sur fond blanc : le cadre reste blanc en thème sombre, comme le papier. Sans
   JavaScript, `--pos` vaut 50 % : les deux images restent visibles, coupées au milieu. */
.compare-frame {
  --pos: 50%;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  box-shadow:
    0 1px 2px rgb(0 0 0 / 6%),
    0 8px 24px rgb(0 0 0 / 6%);
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.compare-frame img {
  display: block;
  max-width: none;
}
.compare-before {
  width: 100%;
  height: auto;
}
.compare-before.pixelated {
  image-rendering: pixelated;
}
.compare-after {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  clip-path: inset(0 0 0 var(--pos));
}
.compare-frame::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  width: 2px;
  margin-left: -1px;
  background: #2f4fbf;
  pointer-events: none;
}
.compare-tag {
  position: absolute;
  bottom: 12px;
  z-index: 1;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgb(27 27 26 / 82%);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.04em;
  pointer-events: none;
}
.compare-tag-before {
  left: 12px;
}
.compare-tag-after {
  right: 12px;
  background: #2f4fbf;
}
/* Poignée : 44 px de large sur toute la hauteur (cible tactile), pastille au milieu. */
.compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  /* Au-dessus de la loupe : la poignée reste visible quand le détail est affiché. */
  z-index: 4;
  display: grid;
  place-items: center;
  width: 44px;
  margin-left: -22px;
  cursor: ew-resize;
  outline: none;
}
.compare-knob {
  display: grid;
  grid-auto-flow: column;
  place-items: center;
  gap: 6px;
  width: 44px;
  height: 44px;
  border: 2px solid #2f4fbf;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 8px rgb(0 0 0 / 25%);
}
.compare-knob::before,
.compare-knob::after {
  content: '';
  width: 0;
  height: 0;
  border-block: 6px solid transparent;
}
.compare-knob::before {
  border-right: 7px solid #2f4fbf;
}
.compare-knob::after {
  border-left: 7px solid #2f4fbf;
}
.compare-handle:focus-visible .compare-knob {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
/* Loupe : deux moitiés CARRÉES côte à côte (même point, avant | après) ; aucune bordure qui
   prendrait de la place (le calcul de `loupeLayout` suppose des carrés exacts). */
.compare-loupe {
  position: absolute;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: 10px;
  background: #ffffff;
  outline: 2px solid #2f4fbf;
  box-shadow: 0 10px 28px rgb(0 0 0 / 30%);
  overflow: hidden;
  pointer-events: none;
}
.compare-loupe[hidden] {
  display: none;
}
.compare-loupe::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: #2f4fbf;
}
.compare-loupe-pane {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
}
.compare-loupe-pane img {
  position: absolute;
  height: auto;
}
/* Les pixels du raster restent des pixels : c'est ce que montre un agrandissement. */
.compare-loupe-before img {
  image-rendering: pixelated;
}
.compare-loupe-pane span {
  position: absolute;
  bottom: 6px;
  z-index: 1;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgb(27 27 26 / 82%);
  color: #ffffff;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.5;
}
.compare-loupe-before span {
  left: 6px;
}
.compare-loupe-after span {
  right: 6px;
  background: #2f4fbf;
}
.compare figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.875rem;
}
