/* ═══════════════════════════════════════════════════════════
   SINGULARITÉ — LE COFFRE · couche cinématique
   Se pose sur le design system du site (style.css) : mêmes
   tokens de surface/bordure, palette restreinte de la quête.

   Règle d'or : l'ambre est une récompense. Elle n'apparaît que
   là où le joueur a progressé. Le reste est froid.
   ═══════════════════════════════════════════════════════════ */

:root {
    --q-void:      #050507;
    --q-void-2:    #0a0a0f;
    --q-amber:     #F5A623;
    --q-amber-hi:  #FFC766;
    --q-amber-dim: rgba(245, 166, 35, 0.14);
    --q-spectral:  #E8E8EE;
    --q-cyan:      #7DE3C3;      /* acte 0 uniquement */
    --q-red:       #FF3B30;      /* l'ouverture uniquement */
    --q-dim:       #6f7480;

    --q-track:     0.08em;       /* tracking +8 % des titres */
    --q-ease-out:  cubic-bezier(0.16, 1, 0.3, 1);        /* expo-out */
    --q-ease-in:   cubic-bezier(0.64, 0, 0.78, 0);       /* quint-in */
    --q-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);    /* ressort amorti */
}

/* ── Page de quête : on éteint le décor du site ───────────── */
html.q-page,
html.q-page body { background: var(--q-void); }

html.q-page .bg-blackhole,
html.q-page .bh-nebula,
html.q-page .bh-stars,
html.q-page .bh-particles { display: none !important; }

html.q-page main > .section:first-child { padding-top: 0; }

/* Acte 0 : immersion totale, pas de chrome. */
html.q-page--intrusion .nav,
html.q-page--intrusion .footer,
html.q-page--intrusion .chat-launcher,
html.q-page--intrusion .chat-fab { display: none !important; }
html.q-page--intrusion body { overflow: hidden; }
html.q-page--intrusion main { padding: 0; }

/* ── Calques d'ambiance (grain / scanlines / vignettage) ──── */
.q-fx {
    position: fixed;
    inset: 0;
    z-index: 40;
    pointer-events: none;
}
.q-fx-grain {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.03;               /* grain 3 % */
    mix-blend-mode: screen;
}
.q-fx-scan {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.04) 0 1px,
        transparent 1px 3px
    );
    opacity: 1;
}
.q-fx-vig {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 52%,
        rgba(0, 0, 0, 0.12) 78%,
        rgba(0, 0, 0, 0.42) 100%
    );
}
/* Vignettage renforcé pendant l'horizon rouge. */
.q-fx-vig.is-horizon {
    background: radial-gradient(
        ellipse at center,
        transparent 18%,
        rgba(0, 0, 0, 0.70) 72%,
        #000 100%
    );
    transition: background 1.4s var(--q-ease-out);
}

/* ── Typographie de la quête ──────────────────────────────── */
.q-title {
    font-family: var(--font);
    font-weight: 700;
    font-size: clamp(1.5rem, 6vw, 2.6rem);
    line-height: 1.05;
    letter-spacing: var(--q-track);
    text-transform: uppercase;
    color: var(--q-spectral);
}
.q-eyebrow {
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--q-dim);
}
.q-mono { font-family: var(--mono); }

/* Les douze mots sont des reliques : mono ×1.5, entourés de vide. */
.q-relic {
    font-family: var(--mono);
    font-size: 1.5em;
    letter-spacing: 0.06em;
    color: var(--q-amber-hi);
    display: block;
    margin: 1.25rem 0;
    line-height: 1.9;
    word-spacing: 0.3em;
}

