/* Tech motion layer for the resource directory and Security Lab.
   Everything is visible without JS; JS only adds the boot/decode effects. */
.tech-page { --tech-rgb: 130, 230, 186; --tech: rgb(var(--tech-rgb)); --tech-mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Consolas, monospace; }
.doc-page.tech-page { --tech-rgb: 95, 212, 212; }

/* ---------- Hero background: drifting grid + scan beam ---------- */
.tech-hero-bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(var(--tech-rgb), 0.09) 1px, transparent 1px),
        linear-gradient(90deg, rgba(var(--tech-rgb), 0.09) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: radial-gradient(ellipse 75% 90% at 60% 40%, #000 20%, transparent 78%);
    mask-image: radial-gradient(ellipse 75% 90% at 60% 40%, #000 20%, transparent 78%);
    animation: tech-grid-drift 9s linear infinite;
}
.tech-beam {
    position: absolute;
    left: 0;
    right: 0;
    top: -140px;
    height: 140px;
    background: linear-gradient(180deg, transparent, rgba(var(--tech-rgb), 0.16) 85%, rgba(var(--tech-rgb), 0.85) 99%, transparent);
    animation: tech-beam 6.5s cubic-bezier(.45, 0, .55, 1) infinite;
}
.directory-hero { position: relative; isolation: isolate; }

/* ---------- Resource directory hero: copy + topology ---------- */
.directory-hero.tech-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 40px;
    align-items: center;
    padding: 8px 0 12px;
}
.tech-topology {
    border: 1px solid rgba(var(--tech-rgb), 0.28);
    border-radius: 14px;
    background: rgba(4, 18, 13, 0.82);
    box-shadow: 0 0 0 1px rgba(var(--tech-rgb), 0.05), 0 24px 60px rgba(0, 0, 0, 0.4), inset 0 0 40px rgba(var(--tech-rgb), 0.05);
    padding: 14px 16px;
    font-family: var(--tech-mono);
}
.topo-head, .topo-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    color: rgba(var(--tech-rgb), 0.85);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
}
.topo-live { display: inline-flex; align-items: center; gap: 6px; color: #cfeee0; }
.topo-live i, .tech-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--tech); box-shadow: 0 0 10px var(--tech); animation: tech-blink 1.6s ease-in-out infinite; display: inline-block; }
.topo-stage {
    --r: 128px;
    position: relative;
    height: 300px;
    margin: 6px 0;
}
.topo-ring {
    position: absolute;
    left: 50%;
    top: 50%;
    border-radius: 50%;
    border: 1px dashed rgba(var(--tech-rgb), 0.3);
    transform: translate(-50%, -50%);
}
.topo-ring-a { width: calc(var(--r) * 2); height: calc(var(--r) * 2); animation: tech-spin 40s linear infinite; }
.topo-ring-b { width: calc(var(--r) * 1.15); height: calc(var(--r) * 1.15); border-style: solid; border-color: rgba(var(--tech-rgb), 0.16); animation: tech-spin-rev 24s linear infinite; }
.topo-sweep {
    position: absolute;
    left: 50%;
    top: 50%;
    width: calc(var(--r) * 2.3);
    height: calc(var(--r) * 2.3);
    border-radius: 50%;
    background: conic-gradient(from 0deg, rgba(var(--tech-rgb), 0.28), rgba(var(--tech-rgb), 0) 22%, transparent);
    -webkit-mask-image: radial-gradient(circle, #000 60%, transparent 71%);
    mask-image: radial-gradient(circle, #000 60%, transparent 71%);
    transform: translate(-50%, -50%);
    animation: tech-sweep-rot 5.6s linear infinite;
}
.topo-spoke {
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--r);
    height: 1px;
    transform-origin: 0 50%;
    transform: rotate(var(--a));
    background: linear-gradient(90deg, rgba(var(--tech-rgb), 0.65), rgba(var(--tech-rgb), 0.12));
}
.topo-spoke i {
    position: absolute;
    left: 0;
    top: -3px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #eafff6;
    box-shadow: 0 0 10px var(--tech), 0 0 18px var(--tech);
    animation: topo-packet 2.8s ease-in infinite;
    animation-delay: var(--d);
}
.topo-hub {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 78px;
    height: 78px;
    display: grid;
    place-content: center;
    text-align: center;
    border-radius: 50%;
    border: 1px solid rgba(var(--tech-rgb), 0.7);
    background: radial-gradient(circle, rgba(var(--tech-rgb), 0.3), rgba(4, 18, 13, 0.95) 70%);
    color: #ffffff;
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: 0.06em;
    transform: translate(-50%, -50%);
    animation: topo-hub 2.8s ease-in-out infinite;
}
.topo-hub small { display: block; color: rgba(var(--tech-rgb), 0.9); font-size: 0.55rem; font-weight: 600; letter-spacing: 0.16em; }
.topo-node {
    position: absolute;
    left: 50%;
    top: 50%;
    padding: 4px 9px;
    border: 1px solid rgba(var(--tech-rgb), 0.38);
    border-radius: 6px;
    background: rgba(6, 26, 19, 0.95);
    color: #d9f5e8;
    font-family: Inter, "Microsoft YaHei", sans-serif;
    font-size: 0.72rem;
    white-space: nowrap;
    transform: translate(-50%, -50%) rotate(var(--a)) translateX(var(--r)) rotate(calc(-1 * var(--a)));
    animation: topo-node-hit 2.8s ease-out infinite;
    animation-delay: var(--d);
}
.topo-foot { padding-top: 10px; border-top: 1px solid rgba(var(--tech-rgb), 0.14); }
.topo-log { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: #cfeee0; letter-spacing: 0.02em; }
.topo-log::after { content: "▌"; margin-left: 2px; color: var(--tech); animation: tech-blink 0.9s steps(2, jump-none) infinite; }

/* ---------- Security Lab: radar in the overview card ---------- */
.tech-radar {
    position: relative;
    width: 112px;
    height: 112px;
    margin-bottom: 16px;
    border-radius: 50%;
    border: 1px solid rgba(var(--tech-rgb), 0.5);
    background:
        radial-gradient(circle, transparent 32%, rgba(var(--tech-rgb), 0.2) 33%, transparent 34%),
        radial-gradient(circle, transparent 64%, rgba(var(--tech-rgb), 0.2) 65%, transparent 66%),
        linear-gradient(rgba(var(--tech-rgb), 0.16), rgba(var(--tech-rgb), 0.16)) center / 100% 1px no-repeat,
        linear-gradient(rgba(var(--tech-rgb), 0.16), rgba(var(--tech-rgb), 0.16)) center / 1px 100% no-repeat,
        radial-gradient(circle, rgba(var(--tech-rgb), 0.12), rgba(3, 14, 11, 0.9) 72%);
    box-shadow: 0 0 24px rgba(var(--tech-rgb), 0.18);
    overflow: hidden;
}
.radar-sweep {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(from 0deg, rgba(var(--tech-rgb), 0.55), rgba(var(--tech-rgb), 0) 26%, transparent);
    animation: tech-sweep-rot 4s linear infinite;
}
.radar-blip {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    border-radius: 50%;
    background: #eafff9;
    box-shadow: 0 0 10px var(--tech);
    opacity: 0.15;
    animation: radar-blip 4s linear infinite;
    animation-delay: var(--d);
}
.tech-radar > i {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: 1.35rem;
    text-shadow: 0 0 12px var(--tech);
}
.tech-radar-label { display: flex; align-items: center; gap: 7px; margin: -6px 0 14px; color: rgba(var(--tech-rgb), 0.95); font-family: var(--tech-mono); font-size: 0.66rem; letter-spacing: 0.1em; }

/* ---------- Cards: HUD corners, looping scan, spotlight ---------- */
.tech-card {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    --mx: -200px;
    --my: -200px;
    --c: rgba(var(--tech-rgb), 0.75);
    background-image:
        radial-gradient(260px circle at var(--mx) var(--my), rgba(var(--tech-rgb), 0.16), transparent 70%),
        linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)),
        linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)),
        linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)),
        linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c));
    background-size: 100% 100%, 12px 1.5px, 1.5px 12px, 12px 1.5px, 1.5px 12px, 12px 1.5px, 1.5px 12px, 12px 1.5px, 1.5px 12px;
    background-position: 0 0, 7px 7px, 7px 7px, calc(100% - 7px) 7px, calc(100% - 7px) 7px, 7px calc(100% - 7px), 7px calc(100% - 7px), calc(100% - 7px) calc(100% - 7px), calc(100% - 7px) calc(100% - 7px);
    background-repeat: no-repeat;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}
