/* =====================================================================
   judge.club — The Court in the Clouds
   black-tie command-line · luxurious tech-mono · triadic palette
   ===================================================================== */

:root {
    /* Triadic primaries */
    --court-midnight: #1B2A41;
    --walnut-cordovan: #41281B;
    --verdigris-pine: #2A411B;

    /* Triadic accents */
    --brass-witness: #C9A65C;
    --vellum: #E8DCC4;
    --pre-dawn: #0C141F;
    --grain-warm: #F4ECD8;

    --rail-width: 15.6vw;
    --rail-min-width: 240px;

    --cadence: 65ms;
    --ease-typewriter: cubic-bezier(0.16, 0.84, 0.44, 1);
}

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

html, body {
    background: var(--pre-dawn);
    color: var(--vellum);
    font-family: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.55;
    letter-spacing: 0.02em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    background: var(--pre-dawn);
}

/* Selection */
::selection {
    background: var(--brass-witness);
    color: var(--court-midnight);
}

/* =============================================
   Mountain Ridge Stage (sticky background)
   ============================================= */
#ridge-stage {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: linear-gradient(180deg, var(--pre-dawn) 0%, var(--court-midnight) 62%, #0e1726 100%);
    overflow: hidden;
}

#ridge-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#ridge-layers polyline {
    fill: none;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

#ridge-layers .ridge-fill {
    stroke: none;
}

/* =============================================
   Grain Overlay
   ============================================= */
#grain-canvas {
    position: fixed;
    inset: 0;
    z-index: 90;
    width: 100%;
    height: 100%;
    pointer-events: none;
    mix-blend-mode: overlay;
    opacity: 0.5;
}

/* =============================================
   Justice Rail (15.6% left, fixed)
   ============================================= */
#justice-rail {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--rail-width);
    min-width: var(--rail-min-width);
    z-index: 50;
    background: linear-gradient(180deg, rgba(12,20,31,0.94) 0%, rgba(27,42,65,0.88) 100%);
    border-right: 1px solid rgba(232, 220, 196, 0.18);
    backdrop-filter: blur(2px);
    overflow-y: auto;
    overflow-x: hidden;
}

.rail-inner {
    padding: 28px 22px 24px 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 100%;
}

.rail-medallion-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

#medallion {
    flex-shrink: 0;
    animation: medallion-rotate 900s linear infinite;
    transform-origin: center;
    filter: drop-shadow(0 0 6px rgba(201, 166, 92, 0.18));
}

@keyframes medallion-rotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.rail-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.18em;
    color: var(--vellum);
    text-transform: uppercase;
    font-feature-settings: "smcp";
}

.rail-sub {
    font-size: 9px;
    letter-spacing: 0.26em;
    color: var(--brass-witness);
    text-transform: uppercase;
    margin-top: -10px;
    margin-left: 2px;
    opacity: 0.86;
}

.rail-divider {
    height: 1px;
    background: var(--vellum);
    opacity: 0.3;
    margin: 4px 0 6px 0;
    transform-origin: left center;
    animation: hairline-type 1.6s var(--ease-typewriter) 0.4s both;
}

@keyframes hairline-type {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

.rail-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0;
}

.rail-key {
    font-size: 9px;
    letter-spacing: 0.22em;
    color: var(--brass-witness);
    text-transform: uppercase;
    opacity: 0.78;
}

.rail-val {
    font-size: 12px;
    letter-spacing: 0.04em;
    color: var(--vellum);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    word-break: break-all;
}

.rail-numeral {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--brass-witness);
    line-height: 1;
    transition: opacity 0.3s var(--ease-typewriter);
}

#progress-bar {
    font-family: 'IBM Plex Mono', monospace;
    color: var(--brass-witness);
    letter-spacing: 0;
    font-size: 11px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    max-width: 100%;
}

.rail-toggle {
    cursor: pointer;
    user-select: none;
    color: var(--vellum);
    transition: color 0.2s linear;
}

.rail-toggle:hover {
    color: var(--brass-witness);
}

.rail-typewriter {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed rgba(232,220,196,0.18);
}

#typewriter-svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 200px;
    transition: filter 0.4s var(--ease-typewriter);
}

#typewriter-platen-group {
    transform-origin: 240px 105px;
    transition: transform 0.6s var(--ease-typewriter);
}

