/* lrx.sh — License and Right eXchange
   Scriptorium-terminal: candle-lit ledger, serif-set shell, liturgical neon. */

:root {
    --sumi-ink: #0F0B07;
    --vellum: #F4E9D2;
    --oak: #7A6147;
    --soot: #2B1F14;
    --neon-magenta: #FF2E9A;
    --neon-lime: #A6FF1F;
    --candle-halo: #FFB347;
    --oxblood: #5C0F38;

    --neon-active: var(--neon-magenta);
    --neon-rest: var(--oak);

    --reading-col: 720px;
    --line-bw-leading: 1.7;
    --display-leading: 0.95;

    --ease-ritual: cubic-bezier(0.65, 0, 0.35, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
    background: var(--sumi-ink);
}

body {
    font-family: "EB Garamond", Georgia, serif;
    font-size: 19px;
    line-height: var(--line-bw-leading);
    color: var(--vellum);
    background: var(--sumi-ink);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* === The Master Candle (fixed atmospheric source) === */

.candle-stage {
    position: fixed;
    top: 4vh;
    left: 3vw;
    width: 200px;
    height: 360px;
    pointer-events: none;
    z-index: 5;
    filter: drop-shadow(0 0 24px rgba(255, 179, 71, 0.25));
}

.candle-master {
    width: 100%;
    height: 100%;
    overflow: visible;
}

#candle-halo {
    transform-origin: 100px 100px;
    transition: transform 220ms ease-out, opacity 220ms ease-out;
}

#candle-flame {
    transform-origin: 100px 100px;
    transition: transform 90ms linear, opacity 90ms linear;
}

#candle-flame-core {
    transform-origin: 100px 100px;
    transition: transform 60ms linear;
}

/* === Cipher gutter glyphs (parallax) === */

.cipher-gutter {
    position: fixed;
    top: 0;
    right: 4vw;
    width: 60px;
    height: 100vh;
    z-index: 4;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 8vh 0;
}

.cipher {
    width: 32px;
    height: 32px;
    opacity: 0.4;
    transition: opacity 600ms ease;
    will-change: transform;
}

.cipher path,
.cipher circle {
    stroke: var(--oak);
}

/* === Scroll-progress signature thread === */

.scroll-thread {
    position: fixed;
    top: 0;
    right: 0;
    width: 1px;
    height: 100vh;
    background: rgba(122, 97, 71, 0.15);
    z-index: 9;
    pointer-events: none;
}

#thread-fill {
    display: block;
    width: 1px;
    height: 0;
    background: var(--neon-magenta);
    box-shadow: 0 0 8px rgba(255, 46, 154, 0.7);
    transition: height 90ms linear;
}

/* === Chamber base === */

main#ledger {
    position: relative;
    z-index: 2;
}

.chamber {
    position: relative;
    min-height: 100vh;
    padding: 10vh 0 25vh 0;
    scroll-snap-align: start;
    overflow: hidden;
}

.chamber-inner {
    max-width: var(--reading-col);
    margin: 0 auto;
    padding: 0 7vw 0 calc(3vw + 220px); /* leave room for fixed candle on the left */
    position: relative;
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.4em;
}

/* Margin rule (path-draw vertical line) */
.margin-rule {
    position: absolute;
    top: 0;
    left: calc(3vw + 220px - 28px);
    width: 4px;
    height: 100%;
    pointer-events: none;
}

.margin-rule svg {
    width: 100%;
    height: 100%;
}

.margin-rule--fuse path,
.margin-rule--wire path {
    stroke: var(--neon-rest);
}

/* Path-draw mechanism */
.path-draw {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    transition: stroke-dashoffset 1800ms var(--ease-ritual);
}

.chamber.in-view .path-draw {
    stroke-dashoffset: 0;
}

.chamber.in-view .margin-rule .path-draw {
    transition-delay: 200ms;
}

/* Reveal: body text */
[data-reveal] {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 900ms var(--ease-ritual), transform 900ms var(--ease-ritual);
}

