/* ─────────────────────────────────────────────────────────────────────────────
   polish.css — presentation layer on top of styles.css (loaded after it).
   Scope: dynamic background, frame/menu, natural card layout, buttons, motion.
   Everything here is additive; tokens come from :root in styles.css.
   ───────────────────────────────────────────────────────────────────────────── */

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* ── 1. Dynamic background: aurora blobs + drifting grid under the node canvas ── */
.aurora {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background:
    linear-gradient(rgba(0, 247, 255, 0.045) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(90deg, rgba(0, 247, 255, 0.045) 1px, transparent 1px) 0 0 / 56px 56px;
  animation: aurora-grid 48s linear infinite;
  mask-image: radial-gradient(120% 90% at 50% 30%, #000 40%, transparent 100%);
}
.aurora i {
  position: absolute; display: block; border-radius: 50%; filter: blur(70px); opacity: 0.55;
  mix-blend-mode: screen; will-change: transform;
}
.aurora i:nth-child(1) { width: 52vw; height: 52vw; left: -12vw; top: -18vw; background: radial-gradient(circle, rgba(0, 247, 255, 0.28), transparent 62%); animation: blob-a 34s ease-in-out infinite; }
.aurora i:nth-child(2) { width: 46vw; height: 46vw; right: -14vw; top: 8vh;   background: radial-gradient(circle, rgba(255, 0, 170, 0.18), transparent 62%); animation: blob-b 41s ease-in-out infinite; }
.aurora i:nth-child(3) { width: 40vw; height: 40vw; left: 28vw; bottom: -22vw; background: radial-gradient(circle, rgba(0, 255, 65, 0.14), transparent 62%); animation: blob-c 37s ease-in-out infinite; }
@keyframes aurora-grid { to { background-position: 56px 56px, 56px 56px; } }
@keyframes blob-a { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(9vw, 6vh) scale(1.12); } }
@keyframes blob-b { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-8vw, 10vh) scale(0.94); } }
@keyframes blob-c { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(6vw, -8vh) scale(1.08); } }
body.light-mode .aurora { opacity: 0.35; }
@media (prefers-reduced-motion: reduce) { .aurora, .aurora i { animation: none; } }
#bg-canvas { z-index: 1; }

/* ── 2. Frame: scroll progress + glass top bar + animated nav underline ── */
.scroll-progress {
  position: fixed; top: 0; left: 0; z-index: 1000; height: 2px; width: 0;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  box-shadow: 0 0 12px color-mix(in srgb, var(--cyan) 60%, transparent);
  transition: width 80ms linear;
}
.topbar {
  backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  transition: box-shadow 220ms ease, background 220ms ease, border-color 220ms ease;
}
.topbar.scrolled {
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  border-bottom-color: var(--border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}
#primary-nav a { position: relative; transition: color 160ms ease; }
#primary-nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -0.35rem; height: 2px;
  background: linear-gradient(90deg, var(--cyan), color-mix(in srgb, var(--cyan) 20%, transparent));
  transform: scaleX(0); transform-origin: left; transition: transform 220ms cubic-bezier(.2,.8,.2,1);
}
#primary-nav a:hover::after, #primary-nav a[aria-current="location"]::after { transform: scaleX(1); }
#primary-nav a[aria-current="location"] { color: var(--cyan); text-shadow: 0 0 14px color-mix(in srgb, var(--cyan) 50%, transparent); }
#site-header #primary-nav a[aria-current="location"]::before, #site-header #primary-nav a[aria-current="location"]::after { content: ""; }
#site-header #primary-nav a[aria-current="location"]::before { display: none; }
#site-header #primary-nav a[aria-current="location"]::after { position: absolute; left: 0; right: 0; bottom: -0.35rem; height: 2px; width: auto; background: linear-gradient(90deg, var(--cyan), color-mix(in srgb, var(--cyan) 20%, transparent)); transform: scaleX(1); }
#primary-nav a[aria-current="location"] { padding-left: 0; padding-right: 0; }