.typewriter-caption {
    font-size: 8px;
    letter-spacing: 0.3em;
    color: var(--brass-witness);
    text-align: center;
    margin-top: 6px;
    opacity: 0.7;
    text-transform: uppercase;
}

.rail-foot {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px dashed rgba(232,220,196,0.16);
    text-align: left;
}

.rail-foot-line {
    font-size: 9px;
    letter-spacing: 0.32em;
    color: var(--vellum);
    opacity: 0.5;
    line-height: 1.7;
    text-transform: uppercase;
}

/* =============================================
   Main Stage / Scenes
   ============================================= */
#stage {
    position: relative;
    z-index: 10;
    margin-left: var(--rail-width);
    width: calc(100% - var(--rail-width));
    scroll-snap-type: y proximity;
    overflow-y: visible;
}

.scene {
    position: relative;
    min-height: 100vh;
    padding: 92px 7vw 92px 7vw;
    scroll-snap-align: start;
    scroll-snap-stop: normal;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-bottom: 1px solid rgba(232, 220, 196, 0.06);
    overflow: hidden;
    transition: opacity 0.8s linear;
}

/* Different scene atmospheric tints (subtle) */
.scene-i  { background: linear-gradient(180deg, rgba(12,20,31,0.0) 0%, rgba(12,20,31,0.18) 100%); }
.scene-ii { background: linear-gradient(180deg, rgba(27,42,65,0.10) 0%, rgba(27,42,65,0.25) 100%); }
.scene-iii{ background: linear-gradient(180deg, rgba(27,42,65,0.18) 0%, rgba(65,40,27,0.12) 100%); }
.scene-iv { background: linear-gradient(180deg, rgba(42,65,27,0.06) 0%, rgba(27,42,65,0.22) 100%); }
.scene-v  { background: linear-gradient(180deg, rgba(27,42,65,0.30) 0%, rgba(12,20,31,0.42) 100%); }
.scene-vi { background: linear-gradient(180deg, rgba(12,20,31,0.36) 0%, rgba(27,42,65,0.30) 100%); }
.scene-vii{ background: linear-gradient(180deg, rgba(12,20,31,0.5) 0%, rgba(27,42,65,0.36) 100%); }

/* Art-deco corner brackets */
.scene-bracket {
    position: absolute;
    width: 36px;
    height: 36px;
    border-color: var(--brass-witness);
    border-style: solid;
    border-width: 0;
    pointer-events: none;
    opacity: 0.85;
}
.scene-bracket.tl { top: 28px; left: 28px; border-top-width: 1px; border-left-width: 1px; }
.scene-bracket.tr { top: 28px; right: 28px; border-top-width: 1px; border-right-width: 1px; }
.scene-bracket.bl { bottom: 28px; left: 28px; border-bottom-width: 1px; border-left-width: 1px; }
.scene-bracket.br { bottom: 28px; right: 28px; border-bottom-width: 1px; border-right-width: 1px; }

/* Scene meta header */
.scene-meta {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 36px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(232, 220, 196, 0.14);
    flex-wrap: wrap;
}

.scene-numeral {
    font-size: 11px;
    letter-spacing: 0.32em;
    color: var(--brass-witness);
    text-transform: uppercase;
    font-feature-settings: "smcp";
    font-weight: 700;
}

.scene-dot {
    color: var(--brass-witness);
    opacity: 0.6;
    font-size: 11px;
}

.scene-latin {
    font-style: italic;
    font-weight: 400;
    font-size: 14px;
    letter-spacing: 0.2em;
    color: var(--vellum);
    text-transform: uppercase;
}

.scene-trans {
    font-size: 10px;
    letter-spacing: 0.18em;
    color: var(--vellum);
    opacity: 0.5;
    font-style: italic;
    text-transform: lowercase;
}

/* Scene heading — verdict-grade type */
.scene-heading {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 700;
    font-size: clamp(2rem, 5.4vw, 4.6rem);
    line-height: 1.05;
    letter-spacing: 0.04em;
    color: var(--vellum);
    text-transform: uppercase;
    font-feature-settings: "smcp";
    margin-bottom: 0.4em;
}

.scene-i .scene-heading {
    font-size: clamp(2.4rem, 6.2vw, 5.6rem);
    color: var(--vellum);
    text-shadow: 0 0 24px rgba(201, 166, 92, 0.04);
}

/* =============================================
   Generic blocks with prime-number offsets
   ============================================= */
