/* ---------- Typographies auto-hébergées (variables, latin) ---------- */
@font-face {
    font-family: "Cinzel";
    src: url("../fonts/cinzel.woff2") format("woff2");
    font-weight: 400 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Cormorant Garamond";
    src: url("../fonts/cormorant.woff2") format("woff2");
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Cormorant Garamond";
    src: url("../fonts/cormorant-italic.woff2") format("woff2");
    font-weight: 300 700;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "EB Garamond";
    src: url("../fonts/ebgaramond.woff2") format("woff2");
    font-weight: 400 800;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "EB Garamond";
    src: url("../fonts/ebgaramond-italic.woff2") format("woff2");
    font-weight: 400 800;
    font-style: italic;
    font-display: swap;
}

/* ---------- Palette « Le Seuil de Minuit » ---------- */
:root {
    --bg: #140b24;
    --bg-deep: #0c0616;
    --bg-alt: #241539;
    --bg-input: #180e2a;
    --fg: #ede4d3;
    --accent: #cfa03a;
    --accent-bright: #f0b94a;
    --accent-soft: rgba(207, 160, 58, 0.14);
    --accent-glow: rgba(240, 185, 74, 0.35);
    --amethyste: #583c8c;
    --braise: #b33a2b;
    --muted: rgba(237, 228, 211, 0.62);
    --border: rgba(237, 228, 211, 0.12);
    --border-gold: rgba(207, 160, 58, 0.38);
    --user-bubble: linear-gradient(135deg, #d4a63f 0%, #b8913c 100%);
    --user-bubble-fg: #140b24;
    --assistant-bubble: rgba(237, 228, 211, 0.05);
    --danger: #e07070;
    --shadow-card: 0 6px 24px rgba(0, 0, 0, 0.5);
    --font-grave: "Cinzel", "Palatino Linotype", Georgia, serif;
    --font-display: "Cormorant Garamond", Georgia, serif;
    --font-body: "EB Garamond", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 1.05rem;
    background:
        radial-gradient(ellipse 75% 55% at 50% -12%, rgba(88, 60, 140, 0.30) 0%, transparent 62%),
        radial-gradient(ellipse 85% 45% at 50% 112%, rgba(179, 58, 43, 0.13) 0%, transparent 65%),
        linear-gradient(175deg, var(--bg) 0%, var(--bg-deep) 100%);
    background-attachment: fixed;
    color: var(--fg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Seul le cabinet (chat) verrouille sa hauteur à l'écran : les messages
   défilent à l'intérieur (main peut s'écraser via min-height: 0). Les
   pages annexes restent en flux normal — la page défile, le pied de page
   vient après le contenu, clavier virtuel ouvert compris. */
body.page-chat { height: 100%; }

/* Voile étoilé subtil, en CSS pur (aucune image) */
.veil {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        radial-gradient(1px 1px at 12% 22%, rgba(244,236,216,0.5) 50%, transparent 51%),
        radial-gradient(1px 1px at 78% 12%, rgba(244,236,216,0.35) 50%, transparent 51%),
        radial-gradient(1.5px 1.5px at 55% 35%, rgba(201,162,74,0.4) 50%, transparent 51%),
        radial-gradient(1px 1px at 30% 68%, rgba(244,236,216,0.28) 50%, transparent 51%),
        radial-gradient(1px 1px at 88% 55%, rgba(244,236,216,0.3) 50%, transparent 51%),
        radial-gradient(1.5px 1.5px at 8% 85%, rgba(201,162,74,0.3) 50%, transparent 51%),
        radial-gradient(1px 1px at 65% 82%, rgba(244,236,216,0.25) 50%, transparent 51%),
        radial-gradient(1px 1px at 42% 8%, rgba(244,236,216,0.3) 50%, transparent 51%);
    opacity: 0.8;
}

header.topbar, main, footer.disclaimer { position: relative; z-index: 1; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1.25rem;
    border-bottom: 1px solid var(--border-gold);
    background: rgba(20, 11, 36, 0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 5;
}
.brand {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    text-decoration: none;
}
.brand-sigil {
    color: var(--accent);
    font-size: 0.95rem;
    text-shadow: 0 0 12px var(--accent-glow);
}
.brand-text {
    font-family: var(--font-grave);
    font-weight: 500;
    font-size: 1.15rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--accent-bright);
}
.topnav {
    display: flex;
    gap: 1rem;
    align-items: center;
}
.topnav a {
    color: var(--fg);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}
.topnav a:hover { color: var(--accent-bright); }
.btn-mini {
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border-gold);
    border-radius: 20px;
    background: var(--accent-soft);
    letter-spacing: 0.03em;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.btn-mini:hover {
    background: var(--accent);
    color: var(--bg) !important;
    box-shadow: 0 0 16px var(--accent-glow);
}
.badge-cercle {
    font-size: 0.82rem;
    color: var(--accent-bright);
    border: 1px solid var(--border-gold);
    border-radius: 20px;
    padding: 0.3rem 0.75rem;
    letter-spacing: 0.04em;
    background: var(--accent-soft);
}

/* ---------- Main / chat layout ---------- */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    min-height: 0;
}

.chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1rem 1rem;
    min-height: 0;
}

/* ---------- Cartouche du cabinet (en-tête persona) ----------
   Plus un en-tête de messagerie (avatar + nom à gauche) mais un
   cartouche gravé, centré, comme l'enseigne du cabinet. */
.persona-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0.55rem 0.75rem 0.7rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
}
.persona-sigil {
    color: var(--accent);
    font-size: 0.8rem;
    opacity: 0.85;
    text-shadow: 0 0 10px var(--accent-glow);
}
.persona-name {
    margin: 0;
    font-family: var(--font-grave);
    font-weight: 500;
    font-size: 1.15rem;
    letter-spacing: 0.3em;
    text-indent: 0.3em;
    text-transform: uppercase;
    color: var(--accent-bright);
    line-height: 1.15;
}
.persona-title {
    margin: 0.1rem 0 0;
    font-family: var(--font-display);
    font-size: 0.92rem;
    font-style: italic;
    color: var(--muted);
    letter-spacing: 0.05em;
}

/* ---------- Messages ---------- */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.5rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-gold) transparent;
}

/* La conversation n'est plus une messagerie : la parole d'Astrid est
   une lecture de consultation (pleine mesure, ornement d'ouverture),
   celle de l'utilisateur une question notée en marge droite. */
