/*
 * Schaubilder im Beitrag (Florian, 30.10.2026: „wir stellen das wirklich nativ nach“).
 * Übernommen aus der fuerst.ai-Website (adminfuerst/fuerst-ai-website, src/styles/diagrams.css, Stand 28.10.2026),
 * nur die Website-Tokens auf die Zeitgeist-Tokens umgelegt; Erzeugung workflows/grafik/diagramm/diagramm.js,
 * Linien und „Beispiel durchspielen“ in assets/js/zeitgeist.js.
 */
.dg {
  --petrol: var(--zg-petrol); --petrol-60: #6b919a; --petrol-20: #cedadd; --offwhite: var(--zg-paper);
  --turkis: var(--zg-tuerkis); --lila: #702b99; --darkgrey: var(--zg-grey); --strong: var(--zg-petrol);
  --font-display: var(--zg-display); --measure: 41rem;
}
.dg .dg-play { min-height: 44px; padding: .6rem 1rem; background: transparent; color: var(--zg-petrol); border: 1px solid currentColor;
  font: 600 .8rem/1.15 var(--zg-display); letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
.dg .dg-play:hover { color: var(--zg-ink); }
/*
 * Workflow diagrams (`<!-- diagram: <id> -->`, data in src/lib/diagrams.ts).
 * Florian, 28.10.: they should look like n8n workflows. So: a dotted canvas,
 * the phases as notes on it, each box a tile with its icon and the name
 * underneath, the tools of an agent hanging below it on dashed lines, the
 * connections drawn as curves by the script in Base.astro. Brand rules kept:
 * square corners, brand colours only (Türkis for lines and the active tile,
 * Lila only for "a person checks"), titles in Area, notes in Garamond.
 */
.dg {
  --dg-line: var(--petrol-60);
  --dg-tile: #fff;
  --dg-wire: var(--petrol-60);
  --dg-canvas: var(--offwhite);
  --dg-dots: var(--petrol-20);
  position: relative;
  margin: 2rem 0 0;
}
  --dg-line: rgba(245, 242, 240, 0.45);
  --dg-tile: #0b5466;
  --dg-wire: rgba(245, 242, 240, 0.55);
  --dg-canvas: rgba(0, 0, 0, 0.18);
  --dg-dots: rgba(245, 242, 240, 0.14);
}

