/* VAULT: "The vault has rules." Rebuilt diagram (replaces vault-art.js).
   Vector only: HTML text and HTML/SVG line pieces, pixel glyphs on a 3px grid with
   crispEdges. Every selector is .vault-* or scoped under .protection-section.
   Uses the page's .wrap, .section, .section-heading, h2, code and .reveal as is.
   Layout is driven by the component's own width (container "vault"):
     >= 1152px  one shared map of the vault's moves. One geometry: every x is
                a + k * --e, where --e is a quarter of the width over 1152, in whole
                pixels, so the map always spans the wrap and nothing scales.
     840..1151  per mode vertical flow beside the panel text
     <  840     per mode vertical flow, then the panel text                      */

.protection-section {
  --vault-check-on: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6' shape-rendering='crispEdges'%3E%3Crect width='3' height='3' fill='%231b2b41'/%3E%3Crect x='3' y='3' width='3' height='3' fill='%231b2b41'/%3E%3C/svg%3E");
  --vault-check-off: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6' shape-rendering='crispEdges'%3E%3Crect width='3' height='3' fill='%238db1c1'/%3E%3Crect x='3' y='3' width='3' height='3' fill='%238db1c1'/%3E%3C/svg%3E");
  --vault-dash-off: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='3' height='18' shape-rendering='crispEdges'%3E%3Crect width='3' height='12' fill='%238db1c1'/%3E%3C/svg%3E");
}
.protection-section .vault-shell { container: vault / inline-size; }

/* State tones. Everything is "off" (Mineral) unless it is on the chosen path. */
.protection-section .vault-figure {
  --vault-tone: var(--mineral);
  --vault-text: var(--muted);
  --vault-b: var(--ramp-2);
  --vault-c: var(--paper);
  --vault-check: var(--vault-check-off);
  margin: 0;
}
.vault-figure [data-paths] {
  --vault-tone: var(--mineral);
  --vault-text: var(--muted);
  --vault-b: var(--ramp-2);
  --vault-check: var(--vault-check-off);
}
.vault-figure[data-mode="payout"] [data-paths~="payout"],
.vault-figure[data-mode="sweep"] [data-paths~="sweep"],
.vault-figure[data-mode="veto"] [data-paths~="veto"] {
  --vault-tone: var(--ink);
  --vault-text: var(--ink);
  --vault-b: var(--mineral);
  --vault-check: var(--vault-check-on);
}