.msg {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.55;
    animation: fade-in 0.35s ease-out;
}
/* T6 : la question est consignée dans le registre — le filet doré se
   trace (pseudo-élément en scaleY, plus un border animable) pendant
   que la note glisse de quelques pixels depuis la marge. */
.msg-user {
    position: relative;
    align-self: flex-end;
    max-width: 78%;
    text-align: right;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.12rem;
    color: rgba(237, 228, 211, 0.86);
    padding: 0.15rem 0.85rem 0.15rem 0;
    margin: 0.35rem 0;
    animation: note-glisse 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.msg-user::after {
    content: "";
    position: absolute;
    top: 0.15rem;
    bottom: 0.15rem;
    right: 0;
    width: 2px;
    background: var(--border-gold);
    transform-origin: top;
    animation: filet-trace 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) 0.1s backwards;
}
@keyframes note-glisse {
    from { opacity: 0; transform: translateX(12px); }
}
@keyframes filet-trace {
    from { transform: scaleY(0); }
}
.msg-assistant {
    align-self: stretch;
    max-width: 62ch;
    margin: 0.4rem auto 0.55rem;
    padding: 0 0.25rem;
    line-height: 1.7;
    width: 100%;
}
/* L'ornement qui marque la prise de parole d'Astrid */
.msg-assistant::before {
    content: "✦";
    display: block;
    text-align: center;
    color: var(--accent);
    opacity: 0.55;
    font-size: 0.7rem;
    letter-spacing: 0.4em;
    text-indent: 0.4em;
    margin-bottom: 0.75rem;
}
.msg-system {
    color: var(--muted);
    font-style: italic;
    text-align: center;
    align-self: center;
    font-size: 0.9rem;
    max-width: 92%;
}
.didascalie {
    display: block;
    text-align: center;
    font-family: var(--font-display);
    font-style: italic;
    color: var(--accent-bright);
    opacity: 0.9;
    font-size: 1.08em;
    margin-bottom: 0.8rem;
}

/* Révélation avec rythme : les segments naissent transparents et
   s'éclairent l'un après l'autre. Opacité seule (aucun décalage de
   mise en page, lisible par les lecteurs d'écran dès l'insertion). */
.msg-assistant .seg { transition: opacity 0.85s ease; }
.msg-assistant .seg.seg-cache { opacity: 0; }
.msg-assistant.reveal-instant .seg { transition: none; }
.msg-assistant.en-revelation { cursor: pointer; }

@keyframes fade-in {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- L'attente (Astrid consulte) ---------- */
.typing {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.5rem 1rem;
    color: var(--muted);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 0.98rem;
    align-self: center;
}
.typing[hidden] { display: none; }
.typing-sigil {
    color: var(--accent);
    font-size: 0.85rem;
    animation: souffle 1.8s infinite ease-in-out;
}
@keyframes souffle {
    0%, 100% { opacity: 0.35; transform: scale(0.92); }
    50% { opacity: 1; transform: scale(1.08); }
}

/* ---------- L'écritoire (zone de saisie) ----------
   Plus une barre de messagerie : une surface d'écriture du cabinet,
   ouverte par un filet doré et son sigil. */
.ecritoire { margin-top: 0.6rem; }
.ecritoire-orn {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--accent);
    opacity: 0.65;
    font-size: 0.7rem;
    margin: 0 0.25rem 0.55rem;
}
.ecritoire-orn span {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--border-gold) 100%);
}
.ecritoire-orn span:last-child {
    background: linear-gradient(90deg, var(--border-gold) 0%, transparent 100%);
}
.chat-form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(24, 14, 42, 0.72) 0%, rgba(14, 7, 26, 0.85) 100%);
    transition: border-color 0.25s, box-shadow 0.25s;
}
.chat-form:focus-within {
    border-color: var(--border-gold);
    box-shadow: 0 0 0 3px rgba(201, 162, 74, 0.08), 0 4px 18px rgba(0, 0, 0, 0.3);
}
.chat-form textarea {
    flex: 1;
    padding: 0.6rem 0.5rem;
    border: none;
    background: transparent;
    color: var(--fg);
    font-family: inherit;
    font-size: 1.05rem;
    resize: none;
    line-height: 1.4;
    max-height: 200px;
    overflow-y: auto;
}
.chat-form textarea:focus { outline: none; }
.chat-form textarea::placeholder {
    color: var(--muted);
    font-family: var(--font-display);
    font-style: italic;
}
.chat-form textarea:disabled { opacity: 0.6; }
.chat-form button {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent-bright) 0%, var(--accent) 100%);
    color: var(--bg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.2s;
}
.chat-form button:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-form button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px var(--accent-glow);
}
.tirage-btn {
    position: relative;
    background: transparent !important;
    color: var(--accent) !important;
    border: 1px solid var(--border-gold) !important;
    font-size: 1.3rem !important;
}
.tirage-btn:hover:not(:disabled):not(.locked) { background: var(--accent-soft) !important; }
.tirage-btn.locked {
    opacity: 0.45;
    cursor: help;
    filter: grayscale(0.5);
}
.tirage-lock-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg-alt);
    border: 1px solid var(--border-gold);
    color: var(--accent-bright);
    font-size: 0.72rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tirage-lock-badge[hidden] { display: none; }
