/* ═══════════════════════════════════════════════════════════════════════════
   MANTORIA — Styles
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=EB+Garamond:ital,opsz,wght@0,6..144,400;0,6..144,500;1,6..144,400&display=swap');

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
    --bg:           #08070a;
    --bg-warm:      #0d0b09;
    --bg-panel:     #110e0c;
    --bg-card:      #161210;
    --bg-card-h:    #1e1914;

    --gold:         #c8a35a;
    --gold-light:   #e4c07a;
    --gold-dim:     #6b5830;
    --gold-glow:    rgba(200, 163, 90, 0.1);

    --text:         #dfd0b8;
    --text-dim:     #92836e;
    --text-faint:   #473f36;

    --red:          #8b3a3a;
    --red-light:    #c05050;
    --green:        #4a9060;

    --sep:          rgba(200, 163, 90, 0.09);
    --sep-light:    rgba(200, 163, 90, 0.26);

    --font-display: 'Cinzel', 'Times New Roman', serif;
    --font-serif:   'EB Garamond', 'Palatino Linotype', Georgia, serif;
    --font-sans:    'Segoe UI', system-ui, sans-serif;

    --radius:       4px;
    --radius-lg:    8px;
    --ease:         cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --t:            0.22s;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    min-height: 100vh;
    line-height: 1.65;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }

/* ── Bouton primaire ───────────────────────────────────────────────────────── */
.btn-primary {
    display: block;
    width: 100%;
    padding: 13px;
    background: var(--gold);
    color: #0a0806;
    font-family: var(--font-display);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--t);
    margin-top: 8px;
}
.btn-primary:hover { background: var(--gold-light); }


/* ═══════════════════════════════════════════════════════════════════════════
   AUTH (connexion / inscription)
   ═══════════════════════════════════════════════════════════════════════════ */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 30% 60%, rgba(200,163,90,0.06) 0%, transparent 55%),
        radial-gradient(ellipse at 70% 30%, rgba(100,60,180,0.03) 0%, transparent 50%),
        var(--bg);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 24px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 52px;
}
.auth-logo h1 {
    font-family: var(--font-display);
    font-size: 3rem;
    letter-spacing: 0.28em;
    color: var(--gold);
    text-shadow: 0 0 60px rgba(200,163,90,0.22);
}
.auth-tagline {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--text-dim);
    font-size: 1.05rem;
    margin-top: 8px;
    letter-spacing: 0.02em;
}

.auth-form {
    background: var(--bg-panel);
    border: 1px solid var(--sep-light);
    border-radius: var(--radius-lg);
    padding: 38px;
}
.auth-form h2 {
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 30px;
}

.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.form-group input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--sep);
    border-radius: var(--radius);
    padding: 11px 14px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color var(--t);
}
.form-group input:focus { border-color: var(--gold-dim); }
.hint { color: var(--text-faint); font-size: 0.78rem; margin-top: 4px; }

.form-error {
    background: rgba(139,58,58,0.12);
    border: 1px solid rgba(192,80,80,0.22);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--red-light);
    font-size: 0.85rem;
    margin-bottom: 18px;
}
.auth-switch { text-align: center; margin-top: 20px; color: var(--text-dim); font-size: 0.85rem; }


/* ═══════════════════════════════════════════════════════════════════════════
   SÉLECTION HÉROS
   ═══════════════════════════════════════════════════════════════════════════ */

.heroes-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 50% -10%, rgba(200,163,90,0.08) 0%, transparent 55%),
        var(--bg);
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 44px;
    border-bottom: 1px solid var(--sep);
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(8,7,10,0.9);
    backdrop-filter: blur(12px);
}
.site-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    letter-spacing: 0.28em;
    color: var(--gold);
}
.site-user {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 0.82rem;
    color: var(--text-dim);
}
.btn-logout {
    background: none;
    border: 1px solid var(--sep);
    border-radius: var(--radius);
    color: var(--text-dim);
    padding: 6px 14px;
    cursor: pointer;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: all var(--t);
}
.btn-logout:hover { border-color: var(--gold-dim); color: var(--gold); }

.heroes-main {
    flex: 1;
    padding: 64px 44px;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
}

.heroes-intro {
    text-align: center;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 1.2rem;
    color: var(--text-dim);
    margin-bottom: 64px;
    letter-spacing: 0.01em;
}

