/* Talisman /substrate: the floor under the music. Extends styles.css and shell.css.
   The page's own network floats behind everything; the story is drawn on a sticky stage with the
   scene cards scrolling past it. Tokens come from styles.css :root; none are redeclared. */

.sub { font-family: var(--font-mono); padding-top: 56px; }
.sub [id] { scroll-margin-top: 72px; }

/* The page's network, lit as the subject while the opening is on screen, and quiet while the
   story draws its own picture over it. */
#mesh-canvas { transition: opacity 1.4s ease-out, filter 1.4s ease-out !important; }
.sub-lit #mesh-canvas { filter: brightness(2.4) saturate(1.3) drop-shadow(0 0 6px rgba(200, 212, 226, 0.5)) !important; }
.sub-story #mesh-canvas { opacity: 0.22 !important; }

/* ---- Type ------------------------------------------------------------------ */

.card-num, .sub-kicker {
    font-size: var(--text-xs);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--color-turquoise);
    margin-bottom: var(--space-sm);
}
.sub-h2 {
    font-size: clamp(1.8rem, 4.2vw, 2.8rem);
    font-weight: var(--weight-thin);
    line-height: 1.15;
    color: #fff;
    margin-bottom: var(--space-sm);
}
.sub-body {
    font-size: var(--text-base);
    line-height: 1.75;
    color: rgba(255, 255, 255, 0.72);
    max-width: 54ch;
    margin-bottom: var(--space-md);
}
.sub-body a { color: var(--color-turquoise); text-decoration: none; border-bottom: 1px solid rgba(64, 224, 208, 0.4); }

/* ---- The opening: one line over the lit network ----------------------------- */

.sub-open {
    min-height: calc(100svh - 56px);
    max-width: 1060px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-xl) var(--space-sm);
}
.sub-title {
    font-size: clamp(2.2rem, 6.4vw, 4.6rem);
    font-weight: var(--weight-thin);
    line-height: 1.1;
    color: #fff;
    text-wrap: balance;
    margin: 0;
}
.sub-lede {
    max-width: 46ch;
    margin: var(--space-md) auto 0;
    font-size: clamp(1.05rem, 2.2vw, 1.4rem);
    font-weight: var(--weight-light);
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.72);
    text-wrap: balance;
}
.sub-more { margin-top: var(--space-lg); }

/* ---- The story: one stage, six scenes ------------------------------------- */

.story {
    position: relative;
    width: 100vw;
    margin-left: calc(50% - 50vw);
}
.stage {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100svh;
    overflow: hidden;
}
.stage canvas { display: block; width: 100%; height: 100%; }
.stage-dots {
    position: absolute;
    z-index: 3;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.stage-dots li { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); transition: background 0.4s; }
