/* =========================================================================
   Éléments communs à toutes les pages (tools/layout.py, assets/js/app.js) :
   en-tête et menu mobile, pied de page, badge UNOFFICIAL, boutons flottants, fenêtres (confirmation, contact,
   recherche), messages, chargement, pages légales, petites classes utilitaires.
   Chargé après style.css, aincrad.css (et wiki.css) ; theme-light.css adapte tout au thème clair.
   ========================================================================= */

/* --- Utilitaires (remplacent les attributs style="" : la Content-Security-Policy les refuse) --------------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.pt-tight { padding-top: 1rem; }
.pb-tight { padding-bottom: 1rem; }
.pb-hero { padding-bottom: 2rem; }
.mt-hero { margin-top: 2.2rem; }
.hero-center { justify-content: center; }
.pre-line { white-space: pre-line; }
.mc-help-start { justify-content: flex-start; }
.bench-hero { padding: 2.4rem 0 1.6rem; }
section.mc-stage { padding: 0 0 1rem; }
.btn-small { padding: .5rem 1rem; font-size: .74rem; }
.btn-danger { background: linear-gradient(180deg, #c2412b, #a52c18); color: #fff; box-shadow: 0 0 0 1px rgba(255, 143, 122, .5), 0 6px 18px rgba(0, 10, 25, .35); }
.btn-danger:hover { background: linear-gradient(180deg, #b8321c, #93250f); color: #fff; box-shadow: 0 0 0 1px rgba(255, 143, 122, .7), 0 0 22px rgba(226, 85, 60, .55); }
.btn-ghost.btn-danger { background: rgba(226, 85, 60, .12); color: #ffb3a6; box-shadow: inset 0 0 0 1px rgba(255, 143, 122, .45); }
.btn-ghost.btn-danger:hover { background: #b8321c; color: #fff; }
.btn.is-ok { color: #0b2a12; background: linear-gradient(180deg, #c9ffb0, #7ce38f); }
.btn.is-error { color: #fff; background: linear-gradient(180deg, #c2412b, #a52c18); }
.link-btn { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-align: left; }
.link-btn:hover { color: var(--accent-light); }

/* --- Focus clavier visible partout ---------------------------------------------------------------------------- */
:focus-visible { outline: 2px solid var(--sao-orange); outline-offset: 2px; }
.btn:focus-visible, .icon-btn:focus-visible, .fab:focus-visible { outline: 3px solid var(--sao-orange); outline-offset: 3px; }
main:focus { outline: none; }

/* --- Aller au contenu ------------------------------------------------------------------------------------------- */
.skip-link {
  position: fixed;
  left: 1rem;
  top: -4rem;
  z-index: 200;
  padding: .7rem 1.2rem;
  border-radius: 999px;
  background: var(--sao-white);
  color: var(--sao-ink);
  font: 700 .9rem var(--display);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  transition: top .15s;
}
.skip-link:focus { top: .8rem; color: var(--sao-ink); }

/* --- Barre de progression de lecture --------------------------------------------------------------------------- */
.scroll-progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 70; pointer-events: none; }
.scroll-progress span {
  display: block;
  height: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--sao-cyan), var(--sao-orange));
  box-shadow: 0 0 10px rgba(247, 165, 49, .6);
}

/* --- En-tête : navigation, outils, menu mobile -------------------------------------------------------------------- */
.site-header .wrap { position: relative; gap: 1rem; }
.site-menu { display: flex; align-items: center; gap: .8rem; margin-left: auto; }
.site-menu .nav { margin-left: 0; }
.header-tools { display: flex; align-items: center; gap: .45rem; }
.header-tools .lang-select { margin-left: 0; }
.header-actions { display: flex; align-items: center; gap: .45rem; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  padding: 0;
  border: 1px solid var(--sao-line-hi);
  border-radius: 50%;
  background: rgba(255, 255, 255, .05);
  color: var(--sao-white);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .15s;
}
.icon-btn:hover { background: var(--sao-white); color: var(--sao-ink); border-color: transparent; }
.icon-btn svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* bouton de thème : l'icône du thème vers lequel il bascule */
.theme-toggle .i-moon { display: none; }
[data-theme="light"] .theme-toggle .i-sun { display: none; }
[data-theme="light"] .theme-toggle .i-moon { display: block; }
.menu-toggle { display: none; }

