@import url("../vendor/marinos/marinos.css");

.card p {
  color: var(--app-muted);
}

.view-toggle {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  background: var(--app-surface);
}

.view-toggle button {
  padding: 0.35rem 0.9rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--app-muted);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
}

.view-toggle button:hover {
  color: var(--app-text);
}

.view-toggle button[aria-selected="true"] {
  background: var(--app-accent);
  color: var(--app-bg);
}

.flow-group {
  margin-top: 1.25rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--app-border);
}

.flow-group:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.flow-group__title {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.flow-nodes {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.flow-node {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.flow-node + .flow-node {
  margin-top: 0.75rem;
}

.flow-node__rail {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  align-items: center;
  justify-content: center;
}

.flow-node:not(:first-child) .flow-node__rail::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -0.75rem;
  width: 2px;
  height: 0.75rem;
  background: var(--app-border);
  transform: translateX(-50%);
}

.flow-node__body {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 0.1rem;
}

.flow-node__toggle {
  display: flex;
  width: 100%;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--app-border);
  border-radius: var(--pico-border-radius);
  background: var(--app-surface);
  color: var(--app-text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.flow-node__toggle:hover,
.flow-node__toggle[aria-expanded="true"] {
  border-color: var(--app-accent);
}

.flow-node__detail {
  margin-top: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--app-border);
  border-radius: var(--pico-border-radius);
  background: var(--app-surface);
  font-size: 0.9rem;
}

.flow-node__detail p {
  margin: 0 0 0.5rem;
}

.flow-node__detail .mini-dl {
  margin: 0.35rem 0 0;
}

.chart-legend {
  margin: 0 0 1.5rem;
  color: var(--app-muted);
  font-size: 0.85rem;
}

.chart-legend__swatch {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  margin: 0 0.3rem 0 1rem;
  border-radius: 2px;
  vertical-align: middle;
}

.chart-legend__swatch:first-of-type {
  margin-left: 0.35rem;
}

.chart-legend__swatch--event {
  border-radius: 50%;
  border: 2px solid var(--app-text);
}

.chart-legend__swatch--decision {
  border-radius: 0;
  border: 2px solid var(--app-accent);
  transform: rotate(45deg) scale(0.8);
}

.chart-legend__swatch--terminal {
  border: 2px solid var(--app-success);
}

.chart-legend__swatch--undocumented {
  border: 1px dashed var(--app-border);
}

.flow-chart {
  position: relative;
  display: grid;
  grid-auto-rows: min-content;
  row-gap: 2.5rem;
  column-gap: 1.5rem;
  padding: 0.5rem 0 1rem;
}

.chart-node {
  position: relative;
  z-index: 1;
  align-self: start;
  min-width: 12rem;
  max-width: 16rem;
}

.chart-node--terminal {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--app-success);
  border-radius: 999px;
  background: color-mix(in srgb, var(--app-success) 12%, var(--app-surface));
}

.chart-node--terminal .chart-node__title {
  font-weight: 700;
}

.chart-node--undocumented {
  padding: 0.5rem 0.75rem;
  border: 1px dashed var(--app-border);
  border-radius: var(--pico-border-radius);
  color: var(--app-muted);
  font-size: 0.85rem;
  font-style: italic;
}

/* BPMN start/end events: plain circles, decorative markers distinct from every
   task/gateway shape — a thin border for start, a thick border for end, per
   standard BPMN 2.0 notation. */
.chart-node--event {
  justify-self: center;
  width: 2rem;
  height: 2rem;
  min-width: 0;
  max-width: none;
  border-radius: 50%;
  background: var(--app-surface);
}

.chart-node--event-start {
  border: 2px solid var(--app-text);
}

.chart-node--event-end {
  border: 4px solid var(--app-text);
}

.chart-node__toggle {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--app-border);
  border-radius: var(--pico-border-radius);
  background: var(--app-surface);
  color: var(--app-text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.chart-node--decision .chart-node__toggle {
  border-color: var(--app-accent);
}

.chart-node__toggle:hover,
.chart-node__toggle[aria-expanded="true"] {
  border-color: var(--app-accent);
}

.chart-node__title {
  flex: 1 1 auto;
}

/* BPMN exclusive-gateway marker: a small fixed-size diamond with an "X" —
   not stretched to fit the question text (that's shown separately, in
   .chart-node__question), which is what makes a literal diamond legible
   here regardless of how long the question is. */
.chart-node__decision-mark {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  width: 0.9rem;
  height: 0.9rem;
  margin-left: 0.15rem;
  border: 2px solid var(--app-accent);
  transform: rotate(45deg);
}

.chart-node__decision-mark::before,
.chart-node__decision-mark::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.65rem;
  height: 2px;
  background: var(--app-accent);
  transform-origin: center;
}

.chart-node__decision-mark::before {
  transform: translate(-50%, -50%);
}

.chart-node__decision-mark::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.chart-node__question {
  margin: 0.4rem 0 0;
  padding-top: 0.4rem;
  border-top: 1px solid var(--app-border);
  color: var(--app-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.chart-node__detail {
  margin-top: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--app-border);
  border-radius: var(--pico-border-radius);
  background: var(--app-surface);
  font-size: 0.9rem;
}

.chart-node__detail p {
  margin: 0 0 0.5rem;
}

.chart-node__branches {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}

.chart-node__branches li {
  margin: 0.3rem 0;
}

.chart-node__branches a {
  color: var(--app-accent);
  text-decoration: none;
}

.chart-node__branches a:hover {
  text-decoration: underline;
}

.chart-node__condition {
  color: var(--app-muted);
  font-size: 0.85rem;
}

.flow-chart__edges {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  pointer-events: none;
}

.flow-chart__edge {
  fill: none;
  stroke: var(--app-border);
  stroke-width: 1.5;
}

.flow-chart__arrowhead {
  fill: none;
  stroke: var(--app-border);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.flow-chart__edge-label {
  fill: var(--app-muted);
  font-family: var(--app-font-heading);
  font-size: 0.7rem;
}

@media (max-width: 700px) {
  .flow-chart {
    row-gap: 1.25rem;
  }

  .chart-node {
    grid-column: 1 !important;
    grid-row: auto !important;
    max-width: none;
  }

  .flow-chart__edges {
    display: none;
  }
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

/* Applied to .docs-layout only while Flow view is active (sop/flow-view.js) —
   a branching chart needs real width, which the fixed 15.5rem TOC column
   doesn't leave room for. Same full-viewport-breakout technique already
   shipped in Marin Decision Maker's diagram (.way-diagram-card--wide). */
.docs-layout--wide {
  grid-template-columns: 1fr;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding: 0 1.5rem;
}

.docs-layout--wide .toc {
  display: none;
}

.card {
  display: flex;
  padding: 1.25rem;
  flex-direction: column;
  border: 1px solid var(--app-border);
  border-radius: var(--pico-border-radius);
  background: var(--app-surface);
}

.card h2 {
  margin: 0.65rem 0;
  font-size: 1.2rem;
}

.meta {
  font-size: 0.825rem;
}

.docs-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 15.5rem;
  gap: 3.5rem;
}

.breadcrumb {
  margin-bottom: 1.5rem;
  font-size: 0.9375rem;
}

.step {
  padding: 1rem 0;
  border-top: 1px solid var(--app-border);
}

.step:first-of-type {
  border-top: 0;
}

.step-num {
  display: inline-flex;
  width: 1.75rem;
  height: 1.75rem;
  margin-right: 0.4rem;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--app-accent);
  color: var(--app-bg);
  font-size: 0.85rem;
}

.mini-dl dt {
  font-weight: 700;
}

.mini-dl dt,
.mini-dl dd {
  display: inline;
}

.mini-dl dd {
  margin-left: 0.35rem;
}

.callout {
  margin: 1.5rem 0;
  padding: 1rem;
  border-left: 0.375rem solid var(--marin-gold);
  background: var(--app-surface);
}

@media print {
  .view-toggle,
  #flow-view {
    display: none !important;
  }

  #text-view[hidden] {
    display: block !important;
  }
}