/* ── Bouton de quête (ambre = progression) ────────────────── */
.q-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-height: 48px;
    padding: 0.875rem 1.75rem;
    font-family: var(--mono);
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--q-amber-hi);
    background: transparent;
    border: 1px solid rgba(245, 166, 35, 0.34);
    border-radius: var(--r-md);
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.5s var(--q-ease-out),
                background 0.5s var(--q-ease-out),
                color 0.5s var(--q-ease-out);
}
.q-btn:hover,
.q-btn:focus-visible {
    border-color: rgba(245, 166, 35, 0.7);
    background: var(--q-amber-dim);
    color: #fff;
}
.q-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.q-btn--solid {
    background: linear-gradient(180deg, var(--q-amber-hi), var(--q-amber));
    color: #0a0602;
    border-color: transparent;
}
.q-btn--solid:hover { color: #0a0602; background: var(--q-amber-hi); }
.q-btn--quiet {
    color: var(--q-dim);
    border-color: var(--border);
}
.q-btn--quiet:hover { color: var(--q-spectral); border-color: var(--border-strong); }

/* ═══ ACTE 0 — L'INTRUSION ══════════════════════════════════ */
.q-intrusion {
    position: fixed;
    inset: 0;
    z-index: 10;
    background: #000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: hidden;
    /* zone de tap plein écran : l'étape se saute au doigt */
    -webkit-tap-highlight-color: transparent;
}
.q-intrusion__bh {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 1.2s var(--q-ease-out);
}
.q-intrusion__bh.is-on { opacity: 1; }
.q-intrusion__suck {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.q-term {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 46rem;
    padding: clamp(1.25rem, 6vh, 3.5rem) clamp(1.1rem, 5vw, 2.5rem);
    font-family: var(--mono);
    font-size: clamp(0.9375rem, 3.6vw, 1.125rem);
    line-height: 1.7;
    color: var(--q-cyan);
    text-shadow: 0 0 12px rgba(125, 227, 195, 0.18);
    transition: filter 1.1s var(--q-ease-out), opacity 1.1s var(--q-ease-out),
                transform 1.1s var(--q-ease-out);
}
.q-term.is-defocused {
    filter: blur(3px) brightness(0.45);
    opacity: 0.5;
    transform: scale(0.985);
}
.q-term.is-gone { opacity: 0; }
.q-term__line {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 1.7em;
}
.q-term__line--dim { color: rgba(125, 227, 195, 0.45); }
.q-term__line--alert { color: var(--q-amber-hi); }
.q-caret {
    display: inline-block;
    width: 0.62em;
    height: 1.05em;
    margin-left: 0.06em;
    vertical-align: -0.18em;
    background: var(--q-cyan);
    animation: q-blink 1.06s steps(1, end) infinite;
}
@keyframes q-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

.q-term__prompt {
    margin-top: 1.4rem;
    color: var(--q-amber-hi);
    animation: q-pulse 1.8s var(--q-ease-out) infinite;
}
@keyframes q-pulse {
    0%, 100% { opacity: 0.45; }
    50%      { opacity: 1; }
}

/* Glitches : saut d'écran, aberration chromatique, réécriture. */
.q-glitch-shift { animation: q-shift 0.16s steps(2, end) 1; }
@keyframes q-shift {
    0%   { transform: translateY(0); }
    50%  { transform: translateY(-6px); }
    100% { transform: translateY(0); }
}
.q-glitch-chroma { animation: q-chroma 0.08s linear 1; }
@keyframes q-chroma {
    0%   { text-shadow: 0 0 12px rgba(125, 227, 195, 0.18); }
    50%  { text-shadow: -2px 0 rgba(255, 0, 80, 0.75), 2px 0 rgba(0, 220, 255, 0.75); }
    100% { text-shadow: 0 0 12px rgba(125, 227, 195, 0.18); }
}

/* ── La note manuscrite ───────────────────────────────────── */
.q-note {
    position: absolute;
    z-index: 4;
    left: 50%;
    top: 50%;
    width: min(92vw, 34rem);
    transform: translate(-50%, -46%) rotate(-1.1deg) scale(0.94);
    opacity: 0;
    pointer-events: none;
    padding: clamp(1.75rem, 6vw, 2.75rem) clamp(1.5rem, 6vw, 2.5rem) clamp(1.5rem, 5vw, 2.25rem);
    border-radius: 3px;
    color: #1b1a16;
    background:
        linear-gradient(103deg, rgba(0, 0, 0, 0.10) 0%, transparent 6%, transparent 46%,
                        rgba(0, 0, 0, 0.09) 49%, transparent 53%, transparent 94%,
                        rgba(0, 0, 0, 0.10) 100%),
        radial-gradient(ellipse at 22% 12%, rgba(120, 96, 54, 0.16), transparent 58%),
        radial-gradient(ellipse at 82% 88%, rgba(120, 96, 54, 0.20), transparent 62%),
        linear-gradient(178deg, #e6ddc7 0%, #ded3ba 52%, #d6c9ac 100%);
    box-shadow:
        0 32px 70px rgba(0, 0, 0, 0.72),
        0 2px 0 rgba(255, 255, 255, 0.18) inset,
        0 -18px 32px rgba(0, 0, 0, 0.16) inset;
    transition: opacity 1s var(--q-ease-out), transform 1.1s var(--q-ease-out);
}
.q-note.is-in {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) rotate(-1.1deg) scale(1);
}
/* Grain du papier — pur CSS, aucune image. */
.q-note::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0.32;
    background-image:
        radial-gradient(rgba(90, 74, 45, 0.30) 0.5px, transparent 0.6px),
        radial-gradient(rgba(90, 74, 45, 0.20) 0.5px, transparent 0.6px);
    background-size: 3px 3px, 5px 5px;
    background-position: 0 0, 2px 1px;
    mix-blend-mode: multiply;
}
/* Le pli central. */
.q-note::after {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 48%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.14) 12%,
                rgba(255, 255, 255, 0.35) 50%, rgba(0, 0, 0, 0.14) 88%, transparent);
    pointer-events: none;
}
.q-note__ink {
    position: relative;
    z-index: 1;
    font-family: var(--mono);
    font-size: clamp(0.9375rem, 3.4vw, 1.0625rem);
    line-height: 1.85;
    color: #221f18;
    letter-spacing: 0.01em;
}
.q-note__ink em { font-style: italic; }
.q-note__sig {
    position: relative;
    z-index: 1;
    margin-top: 1.4rem;
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(34, 31, 24, 0.5);
}
.q-note__cta {
    position: relative;
    z-index: 1;
    margin-top: 1.75rem;
    display: flex;
    justify-content: center;
}
/* Sur le papier, l'ambre doit rester lisible : on l'assombrit. */
.q-note__cta .q-btn {
    color: #6b4306;
    border-color: rgba(107, 67, 6, 0.4);
    background: rgba(245, 166, 35, 0.12);
}
.q-note__cta .q-btn:hover,
.q-note__cta .q-btn:focus-visible {
    color: #2a1a02;
    border-color: rgba(107, 67, 6, 0.85);
    background: rgba(245, 166, 35, 0.3);
}

