/*
   System diagram: the animated SynnoDB architecture (canvas + projected labels).
   Shared by two hosts:
     - the DuckDB case study (casestudy/), scroll-driven through six chapters;
     - the homepage (index.html), locked to the final "whole system" frame.
   system-diagram.js draws the canvas; this file styles the stage, the projected
   DOM labels, and the per-theme diagram tokens both hosts read from `body`.
   Host-specific chrome (case-study intro/caption, homepage section) lives with
   the page, not here.
    */

body {
  /* pre-router dot stream */
  --dg-neutral: #94a0b4;
  /* fast path (Bespoke Engine) */
  --dg-fast: #3b6ef5;
  --dg-fast-glow: #1fc4d4;
  --dg-fast-ink: #2952c8;
  /* fallback path (DuckDB), a muted amber nod to the duck */
  --dg-duck: #bd921f;
  --dg-duck-ink: #8f6a0a;
  /* node shells */
  --dg-node-a: #ffffff;
  --dg-node-b: #f2f6fc;
  --dg-cloud-a: #eef3fa;
  --dg-cloud-b: #d9e4f2;
  --dg-shadow: rgba(15, 27, 45, 0.16);
  --dg-line: rgba(15, 27, 45, 0.20);
}
body[data-theme="dark"] {
  --dg-neutral: #7b8ca3;
  --dg-fast: #2dd4bf;
  --dg-fast-glow: #5eead4;
  --dg-fast-ink: #99e9dd;
  --dg-duck: #d9ae45;
  --dg-duck-ink: #ecd08a;
  --dg-node-a: #182b47;
  --dg-node-b: #0f1d33;
  --dg-cloud-a: #1b2e4c;
  --dg-cloud-b: #12213b;
  --dg-shadow: rgba(0, 0, 0, 0.55);
  --dg-line: rgba(148, 163, 184, 0.30);
}

/* Stage + canvas. The host sizes .dg-stage (sticky full-height on the case
   study, a bounded box on the homepage); here it only needs to clip and to
   host the absolutely-positioned canvas + labels. */
.dg-stage {
  position: relative;
  overflow: hidden;
}
.dg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Static showcase host (homepage + blog embeds): a bounded, framed box. The
   scroll study sizes .dg-stage itself; every static embed shares this frame so
   they stay identical without duplicating the sizing per page. */
.dg-showcase .dg-stage {
  height: min(58vh, 560px);
  margin: 12px auto 0;
  max-width: 1100px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
}
@media (max-width: 820px), (max-height: 680px) {
  .dg-showcase .dg-stage { height: 72vh; min-height: 420px; }
}

/* Projected diagram labels (positioned each frame by system-diagram.js) */
.dg-labels {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}
.dg-label {
  position: absolute;
  left: 0;
  top: 0;
  max-width: 212px;
  opacity: 0;
  will-change: transform, opacity;
}
.dg-label[data-label="cloud"] { text-align: center; }
/* Bespoke label sits to the left of its box, mirroring the general-purpose engine
   label on the right. */
.dg-label[data-label="besp"] { text-align: right; }
/* The case study's caption card occupies the left of the viewport, so cap the
   width there to clear it in the zoomed-in chapters. The homepage has no card
   and keeps the full width, matching the general-purpose label. */
.dg-scrolly .dg-label[data-label="besp"] { max-width: 166px; }
.dg-label b {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--text);
}
.dg-label span {
  display: block;
  margin-top: 3px;
  font-size: 0.73rem;
  line-height: 1.45;
  color: var(--muted);
}
.dg-pill {
  max-width: none;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(4px);
}
.dg-pill-fast { color: var(--dg-fast-ink); border: 1px solid color-mix(in srgb, var(--dg-fast) 42%, transparent); }
.dg-pill-duck { color: var(--dg-duck-ink); border: 1px solid color-mix(in srgb, var(--dg-duck) 46%, transparent); }
.dg-pill-arc {
  color: var(--muted);
  border: 1px dashed var(--dg-line);
  background: color-mix(in srgb, var(--bg) 92%, transparent);  /* sits below the arc */
  text-align: center;
  line-height: 1.3;
}
/* charc label: the pill card, with a plain caption naming the shared format
   sitting below it rather than crammed inside the pill */
.dg-arc-group {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.dg-arc-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}
/* iceberg mark: the shared data lives on disk as Iceberg/Parquet */
.dg-berg {
  flex: none;
  width: 14px;
  height: 14px;
  display: block;
}

/* Small screens: labels shrink to titles */
@media (max-width: 899px) {
  .dg-label { max-width: 130px; }
  .dg-label b { font-size: 0.7rem; }
  .dg-label span { display: none; }
  .dg-label.dg-pill { max-width: none; font-size: 0.55rem; padding: 3px 8px; }
  /* Case study: no room between the engines on a phone; the per-chapter caption
     copy covers the shared-data idea, so drop the arc note there. The homepage
     (dg-showcase) docks both engine labels below their boxes and shows the note
     beneath them (JS `m` variant), so keep it. */
  .dg-scrolly .dg-label.dg-arc-group,
  .dg-scrolly .dg-label.dg-pill-arc { display: none; }
}

/* Portrait phones dock the bespoke label centered below its box (JS `m`
   variant) on both pages, so drop its right alignment. The general-purpose
   label only docks below on the homepage (JS `sm` variant); on the case study
   it stays a side label, so center it there only. */
@media (max-width: 899px) and (orientation: portrait) {
  .dg-label[data-label="besp"] { text-align: center; }
  .dg-showcase .dg-label[data-label="duck"] { text-align: center; }
}

/* Very narrow phones: the two channel pills sit side by side after viewport
   clamping; a smaller face keeps them from touching */
@media (max-width: 419px) {
  .dg-label.dg-pill { font-size: 0.5rem; letter-spacing: 0.05em; padding: 3px 7px; }
}