.scene-body {
    display: flex;
    flex-direction: column;
    gap: 28px;
    max-width: 100%;
    flex: 1;
    justify-content: center;
}

.block {
    max-width: 760px;
}

/* Prime-number column offsets (8/12-column rhythm, 1 col = 8.333%) */
.block-offset-1  { margin-left: calc(1 * 8.333%); }
.block-offset-3  { margin-left: calc(3 * 4.166%); }
.block-offset-5  { margin-left: calc(5 * 4.166%); }
.block-offset-7  { margin-left: calc(7 * 4.166%); }
.block-offset-11 { margin-left: calc(11 * 4.166%); max-width: 540px; }

/* Reset offsets on scene I to keep heading prominent */
.scene-i .block-offset-1 { margin-left: 0; }

/* Scene paragraphs */
.scene-lede {
    font-size: clamp(1rem, 1.5vw, 1.18rem);
    line-height: 1.55;
    color: var(--vellum);
    letter-spacing: 0.03em;
    max-width: 640px;
}

.scene-para {
    font-size: clamp(0.95rem, 1.15vw, 1.05rem);
    line-height: 1.7;
    color: var(--vellum);
    max-width: 660px;
    letter-spacing: 0.025em;
}

.scene-aside {
    font-size: 0.95rem;
    color: var(--brass-witness);
    line-height: 1.6;
    max-width: 540px;
    letter-spacing: 0.03em;
    opacity: 0.9;
}

.scene-aside em {
    font-style: italic;
    color: var(--brass-witness);
}

.scene-quiet {
    font-size: 0.85rem;
    color: var(--vellum);
    opacity: 0.62;
    line-height: 1.7;
    letter-spacing: 0.04em;
    max-width: 520px;
    font-style: italic;
}

/* Ridge caption + hairline */
.ridge-caption {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 10px;
    letter-spacing: 0.24em;
    color: var(--brass-witness);
    text-transform: uppercase;
    opacity: 0.8;
}

.hairline-typed {
    flex: 0 0 96px;
    height: 1px;
    background: var(--vellum);
    opacity: 0.3;
    transform-origin: left center;
    transform: scaleX(0);
    animation: hairline-type 1.4s var(--ease-typewriter) 1.2s forwards;
}

.caption-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
}

/* =============================================
   Typed underline (the only "button" form)
   ============================================= */
.typed-underline {
    position: relative;
    color: var(--brass-witness);
    cursor: pointer;
    padding: 0 1px;
    transition: color 0.2s linear;
    border-bottom: 1px dashed rgba(201, 166, 92, 0.55);
}

.typed-underline:hover {
    color: var(--vellum);
    border-bottom-color: var(--vellum);
}

/* =============================================
   Scene III — Pillars
   ============================================= */
.pillar-stack {
    display: flex;
    flex-direction: column;
    gap: 36px;
    margin-top: 28px;
}

.pillar {
    max-width: 600px;
    border-left: 1px solid var(--brass-witness);
    padding-left: 22px;
    position: relative;
}

.pillar-offset-1 { margin-left: calc(1 * 4.166%); }
.pillar-offset-5 { margin-left: calc(5 * 4.166%); }
.pillar-offset-7 { margin-left: calc(7 * 4.166%); }

.pillar-numeral {
    position: absolute;
    left: -3px;
    top: -2px;
    font-size: 10px;
    color: var(--brass-witness);
    letter-spacing: 0.18em;
    background: var(--pre-dawn);
    padding: 0 4px;
    transform: translateX(-100%);
    margin-right: 8px;
    font-weight: 700;
}

.pillar-title {
    font-size: clamp(1.2rem, 2.2vw, 1.7rem);
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--vellum);
    margin-bottom: 0.4em;
    font-feature-settings: "smcp";
    text-transform: uppercase;
}

.pillar-text {
    font-size: 0.96rem;
    color: var(--vellum);
    opacity: 0.86;
    line-height: 1.65;
    letter-spacing: 0.025em;
}

/* =============================================
   Scene IV — Re-draw affordance
   ============================================= */
.redraw-block {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 32px;
}

.redraw-prompt {
    font-size: 11px;
    letter-spacing: 0.32em;
    color: var(--brass-witness);
    opacity: 0.85;
    text-transform: uppercase;
}