/* Le HUD qui se déploie à la toute fin de l'acte 0. */
.q-deploy {
    position: absolute;
    z-index: 5;
    left: 50%;
    bottom: clamp(2rem, 12vh, 6rem);
    transform: translateX(-50%) translateY(14px);
    width: min(92vw, 30rem);
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.9s var(--q-ease-out), transform 0.9s var(--q-spring);
}
.q-deploy.is-in { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

/* Affordance de scroll : petite flèche ↓ en bas quand le contenu dépasse. */
.q-scroll-hint {
    position: fixed;
    left: 50%;
    bottom: clamp(0.75rem, 4vw, 1.5rem);
    transform: translateX(-50%);
    z-index: 40;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid rgba(247, 147, 26, 0.5);
    border-radius: 50%;
    color: #f7931a;
    font-size: 1.1rem;
    line-height: 2rem;
    text-align: center;
    background: rgba(8, 9, 10, 0.75);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.5s ease;
    animation: q-hint-bob 1.6s ease-in-out infinite;
}
.q-scroll-hint.is-done { opacity: 0; }
@keyframes q-hint-bob {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50%      { transform: translateX(-50%) translateY(4px); }
}
@media (prefers-reduced-motion: reduce) {
    .q-scroll-hint { animation: none; }
}

/* Mobile : contenu tassé en haut, actions plus proches. */
@media (max-width: 640px) {
    .q-hud, .q-mine { justify-content: flex-start; }
    .q-hud { padding-top: 1rem; }
    .q-mine { padding-top: 1rem; }
    .q-slot { padding: 0.7rem 0.9rem; }
    .q-claim { margin-top: 1.5rem; }
}

.q-skip {
    position: absolute;
    z-index: 6;
    right: clamp(0.75rem, 4vw, 1.5rem);
    bottom: clamp(0.75rem, 4vw, 1.5rem);
    min-height: 48px;
    padding: 0 1rem;
    display: inline-flex;
    align-items: center;
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--q-dim);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.6s var(--q-ease-out), color 0.3s;
}
.q-skip.is-in { opacity: 1; }
.q-skip:hover { color: var(--q-spectral); }

/* ── Interrupteur son (toutes les pages de quête) ─────────── */
.q-audio {
    position: fixed;
    z-index: 45;
    left: clamp(0.75rem, 4vw, 1.5rem);
    bottom: clamp(0.75rem, 4vw, 1.5rem);
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 0.875rem;
    color: var(--q-dim);
    background: rgba(5, 5, 7, 0.72);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: color 0.3s, border-color 0.3s;
}
.q-audio:hover { color: var(--q-spectral); border-color: var(--border-strong); }
.q-audio[aria-pressed="true"] { color: var(--q-amber-hi); border-color: rgba(245, 166, 35, 0.34); }

/* ═══ ACTE 1-3 — LE HUD DE L'OPÉRATEUR ══════════════════════ */
.q-hud {
    position: relative;
    min-height: calc(100vh - var(--nav-h));
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(1.5rem, 5vh, 3rem) 0 clamp(3rem, 10vh, 5rem);
}
.q-hud__bh {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}
.q-hud__inner {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 42rem;
    margin: 0 auto;
    padding: 0 clamp(1.1rem, 5vw, 2rem);
}

/* Coins de viseur — le cadre de l'opérateur. */
.q-frame {
    position: fixed;
    inset: clamp(0.75rem, 3vw, 1.75rem);
    z-index: 1;
    pointer-events: none;
}
.q-frame span {
    position: absolute;
    width: 22px;
    height: 22px;
    border: 1px solid rgba(232, 232, 238, 0.16);
}
.q-frame span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.q-frame span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.q-frame span:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.q-frame span:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }

/* Ligne de statut : timer + coordonnées du bloc. Deux éléments, pas plus. */
.q-status {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--q-dim);
    margin-bottom: clamp(1.5rem, 5vh, 2.5rem);
}
.q-status__t { color: var(--q-spectral); font-variant-numeric: tabular-nums; }

/* Les trois fentes du coffre. */
.q-slots {
    display: grid;
    gap: 0.625rem;
    margin: clamp(1.5rem, 5vh, 2.25rem) 0;
}
.q-slot {
    position: relative;
    display: block;
    width: 100%;
    text-align: left;
    padding: 1rem 1.125rem;
    min-height: 48px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--q-dim);
    overflow: hidden;
    transition: border-color 0.9s var(--q-ease-out), background 0.9s var(--q-ease-out),
                color 0.9s var(--q-ease-out);
}
.q-slot__head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}
.q-slot__glyph { font-size: 0.8125rem; line-height: 1; }
.q-slot__body {
    margin-top: 0.5rem;
    font-family: var(--mono);
    font-size: 0.8125rem;
    color: var(--q-dim);
    letter-spacing: 0.02em;
}
/* Fente gravée : l'ambre + le glyphe plein + le liseré. Jamais la couleur seule. */
.q-slot.is-filled {
    background: linear-gradient(180deg, rgba(245, 166, 35, 0.07), rgba(245, 166, 35, 0.02));
    border-color: rgba(245, 166, 35, 0.34);
    color: var(--q-amber-hi);
}
.q-slot.is-filled .q-slot__body { color: var(--q-amber-hi); }
.q-slot.is-filled::after {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, var(--q-amber-hi), var(--q-amber));
}
.q-slot.just-filled { animation: q-engrave 1.4s var(--q-ease-out) 1; }
@keyframes q-engrave {
    0%   { transform: translateX(0) scale(1); box-shadow: 0 0 0 0 rgba(245, 166, 35, 0); }
    18%  { transform: translateX(0) scale(1.012); box-shadow: 0 0 34px 2px rgba(245, 166, 35, 0.28); }
    100% { transform: translateX(0) scale(1); box-shadow: 0 0 0 0 rgba(245, 166, 35, 0); }
}
.q-slot__words { font-family: var(--mono); font-size: 0.875rem; letter-spacing: 0.05em; }

/* Les pistes (max 3 éléments à l'écran). */
.q-win__phrase {
    margin: 1.25rem auto 0.4rem;
    max-width: 30rem;
    font-family: var(--mono, ui-monospace, monospace);
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--q-dim, rgba(232, 232, 238, 0.55));
    letter-spacing: 0.02em;
}
.q-win__phrase b { color: #f7931a; font-weight: 600; }
.q-win > .q-btn { margin-top: 0.35rem; }

.q-trail {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1.25rem 0 0;
}
.q-trail .q-btn { flex: 1 1 auto; padding: 0.75rem 1rem; font-size: 0.6875rem; }

/* Indices — trois niveaux, zéro LLM. */
.q-hint {
    margin: 1.5rem 0 0;
    padding: 0.9rem 1.125rem;
    border-left: 2px solid rgba(232, 232, 238, 0.14);
    background: var(--surface-1);
    border-radius: 0 var(--r-md) var(--r-md) 0;
    font-family: var(--mono);
    font-size: 0.8125rem;
    line-height: 1.7;
    color: var(--text-3);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.8s var(--q-ease-out), transform 0.8s var(--q-ease-out);
}
.q-hint.is-in { opacity: 1; transform: translateY(0); }
.q-hint__lvl {
    display: block;
    font-size: 0.625rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--q-dim);
    margin-bottom: 0.35rem;
}

/* Le claim. */
.q-claim { margin-top: clamp(2rem, 7vh, 3rem); }
.q-field { margin-bottom: 0.625rem; }
.q-field label {
    display: block;
    font-family: var(--mono);
    font-size: 0.625rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--q-dim);
    margin-bottom: 0.45rem;
}
.q-input {
    width: 100%;
    min-height: 48px;
    padding: 0.875rem 1rem;
    font-family: var(--mono);
    font-size: 0.9375rem;
    line-height: 1.6;
    letter-spacing: 0.03em;
    color: var(--q-spectral);
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    resize: vertical;
    transition: border-color 0.4s var(--q-ease-out), background 0.4s var(--q-ease-out);
}
.q-input::placeholder { color: #4d525c; }
.q-input:focus {
    outline: none;
    border-color: rgba(245, 166, 35, 0.4);
    background: var(--surface-2);
}
.q-input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.q-count {
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.14em;
    color: var(--q-dim);
    margin-top: 0.4rem;
    display: block;
}
.q-count.is-ready { color: var(--q-amber-hi); }

/* Identité de nœud : le challenge exact à signer, affiché sous le champ
   signature — discret, mono, copiable d'un coup d'œil. */
.q-node-challenge {
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.06em;
    color: var(--q-dim);
    margin-top: 0.4rem;
    display: block;
    word-break: break-all;
    user-select: all;
}

.q-error {
    margin-top: 0.875rem;
    min-height: 1.4em;
    font-family: var(--mono);
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--text-2);
}
.q-error:not(:empty)::before {
    content: "✕ ";
    color: var(--err);
}
/* Erreur : secousse + aberration chromatique (le seul endroit hors ouverture). */
.q-shake { animation: q-shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97) 1; }
@keyframes q-shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-7px); }
    40%, 60% { transform: translateX(7px); }
}
.q-aberr { animation: q-aberr 0.22s linear 1; }
@keyframes q-aberr {
    0%, 100% { text-shadow: none; }
    50% { text-shadow: -2px 0 rgba(255, 59, 48, 0.8), 2px 0 rgba(0, 220, 255, 0.7); }
}

