/* ============================================================
   MYTHÉO — Explorateur
   ============================================================ */

body.explore { overflow: hidden; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  height: -webkit-fill-available; /* iOS standalone : hauteur écran réelle → barre du bas collée */
}

/* --- barre du haut --- */
.topbar {
  flex: none;
  padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) 12px calc(16px + var(--safe-l));
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 20;
}
.topbar .line1 {
  display: flex;
  align-items: center;
  gap: 12px;
}
.home {
  flex: none;
  width: var(--touch);
  height: var(--touch);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-round);
  background: var(--bg-raised-2);
  color: var(--text);
  text-decoration: none;
  font-size: 18px;
}
.titles { flex: 1; min-width: 0; }
.titles h1 {
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.titles p { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.topbar .ring circle.val { stroke: var(--accent); }

.searchbox {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-raised-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-round);
  padding: 0 14px;
  min-height: var(--touch);
}
.searchbox .ico { color: var(--text-faint); margin-right: 8px; }
.searchbox input {
  flex: 1;
  min-width: 0;
  height: var(--touch);
  font-size: 16px;
}
.searchbox input::placeholder { color: var(--text-faint); }
.searchbox .clear {
  width: 32px; height: 32px;
  border-radius: var(--radius-round);
  color: var(--text-dim);
  font-size: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}
.searchbox.has-text .clear { opacity: 1; pointer-events: auto; }

/* --- zone de contenu --- */
.stage {
  flex: 1;
  overflow-y: auto;
  padding: 18px calc(16px + var(--safe-r)) calc(18px + var(--safe-b)) calc(16px + var(--safe-l));
  -webkit-overflow-scrolling: touch;
}

.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 80px 0;
  color: var(--text-dim);
}
.loader .spin {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.view { display: none; }
.view.active { display: block; }
.view-title {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.empty { color: var(--text-dim); padding: 30px 4px; text-align: center; }

/* --- Découvrir : chips --- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 14px;
  margin-bottom: 4px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-round);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--text-dim);
  white-space: nowrap;
  transition: border-color .15s ease, box-shadow .15s ease, color .15s ease;
}
.chip:hover { border-color: var(--accent); color: var(--text); box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 22%, transparent); }
.chip.active {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}

/* --- Découvrir : grille --- */
.entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.entry-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  text-align: left;
  padding: 14px;
  min-height: 100px;
  background: var(--bg-raised);
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  border-radius: var(--radius-md);
}
.entry-card:active { transform: scale(.97); }
.ec-ico { font-size: 22px; }
.ec-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.entry-card { transition: border-color .15s ease, transform .1s ease, box-shadow .15s ease; }
.entry-card:hover { border-color: var(--accent); box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 20%, transparent); transform: translateY(-2px); }
.parcours-card { transition: border-color .15s ease, transform .1s ease, box-shadow .15s ease; }
.parcours-card:hover { border-color: var(--accent); box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 20%, transparent); }
/* Crochets d'angle (signature « cartouche »), comme les cartes de mondes. */
.entry-card::before, .entry-card::after,
.parcours-card::before, .parcours-card::after,
.frise-card::before, .frise-card::after {
  content: ""; position: absolute; width: 9px; height: 9px;
  border: 2px solid var(--accent); pointer-events: none;
}
.entry-card::before, .parcours-card::before, .frise-card::before { left: -1px; top: -1px; border-right: 0; border-bottom: 0; }
.entry-card::after, .parcours-card::after, .frise-card::after { right: -1px; bottom: -1px; border-left: 0; border-top: 0; }
.ec-sub { font-size: 12.5px; color: var(--text-dim); }
.ec-check {
  position: absolute;
  top: 8px; right: 8px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}