/* ── 3. Sections: consistent kicker + heading rule ── */
.section-head { position: relative; }
.section-head h2, .section-head .section-heading { letter-spacing: 0.01em; }
.section-head::after {
  content: ""; display: block; width: 72px; height: 2px; margin-top: 0.85rem;
  background: linear-gradient(90deg, var(--cyan), transparent);
}

/* ── 4. Buttons: one family, natural sizes ── */
.button, .read-doc, .card-action, .credential-link, .credential-document {
  border-radius: 6px;
}
.button { padding: 0.7rem 1.15rem; letter-spacing: 0.06em; }
.button-primary {
  background: linear-gradient(135deg, var(--cyan), color-mix(in srgb, var(--cyan) 70%, #7cf7ff));
  color: #041016; border-color: transparent;
  box-shadow: 0 8px 26px color-mix(in srgb, var(--cyan) 28%, transparent);
}
.button-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 34px color-mix(in srgb, var(--cyan) 40%, transparent); }
.button-ghost:hover { transform: translateY(-2px); background: color-mix(in srgb, var(--cyan) 8%, transparent); }
.read-doc {
  text-decoration: none; min-height: 2.5rem; padding: 0 0.95rem; gap: 0.4rem;
  border: 1px solid var(--border-strong); background: color-mix(in srgb, var(--cyan) 6%, transparent);
  font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase;
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.read-doc:hover { background: var(--cyan); color: #041016; transform: translateY(-2px); box-shadow: 0 10px 28px color-mix(in srgb, var(--cyan) 35%, transparent); }
.project-link-row { align-items: center; gap: 0.75rem; margin-top: auto; padding-top: 0.9rem; }
.project-link-row time { color: var(--text-faint); font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.05em; }

/* ── 5. Cards: natural top-to-bottom layout, badge on the image, hover lift, cursor spotlight ── */
.project-card, .category-card, .credential-card, .capability-card {
  position: relative; isolation: isolate;
  transition: transform 220ms cubic-bezier(.2,.8,.2,1), box-shadow 220ms ease, border-color 220ms ease;
}
.project-card::after, .category-card::after, .credential-card::after, .capability-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0; opacity: 0;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--cyan) 13%, transparent), transparent 55%);
  transition: opacity 260ms ease;
}
.project-card:hover::after, .category-card:hover::after, .credential-card:hover::after, .capability-card:hover::after { opacity: 1; }
.project-card > *, .category-card > *, .credential-card > *, .capability-card > * { position: relative; z-index: 1; }
.project-card:hover, .category-card:hover, .credential-card:hover, .capability-card:hover {
  transform: translateY(-5px); border-color: var(--border-strong);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px color-mix(in srgb, var(--cyan) 20%, transparent);
}
.project-card { cursor: pointer; border-radius: 10px; }

