/* ==========================================================================
   Vacuum fluorescent display touches: thin lit lines, a slight flicker and a warm glow.
   Everything here is decoration. It stays quiet at rest and is off with reduced motion.
   ========================================================================== */

:root {
    /* The honeycomb mesh of a VFD grid, as a tile: 6 x 10.4 px, in the display colour. */
    --hex-12: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 10.392'%3E%3Cpath d='M0 1.732L3.0 0L6 1.732V5.196L3.0 6.928L0 5.196Z M3.0 6.928V10.392' fill='none' stroke='%23f6c64a' stroke-opacity='0.14' stroke-width='0.5'/%3E%3C/svg%3E");
    --hex-08: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 10.392'%3E%3Cpath d='M0 1.732L3.0 0L6 1.732V5.196L3.0 6.928L0 5.196Z M3.0 6.928V10.392' fill='none' stroke='%23f6c64a' stroke-opacity='0.1' stroke-width='0.5'/%3E%3C/svg%3E");
    --vfd-rgb: 246, 198, 74;
    --vfd: rgb(var(--vfd-rgb));
    --vfd-hot-rgb: 255, 122, 69;
    --vfd-hot: rgb(var(--vfd-hot-rgb));
}

/* ---------- Glow on the small lit parts ---------------------------------------------------- */

.chapter-index .roman,
.hero-project-index,
.item-idx .big-num,
.hero-copy h1 .mono-word,
.flow-num {
    text-shadow: 0 0 12px color-mix(in srgb, var(--tone, var(--armitage)) 40%, transparent);
}

.chapter-label,
.aside-label,
.sub-label,
.figure-bar>span:first-child {
    text-shadow: 0 0 8px rgba(var(--vfd-rgb), 0.18);
}

.figure,
.hero-art {
    position: relative;
}

.figure {
    box-shadow: 0 0 36px -16px rgba(var(--vfd-rgb), 0.22);
}

/* The header's second hairline breathes a little. */
.site-header::after {
    background: rgba(var(--vfd-rgb), 0.16);
    box-shadow: 0 0 8px rgba(var(--vfd-rgb), 0.18);
}

/* ---------- Flicker: a rare dip in brightness on a few small parts ------------------------ */

@media (prefers-reduced-motion: no-preference) {
    .vfd-flicker {
        animation: vfd-flicker var(--flicker-len, 9s) linear infinite;
        animation-delay: var(--flicker-delay, 0s);
    }

    @keyframes vfd-flicker {

        0%,
        90%,
        93%,
        96%,
        100% {
            opacity: 1;
        }

        91% {
            opacity: 0.72;
        }

        94% {
            opacity: 0.84;
        }

        95% {
            opacity: 0.66;
        }
    }
}

/* ---------- Scroll meter: the header's lower rule, cut into one lit segment per section --------- */

.vfd-meter {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    display: flex;
    gap: 6px;
    height: 2px;
    padding: 0 6px;
    pointer-events: none;
}

.vfd-step {
    flex: 1;
    background: rgba(var(--vfd-rgb), 0.16);
    transform: skewX(-30deg);
    transition: background 0.25s, box-shadow 0.25s;
}

.vfd-step.on {
    background: var(--vfd);
    box-shadow: 0 0 5px rgba(var(--vfd-rgb), 0.55);
}

.vfd-step.hot {
    background: var(--vfd-hot);
    box-shadow: 0 0 6px rgba(var(--vfd-hot-rgb), 0.7);
}

/* ==========================================================================
   A little more: slanted buttons, lit vertical rules, corner brackets, brighter headings.
   ========================================================================== */

/* ---------- Slanted buttons and tags (the style of "TONE MEMO") --------------------------- */

.to-top {
    --slant: var(--vfd);
    transform: skewX(-14deg);
    border: 1px solid color-mix(in srgb, var(--slant) 50%, transparent);
    border-radius: 1px;
    color: var(--slant);
    text-shadow: 0 0 8px color-mix(in srgb, var(--slant) 50%, transparent);
    box-shadow: 0 0 10px -4px color-mix(in srgb, var(--slant) 60%, transparent);
    background: transparent;
    transition: background 0.18s, box-shadow 0.18s, color 0.18s, border-color 0.18s, opacity 0.18s;
}

.to-top:hover,
.to-top:focus-visible {
    background-color: color-mix(in srgb, var(--slant) 16%, transparent);
    box-shadow: 0 0 14px -2px color-mix(in srgb, var(--slant) 70%, transparent);
    color: var(--slant);
    border-color: color-mix(in srgb, var(--slant) 80%, transparent);
}

/* The back-to-top square keeps its size; only its edges slant. */
.to-top {
    border-radius: 1px;
    opacity: 0.85;
    transform: skewX(-14deg);
}

.to-top:hover {
    opacity: 1;
}


.nav a:hover {
    text-shadow: 0 0 10px rgba(var(--vfd-rgb), 0.45);
}

.footer-links a:hover {
    text-shadow: 0 0 10px rgba(var(--vfd-rgb), 0.45);
}

/* ---------- Corner brackets on the windows, like the wiring in a schematic ---------------- */