/* --- Frise horizontale (axe du temps) --- */
.frise-hint {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  margin-bottom: 6px;
  padding: 0 2px;
}
.frise-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  /* déborde jusqu'aux marges de la scène pour un vrai défilement plein écran */
  margin: 0 calc(-16px - var(--safe-r)) 0 calc(-16px - var(--safe-l));
  padding: 0 calc(16px + var(--safe-r)) 8px calc(16px + var(--safe-l));
}
.frise-scroll::-webkit-scrollbar { display: none; }
.frise-track {
  display: inline-flex;
  align-items: flex-start;
  padding-top: 42px;
  position: relative;
}
.frise-era {
  position: relative;
  flex: none;
  width: 230px;
  padding: 0 9px;
}
/* la ligne d'axe, continue d'une époque à l'autre */
.frise-era::before {
  content: "";
  position: absolute;
  top: -24px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--line);
}
.frise-era:first-child::before { left: 50%; }
.frise-era:last-child::before  { right: 50%; }
.frise-node {
  position: absolute;
  top: -33px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 0 0 4px var(--bg);
}
.frise-era-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-strong);
  text-align: center;
  line-height: 1.3;
  min-height: 34px;
  margin-bottom: 12px;
}
.frise-cards { display: flex; flex-direction: column; gap: 8px; }
.frise-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 34px 8px 10px;
  background: var(--bg-raised);
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  border-radius: var(--radius-md);
  text-align: left;
  width: 100%;
}
.frise-card:active { transform: scale(.98); }
.er-txt { display: flex; flex-direction: column; min-width: 0; }
.er-name { font-weight: 700; font-size: 15px; }
.er-sub { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.frise-card .ec-check { top: 50%; transform: translateY(-50%); right: 10px; }

/* --- Carte des liens : toile navigable (pan / zoom / glisser) --- */
.graph {
  position: relative;
  width: 100%;
  height: min(72vh, 620px);
  background:
    radial-gradient(80% 60% at 50% 42%, color-mix(in srgb, var(--accent) 8%, transparent) 0%, transparent 70%),
    radial-gradient(120% 100% at 50% 0%, var(--bg-raised) 0%, var(--bg) 72%);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 14px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.graph:active { cursor: grabbing; }

.graph-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 6000px;
  height: 6000px;
  transform-origin: 0 0;
  will-change: transform;
}
.graph-nodes { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.graph-lines { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.graph-lines line { stroke: var(--line); stroke-width: 1.4; }
.graph-lines line.hot {
  stroke: var(--accent);
  stroke-width: 2.4;
  opacity: .95;
  filter: drop-shadow(0 0 3px color-mix(in srgb, var(--accent) 60%, transparent));
}
.graph-lines line.path { stroke: #ffcf4a; stroke-width: 3.2; opacity: 1; filter: drop-shadow(0 0 4px rgba(255,207,74,.6)); }
.graph-lines line.dim { opacity: .15; }
.graph-lines text {
  fill: var(--accent-strong);
  font-size: 11px;
  font-style: italic;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 3px;
}

.g-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 78px;
  padding: 8px 5px;
  border-radius: var(--radius-md);
  background: var(--bg-raised-2);
  border: 1px solid var(--line);
  text-align: center;
  color: var(--text);
  touch-action: none;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.g-node:active { transform: translate(-50%, -50%) scale(.94); }
.g-ico { font-size: 18px; }
.g-name { font-size: 12px; font-weight: 700; line-height: 1.15; }
.g-node.expandable::after {
  content: "+";
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 900;
  line-height: 18px;
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 55%, transparent);
}
.g-node.selected {
  border-color: var(--accent);
  background: var(--bg-raised);
  box-shadow: 0 0 0 2px var(--accent), 0 0 20px color-mix(in srgb, var(--accent) 45%, transparent);
  z-index: 3;
}
.g-node:focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: 3px;
  z-index: 4;
}
.g-dot {
  position: absolute;
  top: -5px; left: -5px;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg);
}
.g-node.dim { opacity: .18; pointer-events: none; filter: grayscale(1); }
.g-node.on-path { border-color: #ffcf4a; box-shadow: 0 0 0 2px #ffcf4a, 0 0 16px rgba(255,207,74,.4); z-index: 3; }
.g-node.path-end { border-color: #ffcf4a; box-shadow: 0 0 0 3px #ffcf4a; }

/* légende / filtre par type */
.graph-legend { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 12px; }
.lg-item {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 0 10px;
  border-radius: var(--radius-round);
  background: var(--bg-raised); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; color: var(--text-dim);
}
.lg-item[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
#cPath.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.c-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 13.5px;
  max-width: 40ch;
  margin: 0 auto 16px;
}
.c-hint b { color: var(--text); }
.c-bar { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.c-bar .btn { padding: 0 14px; font-size: 14px; }
#cBack:disabled { opacity: .4; }

/* --- Défis --- */
#quizHost {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}
.quiz-setup { display: flex; flex-direction: column; gap: 16px; }
.qs-group { display: flex; flex-direction: column; gap: 8px; }
.qs-label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); }
.qs-select {
  min-height: var(--touch);
  padding: 0 14px;
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 15px;
}
.quiz-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.quiz-actions .btn { flex: 1; min-width: 150px; }
.quiz-progress { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-dim); }
.quiz-streak { font-weight: 700; color: var(--accent-strong); }
.qr-review { margin: 18px 0; text-align: left; }
.qr-review h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin-bottom: 8px; }
.quiz-prompt { font-size: 19px; font-weight: 700; line-height: 1.35; }
.quiz-choices { display: flex; flex-direction: column; gap: 10px; }
.quiz-choice {
  min-height: var(--touch);
  padding: 12px 16px;
  text-align: left;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 15.5px;
}
.quiz-choice.correct { border-color: #4ade80; background: rgba(74, 222, 128, .12); }
.quiz-choice.wrong { border-color: var(--danger); background: rgba(255, 122, 122, .12); }
.quiz-choice:disabled { opacity: .85; }
.quiz-next { align-self: flex-start; }

.quiz-result { text-align: center; padding: 30px 0; }
.qr-score { font-size: 44px; font-weight: 800; color: var(--accent-strong); }
.qr-txt { color: var(--text-dim); margin: 8px 0 22px; }

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  opacity: .4;
  filter: grayscale(1);
}
.badge.earned { opacity: 1; filter: none; border-color: var(--accent); }
.b-ico { font-size: 24px; }
.b-label { font-size: 11px; text-align: center; color: var(--text-dim); }
.badge.earned .b-label { color: var(--text); }