/* featured: vertical layout (image, then text) on every width */
.featured-card { grid-template-columns: 1fr; }
.featured-card .thumbnail-frame { aspect-ratio: 16 / 10; border-bottom: 1px solid var(--border); }
.featured-card-body, .project-entry-body { display: flex; flex-direction: column; gap: 0.7rem; padding: 1.15rem 1.25rem 1.2rem; }
.thumbnail-frame { position: relative; overflow: hidden; }
.thumbnail-frame img { width: 100%; height: 100%; object-fit: cover; transition: transform 600ms cubic-bezier(.2,.8,.2,1), filter 400ms ease; }
.project-card:hover .thumbnail-frame img, .category-card:hover .thumbnail-frame img, .category-card:hover .category-cover img { transform: scale(1.05); }
.thumbnail-frame::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 55%, color-mix(in srgb, var(--bg) 78%, transparent));
}
/* Category/status labels remain in normal flow directly above the title. */
.card-badge {
  display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center;
  font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase;
}
.card-badge a, .card-badge span {
  display: inline-flex; align-items: center; height: 1.55rem; padding: 0 0.6rem; border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 70%, transparent); border: 1px solid var(--border-strong);
  color: var(--cyan); text-decoration: none; backdrop-filter: blur(6px);
}
.card-badge span { color: var(--text-dim); border-color: var(--border); }
.card-badge a:hover { background: var(--cyan); color: #041016; }
.stack-list li { border-radius: 999px; transition: background 140ms ease, color 140ms ease; }
.stack-list li:hover { background: color-mix(in srgb, var(--cyan) 14%, transparent); color: var(--text); }
.project-card h2 a, .project-card h3 a { text-decoration: none; }
.project-card:hover h3 a, .project-card:hover h2 a { color: var(--cyan); }

/* category cards */
.category-card { border-radius: 10px; }
.category-card .card-action {
  display: inline-flex; align-items: center; min-height: 2.4rem; padding: 0 0.9rem; margin-top: 0.4rem;
  border: 1px solid var(--border-strong); border-radius: 6px; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
  transition: background 160ms ease, color 160ms ease;
}
.category-card:hover .card-action { background: var(--cyan); color: #041016; }

/* credential cards: badge left, text right, actions below */
.credential-card {
  display: grid; grid-template-columns: 84px 1fr; grid-template-areas: "top top" "thumb name" "thumb issuer" "act act";
  column-gap: 1rem; row-gap: 0.25rem; align-items: start; min-height: 0; border-radius: 10px; border-left-width: 3px;
}
.credential-topline { grid-area: top; margin-bottom: 0.35rem; }
.credential-topline span:last-child {
  display: inline-flex; align-items: center; height: 1.4rem; padding: 0 0.55rem; border-radius: 999px;
  font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; border: 1px solid currentColor;
}
.credential-thumb { grid-area: thumb; width: 84px; height: 84px; margin: 0; border-radius: 10px; overflow: hidden;
  background: #fff; display: grid; place-items: center; border: 1px solid var(--border); }
.credential-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.credential-card h3 { grid-area: name; margin: 0; }
.credential-card > p { grid-area: issuer; margin: 0; }
.credential-actions, .credential-link { grid-area: act; margin-top: 0.7rem; }
.credential-card:not(:has(.credential-thumb)) { grid-template-columns: 1fr; grid-template-areas: "top" "name" "issuer" "act"; }
.credential-link {
  display: inline-flex; align-items: center; min-height: 2.3rem; padding: 0 0.85rem; text-decoration: none;
  border: 1px solid var(--border-strong); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase;
}
.credential-link:hover { background: var(--cyan); color: #041016; }

/* capability cards */
.capability-card { border-radius: 10px; }

/* ── 6. Hero: living highlight + panel pulse ── */
#hero-highlight, .hero .highlight {
  background: linear-gradient(90deg, var(--cyan), #7cf7ff, var(--cyan)); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 6s linear infinite;
}
@keyframes shimmer { to { background-position: 200% 0; } }
.operator-signal { animation: signal 2.4s ease-in-out infinite; }
@keyframes signal { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #hero-highlight, .hero .highlight, .operator-signal { animation: none; } }

/* ── 7. Project pages: gallery, diagram, embeds, lightbox ── */
.project-diagram { border-radius: 12px; overflow: hidden; }
.project-diagram img { transition: transform 500ms ease; cursor: zoom-in; }
.project-diagram:hover img { transform: scale(1.015); }
.gallery-grid { gap: 1rem; }
.gallery-item { border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--bg-elev);
  transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease; }
.gallery-item:hover { transform: translateY(-4px); border-color: var(--border-strong); box-shadow: 0 18px 50px rgba(0,0,0,.5); }
.gallery-item img { cursor: zoom-in; transition: transform 600ms cubic-bezier(.2,.8,.2,1); }
.gallery-item:hover img { transform: scale(1.04); }
.gallery-item figcaption { font-size: 0.86rem; line-height: 1.5; padding: 0.8rem 0.95rem; }
.gallery-item.gallery-wide { grid-column: 1 / -1; }
.gallery-wide img { width: 100%; height: auto; object-fit: contain; }
.gallery-wide:hover img { transform: none; }
@media (min-width: 761px) {
  .gallery-grid:has(> .gallery-wide) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.embed-frame { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--bg-elev);
  box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.embed-frame iframe { width: 100%; border: 0; display: block; background: #03060b; }
.embed-frame figcaption { padding: 0.75rem 1rem; font-family: var(--font-mono); font-size: 0.78rem; }
.embed-frame figcaption a { color: var(--cyan); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--cyan) 40%, transparent); }
/* lightbox: full-viewport grid — stage (centred image) over a caption bar. No transforms on the
   image itself, so it is painted at device pixels and stays sharp; 1:1 mode scrolls inside the stage. */
html.lb-open { overflow: hidden; }
.lightbox {
  position: fixed; inset: 0; z-index: 2000; display: none; margin: 0;
  background: rgba(2, 4, 10, 0.94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.lightbox.open { display: grid; grid-template-rows: minmax(0, 1fr) auto; }
/* Flex centring with min-height:0 so the image is clamped to the stage in BOTH axes.
   In 1:1 mode the auto margins keep an oversized image centred and still fully scrollable. */
.lb-stage {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-width: 0; min-height: 0; overflow: hidden; padding: 2vh 2vw; cursor: zoom-out;
}
.lb-stage img {
  display: block; flex: 0 0 auto; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  border-radius: 8px; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7); cursor: zoom-in; image-rendering: auto;
  opacity: 1; transition: opacity 160ms ease;
}
.lb-stage img:not([src]) { opacity: 0; }
.lightbox.loading .lb-stage img { opacity: 0.35; }
.lightbox.zoomed .lb-stage { overflow: auto; align-items: flex-start; justify-content: flex-start; cursor: grab; scrollbar-width: thin; }
.lightbox.zoomed .lb-stage img { max-width: none; max-height: none; margin: auto; border-radius: 0; cursor: zoom-out; }
.lb-spinner {
  position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--cyan) 25%, transparent); border-top-color: var(--cyan);
  animation: lb-spin 0.9s linear infinite; display: none;
}
.lightbox.loading .lb-spinner { display: block; }
@keyframes lb-spin { to { transform: rotate(360deg); } }
.lb-bar {
  display: flex; align-items: center; gap: 0.9rem; min-height: 3.2rem; padding: 0.55rem 1rem;
  background: rgba(5, 8, 13, 0.96); border-top: 1px solid var(--border); color: var(--text); font-size: 0.86rem; line-height: 1.45;
}
.lb-count { flex: 0 0 auto; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; color: var(--text-faint); }
.lb-cap { flex: 1 1 auto; min-width: 0; }
.lb-actions { display: flex; gap: 0.4rem; flex: 0 0 auto; }
.lb-btn {
  min-height: 2rem; padding: 0 0.7rem; border: 1px solid var(--border-strong); border-radius: 6px; background: transparent;
  color: var(--cyan); font: 600 0.72rem var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer;
}
.lb-btn:hover, .lb-btn[aria-pressed="true"] { background: var(--cyan); color: #041016; }
.lb-btn[hidden] { display: none; }
/* Keep the full image and touch controls available with long captions or a short viewport. */
.lightbox { height: 100dvh; padding-bottom: env(safe-area-inset-bottom, 0px); }
.lb-cap { overflow-wrap: anywhere; max-height: 22vh; max-height: 22dvh; overflow-y: auto; }
@media (max-width: 640px), (max-height: 500px) {
  .lb-bar { flex-wrap: wrap; gap: 0.5rem; padding: 0.5rem max(0.75rem, env(safe-area-inset-right)) 0.5rem max(0.75rem, env(safe-area-inset-left)); }
  .lb-cap { flex-basis: 100%; font-size: 0.78rem; }
  .lb-count { display: none; }
  .lb-actions { width: 100%; justify-content: flex-end; }
  .lb-btn { min-width: 44px; min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { .lb-spinner { animation: none; } .lb-stage img { transition: none; } }

/* ── 8. Home: one project-oriented section (three rich cards, image on top) ── */
#home-project-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: stretch; }
#home-project-grid .featured-card { height: 100%; }
#home-project-grid .featured-card .thumbnail-frame { aspect-ratio: 16 / 10; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
#home-project-grid .featured-card .project-summary { -webkit-line-clamp: 3; }
/* keep all four cards on one row as far down as they still fit, so the grid never
   leaves a single card stranded on its own line; only drop to two, then one, when narrow */
@media (max-width: 1024px) { #home-project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px)  { #home-project-grid { grid-template-columns: 1fr; } }

/* the network map now leads the page, so give the frame a little more presence */
.topology-embed-mount { position: relative; }
.topology-embed-mount iframe { border-radius: 10px; background: #05080d; }
/* the embedded map zooms on wheel, which would trap the page scroll; a shield lets the
   page scroll straight past it and only hands the map the wheel/pointer after a click */
.map-shield {
  position: absolute; inset: 0; z-index: 3; cursor: pointer; border-radius: 10px;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 1.1rem;
  background: linear-gradient(to top, color-mix(in srgb, var(--bg) 55%, transparent) 0%, transparent 22%);
  transition: opacity 180ms ease;
}
.map-shield span {
  font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.04em;
  color: var(--text); background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  border: 1px solid var(--border); border-radius: 999px; padding: 0.4rem 0.95rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.topology-embed-mount.map-live .map-shield { opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .map-shield { transition: none; } }

/* ── 9. Project pages: one fixed rhythm — explanation, then diagrams, then screenshots ── */
.project-architecture { margin: 2.75rem 0 0; }
.project-architecture[hidden] { display: none; }
.project-architecture > h2, .project-embeds > h2, .project-gallery > h2 {
  display: flow-root; margin: 0 0 1rem; padding-bottom: 0.25rem; color: var(--cyan); font: 700 1.5rem/1.15 var(--font-display);
}
.project-architecture > h2::after, .project-embeds > h2::after, .project-gallery > h2::after {
  content: ""; display: block; width: 72px; height: 2px; margin-top: 0.7rem;
  background: linear-gradient(90deg, var(--cyan), transparent);
}
.project-embeds > .section-intro { margin-top: 0; }
.project-architecture .project-diagram { margin-top: 1.1rem; }
.project-embeds, .project-gallery { margin-top: 2.75rem; }
.project-gallery .gallery-grid { margin-top: 1.1rem; }

/* ── 10. Live map cards: each card carries its own screenshots underneath ── */
.embed-block { margin: 2rem 0 0; padding-top: 1.6rem; border-top: 1px solid var(--border); }
.embed-block:first-of-type { border-top: 0; padding-top: 0.4rem; }
.embed-block > h3 { margin: 0; color: var(--text); font: 700 1.15rem/1.2 var(--font-display); letter-spacing: 0.01em; }
.embed-note {
  margin: 0.3rem 0 0.9rem; color: var(--text-dim);
  font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.05em; text-transform: uppercase;
}
.embed-block .embed-frame { margin: 0; }
.embed-block .gallery-grid { margin-top: 1.1rem; }

/* ── 11. Thumbnails that stay alive: one radar sweep that spins where the picture's radar is ──
   polish.js sets --sx/--sy (ring centre) and --sd (ring diameter) per cover; anything without
   coordinates gets a centred sweep. Translate and rotate live in ONE transform so nothing fights. */
#home-project-grid .thumbnail-frame::before,
.project-card .thumbnail-frame::before,
.project-cover.thumbnail-frame::before {
  content: ""; position: absolute; left: var(--sx, 50%); top: var(--sy, 50%);
  width: var(--sd, 120%); aspect-ratio: 1; border-radius: 50%;
  z-index: 1; pointer-events: none;
  background: conic-gradient(from 0deg,
    transparent 0deg, transparent 292deg,
    color-mix(in srgb, var(--cyan) 14%, transparent) 330deg,
    color-mix(in srgb, var(--cyan) 46%, transparent) 358deg,
    transparent 360deg);
  mask-image: radial-gradient(circle, #000 0 58%, transparent 74%);
  -webkit-mask-image: radial-gradient(circle, #000 0 58%, transparent 74%);
  animation: card-sweep 5.8s linear infinite;
  mix-blend-mode: screen; opacity: 0.85;
}
.thumbnail-frame.has-sweep::before { opacity: 0.95; }
#home-project-grid .thumbnail-frame::after,
.project-card .thumbnail-frame::after { z-index: 2; }
.project-cover.thumbnail-frame::before { animation-duration: 6.6s; }
#home-project-grid .project-card:hover .thumbnail-frame::before,
.project-card:hover .thumbnail-frame::before { animation-duration: 2.3s; }
@keyframes card-sweep {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Keep the live status pip with its label when metadata wraps. */
.project-card .card-badge span::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  flex: 0 0 7px; margin-right: 0.45rem;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 70%, transparent); animation: pip 2.4s ease-out infinite;
}
@keyframes pip {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 70%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  #home-project-grid .thumbnail-frame::before, .project-card .thumbnail-frame::before,
  .project-cover.thumbnail-frame::before, .project-card .card-badge span::before { animation: none; }
}

/* ── 12. Write-up as closed dropdowns, one per section; the sidebar outline is retired ── */
.document-layout { display: block; }
.toc-shell { display: none !important; }
.doc-controls { display: flex; justify-content: flex-end; gap: 0.5rem; margin: 0 0 0.8rem; }
.doc-controls button {
  min-height: 2rem; padding: 0 0.7rem; border: 1px solid var(--border-strong); border-radius: 6px; background: transparent;
  color: var(--cyan); font: 600 0.68rem var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer;
}
.doc-controls button:hover { background: var(--cyan); color: #041016; }
.doc-section { margin: 0 0 0.7rem; border: 1px solid var(--border); border-radius: 10px; background: color-mix(in srgb, var(--surface) 92%, transparent); overflow: hidden; }
.doc-section > summary { display: flex; align-items: center; gap: 0.85rem; padding: 0.95rem 1.15rem; cursor: pointer; list-style: none; }
.doc-section > summary::-webkit-details-marker { display: none; }
.doc-section > summary::before {
  content: ""; flex: 0 0 auto; width: 0.5rem; height: 0.5rem; border-right: 2px solid var(--text-faint); border-bottom: 2px solid var(--text-faint);
  transform: rotate(-45deg); transition: transform 200ms ease;
}
.doc-section[open] > summary::before { transform: rotate(45deg); border-color: var(--cyan); }
.doc-section > summary:hover { background: color-mix(in srgb, var(--cyan) 7%, transparent); }
.doc-section > summary h2 { margin: 0; color: var(--cyan); font: 700 1.12rem/1.25 var(--font-display); letter-spacing: 0.01em; }
.doc-section-body { padding: 0.2rem 1.25rem 1.2rem; }
.doc-section-body > :first-child { margin-top: 0; }
.doc-intro { margin-bottom: 1rem; }

/* per-frame service tag above the caption */
.shot-kicker { display: block; margin-bottom: 0.3rem; color: var(--cyan); font: 600 0.64rem var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; }

/* ── 13. Project page cover: same 16:10 frame as the home cards, so the art is never cropped ── */
.project-hero .project-cover.thumbnail-frame { aspect-ratio: 16 / 10; height: auto; align-self: center; }
.project-hero .project-cover.thumbnail-frame img { object-position: center; }

/* ── 14. The write up gets a heading row of its own, controls on the right, diagram above it ── */
.writeup-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 2.6rem 0 0.9rem; }
.writeup-head h2 { margin: 0; color: var(--cyan); font: 700 1.5rem/1.2 var(--font-display); }
.writeup-head p { flex-basis: 100%; margin: 0.15rem 0 0; color: var(--text-dim); font-size: 0.9rem; }
.writeup-head .doc-controls { margin: 0; }
.project-architecture { margin-top: 2.2rem; }

/* ── 15. TBD slots: a card always shows three, an empty one says so ── */
.gallery-placeholder { border-style: dashed; background: color-mix(in srgb, var(--surface) 55%, transparent); }
.gallery-placeholder:hover { transform: none; box-shadow: none; border-color: var(--border-strong); }
.gallery-placeholder .placeholder-box {
  aspect-ratio: 16 / 10; display: grid; place-items: center; color: var(--text-faint);
  font: 700 1.05rem var(--font-mono); letter-spacing: 0.28em;
  background: repeating-linear-gradient(135deg, transparent 0 14px, color-mix(in srgb, var(--border) 60%, transparent) 14px 15px);
}
.gallery-placeholder figcaption { color: var(--text-faint); }

/* ── 16. Contain the homepage network map so it no longer dominates the scroll ── */
.topology-embed { width: auto !important; margin-left: 0 !important; transform: none !important; }
.topology-embed-mount iframe { aspect-ratio: 16 / 9; max-height: 66vh; }
@media (max-width: 760px) { .topology-embed-mount iframe { aspect-ratio: 4 / 3; max-height: 70vh; } }

/* Service diagrams use their own bounds, without map chrome or an activation overlay. */
.service-diagram { background: #05080d; }
.diagram-stage { position: relative; width: 100%; }
.diagram-stage > img { display: block; width: 100%; height: auto; }
.diagram-stage .diagram-interactive { position: absolute; inset: 0; display: block; width: 100%; height: 100%; min-height: 0; border: 0; opacity: 0; background: #05080d; }
.diagram-stage.is-interactive > img { opacity: 0; pointer-events: none; }
.diagram-stage.is-interactive .diagram-interactive { opacity: 1; }
.diagram-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font: 11px/1.5 var(--font-mono); color: var(--text-dim); }
.diagram-toolbar button, .diagram-toolbar select { border: 1px solid var(--border); border-radius: 4px; padding: 6px 9px; color: var(--text); background: var(--bg-elev); font: inherit; cursor: pointer; }
.diagram-toolbar button:hover, .diagram-toolbar button[aria-pressed="true"] { border-color: var(--cyan); color: var(--cyan); }
.diagram-toolbar :focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.diagram-toolbar [hidden] { display: none; }
.diagram-speed { display: flex; align-items: center; gap: 5px; }
.diagram-flow-hint { flex-basis: 100%; color: var(--text-dim); font-size: 10px; }
.project-diagram .diagram-stage:hover > img { transform: none; }
.embed-block .service-diagram { width: fit-content; max-width: 100%; margin-inline: auto; }
.embed-block { scroll-margin-top: 7rem; }
.embed-poster { display: block; width: 100%; height: auto; cursor: zoom-in; }
.service-diagram img:focus-visible, .gallery-item img:focus-visible { outline: 3px solid var(--cyan); outline-offset: -3px; }
.embed-block .gallery-grid { grid-template-columns: repeat(var(--gallery-columns, 3), minmax(0, 1fr)); align-items: start; }
.evidence-count { margin: 1.2rem 0 0; color: var(--text-dim); font: 0.78rem var(--font-mono); }
.screenshot-crop { position: relative; overflow: hidden; background: #19191d; aspect-ratio: 1; }
.screenshot-crop img { position: absolute; top: 0; left: 0; width: 100%; height: auto; transition: none; }
.gallery-item:hover .screenshot-crop img { scale: none; }
.embed-block .gallery-item:hover img { transform: none; }
@media (max-width: 1000px) { .embed-block .gallery-grid { grid-template-columns: repeat(var(--gallery-tablet-columns, 2), minmax(0, 1fr)); } }
@media (max-width: 600px) { .embed-block .gallery-grid { grid-template-columns: 1fr; } }
.embed-note, .gallery-item figcaption { white-space: pre-line; overflow-wrap: anywhere; }

/* ── 17. Physical setup: six slots, empty ones say so ── */
#setup-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.setup-item { align-self: start; }
.setup-item img { aspect-ratio: auto; object-fit: contain; }
.setup-item:hover img { transform: none; }
.setup-slot .placeholder-box { aspect-ratio: 4 / 3; }

/* Use the phone width for reading rather than nested desktop gutters. */
.document-layout, .project-body, .doc-section-body, .gallery-item { min-width: 0; }
.project-body figure { max-width: 100%; margin-inline: 0; }
@media (max-width: 600px) {
  .project-body { padding: 0.65rem; }
  .doc-section > summary { padding: 0.85rem 0.75rem; gap: 0.65rem; }
  .doc-section-body { padding: 0.2rem 0.75rem 1rem; }
  .doc-controls { flex-wrap: wrap; }
  .doc-controls button { min-height: 44px; }
}
