/* =====================================================================
   BASE — composants communs (utilise uniquement les variables du thème)
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s, color .3s;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  line-height: 1.08;
  margin: 0;
  text-wrap: balance;
}
p { text-wrap: pretty; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
main, footer, header { position: relative; z-index: 1; }

/* Taches de couleur en fond (désactivées par certains thèmes) */
.blobs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; opacity: var(--blob-opacity); }
.blobs span { position: absolute; border-radius: 50%; filter: blur(90px); }
.blobs span:nth-child(1) { width: 480px; height: 480px; background: var(--blob-1); top: -160px; right: -120px; }
.blobs span:nth-child(2) { width: 400px; height: 400px; background: var(--blob-2); top: 45%; left: -200px; }
.blobs span:nth-child(3) { width: 340px; height: 340px; background: var(--blob-3); bottom: -140px; right: 25%; }

/* Petit sur-titre */
.eyebrow {
  display: inline-block;
  font-weight: 700; font-size: .85rem; letter-spacing: .08em;
  text-transform: var(--eyebrow-transform);
  color: var(--accent-2);
  margin: 0 0 .8em;
}

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55em;
  padding: .8em 1.4em; border-radius: var(--radius-pill);
  font: 700 .97rem/1.2 var(--font-body);
  text-decoration: none; cursor: pointer; border: 2px solid transparent;
  background: var(--accent); color: var(--accent-ink);
  transition: transform .2s, box-shadow .2s, background .2s, border-color .2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -10px var(--accent); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); box-shadow: none; }
.btn .arrow { transition: transform .2s; }
.btn:hover .arrow { transform: translateX(3px); }

/* Pastilles / étiquettes */
.chip {
  display: inline-flex; align-items: center; gap: .35em;
  font-size: .78rem; font-weight: 700; line-height: 1;
  padding: .45em .8em; border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--tone, var(--accent)) 13%, var(--surface));
  color: color-mix(in srgb, var(--tone, var(--accent)) 78%, var(--ink));
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }

/* Liens sociaux */
.socials { display: flex; flex-wrap: wrap; gap: 8px; }
.socials a {
  text-decoration: none; font-weight: 600; font-size: .9rem;
  padding: .5em 1em; border-radius: var(--radius-pill);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-soft);
  transition: border-color .2s, color .2s;
}
.socials a:hover { border-color: var(--ink); color: var(--ink); }

/* Titres de section */
.section { padding-top: 72px; padding-bottom: 72px; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 16px 32px; margin-bottom: 32px; }
.section-head h2 { font-size: clamp(1.9rem, 3.6vw, 2.8rem); }
.section-head p { margin: .5em 0 0; color: var(--ink-soft); max-width: 60ch; }

/* Filtres (onglets) */
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters button {
  font: 600 .92rem/1 var(--font-body); cursor: pointer;
  padding: .7em 1.1em; border-radius: var(--radius-pill);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-soft);
  transition: all .2s;
}
.filters button:hover { color: var(--ink); border-color: var(--ink-faint); }
.filters button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.filters .count { opacity: .6; margin-left: .3em; font-weight: 500; }

/* Visuel de remplacement (pas d'image) : dégradé + emoji / initiales */
.placeholder {
  display: grid; place-items: center; width: 100%; height: 100%;
  background:
    radial-gradient(circle at 30% 20%, color-mix(in srgb, #fff 30%, transparent), transparent 60%),
    linear-gradient(135deg, var(--tone, var(--accent)), color-mix(in srgb, var(--tone, var(--accent)) 55%, var(--surface)));
  color: #fff; font-family: var(--font-display); font-weight: var(--display-weight);
}
img.broken { display: none; }

/* Pied de page */
.footer { padding: 40px 0 48px; color: var(--ink-faint); font-size: .9rem; text-align: center; }
.footer a { color: var(--ink-soft); text-underline-offset: 3px; }

/* Message d'erreur de configuration */
.config-error {
  max-width: 720px; margin: 80px auto; padding: 24px 28px;
  border: 2px dashed var(--accent-2); border-radius: var(--radius); background: var(--surface);
}
.config-error code { background: var(--bg-alt); padding: 2px 6px; border-radius: 4px; }

/* Sélecteur de thème (affiché si "themeSwitcher": true) */
.theme-switcher {
  position: fixed; right: 16px; bottom: 16px; z-index: 40;
  display: flex; align-items: center; gap: 6px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow-hover);
}
.theme-switcher .ts-label { font-size: .75rem; font-weight: 700; color: var(--ink-faint); padding: 0 6px 0 10px; }
.theme-switcher button {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line);
  transition: transform .15s, box-shadow .15s;
}
.theme-switcher button:hover { transform: scale(1.12); }
.theme-switcher button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }

/* Fenêtre modale */
dialog.modal {
  width: min(920px, calc(100% - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 0; border-radius: var(--radius);
  background: var(--surface); color: var(--ink); box-shadow: 0 40px 100px -20px rgba(0,0,0,.5);
  overflow: auto;
}
dialog.modal::backdrop { background: rgba(10,10,20,.6); backdrop-filter: blur(4px); }
dialog.modal[open] { animation: pop .25s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.modal-close {
  position: sticky; top: 12px; display: block; margin: 12px 12px -52px auto; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-size: 1.1rem;
}

/* Visionneuse d'image */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(8,8,16,.9); display: grid; place-items: center; padding: 24px; }
.lightbox[hidden] { display: none; }
.lightbox img { max-height: 84vh; border-radius: 10px; }
.lightbox p { color: #fff; text-align: center; margin: 12px 0 0; }

/* Apparition au défilement */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .section { padding-top: 52px; padding-bottom: 52px; }
  .theme-switcher .ts-label { display: none; }
  .theme-switcher { right: 10px; bottom: 10px; gap: 4px; padding: 4px; }
  .theme-switcher button { width: 22px; height: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}