/* --- barre d'onglets --- */
.tabbar {
  flex: none;
  display: flex;
  padding-bottom: var(--safe-b);
  background: var(--bg-raised);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: var(--touch);
  padding: 8px 0 6px;
  font-size: 11px;
  color: var(--text-faint);
}
.tab .t-ico { font-size: 20px; }
.tab[aria-selected="true"] { color: var(--accent-strong); }

/* --- fiche détaillée --- */
/* ============ Fiche — direction « Atlas céleste » ============ */
.sheet {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 100vh;
  height: 100dvh;
  height: -webkit-fill-available; /* iOS standalone : menu du bas bien collé */
  background: var(--bg);
  transform: translateY(100%);
  transition: transform .28s ease;
  z-index: 50;
}
.sheet.open { transform: translateY(0); }
/* Barre de navigation contextuelle en bas de la fiche */
.sheet-nav {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  display: flex;
  background: var(--bg-raised);
  border-top: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line));
  padding-bottom: var(--safe-b);
}
.sheet-nav .tab { color: var(--text-dim); transition: color .15s ease; }
.sheet-nav .tab:hover, .sheet-nav .tab:focus-visible { color: var(--accent); }
.sheet-body { padding-bottom: calc(86px + var(--safe-b)); }
.sheet-scroll {
  position: absolute; inset: 0; z-index: 1;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
/* grain de sérigraphie sur toute la fiche */
.sheet::after {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

.sheet-close, .sheet-fav, .sheet-set {
  position: absolute; top: calc(12px + var(--safe-t));
  width: var(--touch); height: var(--touch);
  border-radius: var(--radius-round);
  background: rgba(12, 20, 24, .55);
  border: 1px solid var(--line);
  z-index: 4;
}
.sheet-close { left: 16px; font-size: 18px; color: var(--text); }
.sheet-fav { right: 16px; font-size: 22px; line-height: 1; color: var(--text-dim); }
.sheet-fav.on { color: var(--accent); }
.sheet-set { right: calc(16px + var(--touch) + 10px); font-size: 17px; color: var(--text-dim); }
.sheet-set:hover, .sheet-set:focus-visible { color: var(--accent); border-color: var(--accent); }

/* Pendant la lecture (fiche scrollée) : les boutons du haut s'estompent pour ne pas gêner */
.sheet-close, .sheet-set, .sheet-fav { transition: opacity .3s ease, color .15s ease, border-color .15s ease; }
.sheet.reading .sheet-close, .sheet.reading .sheet-set, .sheet.reading .sheet-fav { opacity: .22; }
.sheet.reading .sheet-close:hover, .sheet.reading .sheet-set:hover, .sheet.reading .sheet-fav:hover,
.sheet.reading .sheet-close:focus-visible, .sheet.reading .sheet-set:focus-visible, .sheet.reading .sheet-fav:focus-visible { opacity: 1; }

.sheet-head {
  position: relative; z-index: 1;
  padding: calc(78px + var(--safe-t)) clamp(16px, 4vw, 26px) 4px;
}
.fiche-eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-display); font-weight: 700;
  font-size: 12px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 10px;
}
.fiche-eyebrow::before { content: "✦"; color: var(--rust); }