.chamber.in-view [data-reveal] {
    opacity: 1;
    transform: translateY(0);
}

/* Reveal: word-by-word display headings */
[data-reveal-words] {
    display: block;
}

.word-span {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 600ms var(--ease-ritual), transform 600ms var(--ease-ritual);
    margin-right: 0.28em;
}

.chamber.in-view .word-span.in {
    opacity: 1;
    transform: translateY(0);
}

/* === Typography === */

.chamber-label {
    font-family: "Cormorant SC", "Cormorant Garamond", serif;
    font-size: 11px;
    letter-spacing: 0.36em;
    text-transform: uppercase;
    color: var(--oak);
    margin-bottom: 2.2em;
}

.display-heading {
    font-family: "Cormorant Garamond", serif;
    font-weight: 500;
    font-size: clamp(48px, 7vw, 96px);
    line-height: var(--display-leading);
    color: var(--vellum);
    letter-spacing: -0.01em;
    margin-bottom: 0.4em;
}

.prompt-line {
    font-family: "Cormorant Garamond", serif;
    font-weight: 300;
    font-size: clamp(56px, 9vw, 132px);
    line-height: var(--display-leading);
    color: var(--vellum);
    letter-spacing: -0.012em;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.2em;
}

.prompt-line--small {
    font-size: clamp(36px, 5vw, 64px);
}

.prompt-prefix {
    color: var(--vellum);
    font-style: italic;
}

.prompt-mark {
    color: var(--oak);
    font-family: "IBM Plex Serif", serif;
    font-weight: 500;
    margin: 0 0.2em;
}

.prompt-cmd {
    color: var(--vellum);
    font-style: italic;
    white-space: pre;
}

.prompt-cursor {
    display: inline-block;
    width: 0.08em;
    height: 0.85em;
    background: var(--neon-magenta);
    margin-left: 0.04em;
    box-shadow: 0 0 12px rgba(255, 46, 154, 0.6);
    animation: cursor-blink 980ms steps(2, jump-none) infinite;
    vertical-align: -0.12em;
}

#cursor-ember {
    background: var(--oxblood);
    box-shadow: 0 0 10px rgba(92, 15, 56, 0.65);
}

@keyframes cursor-blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.chamber-tagline {
    font-family: "EB Garamond", serif;
    font-style: italic;
    font-size: 19px;
    color: var(--oak);
    max-width: 60ch;
    margin-top: 1em;
}

.indenture {
    display: flex;
    flex-direction: column;
    gap: 1.2em;
    padding-left: 2.2em;
    border-left: none;
}

.indenture p {
    font-family: "EB Garamond", serif;
    font-size: 19px;
    line-height: 1.7;
    color: var(--vellum);
    text-indent: 1.6em;
}

.indenture p:first-child {
    text-indent: 2.4em;
}

.indenture em {
    font-style: italic;
    color: var(--candle-halo);
}

/* === Hand chambers === */

.hand-stage,
.counterparty-stage {
    position: relative;
    width: 100%;
    margin-top: 2em;
    margin-bottom: 1.2em;
}

.hand-illustration {
    width: 100%;
    max-width: 560px;
    height: auto;
    display: block;
}

.hand-illustration--right {
    margin-left: auto;
}

.signature-stroke {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    transition: stroke-dashoffset 2000ms var(--ease-ritual) 600ms;
    filter: drop-shadow(0 0 6px rgba(255, 46, 154, 0.55));
}

.chamber.in-view .signature-stroke {
    stroke-dashoffset: 0;
}

.connecting-wire {
    width: 100%;
    height: 80px;
    margin-top: 1.6em;
    display: block;
}

.connecting-wire .signature-stroke {
    filter: drop-shadow(0 0 6px rgba(166, 255, 31, 0.55));
}

/* === Witness TTY panel === */

