/* ppss.ee v2 — Frost-Station Console (sci-fi field station, peat ground, translucent frost) */
/*
 * Design tokens reference:
 *   Palette: #141812 peat-ground / #2A3128 lichen-mid / #DCE4E0 frost-glass-base /
 *            #E8EDE6 rime-white / #6F8B5A pine-signal / #C9B98E birch-bark /
 *            #C26A3F cold-ember.
 *   Frost glass slabs composite #DCE4E0 at 8% alpha over the peat ground.
 *   Typography:
 *     Callsign / display:  "Jost" weight 500 (Futura-geometric)
 *     Body / station log:  "Inter" weight 400
 *     Mono / readouts:     "JetBrains Mono" weight 400
 *   Reveal: IntersectionObserver tied to a slide-reveal class. Blocks anchored to
 *   the left columns slide-reveal from the left margin; right-anchored from the right;
 *   top-anchored full-width blocks from above. 140ms stagger.
 */

:root {
    --peat-ground: #141812;
    --lichen-mid: #2A3128;
    --frost-glass: rgba(220, 228, 224, 0.08);
    --frost-glass-fallback: rgba(220, 228, 224, 0.10);
    --frost-edge: rgba(220, 228, 224, 0.32);
    --frost-edge-hover: rgba(220, 228, 224, 0.55);
    --rime-white: #E8EDE6;
    --rime-white-dim: rgba(232, 237, 230, 0.62);
    --pine-signal: #6F8B5A;
    --birch-bark: #C9B98E;
    --cold-ember: #C26A3F;
    --rime-particle: rgba(232, 237, 230, 0.30);
    --bevel-highlight: rgba(255, 255, 255, 0.06);

    --font-callsign: 'Jost', 'Futura', 'Trebuchet MS', sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Menlo', 'Consolas', monospace;

    --ease-frost: cubic-bezier(0.2, 0.7, 0.1, 1);
    --reveal-duration: 700ms;

    --peat-margin: 40px;
    --rail-height: 28px;
}

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

html, body {
    background: var(--peat-ground);
    color: var(--rime-white);
    font-family: var(--font-body);
    font-size: clamp(15px, 1.05vw, 17px);
    line-height: 1.65;
    overflow-x: hidden;
    min-height: 100vh;
}

body {
    position: relative;
    padding: var(--peat-margin);
    padding-top: calc(var(--rail-height) + var(--peat-margin));
    padding-bottom: calc(var(--rail-height) + var(--peat-margin));
}

/* Peat ground + noise overlay */
.peat-ground {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 30% 20%, #1a1f17 0%, var(--peat-ground) 55%, #0d1009 100%);
    z-index: -2;
    pointer-events: none;
}

.peat-ground::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.91  0 0 0 0 0.93  0 0 0 0 0.90  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
    background-size: 220px 220px;
    opacity: 1;
    pointer-events: none;
    mix-blend-mode: screen;
}

/* Particle canvas */
.particle-canvas {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

/* Status rails (fixed top/bottom) */
.status-rail {
    position: fixed;
    left: 0;
    right: 0;
    height: var(--rail-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--peat-margin);
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.05em;
    color: var(--birch-bark);
    z-index: 80;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(20, 24, 18, 0.85), rgba(20, 24, 18, 0.4));
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.status-rail--top {
    top: 0;
    border-bottom: 1px solid var(--frost-edge);
}

.status-rail--bottom {
    bottom: 0;
    border-top: 1px solid var(--frost-edge);
    background: linear-gradient(to top, rgba(20, 24, 18, 0.85), rgba(20, 24, 18, 0.4));
}

.rail-segment {
    white-space: nowrap;
    opacity: 0.88;
}

.rail-center {
    color: var(--rime-white-dim);
    flex: 1;
    text-align: center;
    transition: color 200ms ease;
}

.rail-left {
    color: var(--birch-bark);
}

.rail-right {
    color: var(--rime-white-dim);
}

#rail-typed {
    min-width: 220px;
}

#rail-typed::after {
    content: "";
    display: inline-block;
    width: 6px;
    height: 11px;
    background: var(--birch-bark);
    margin-left: 3px;
    vertical-align: -1px;
    animation: blink-caret 900ms steps(1) infinite;
}