.typed-affordance {
    background: transparent;
    border: none;
    color: var(--vellum);
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(1.1rem, 2vw, 1.55rem);
    font-weight: 700;
    letter-spacing: 0.18em;
    cursor: pointer;
    padding: 14px 0;
    text-align: left;
    transition: color 0.2s linear, letter-spacing 0.3s var(--ease-typewriter);
    width: max-content;
    text-transform: uppercase;
    font-feature-settings: "smcp";
}

.typed-affordance .bracket {
    color: var(--brass-witness);
    margin: 0 8px;
    transition: transform 0.3s var(--ease-typewriter);
    display: inline-block;
}

.typed-affordance:hover {
    color: var(--brass-witness);
    letter-spacing: 0.22em;
}

.typed-affordance:hover .bracket {
    transform: scaleY(1.15);
}

.typed-affordance:active {
    color: var(--vellum);
}

.redraw-meta {
    font-size: 10px;
    letter-spacing: 0.24em;
    color: var(--vellum);
    opacity: 0.6;
    display: flex;
    gap: 10px;
}

.meta-key { color: var(--brass-witness); }
.meta-val { color: var(--vellum); font-variant-numeric: tabular-nums; }

/* =============================================
   Scene V — Sub Rosa
   ============================================= */
.scene-v {
    position: relative;
}

#sub-rosa-rose {
    position: absolute;
    bottom: 80px;
    right: 80px;
    width: 120px;
    height: 120px;
    cursor: pointer;
    transition: transform 0.7s var(--ease-typewriter), opacity 0.4s linear;
    opacity: 0.55;
}

#sub-rosa-rose:hover {
    transform: rotate(7deg);
    opacity: 1;
}

.rose-reveal {
    position: absolute;
    bottom: 80px;
    right: 220px;
    font-size: 11px;
    letter-spacing: 0.28em;
    color: var(--verdigris-pine);
    text-transform: uppercase;
    font-feature-settings: "smcp";
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s linear;
    color: var(--brass-witness);
    max-width: 320px;
    text-align: right;
}

.rose-reveal.is-revealed {
    opacity: 1;
}

/* =============================================
   Scene VI — Obiter Dictum
   ============================================= */
.dictum-stack {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 24px;
}

.dictum {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    max-width: 640px;
}

.dictum-offset-1 { margin-left: calc(1 * 4.166%); }
.dictum-offset-3 { margin-left: calc(3 * 4.166%); }
.dictum-offset-5 { margin-left: calc(5 * 4.166%); }
.dictum-offset-7 { margin-left: calc(7 * 4.166%); }

.dictum-glyph {
    flex: 0 0 36px;
    font-size: 10px;
    letter-spacing: 0.18em;
    color: var(--brass-witness);
    padding-top: 4px;
    font-weight: 700;
}

.dictum-text {
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--vellum);
    opacity: 0.84;
    letter-spacing: 0.03em;
}

.dictum-text em {
    font-style: italic;
    color: var(--vellum);
}

/* =============================================
   Scene VII — Res Iudicata (the verdict)
   ============================================= */
.scene-body-vii {
    align-items: flex-start;
    gap: 56px;
}

.verdict-frame {
    position: relative;
    margin-left: calc(1 * 4.166%);
    max-width: 90%;
    padding: 36px 0;
}

.verdict-pre {
    font-size: 11px;
    letter-spacing: 0.42em;
    color: var(--brass-witness);
    text-transform: uppercase;
    margin-bottom: 18px;
    opacity: 0.9;
}

.verdict {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 700;
    font-size: clamp(3rem, 11vw, 9rem);
    letter-spacing: 0.05em;
    color: var(--vellum);
    text-transform: uppercase;
    line-height: 0.95;
    margin-bottom: 14px;
    text-shadow: 0 0 32px rgba(232, 220, 196, 0.06);
}

.verdict-strike {
    height: 0.5px;
    background: var(--brass-witness);
    width: 0%;
    opacity: 0.85;
    margin-top: 6px;
    margin-bottom: 22px;
    transition: width 1.2s var(--ease-typewriter);
}

.verdict-frame.is-struck .verdict-strike {
    width: 100%;
}

.verdict-trail {
    font-size: 0.95rem;
    color: var(--vellum);
    opacity: 0.75;
    letter-spacing: 0.04em;
    line-height: 1.7;
    max-width: 620px;
    font-style: italic;
}

