:root {
    /* Same token families as style.css, re-themed: dark green surfaces, a green-tinted label,
       neon green accent with amber for warnings/planned. Labels (--label-2/-3/-4) derive from
       --label-rgb, so only that one value changes here. */
    --bg: #060a07;
    --bg-deep: #030504;
    --bg-panel: #0b120d;
    --bg-raised: #121c15;
    --label-rgb: 234 250 238;
    --separator: rgba(120, 255, 140, 0.16);
    --separator-faint: rgba(120, 255, 140, 0.05);
    --accent: #39ff14;
    --accent-dim: rgba(57, 255, 20, 0.4);
    --highlight: #39ff14;
    --amber: #ffb020;
    --nav-bg: rgb(3 5 4 / 0.72);
    /* opaque grey for SVG strokes (see style.css) */
    --muted: #7f9686;
}

#navLogo {
    color: var(--accent);
    text-shadow: 0 0 14px var(--accent-dim);
}

.heroTitle em {
    text-shadow: 0 0 28px var(--accent-dim);
}

/* ---------------- Hero (stacked: copy, then the display) ---------------- */
#hero.bkHero {
    display: block;
    min-height: 0;
    padding: 160px 0 72px;
}

/* (The collaboration credit card, .collab, lives in style.css: the landing page uses it too.) */

/* Project logo (1800x400 PNG, 4.5:1). Width drives the size; height follows. */
.bkLogo {
    display: block;
    width: clamp(220px, 34vw, 380px);
    height: auto;
    margin-bottom: 28px;
    filter: drop-shadow(0 0 22px var(--accent-dim));
    view-transition-name: bckupLogo;
}

.bkHero .heroSub {
    max-width: 58ch;
}

.bkHero .statusPill {
    display: inline-block;
    margin-bottom: 24px;
}

.bkHero .intro {
    margin-bottom: 48px;
}

/* ---------------- Energy-flow panel ---------------- */
.flowPanel {
    position: relative;
    border: var(--edge);
    background: var(--bg-panel);
    padding: 20px;
}

.flowHead {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px 24px;
    margin-bottom: 16px;
}

.simTag {
    font-family: var(--mono);
    font-size: var(--fs-caption);
    line-height: var(--lh-caption);
    letter-spacing: var(--tr-caption);
    color: var(--amber);
}

.stateTabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tab {
    font-family: var(--mono);
    font-size: var(--fs-footnote);
    line-height: var(--lh-footnote);
    letter-spacing: var(--tr-footnote);
    color: var(--label-2);
    background: transparent;
    border: var(--edge);
    border-radius: var(--radius);
    padding: 8px 12px;
    cursor: pointer;
    /* transitions + press feedback come from style.css */
}

@media (hover: hover) {
    .tab:hover {
        color: var(--label);
        border-color: var(--label-3);
    }
}

.tab[aria-pressed="true"] {
    color: var(--accent);
    border-color: var(--accent);
    background-color: color-mix(in srgb, var(--accent) 8%, transparent);
}

.tab:focus-visible,
.cycleBtn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.cycleBtn {
    margin-left: auto;
}

.flowScroll {
    overflow-x: auto;
}

.flowScroll svg {
    min-width: 720px;
    width: 100%;
    height: auto;
}

/* pipes: dim base + animated neon overlay when active */
.pipe {
    fill: none;
    stroke: var(--line-dim);
    stroke-width: 2;
}

.flow {
    fill: none;
    stroke: var(--accent);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 2 12;
    opacity: 0;
    transition: opacity 0.4s ease;
    filter: drop-shadow(0 0 4px var(--accent));
}

.flow.on {
    opacity: 1;
    animation: flowMove 0.7s linear infinite;
}

.flow.rev {
    animation-direction: reverse;
}

.flow.ghost.on {
    opacity: 0.45;
    stroke: var(--muted);
    filter: none;
}

@keyframes flowMove {
    to {
        stroke-dashoffset: -14;
    }
}

/* nodes */
.node rect {
    fill: var(--bg-deep);
    stroke: var(--line-dim);
    stroke-width: 1.5;
    transition: stroke 0.4s ease;
}

.node.on rect {
    stroke: var(--accent);
    filter: drop-shadow(0 0 6px var(--accent-dim));
}

.node.warn rect {
    stroke: var(--amber);
    filter: drop-shadow(0 0 6px rgba(255, 176, 32, 0.35));
}

.node.ghost rect {
    stroke-dasharray: 4 4;
}

.nTag,
.nSub,
.wLabel,
.warnTxt {
    font-family: var(--mono);
}

.nTag {
    font-size: 9px;
    letter-spacing: 0.08em;
    fill: var(--muted);
}

.nName {
    font-family: var(--display);
    font-weight: 700;
    font-size: 15px;
    fill: var(--ink);
    transition: fill 0.4s ease;
}

.nSub {
    font-size: 9px;
    fill: var(--muted);
}

.node.off .nName {
    fill: var(--muted);
}

.node.on .nName {
    fill: var(--accent);
}

.node.warn .nName {
    fill: var(--amber);
}