.tirage-btn.just-unlocked {
    animation: unlock-pulse 1.6s ease-out 3;
}
@keyframes unlock-pulse {
    0% { box-shadow: 0 0 0 0 var(--accent-glow); }
    70% { box-shadow: 0 0 0 12px rgba(201, 162, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(201, 162, 74, 0); }
}

/* ---------- Cartes révélées dans la conversation ---------- */
.cards-area {
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding: 1.2rem 0;
    align-self: center;
    flex-wrap: wrap;
    perspective: 1200px;
}
.card {
    width: 132px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
}
.card-inner {
    width: 100%;
    height: 214px;
    position: relative;
    transform-style: preserve-3d;
}
/* État final (historique rendu côté serveur) : face visible, figée */
.card.flipped .card-inner { transform: rotateY(180deg); }
/* Révélation vivante : la carte se soulève, pivote avec son poids, retombe */
.card.reveal .card-inner {
    animation: carte-revele 1.15s cubic-bezier(0.34, 0.08, 0.24, 1) forwards;
}
@keyframes carte-revele {
    0%   { transform: rotateY(0deg) translateY(0) scale(1); }
    30%  { transform: rotateY(0deg) translateY(-16px) scale(1.05); }
    100% { transform: rotateY(180deg) translateY(0) scale(1); }
}
/* Éclat doré au point de bascule */
.card.reveal::after {
    content: "";
    position: absolute;
    inset: -14% -20%;
    border-radius: 18px;
    pointer-events: none;
    background: radial-gradient(circle, rgba(240, 185, 74, 0.38) 0%, transparent 62%);
    opacity: 0;
    animation: carte-eclat 1.15s ease forwards;
}
@keyframes carte-eclat {
    0%, 42% { opacity: 0; }
    60%     { opacity: 1; }
    100%    { opacity: 0; }
}
.card-face {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.card-back {
    background:
        radial-gradient(circle at 50% 32%, rgba(240, 185, 74, 0.16) 0%, transparent 58%),
        linear-gradient(155deg, #221338 0%, #150c24 100%);
    border: 1px solid rgba(207, 160, 58, 0.5);
    box-shadow: var(--shadow-card);
}
/* Filet gravé intérieur du dos */
.card-back::before {
    content: "";
    position: absolute;
    inset: 7px;
    border: 1px solid rgba(207, 160, 58, 0.3);
    border-radius: 8px;
    pointer-events: none;
}
/* Rai de lumière sur le dos, juste avant le retournement */
.card.balayage .card-back::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 30%, rgba(240, 185, 74, 0.26) 50%, transparent 70%);
    transform: translateX(-130%);
    animation: carte-balayage 0.65s ease forwards;
}
@keyframes carte-balayage {
    to { transform: translateX(130%); }
}
.card-sigil {
    font-size: 2.2rem;
    color: var(--accent);
    opacity: 0.85;
    text-shadow: 0 0 12px var(--accent-glow);
}
.card-front {
    background: linear-gradient(180deg, #f4ecd8 0%, #e8dcbe 100%);
    color: #140b24;
    transform: rotateY(180deg);
    padding: 0.5rem;
    border: 1px solid var(--accent);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}
.card-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 11px;
}
/* Vignette de matière : la gravure semble posée sous un léger verre */
.card-front::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 11px;
    pointer-events: none;
    box-shadow: inset 0 0 30px rgba(20, 11, 36, 0.35), inset 0 0 4px rgba(20, 11, 36, 0.3);
}
/* Quand l'image charge OK, on masque le texte fallback */
.card-front:not(.no-image) .card-front-inner { display: none; }
.card-front-inner {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}
.card-name {
    font-weight: bold;
    font-size: 0.95rem;
    line-height: 1.2;
    margin-bottom: 0.25rem;
}
.card-meaning {
    font-size: 0.75rem;
    line-height: 1.3;
    opacity: 0.85;
}
.card-position {
    font-family: var(--font-grave);
    font-size: 0.68rem;
    color: var(--accent-bright);
    letter-spacing: 0.32em;
    text-transform: uppercase;
}

/* ---------- Le Rituel du tirage : la table d'Astrid ---------- */
.tirage-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    /* T1 : la caméra s'avance vers la table — le point de fuite est ici.
       Pas d'opacité animée sur l'overlay lui-même : elle multiplierait
       celle de la scène et cacherait le voyage en profondeur (cause
       racine du correctif post-étape 4). Le fond vit sur ::before. */
    perspective: 700px;
}
/* Le fond du rituel : un plan à part, en léger retrait de profondeur.
   Il arrive moins vite que la scène (parallax différentiel) et laisse
   entrevoir le cabinet qui recule pendant l'approche. inset négatif :
   à translateZ(-60px) il couvre encore tout l'écran. */
