/* ---------------------------------------------------------------
   Panthéon — feuille de style
   Palette encre profonde + or, une couleur d'accent par mythologie.
   --------------------------------------------------------------- */

:root {
  --bg:        #0b0e14;
  --bg-soft:   #11151f;
  --surface:   #151a26;
  --line:      #232a3a;
  --line-soft: #1b2130;
  --text:      #e8eaf0;
  --text-dim:  #99a1b3;
  --text-mute: #6c7484;
  --gold:      #d9b26a;
  --radius:    16px;
  --maxw:      1280px;
  --ease:      cubic-bezier(.22,.72,.24,1);
  --font-display: "Cinzel", Georgia, "Times New Roman", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  /* réserve la gouttière d'ascenseur en permanence : sans elle, le blocage du
     défilement à l'ouverture d'une fiche décalerait la page de sa largeur et
     l'animation de dépliement partirait à côté de la carte */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 50% -10%, rgba(217,178,106,.10), transparent 65%),
    radial-gradient(900px 500px at 100% 0%, rgba(95,168,211,.07), transparent 60%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

a { color: inherit; }

/* ------------------------------ En-tête ------------------------------ */

.site-header { padding: 72px 0 44px; text-align: center; }

.eyebrow {
  margin: 0 0 14px;
  font-size: 11px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: .8;
}

.site-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(44px, 9vw, 82px);
  letter-spacing: .04em;
  line-height: 1;
  background: linear-gradient(180deg, #fdf6e6 0%, var(--gold) 78%, #a67c3d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.site-title::after {
  content: "";
  display: block;
  width: 88px;
  height: 1px;
  margin: 26px auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.site-sub {
  margin: 22px 0 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0 6px;
  color: var(--text-dim);
  font-size: 15px;
}
.site-sub > span { white-space: nowrap; }
.site-sub strong { color: var(--text); font-weight: 600; }
.sep { color: var(--text-mute); }

/* ------------------------------ Barre d'outils ------------------------------ */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 16px 0 14px;
  background: rgba(11,14,20,.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.toolbar-row { display: flex; gap: 12px; align-items: center; }

.search {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: 46px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color .2s, box-shadow .2s;
}
.search:focus-within { border-color: rgba(217,178,106,.55); box-shadow: 0 0 0 3px rgba(217,178,106,.10); }
.search svg { width: 17px; height: 17px; flex: none; fill: none; stroke: var(--text-mute); stroke-width: 2; stroke-linecap: round; }
.search input {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: none;
  color: var(--text); font: inherit; font-size: 15px;
}
.search input::placeholder { color: var(--text-mute); }
.search input::-webkit-search-cancel-button { filter: invert(.6); }

.select-wrap { position: relative; flex: none; }
.select-wrap::after {
  content: "";
  position: absolute; right: 16px; top: 50%;
  width: 7px; height: 7px; margin-top: -5px;
  border-right: 1.5px solid var(--text-mute);
  border-bottom: 1.5px solid var(--text-mute);
  transform: rotate(45deg);
  pointer-events: none;
}
#sort {
  height: 46px;
  padding: 0 40px 0 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-dim);
  font: inherit; font-size: 14px;
  appearance: none; -webkit-appearance: none;
  cursor: pointer;
  outline: none;
}
#sort:focus { border-color: rgba(217,178,106,.55); }
#sort option { background: var(--bg-soft); color: var(--text); }

.chips {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  /* la liste défile : on estompe le bord droit pour le signaler */
  mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent);
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent);
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-dim);
  font: inherit; font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .18s, border-color .18s, background .18s;
}
.chip:hover { color: var(--text); border-color: #33405a; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.chip .n { opacity: .55; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] {
  color: #0b0e14;
  background: var(--chip-accent, var(--gold));
  border-color: transparent;
  font-weight: 600;
}
.chip[aria-pressed="true"] .dot { background: rgba(11,14,20,.55); }

