:root {
    color-scheme: dark;
    --bg: #0c0e12;
    --ink: #e9ecf2;
    --ink-dim: #9aa3b2;
    --line: rgba(255, 255, 255, 0.6);
    --face-opacity: 0.5; /* 1 = solid, 0 = gone */
    --glow: 5px;         /* line glow size. 0px = no glow */
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    overflow: hidden;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------- Intro: shining text ---------- */
#loader {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    transition: opacity 0.6s ease, visibility 0.6s;
}
.js #loader { display: flex; }
#loader.done { opacity: 0; visibility: hidden; }

.shine {
    font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    font-weight: 600;
    letter-spacing: 0.14em;
    color: #5c6270;
    background: linear-gradient(105deg, #5c6270 40%, #ffffff 50%, #5c6270 60%) -50% 0 / 200% 100% no-repeat;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shine 1.8s linear infinite;
}
@keyframes shine {
    from { background-position: -50% 0; }
    to   { background-position: 150% 0; }
}

/* ---------- Background: dot grid + cursor glow ---------- */
.bg {
    position: fixed;
    inset: -40px;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(circle 150px at var(--mx, 50%) var(--my, 50%), rgba(130, 155, 210, 0.13), transparent 100%),
        radial-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1.6px);
    background-size: 100% 100%, 28px 28px;
}

/* ---------- Stage: 16:9 box, 1em = 1% of its width ---------- */
.stage {
    --u: min(1vw, calc(100vh / 9 * 16 / 100));
    position: relative;
    z-index: 1;
    width: calc(var(--u) * 100);
    height: calc(var(--u) * 56.25);
    font-size: var(--u);
}

#links {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: visible;
}
/* Link types, like cable types in Packet Tracer. Set per box with data-link. */
#links path {
    fill: none;
    stroke: var(--line);
    stroke-width: 1.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
#links circle { fill: #fff; }

/* copper: plain thin white, no glow */
#links .copper { stroke: var(--line); }

/* fiber: solid amber, glowing */
#links .fiber  { stroke: #ffb454; stroke-width: 1.6; filter: drop-shadow(0 0 var(--glow) rgba(255, 180, 84, 0.9)); }
#links circle.fiber { fill: #ffb454; }

/* serial: coral zigzag bolt, glowing */
#links .serial { stroke: #ff6b6b; stroke-width: 1.6; filter: drop-shadow(0 0 var(--glow) rgba(255, 107, 107, 0.9)); }
#links circle.serial { fill: #ff6b6b; }

/* console: cyan dashes, soft glow */
#links .console { stroke: #5ee0ff; stroke-width: 1.2; stroke-dasharray: 6 5; filter: drop-shadow(0 0 calc(var(--glow) * 0.7) rgba(94, 224, 255, 0.8)); }
#links circle.console { fill: #5ee0ff; }

/* dotted: lilac round dots, glowing */
#links .dotted { stroke: #b69cff; stroke-width: 2.4; stroke-dasharray: 0.1 7; filter: drop-shadow(0 0 var(--glow) rgba(182, 156, 255, 0.9)); }
#links circle.dotted { fill: #b69cff; }

/* Face = the cloud. Still. Edges melt into the background. */
.face {
    position: absolute;
    left: 0;
    top: 0;
    height: 52%;
    z-index: 2;
    pointer-events: none;
    user-select: none;
    opacity: var(--face-opacity);
    -webkit-mask-image: radial-gradient(ellipse 70% 58% at 50% 40%, #000 62%, transparent 100%);
    mask-image: radial-gradient(ellipse 70% 58% at 50% 40%, #000 62%, transparent 100%);
}

/* Name: hidden from eyes, kept for screen readers and search */
.face-name {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Node = moved by JS. Glass inside = hover. */
.node {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 3;
}

.glass {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 9.5em;
    height: 3.2em;
    font-size: 1.3em;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
    color: var(--ink);
    border-radius: 1em;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow:
        0 8px 26px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.35),
        inset 0 -1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(10px) saturate(150%);
    -webkit-backdrop-filter: blur(10px) saturate(150%);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.glass small {
    font-size: 0.55em;
    font-weight: 400;
    color: var(--ink-dim);
    margin-top: 0.15em;
}
.glass:hover {
    transform: scale(1.07);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.08));
    border-color: rgba(255, 255, 255, 0.45);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.glass:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.hub .glass  { border-color: rgba(255, 255, 255, 0.4); }
.leaf .glass { font-size: 1.1em; width: 9em; height: 3em; }

/* ---------- Reveal after intro (only when JS is on) ---------- */
.js .face,
.js .face-name,
.js .node,
.js #links path,
.js #links circle {
    opacity: 0;
    transition: opacity 0.7s ease;
}
.js .on,
.js #links .on { opacity: 1; }
.js .face.on { opacity: var(--face-opacity); }

/* ---------- Phone / narrow: stacked, no lines, no parallax ---------- */
@media (max-width: 800px), (max-aspect-ratio: 1/1) {
    html, body { overflow: auto; height: auto; min-height: 100%; }
    body { display: block; padding: 1.5rem 1rem 3rem; }
    .stage {
        width: 100%;
        height: auto;
        font-size: 16px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }
    #links { display: none; }
    .face {
        position: static;
        transform: none !important;
        height: auto;
        width: min(70vw, 320px);
    }
    .node {
        position: static;
        transform: none !important;
        width: 100%;
        max-width: 360px;
    }
    .glass, .leaf .glass { width: 100%; height: 4.2rem; font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
    .glass { transition: none; }
    .shine { animation: none; -webkit-text-fill-color: #8b93a3; }
    .js .face, .js .face-name, .js .node, .js #links path, .js #links circle { transition: none; }
}