.tirage-overlay::before {
    content: "";
    position: absolute;
    inset: -8%;
    background:
        radial-gradient(ellipse 85% 55% at 50% 118%, rgba(179, 58, 43, 0.22) 0%, transparent 62%),
        radial-gradient(ellipse 70% 50% at 50% -12%, rgba(88, 60, 140, 0.30) 0%, transparent 62%),
        linear-gradient(180deg, #180e2b 0%, #0d0718 100%);
    animation: rituel-fond 0.65s ease-out backwards;
}
.tirage-overlay[hidden] { display: none; }
/* Annuler : on n'a rien engagé, sortie discrète et brève */
.tirage-overlay.se-ferme { opacity: 0; transition: opacity 0.3s ease; }
.tirage-scene {
    --carte-w: 76px;
    --carte-h: 123px;
    /* T1 : la scène naît en profondeur et vient se poser devant nous.
       fill backwards (pas forwards) : une fois posée, plus aucun
       transform résiduel — les transitions de sortie partent de zéro. */
    animation: rituel-approche 0.8s cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 1040px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 1rem 1rem 1.2rem;
}
.tirage-close {
    position: absolute;
    top: 0.85rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--fg);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    z-index: 5;
    transition: background 0.2s;
}
.tirage-close:hover { background: var(--accent-soft); }
.ornament {
    color: var(--accent);
    font-size: 0.8rem;
    letter-spacing: 0.6em;
    margin-bottom: 0.6rem;
    opacity: 0.85;
    text-shadow: 0 0 10px var(--accent-glow);
}
.son-toggle {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.85rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--muted);
    font-family: var(--font-grave);
    font-size: 0.62rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.son-toggle[aria-pressed="true"] {
    color: var(--accent-bright);
    border-color: var(--border-gold);
    background: var(--accent-soft);
}
.tirage-tete {
    text-align: center;
    padding: 0.5rem 3.5rem 0.3rem;
}
.tirage-eyebrow {
    margin: 0 0 0.5rem;
    font-family: var(--font-grave);
    font-size: 0.66rem;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: var(--accent);
}
.tirage-tete h2 {
    margin: 0;
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 500;
    font-size: clamp(1.4rem, 3.4vw, 1.9rem);
    color: var(--fg);
}
/* Choix du rituel (abonnés) : trois cartes ou l'étoile à cinq */
.tirage-modes {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.7rem;
}
.tirage-modes[hidden] { display: none; }
.mode-btn {
    padding: 0.42rem 1rem;
    font-family: var(--font-grave);
    font-size: 0.62rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.mode-btn:hover { color: var(--fg); border-color: var(--border-gold); }
.mode-btn.actif {
    color: var(--accent-bright);
    border-color: var(--border-gold);
    background: var(--accent-soft);
    box-shadow: 0 0 14px rgba(240, 185, 74, 0.12);
}
/* L'autel : les places du tirage (3, ou 5 pour l'étoile) */
.autel {
    display: flex;
    justify-content: center;
    gap: clamp(0.9rem, 4vw, 2.2rem);
    padding: 1rem 0 2.1rem;
}
.autel.autel-etoile { gap: clamp(0.5rem, 2.2vw, 1.2rem); }
.autel.autel-etoile .slot-nom {
    font-size: 0.5rem;
    letter-spacing: 0.18em;
    width: calc(var(--carte-w) + 1.4rem);
    white-space: normal;
    text-align: center;
    line-height: 1.35;
    bottom: auto;
    top: calc(100% + 0.4rem);
}
.autel-slot {
    position: relative;
    width: var(--carte-w);
    height: var(--carte-h);
    border: 1px dashed rgba(207, 160, 58, 0.4);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.3s, box-shadow 0.3s;
    /* T7 : les places du tirage naissent en cascade (délai posé en JS) */
    animation: slot-nait 0.45s ease backwards;
}
@keyframes slot-nait {
    from { opacity: 0; transform: translateY(6px); }
}
.autel-slot .slot-vide {
    color: rgba(207, 160, 58, 0.3);
    font-size: 1.1rem;
    transition: opacity 0.3s;
}
.autel-slot.rempli {
    border-style: solid;
    border-color: var(--border-gold);
    box-shadow: 0 0 22px rgba(240, 185, 74, 0.18);
}
.autel-slot.rempli .slot-vide { opacity: 0; }
.slot-nom {
    position: absolute;
    left: 50%;
    bottom: -1.7rem;
    transform: translateX(-50%);
    font-family: var(--font-grave);
    font-size: 0.62rem;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
}
.autel-slot.rempli .slot-nom { color: var(--accent-bright); }
/* La table : l'éventail des 22 arcanes (positions calculées en JS).
   touch-action: none — le doigt balaye l'éventail (app.js), il ne doit
   pas faire défiler la page ; user-select — pas de sélection de texte
   ni de loupe iOS pendant le geste. */
.tirage-table {
    position: relative;
    flex: 1;
    min-height: 230px;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
.arcane {
    position: absolute;
    left: 50%;
    top: 0;
    width: var(--carte-w);
    height: var(--carte-h);
    margin-left: calc(var(--carte-w) / -2);
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    will-change: transform;
    transition: transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.45s ease;
}
.arcane-dos {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    border: 1px solid rgba(207, 160, 58, 0.5);
    background:
        radial-gradient(circle at 50% 30%, rgba(240, 185, 74, 0.14) 0%, transparent 60%),
        linear-gradient(155deg, #221338 0%, #150c24 100%);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5), inset 0 0 0 4px rgba(207, 160, 58, 0.07);
    color: rgba(240, 185, 74, 0.55);
    font-size: 1.05rem;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
/* Le survol soulève la carte hors de l'éventail, le long de son axe.
   :hover est réservé aux vrais pointeurs (hover: hover) : au toucher,
   le navigateur posait un « hover collant » sur la carte tapée. C'est
   la classe .survolee, posée par le balayage au doigt (app.js), qui
   joue ce rôle sur écran tactile. */
.arcane.survolee:not(.en-autel) .arcane-dos,
.arcane:focus-visible:not(.en-autel) .arcane-dos {
    transform: translateY(-18px);
    box-shadow: 0 18px 34px rgba(0, 0, 0, 0.55), 0 0 18px rgba(240, 185, 74, 0.2);
}
@media (hover: hover) {
    .arcane:hover:not(.en-autel) .arcane-dos {
        transform: translateY(-18px);
        box-shadow: 0 18px 34px rgba(0, 0, 0, 0.55), 0 0 18px rgba(240, 185, 74, 0.2);
    }
}
.arcane:focus-visible { outline: none; }
.arcane:focus-visible .arcane-dos { border-color: var(--accent-bright); }
.arcane.en-autel { z-index: 30; }
.arcane.en-autel .arcane-dos {
    border-color: var(--accent);
    background:
        radial-gradient(circle at 50% 30%, rgba(240, 185, 74, 0.24) 0%, transparent 62%),
        linear-gradient(155deg, #2a1844 0%, #1a0f2e 100%);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55), 0 0 24px rgba(240, 185, 74, 0.3);
}
.tirage-actions {
    display: flex;
    justify-content: center;
    padding: 1rem 0 0.2rem;
}
.cta-grave {
    padding: 0.95rem 2.4rem;
    font-family: var(--font-grave);
    font-size: 0.8rem;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    color: var(--accent-bright);
    background: transparent;
    border: 1px solid var(--border-gold);
    border-radius: 2px;
    cursor: pointer;
    transition: box-shadow 0.3s ease, background-color 0.3s ease, opacity 0.3s ease;
}
.cta-grave:disabled { opacity: 0.35; cursor: default; }
.cta-grave:not(:disabled):hover {
    background-color: var(--accent-soft);
    box-shadow: 0 0 26px rgba(240, 185, 74, 0.22);
}
.cta-grave.pret { animation: unlock-pulse 1.5s ease-out 2; }
button.btn { cursor: pointer; }

/* ---------- Auth forms (signup / login) ---------- */
/* T8 : les pages annexes se présentent avec le même souffle que le
   Seuil (seuil-apparait) — fin des chargements secs hors du cabinet.
   Transform/opacité seuls : aucun décalage de mise en page. */
.auth-form,
.pricing {
    animation: seuil-apparait 0.6s ease both;
}
.auth-form {
    max-width: 440px;
    margin: 2.5rem auto;
    padding: 1.75rem 1.5rem;
    background: rgba(42, 28, 74, 0.45);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-card);
    width: calc(100% - 2rem);
}
.auth-form h1 {
    margin: 0 0 0.5rem;
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--accent-bright);
}
.auth-sub {
    color: var(--muted);
    margin: 0 0 1.5rem;
    line-height: 1.55;
}
.auth-sub strong { color: var(--accent-bright); font-weight: 600; }
.auth-form form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    color: var(--fg);
    font-size: 0.95rem;
}
.auth-form label.checkbox {
    flex-direction: row;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.4;
}
/* Une vraie cible tactile : la case native (~13 px) était presque
   incochable au doigt. Tout le texte du label reste cliquable. */
.auth-form label.checkbox {
    padding: 0.25rem 0;
    cursor: pointer;
}
.auth-form label.checkbox input {
    margin-top: 0.1rem;
    width: 1.3rem;
    height: 1.3rem;
    flex-shrink: 0;
    accent-color: var(--accent);
}
.auth-form label.checkbox em { color: var(--fg); font-style: italic; }
.auth-form .optional,
.auth-form .hint {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: normal;
}
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"],
.auth-form input[type="date"] {
    background: var(--bg-input);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem 0.85rem;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-form input:focus {
    outline: none;
    border-color: var(--border-gold);
    box-shadow: 0 0 0 3px rgba(201, 162, 74, 0.08);
}
.auth-error {
    background: rgba(224, 112, 112, 0.15);
    border: 1px solid var(--danger);
    color: #ffdada;
    padding: 0.65rem 0.9rem;
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.btn-block {
    width: 100%;
    text-align: center;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    display: block;
}
.auth-alt {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}
.auth-alt a { color: var(--accent-bright); text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }

/* ---------- Pricing / abonnement ---------- */
.pricing {
    max-width: 460px;
    margin: 2.5rem auto;
    padding: 0 1rem 2rem;
    text-align: center;
}
.pricing h1 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--accent-bright);
    margin: 0 0 0.5rem;
    font-size: 2rem;
}
.pricing-sub {
    color: var(--muted);
    margin: 0 0 1.75rem;
    line-height: 1.55;
    font-style: italic;
}
.pricing-card {
    background: linear-gradient(180deg, rgba(42, 28, 74, 0.65) 0%, rgba(32, 21, 64, 0.65) 100%);
    border: 1px solid var(--border-gold);
    border-radius: 20px;
    padding: 1.75rem 1.5rem;
    box-shadow: var(--shadow-card), 0 0 40px rgba(201, 162, 74, 0.08);
    text-align: left;
}
.pricing-head {
    text-align: center;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
}
.pricing-plan {
    display: block;
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.5rem;
}
.pricing-amount {
    font-family: var(--font-display);
    font-size: 2.6rem;
    font-weight: 600;
    color: var(--accent-bright);
}
.pricing-period { color: var(--muted); font-size: 1rem; }
.pricing-features {
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}
.pricing-features li {
    display: flex;
    gap: 0.6rem;
    align-items: baseline;
    line-height: 1.45;
}
.pricing-features li span { color: var(--accent); font-size: 0.8rem; }
.pricing-note {
    margin: 0.9rem 0 0;
    font-size: 0.82rem;
    color: var(--muted);
    text-align: center;
    line-height: 1.5;
}
.pricing-already {
    text-align: center;
    color: var(--accent-bright);
    font-style: italic;
    margin: 0 0 1rem;
}
.pricing-free-hint {
    margin-top: 1.5rem;
    font-size: 0.88rem;
    color: var(--muted);
}

/* ---------- Topnav auth extras ---------- */
.topnav-greet {
    color: var(--muted);
    font-size: 0.9rem;
    font-style: italic;
}
.logout-form { display: inline; margin: 0; }
.link-btn {
    background: transparent;
    color: var(--fg);
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
}
.link-btn:hover { color: var(--accent-bright); }

/* ---------- Compteurs sous l'écritoire : gravés, discrets ---------- */
.counter {
    color: var(--muted);
    font-family: var(--font-grave);
    font-size: 0.66rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.counter #remaining { color: var(--accent-bright); font-weight: 600; }
.input-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 0.45rem;
    padding: 0 0.5rem;
    flex-wrap: wrap;
}
.char-counter {
    color: var(--muted);
    font-family: var(--font-grave);
    font-size: 0.66rem;
    letter-spacing: 0.12em;
    font-variant-numeric: tabular-nums;
}
.char-counter.warn { color: var(--accent); }
.char-counter.full { color: var(--danger); font-weight: bold; }

/* ---------- Disclaimer ---------- */
.disclaimer {
    text-align: center;
    padding: 0.6rem;
    font-size: 0.75rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
    letter-spacing: 0.04em;
}
.disclaimer-orn { color: var(--accent); margin-right: 0.4rem; opacity: 0.7; }

/* ---------- Modal ---------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 5, 22, 0.8);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 100;
}
.modal[hidden] { display: none; }
.modal-body {
    position: relative;
    background: linear-gradient(180deg, var(--bg-alt) 0%, #1a0f2e 100%);
    border: 1px solid var(--border-gold);
    border-radius: 18px;
    padding: 2rem 1.75rem 1.5rem;
    max-width: 440px;
    text-align: center;
    animation: voile-pose 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--fg);
    font-size: 1.3rem;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { background: var(--accent-soft); }
.modal-body h2 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--accent-bright);
    margin: 0.25rem 0 0.75rem;
    letter-spacing: 0.03em;
}
.modal-body p { color: var(--fg); line-height: 1.55; margin: 0; }
.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    justify-content: center;
    margin-top: 1.4rem;
}
.modal-note {
    margin-top: 1.1rem !important;
    font-size: 0.82rem;
    color: var(--muted) !important;
    font-style: italic;
}

/* ---------- Boutons ---------- */
.btn {
    padding: 0.7rem 1.2rem;
    border-radius: 24px;
    text-decoration: none;
    border: 1px solid var(--border-gold);
    color: var(--fg);
    font-family: inherit;
    font-size: 0.95rem;
    letter-spacing: 0.03em;
    transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
    display: inline-block;
}
.btn:hover { background: var(--accent-soft); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent-bright) 0%, var(--accent) 100%);
    color: var(--bg);
    font-weight: bold;
    border-color: transparent;
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-bright) 0%, var(--accent) 100%);
    box-shadow: 0 4px 18px var(--accent-glow);
    transform: translateY(-1px);
}

