/* ============================================
   PARCOURS — scrollytelling (js/views/story.js, js/controllers/story.js)
   ============================================
   La section fait plusieurs écrans de haut ; .story-stage y reste collée en
   haut de l'écran pendant que le scroll fait avancer l'animation. */

#story { --tone: var(--surface-lowest); }

/* Le parcours ouvre la page : il remonte sous l'en-tête fixe (main garde
   un retrait de sa hauteur) pour que la scène occupe tout l'écran dès le départ. */
.story:first-child { margin-top: calc(-1 * var(--nav-height)); }

.story {
    position: relative;
    /* Un écran pour la scène + ~90 % d'écran de scroll par étape, plus le
       segment des mains d'Atlas (--story-atlas, posé par controllers/story.js
       hors mouvement réduit). */
    height: calc(100svh + var(--story-scenes, 5) * 90svh + var(--story-atlas, 0svh));
}

.story-stage {
    --story-inline: max(var(--margin), (100% - var(--max-width)) / 2);
    position: sticky;
    top: 0;
    height: 100svh;
    overflow: hidden;
    isolation: isolate;
    /* Fond opaque : le réseau de fond de page ne se superpose pas à celui-ci. */
    background:
        radial-gradient(ellipse 70% 55% at 50% 42%, rgba(255, 255, 255, 0.035), transparent 70%),
        var(--surface-lowest);
}

.story-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* Assombrit le bas de l'écran pour que le texte reste lisible sur le réseau. */
.story-scrim {
    position: absolute;
    inset: auto 0 0;
    height: 60%;
    background: linear-gradient(to top, rgba(10, 10, 10, 0.94), rgba(10, 10, 10, 0.55) 50%, transparent);
    pointer-events: none;
}

/* ---------- Scènes de texte ---------- */
.story-scene {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    padding: calc(var(--nav-height) + var(--space-lg)) var(--story-inline) 12vh var(--story-inline);
    opacity: 0;
    pointer-events: none;
}

.story-scene.is-active { pointer-events: auto; }
.story-scene:first-of-type { opacity: 1; }

.story-scene-inner {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    max-width: 36rem;
    text-shadow: 0 2px 18px rgba(10, 10, 10, 0.85);
}

.pos-bottom-right,
.pos-center-right { align-items: flex-end; text-align: right; }
.pos-center-left,
.pos-center-right { justify-content: center; }
.pos-bottom-center { align-items: center; text-align: center; }
.pos-bottom-center .story-scene-inner { max-width: 40rem; align-items: center; }
.pos-bottom-right .story-scene-inner,
.pos-center-right .story-scene-inner { align-items: flex-end; }

.story-kicker {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--secondary);
}

.story-title {
    font-family: var(--font-display);
    font-size: clamp(24px, 2.9vw, 40px);
    line-height: 1.06;
    font-weight: 500;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

/* Scène d'ouverture : le nom en grand. */
.is-intro .story-title {
    font-size: clamp(44px, 7.5vw, 104px);
    line-height: 1;
    letter-spacing: -0.04em;
}

.is-intro .story-text { font-size: clamp(17px, 1.5vw, 22px); }

.story-text {
    max-width: 34rem;
    font-size: clamp(16px, 1.2vw, 18px);
    color: var(--on-surface-variant);
}

.story-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: var(--space-xs);
    padding: 0;
    list-style: none;
    text-shadow: none;
}

.story-tags li {
    padding: 3px 9px;
    border: 1px solid var(--border-glass);
    border-radius: 999px;
    background: rgba(10, 10, 10, 0.55);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--on-surface-variant);
}

.pos-bottom-right .story-tags,
.pos-center-right .story-tags { justify-content: flex-end; }
.pos-bottom-center .story-tags { justify-content: center; }

.story-project {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.06em;
    color: var(--secondary);
    transition: gap 0.2s, color 0.2s;
}

.story-project .icon { font-size: 16px; }
.story-project:hover { gap: var(--space-sm); color: var(--on-surface); }

.story-ctas {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    text-shadow: none;
}

/* ---------- Scène d'accueil : présentation + assistant ---------- */
/* La première scène reprend l'accueil complet (js/views/hero.js) : nom en très
   grand ancré en bas à gauche, assistant ReyMysterio à droite. */
.pos-hero { align-items: stretch; }

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-xl);
    align-items: end;
}