/* cartouche-héros : cadre + double liseré or */
.fiche-hero {
  position: relative; overflow: visible; /* le picto et le badge débordent le cadre */
  border: 2px solid var(--accent);
  box-shadow: inset 0 0 0 4px var(--bg), inset 0 0 0 5px rgba(231, 197, 110, .25);
  background:
    radial-gradient(140% 120% at 82% -20%, rgba(231, 197, 110, .10), transparent 55%),
    linear-gradient(180deg, var(--bg-raised), var(--bg-raised-2));
}
.fiche-scene { position: relative; height: clamp(126px, 21vw, 166px); }
.fiche-scene .sky { position: absolute; inset: 0; opacity: .9;
  background-image:
    radial-gradient(1.5px 1.5px at 22% 32%, #fff 40%, transparent),
    radial-gradient(1.3px 1.3px at 46% 20%, var(--accent) 40%, transparent),
    radial-gradient(1.4px 1.4px at 68% 36%, #fff 40%, transparent),
    radial-gradient(1.2px 1.2px at 86% 24%, #dfeaff 40%, transparent),
    radial-gradient(1.3px 1.3px at 58% 50%, #fff 40%, transparent); }
.fiche-scene .wave { position: absolute; left: 0; right: 0; bottom: 8px; height: 20px; opacity: .5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='72' height='20'><path d='M0 14 Q 18 3 36 14 T 72 14' fill='none' stroke='%235E8C86' stroke-width='2'/></svg>");
  background-size: 72px 20px; background-repeat: repeat-x; }
.fiche-medallion {
  position: absolute; left: clamp(16px, 5vw, 30px); top: 50%; transform: translateY(-50%);
  width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center;
  color: var(--accent); background: rgba(12, 20, 24, .5);
  border: 2px solid var(--accent); box-shadow: 0 0 22px rgba(231, 197, 110, .25);
}
.fiche-medallion svg { width: 46px; height: 46px; display: block; }

/* Picto principal : médaillon qui chevauche le coin haut-droit du cadre */
.fiche-pictos {
  position: absolute; right: -18px; top: -18px; z-index: 5;
}
.fp-main {
  width: 50px; height: 50px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent); background: var(--bg); border: 2px solid var(--accent);
  box-shadow: 0 0 18px rgba(231, 197, 110, .28); cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.fp-main svg { width: 27px; height: 27px; display: block; }
.fp-main:hover, .fp-main:focus-visible { transform: translateY(-1px); box-shadow: 0 0 22px rgba(231, 197, 110, .5); }
/* Rangée de raccourcis « liens par catégorie » sous le tagline (esprit profil) */
.fiche-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.fl-item {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent); background: rgba(12, 20, 24, .4); border: 1px solid rgba(231, 197, 110, .5);
  cursor: pointer; transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.fl-item svg { width: 19px; height: 19px; display: block; }
.fl-item:hover, .fl-item:focus-visible {
  transform: translateY(-1px); background: rgba(231, 197, 110, .18); box-shadow: 0 0 12px rgba(231, 197, 110, .4);
}

.fiche-band {
  position: relative; display: flex; align-items: flex-end; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding: 12px clamp(16px, 4vw, 22px) 16px;
  border-top: 2px solid var(--accent);
  background: linear-gradient(180deg, rgba(12, 20, 24, .45), transparent);
}
.fiche-titlewrap { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; flex: 1 1 200px; min-width: 0; }
.fiche-titlewrap .rule { height: 3px; width: min(300px, 78%); background: var(--rust); }
.sheet-head h2 {
  font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
  font-size: clamp(34px, 8.5vw, 60px); line-height: .92; color: var(--accent);
  text-shadow: 0 0 22px rgba(231, 197, 110, .22);
}
.sheet-head .sub { font-family: var(--font-body); font-style: italic; color: var(--text-dim); font-size: clamp(14px, 2.4vw, 18px); margin-top: 2px; }
.fiche-badge {
  position: absolute; right: clamp(18px, 5vw, 40px); bottom: -14px; z-index: 5;
  font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  font-size: 11.5px; padding: 7px 14px; background: var(--accent); color: var(--accent-ink);
  border: 2px solid var(--bg); white-space: nowrap; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.fiche-badge:hover, .fiche-badge:focus-visible {
  transform: translateY(-1px); box-shadow: 0 0 18px rgba(231, 197, 110, .5);
}

.sheet-body {
  position: relative; z-index: 1;
  /* Marge basse généreuse : le menu contextuel ne doit plus recouvrir les sources. */
  padding: 22px clamp(16px, 4vw, 26px) calc(116px + var(--safe-b));
}
.sheet-body .story { line-height: 1.62; }
.sheet-body .story::first-letter {
  font-family: var(--font-display); font-size: 3.1em; line-height: .72; float: left;
  padding: 8px 12px 0 0; color: var(--accent); text-shadow: 0 0 14px rgba(231, 197, 110, .4);
}

/* Image Mythéo en photo de profil, dans le médaillon du hero (repli sur le glyphe) */
.fiche-medallion { overflow: hidden; }
.fiche-medallion .med-glyph { display: grid; place-items: center; width: 100%; height: 100%; }
.fiche-medallion .med-photo {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0; transition: opacity .35s ease;
  /* iOS Safari ne découpe pas l'image absolue via overflow du parent → on arrondit
     l'image elle-même (fiable partout), avec un masque circulaire de secours. */
  border-radius: 50%; -webkit-mask-image: radial-gradient(circle, #000 99%, transparent 100%);
}
.fiche-medallion.has-photo .med-photo { opacity: 1; }
.fiche-medallion.has-photo { cursor: zoom-in; }
.fiche-medallion.has-photo:hover { box-shadow: 0 0 26px rgba(231, 197, 110, .45); }

/* Réglages (⚙️) — modale partagée, portée à la page explore */
.settings { display: flex; flex-direction: column; gap: 16px; margin: 4px 0 0; }
.set-row { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.set-label { font-size: 14px; color: var(--text-dim); font-weight: 600; }
.settings .seg { display: flex; width: 100%; }
.settings .seg button { flex: 1; }
.settings-modal {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(4, 6, 16, .72); backdrop-filter: blur(3px);
}
.settings-card {
  position: relative; width: 100%; max-width: 420px;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius-lg, 18px); box-shadow: var(--shadow-2);
  padding: 24px 22px calc(24px + var(--safe-b));
}
.settings-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 18px; }
.settings-close {
  position: absolute; top: 12px; right: 12px;
  width: 36px; height: 36px; border-radius: var(--radius-round);
  background: var(--bg-raised-2); color: var(--text-dim); font-size: 20px;
}
/* Bouton réglages de la barre du haut */
.topset {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: var(--radius-round);
  background: transparent; border: 1px solid var(--line); color: var(--text-dim); font-size: 18px;
  transition: color .15s ease, border-color .15s ease;
}
.topset:hover, .topset:focus-visible { color: var(--accent); border-color: var(--accent); }

/* Liens de sources cliquables */
.sources a {
  color: var(--accent); text-decoration: none;
  border-bottom: 1px dotted color-mix(in srgb, var(--accent) 55%, transparent);
}
.sources a:hover, .sources a:focus-visible { border-bottom-style: solid; }

/* Plein écran d'une illustration */
.illus-lightbox {
  position: fixed; inset: 0; z-index: 120; display: grid; place-items: center;
  background: rgba(6, 10, 13, .93); padding: 20px; cursor: zoom-out;
  opacity: 0; transition: opacity .2s ease;
}
.illus-lightbox.on { opacity: 1; }
.illus-lightbox img {
  max-width: 100%; max-height: 100%;
  box-shadow: 0 12px 46px rgba(0, 0, 0, .6); border: 1px solid rgba(231, 197, 110, .3);
}
.illus-lightbox .lb-close {
  position: absolute; top: calc(14px + var(--safe-t)); right: 16px;
  width: var(--touch); height: var(--touch); border-radius: var(--radius-round);
  background: rgba(12, 20, 24, .6); border: 1px solid var(--line); color: var(--text); font-size: 20px;
}

/* cartouches à coins */
.sheet-body .block {
  margin-top: 20px; position: relative; padding: 16px 18px;
  background: rgba(12, 20, 24, .3); border: 1px solid rgba(231, 197, 110, .38);
}
.sheet-body .block::before, .sheet-body .block::after {
  content: ""; position: absolute; width: 9px; height: 9px; border: 2px solid var(--accent);
}
.sheet-body .block::before { left: -1px; top: -1px; border-right: 0; border-bottom: 0; }
.sheet-body .block::after { right: -1px; bottom: -1px; border-left: 0; border-top: 0; }
.sheet-body .block h3 {
  font-family: var(--font-display); font-size: 12.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 7px;
}
.sheet-body .block p { line-height: 1.55; }
.sheet-body .block.fun p { color: var(--text); }

.sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.sheet-actions .act {
  flex: 1; min-width: 140px; min-height: 50px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 14px;
  background: rgba(12, 20, 24, .32);
  border: 1px solid rgba(231, 197, 110, .4);
  color: var(--text);
  font-family: var(--font-display); font-size: 13px; letter-spacing: .03em; font-weight: 600;
  cursor: pointer; transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.sheet-actions .act svg { width: 19px; height: 19px; color: var(--accent); flex: none; }
.sheet-actions .act:hover { border-color: var(--accent); background: rgba(231, 197, 110, .08); }
.sheet-actions .act:active { transform: scale(.98); }

.link-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.link-chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-round);
  background: var(--bg-raised);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line));
  font-family: var(--font-display);
  font-size: 13.5px; font-weight: 600;
  color: var(--text); cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .12s ease;
}
.link-chip:hover { border-color: var(--accent); box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 24%, transparent); transform: translateY(-2px); }
.link-chip:active { transform: scale(.97); }

.artworks .artwork { margin-bottom: 16px; }
.artworks img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}
.artworks figcaption {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-top: 6px;
  line-height: 1.4;
}
.artworks figcaption a { color: var(--text-dim); }
.artworks .museum { font-style: italic; }
.artworks .license { color: var(--text-faint); font-size: 11.5px; }

.sources summary { font-size: 13.5px; color: var(--text-dim); font-weight: 600; }
.sources ul { margin-top: 8px; padding-left: 18px; list-style: disc; }
.sources li { font-size: 13.5px; color: var(--text-dim); margin-bottom: 4px; }

.link-chip.corr { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); }