@media (max-width: 860px) {
  .menu-toggle { display: inline-grid; }
  .header-actions { margin-left: auto; }
  .site-menu {
    position: absolute;
    top: calc(100% + 1px);
    left: -1.25rem;
    right: -1.25rem;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    padding: 1rem 1.25rem 1.3rem;
    background: rgba(6, 15, 30, .97);
    border-bottom: 1px solid var(--sao-line);
    box-shadow: 0 18px 40px rgba(0, 8, 20, .5);
  }
  .site-menu.is-open { display: flex; }
  .site-menu .nav { flex-direction: column; gap: .3rem; }
  .site-menu .nav a { padding: .75rem 1rem; font-size: .9rem; border-radius: 10px; }
  .header-tools { justify-content: space-between; }
  .header-tools .lang-select { padding: .6rem .8rem; font-size: .85rem; }
}

/* --- Pied de page ------------------------------------------------------------------------------------------------ */
.site-footer { padding: 2.6rem 0 5.5rem; color: var(--muted); }
.footer-grid { display: grid !important; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 2rem 3rem; }
.footer-brand { margin: 0 0 .4rem; font: 800 1rem var(--display); letter-spacing: .18em; text-transform: uppercase; color: var(--sao-white); }
.footer-about p { margin: 0 0 .6rem; max-width: 46ch; }
.footer-meta { font-size: .8rem; }
.footer-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.footer-title { margin: 0 0 .6rem; font: 700 .74rem var(--display); letter-spacing: .16em; text-transform: uppercase; color: var(--sao-cyan); }
.footer-cols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.footer-cols a, .footer-cols .link-btn { color: var(--muted); font-size: .86rem; }
.footer-cols a:hover, .footer-cols .link-btn:hover { color: var(--sao-white); }
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr; } }