/* TABS ------------------------------------------------------------------ */
.vault-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 32px; }
.vault-tabs button {
  display: inline-flex; align-items: center; min-height: 44px; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: 9999px; background: transparent;
  font-size: 14px; line-height: 20px; font-weight: 600;
  transition: background-color 300ms var(--ease), border-color 300ms var(--ease), color 300ms var(--ease), transform 300ms var(--ease);
}
.vault-tabs button:hover:not([aria-selected="true"]) { background: var(--paper-soft); }
.vault-tabs button:active { transform: scale(.98); }
.vault-tabs button[aria-selected="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }

/* GLYPHS ---------------------------------------------------------------- */
.vault-glyph { display: block; flex: none; width: 48px; height: 48px; }
.vault-px-a { fill: var(--vault-tone); }
.vault-px-b { fill: var(--vault-b); }
.vault-px-c { fill: var(--vault-c); }
.vault-px-a, .vault-px-b { transition: fill 300ms var(--ease); }

/* DESKTOP MAP ----------------------------------------------------------- */
.vault-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.vault-map { display: none; position: relative; height: 656px; --e: 0px; }
@supports (left: round(down, 10%, 1px)) {
  /* 100% is the map's own width wherever --e is used (left and width of its pieces). */
  .vault-map { --e: clamp(0px, round(down, (100% - 1152px) / 4, 1px), 32px); }
}
.vault-wire { display: contents; }
.vault-map > :not(.vault-wire), .vault-wire > * {
  position: absolute; top: var(--y);
  left: calc(var(--x) + var(--xe, 0) * var(--e));
  width: calc(var(--w) + var(--we, 0) * var(--e));
  height: var(--h, auto);
}
.vault-map > .is-right { right: 0; width: auto; }
.vault-wire svg { display: block; overflow: hidden; }
.vault-wire rect { fill: var(--vault-tone); transition: fill 300ms var(--ease); }
.vault-line { background-color: var(--vault-tone); transition: background-color 300ms var(--ease); }
.vault-dither { background: var(--paper) var(--vault-check) 0 0 / 6px 6px repeat; }

.vault-node {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px;
  border: 2px solid var(--vault-tone); background: var(--paper);
  transition: border-color 300ms var(--ease);
}
.vault-node p, .vault-head p { margin: 0; min-width: 0; }
.vault-node strong { display: block; font-size: 16px; line-height: 24px; font-weight: 600; color: var(--vault-text); transition: color 300ms var(--ease); }
.vault-node span, .vault-head span { display: block; font-size: 14px; line-height: 20px; color: var(--muted); text-wrap: pretty; }

/* The vault: its name and role, then a narrow wall with one door per move. */
.vault-head { display: flex; align-items: flex-start; gap: 12px; }
.vault-head strong { display: block; font-size: 20px; line-height: 28px; font-weight: 600; color: var(--vault-text); transition: color 300ms var(--ease); }
.vault-column { border: 2px solid var(--vault-tone); transition: border-color 300ms var(--ease); }
.vault-port {
  position: absolute; right: 20px; top: var(--py);
  font-size: 14px; line-height: 20px; font-weight: 600; color: var(--vault-text); text-align: right;
  transition: color 300ms var(--ease);
}

.vault-tag {
  margin: 0; font-size: 14px; line-height: 20px; color: var(--vault-text); text-wrap: pretty;
  transition: color 300ms var(--ease);
}
.vault-tag.is-time { font-weight: 600; }
.vault-tag.is-end { text-align: right; }
.protection-section .vault-figure code { font-size: 1em; letter-spacing: -.02em; font-synthesis: none; }

/* CAPTION AND KEY -------------------------------------------------------- */
.vault-caption {
  display: grid; gap: 16px; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 14px; line-height: 20px;
}
.vault-caption p { margin: 0; }
.vault-caption-live { max-width: 800px; color: var(--ink); }
.vault-key { display: flex; flex-wrap: wrap; gap: 8px 32px; color: var(--muted); }
.vault-key-item { display: inline-flex; align-items: center; gap: 8px; }
.vault-swatch { display: block; flex: none; }
.vault-swatch rect { fill: var(--ink); }
.vault-key-item.is-off rect { fill: var(--mineral); }

/* VERTICAL FLOWS (below 1152px) ------------------------------------------ */
.vault-flow ol { margin: 0; padding: 0; list-style: none; }
.vault-flow + .vault-flow { margin-top: 48px; }
.vault-flow-title { margin: 0 0 24px; font-size: 18px; line-height: 28px; font-weight: 600; }
.vault-flow li {
  --vault-tone: var(--ink); --vault-b: var(--mineral);
  position: relative; display: grid; grid-template-columns: 48px minmax(0, 1fr); column-gap: 16px;
}
.vault-flow li::before { content: ""; position: absolute; left: 22px; width: 3px; top: 0; bottom: 0; background: var(--ink); }
.vault-flow li:first-child::before { top: 48px; }
.vault-flow li:last-child::before, .vault-flow-node.is-end::before { display: none; }
.vault-flow-node { padding-bottom: 8px; }
.vault-flow-node::before { top: 48px !important; }
.vault-flow-node .vault-glyph { position: relative; z-index: 1; background: var(--paper); }
.vault-flow-text { grid-column: 2; min-width: 0; max-width: 560px; }
.protection-section .vault-flows code { white-space: nowrap; }
.vault-flow-text p { margin: 0; }
.vault-flow-name { font-size: 16px; line-height: 24px; font-weight: 600; }
.vault-flow-role, .vault-flow-detail { font-size: 14px; line-height: 20px; color: var(--muted); }
.vault-flow-edge { padding: 8px 0 24px; }
.vault-flow-edge::after {
  content: ""; position: absolute; left: 13px; bottom: 0; width: 21px; height: 12px; background: var(--vault-tone);
  clip-path: polygon(0 0, 100% 0, 100% 25%, 85.71% 25%, 85.71% 50%, 71.43% 50%, 71.43% 75%, 57.14% 75%, 57.14% 100%, 42.86% 100%, 42.86% 75%, 28.57% 75%, 28.57% 50%, 14.29% 50%, 14.29% 25%, 0 25%);
}
.vault-flow-edge::before { bottom: 12px !important; }
.vault-flow-action { font-size: 14px; line-height: 20px; font-weight: 600; }
.vault-flow-window { padding: 8px 0 24px; }
.vault-flow-break { padding: 24px 0 16px; }
.vault-flow-break::before { display: none; }
.vault-flow-break-text { grid-column: 2; font-size: 14px; line-height: 20px; font-weight: 600; color: var(--muted); }
/* The separate recovery path: a dashed Mineral spine, like the dashed line on the map. */
.vault-flow li.is-aside { --vault-tone: var(--mineral); --vault-b: var(--ramp-2); }
.vault-flow li.is-aside::before { background: var(--vault-dash-off) 0 0 / 3px 18px repeat-y; }

/* The mini time strip: a framed, dithered review window, then the open line. */
.vault-strip { display: flex; align-items: center; height: 21px; margin-bottom: 12px; }
.vault-strip-window { flex: 1 1 0; height: 15px; border: 3px solid var(--mineral); background: var(--paper) var(--vault-check-off) 0 0 / 6px 6px repeat; }
.vault-strip-after { position: relative; flex: 1 1 0; height: 3px; background: var(--mineral); border-left: 3px solid var(--mineral); }
.vault-strip-after::before { content: ""; position: absolute; left: -3px; top: -9px; width: 3px; height: 21px; background: inherit; }
.vault-strip-after::after {
  content: ""; position: absolute; right: 0; top: -9px; width: 12px; height: 21px; background: inherit;
  clip-path: polygon(0 0, 25% 0, 25% 14.29%, 50% 14.29%, 50% 28.57%, 75% 28.57%, 75% 42.86%, 100% 42.86%, 100% 57.14%, 75% 57.14%, 75% 71.43%, 50% 71.43%, 50% 85.71%, 25% 85.71%, 25% 100%, 0 100%);
}
.vault-strip--before .vault-strip-window { border-color: var(--ink); background-image: var(--vault-check-on); }
.vault-strip--after .vault-strip-after { background: var(--ink); }
.vault-strip-labels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.vault-strip-labels p { font-size: 14px; line-height: 20px; color: var(--muted); }
.vault-strip-labels .vault-strip-time { font-weight: 600; }
.vault-strip-label.is-focus p { color: var(--ink); }

/* PANELS ---------------------------------------------------------------- */
.vault-panels { margin-top: 48px; }
.protection-section .vault-panels code { white-space: nowrap; }
.vault-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 80px; padding-top: 32px; border-top: 1px solid var(--line); }
.vault-panel + .vault-panel { margin-top: 48px; }
.vault-panel:focus-visible { outline-offset: 8px; }
.vault-panel-lead h3 { margin: 0 0 24px; font-size: 36px; line-height: 40px; font-weight: 500; letter-spacing: -.04em; }
.vault-panel-lead p { max-width: 560px; margin: 0; color: var(--muted); }
.vault-panel-facts { margin: 0; border-top: 1px solid var(--line); }
.vault-panel-facts > div { padding-block: 24px; border-bottom: 1px solid var(--line); }
.vault-panel-facts > div:last-child { border-bottom: 0; padding-bottom: 0; }
.vault-panel-facts dt { margin-bottom: 8px; font-size: 18px; line-height: 28px; font-weight: 600; }
.vault-panel-facts dd { max-width: 560px; margin: 0; color: var(--muted); }