/* ── L'OUVERTURE (11 s) ───────────────────────────────────── */
.q-open {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
    background: transparent;
    pointer-events: none;
}
.q-open.is-running { display: block; pointer-events: auto; }
.q-open__scrim {
    position: absolute;
    inset: 0;
    background: #000;
    opacity: 0;
    transition: opacity 2.6s var(--q-ease-out);
}
.q-open__scrim.is-in { opacity: 0.82; }

/* Les douze mots arrachés vers le centre. */
.q-open__words {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.q-open__word {
    position: absolute;
    font-family: var(--mono);
    font-size: clamp(0.875rem, 3.6vw, 1.25rem);
    letter-spacing: 0.08em;
    color: var(--q-amber-hi);
    white-space: nowrap;
    opacity: 0;
    will-change: transform, opacity, filter;
}

/* L'anneau d'horizon — le SEUL rouge du site. */
.q-open__ring {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 42vmin;
    height: 42vmin;
    margin: -21vmin 0 0 -21vmin;
    border-radius: 50%;
    border: 2px solid var(--q-red);
    box-shadow: 0 0 60px rgba(255, 59, 48, 0.5), 0 0 140px rgba(255, 59, 48, 0.25) inset;
    opacity: 0;
    transform: scale(0.7);
}
.q-open__flash {
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    mix-blend-mode: screen;
}
.q-open__bolt {
    position: absolute;
    left: -20%;
    top: 50%;
    width: 140%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--q-amber-hi) 35%,
                #fff 50%, var(--q-amber-hi) 65%, transparent);
    box-shadow: 0 0 24px rgba(245, 166, 35, 0.8);
    transform: rotate(-18deg) scaleX(0);
    transform-origin: 50% 50%;
    opacity: 0;
}

/* ── Écran de victoire (composition carrée, partageable) ──── */
.q-win {
    position: relative;
    z-index: 3;
    max-width: 34rem;
    margin: 0 auto;
    text-align: center;
    padding: clamp(1.5rem, 6vh, 2.5rem) 0;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 1.2s var(--q-ease-out), transform 1.2s var(--q-ease-out);
}
.q-win.is-in { opacity: 1; transform: translateY(0); }
.q-seal {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 1rem;
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--q-amber-hi);
    border: 1px solid rgba(245, 166, 35, 0.4);
    border-radius: var(--r-pill);
    background: var(--q-amber-dim);
}
.q-nodebadge {
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--q-amber-hi);
    margin-top: 0.5rem;
}
.q-sats {
    font-family: var(--mono);
    font-size: clamp(2.75rem, 13vw, 4.5rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--q-amber-hi);
    font-variant-numeric: tabular-nums;
    margin: 1.5rem 0 0.4rem;
    text-shadow: 0 0 48px rgba(245, 166, 35, 0.35);
}
.q-sats__unit {
    font-size: 0.9375rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--q-dim);
    display: block;
    margin-bottom: 1.75rem;
}
.q-win__meta {
    display: flex;
    justify-content: center;
    gap: clamp(1rem, 5vw, 2.5rem);
    flex-wrap: wrap;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--q-dim);
    margin-bottom: 2rem;
}
.q-win__meta b {
    display: block;
    color: var(--q-spectral);
    font-weight: 500;
    font-size: 0.9375rem;
    margin-top: 0.2rem;
    font-variant-numeric: tabular-nums;
}

.q-qr {
    display: inline-block;
    padding: 0.875rem;
    background: #E8E8EE;
    border-radius: var(--r-md);
    line-height: 0;
}
.q-qr canvas { width: min(64vw, 232px); height: auto; image-rendering: pixelated; }
.q-qr__cap {
    display: block;
    margin-top: 0.75rem;
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--q-dim);
    line-height: 1.6;
}

.q-code {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 26rem;
    margin: 1.25rem auto 0;
    padding: 0.75rem 0.75rem 0.75rem 1rem;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}