/* ------------------------------ Grille ------------------------------ */

.result-count {
  margin: 28px 0 18px;
  font-size: 13px;
  color: var(--text-mute);
  letter-spacing: .04em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 22px;
  padding-bottom: 40px;
}

/* ------------------------------ Carte ------------------------------ */

.card {
  --accent: #d9b26a;
  --accent2: #8d99ae;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0 0 12px;
  text-align: left;
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), transparent 40%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  transition: transform .3s var(--ease), border-color .3s, box-shadow .3s;
  animation: rise .45s var(--ease) backwards;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* liseré coloré en haut de carte */
.card::before {
  content: "";
  position: absolute; inset: 0 0 auto 0;
  height: 3px;
  z-index: 3;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.card:hover, .card:focus-visible {
  transform: translateY(-7px);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 20px 40px -18px rgba(0,0,0,.9), 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
  outline: none;
}

/* --- illustration --- */

.card-art {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background:
    radial-gradient(90% 70% at 50% 30%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 70%),
    #0f131c;
}
.card-art img {
  width: 100%; height: 100%;
  object-fit: cover;
  /* bustes et statues : le visage est plutôt dans le tiers supérieur */
  object-position: 50% 28%;
  transition: transform .5s var(--ease), opacity .4s;
}
.card:hover .card-art img { transform: scale(1.06); }
.card-art.broken img { opacity: 0; }

/* voile sombre en haut et en bas pour que les libellés restent lisibles */
.card-art::after {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(6,9,14,.78) 0%, rgba(6,9,14,.10) 34%, transparent 55%),
    linear-gradient(0deg, var(--surface) 1px, rgba(21,26,38,.55) 14%, transparent 42%);
  pointer-events: none;
}

.card-top {
  position: absolute;
  inset: 9px 11px auto 11px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: rgba(232,234,240,.72);
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
}
.card-pantheon { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.card-pantheon .emb { flex: none; font-size: 13px; letter-spacing: 0; color: var(--accent); }
.card-pantheon .pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rarity { display: inline-flex; align-items: center; gap: 5px; flex: none; color: var(--rar); }
.gem {
  display: inline-block;
  flex: none;
  width: 8px; height: 8px;
  border-radius: 2px;
  background: var(--rar);
  transform: rotate(45deg);
  box-shadow: 0 0 8px color-mix(in srgb, var(--rar) 70%, transparent);
}

/* --- corps --- */

.card-body { display: block; padding: 12px 14px 0; }

.card-name {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  line-height: 1.16;
  letter-spacing: .01em;
}

.card-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 5px;
  font-size: 12px;
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.35;
}

.card-domains { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.tag {
  padding: 2.5px 8px;
  font-size: 10.5px;
  letter-spacing: .03em;
  border-radius: 999px;
  color: color-mix(in srgb, var(--accent) 78%, #ffffff);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  white-space: nowrap;
}

.card-stats {
  display: grid;
  gap: 5px;
  margin-top: auto;
  padding: 12px 14px 0;
}
.card-stats .stat { display: grid; grid-template-columns: 13px 1fr 20px; align-items: center; gap: 7px; }
.stat .k { font-size: 10px; color: var(--text-mute); text-transform: uppercase; }
.stat .v { font-size: 10px; color: var(--text-dim); text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 3px; border-radius: 3px; background: rgba(255,255,255,.07); overflow: hidden; }
.bar > i {
  display: block; height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
}

.empty { padding: 60px 0 90px; text-align: center; color: var(--text-mute); }

/* ------------------------------ Carte étendue ------------------------------ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5,7,11,0);
  transition: background .35s ease, backdrop-filter .35s ease;
}
.overlay[hidden] { display: none; }
.overlay.visible {
  background: rgba(5,7,11,.82);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.panel {
  position: fixed;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  box-shadow: 0 50px 100px -30px rgba(0,0,0,.95);
  transition:
    left .44s var(--ease), top .44s var(--ease),
    width .44s var(--ease), height .44s var(--ease),
    border-radius .44s var(--ease);
}
/* pose de la géométrie de départ : aucune animation sur cette trame */
.panel.flipping, .panel.instant { transition: none; }

.sheet {
  display: grid;
  grid-template-columns: minmax(0, 38%) minmax(0, 1fr);
  height: 100%;
}
.panel.open .sheet { animation: sheetIn .4s ease both .08s; }
.sheet.swap { animation: sheetOut .14s ease forwards; }
@keyframes sheetIn  { from { opacity: 0; transform: translateY(10px); } }
@keyframes sheetOut { to   { opacity: 0; transform: translateY(-8px); } }

.sheet-art {
  position: relative;
  overflow: hidden;
  background: #0a0d14;
}
.sheet-art img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 28%; }
.sheet-art::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 55%, rgba(17,21,31,.85) 100%);
}