.vault-boundary { max-width: 960px; margin: 48px 0 0; padding-top: 24px; border-top: 1px solid var(--line); color: var(--muted); }
.vault-boundary strong { color: var(--ink); font-weight: 600; }

/* ENHANCED (JS): one mode at a time ------------------------------------- */
.protection-section[data-vault-ready] .vault-flow-title,
.protection-section .vault-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
.protection-section[data-vault-ready] .vault-panel + .vault-panel { margin-top: 0; }

/* LAYOUTS BY COMPONENT WIDTH -------------------------------------------- */
@container vault (min-width: 1152px) {
  .vault-map { display: block; }
  .vault-panel:first-child, .protection-section[data-vault-ready] .vault-panel { border-top: 0; padding-top: 0; }
  .vault-flows {
    position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
}
@container vault (min-width: 840px) and (max-width: 1151.98px) {
  .vault-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 64px; align-items: start; }
  .vault-tabs { grid-column: 1 / -1; }
  .vault-panels { margin-top: 0; }
  .vault-panel { display: block; padding-top: 0; border-top: 0; }
  .vault-panel-facts { margin-top: 32px; }
}
@container vault (max-width: 1151.98px) {
  .vault-caption { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; padding: 0; border: 0; }
}
@container vault (max-width: 839.98px) {
  .vault-panels { margin-top: 40px; }
  .vault-panel { display: block; padding-top: 24px; }
  .vault-panel-facts { margin-top: 24px; }
}
@container vault (max-width: 479.98px) {
  .vault-tabs { display: grid; grid-template-columns: 1fr; margin-bottom: 24px; }
  .vault-flow li { grid-template-columns: 48px minmax(0, 1fr); column-gap: 12px; }
  .vault-strip-labels { gap: 12px; }
}

@media (max-width: 900px) {
  .vault-panel-lead h3 { margin-bottom: 16px; font-size: 30px; line-height: 36px; }
  .vault-panel-facts dt { font-size: 16px; line-height: 24px; }
  .vault-boundary { margin-top: 32px; }
}

/* STEP THROUGH: only after a tab is chosen, never under reduced motion. ---- */
.vault-figure.is-stepping[data-mode="payout"] [data-paths~="payout"],
.vault-figure.is-stepping[data-mode="sweep"] [data-paths~="sweep"],
.vault-figure.is-stepping[data-mode="veto"] [data-paths~="veto"] { --vault-delay: calc(var(--vault-step, 0) * 110ms); }
.vault-figure.is-stepping [data-paths] .vault-px-a,
.vault-figure.is-stepping [data-paths] .vault-px-b,
.vault-figure.is-stepping .vault-node,
.vault-figure.is-stepping .vault-node strong,
.vault-figure.is-stepping .vault-head strong,
.vault-figure.is-stepping .vault-column,
.vault-figure.is-stepping .vault-port,
.vault-figure.is-stepping .vault-tag,
.vault-figure.is-stepping .vault-line,
.vault-figure.is-stepping .vault-wire rect { transition-delay: var(--vault-delay, 0ms); }
.vault-figure.is-stepping .vault-flow:not([hidden]) li { animation: vault-rise 500ms var(--ease) both; animation-delay: calc(var(--i) * 50ms); }
@keyframes vault-rise { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  .vault-figure *, .vault-tabs button { transition: none !important; animation: none !important; }
}