.tty-panel {
    background: var(--soot);
    border: 1px solid rgba(122, 97, 71, 0.4);
    padding: 1.4em 1.8em;
    margin-top: 1.4em;
    border-radius: 2px;
    box-shadow: 0 6px 32px rgba(0, 0, 0, 0.4);
    font-family: "IBM Plex Serif", serif;
    font-size: 16px;
    line-height: 1.85;
    letter-spacing: 0.02em;
    color: var(--vellum);
    position: relative;
}

.tty-panel::before {
    content: "";
    position: absolute;
    top: 0.6em;
    left: 0.8em;
    right: 0.8em;
    height: 1px;
    background: rgba(244, 233, 210, 0.08);
}

.tty-line {
    white-space: pre;
    overflow: hidden;
    color: var(--vellum);
    font-variant-ligatures: none;
}

.tty-line.tty-commit {
    color: var(--neon-lime);
    text-shadow: 0 0 8px rgba(166, 255, 31, 0.45);
    margin-top: 0.4em;
}

.tty-cursor {
    display: inline-block;
    width: 0.5em;
    height: 1em;
    background: var(--neon-magenta);
    margin-left: 0.1em;
    vertical-align: -0.15em;
    animation: cursor-blink 980ms steps(2, jump-none) infinite;
    box-shadow: 0 0 6px rgba(255, 46, 154, 0.6);
}

.chamber--witness.in-view .tty-cursor {
    background: var(--neon-lime);
    box-shadow: 0 0 8px rgba(166, 255, 31, 0.6);
}

/* === Seal chamber === */

.seal-stage {
    position: relative;
    width: 100%;
    margin: 2em 0;
    min-height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fuse-svg {
    position: absolute;
    top: 50%;
    left: -10%;
    width: 120%;
    height: 200px;
    transform: translateY(-50%);
    pointer-events: none;
}

#fuse-flame {
    filter: drop-shadow(0 0 10px rgba(255, 46, 154, 0.85));
    transition: opacity 200ms ease;
}

.seal-svg {
    width: 280px;
    height: 280px;
    z-index: 2;
}

#seal-fill {
    transition: opacity 800ms ease, fill 1800ms ease;
    transform-origin: 140px 140px;
}

#seal-monogram {
    transition: fill 1800ms ease, opacity 600ms ease;
}

#seal-ring-outer,
#seal-ring-inner {
    transition: stroke 1400ms ease;
}

.chamber--seal.ignited #seal-fill {
    opacity: 0.85;
}

.chamber--seal.cooled #seal-fill {
    opacity: 0.7;
    filter: hue-rotate(-30deg) saturate(0.8);
}

.chamber--seal.ignited #seal-ring-outer,
.chamber--seal.ignited #seal-ring-inner {
    stroke: var(--neon-magenta);
}

.chamber--seal.cooled #seal-ring-outer,
.chamber--seal.cooled #seal-ring-inner {
    stroke: var(--oxblood);
}

.chamber--seal.cooled #seal-monogram {
    fill: var(--vellum);
}

.chamber--seal.cooled #seal-crack {
    opacity: 0.7;
}

/* === Ledger chamber === */

.ledger-list {
    list-style: none;
    margin-top: 1.4em;
    display: flex;
    flex-direction: column;
    gap: 1.05em;
}

.ledger-row {
    display: grid;
    grid-template-columns: 56px 16px 1fr;
    align-items: baseline;
    gap: 0.6em;
    font-family: "IBM Plex Serif", serif;
    font-size: 15px;
    color: var(--vellum);
    letter-spacing: 0.02em;
    position: relative;
    padding-bottom: 0.4em;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 700ms var(--ease-ritual), transform 700ms var(--ease-ritual);
}

.chamber--ledger.in-view .ledger-row {
    opacity: 1;
    transform: translateY(0);
}