.hero-main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
    text-shadow: 0 2px 18px rgba(10, 10, 10, 0.85);
}

.hero-name {
    font-family: var(--font-display);
    font-size: clamp(32px, 4.6vw, 68px);
    line-height: 1;
    font-weight: 500;
    letter-spacing: -0.03em;
    color: var(--on-surface);
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(16px, 1.6vw, 22px);
    line-height: 1.2;
    font-weight: 500;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

/* Comme dans l'intro : la fin de la phrase en italique. */
.hero-title .gradient-text { font-style: italic; }

.hero-bio {
    max-width: 34rem;
    margin-top: var(--space-xs);
    font-size: clamp(16px, 1.2vw, 18px);
    line-height: 1.6;
    color: var(--on-surface-variant);
}

.hero-bio strong { color: var(--on-surface); font-weight: 600; }

.hero-ctas {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    text-shadow: none;
}

.hero-aside {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    min-width: 0;
}

/* Le panneau du chatbot dans la scène : verre sombre, trait fin. */
.hero-side .chat-panel {
    border: 1px solid var(--border-glass);
    background: rgba(10, 10, 10, 0.72);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

@media (min-width: 1024px) {
    .hero-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--space-2xl); }
}

/* Trop étroit pour les deux côte à côte dans un seul écran : la scène garde
   la présentation, l'assistant reste accessible par le lanceur flottant. */
@media (max-width: 1023px) {
    .pos-hero .hero-aside { display: none; }
}

/* Écran peu haut : l'assistant ne tiendrait pas, même traitement. */
@media (min-width: 1024px) and (max-height: 760px) {
    .pos-hero .hero-aside { display: none; }
    .hero-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Passer l'intro & invitation à défiler ---------- */
.story-skip {
    position: absolute;
    z-index: 3;
    top: calc(var(--nav-height) + var(--space-md));
    right: var(--story-inline);
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid var(--border-glass);
    border-radius: 999px;
    background: rgba(28, 28, 28, 0.6);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--on-surface-variant);
    transition: opacity 0.3s, color 0.2s, border-color 0.2s;
}

.story-skip .icon { font-size: 16px; }
.story-skip:hover { color: var(--on-surface); border-color: var(--outline-variant); }
.story-skip.is-hidden { opacity: 0; pointer-events: none; }

.story-hint {
    position: absolute;
    z-index: 3;
    bottom: var(--space-lg);
    left: 50%;
    translate: -50% 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--outline);
    pointer-events: none;
}

.story-hint-line {
    position: relative;
    width: 1px;
    height: 40px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.12);
}

.story-hint-line::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--secondary);
    animation: story-hint 1.8s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

@keyframes story-hint {
    from { translate: 0 -100%; }
    to { translate: 0 100%; }
}

/* ---------- Mobile : textes centrés en bas, réseau en haut ---------- */
@media (max-width: 820px) {
    .story-scene,
    .story-scene[class*="pos-"] {
        justify-content: flex-end;
        align-items: center;
        text-align: center;
        padding-bottom: 9vh;
        padding-inline: var(--story-inline);
    }

    /* Textes plus longs qu'un écran de téléphone ne le permet à côté du
       réseau : voile plus haut, texte un peu plus petit. */
    .story-scrim { height: 78%; }
    /* L'accueil garde la place de l'invitation à défiler, sous ses boutons. */
    .story-scene.pos-hero { padding-bottom: 14vh; }
    .story-text { font-size: 13px; line-height: 1.5; }
    .story-title { font-size: clamp(20px, 5.6vw, 26px); }

    .story-scene[class*="pos-"] .story-scene-inner,
    .pos-hero .hero-main { align-items: center; }
    .pos-hero .hero-ctas,
    .story-scene .story-tags { justify-content: center; }

}

/* ---------- Mouvement réduit : scènes empilées, décor figé ---------- */
.story.is-static { height: auto; }

.story.is-static .story-stage {
    position: relative;
    height: auto;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--space-2xl);
    padding: var(--space-2xl) var(--story-inline);
}

.story.is-static .story-canvas { opacity: 0.35; }

.story.is-static .story-scene {
    position: relative;
    inset: auto;
    padding: 0;
    opacity: 1;
    pointer-events: auto;
}

.story.is-static :is(.story-scrim, .story-skip, .story-hint) { display: none; }