.figure::before {
    content: "";
    position: absolute;
    inset: -1px;
    z-index: 3;
    pointer-events: none;
    --arm: 12px;
    background:
        linear-gradient(var(--vfd), var(--vfd)) 0 0 / var(--arm) 1px no-repeat,
        linear-gradient(var(--vfd), var(--vfd)) 0 0 / 1px var(--arm) no-repeat,
        linear-gradient(var(--vfd), var(--vfd)) 100% 0 / var(--arm) 1px no-repeat,
        linear-gradient(var(--vfd), var(--vfd)) 100% 0 / 1px var(--arm) no-repeat,
        linear-gradient(var(--vfd), var(--vfd)) 0 100% / var(--arm) 1px no-repeat,
        linear-gradient(var(--vfd), var(--vfd)) 0 100% / 1px var(--arm) no-repeat,
        linear-gradient(var(--vfd), var(--vfd)) 100% 100% / var(--arm) 1px no-repeat,
        linear-gradient(var(--vfd), var(--vfd)) 100% 100% / 1px var(--arm) no-repeat;
    opacity: 0.55;
    filter: drop-shadow(0 0 3px rgba(var(--vfd-rgb), 0.6));
}

/* ---------- Brighter headings ---------------------------------------------------------------- */

.chapter-header {
    background: linear-gradient(135deg,
            color-mix(in srgb, var(--tone) 8%, rgba(var(--glass-rgb), 0.03)),
            rgba(var(--glass-rgb), 0.02));
}

.chapter-head h2,
.sect-intro h3,
.items h4,
.hero-copy h1 {
    text-shadow: 0 0 22px rgba(var(--vfd-rgb), 0.14);
}

.chapter-links a:hover::after,
.hero-project:hover,
.chapter-cta:hover,
.crumb a:hover {
    text-shadow: 0 0 10px color-mix(in srgb, var(--tone, var(--vfd)) 55%, transparent);
}

/* Table headers and the dep strip read like the printed labels on the panel. */
.ledger-table th,
.dep-strip .label {
    text-shadow: 0 0 8px rgba(var(--vfd-rgb), 0.2);
}

/* A table row warms a little under the pointer. No edge line: it showed up as a stray vertical line. */
.ledger-table tbody tr {
    transition: background 0.2s;
}

.ledger-table tbody tr:hover {
    background: rgba(var(--vfd-rgb), 0.04);
}

/* ==========================================================================
   Tighter spacing between and inside sections.
   ========================================================================== */

.sect-intro {
    padding-top: 36px;
    padding-bottom: 36px;
}

.sect-body {
    padding-top: 36px;
    padding-bottom: 36px;
}

.sect--bare .sect-body,
.sect--stack .sect-body {
    padding-top: 24px;
    padding-bottom: 28px;
}

.sect--bare {
    padding-top: 8px;
}

.chapter+.chapter {
    margin-top: 0;
}

.sect-body>*+* {
    margin-top: 24px;
}

/* One fine dot mesh sits fixed to the screen, like the glass of an old display, and shows only inside
   these parts: it stays still while they scroll past (background-attachment: fixed). */
.to-top {
    background-image: var(--hex-12);
    background-size: 6px 10.392px;
    background-attachment: fixed;
}

/* On a project page there is no overview bar under the links, so the links column runs the full height
   of the header again and its divider reaches the bottom. */
@media (min-width: 961px) {
    .chapter-header .chapter-aside:not(:has(+ .chapter-cta)) {
        grid-row: 1 / 3;
    }
}

/* The project bars and the back bar are buttons as a whole, filled with the same fine dot mesh as the project
   headers (same colour and strength, on the same screen-fixed grid). The overview bar sits inside a project
   header, so it shows that header's mesh and adds no second one on top. */
.hero-project,
.hero-project:hover,
.crumb a,
.crumb a:hover {
    background-image: var(--hex-08);
    background-size: 6px 10.392px;
    background-attachment: fixed;
    transition: background-color 0.18s, color 0.18s;
}

.chapter-cta {
    transition: background-color 0.18s, color 0.18s;
}

.hero-project:hover,
.chapter-cta:hover,
.crumb a:hover {
    background-color: color-mix(in srgb, var(--tone, var(--vfd)) 12%, transparent);
}

/* A code window with a single file shows its name as a label, not as a button. */
.figure-file {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink);
    text-shadow: 0 0 8px rgba(var(--vfd-rgb), 0.18);
}

/* ==========================================================================
   Code, command, terminal and chat windows share one look: the same glass, type size,
   line height and padding. Only their contents differ.
   ========================================================================== */

.figure {
    border-radius: 8px;
}

.figure>.code,
.figure>.shell,
.figure>.tui,
.figure>.zp {
    background: transparent;
    font-size: 11.5px;
    line-height: 1.7;
}

.figure>.shell,
.figure>.tui {
    padding: 14px 16px 16px;
}

.figure>.code {
    padding: 14px 0 16px;
}

/* The current page in the nav is just lit; the whole header carries the fine dot mesh. */
.nav a[aria-current="page"] {
    color: var(--vfd);
    text-shadow: 0 0 9px rgba(var(--vfd-rgb), 0.5);
}