/* ---------- Administration ---------- */
.admin {
    max-width: 960px;
    margin: 1.75rem auto;
    padding: 0 1rem 2rem;
    width: 100%;
}
.admin-head { text-align: center; margin-bottom: 1.5rem; }
.admin-head h1 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--accent-bright);
    margin: 0 0 0.35rem;
}
.admin-sub { color: var(--muted); margin: 0; font-style: italic; }
.flash {
    background: var(--accent-soft);
    border: 1px solid var(--border-gold);
    color: var(--accent-bright);
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    font-size: 0.92rem;
    margin-bottom: 1rem;
    animation: fade-in 0.3s ease-out;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.stat {
    background: rgba(42, 28, 74, 0.5);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.9rem 0.75rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.stat-num {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 600;
    color: var(--accent-bright);
}
.stat-label { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.04em; }
.admin-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(32, 21, 64, 0.45);
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    min-width: 720px;
}
.admin-table th {
    text-align: left;
    padding: 0.7rem 0.85rem;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-gold);
}
.admin-table td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: rgba(201, 162, 74, 0.05); }
.cell-sub { display: block; color: var(--muted); font-size: 0.82rem; }
.cell-actions form {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.tag {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 12px;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    color: var(--muted);
    letter-spacing: 0.03em;
}
.tag-gold {
    border-color: var(--border-gold);
    background: var(--accent-soft);
    color: var(--accent-bright);
}
.tag-admin { border-color: #7a5cc0; color: #b9a3ea; }
.btn-xs {
    padding: 0.3rem 0.6rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--fg);
    font-family: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.btn-xs:hover { background: var(--accent-soft); border-color: var(--border-gold); }
.btn-xs-gold {
    border-color: var(--border-gold);
    color: var(--accent-bright);
}
.admin-note {
    margin-top: 1.25rem;
    font-size: 0.82rem;
    color: var(--muted);
    text-align: center;
}
.admin-back { margin: 0 0 0.75rem; }
.admin-back a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.admin-back a:hover { color: var(--accent-bright); }
.client-link { text-decoration: none; color: inherit; display: block; }
.client-link:hover strong { color: var(--accent-bright); text-decoration: underline; }
.btn-xs-danger { border-color: rgba(224, 112, 112, 0.5); color: #f0a3a3; }
.btn-xs-danger:hover { background: rgba(224, 112, 112, 0.12); border-color: var(--danger); }
.admin-actions-bar {
    margin-bottom: 1.5rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(32, 21, 64, 0.45);
}
.admin-actions-bar form { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.admin-section-title {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--accent-bright);
    letter-spacing: 0.04em;
    font-size: 1.2rem;
    margin: 1.5rem 0 0.75rem;
}
.cell-sub-inline { color: var(--muted); font-size: 0.8rem; font-weight: normal; }
.memory-block {
    background: var(--accent-soft);
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    font-size: 0.92rem;
    line-height: 1.55;
    margin-bottom: 0.75rem;
}
.memory-block .cell-sub { margin-bottom: 0.35rem; }
.convo-log {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(32, 21, 64, 0.45);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-height: 60vh;
    overflow-y: auto;
}
.convo-line { padding: 0.5rem 0.7rem; border-radius: 10px; }
.convo-user { background: rgba(201, 162, 74, 0.08); border-left: 2px solid var(--border-gold); }
.convo-assistant { background: rgba(244, 236, 216, 0.04); border-left: 2px solid var(--border); }
.convo-meta { display: flex; gap: 0.6rem; align-items: baseline; margin-bottom: 0.2rem; }
.convo-role { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-bright); }
.convo-assistant .convo-role { color: var(--muted); }
.convo-date { font-size: 0.75rem; color: var(--muted); }
.convo-text { font-size: 0.94rem; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.admin-note code {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.1rem 0.4rem;
    font-size: 0.8rem;
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
    .topbar { padding: 0.5rem 0.75rem; }
    .brand-text { font-size: 1.3rem; }
    .topnav { gap: 0.5rem; }
    .topnav a { font-size: 0.85rem; }
    .btn-mini { padding: 0.3rem 0.6rem; }
    .badge-cercle { display: none; }
    .chat { padding: 0.5rem; }
    .persona-name { font-size: 1rem; letter-spacing: 0.24em; text-indent: 0.24em; }
    .persona-title { font-size: 0.8rem; }
    .msg-user { max-width: 88%; font-size: 1.06rem; }
    .msg-assistant { padding: 0 0.1rem; }
    .chat-form textarea { font-size: 16px; } /* évite le zoom iOS */
    .card { width: 100px; }
    .card-inner { height: 160px; }
    .card-name { font-size: 0.8rem; }
    .card-meaning { font-size: 0.65rem; }

    .tirage-scene { --carte-w: 58px; --carte-h: 94px; padding: 0.75rem 0.6rem 1rem; }
    .tirage-tete { padding: 2.9rem 0.75rem 0.2rem; }
    .autel { padding-bottom: 1.9rem; }
    .son-toggle .son-etat { display: none; }
    .tirage-table { min-height: 190px; }
    .pricing { margin-top: 1.5rem; }
    .auth-form { margin-top: 1.25rem; }
}

/* ==========================================================
   Le Seuil — scène d'arrivée
   Toutes les animations n'utilisent que transform / opacity
   (composées GPU). Aucun asset image : gradients + typo.
   ========================================================== */
.seuil {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background:
        radial-gradient(ellipse 80% 60% at 50% -15%, rgba(88, 60, 140, 0.35) 0%, transparent 60%),
        radial-gradient(ellipse 90% 50% at 50% 115%, rgba(179, 58, 43, 0.22) 0%, transparent 62%),
        linear-gradient(180deg, #1a0f2e 0%, #120a1e 55%, #0c0616 100%);
}
.seuil.franchi {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease 0.8s;
}
.seuil.seuil-fondu {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

/* Calques de parallax : marge négative pour que les translations
   ne découvrent jamais un bord. */
.seuil-couche {
    position: absolute;
    inset: -6%;
    pointer-events: none;
    will-change: transform;
}

.seuil-etoiles {
    background-image:
        radial-gradient(1px 1px at 12% 22%, rgba(237,228,211,0.55) 50%, transparent 51%),
        radial-gradient(1px 1px at 78% 12%, rgba(237,228,211,0.4) 50%, transparent 51%),
        radial-gradient(1.5px 1.5px at 55% 35%, rgba(240,185,74,0.45) 50%, transparent 51%),
        radial-gradient(1px 1px at 30% 68%, rgba(237,228,211,0.3) 50%, transparent 51%),
        radial-gradient(1px 1px at 88% 55%, rgba(237,228,211,0.35) 50%, transparent 51%),
        radial-gradient(1.5px 1.5px at 8% 85%, rgba(240,185,74,0.35) 50%, transparent 51%),
        radial-gradient(1px 1px at 65% 82%, rgba(237,228,211,0.28) 50%, transparent 51%),
        radial-gradient(1px 1px at 42% 8%, rgba(237,228,211,0.35) 50%, transparent 51%);
}

/* Cartes qui flottent dans la pénombre */
.seuil-carte {
    position: absolute;
    width: 88px;
    height: 142px;
    border-radius: 8px;
    border: 1px solid rgba(207, 160, 58, 0.45);
    background: linear-gradient(155deg, #221338 0%, #150c24 100%);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), inset 0 0 0 4px rgba(207, 160, 58, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(240, 185, 74, 0.55);
    font-size: 1.4rem;
    animation: seuil-flotte var(--duree, 9s) ease-in-out var(--retard, 0s) infinite alternate;
}
@keyframes seuil-flotte {
    from { transform: rotate(var(--rot, 0deg)) translateY(0); }
    to   { transform: rotate(var(--rot, 0deg)) translateY(-16px); }
}
.seuil-cartes-loin .seuil-carte { width: 60px; height: 97px; font-size: 1rem; opacity: 0.45; }
.seuil-cartes-loin .carte-1 { --rot: -14deg; --duree: 11s; top: 16%; left: 12%; }
.seuil-cartes-loin .carte-2 { --rot: 9deg;  --duree: 13s; --retard: -4s; top: 12%; right: 16%; }
.seuil-cartes-loin .carte-3 { --rot: -6deg; --duree: 12s; --retard: -7s; bottom: 20%; left: 20%; }
.seuil-cartes-pres .carte-4 { --rot: 11deg; --duree: 9s;  --retard: -2s; bottom: 16%; right: 12%; opacity: 0.8; }
.seuil-cartes-pres .carte-5 { --rot: -9deg; --duree: 10s; --retard: -5s; top: 30%; left: 6%; opacity: 0.8; }

/* Brume : deux nappes qui dérivent lentement */
.seuil-brume {
    position: absolute;
    left: -35%;
    right: -35%;
    pointer-events: none;
    will-change: transform;
    animation: seuil-derive var(--duree, 18s) ease-in-out infinite alternate;
}
.seuil-brume-1 {
    bottom: -12%;
    height: 48%;
    background: radial-gradient(ellipse 55% 90% at 50% 100%, rgba(150, 120, 200, 0.16) 0%, transparent 68%);
}
.seuil-brume-2 {
    --duree: 26s;
    top: -14%;
    height: 40%;
    background: radial-gradient(ellipse 60% 90% at 50% 0%, rgba(88, 60, 140, 0.20) 0%, transparent 70%);
    animation-direction: alternate-reverse;
}
@keyframes seuil-derive {
    from { transform: translateX(-4%); }
    to   { transform: translateX(4%); }
}

/* Halo : suit doucement le curseur (JS), explose au franchissement */
.seuil-halo {
    position: absolute;
    left: 50%;
    top: 44%;
    width: 52vmax;
    height: 52vmax;
    margin: -26vmax 0 0 -26vmax;
    border-radius: 50%;
    pointer-events: none;
    will-change: transform, opacity;
    background: radial-gradient(circle,
        rgba(240, 185, 74, 0.12) 0%,
        rgba(88, 60, 140, 0.08) 42%,
        transparent 68%);
}

/* Contenu éditorial */
.seuil-contenu {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    max-width: 640px;
}
.seuil-eyebrow {
    margin: 0;
    font-family: var(--font-grave);
    font-size: 0.78rem;
    letter-spacing: 0.45em;
    text-transform: uppercase;
    color: var(--accent);
    animation: seuil-apparait 1s ease 0.25s both;
}
.seuil-titre {
    margin: 0;
    font-family: var(--font-grave);
    font-weight: 500;
    font-size: clamp(3.2rem, 13vw, 5.6rem);
    letter-spacing: 0.16em;
    text-indent: 0.16em; /* compense le letter-spacing pour un vrai centrage */
    line-height: 1.05;
    color: #f2e8d5;
    text-shadow: 0 0 34px rgba(240, 185, 74, 0.28);
    animation: seuil-apparait 1.2s cubic-bezier(0.22, 0.61, 0.36, 1) 0.55s both;
}
.seuil-ligne {
    margin: 0;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.2rem;
    line-height: 1.6;
    color: var(--muted);
    max-width: 36ch;
    text-wrap: balance;
    animation: seuil-apparait 1s ease 1s both;
}
.seuil-cta {
    margin-top: 0.6rem;
    padding: 1rem 2.4rem;
    font-family: var(--font-grave);
    font-size: 0.85rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--accent-bright);
    background: transparent;
    border: 1px solid var(--border-gold);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.3s ease, background-color 0.3s ease, transform 0.2s ease;
    animation: seuil-apparait 1s ease 1.35s both;
}
.seuil-cta::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 30%, rgba(240, 185, 74, 0.22) 50%, transparent 70%);
    transform: translateX(-130%);
    transition: transform 0.7s ease;
}
.seuil-cta:hover,
.seuil-cta:focus-visible {
    background-color: var(--accent-soft);
    box-shadow: 0 0 30px rgba(240, 185, 74, 0.25);
    transform: translateY(-1px);
}
.seuil-cta:hover::after,
.seuil-cta:focus-visible::after { transform: translateX(130%); }
.seuil-cta:focus-visible { outline: 1px solid var(--accent-bright); outline-offset: 3px; }
.seuil-note {
    margin: 0.4rem 0 0;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    color: var(--muted);
    opacity: 0.8;
    animation: seuil-apparait 1s ease 1.6s both;
}
@keyframes seuil-apparait {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Chorégraphie du franchissement : la lumière s'ouvre,
   les cartes montent comme des étincelles, la brume se dissipe. */
.seuil.franchi .seuil-halo {
    transform: scale(3.4) !important;
    opacity: 0;
    /* La lumière grandit d'abord pleine, puis s'éteint tard :
       le franchissement est une révélation, pas une extinction. */
    transition: transform 1.3s ease-in, opacity 0.7s ease-in 0.6s;
}
.seuil.franchi .seuil-carte {
    animation: none;
    transform: rotate(var(--rot, 0deg)) translateY(-75vh);
    opacity: 0;
    transition: transform 1.15s ease-in, opacity 0.95s ease-in;
}
.seuil.franchi .seuil-brume { opacity: 0; transition: opacity 0.9s ease; }
.seuil.franchi .seuil-contenu {
    opacity: 0;
    transform: translateY(-28px);
    transition: opacity 0.55s ease, transform 0.55s ease;
}

/* Le cabinet se révèle derrière le seuil */
body.cabinet-revele main {
    animation: cabinet-rise 1.1s cubic-bezier(0.22, 0.61, 0.36, 1) 0.7s both;
}
@keyframes cabinet-rise {
    from { opacity: 0; transform: translateY(18px) scale(0.995); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 600px) {
    .seuil-cartes-loin { display: none; }
    .seuil-carte { width: 72px; height: 116px; }
    .seuil-contenu { max-width: 100vw; padding: 1.25rem; }
    .seuil-titre { font-size: clamp(2.4rem, 10vw, 3.4rem); letter-spacing: 0.12em; text-indent: 0.12em; }
    .seuil-eyebrow { font-size: 0.68rem; letter-spacing: 0.34em; }
    .seuil-ligne { font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
    .seuil-carte,
    .seuil-brume,
    .seuil-eyebrow,
    .seuil-titre,
    .seuil-ligne,
    .seuil-cta,
    .seuil-note { animation: none; }
    .seuil.franchi { transition: opacity 0.35s ease; }
    .seuil.franchi .seuil-halo,
    .seuil.franchi .seuil-carte,
    .seuil.franchi .seuil-contenu { transition: none; transform: none; }
    body.cabinet-revele main { animation: none; }
}

/* Mouvement réduit : le rituel reste lisible, sans chorégraphie */
@media (prefers-reduced-motion: reduce) {
    .arcane, .arcane-dos { transition: none; }
    .tirage-overlay, .tirage-overlay::before { animation: none; }
    .card.reveal .card-inner { animation: none; transform: rotateY(180deg); }
    .card.reveal::after,
    .card.balayage .card-back::after { animation: none; opacity: 0; }
    .cta-grave.pret { animation: none; }
    .msg-assistant .seg { transition: none; }
    .typing-sigil { animation: none; }
}

/* ==========================================================
   Étape 4 — Transitions & respirations
   T1/T2 : entrer dans le Rituel est un mouvement de caméra.
   Transform/opacity uniquement (GPU) ; un seul plan 3D animé
   (.tirage-scene) + un plan 2D (main), jamais d'ombre ou de
   blur animés. Cette section vit après le bloc du Seuil pour
   que body.rituel-ouvert main gagne sur body.cabinet-revele.
   ========================================================== */

/* Le voile : simple fondu, réutilisé par les modales (T4) */
@keyframes rituel-voile {
    from { opacity: 0; }
}
/* Le fond du rituel se pose avec une courte dérive de profondeur */
@keyframes rituel-fond {
    from { opacity: 0; transform: translateZ(-60px); }
    to   { opacity: 1; transform: translateZ(0); }
}
/* L'approche : la table existe déjà, la caméra s'avance vers elle.
   Correctif (cause racine trouvée le 2026-07-10) : l'opacité atteint 1
   à 38 % du trajet pendant que le transform continue jusqu'au bout —
   sinon tout le voyage en profondeur se joue à découvert de personne,
   caché par le fondu, et l'effet 3D est invisible quelle que soit la
   distance parcourue. */
@keyframes rituel-approche {
    0%   { opacity: 0; transform: translateZ(-450px) rotateX(5deg); }
    38%  { opacity: 1; }
    100% { opacity: 1; transform: translateZ(0) rotateX(0deg); }
}

/* T2 — confirmer son tirage : la table nous relâche, la caméra
   recule ; distinct de l'annulation (simple fondu .se-ferme). */
.tirage-overlay.se-retire { opacity: 0; transition: opacity 0.6s ease 0.08s; }
.tirage-overlay.se-retire .tirage-scene {
    transform: translateZ(-450px) rotateX(4deg);
    opacity: 0;
    transition: transform 0.65s cubic-bezier(0.45, 0.05, 0.55, 0.95), opacity 0.6s ease;
}

/* T4 — Le voile de la limite : un moment délicat, pas une punition.
   Le fond se pose en fondu, le corps monte doucement ; à la fermeture,
   le voile se retire au lieu de disparaître d'un coup. 2D volontaire :
   la profondeur est réservée au rituel. */
.modal { animation: rituel-voile 0.35s ease-out; }
@keyframes voile-pose {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
}
.modal.se-retire { opacity: 0; transition: opacity 0.25s ease; }
.modal.se-retire .modal-body {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

/* T5 — L'attente d'Astrid entre et sort en douceur (aria-live intact :
   le texte est présent dès que hidden est levé, l'opacité n'est que
   visuelle). L'état visible est piloté par la classe t-visible. */
.typing {
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}
.typing.t-visible { opacity: 1; transform: translateY(0); }

/* T3 — Astrid pose les cartes une à une, à plat sur la table (le
   décalage entre cartes vient de --pose-delai, posé en JS). La zone
   est insérée à sa taille finale : opacité/transform seuls, zéro CLS.
   La perspective vient de .cards-area (déjà en place). */
.card.se-pose {
    animation: carte-se-pose 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) both;
    animation-delay: var(--pose-delai, 0s);
}
@keyframes carte-se-pose {
    from { opacity: 0; transform: rotateX(26deg) translateY(-14px); }
    to   { opacity: 1; transform: rotateX(0deg) translateY(0); }
}

/* Pendant le rituel, le cabinet s'éloigne d'un pas derrière le voile.
   animation:none coupe cabinet-rise (fill both) qui sinon verrouillerait
   le transform de main juste après le franchissement du seuil. */
main { transition: transform 0.8s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.8s ease; }
body.rituel-ouvert main {
    animation: none;
    transform: scale(0.965);
    opacity: 0.35;
}

@media (prefers-reduced-motion: reduce) {
    .tirage-scene, .tirage-overlay::before { animation: none; }
    .tirage-overlay.se-retire { transition: opacity 0.25s ease; }
    .tirage-overlay.se-retire .tirage-scene { transition: none; transform: none; }
    main { transition: none; }
    body.rituel-ouvert main { transform: none; opacity: 1; }
    .card.se-pose { animation: none; }
    .modal, .modal-body { animation: none; }
    .modal.se-retire { transition: none; }
    .modal.se-retire .modal-body { transition: none; transform: none; }
    .typing { transition: none; transform: none; }
    .msg { animation: none; }
    .msg-user::after { animation: none; }
    .autel-slot { animation: none; }
    .auth-form, .pricing { animation: none; }
}
