/* Les Annales d'Aubemont (annales.js) : un livre de chroniques ouvert sur la table sombre ; vélin, encre brune,
   rubriques rouges, fanions des Blasons. Préfixe an-. */
body.annales { min-height: 100dvh; }
.an-app { width: min(100%, 860px); margin: 0 auto; padding: 0 12px max(40px, env(safe-area-inset-bottom)); }
.an-charge { padding: 60px 0; text-align: center; color: var(--encre-att); }

.an-tete { display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 0 10px; }
.an-retour { display: grid; place-items: center; width: 44px; height: 44px; margin-left: -8px; color: var(--encre-att); }
.an-retour svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.an-boutique { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px 0 9px; border: 1px solid rgba(242, 196, 107, .45); border-radius: 999px; color: #F6D894; text-decoration: none; font: 600 1rem/1 var(--titre); background: #140D0B; }
.an-boutique .pf-piece { width: 18px; height: 18px; }
.an-son { position: relative; } /* sa zone tactile élargie (::after) se mesure sur lui, pas sur l’en-tête */
.an-menu { margin-left: auto; }
.mc-dans .an-tete .an-son { visibility: hidden; }

/* Le livre : une page de vélin */
.an-livre {
  --encre-v: #2E1E12; --encre-p: #6A5440; --rubrique: #8E1E14; --velin: #EADDBE;
  position: relative; padding: 26px 16px 22px; color: var(--encre-v);
  background:
    radial-gradient(ellipse 60% 40% at 15% 10%, rgba(140, 100, 50, .18), transparent 70%),
    radial-gradient(ellipse 50% 30% at 85% 90%, rgba(120, 80, 40, .2), transparent 70%),
    radial-gradient(ellipse 120% 100% at 50% 50%, transparent 60%, rgba(90, 60, 25, .35)),
    linear-gradient(180deg, #F1E6CB, #E4D3AE);
  box-shadow: 0 0 0 1px #8A6A3E, 0 0 0 5px #2A1A10, 0 0 0 6px #6A4A22, 0 30px 70px rgba(0, 0, 0, .7);
  animation: an-ouvre .6s cubic-bezier(.2, .8, .3, 1) both;
}
.an-livre::before { content: ""; position: absolute; inset: 8px; border: 1px solid rgba(110, 70, 30, .35); pointer-events: none; }
@keyframes an-ouvre { from { opacity: 0; transform: translateY(16px) scale(.985); } }
@media (min-width: 720px) { .an-livre { padding: 40px 44px 34px; } }

.an-titre { display: grid; justify-items: center; gap: 6px; text-align: center; }
.an-sur { margin: 0; font: 500 .74rem/1 var(--titre); letter-spacing: .26em; text-transform: uppercase; color: var(--encre-p); }
.an-titre h1 { font: 600 clamp(2rem, 9vw, 3.2rem)/1 var(--titre); color: var(--encre-v); letter-spacing: .01em; }
.an-lettrine { display: inline-block; margin-right: 1px; color: var(--rubrique); font-size: 1.3em; line-height: .8; text-shadow: 1px 1px 0 rgba(255, 240, 200, .6); }
.an-lore { margin: 2px 0 0; max-width: 40ch; font: italic 500 1.08rem/1.4 var(--titre); color: var(--encre-p); text-wrap: balance; }
.an-chapitre { margin: 4px 0 0; padding: 4px 12px; border-top: 1px solid rgba(110, 70, 30, .4); border-bottom: 1px solid rgba(110, 70, 30, .4); font: 400 .82rem/1.3 var(--etiquette); letter-spacing: .04em; color: var(--rubrique); }
.an-chapitre:empty { display: none; }

/* Signets : les quatre tableaux */
.an-onglets { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 20px -6px 0; border-bottom: 2px solid rgba(110, 70, 30, .5); }
.an-onglets button { position: relative; min-height: 46px; padding: 0 2px; border: 0; background: none; color: var(--encre-p); font: 600 .92rem/1.05 var(--titre); }
.an-onglets button[aria-selected="true"] { color: var(--rubrique); }
.an-onglets button[aria-selected="true"]::after { content: ""; position: absolute; left: 50%; bottom: -14px; width: 16px; height: 22px; margin-left: -8px; background: var(--rubrique); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); }
@media (min-width: 720px) { .an-onglets button { font-size: 1.2rem; } }
.an-periode { display: flex; justify-content: center; gap: 0; margin: 24px auto 0; width: max-content; border: 1px solid rgba(110, 70, 30, .5); }
.an-periode button { min-height: 40px; padding: 0 16px; border: 0; background: none; color: var(--encre-p); font: 600 1rem/1 var(--titre); }
.an-periode button[aria-checked="true"] { background: var(--encre-v); color: var(--velin); }
.an-sous { margin: 10px 0 0; text-align: center; font: italic 500 .95rem/1.2 var(--titre); color: var(--encre-p); }

.an-tableau { margin-top: 10px; }
.an-vide, .an-note { margin: 24px 0; text-align: center; font: italic 500 1.05rem/1.4 var(--titre); color: var(--encre-p); }
.an-note a, .an-lien { color: var(--rubrique); font: inherit; background: none; border: 0; text-decoration: underline; }

/* Le podium : trois étendards suspendus */
.an-podium { list-style: none; margin: 18px 0 8px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 8px; }
.an-marche { display: grid; justify-items: center; animation: an-hisse .7s cubic-bezier(.2, .9, .3, 1.15) calc(.15s + var(--i, 0) * .12s) both; }
@keyframes an-hisse { from { opacity: 0; transform: translateY(-26px); } }
.an-marche-btn { display: grid; justify-items: center; gap: 3px; width: 100%; padding: 0; border: 0; background: none; color: inherit; text-align: center; }
.an-etendard { position: relative; display: block; width: 64%; aspect-ratio: 2 / 3; filter: drop-shadow(0 6px 8px rgba(60, 30, 10, .45)); transform-origin: 50% 0; animation: an-flotte 5s ease-in-out infinite; }
.an-etendard::before { content: ""; position: absolute; left: -10%; right: -10%; top: -4px; height: 5px; z-index: 3; border-radius: 3px; background: linear-gradient(180deg, #F0D9A0, #6A4A22); }
.an-marche--1 .an-etendard { width: 80%; }
.an-rang-grand { position: absolute; left: 50%; bottom: 22%; z-index: 4; transform: translateX(-50%); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #FFF3C4, #D9A43A 55%, #8A5E16); color: #3A2208; font: 600 1.05rem/1 var(--titre); box-shadow: 0 2px 6px rgba(0, 0, 0, .5); }
.an-marche--2 .an-rang-grand { background: radial-gradient(circle at 40% 35%, #FFFFFF, #C8CED6 55%, #6A727C); }
.an-marche--3 .an-rang-grand { background: radial-gradient(circle at 40% 35%, #FFE0C0, #C08A48 55%, #6A4520); }
.an-marche--1 .an-rang-grand { width: 42px; height: 42px; font-size: 1.3rem; box-shadow: 0 0 16px rgba(242, 196, 107, .9); }
.an-marche-pseudo { margin-top: 6px; max-width: 100%; font: 600 1.08rem/1.1 var(--titre); color: var(--encre-v); overflow-wrap: anywhere; }
.an-marche--1 .an-marche-pseudo { font-size: 1.3rem; }
.an-marche-titre { font: italic 500 .8rem/1.15 var(--titre); color: var(--encre-p); }
.an-marche-valeur { font-size: .78rem; color: var(--encre-p); }
.an-marche-valeur b { display: block; font: 600 1.25rem/1.1 var(--titre); color: var(--rubrique); }
.an-socle { width: 92%; height: 10px; margin-top: 6px; background: linear-gradient(180deg, #8A6A3E, #4A3018); border-radius: 2px 2px 0 0; }
.an-marche--1 .an-socle { height: 22px; } .an-marche--2 .an-socle { height: 15px; }
.an-marche-btn:focus-visible { outline: 2px solid var(--rubrique); outline-offset: 2px; }
@keyframes an-flotte { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(1.4deg) skewX(-1deg); } }

/* Les lignes du registre */
.an-liste { list-style: none; margin: 10px 0 0; padding: 0; display: grid; }
.an-ligne button {
  display: grid; grid-template-columns: 30px 28px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; min-height: 58px; padding: 6px 4px;
  border: 0; border-bottom: 1px solid rgba(110, 70, 30, .28); background: none; color: inherit; text-align: left;
}
.an-ligne button:hover { background: rgba(110, 70, 30, .08); }
.an-ligne button:focus-visible { outline: 2px solid var(--rubrique); outline-offset: -2px; }
.an-rang { font: 600 1.2rem/1 var(--titre); color: var(--encre-p); text-align: right; }
.an-fanion { position: relative; display: block; width: 28px; height: 42px; filter: drop-shadow(0 2px 3px rgba(60, 30, 10, .4)); }
.an-qui { display: grid; min-width: 0; }
.an-qui b { font: 600 1.1rem/1.15 var(--titre); color: var(--encre-v); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-qui i { font: italic 500 .82rem/1.2 var(--titre); color: var(--encre-p); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-valeur { display: grid; justify-items: end; }
.an-valeur b { font: 600 1.2rem/1 var(--titre); color: var(--rubrique); white-space: nowrap; }
.an-valeur small { font-size: .7rem; color: var(--encre-p); }
.an-ligne--moi button { background: linear-gradient(90deg, rgba(142, 30, 20, .14), rgba(142, 30, 20, .04)); box-shadow: inset 3px 0 0 var(--rubrique); }

/* Ma place, épinglée en bas de l'écran */
.an-moi { position: sticky; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 5; margin-top: 14px; padding: 4px 8px 0; background: #EADDBE; box-shadow: 0 0 0 1px #8A6A3E, 0 -10px 30px rgba(0, 0, 0, .35); }
.an-moi-sur { margin: 0; padding-top: 4px; font: 500 .68rem/1 var(--titre); letter-spacing: .2em; text-transform: uppercase; color: var(--rubrique); }
.an-moi .an-liste { margin: 0; }
.an-moi .an-ligne button { border-bottom: 0; }

/* Le Blason par-dessus le livre */
.an-voile { position: fixed; inset: 0; z-index: 80; display: grid; place-items: start center; overflow-y: auto; padding: max(16px, env(safe-area-inset-top)) 12px 24px; background: rgba(5, 3, 4, .84); animation: bq-fondu .25s ease-out both; }
.an-voile.sortie { animation: bq-fondu .25s ease-in reverse both; }
@keyframes bq-fondu { from { opacity: 0; } }
.an-voile-corps { position: relative; display: grid; justify-items: center; width: 100%; max-width: 760px; margin: auto 0; animation: an-blason .5s cubic-bezier(.2, .9, .3, 1.1) both; }
@keyframes an-blason { from { opacity: 0; transform: translateY(24px) scale(.96); } }
.an-voile .an-vide { color: var(--encre-att); }
.an-fermer { position: absolute; top: 4px; right: 4px; z-index: 10; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(11, 8, 9, .6); color: var(--encre); font: 300 2rem/1 var(--titre); }

/* La carte du royaume, discrète, au pied du livre */
.an-carte { display: flex; align-items: center; gap: 10px; width: max-content; min-height: 44px; margin: 22px auto 0; padding: 0 16px 0 6px; color: #F6D894; text-decoration: none; font: italic 500 1.05rem/1 var(--titre); opacity: .85; transition: opacity .2s; }
.an-carte:hover, .an-carte:focus-visible { opacity: 1; }
.an-carte svg { width: 38px; height: 38px; padding: 3px; border: 1px solid rgba(242, 196, 107, .45); border-radius: 50%; background: #140D0B; fill: none; stroke: #C9A24A; stroke-width: 1; transition: transform .6s cubic-bezier(.2, .9, .3, 1.2); }
.an-carte:hover svg { transform: rotate(20deg); }
.an-carte .an-carte-aig { fill: #3A2616; stroke: #C9A24A; }
.an-carte .an-carte-nord { fill: #F0D9A0; stroke: none; }

@media (prefers-reduced-motion: reduce) {
  .an-livre, .an-marche, .an-etendard, .an-voile, .an-voile.sortie, .an-voile-corps { animation: none; }
}

/* ——— Ordinateur : un livre plus large ; le registre se lit sur deux colonnes (rangs 4 à 27, puis la suite) ——— */
@media (min-width: 1100px) and (min-height: 640px) {
  .an-app { width: min(100% - 48px, 1180px); }
  .an-livre { padding: 48px 64px 40px; }
  .an-podium { max-width: 760px; margin-inline: auto; gap: 24px; }
  :not(.an-moi) > .an-liste { display: block; columns: 2; column-gap: 48px; }
  :not(.an-moi) > .an-liste > li { break-inside: avoid; }
  .an-moi { max-width: 560px; margin-inline: auto; }
}

/* Entre amis : le second sélecteur suit de près celui de la période */
.an-periode + .an-cercle { margin-top: 10px; }