.chamber--ledger.in-view .ledger-row:nth-child(1) { transition-delay: 0ms; }
.chamber--ledger.in-view .ledger-row:nth-child(2) { transition-delay: 120ms; }
.chamber--ledger.in-view .ledger-row:nth-child(3) { transition-delay: 240ms; }
.chamber--ledger.in-view .ledger-row:nth-child(4) { transition-delay: 360ms; }
.chamber--ledger.in-view .ledger-row:nth-child(5) { transition-delay: 480ms; }
.chamber--ledger.in-view .ledger-row:nth-child(6) { transition-delay: 600ms; }
.chamber--ledger.in-view .ledger-row:nth-child(7) { transition-delay: 720ms; }
.chamber--ledger.in-view .ledger-row:nth-child(8) { transition-delay: 840ms; }

.ledger-num {
    color: var(--candle-halo);
    font-weight: 500;
    font-family: "IBM Plex Serif", serif;
}

.ledger-arrow {
    color: var(--oak);
    font-family: "EB Garamond", serif;
}

.ledger-label {
    font-family: "EB Garamond", serif;
    font-size: 17px;
    color: var(--vellum);
}

.ledger-rule {
    grid-column: 1 / -1;
    width: 100%;
    height: 4px;
    margin-top: 0.4em;
}

/* === Compline === */

.compline-prose {
    font-family: "EB Garamond", serif;
    font-style: italic;
    font-size: 21px;
    line-height: 1.65;
    color: var(--vellum);
    max-width: 56ch;
    margin: 0.6em 0 1.2em;
}

/* When compline is active, dim neon to ember */
.chamber--compline.in-view ~ * .scroll-thread #thread-fill,
body.late-scroll #thread-fill {
    background: var(--oxblood);
    box-shadow: 0 0 8px rgba(92, 15, 56, 0.7);
}

/* === Ash footer === */

.chamber--ash {
    padding-bottom: 12vh;
}

.ash-field {
    position: relative;
    width: 100%;
    height: 80px;
    margin: 1em 0 2em;
}

.ash-speck {
    position: absolute;
    width: 14px;
    height: 14px;
    cursor: default;
}

.ash-speck svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.ash-speck path,
.ash-speck circle {
    fill: var(--oxblood);
    stroke: var(--oak);
    stroke-width: 0.6;
    transition: fill 240ms ease, transform 240ms ease;
}

.ash-speck:hover path,
.ash-speck:hover circle {
    fill: var(--candle-halo);
}

.ash-tooltip {
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--soot);
    color: var(--vellum);
    font-family: "Cormorant SC", serif;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    padding: 0.4em 0.7em;
    border: 1px solid rgba(122, 97, 71, 0.5);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
    z-index: 8;
}

.ash-speck:hover .ash-tooltip {
    opacity: 1;
}

.footer-meta {
    margin-top: 1.4em;
    display: flex;
    flex-direction: column;
    gap: 0.6em;
    font-family: "Cormorant SC", "Cormorant Garamond", serif;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--oak);
}

.legalese {
    font-family: "Cormorant SC", serif;
    font-size: 11px;
    letter-spacing: 0.16em;
}

.version-hash {
    color: var(--vellum);
    cursor: pointer;
    font-family: "IBM Plex Serif", serif;
    text-transform: none;
    letter-spacing: 0.02em;
    font-size: 12px;
    transition: color 240ms ease, text-shadow 240ms ease;
    border-bottom: 1px dotted var(--oak);
    padding: 0 2px;
}

.version-hash.copied {
    color: var(--neon-lime);
    text-shadow: 0 0 10px rgba(166, 255, 31, 0.7);
}

.ambience-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.6em;
    cursor: not-allowed;
    margin-top: 0.4em;
    user-select: none;
}

.ambience-toggle input {
    appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid var(--oak);
    background: transparent;
    position: relative;
    cursor: not-allowed;
}

.ambience-toggle input:checked::after {
    content: "";
    position: absolute;
    inset: 2px;
    background: var(--oxblood);
}