/* --- Mode révision (flashcards) --- */
.quiz-review-btn { width: 100%; }
.flashcard {
  position: relative;
  width: 100%;
  min-height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  margin: 6px 0 4px;
}
.flashcard:active { transform: scale(.99); }
.fc-face { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.flashcard .fc-back { display: none; }
.flashcard.flipped .fc-front { display: none; }
.flashcard.flipped .fc-back { display: flex; }
.fc-ico { font-size: 42px; }
.fc-name { font-size: 24px; font-weight: 800; }
.fc-hint { font-size: 12px; color: var(--text-faint); }
.fc-sub { font-size: 17px; font-weight: 700; color: var(--accent-strong); }
.fc-key { font-size: 15px; color: var(--text-dim); line-height: 1.5; }

/* --- Parcours guidés --- */
.parcours-bar { margin-bottom: 16px; }
.parcours-title { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin-bottom: 8px; }
.parcours-cards { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.parcours-cards::-webkit-scrollbar { display: none; }
.parcours-card {
  position: relative;
  flex: none;
  width: 210px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
}
.parcours-card:active { transform: scale(.98); }
.pc-title { font-weight: 700; font-size: 15px; }
.pc-desc { font-size: 12.5px; color: var(--text-dim); }
.pc-count { font-size: 12px; color: var(--accent-strong); font-weight: 600; margin-top: 4px; }

.parcours-nav {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px; margin-bottom: 6px;
  background: var(--bg-raised); border: 1px solid var(--accent); border-radius: var(--radius-md);
}
.pn-label { font-size: 13px; font-weight: 700; color: var(--accent-strong); }
.pn-btns { display: flex; gap: 8px; }
.pn-btns .btn { flex: 1; min-height: 40px; padding: 0 10px; font-size: 13.5px; }

/* --- Bloc Famille (parenté) --- */
.sheet-body .block.family .fam-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.sheet-body .block.family .fam-row:last-child { margin-bottom: 0; }
.fam-label { font-size: 12px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }

.sheet-body .pron { font-size: 14px; color: var(--accent-strong); font-weight: 600; margin-bottom: 10px; }

/* --- Arbre généalogique en constellation --- */
.block.family { padding-left: 12px; padding-right: 12px; }
.block.family > h3 { text-align: center; }
.constel-wrap {
  position: relative; overflow: hidden; margin-top: 8px;
  height: clamp(300px, 56vh, 460px);
  touch-action: none; cursor: grab; user-select: none;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(231, 197, 110, .05), transparent 60%),
    linear-gradient(180deg, rgba(12, 20, 24, .35), rgba(12, 20, 24, .55));
  border: 1px solid rgba(231, 197, 110, .28);
}
.constel-wrap.grabbing { cursor: grabbing; }
.constel-svg { display: block; transform-origin: 0 0; will-change: transform; }
.constel-hint {
  position: absolute; left: 10px; bottom: 8px; pointer-events: none;
  font-family: var(--font-display); font-size: 10.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-faint); opacity: .8;
}
.constel-recenter {
  position: absolute; right: 8px; top: 8px; width: 34px; height: 34px;
  display: grid; place-items: center; border-radius: 3px;
  background: rgba(12, 20, 24, .6); border: 1px solid rgba(231, 197, 110, .4);
  color: var(--accent); font-size: 17px; cursor: pointer;
}
.constel-recenter:hover { border-color: var(--accent); box-shadow: 0 0 12px rgba(231, 197, 110, .3); }
.constel-recenter:active { transform: scale(.94); }