.nav a[aria-current="page"] .num {
    color: inherit;
}

.site-header {
    background-image: var(--hex-12);
    background-size: 6px 10.392px;
    background-attachment: fixed;
}

/* Back to top is a small key, like the ones in the header, with its own backing so it stays legible over text. */
.to-top {
    width: auto;
    height: auto;
    padding: 7px 11px 6px;
    transform: none;
    border: 1px solid rgba(var(--vfd-rgb), 0.3);
    border-radius: 2px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 4px 14px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.16em;
    color: rgba(var(--vfd-rgb), 0.85);
    text-shadow: 0 0 6px rgba(var(--vfd-rgb), 0.35);
    opacity: 1;
}

.to-top:hover,
.to-top:focus-visible {
    background: color-mix(in srgb, var(--bg) 88%, rgba(var(--vfd-rgb), 0.14));
    border-color: rgba(var(--vfd-rgb), 0.55);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 4px 14px rgba(0, 0, 0, 0.55), 0 0 12px -4px rgba(var(--vfd-rgb), 0.5);
    color: var(--vfd);
    text-shadow: 0 0 10px rgba(var(--vfd-rgb), 0.7);
}

/* The project headers carry the same fine dot mesh, a little fainter so the text stays easy to read. */
.chapter-header {
    background-image:
        var(--hex-08),
        linear-gradient(135deg,
            color-mix(in srgb, var(--tone) 8%, rgba(var(--glass-rgb), 0.03)),
            rgba(var(--glass-rgb), 0.02));
    background-size: 6px 10.392px, auto;
    background-attachment: fixed, scroll;
}

/* ==========================================================================
   Instrument panel: hairlines, status slabs and rulers, after vector HUD layouts.
   ========================================================================== */

/* Window title bars read as status slabs: a neutral grey plate, a small lit square in an index cell on
   the left, a hairline after it, and the right-hand note set as a quiet, tracked readout. */
.figure-bar {
    position: relative;
    padding-left: 44px;
    background-color: rgba(255, 255, 255, 0.045);
    background-image: none;
}

.figure-bar::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    border-right: 1px solid rgba(var(--vfd-rgb), 0.22);
    background:
        linear-gradient(var(--vfd), var(--vfd)) center / 4px 4px no-repeat;
    opacity: 0.85;
}

.figure-bar>span:last-child {
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ==========================================================================
   Status tags as a lit cell of the display: a slanted window with the honeycomb grid in front of a
   lit label, in a muted tone.
   ========================================================================== */

.chapter-kicker .tag {
    /* The tone, greyed: the tag should sit in the page, not shout. */
    --tag: color-mix(in srgb, var(--tone) 42%, #8c8982);
    position: relative;
    isolation: isolate;
    display: inline-flex;
    align-items: center;
    transform: none;
    padding: 4px 15px 4px 15px;
    border: 0;
    border-radius: 0;
    font-size: 9.5px;
    font-weight: 500;
    font-style: normal;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--tag) 55%, #fff);
    text-shadow: 0 0 6px color-mix(in srgb, var(--tag) 35%, transparent);
    background: color-mix(in srgb, var(--tag) 62%, transparent);
    box-shadow: none;
    clip-path: polygon(7.1px 2px, 11px 0, calc(100% - 3px) 0, calc(100% - 0.9px) 2px, calc(100% - 7.1px) calc(100% - 2px), calc(100% - 11px) 100%, 3px 100%, 0.9px calc(100% - 2px));
}

/* The window: dark, with a little of the tone. */
.chapter-kicker .tag::before {
    content: "";
    position: absolute;
    inset: 2px;
    z-index: -1;
    clip-path: polygon(7.1px 2px, 11px 0, calc(100% - 3px) 0, calc(100% - 0.9px) 2px, calc(100% - 7.1px) calc(100% - 2px), calc(100% - 11px) 100%, 3px 100%, 0.9px calc(100% - 2px));
    background: color-mix(in srgb, var(--tag) 8%, #08090b);
}

/* The grid over the window, in the tone's own light. */
.chapter-kicker .tag::after {
    content: "";
    position: absolute;
    inset: 2px;
    z-index: -1;
    pointer-events: none;
    clip-path: polygon(7.1px 2px, 11px 0, calc(100% - 3px) 0, calc(100% - 0.9px) 2px, calc(100% - 7.1px) calc(100% - 2px), calc(100% - 11px) 100%, 3px 100%, 0.9px calc(100% - 2px));
    background: var(--tag);
    opacity: 0.24;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 10.392'%3E%3Cpath d='M0 1.732L3.0 0L6 1.732V5.196L3.0 6.928L0 5.196Z M3.0 6.928V10.392' fill='none' stroke='black' stroke-width='0.95'/%3E%3C/svg%3E") 0 0 / 6px 10.392px;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 10.392'%3E%3Cpath d='M0 1.732L3.0 0L6 1.732V5.196L3.0 6.928L0 5.196Z M3.0 6.928V10.392' fill='none' stroke='black' stroke-width='0.95'/%3E%3C/svg%3E") 0 0 / 6px 10.392px;
}