.stage[data-scene="0"] .stage-dots li:nth-child(1),
.stage[data-scene="1"] .stage-dots li:nth-child(2),
.stage[data-scene="2"] .stage-dots li:nth-child(3),
.stage[data-scene="3"] .stage-dots li:nth-child(4),
.stage[data-scene="4"] .stage-dots li:nth-child(5),
.stage[data-scene="5"] .stage-dots li:nth-child(6) { background: #fff; }

/* Pulled up over the stage, so the first scene starts alongside the picture. The cards sit in
   the left third on a wide screen, where mesh.js leaves the picture its right 56%. */
.scenes { position: relative; margin-top: -100vh; margin-top: -100svh; }
.scene {
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    align-items: center;
    padding: 0 max(16px, calc(50% - 530px));
}
.card { max-width: min(380px, 34%); }
.card-title {
    font-size: clamp(1.5rem, 3vw, 2.1rem);
    font-weight: var(--weight-thin);
    line-height: 1.2;
    color: #fff;
    margin-bottom: var(--space-sm);
}
.card-body {
    font-size: var(--text-base);
    line-height: 1.75;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: var(--space-sm);
}
.card .thread { margin-top: var(--space-xs); }
.has-js .card { will-change: opacity; }

/* ---- Where it is: five kinds of node, honestly ---------------------------- */

.ledger {
    max-width: 1060px;
    margin: var(--space-2xl) auto 0;
    padding: 0 var(--space-sm);
}
.roles {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-md) var(--space-sm);
    margin: var(--space-lg) 0 var(--space-sm);
}
.role { border-top: 1px solid rgba(255, 255, 255, 0.15); padding-top: var(--space-sm); min-width: 0; }
.role dt { font-size: var(--text-base); color: #fff; margin-bottom: 0.4rem; }
.role dd {
    margin: 0 0 0.7rem;
    font-size: var(--text-xs);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
}
.role dd::before { content: '● '; }
.role.is-running dd { color: var(--color-turquoise); }
.role p { font-size: var(--text-sm); line-height: 1.6; color: rgba(255, 255, 255, 0.62); margin: 0; }

/* ---- Run a node: the installer, as it runs --------------------------------- */

.node {
    max-width: 1060px;
    margin: var(--space-2xl) auto 0;
    padding: 0 var(--space-sm);
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: var(--space-xl);
    align-items: center;
}
.node-text .sub-body { margin-bottom: var(--space-sm); }
.node-note { font-size: var(--text-sm); line-height: 1.7; color: rgba(255, 255, 255, 0.55); }
.term {
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(0, 0, 0, 0.7);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.term-bar { display: flex; gap: 6px; margin: 0; padding: 10px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.term-bar span { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.18); }
.term-screen {
    margin: 0;
    padding: var(--space-sm) var(--space-md) var(--space-md);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.75;
    color: rgba(255, 255, 255, 0.85);
    white-space: pre;
}
.term-prompt { color: rgba(255, 255, 255, 0.45); }
.term-cmd { color: var(--color-turquoise); }
.term-cursor { display: inline-block; width: 0.55em; height: 1em; vertical-align: -0.15em; background: rgba(255, 255, 255, 0.8); animation: term-blink 1s steps(2, start) infinite; }
.term.is-done .term-cursor { display: none; }
@keyframes term-blink { to { visibility: hidden; } }
.term-line { display: block; }
.term-line .term-arrow { color: var(--color-turquoise); }
.term-line.is-up { color: #fff; }
.term-line.is-plain { color: rgba(255, 255, 255, 0.6); }
/* Armed: the transcript waits for the typing; each line comes up in turn. */
.term.is-armed .term-line { opacity: 0; transform: translateY(3px); transition: opacity 0.35s ease-out, transform 0.35s ease-out; }
.term.is-armed .term-line.is-on { opacity: 1; transform: none; }
.install-line {
    display: block;
    margin-top: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--color-turquoise);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    user-select: all;
}

/* ---- The ending ------------------------------------------------------------- */

.sub-ending {
    max-width: 1060px;
    min-height: 60svh;
    margin: var(--space-xl) auto 0;
    padding: var(--space-xl) var(--space-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.sub-ending .sub-body { max-width: 44ch; margin: 0 auto var(--space-md); }
.sub-actions { margin: 0 0 var(--space-md); }
.sub-threads { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-sm) var(--space-md); }

.sub-footer { max-width: 1060px; margin: var(--space-xl) auto 0; padding-left: var(--space-sm); padding-right: var(--space-sm); width: 100%; }
.sub-footer .ritual-mark { color: var(--color-purple); letter-spacing: 0.2em; }

/* ---- Phones ---------------------------------------------------------------- */

@media (max-width: 760px) {
    .scene { align-items: flex-end; padding-bottom: 7svh; }
    .card { max-width: none; }
    .roles { grid-template-columns: 1fr 1fr; }
    /* One column; the terminal's long lines scroll inside it rather than widening the page. */
    .node { grid-template-columns: minmax(0, 1fr); gap: var(--space-md); }
    .node-text, .term { min-width: 0; }
    .term-screen { font-size: 0.72rem; padding: var(--space-sm); }
}
@media (max-width: 480px) {
    .roles { grid-template-columns: 1fr; gap: var(--space-sm); }
}

/* ---- Without enhancement, and with reduced motion: everything in plain flow ----- */

html:not(.has-js) .stage { display: none; }
html:not(.has-js) .scenes { margin-top: 0; }
html:not(.has-js) .scene { min-height: 0; padding-top: var(--space-lg); padding-bottom: var(--space-lg); }
html:not(.has-js) .stage-dots { display: none; }

@media (prefers-reduced-motion: reduce) {
    .term-cursor { animation: none; }
    .card { opacity: 1 !important; }
    #mesh-canvas { transition: none !important; }
}