/* ---------------------------------------------------------- effets --- */
/* Révélation des sections de la fiche à l'ouverture */
@keyframes fiche-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.sheet.open .sheet-body > * { animation: fiche-in .5s cubic-bezier(.2, .7, .2, 1) both; }
.sheet.open .sheet-body > *:nth-child(2) { animation-delay: .05s; }
.sheet.open .sheet-body > *:nth-child(3) { animation-delay: .10s; }
.sheet.open .sheet-body > *:nth-child(4) { animation-delay: .15s; }
.sheet.open .sheet-body > *:nth-child(5) { animation-delay: .20s; }
.sheet.open .sheet-body > *:nth-child(n+6) { animation-delay: .24s; }

/* Constellation : pulsation douce de l'étoile centrale + étoiles réactives */
@keyframes cn-pulse { 0%, 100% { opacity: .9; } 50% { opacity: .45; } }
.cn-glow { animation: cn-pulse 3.2s ease-in-out infinite; }
.cn-star { r: 3.4; transition: r .12s ease, filter .12s ease; }
.cn-node:hover .cn-star, .cn-node:focus-visible .cn-star { r: 5.5; filter: drop-shadow(0 0 5px rgba(231, 197, 110, .85)); }

/* Boutons d'action de fiche : glow au survol */
.sheet-actions .act:hover { box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 24%, transparent); }
.cn-blood { stroke: var(--accent); stroke-width: 1.4; fill: none; opacity: .68; }
/* Lignée (parenté indirecte, sur plusieurs générations) : or plus discret, pointillé fin. */
.cn-lineage { stroke: var(--accent); stroke-width: 1.1; fill: none; stroke-dasharray: 1.5 5; stroke-linecap: round; opacity: .42; }
.cn-union { stroke: var(--rust); stroke-width: 1.6; fill: none; stroke-dasharray: 3 7; stroke-linecap: round; opacity: .85; }
.cn-glow { fill: url(#cnGlow); }
.cn-mestar { fill: var(--accent-strong); stroke: #fff; stroke-width: 1; }
.cn-star { stroke: rgba(255,255,255,.35); stroke-width: .5; }
.cn-hit { fill: transparent; }
.cn-name { font-family: var(--font-body); fill: var(--text); font-size: 14px; }
.cn-node { cursor: pointer; }
.cn-node.cn-self { cursor: default; }
.cn-node:hover .cn-name, .cn-node:focus-visible .cn-name { fill: var(--accent-strong); }
.cn-node:focus { outline: none; }
.cn-node:focus-visible .cn-star { stroke: var(--accent-strong); stroke-width: 2; }
.cn-node.sp .cn-name { fill: var(--rust); font-style: italic; }
.cn-self .cn-name { font-family: var(--font-display); fill: var(--accent-strong); font-size: 17px; font-weight: 700; }
.cn-tier { font-family: var(--font-display); fill: var(--wave); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }

/* Petit symbole de type en ligne (remplace les emojis dans cartes/chips/graphe) */
.tglyph { width: 1.25em; height: 1.25em; display: inline-block; vertical-align: -0.24em; flex: none; }
.link-chip .tglyph { margin-right: 5px; }
.chip .tglyph { margin-right: 3px; }
.b-glyph { color: var(--accent); display: block; }
.badge:not(.earned) .b-glyph { color: var(--text-faint); opacity: .7; }

.c-bar { margin-bottom: 12px; }