.q-code code {
    flex: 1;
    font-family: var(--mono);
    font-size: 0.9375rem;
    letter-spacing: 0.08em;
    color: var(--q-amber-hi);
    overflow-wrap: anywhere;
    text-align: left;
}
.q-copy {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 0.875rem;
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--q-dim);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: color 0.3s, border-color 0.3s;
}
.q-copy:hover { color: var(--q-spectral); border-color: var(--border-strong); }

.q-share-preview {
    max-width: min(88vw, 22rem);
    margin: 1.5rem auto 0;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    display: block;
}

/* ═══ FRAGMENT II — LE JOURNAL ══════════════════════════════ */
.q-journal {
    position: relative;
    padding: clamp(2rem, 8vh, 5rem) 0 clamp(3rem, 10vh, 6rem);
}
.q-doc {
    position: relative;
    max-width: 40rem;
    margin: 0 auto;
    padding: clamp(2rem, 8vw, 3.75rem) clamp(1.5rem, 7vw, 3.25rem);
    color: #211e17;
    border-radius: 2px;
    background:
        linear-gradient(96deg, rgba(0, 0, 0, 0.09) 0%, transparent 5%, transparent 44%,
                        rgba(0, 0, 0, 0.07) 47%, transparent 51%, transparent 95%,
                        rgba(0, 0, 0, 0.09) 100%),
        radial-gradient(ellipse at 12% 6%, rgba(122, 98, 55, 0.20), transparent 50%),
        radial-gradient(ellipse at 88% 94%, rgba(122, 98, 55, 0.24), transparent 55%),
        linear-gradient(176deg, #e9e0cb 0%, #ded3b9 55%, #d2c4a4 100%);
    box-shadow:
        0 40px 90px rgba(0, 0, 0, 0.66),
        0 1px 0 rgba(255, 255, 255, 0.2) inset;
    transform: rotate(-0.35deg);
}
.q-doc::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.34;
    mix-blend-mode: multiply;
    pointer-events: none;
    background-image:
        radial-gradient(rgba(85, 70, 42, 0.32) 0.5px, transparent 0.6px),
        radial-gradient(rgba(85, 70, 42, 0.22) 0.5px, transparent 0.6px);
    background-size: 3px 3px, 6px 6px;
    background-position: 0 0, 2px 3px;
}
/* Les plis horizontaux du document. */
.q-doc::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, transparent 31%, rgba(0, 0, 0, 0.10) 32%,
                        rgba(255, 255, 255, 0.30) 33%, transparent 34%),
        linear-gradient(180deg, transparent 67%, rgba(0, 0, 0, 0.08) 68%,
                        rgba(255, 255, 255, 0.24) 69%, transparent 70%);
}
.q-doc > * { position: relative; z-index: 1; }
.q-doc__head {
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: rgba(33, 30, 23, 0.5);
    border-bottom: 1px solid rgba(33, 30, 23, 0.18);
    padding-bottom: 0.75rem;
    margin-bottom: 1.75rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.q-doc__title {
    font-family: var(--font);
    font-weight: 700;
    font-size: clamp(1.25rem, 5vw, 1.75rem);
    letter-spacing: var(--q-track);
    text-transform: uppercase;
    color: #191710;
    margin-bottom: 1.25rem;
}
.q-doc__body {
    font-family: var(--mono);
    font-size: clamp(0.9375rem, 3.4vw, 1.0625rem);
    line-height: 1.9;
    color: #262218;
}
.q-doc__body em { font-style: italic; }
.q-doc__quote {
    margin: 0 0 1.75rem;
    padding-left: 1rem;
    border-left: 2px solid rgba(33, 30, 23, 0.28);
    font-style: italic;
}
.q-cipher {
    display: grid;
    /* Des mots, plus des lettres : cinq colonnes ne tiennent plus sur un
       téléphone. La grille retombe à deux colonnes toute seule. */
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: 0.4rem;
    margin: 1.75rem 0;
    padding: 1rem;
    border: 1px solid rgba(33, 30, 23, 0.22);
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.14);
}
.q-cipher span {
    font-family: var(--mono);
    font-size: 0.875rem;
    letter-spacing: 0.08em;
    text-align: center;
    color: #221f18;
    padding: 0.35rem 0;
}
.q-doc__note {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(33, 30, 23, 0.18);
    font-size: 0.9375rem;
    line-height: 1.85;
}
.q-doc__sig {
    margin-top: 2rem;
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(33, 30, 23, 0.45);
}
.q-doc__stamp {
    position: absolute;
    right: clamp(1rem, 5vw, 2.5rem);
    bottom: clamp(1rem, 5vw, 2.25rem);
    z-index: 2;
    font-family: var(--mono);
    font-size: 0.625rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(140, 32, 24, 0.62);
    border: 1.5px solid rgba(140, 32, 24, 0.45);
    border-radius: 3px;
    padding: 0.35rem 0.7rem;
    transform: rotate(-7deg);
    opacity: 0;
    transition: opacity 1.4s var(--q-ease-out);
}
.q-doc__stamp.is-in { opacity: 1; }