/* Level switcher (the three levels on the services page). */
.dg-switch { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1.5rem; }
.dg-level {
  min-height: 44px;
  padding: 0.6rem 0.9rem;
  background: transparent;
  color: var(--strong);
  border: 1px solid var(--dg-line);
  font: 600 0.8rem/1.15 var(--font-display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}
.dg-level:hover { border-color: var(--strong); }
.dg-level[aria-pressed='true'] { background: var(--petrol); color: var(--offwhite); border-color: var(--petrol); }
.dg-intro { max-width: var(--measure); margin: 0 0 1.5rem; }

/* The sovereignty band of the RAG agent: a turquoise line, a label, one sentence. */
.dg-band { margin: 0 0 1.75rem; padding-top: 0.75rem; border-top: 2px solid var(--turkis); max-width: 48rem; font-size: 0.9em; }
.dg-band strong { display: block; font: 600 0.8rem/1.2 var(--font-display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--strong); margin-bottom: 0.3rem; }

/* The canvas: dots as in the n8n editor. */
.dg-canvas {
  position: relative;
  padding: clamp(1rem, 0.6rem + 1.5vw, 2rem);
  background-color: var(--dg-canvas);
  background-image: radial-gradient(circle, var(--dg-dots) 1.1px, transparent 1.4px);
  background-size: 20px 20px;
  border: 1px solid var(--dg-line);
}
.dg-wires { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; overflow: visible; color: var(--dg-wire); }
.dg-wires path { fill: none; stroke: currentColor; stroke-width: 1.5; }
.dg-wires .is-sub { stroke-dasharray: 5 4; }
.dg-wires .handle { fill: var(--dg-tile); stroke: currentColor; stroke-width: 1.5; }
.dg-wires .arrow { fill: currentColor; stroke: none; }

.dg-phases, .dg-nodes, .dg-subs ol { list-style: none; margin: 0; padding: 0; }
.dg-phases { display: flex; flex-wrap: wrap; gap: 2rem 3rem; align-items: flex-start; }

/* A phase is a note, like the coloured sticky notes in n8n, in brand tints. */
.dg-phase {
  flex: var(--cols) 1 calc(var(--cols) * 11.5rem);
  margin: 0;
  padding: 0.9rem 1.1rem 1.25rem;
  background: rgba(18, 232, 242, 0.09);
  border: 1px solid rgba(8, 71, 87, 0.12);
}
.dg-phase:nth-child(3n + 2) { background: rgba(8, 71, 87, 0.07); }
.dg-phase:nth-child(3n + 3) { background: rgba(83, 82, 81, 0.07); }
/* `.dg .` so that `.row p { margin: 0 }` in the case rows does not win. */
.dg .dg-phase-title { margin: 0 0 1.25rem; font: 600 0.95rem/1.25 var(--font-display); color: var(--strong); }

/* Boxes side by side inside a note; alternatives stacked. */
.dg-nodes { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 1.5rem 3rem; }
.dg-phase--parallel .dg-nodes { grid-auto-flow: row; gap: 1.25rem; }

.dg-node { position: relative; z-index: 2; margin: 0; display: grid; justify-items: center; align-content: start; gap: 0.55rem; text-align: center; }
.dg-text { display: grid; gap: 0.2rem; justify-items: center; }

/* The tile: a square with the icon, as an n8n node. An agent is wider and names itself. */
.dg-tile {
  position: relative;
  display: grid;
  place-items: center;
  width: 4.5rem;
  height: 4.5rem;
  background: var(--dg-tile);
  border: 1px solid var(--dg-line);
  color: var(--strong);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.dg-svg { width: 2rem; height: 2rem; }
.dg-bolt { position: absolute; left: -1.35rem; top: 50%; width: 1rem; height: 1rem; margin-top: -0.5rem; color: var(--strong); }
.dg-node--agent > .dg-tile, .dg-node--human > .dg-tile { width: 9rem; grid-auto-flow: column; gap: 0.6rem; }
.dg-node--agent > .dg-tile .dg-svg, .dg-node--human > .dg-tile .dg-svg { width: 1.75rem; height: 1.75rem; }
.dg-tile .dg-tile-text { font-size: 0.85rem; text-align: left; color: inherit; }
.dg-node--agent > .dg-tile, .dg-node--human > .dg-tile { width: auto; min-width: 9rem; padding: 0 1rem; }
/* The name stands in the wide tile; underneath only on phones, where the tile is small. */
.dg-node--agent > .dg-text > .dg-label, .dg-node--human > .dg-text > .dg-label { display: none; }
.dg-node--human > .dg-tile { border-color: var(--lila); color: var(--lila); }
.dg-node--muted { opacity: 0.6; }
.dg-node--muted .dg-tile { border-style: dashed; }

.dg-label { font: 600 0.92rem/1.25 var(--font-display); color: var(--strong); }
.dg-tools { font: 400 0.78rem/1.3 var(--font-display); letter-spacing: 0.02em; opacity: 0.8; }
.dg-note { font-size: 0.95rem; line-height: 1.45; max-width: 17rem; }
.dg-example { display: none; font-size: 0.95rem; line-height: 1.4; max-width: 17rem; padding-top: 0.35rem; border-top: 1px solid var(--turkis); }
.dg-example em { font-style: normal; font-weight: 600; }
.dg-node.is-active .dg-example, .dg-node.is-played .dg-example { display: block; }

/* The active tile while playing an example: a turquoise edge on the tile itself. */
.dg-node.is-active .dg-tile { border-color: var(--turkis); box-shadow: 0 0 0 3px rgba(18, 232, 242, 0.35); }

/* An agent's tools hang below it on dashed lines, as sub-nodes in n8n. */
.dg-subs { margin-top: 2.75rem; display: grid; gap: 0.9rem; justify-items: center; }
.dg-subs ol { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 1.5rem; }
.dg-subs-title { order: 2; margin: 0; font-size: 0.85rem; line-height: 1.4; max-width: 30rem; opacity: 0.85; }
.dg-tile--sub { width: 3.5rem; height: 3.5rem; }
.dg-tile--sub .dg-svg { width: 1.6rem; height: 1.6rem; }
.dg-node--has-subs { grid-column: span 2; grid-template-columns: auto minmax(0, 17rem); justify-content: center; column-gap: 1.25rem; text-align: left; }
/* With tools below, the agent's text stands beside it, so the dashed lines run free. */
.dg-node--has-subs > .dg-text { justify-items: start; align-self: center; }
.dg-node--has-subs > .dg-subs { grid-column: 1 / -1; }

/* Play bar and the travelling point. */
.dg-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-top: 1.25rem; }
.dg-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dg-dot {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  width: 10px;
  height: 10px;
  background: var(--turkis);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.9s cubic-bezier(0.3, 0.8, 0.25, 1), opacity 0.3s ease;
}
.dg-dot.is-on { opacity: 1; }
.dg figcaption { margin-top: 0.75rem; font-size: 0.85em; opacity: 0.8; }

/* Phones: the boxes run downwards, tile on the left, text beside it. */
@media (max-width: 40rem) {
  .dg-phases { gap: 1.75rem; }
  .dg-phase { flex-basis: 100%; }
  .dg-nodes, .dg-subs ol { grid-auto-flow: row; gap: 1.75rem; }
  .dg-node { grid-template-columns: auto minmax(0, 1fr); justify-items: start; align-items: start; text-align: left; gap: 0 1.5rem; }
  .dg-text { justify-items: start; }
  .dg-tile { width: 3.5rem; height: 3.5rem; }
  .dg-svg { width: 1.6rem; height: 1.6rem; }
  .dg-node--agent > .dg-tile, .dg-node--human > .dg-tile { width: 3.5rem; }
  .dg-node--agent > .dg-tile, .dg-node--human > .dg-tile { min-width: 0; padding: 0; }
  .dg-node--agent > .dg-tile .dg-tile-text, .dg-node--human > .dg-tile .dg-tile-text { display: none; }
  .dg-node--agent > .dg-text > .dg-label, .dg-node--human > .dg-text > .dg-label { display: inline; }
  .dg-bolt { left: -1.2rem; }
  /* The title stands beside the line of tiles, not on it. */
  .dg .dg-phase-title { padding-left: 4.5rem; }
  .dg-subs { grid-column: 1 / -1; justify-items: start; margin: 1.75rem 0 0 1.5rem; }
  .dg-node--has-subs { grid-column: auto; grid-template-columns: auto minmax(0, 1fr); justify-content: start; }
}

@media (prefers-reduced-motion: reduce) {
  .dg-bar, .dg-dot { display: none; }
  .dg-tile { transition: none; }
}

/* In the workshop and case rows the diagram runs across the whole row, below text and photo. */
.row > .dg { grid-column: 1 / -1 !important; grid-row: auto !important; max-width: none !important; margin-top: 2rem; }

/* Portal screenshots: a plain Dark Grey browser frame, three dots, no shadow. */
.photo.screen::before {
  content: '';
  display: block;
  height: 1.5rem;
  background-color: var(--darkgrey);
  background-image:
    radial-gradient(circle at 0.9rem 50%, rgba(245, 242, 240, 0.7) 0 0.2rem, transparent 0.22rem),
    radial-gradient(circle at 1.6rem 50%, rgba(245, 242, 240, 0.7) 0 0.2rem, transparent 0.22rem),
    radial-gradient(circle at 2.3rem 50%, rgba(245, 242, 240, 0.7) 0 0.2rem, transparent 0.22rem);
  background-repeat: no-repeat;
}
.photo.screen img, .row .photo.screen img { border: 1px solid var(--darkgrey); border-top: 0; }

/* The real figures of a portal, next to its screenshot. */
.s-cases .row > ul {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
}
.s-cases .row > ul li { margin: 0; font-size: 0.9em; line-height: 1.3; }
.s-cases .row > ul strong { display: block; font: 600 clamp(1.6rem, 1.3rem + 1vw, 2.25rem)/1.05 var(--font-display); color: var(--strong); }

/*
 * Zeitgeist, technical build (`<!-- diagram: zeitgeist-aufbau -->`), after
 * Florian's overview: build once | daily operation | outside, the human as
 * publisher underneath. Boxes as glass on the dark section, turquoise only for
 * lines, arrows and model tags.
 */

/* Zeitgeist: Icons kommen als Platzhalter (span[data-icon]) und werden im Browser gefüllt; weitere Stufen bis dahin verborgen. */
.dg-svg, .dg-bolt { display: inline-flex; flex: none; }
.dg-svg > svg, .dg-bolt > svg { width: 100%; height: 100%; }
.dg:not(.dg-ready) .dg-variant[data-hidden] { display: none; }