/* Grille : 5 colonnes portrait sur grand écran */
.heroes-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 18px;
}

.hero-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--sep);
    border-radius: var(--radius-lg);
    overflow: hidden;
    text-decoration: none;
    transition: border-color 0.4s var(--ease), box-shadow 0.4s var(--ease), transform 0.4s var(--ease);
    position: relative;
}
.hero-card:hover {
    border-color: var(--hero-color, var(--gold-dim));
    box-shadow:
        0 16px 56px rgba(0,0,0,0.7),
        0 0 0 1px var(--hero-color, var(--gold-dim)),
        inset 0 0 0 1px rgba(255,255,255,0.02);
    transform: translateY(-5px);
}

/* Image en ratio portrait 2:3 */
.hero-card-image {
    aspect-ratio: 2 / 3;
    background: linear-gradient(175deg, var(--hero-color, #2a1f18) 0%, var(--bg-card) 100%);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
.hero-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    opacity: 0.72;
    transition: opacity 0.5s var(--ease), transform 0.6s var(--ease);
}
.hero-card:hover .hero-card-image img {
    opacity: 0.88;
    transform: scale(1.04);
}
.hero-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 45%, var(--bg-card) 100%);
    transition: background 0.4s;
}
.hero-card:hover .hero-card-overlay {
    background: linear-gradient(to bottom, transparent 38%, rgba(5,4,6,0.85) 100%);
}

.hero-card-body {
    padding: 14px 16px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.hero-card-subtitle {
    font-size: 0.66rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--hero-color, var(--gold));
    opacity: 0.85;
}
.hero-card-name {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.04em;
}
.hero-card-desc {
    font-family: var(--font-serif);
    font-size: 0.9rem;
    color: var(--text-dim);
    line-height: 1.5;
    flex: 1;
}
.hero-card-status {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.status-badge {
    font-size: 0.66rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-family: var(--font-display);
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.status-new     { background: var(--gold-glow); color: var(--gold); border: 1px solid var(--gold-dim); }
.status-continue { background: rgba(74,144,96,0.1); color: #72c090; border: 1px solid rgba(74,144,96,0.3); }
.status-page    { font-size: 0.68rem; color: var(--text-faint); }


/* ═══════════════════════════════════════════════════════════════════════════
   LECTEUR
   ═══════════════════════════════════════════════════════════════════════════ */

.reader-page {
    height: 100vh;
    overflow: hidden;
    display: flex;
}

/* ── Panneau image portrait (gauche, fixe) ─────────────────────────────────── */
.reader-img-panel {
    width: 38%;
    flex-shrink: 0;
    height: 100vh;
    background-color: var(--bg-warm);
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    position: relative;
}

/* Vignette globale sur l'image */
.reader-img-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to bottom, rgba(0,0,0,0.2) 0%, transparent 25%, transparent 65%, rgba(0,0,0,0.55) 100%);
    pointer-events: none;
    z-index: 1;
}

/* Fondu vers le fond à droite — l'image saigne dans le texte */
.reader-img-panel::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 120px;
    background: linear-gradient(to right, transparent, var(--bg));
    pointer-events: none;
    z-index: 2;
}

/* ── Corps principal (droite) ──────────────────────────────────────────────── */
.reader-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
    min-width: 0;
}

/* ── En-tête lecteur ───────────────────────────────────────────────────────── */
.reader-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 44px;
    border-bottom: 1px solid var(--sep);
    position: relative;
}
.reader-back {
    font-family: var(--font-display);
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 7px;
    transition: color var(--t);
}
.reader-back:hover { color: var(--gold); }
.reader-back svg { flex-shrink: 0; }

.reader-hero-label {
    font-family: var(--font-display);
    font-size: 0.78rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-dim);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.reader-journal-btn {
    background: none;
    border: 1px solid var(--sep);
    border-radius: var(--radius);
    color: var(--text-dim);
    padding: 7px 18px;
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    transition: all var(--t);
}
.reader-journal-btn:hover { border-color: var(--gold-dim); color: var(--gold); }

/* ── Titre de page ─────────────────────────────────────────────────────────── */
.reader-page-title {
    flex-shrink: 0;
    padding: 22px 48px 0;
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold-dim);
    min-height: 36px;
}