/* Application form */
.application-frame {
    margin-left: calc(3 * 4.166%);
    max-width: 720px;
    padding: 28px 0;
    border-top: 1px dashed rgba(232,220,196,0.16);
    border-bottom: 1px dashed rgba(232,220,196,0.16);
}

.application-prompt {
    font-size: 12px;
    letter-spacing: 0.28em;
    color: var(--brass-witness);
    text-transform: uppercase;
    margin-bottom: 18px;
    font-weight: 700;
}

#application-form {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.1rem;
    color: var(--vellum);
}

.prompt-arrow {
    color: var(--brass-witness);
    font-weight: 700;
    font-size: 1.2rem;
}

#application-input {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(232,220,196,0.4);
    color: var(--vellum);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.1rem;
    letter-spacing: 0.06em;
    padding: 8px 4px;
    outline: none;
    text-transform: uppercase;
}

#application-input:focus {
    border-bottom-color: var(--brass-witness);
}

.prompt-cursor {
    color: var(--brass-witness);
    font-size: 1.1rem;
    animation: selectric-blink 1.06s steps(2, end) infinite;
}

@keyframes selectric-blink {
    0%, 49.99%   { opacity: 1; }
    50%, 100%    { opacity: 0; }
}

#application-receipt {
    margin-top: 18px;
    font-size: 11px;
    letter-spacing: 0.18em;
    color: var(--brass-witness);
    min-height: 18px;
    text-transform: uppercase;
}

.closing-line {
    margin-top: 32px;
    margin-left: calc(1 * 4.166%);
    font-size: 10px;
    letter-spacing: 0.26em;
    color: var(--vellum);
    opacity: 0.5;
    text-transform: uppercase;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.closing-dot {
    color: var(--brass-witness);
    opacity: 0.8;
}

/* =============================================
   Typewriter Animation Helpers
   ============================================= */
[data-typewriter] {
    opacity: 1;
    will-change: contents;
}

[data-typewriter] .tw-char {
    display: inline-block;
    opacity: 0;
    transform: translateY(0px);
    animation: tw-char-in 0ms linear forwards;
}

[data-typewriter] .tw-char.tw-visible {
    opacity: 1;
}

@keyframes tw-char-in {
    from { opacity: 0; transform: translateY(0.6px); }
    to   { opacity: 1; transform: translateY(0); }
}

[data-typewriter].is-pending {
    visibility: hidden;
}

[data-typewriter].is-typing,
[data-typewriter].is-done {
    visibility: visible;
}

.tw-cursor {
    display: inline-block;
    width: 0.55em;
    background: var(--vellum);
    color: transparent;
    margin-left: 1px;
    height: 1em;
    line-height: 1;
    vertical-align: -0.12em;
    animation: selectric-blink 1.06s steps(2, end) infinite;
}

/* =============================================
   Scene fade-out for past scenes (stay at 0.18)
   ============================================= */
.scene.is-past {
    opacity: 0.62;
}

.scene.is-active {
    opacity: 1;
}

/* =============================================
   Responsive — keep rail-essence even when smaller
   ============================================= */
@media (max-width: 900px) {
    :root {
        --rail-width: 220px;
    }

    .scene {
        padding: 80px 6vw 80px 6vw;
    }

    .block-offset-1, .block-offset-3, .block-offset-5,
    .block-offset-7, .block-offset-11,
    .pillar-offset-1, .pillar-offset-5, .pillar-offset-7,
    .dictum-offset-1, .dictum-offset-3, .dictum-offset-5, .dictum-offset-7 {
        margin-left: 0;
    }

    .verdict-frame, .application-frame, .closing-line {
        margin-left: 0;
    }

    #sub-rosa-rose {
        bottom: 40px;
        right: 40px;
        width: 80px;
        height: 80px;
    }

    .rose-reveal {
        right: 40px;
        bottom: 130px;
    }
}

@media (max-width: 640px) {
    #justice-rail {
        position: relative;
        width: 100%;
        min-width: 0;
        height: auto;
        border-right: none;
        border-bottom: 1px solid rgba(232,220,196,0.18);
    }

    .rail-inner {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 14px;
        padding: 16px;
    }

    .rail-typewriter, .rail-foot {
        display: none;
    }

    #stage {
        margin-left: 0;
        width: 100%;
    }

    .scene-heading {
        font-size: clamp(1.6rem, 8vw, 2.6rem);
    }

    .verdict {
        font-size: clamp(2.4rem, 14vw, 4rem);
    }
}