.tech-card::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 46%;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(180deg, transparent, rgba(var(--tech-rgb), 0.12) 80%, rgba(var(--tech-rgb), 0.7) 99%, transparent);
    transform: translateY(-110%);
    animation: tech-card-scan 7.2s linear infinite;
    animation-delay: calc(var(--i, 0) * 0.6s);
}
.tech-card:hover,
.tech-card:focus-visible {
    border-color: rgba(var(--tech-rgb), 0.65);
    box-shadow: 0 0 0 1px rgba(var(--tech-rgb), 0.18), 0 10px 32px rgba(var(--tech-rgb), 0.14);
    transform: translateY(-2px);
}
.tech-code {
    position: absolute;
    right: 14px;
    bottom: 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: rgba(var(--tech-rgb), 0.7);
    font-family: var(--tech-mono);
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    pointer-events: none;
}
.tech-code .tech-dot { width: 5px; height: 5px; animation-delay: calc(var(--i, 0) * 0.2s); }
.directory-card.tech-card { padding-bottom: 28px; }
.doc-body .trust-panel.tech-card { padding-bottom: 30px; }

/* Section headings get a terminal prompt */
.tech-page .directory-heading h2::before { content: "// "; color: rgba(var(--tech-rgb), 0.7); font-family: var(--tech-mono); font-weight: 500; }
.tech-page .directory-heading h2::after { content: "_"; margin-left: 4px; color: var(--tech); animation: tech-blink 1s steps(2, jump-none) infinite; }