.ambience-text {
    font-family: "Cormorant SC", serif;
    font-size: 10px;
    color: var(--oak);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* === Per-chamber neon discipline === */

.chamber--antechamber.in-view ~ main .prompt-cursor,
.chamber--antechamber.in-view .prompt-cursor {
    background: var(--neon-magenta);
}

/* Antechamber dim halo */
.chamber--antechamber {
    background:
        radial-gradient(ellipse at 22% 36%, rgba(255, 179, 71, 0.07), transparent 55%),
        var(--sumi-ink);
}

.chamber--grant {
    background:
        radial-gradient(ellipse at 18% 32%, rgba(255, 179, 71, 0.05), transparent 50%),
        var(--sumi-ink);
}

.chamber--hand {
    background:
        radial-gradient(ellipse at 18% 32%, rgba(255, 179, 71, 0.05), transparent 55%),
        radial-gradient(ellipse at 70% 64%, rgba(255, 46, 154, 0.04), transparent 60%),
        var(--sumi-ink);
}

.chamber--witness {
    background:
        radial-gradient(ellipse at 18% 32%, rgba(255, 179, 71, 0.05), transparent 50%),
        radial-gradient(ellipse at 60% 64%, rgba(166, 255, 31, 0.03), transparent 60%),
        var(--sumi-ink);
}

.chamber--seal {
    background:
        radial-gradient(ellipse at 18% 32%, rgba(255, 179, 71, 0.06), transparent 50%),
        radial-gradient(ellipse at 50% 60%, rgba(255, 46, 154, 0.06), transparent 60%),
        var(--sumi-ink);
}

.chamber--counterparty {
    background:
        radial-gradient(ellipse at 18% 32%, rgba(255, 179, 71, 0.05), transparent 50%),
        radial-gradient(ellipse at 70% 50%, rgba(166, 255, 31, 0.06), transparent 60%),
        var(--sumi-ink);
}

.chamber--ledger {
    background:
        radial-gradient(ellipse at 18% 32%, rgba(255, 179, 71, 0.04), transparent 50%),
        var(--sumi-ink);
}

.chamber--compline {
    background:
        radial-gradient(ellipse at 18% 36%, rgba(255, 179, 71, 0.04), transparent 50%),
        radial-gradient(ellipse at 60% 60%, rgba(92, 15, 56, 0.08), transparent 60%),
        var(--sumi-ink);
}

.chamber--ash {
    background:
        radial-gradient(ellipse at 18% 36%, rgba(255, 179, 71, 0.03), transparent 50%),
        var(--sumi-ink);
}

/* Compline lowers candle to ember tone */
body.late-scroll .candle-stage {
    filter: drop-shadow(0 0 16px rgba(92, 15, 56, 0.45));
}

/* === Responsive === */

@media (max-width: 900px) {
    .candle-stage {
        width: 130px;
        height: 240px;
        top: 2vh;
        left: 2vw;
        opacity: 0.9;
    }

    .chamber-inner {
        padding: 0 6vw 0 calc(2vw + 140px);
    }

    .margin-rule {
        left: calc(2vw + 140px - 24px);
    }

    .display-heading {
        font-size: clamp(36px, 9vw, 72px);
    }

    .prompt-line {
        font-size: clamp(40px, 12vw, 96px);
    }

    .cipher-gutter {
        right: 1vw;
    }
}

@media (max-width: 640px) {
    .candle-stage {
        width: 96px;
        height: 180px;
        opacity: 0.75;
    }

    .chamber-inner {
        padding: 0 5vw 0 calc(2vw + 100px);
        gap: 1.2em;
    }

    .margin-rule {
        left: calc(2vw + 100px - 22px);
    }

    body {
        font-size: 17px;
    }

    .indenture {
        padding-left: 1em;
    }

    .indenture p {
        font-size: 17px;
    }

    .tty-panel {
        font-size: 13px;
        padding: 1em 1.2em;
        overflow-x: auto;
    }

    .ledger-row {
        grid-template-columns: 44px 14px 1fr;
        font-size: 14px;
    }

    .ledger-label {
        font-size: 15px;
    }

    .cipher-gutter {
        display: none;
    }
}