.sheet-content {
  /* marge droite élargie : la flèche « suivant » flotte à cet endroit et
     recouvrait sinon la valeur des caractéristiques */
  padding: 34px 68px 30px 34px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet-content::-webkit-scrollbar { width: 9px; }
.sheet-content::-webkit-scrollbar-thumb { background: #2a3244; border-radius: 9px; border: 3px solid var(--bg-soft); }

.sheet-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  color: var(--text-dim);
}
.pill.accent {
  color: color-mix(in srgb, var(--accent) 80%, #fff);
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.sheet-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(26px, 3.4vw, 38px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: .02em;
}
.sheet-title { margin: 8px 0 0; font-style: italic; color: var(--text-dim); }
.sheet-lore { margin: 20px 0 24px; font-size: 15.5px; line-height: 1.75; color: #cfd5e2; }

.sheet-block { margin-bottom: 22px; }
.sheet-block h3 {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 600;
  font-family: var(--font-body);
}
.sheet-list { display: flex; flex-wrap: wrap; gap: 7px; }

.sheet-stats { display: grid; gap: 12px; }
.sheet-stat { display: grid; grid-template-columns: 92px 1fr 34px; align-items: center; gap: 12px; }
.sheet-stat .k { font-size: 12.5px; color: var(--text-dim); }
.sheet-stat .v { font-size: 12.5px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.sheet-stat .bar { height: 6px; border-radius: 4px; }

.sheet-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.btn {
  display: inline-flex; align-items: center;
  padding: 9px 16px;
  font-size: 13px;
  text-decoration: none;
  border-radius: 999px;
  color: #0b0e14;
  background: color-mix(in srgb, var(--accent) 85%, #fff);
  font-weight: 600;
  transition: transform .2s var(--ease), filter .2s;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn.ghost {
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line);
  font-weight: 500;
}
.btn.ghost:hover { color: var(--text); border-color: #33405a; }

.sheet-credit {
  margin: 22px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-mute);
}
.sheet-credit a { color: var(--text-dim); }

/* commandes flottantes du panneau */
.sheet-close, .sheet-nav {
  position: absolute;
  z-index: 5;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(11,14,20,.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-dim);
  cursor: pointer;
  transition: color .2s, background .2s, transform .2s var(--ease);
}
.sheet-close:hover, .sheet-nav:hover { color: var(--text); background: rgba(11,14,20,.92); }

.sheet-close { top: 14px; right: 16px; width: 36px; height: 36px; font-size: 23px; line-height: 1; }
.sheet-nav {
  top: 50%; margin-top: -21px;
  width: 42px; height: 42px;
  font-size: 26px; line-height: 1; padding-bottom: 3px;
}
.sheet-nav.prev { left: 14px; }
.sheet-nav.next { right: 14px; }
.sheet-nav:hover { transform: scale(1.08); }

/* ------------------------------ Pied de page ------------------------------ */

.site-footer {
  margin-top: 30px;
  padding: 40px 0 60px;
  border-top: 1px solid var(--line-soft);
  text-align: center;
  font-size: 13.5px;
  color: var(--text-dim);
}
.site-footer p { margin: 0 auto 8px; max-width: 760px; }
.site-footer .muted { color: var(--text-mute); font-size: 12.5px; }
.site-footer a { color: var(--text); text-decoration-color: var(--text-mute); text-underline-offset: 3px; }

/* ------------------------------ Adaptatif ------------------------------ */

@media (max-width: 860px) {
  .sheet { grid-template-columns: 1fr; grid-template-rows: minmax(0, 34%) minmax(0, 1fr); }
  .sheet-art::after { background: linear-gradient(180deg, transparent 45%, rgba(17,21,31,.92) 100%); }
  /* bandeau large découpé dans un portrait en pied : on cadre vers le haut,
     sinon on n'affiche que le torse */
  .sheet-art img { object-position: 50% 14%; }
  /* sur mobile les flèches sont remontées en bandeau : plus besoin de marge */
  .sheet-content { padding: 22px 22px 26px; }
  /* les flèches passeraient par-dessus le texte qui défile : on les regroupe
     avec la fermeture, en bandeau sur l'illustration */
  .sheet-close { width: 34px; height: 34px; font-size: 21px; }
  .sheet-nav {
    top: 14px; margin-top: 0;
    width: 34px; height: 34px;
    font-size: 21px; padding-bottom: 2px;
  }
  .sheet-nav.prev { left: auto; right: 100px; }
  .sheet-nav.next { right: 57px; }
}

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .site-header { padding: 52px 0 32px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .card-body { padding: 10px 11px 0; }
  .card-stats { padding: 10px 11px 0; }
  .card-name { font-size: 15.5px; }
  .card-title { font-size: 11px; -webkit-line-clamp: 2; }
  /* trop étroit pour les deux libellés : on garde l'emblème et la rareté */
  .card-top { font-size: 9px; letter-spacing: .08em; inset: 8px 9px auto 9px; }
  .card-pantheon .pname { display: none; }
  .card-domains .tag:nth-child(n+3) { display: none; }
  .toolbar-row { flex-wrap: wrap; }
  #sort { width: 100%; }
  .sheet-stat { grid-template-columns: 78px 1fr 30px; }
  .sheet-name { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* sentinelle du rendu incrémental : invisible, sert de déclencheur au défilement */
.sentinel { height: 1px; margin-top: -1px; }

/* note sous les caractéristiques : rappelle que ces chiffres ne sont pas savants */
.sheet-note {
  margin: 14px 0 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-mute);
}
.sheet-note strong { color: var(--text-dim); font-weight: 600; }

/* ------------------------------ Liens entre divinités ------------------------------ */

.sheet-famille { display: grid; gap: 11px; }
.rel { display: grid; grid-template-columns: 78px 1fr; align-items: baseline; gap: 12px; }
.rel-k {
  font-size: 11.5px;
  color: var(--text-mute);
  letter-spacing: .04em;
}
.rel-v { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rel-v .reste { font-size: 11.5px; color: var(--text-mute); }

/* une divinité citée est toujours cliquable : on la traite comme un jeton */
.lien {
  padding: 4px 11px;
  font: inherit;
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--text-dim);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: color .18s, border-color .18s, background .18s, transform .18s var(--ease);
}
.lien:hover {
  color: color-mix(in srgb, var(--accent) 82%, #fff);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  transform: translateY(-1px);
}

/* l'équivalence traverse les cultures : on montre celle d'arrivée */
.lien.equiv { display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; font-size: 13px; }
.lien.equiv .emb { font-size: 14px; }
.lien.equiv .ou { font-size: 11px; color: var(--text-mute); letter-spacing: .04em; }
.lien.equiv:hover .ou { color: var(--text-dim); }

@media (max-width: 640px) {
  .rel { grid-template-columns: 1fr; gap: 5px; }
  .rel-k { letter-spacing: .12em; text-transform: uppercase; font-size: 10.5px; }
}