@keyframes blink-caret {
    50% { opacity: 0; }
}

/* Console main wrapper */
.console {
    position: relative;
    max-width: 1180px;
    margin: 0 auto;
    z-index: 1;
}

/* Slabs - common base */
.slab {
    position: relative;
    background: var(--frost-glass);
    backdrop-filter: blur(14px) saturate(1.1);
    -webkit-backdrop-filter: blur(14px) saturate(1.1);
    border: 1px solid var(--frost-edge);
    box-shadow:
        inset 0 1px 0 var(--bevel-highlight),
        0 4px 16px -8px rgba(0, 0, 0, 0.45);
    padding: 30px;
    color: var(--rime-white);
    transition:
        border-color 200ms ease-out,
        box-shadow 280ms ease-out,
        transform 240ms var(--ease-frost);
    overflow: hidden;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .slab {
        background: var(--frost-glass-fallback);
    }
}

.slab:hover {
    border-color: var(--frost-edge-hover);
    box-shadow:
        inset 0 1px 0 var(--bevel-highlight),
        0 4px 16px -8px rgba(0, 0, 0, 0.45),
        0 0 32px -12px var(--pine-signal);
}

.slab:hover .corner-tick {
    border-color: var(--frost-edge-hover);
    border-width: 2px;
}

/* Corner ticks */
.corner-tick {
    position: absolute;
    width: 10px;
    height: 10px;
    border: 1px solid var(--frost-edge);
    transition: border 200ms ease-out;
    pointer-events: none;
}

.tick-tl { top: 4px; left: 4px; border-right: none; border-bottom: none; }
.tick-tr { top: 4px; right: 4px; border-left: none; border-bottom: none; }
.tick-bl { bottom: 4px; left: 4px; border-right: none; border-top: none; }
.tick-br { bottom: 4px; right: 4px; border-left: none; border-top: none; }

/* Screw glyphs */
.screw-glyph {
    position: absolute;
    width: 8px;
    height: 8px;
    color: var(--frost-edge);
    opacity: 0.7;
    pointer-events: none;
}

.screw-tl { top: 14px; left: 14px; }
.screw-tr { top: 14px; right: 14px; }
.screw-bl { bottom: 14px; left: 14px; }
.screw-br { bottom: 14px; right: 14px; }

/* Reveal motion */
[data-reveal] {
    opacity: 0;
    will-change: transform, opacity;
    transition:
        opacity var(--reveal-duration) var(--ease-frost),
        transform var(--reveal-duration) var(--ease-frost),
        border-color 200ms ease-out,
        box-shadow 280ms ease-out;
}

[data-reveal="left"] { transform: translateX(-72px); }
[data-reveal="right"] { transform: translateX(72px); }
[data-reveal="top"] { transform: translateY(-88px); }

[data-reveal].is-mounted {
    opacity: 1;
    transform: translate(0, 0);
}

/* ============== CONSOLE HERO ============== */
.console-hero {
    min-height: calc(100vh - var(--rail-height) * 2 - var(--peat-margin) * 2);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    position: relative;
}

.hero-slab {
    position: relative;
    width: 100%;
    padding: clamp(40px, 6vw, 80px);
    background: var(--frost-glass);
    backdrop-filter: blur(18px) saturate(1.1);
    -webkit-backdrop-filter: blur(18px) saturate(1.1);
    border: 1px solid var(--frost-edge);
    box-shadow:
        inset 0 1px 0 var(--bevel-highlight),
        0 8px 32px -12px rgba(0, 0, 0, 0.6);
    transition: border-color 200ms ease-out, box-shadow 280ms ease-out;
}

.hero-slab:hover {
    border-color: var(--frost-edge-hover);
    box-shadow:
        inset 0 1px 0 var(--bevel-highlight),
        0 8px 32px -12px rgba(0, 0, 0, 0.6),
        0 0 48px -16px var(--pine-signal);
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: left;
}

.hero-prefix {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.18em;
    color: var(--birch-bark);
    margin-bottom: 24px;
    opacity: 0.85;
}