/* --- Badge « UNOFFICIAL / Made by Colmax06 », en bas à gauche de chaque page ------------------------------------ */
.unofficial {
  position: fixed;
  left: .9rem;
  bottom: .9rem;
  z-index: 45;
  display: grid;
  gap: .1rem;
  padding: .42rem .85rem .48rem;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(64, 80, 104, .94), rgba(36, 48, 66, .94));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 6px 18px rgba(0, 8, 20, .45);
  font-family: var(--display);
  line-height: 1.15;
  pointer-events: none;
  user-select: none;
}
.unofficial b { font-size: .76rem; font-weight: 800; letter-spacing: .2em; color: #e3ebf5; }
.unofficial span { font-size: .72rem; font-weight: 600; color: #b9c6d6; }
@media (max-width: 620px) {
  .unofficial { left: .6rem; bottom: .6rem; padding: .32rem .6rem .36rem; }
  .unofficial b { font-size: .64rem; }
  .unofficial span { font-size: .62rem; }
}

/* --- Boutons flottants (bas à droite) : haut de page, contact, et ceux du wiki (Ma liste, Mes métiers) --------- */
.fab-stack {
  position: fixed;
  right: 1.4rem;
  bottom: 1.4rem;
  z-index: 60;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: .7rem;
}
.fab {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: var(--sao-ink);
  background: radial-gradient(circle at 50% 35%, #ffffff, #d5dce3);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .2), 0 8px 24px rgba(0, 0, 0, .5);
  transition: transform .15s, box-shadow .15s;
}
.fab[hidden] { display: none; }
.fab:hover { box-shadow: 0 0 0 3px rgba(247, 165, 49, .6), 0 0 22px rgba(247, 165, 49, .5); }
.fab svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 620px) {
  .fab-stack { right: .8rem; bottom: .8rem; gap: .55rem; }
  .fab { width: 2.5rem; height: 2.5rem; }
}

/* --- Messages (succès / erreur) --------------------------------------------------------------------------------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  z-index: 150;
  display: grid;
  gap: .5rem;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  margin: 0;
  padding: .65rem 1.2rem;
  border-radius: 999px;
  background: rgba(246, 248, 250, .97);
  color: var(--sao-ink);
  font: 700 .88rem var(--display);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  animation: toast-in .25s cubic-bezier(.2, .8, .3, 1);
  transition: opacity .4s, transform .4s;
}
.toast.is-success { box-shadow: inset 4px 0 0 #3fbf5a, 0 10px 30px rgba(0, 0, 0, .45); }
.toast.is-error { background: #fff1ee; color: #8f1f0c; box-shadow: inset 4px 0 0 #e2553c, 0 10px 30px rgba(0, 0, 0, .45); }
.toast.is-leaving { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* --- Fenêtres SAO (<dialog>) : confirmation, contact, recherche ------------------------------------------------- */
.sao-dialog {
  width: min(30rem, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--sao-line-hi);
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, 0) 38%),
    rgba(9, 21, 38, .97);
  clip-path: polygon(0 0, calc(100% - var(--notch)) 0, 100% var(--notch), 100% 100%, var(--notch) 100%, 0 calc(100% - var(--notch)));
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.sao-dialog[open] { animation: dlg-in .22s cubic-bezier(.2, .8, .3, 1); }
.sao-dialog::backdrop { background: rgba(2, 8, 18, .62); backdrop-filter: blur(3px); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.sao-dialog-box { padding: 1.5rem 1.6rem 1.4rem; }
.sao-dialog h2 { margin: 0 0 .8rem; font-size: 1.15rem; }
.sao-dialog p { margin: 0 0 .9rem; color: var(--muted); }
.sao-dialog-input {
  width: 100%;
  padding: .75rem 1rem;
  border: 1px solid var(--sao-line-hi);
  border-radius: 10px;
  background: rgba(255, 255, 255, .95);
  color: var(--sao-ink);
  font: 700 1.2rem var(--display);
  text-align: center;
}
.sao-dialog-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(247, 165, 49, .6); }
.sao-dialog-input[aria-invalid="true"] { border-color: #a52c18; }
.sao-dialog .form-status { margin: .6rem 0 0; }
.sao-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; margin-top: 1.3rem; }
.dialog-note { font-size: .84rem; }
.contact-row {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .8rem 1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
  box-shadow: inset 0 0 0 1px var(--sao-line);
}
.contact-row { flex-wrap: wrap; }
.contact-row > div { flex: 1; display: grid; min-width: 8rem; }
.contact-row .btn { white-space: nowrap; }
.contact-row small { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; }
.contact-row b { font: 800 1.15rem var(--display); letter-spacing: .04em; }
.contact-icon { font-size: 1.6rem; }

/* recherche du site */
.search-dialog { width: min(40rem, calc(100vw - 1.5rem)); margin-top: 8vh; }
.search-dialog .sao-dialog-box { padding: 1rem 1rem .8rem; }
.search-field { display: flex; align-items: center; gap: .6rem; }
.search-field input {
  flex: 1;
  min-width: 0;
  padding: .85rem 1rem .85rem 2.8rem;
  border: 1px solid var(--sao-line-hi);
  border-radius: 999px;
  background: rgba(255, 255, 255, .95) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366717d' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 1rem center / 1.1rem no-repeat;
  color: var(--sao-ink);
  font: 600 1rem var(--display);
}
.search-field input:focus { outline: none; box-shadow: 0 0 0 3px rgba(247, 165, 49, .6); }
.search-close {
  padding: .35rem .6rem;
  border: 1px solid var(--sao-line-hi);
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: 700 .72rem var(--display);
  cursor: pointer;
}
.search-close:hover { color: var(--sao-white); border-color: var(--sao-white); }
.search-list { max-height: min(60vh, 30rem); overflow-y: auto; margin-top: .8rem; }
.search-group { margin: .9rem .4rem .35rem; font: 700 .7rem var(--display); letter-spacing: .16em; text-transform: uppercase; color: var(--sao-cyan); }
.search-group:first-child { margin-top: .2rem; }
.search-item {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .5rem .7rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}
.search-item img { width: 32px; height: 32px; image-rendering: pixelated; flex: none; }
.search-glyph {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, .07);
  color: var(--sao-orange-hi);
  font-weight: 800;
}
.search-item b { display: block; font-family: var(--display); font-size: .95rem; }
.search-item small { display: block; color: var(--muted); font-size: .8rem; }
.search-item:hover, .search-item.is-active { background: rgba(247, 165, 49, .16); box-shadow: inset 0 0 0 1px rgba(247, 165, 49, .5); color: var(--text); }
.search-status { margin: .6rem .5rem 0; font-size: .84rem; color: var(--muted); }
.search-status.is-error { color: #ff9a9a; }
.search-hint { margin: .3rem .5rem 0; font-size: .75rem; color: var(--muted); }

/* --- Chargement ----------------------------------------------------------------------------------------------- */
.loader { display: flex; align-items: center; justify-content: center; gap: .8rem; padding: 2.5rem 1rem; color: var(--muted); font: 600 .95rem var(--display); }
.loader-ring {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  border: 3px solid rgba(103, 228, 255, .2);
  border-top-color: var(--sao-cyan);
  border-right-color: var(--sao-orange);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.mc-frame .loader { margin: auto; }
img[data-bench]:not([src]) {
  border-radius: 8px;
  background: linear-gradient(100deg, rgba(255, 255, 255, .04) 30%, rgba(255, 255, 255, .12) 50%, rgba(255, 255, 255, .04) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -100% 0; } }

/* --- Formulaires : états ------------------------------------------------------------------------------------- */
.form-status { min-height: 1.2em; margin: .8rem 0 0; font: 600 .84rem var(--display); }
.form-status.is-ok { color: #9dffa9; }
.form-status.is-error { color: #ff9a9a; }

/* --- Accueil : bouton principal + adresse du serveur -------------------------------------------------------------- */
.landing .hero-actions { margin: 2rem 0 1.4rem; }
.ip-label { font: 700 .72rem var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* --- Pages légales ------------------------------------------------------------------------------------------------ */
.legal { max-width: 52rem; padding-top: 2.6rem; }
.legal h1 { margin-bottom: .3rem; }
.legal h2 { margin: 2.2rem 0 .7rem; font-size: 1.2rem; }
.legal h3 { margin: 1.3rem 0 .4rem; font-size: .95rem; color: var(--sao-cyan); }
.legal p, .legal li, .legal dd { color: var(--muted); line-height: 1.7; }
.legal b { color: var(--text); }
.legal ul { padding-left: 1.3rem; }
.legal code { color: var(--accent-light); font-size: .92em; }
.legal-date { font-size: .88rem; }
.legal-note { font-size: .85rem; font-style: italic; }
.legal-summary {
  padding: 1rem 1.2rem;
  border-left: 3px solid var(--sao-orange);
  border-radius: 4px;
  background: rgba(255, 255, 255, .05);
}
.legal-facts { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.2rem; margin: 1rem 0; }
.legal-facts dt { font: 700 .82rem var(--display); color: var(--text); padding-top: .15rem; }
.legal-facts dd { margin: 0; }
@media (max-width: 620px) { .legal-facts { grid-template-columns: 1fr; } .legal-facts dd { margin-bottom: .6rem; } }
.table-scroll { overflow-x: auto; }
.legal-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.legal-table th, .legal-table td { padding: .6rem .7rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--sao-line); }
.legal-table th { font: 700 .76rem var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--sao-cyan); }
.legal-table td { color: var(--muted); }
.legal-table td:first-child { white-space: nowrap; }

/* bouton principal de l'accueil vers les crafts : une grille de fabrication à la place de la flèche de téléchargement */
.btn-hero.is-crafts::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Cpath d='M9 3v18M15 3v18M3 9h18M3 15h18'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Cpath d='M9 3v18M15 3v18M3 9h18M3 15h18'/%3E%3C/svg%3E");
}

/* --- Accueil : les crafts mis en avant (vitrine écrite par tools/build_wiki.py) ------------------------------ */
.crafts-spot {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: center;
  margin-bottom: 1.4rem;
  padding: 2rem;
  border: 1px solid rgba(247, 165, 49, .45);
  box-shadow: 0 0 0 1px rgba(247, 165, 49, .15), 0 0 46px rgba(247, 165, 49, .14), 0 18px 50px rgba(0, 10, 25, .45);
}
.crafts-spot .eyebrow { margin: 0 0 .3rem; }
.crafts-spot-title { margin: 0 0 .6rem; font-size: clamp(1.5rem, 3vw, 2.1rem); }
.crafts-spot-lede { margin: 0 0 1rem; color: var(--muted); }
.crafts-stats { display: flex; flex-wrap: wrap; gap: .6rem; margin: 0 0 1.1rem; padding: 0; list-style: none; }
.crafts-stats li {
  padding: .4rem .9rem;
  border-radius: 999px;
  background: rgba(247, 165, 49, .12);
  box-shadow: inset 0 0 0 1px rgba(247, 165, 49, .4);
}
.crafts-stats b { font-family: var(--display); font-size: 1.15rem; color: var(--sao-orange-hi); }
.crafts-points { margin-bottom: 1.3rem; }
.crafts-actions { display: flex; flex-wrap: wrap; gap: .7rem; }
.crafts-showcase { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; justify-items: center; }
.showcase-slot {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 104px;
  aspect-ratio: 1;
  border-radius: 6px;
  background: rgba(20, 14, 28, .82) center / 100% 100% no-repeat;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), inset 0 -2px 0 rgba(0, 0, 0, .35);
  image-rendering: pixelated;
}
.showcase-slot:hover, .showcase-slot:focus-visible { box-shadow: inset 0 0 0 2px var(--sao-orange), 0 0 16px rgba(247, 165, 49, .45); }
.showcase-slot img { width: 72%; height: auto; image-rendering: pixelated; }
.portal-wide { flex-direction: row; align-items: center; gap: 1.2rem; }
.portal-wide > div { flex: 1; }
.portal-wide p { margin-top: .3rem; }
@media (max-width: 760px) {
  .crafts-spot { grid-template-columns: 1fr; gap: 1.4rem; padding: 1.4rem; }
  .portal-wide { flex-direction: column; align-items: flex-start; }
}

/* --- Launcher : avertissement « outil non officiel » (onglet Sécurité) ------------------------------------- */
.callout-warn {
  margin: 0 0 1.4rem;
  border-color: rgba(247, 165, 49, .45);
  border-left-color: var(--sao-orange);
  background: rgba(247, 165, 49, .08);
}
.callout-warn ul { margin-top: .9rem; }