/* ═══ FRAGMENT III — MINE TON BLOC ══════════════════════════ */
.q-mine {
    position: relative;
    min-height: calc(100vh - var(--nav-h));
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(1.5rem, 5vh, 3rem) 0 clamp(3rem, 10vh, 5rem);
    text-align: center;
}
/* Les canvas décoratifs ne doivent jamais avaler les gestes tactiles. */
.q-mine canvas,
.q-journal canvas,
.q-register canvas,
.q-hud canvas { pointer-events: none; }
.q-mine__inner {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 36rem;
    margin: 0 auto;
    padding: 0 clamp(1.1rem, 5vw, 2rem);
}
.q-block3d {
    position: relative;
    width: 100%;
    height: min(46vh, 300px);
    margin: clamp(1rem, 4vh, 2rem) 0;
}
.q-block3d canvas { width: 100%; height: 100%; display: block; }

.q-gauge {
    position: relative;
    height: 2px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: var(--r-pill);
    overflow: hidden;
    margin: 1.25rem 0 1rem;
}
.q-gauge__fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0%;
    background: linear-gradient(90deg, var(--q-amber), var(--q-amber-hi));
    transition: width 0.6s var(--q-ease-out);
}
.q-readout {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    font-family: var(--mono);
    margin-bottom: 1.5rem;
}
.q-readout div {
    padding: 0.75rem 0.5rem;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}
.q-readout span {
    display: block;
    font-size: 0.5625rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--q-dim);
    margin-bottom: 0.35rem;
}
.q-readout b {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--q-spectral);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.q-hash {
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: var(--q-dim);
    overflow-wrap: anywhere;
    min-height: 2.4em;
    line-height: 1.6;
}
.q-hash b { color: var(--q-amber-hi); font-weight: 500; }

.q-coinbase {
    margin-top: 1.5rem;
    padding: 1.5rem 1.25rem;
    border: 1px solid rgba(245, 166, 35, 0.34);
    border-radius: var(--r-md);
    background: linear-gradient(180deg, rgba(245, 166, 35, 0.08), rgba(245, 166, 35, 0.02));
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 1s var(--q-ease-out), transform 1s var(--q-spring);
}
.q-coinbase.is-in { opacity: 1; transform: translateY(0); }
.q-coinbase__label {
    font-family: var(--mono);
    font-size: 0.625rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--q-dim);
}

