/* The diagram panels and everything inside them (DESIGN-R6 §4.5, §6). diagrams.js draws inline SVG
   into each hook; this file reserves the box so nothing shifts when it fills, and colours the parts
   by class (SVG presentation attributes cannot take var()). Habit diagrams are 4:3 at every width;
   the pipeline stacks at (max-width: 899px), the same query as diagrams.js. */

.diagram { display: none; }
.js .diagram {
  display: block;
  position: relative;
  inline-size: 100%;
  /* 492px keeps a desktop habit row as tall as its text (panel 369 + button 31 = 400px). */
  max-inline-size: 492px;
  aspect-ratio: 4 / 3;
  background: var(--deep-2, #141b52);
  border: 1px solid var(--line, rgba(246, 242, 232, .16));
  border-radius: var(--r-panel, 20px);
  overflow: hidden;
  color: var(--foam, #f6f2e8);
  contain: layout paint;
}
/* The pipeline hugs its drawing (960 x 208): about 250px tall at full width. */
.js .diagram[data-diagram='pipeline'] { max-inline-size: none; aspect-ratio: 960 / 208; }
.js .diagram[data-diagram='live'] {
  max-inline-size: none;
  aspect-ratio: auto;
  block-size: 96px;
  border-radius: var(--r-slip, 14px);
}
@media (max-width: 899px) {
  .js .diagram[data-diagram='pipeline'] { max-inline-size: 440px; aspect-ratio: 340 / 560; }
}

.dg-svg { display: block; inline-size: 100%; block-size: 100%; overflow: hidden; }

/* Only one language shows, even if the page's own rule is missing. */
html:not([data-lang='bg']) :is(.diagram, .diagram-replay) [data-lang='bg'],
html[data-lang='bg'] :is(.diagram, .diagram-replay) [data-lang='en'] { display: none; }

/* ---------- type (sizes are SVG attributes, set per layout) ---------- */
.dg-svg .t-mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-weight: 500; }
.dg-svg .t-disp {
  font-family: 'Sofia Sans Extra Condensed', 'Arial Narrow', sans-serif;
  font-weight: 800;
}
.dg-svg .t-body { font-weight: 500; }
.dg-svg .t-bold { font-weight: 700; }

/* ---------- colours (the four roles, the paper, the panel) ---------- */
.dg-svg .f-sea { fill: var(--sea, #2fe0c2); }
.dg-svg .f-coral { fill: var(--coral, #ff5a3d); }
.dg-svg .f-lamp { fill: var(--lamp, #ffc531); }
.dg-svg .f-violet { fill: var(--violet, #8d7bff); }
.dg-svg .f-foam { fill: var(--foam, #f6f2e8); }
.dg-svg .f-foam2 { fill: var(--foam-2, #c7cbea); }
.dg-svg .f-foam3 { fill: var(--foam-3, #9ca3d6); }
.dg-svg .f-deep { fill: var(--deep, #0b1035); }
.dg-svg .f-deep3 { fill: var(--deep-3, #232c78); }
.dg-svg .f-panel { fill: var(--deep-2, #141b52); }
.dg-svg .f-ink { fill: var(--deep, #0b1035); fill-opacity: .28; }
.dg-svg .f-bar { fill: var(--foam-3, #9ca3d6); fill-opacity: .55; }
.dg-svg .k-mark {
  fill: none;
  stroke: var(--deep, #0b1035);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dg-svg :is(.s-line, .s-track) { fill: none; stroke: var(--line, rgba(246, 242, 232, .16)); stroke-linecap: round; }
.dg-svg .f-track { fill: rgba(246, 242, 232, .04); stroke: var(--line, rgba(246, 242, 232, .16)); }
.dg-svg .s-cut { fill: none; stroke: var(--coral, #ff5a3d); stroke-linecap: round; }
.dg-svg .s-sea { fill: none; stroke: var(--sea, #2fe0c2); stroke-width: 2; }
.dg-svg :is(.s-prog, .s-loop) { fill: none; stroke-dasharray: 1; }
.dg-svg .s-prog { stroke: var(--foam-3, #9ca3d6); }
.dg-svg .s-loop { stroke: var(--foam-3, #9ca3d6); stroke-width: 1.5; }
.dg-svg .s-edge { stroke: var(--line, rgba(246, 242, 232, .16)); stroke-width: 1.5; }
.dg-svg .s-panel { stroke: var(--deep-2, #141b52); stroke-width: 3; }
.dg-svg .s-ring { fill: none; stroke-width: 2; }
.dg-svg .r-coral { stroke: var(--coral, #ff5a3d); }
.dg-svg .r-sea { stroke: var(--sea, #2fe0c2); }
.dg-svg .r-lamp { stroke: var(--lamp, #ffc531); }

/* Icons are <use> references into /assets/icons-v1.svg: the sprite paints with currentColor (the
   stroke and the duotone accent), so a class here sets `color`, never `fill`. */
.dg-svg .i-deep { color: var(--deep, #0b1035); }
.dg-svg .i-dim { color: var(--foam-3, #9ca3d6); }
.dg-svg .i-violet { color: var(--violet, #8d7bff); }

/* Scale and pop around the part's own box. */
.dg-svg :is(.o-c, .o-l, .o-r) { transform-box: fill-box; }
.dg-svg .o-c { transform-origin: center; }
.dg-svg .o-l { transform-origin: left center; }
.dg-svg .o-r { transform-origin: right center; }

/* ---------- the wrapper diagrams.js puts round each hook and its button ---------- */
/* It takes the hook's grid cell: keep this query equal to base.css's two-column habit row. */
.diagram-fig { min-inline-size: 0; }
@media (min-width: 900px) {
  .habit > .diagram-fig { grid-column: 2; grid-row: 1; }
}

/* ---------- the replay button (outside the aria-hidden box) ---------- */
.diagram-replay {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-block-start: 6px;
  padding: 2px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: .875rem;
  line-height: 1.5;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  cursor: pointer;
}
.diagram-replay:not(.is-ready) { visibility: hidden; }
.diagram-replay:hover { text-decoration-thickness: 2px; }
.diagram-replay:focus-visible {
  outline: 3px solid var(--focus, var(--sea, #2fe0c2));
  outline-offset: 3px;
  border-radius: 4px;
}
.dg-sr {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