/* Boot-in once a card scrolls into view (only when JS is running) */
.tech-js .tech-card:not(.is-live) { opacity: 0; transform: translateY(14px); }
.tech-js .tech-card.is-live { animation: tech-boot 0.7s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 70ms); }

@keyframes tech-grid-drift { to { background-position: 44px 44px, 44px 44px; } }
@keyframes tech-beam { 0% { top: -140px; } 100% { top: 100%; } }
@keyframes tech-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes tech-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes tech-spin-rev { to { transform: translate(-50%, -50%) rotate(-360deg); } }
@keyframes tech-sweep-rot { from { transform: translate(-50%, -50%) rotate(0deg); } to { transform: translate(-50%, -50%) rotate(360deg); } }
.radar-sweep { transform-origin: center; }
@keyframes topo-packet { 0% { left: 0; opacity: 0; } 10% { opacity: 1; } 88% { opacity: 1; } 100% { left: 100%; opacity: 0; } }
@keyframes topo-hub { 0%, 100% { box-shadow: 0 0 0 0 rgba(var(--tech-rgb), 0.4); } 50% { box-shadow: 0 0 0 10px rgba(var(--tech-rgb), 0); } }
@keyframes topo-node-hit {
    0%, 82% { border-color: rgba(var(--tech-rgb), 0.38); box-shadow: none; color: #d9f5e8; }
    92% { border-color: var(--tech); box-shadow: 0 0 16px rgba(var(--tech-rgb), 0.6); color: #ffffff; }
    100% { border-color: rgba(var(--tech-rgb), 0.38); box-shadow: none; color: #d9f5e8; }
}
@keyframes radar-blip { 0% { opacity: 1; transform: scale(1.5); } 30% { opacity: 0.6; transform: scale(1); } 60%, 100% { opacity: 0.12; } }
@keyframes tech-card-scan { 0% { transform: translateY(-110%); } 22%, 100% { transform: translateY(240%); } }
@keyframes tech-boot {
    0% { opacity: 0; transform: translateY(14px); clip-path: inset(0 0 100% 0); }
    60% { opacity: 1; clip-path: inset(0 0 0 0); box-shadow: 0 0 0 1px rgba(var(--tech-rgb), 0.6), 0 0 24px rgba(var(--tech-rgb), 0.25); }
    100% { opacity: 1; transform: none; clip-path: inset(0 0 0 0); }
}
/* The radar sweep is not translated, so give it its own keyframes. */
.radar-sweep { animation-name: radar-rot; }
@keyframes radar-rot { to { transform: rotate(360deg); } }

@media (max-width: 980px) {
    .directory-hero.tech-hero { grid-template-columns: 1fr; gap: 24px; }
    .tech-topology { max-width: 420px; }
}
@media (max-width: 420px) {
    .topo-stage { --r: 104px; height: 260px; }
    .topo-node { font-size: 0.66rem; padding: 3px 7px; }
}

/* Reduced motion: keep every visual, stop large movement. */
@media (prefers-reduced-motion: reduce) {
    .tech-hero-bg, .tech-beam, .topo-ring, .topo-sweep, .topo-spoke i, .topo-hub, .topo-node,
    .radar-sweep, .radar-blip, .tech-card::after, .tech-card.is-live { animation: none !important; }
    .tech-beam, .tech-card::after, .topo-spoke i { display: none; }
    .tech-js .tech-card:not(.is-live) { opacity: 1; transform: none; }
}