/* ═══ LE REGISTRE ═══════════════════════════════════════════ */
.q-registre {
    position: relative;
    padding: clamp(2rem, 8vh, 4.5rem) 0 clamp(3rem, 10vh, 6rem);
}
.q-registre__bh {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.55;
    pointer-events: none;
}
.q-ledger {
    width: 100%;
    max-width: 44rem;
    margin: clamp(1.5rem, 5vh, 2.5rem) auto 0;
    border-collapse: collapse;
    font-family: Georgia, 'Times New Roman', serif;
}
.q-ledger caption {
    caption-side: top;
    font-family: var(--mono);
    font-size: 0.625rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--q-dim);
    text-align: left;
    padding-bottom: 0.875rem;
}
.q-ledger th {
    font-family: var(--mono);
    font-weight: 400;
    font-size: 0.5625rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--q-dim);
    text-align: left;
    padding: 0 0.75rem 0.75rem 0;
    border-bottom: 1px solid rgba(245, 166, 35, 0.22);
}
.q-ledger td {
    padding: 0.9rem 0.75rem 0.9rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-2);
    font-size: 0.9375rem;
    vertical-align: baseline;
}
.q-ledger tr:last-child td { border-bottom: 0; }
.q-ledger__n {
    font-family: var(--mono);
    color: var(--q-dim);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    width: 5.5rem;
}
.q-ledger__name { color: var(--q-spectral); }
.q-ledger__sats {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.q-ledger__when {
    font-family: var(--mono);
    font-size: 0.8125rem;
    color: var(--q-dim);
    white-space: nowrap;
}
.q-ledger tr.is-founder .q-ledger__n,
.q-ledger tr.is-founder .q-ledger__sats { color: var(--q-amber-hi); }
.q-ledger tr.is-founder .q-ledger__name {
    background: linear-gradient(180deg, #FFC766, #F5A623);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.q-badge {
    display: inline-block;
    margin-left: 0.4rem;
    font-family: var(--mono);
    font-size: 0.5625rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--q-amber-hi);
    border: 1px solid rgba(245, 166, 35, 0.34);
    border-radius: var(--r-pill);
    padding: 0.1rem 0.45rem;
    vertical-align: middle;
    white-space: nowrap;
}
.q-empty {
    max-width: 44rem;
    margin: 2.5rem auto 0;
    padding: 2.5rem 1.5rem;
    text-align: center;
    font-family: var(--mono);
    font-size: 0.875rem;
    line-height: 1.8;
    color: var(--q-dim);
    border: 1px dashed var(--border);
    border-radius: var(--r-md);
}

/* Filet doré discret sous les titres du registre. */
.q-rule {
    width: 3rem;
    height: 1px;
    margin: 1rem 0 0;
    background: linear-gradient(90deg, var(--q-amber), transparent);
}

/* Horodatage serveur d'une fente gravée. */
.q-slot__at {
    margin-left: auto;
    font-size: 0.625rem;
    letter-spacing: 0.1em;
    color: var(--q-dim);
}

/* Repli sans WebGL : la singularité reste une présence, pas un trou. */
.q-bh-fallback {
    background:
        radial-gradient(circle at 50% 48%, #000 0 12%,
                        rgba(245, 166, 35, 0.10) 15%,
                        rgba(120, 140, 170, 0.07) 26%,
                        transparent 58%);
}

/* ── Décryptage (jamais de spinner) ───────────────────────── */
.q-decrypt { font-family: var(--mono); color: var(--q-dim); }
.q-decrypt.is-done { color: inherit; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 560px) {
    .q-readout { grid-template-columns: 1fr 1fr; }
    .q-readout div:last-child { grid-column: 1 / -1; }
    .q-ledger td, .q-ledger th { font-size: 0.875rem; }
    .q-ledger__n { width: 4rem; }
    .q-status { font-size: 0.625rem; letter-spacing: 0.12em; }
    .q-trail .q-btn { flex: 1 1 100%; }
}

/* ── prefers-reduced-motion : tout devient fondu sobre ────── */
@media (prefers-reduced-motion: reduce) {
    .q-fx-grain { display: none; }
    .q-caret { animation: none; opacity: 1; }
    .q-term__prompt { animation: none; opacity: 1; }
    .q-glitch-shift, .q-glitch-chroma,
    .q-shake, .q-aberr, .q-slot.just-filled { animation: none !important; }
    .q-note, .q-deploy, .q-hint, .q-win, .q-coinbase,
    .q-slot, .q-open__scrim {
        transition-duration: 0.3s !important;
        transition-timing-function: ease !important;
    }
    .q-note { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
    .q-note.is-in { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
    .q-deploy, .q-deploy.is-in { transform: translateX(-50%); }
    .q-doc { transform: none; }
    .q-open__ring { transition: opacity 0.4s ease; }
}

/* ── Écran des règles (arrivée sur /coffre/) ── */
.q-rules {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 5, 7, 0.92);
  backdrop-filter: blur(6px);
  padding: 1.25rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.q-rules.is-gone { opacity: 0; visibility: hidden; pointer-events: none; }
.q-rules__card {
  max-width: 480px; width: 100%;
  background: #0a0b0e; border: 1px solid rgba(247, 161, 26, 0.25);
  border-radius: 14px; padding: 1.6rem 1.8rem;
  box-shadow: 0 0 60px rgba(247, 161, 26, 0.08), 0 24px 80px rgba(0, 0, 0, 0.6);
}
.q-rules__tag {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.7rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--accent, #f7931a); margin-bottom: 0.5rem;
}
.q-rules__title {
  font-size: clamp(1.3rem, 4.5vw, 1.7rem); letter-spacing: 0.02em;
  color: #e8e8ee; margin: 0 0 1.1rem;
}
.q-rules__list {
  list-style: none; margin: 0 0 1.4rem; padding: 0;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.85rem; line-height: 1.75; color: #9aa3b2;
}
.q-rules__list li { padding-left: 1.1rem; position: relative; }
.q-rules__list li::before {
  content: "›"; position: absolute; left: 0; color: var(--accent, #f7931a);
}
.q-rules__list b { color: #ffc766; font-weight: 600; }
.q-rules__warn { opacity: 0.8; }
.q-rules__warn::before { color: #ff6b5e !important; }
.q-rules__list a { color: #f5a623; text-decoration: underline; text-underline-offset: 2px; }
.q-btn--amber {
  background: linear-gradient(180deg, #f5a623, #d97e06);
  color: #0a0b0e !important; font-weight: 700;
  border: none; border-radius: 10px; padding: 0.75rem 1.6rem;
  font-family: var(--font-mono, ui-monospace, monospace);
  letter-spacing: 0.06em; cursor: pointer; width: 100%;
  transition: transform 0.15s ease, box-shadow 0.3s ease;
}
.q-btn--amber:hover { transform: translateY(-1px); box-shadow: 0 8px 30px rgba(245, 166, 35, 0.35); }
@media (prefers-reduced-motion: reduce) {
  .q-rules { transition: none; }
}