.hero-prefix::before {
    content: "";
    display: inline-block;
    width: 24px;
    height: 1px;
    background: var(--birch-bark);
    vertical-align: 3px;
    margin-right: 10px;
    opacity: 0.7;
}

.hero-callsign {
    font-family: var(--font-callsign);
    font-weight: 500;
    font-size: clamp(56px, 8vw, 132px);
    letter-spacing: 0.18em;
    line-height: 0.95;
    text-transform: lowercase;
    color: var(--rime-white);
    margin-bottom: 28px;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}

.hero-line {
    width: 0;
    height: 1px;
    background: var(--frost-edge);
    margin: 24px 0 32px 0;
    animation: line-draw 800ms var(--ease-frost) 800ms forwards;
}

@keyframes line-draw {
    to { width: 100%; }
}

.hero-meta {
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.05em;
    color: var(--rime-white-dim);
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
}

.hero-coord {
    text-transform: uppercase;
}

.hero-sep {
    color: var(--frost-edge);
}

/* ============== FIELD LOG ============== */
.field-log {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: auto;
    gap: 24px;
    margin: 96px 0;
    position: relative;
}

.slab-log {
    padding: 32px;
}

.slab--left {
    grid-column: 1 / span 7;
}

.slab--right {
    grid-column: 6 / span 7;
}

.slab--full {
    grid-column: 1 / -1;
}

.slab--small-left {
    grid-column: 1 / span 5;
}

.slab--small-right {
    grid-column: 7 / span 6;
}

.slab-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--frost-edge);
    gap: 16px;
    flex-wrap: wrap;
}

.slab-index {
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.08em;
    color: var(--birch-bark);
    text-transform: uppercase;
}

.slab-title {
    font-family: var(--font-callsign);
    font-weight: 400;
    font-size: clamp(20px, 2.2vw, 30px);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--rime-white);
}

.slab-grid {
    display: grid;
    grid-template-columns: 1fr 80px;
    gap: 28px;
    align-items: start;
}

.slab-grid--wide {
    grid-template-columns: 2fr 1fr;
    gap: 36px;
}

.slab-prose p {
    color: var(--rime-white);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.65;
    margin-bottom: 12px;
}

.slab-prose p:last-child {
    margin-bottom: 0;
}

.slab-prose em {
    font-style: italic;
    color: var(--rime-white-dim);
}

/* Cold ember accent — used very sparingly */
.ember {
    color: var(--cold-ember);
    border-bottom: 1px solid var(--cold-ember);
    padding-bottom: 1px;
}

/* Glyphs in field-log */
.slab-glyph {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--pine-signal);
    transition: transform 200ms ease;
}

.slab-glyph:hover {
    transform: translateY(-1px);
}

.glyph-svg {
    width: 80px;
    height: 80px;
    display: block;
}

.glyph-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--birch-bark);
    text-transform: uppercase;
}

/* Readout block (full-bleed log) */
.slab-readout {
    padding: 20px;
    border: 1px solid var(--frost-edge);
    background: rgba(20, 24, 18, 0.35);
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.05em;
    color: var(--rime-white-dim);
}

.readout-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(220, 228, 224, 0.12);
}

.readout-row:last-child { border-bottom: none; }

.readout-key {
    color: var(--birch-bark);
}

.readout-val {
    color: var(--rime-white);
}

/* Specimen window (inset noise) */
.specimen-window {
    margin-top: 22px;
    height: 64px;
    border: 1px solid var(--frost-edge);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='80'><filter id='n2'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.91  0 0 0 0 0.93  0 0 0 0 0.90  0 0 0 0.10 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n2)'/></svg>");
    background-size: 220px 80px;
    background-color: rgba(42, 49, 40, 0.5);
    position: relative;
    overflow: hidden;
}

.specimen-window::after {
    content: "SPECIMEN.WIN";
    position: absolute;
    top: 6px;
    right: 8px;
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.1em;
    color: var(--birch-bark);
    opacity: 0.7;
}

.specimen-window--small {
    height: 48px;
}

/* ============== INSTRUMENT BAY ============== */
.instrument-bay {
    margin: 120px 0;
}

.bay-header {
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--frost-edge);
}