.nIcon {
    fill: var(--muted);
    transition: fill 0.4s ease, filter 0.4s ease;
}

.node.on .nIcon {
    fill: var(--accent);
}

.node.warn .nIcon {
    fill: var(--amber);
}

.node.on#lights .nIcon {
    filter: drop-shadow(0 0 6px var(--accent));
}

.socTrack {
    fill: none;
    stroke: var(--line-dim);
}

.socFill {
    fill: var(--accent) !important;
    transition: width 0.8s ease, fill 0.4s ease;
}

.node.warn .socFill {
    fill: var(--amber) !important;
}

.fuseBox {
    fill: var(--bg-deep);
    stroke: var(--amber);
    stroke-width: 1.2;
}

.fuseTxt {
    font-family: var(--mono);
    font-size: 8px;
    fill: var(--amber);
}

.wLabel {
    font-size: 10px;
    fill: var(--accent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wLabel.on {
    opacity: 1;
}

.warnTxt {
    font-size: 10px;
    fill: var(--amber);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.warnTxt.on {
    opacity: 1;
}

.flowCaption {
    margin-top: 16px;
    padding-top: 16px;
    border-top: var(--edge);
    color: var(--label-2);
    font-size: var(--fs-subhead);
    line-height: var(--lh-subhead);
    letter-spacing: var(--tr-subhead);
    min-height: 3.4em;
}

.flowCaption strong {
    color: var(--label);
    font-weight: 500;
}

.readout {
    margin-top: 16px;
    grid-template-columns: repeat(4, 1fr);
}

.readout .specValue {
    font-family: var(--mono);
    color: var(--accent);
}

/* ---------------- Safety: six playing cards ----------------
   Portrait cards (5:7). script.js deals them from the centre of the table as the grid scrolls into
   view, setting --e (0 = in the pile, 1 = home) per card, plus its offset to the pile (--dx, --dy)
   and fan angle (--r). The deal uses the individual translate/rotate/scale properties so hover and
   press can keep using `transform`. With no script, or reduced motion, --e is unset and they rest. */
.safeGrid {
    --card-radius: 16px;
    position: relative; /* the cards measure their offsets from this table */
    counter-reset: card;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 40px;
}

.safeItem {
    counter-increment: card;
    position: relative;
    aspect-ratio: 5 / 7;
    padding: 24px 24px 52px;
    overflow: hidden;
    border: 1px solid var(--separator);
    border-radius: var(--card-radius);
    background:
        linear-gradient(180deg, var(--fill) 0%, transparent 38%),
        var(--bg-panel);
    box-shadow: 0 calc(var(--e, 1) * 14px) calc(var(--e, 1) * 34px) -14px rgb(0 0 0 / 0.7);
    translate: calc((1 - var(--e, 1)) * var(--dx, 0px)) calc((1 - var(--e, 1)) * var(--dy, 0px));
    rotate: calc((1 - var(--e, 1)) * var(--r, 0deg));
    scale: calc(0.82 + 0.18 * var(--e, 1));
    transition: transform var(--spring-dur) var(--spring), border-color 0.25s ease;
    will-change: translate, rotate, scale;
}

/* corner indices, as on a playing card: top-left value, bottom-right the same turned over */
.safeItem::before,
.safeItem::after {
    content: counter(card, decimal-leading-zero);
    position: absolute;
    bottom: 14px;
    font-family: var(--mono);
    font-size: var(--fs-footnote);
    line-height: var(--lh-footnote);
    letter-spacing: var(--tr-footnote);
    color: var(--label-3);
}

.safeItem::before {
    left: 24px;
}

.safeItem::after {
    right: 24px;
    rotate: 180deg;
}

@media (hover: hover) {
    .safeItem:hover {
        transform: translateY(-6px);
        border-color: var(--label-3);
    }
}

.safeItem:active {
    transform: scale(0.98);
    transition-duration: 0.09s;
    transition-timing-function: ease-out;
}

/* Diagram runs edge-to-edge across the top of the card (see diagrams.css) */
.safeItem>.illo {
    margin: -24px -24px 20px;
}

.safeItem>.illo .illoPanel {
    border-bottom: var(--edge);
}

.safeItem h3 {
    font-family: var(--display);
    font-size: var(--fs-lede);
    line-height: var(--lh-lede);
    letter-spacing: var(--tr-lede);
    margin: 14px 0 8px;
}

.safeItem p {
    color: var(--label-2);
    font-size: var(--fs-callout);
    letter-spacing: var(--tr-callout);
    line-height: var(--lh-callout);
}

.statusPill.plan {
    color: var(--amber);
    border-color: rgba(255, 176, 32, 0.4);
}

.statusPill.built {
    color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
    .flow.on {
        animation: none;
        stroke-dasharray: none;
    }
}

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

    .safeGrid {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
}

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

    .cycleBtn {
        margin-left: 0;
    }
}
@media (max-width: 560px) {

    /* one card per row: no deal, they simply sit down in order */
    .safeItem {
        aspect-ratio: auto;
        min-height: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .safeItem:active {
        transform: none;
        opacity: 0.7;
    }

    .safeItem:hover {
        transform: none;
    }
}