/* ── Lecteur audio ─────────────────────────────────────────────────────────── */
.reader-audio {
    flex-shrink: 0;
    padding: 14px 48px;
    display: flex;
    align-items: center;
    gap: 18px;
    border-bottom: 1px solid var(--sep);
}

.audio-btn {
    background: none;
    border: 1px solid var(--sep-light);
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    cursor: pointer;
    transition: all var(--t);
    flex-shrink: 0;
}
.audio-btn:hover { background: var(--gold-glow); border-color: var(--gold); }

.audio-btn-sm {
    width: 32px;
    height: 32px;
    color: var(--text-dim);
    border-color: var(--sep);
}
.audio-btn-sm:hover { color: var(--text); border-color: var(--sep-light); }

.audio-track { flex: 1; }
.audio-bar {
    height: 3px;
    background: rgba(255,255,255,0.07);
    border-radius: 2px;
    cursor: pointer;
    margin-bottom: 7px;
}
.audio-fill {
    height: 100%;
    background: var(--gold);
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s linear;
    pointer-events: none;
}
.audio-times {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: var(--text-faint);
    letter-spacing: 0.03em;
}

/* ── Zone de texte ─────────────────────────────────────────────────────────── */
.reader-text {
    flex: 1;
    overflow-y: auto;
    padding: 38px 56px 24px 48px;
    font-family: var(--font-serif);
    font-size: 1.18rem;
    line-height: 1.95;
    color: var(--text);
    min-height: 0;
}
.reader-text::-webkit-scrollbar { width: 5px; }
.reader-text::-webkit-scrollbar-track { background: transparent; }
.reader-text::-webkit-scrollbar-thumb { background: var(--sep-light); border-radius: 3px; }

.reader-text p { margin-bottom: 1em; }
.reader-text em { font-style: italic; color: var(--gold-light); }

/* Lettrine sur le premier paragraphe */
.reader-text p:first-of-type::first-letter {
    font-family: var(--font-display);
    font-size: 4rem;
    font-weight: 600;
    line-height: 0.72;
    float: left;
    margin: 0.06em 0.1em 0 0;
    color: var(--gold);
}

/* Spinner de chargement */
.page-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
}
.loading-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--sep);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Zone de choix ─────────────────────────────────────────────────────────── */
.reader-choices {
    flex-shrink: 0;
    padding: 0 48px 40px;
}

/* Séparateur ornemental avant les choix */
.choices-ornament {
    text-align: center;
    padding: 20px 0;
    color: var(--gold-dim);
    font-size: 0.75rem;
    letter-spacing: 0.7em;
    position: relative;
    user-select: none;
}
.choices-ornament::before,
.choices-ornament::after {
    content: '';
    position: absolute;
    top: 50%;
    height: 1px;
    width: calc(50% - 36px);
    background: var(--sep);
}
.choices-ornament::before { left: 0; }
.choices-ornament::after  { right: 0; }

.choices-list { display: flex; flex-direction: column; gap: 10px; }

.choice-btn {
    display: block;
    width: 100%;
    background: transparent;
    border: 1px solid var(--sep);
    border-radius: var(--radius);
    padding: 16px 24px;
    color: var(--text-dim);
    font-family: var(--font-serif);
    font-size: 1.08rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s var(--ease);
    position: relative;
    overflow: hidden;
}
/* Barre d'accent gauche animée */
.choice-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--gold);
    transform: scaleY(0);
    transform-origin: center;
    transition: transform 0.22s var(--ease);
}
.choice-btn:hover {
    border-color: var(--gold-dim);
    color: var(--text);
    background: var(--gold-glow);
    padding-left: 30px;
}
.choice-btn:hover::before { transform: scaleY(1); }


/* ═══════════════════════════════════════════════════════════════════════════
   JOURNAL — Tiroir droit
   ═══════════════════════════════════════════════════════════════════════════ */

.journal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.32s;
}
.journal-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.journal-drawer {
    position: fixed;
    right: -420px;
    top: 0;
    bottom: 0;
    width: 400px;
    background: var(--bg-panel);
    border-left: 1px solid var(--sep-light);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: right 0.38s var(--ease);
    overflow: hidden;
}
.journal-drawer.open { right: 0; }