.bay-index {
    display: block;
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.08em;
    color: var(--birch-bark);
    margin-bottom: 10px;
}

.bay-title {
    font-family: var(--font-callsign);
    font-weight: 400;
    font-size: clamp(22px, 2.6vw, 36px);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--rime-white);
}

.bay-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.slab-instrument {
    aspect-ratio: 1 / 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
}

.instrument-glyph {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pine-signal);
    transition: transform 220ms ease;
}

.slab-instrument:hover .instrument-glyph {
    transform: translateY(-1px);
}

.slab-instrument:hover .glyph-svg-lg {
    filter: drop-shadow(0 0 8px rgba(111, 139, 90, 0.5));
}

.glyph-svg-lg {
    width: 72%;
    height: auto;
    max-width: 120px;
    display: block;
    transition: filter 200ms ease;
}

.instrument-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.05em;
    padding-top: 14px;
    border-top: 1px solid var(--frost-edge);
}

.instrument-id {
    color: var(--birch-bark);
}

.instrument-name {
    color: var(--rime-white);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ============== ENDPAPER CONSOLE ============== */
.endpaper-console {
    margin: 96px 0 40px 0;
}

.slab-endpaper {
    padding: 40px clamp(28px, 4vw, 56px);
    position: relative;
}

.endpaper-heartbeat {
    position: absolute;
    top: 50%;
    left: 30px;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cold-ember);
    box-shadow: 0 0 16px 2px rgba(194, 106, 63, 0.5);
    opacity: 0.6;
    animation: heartbeat 1800ms ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { opacity: 0.45; transform: translateY(-50%) scale(0.9); }
    50% { opacity: 0.9; transform: translateY(-50%) scale(1.1); }
}

.endpaper-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
    padding-bottom: 18px;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--frost-edge);
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--rime-white-dim);
}

.endpaper-callsign {
    font-family: var(--font-callsign);
    font-weight: 500;
    letter-spacing: 0.18em;
    color: var(--rime-white);
    font-size: 18px;
}

.endpaper-sep {
    color: var(--frost-edge);
}

.endpaper-coord {
    color: var(--birch-bark);
}

.endpaper-rev {
    color: var(--rime-white-dim);
}

.endpaper-readout {
    margin-bottom: 22px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.04em;
}

.endpaper-line {
    display: flex;
    align-items: baseline;
    gap: 18px;
    color: var(--rime-white);
    transition: color 200ms ease-out;
    cursor: default;
}

.endpaper-line:hover {
    color: var(--birch-bark);
}

.endpaper-key {
    color: var(--pine-signal);
    flex-shrink: 0;
    min-width: 96px;
}

.endpaper-val {
    color: inherit;
}

.endpaper-foot {
    display: flex;
    justify-content: space-between;
    padding-top: 18px;
    border-top: 1px solid var(--frost-edge);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    color: var(--birch-bark);
    text-transform: uppercase;
}

/* ============== RESPONSIVE ============== */
@media (max-width: 900px) {
    :root {
        --peat-margin: 22px;
    }

    .slab--left,
    .slab--right,
    .slab--full,
    .slab--small-left,
    .slab--small-right {
        grid-column: 1 / -1;
    }

    .bay-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .slab-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .slab-grid--wide {
        grid-template-columns: 1fr;
    }

    .hero-slab {
        padding: 36px 24px;
    }

    .hero-meta {
        font-size: 10.5px;
    }

    .status-rail {
        font-size: 10px;
    }

    .rail-center {
        display: none;
    }
}

@media (max-width: 540px) {
    .bay-grid {
        grid-template-columns: 1fr;
    }

    .hero-callsign {
        letter-spacing: 0.12em;
    }

    .endpaper-line {
        flex-direction: column;
        gap: 2px;
    }

    .endpaper-key {
        min-width: 0;
    }
}

/* Reduced motion: still reveal, but no transforms */
@media (prefers-reduced-motion: reduce) {
    [data-reveal] {
        opacity: 1 !important;
        transform: none !important;
        transition: none;
    }

    .hero-line {
        width: 100%;
        animation: none;
    }

    .endpaper-heartbeat,
    #rail-typed::after {
        animation: none;
    }
}