.journal-drawer-header {
    flex-shrink: 0;
    padding: 18px 24px;
    border-bottom: 1px solid var(--sep);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.journal-drawer-header span {
    font-family: var(--font-display);
    font-size: 0.72rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.journal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: color var(--t);
}
.journal-close:hover { color: var(--text); }

.journal-tabs {
    flex-shrink: 0;
    display: flex;
    border-bottom: 1px solid var(--sep);
}
.jdrawer-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 12px;
    color: var(--text-dim);
    font-family: var(--font-display);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--t);
}
.jdrawer-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.jdrawer-tab:hover:not(.active) { color: var(--text); }

.journal-panel {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}
.journal-panel::-webkit-scrollbar { width: 4px; }
.journal-panel::-webkit-scrollbar-track { background: transparent; }
.journal-panel::-webkit-scrollbar-thumb { background: var(--sep); border-radius: 2px; }

.journal-empty {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--text-faint);
    font-size: 0.92rem;
    text-align: center;
    margin-top: 36px;
    line-height: 1.7;
}

.journal-entry {
    padding: 14px 0;
    border-bottom: 1px solid var(--sep);
    font-family: var(--font-serif);
    font-size: 0.92rem;
    color: var(--text-dim);
    line-height: 1.6;
}
.journal-entry:last-child { border-bottom: none; }

.journal-entry-page {
    font-family: var(--font-display);
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 7px;
}

.history-item {
    font-family: var(--font-display);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding: 8px 0;
    border-bottom: 1px solid var(--sep);
}
.history-item:last-child { border-bottom: none; }
.history-item.current { color: var(--gold); }

/* ── Bouton flottant (mobile) ──────────────────────────────────────────────── */
.reader-fab {
    display: none;
    position: fixed;
    bottom: 28px;
    right: 28px;
    background: var(--gold);
    border: none;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    color: #0a0806;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 4px 24px rgba(0,0,0,0.55);
    align-items: center;
    justify-content: center;
    transition: background var(--t);
}
.reader-fab:hover { background: var(--gold-light); }


/* ═══════════════════════════════════════════════════════════════════════════
   TRANSITIONS DE PAGE
   ═══════════════════════════════════════════════════════════════════════════ */

.page-fade-out { animation: fadeOut 0.26s var(--ease) forwards; }
.page-fade-in  { animation: fadeIn  0.36s var(--ease) forwards; }

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(-6px); }
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1280px) {
    .heroes-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
    .reader-img-panel { width: 34%; }
    .reader-text { padding: 32px 40px 20px 40px; }
    .reader-choices, .reader-page-title, .reader-audio { padding-left: 40px; padding-right: 40px; }
    .reader-header { padding-left: 36px; padding-right: 36px; }
}

/* Tablette / petit écran : image en bandeau en haut */
@media (max-width: 900px) {
    .reader-page { flex-direction: column; }

    .reader-img-panel {
        width: 100%;
        height: 200px;
        flex-shrink: 0;
    }
    /* Pas de fondu latéral sur mobile, seulement bas */
    .reader-img-panel::after { display: none; }
    .reader-img-panel::before {
        background: linear-gradient(to bottom, transparent 20%, rgba(0,0,0,0.5) 100%);
    }

    .reader-body { flex: 1; min-height: 0; overflow: hidden; }
    .reader-header { padding: 12px 24px; }
    .reader-hero-label { display: none; }
    .reader-journal-btn { display: none; }
    .reader-page-title { padding: 14px 24px 0; font-size: 0.68rem; }
    .reader-audio { padding: 12px 24px; }
    .reader-text { padding: 22px 24px 16px; font-size: 1.05rem; }
    .reader-choices { padding: 0 24px 24px; }

    .reader-fab { display: flex; }
    .journal-drawer { width: 100%; right: -100%; }
    .journal-drawer.open { right: 0; }
}

@media (max-width: 600px) {
    .heroes-main { padding: 36px 20px; }
    .heroes-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .site-header { padding: 14px 20px; }
    .auth-form { padding: 26px 22px; }
    .reader-text { padding: 18px 18px 12px; font-size: 1rem; }
    .reader-choices { padding: 0 18px 20px; }
    .reader-text p:first-of-type::first-letter { font-size: 3rem; }
}
