:root {
  color-scheme: light;
  --navy: #051727;
  --gray: #5b6576;
  --line: #d5dae1;
  --bg: #f4f5f7;
  --card: #ffffff;
  --red: #d20e0f;
  --red-tint: #fdf2f2;
  --red-line: #f3c9c9;
  --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--navy);
  font: 15px/1.55 var(--font);
}

.page-header,
main,
.page-footer {
  max-width: 1560px;
  margin: 0 auto;
  padding-left: clamp(16px, 4vw, 48px);
  padding-right: clamp(16px, 4vw, 48px);
}

.page-header { padding-top: 24px; padding-bottom: 8px; }

/* Co-branded lockup: the AWS logo first, a divider, then Ping Identity. */
.brand-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-bottom: 18px; }
.lockup { display: flex; align-items: center; gap: 18px; }
.lockup img { display: block; width: auto; }
.lockup-aws { height: 40px; }
.lockup-ping { height: 55px; }
.lockup-divider { width: 1px; height: 62px; background: #242f3e; }

.home-link { color: var(--gray); font-size: 14px; font-weight: 600; text-decoration: none; }
.home-link::before { content: "\2190\00a0"; }
.home-link:hover { color: var(--navy); text-decoration: underline; }
.home-link:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
h1 { margin: 0 0 4px; font-size: clamp(20px, 2.4vw, 26px); line-height: 1.2; }
.page-header p { margin: 0; color: var(--gray); }

main { padding-top: 12px; padding-bottom: 24px; }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: 12px 28px; margin-bottom: 16px; }
.control-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.control-label,
.panel-kicker {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.control-label { color: var(--gray); }
.panel-kicker { color: var(--red); }

button { font: inherit; color: var(--navy); cursor: pointer; }
button:disabled { opacity: 0.4; cursor: default; }
button:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.segmented button {
  padding: 7px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 14px;
}
.segmented button[aria-checked="true"] { background: var(--navy); color: #ffffff; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 14px;
}
.chips button:hover { border-color: var(--navy); }
.chips button.current { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.step-tag {
  margin-left: 2px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--gray);
  font-size: 11px;
}
.chips button.needs-stage .step-tag { color: var(--red); }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  gap: 20px;
}

.diagram {
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.diagram-scroll { overflow-x: auto; }
.diagram svg { display: block; width: 100%; height: auto; }
.scroll-hint { display: none; padding: 6px 4px 2px; color: var(--gray); font-size: 12px; }

.panel {
  position: sticky;
  top: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.panel h2 { margin: 2px 0 8px; font-size: 19px; line-height: 1.3; }
.panel h3 { margin: 16px 0 6px; color: var(--gray); font-size: 13px; }
.panel p { margin: 0 0 10px; }
.hint { color: var(--gray); font-size: 13.5px; }
.live-link { display: inline-block; margin-bottom: 10px; color: var(--navy); font-weight: 700; }

.steps { margin: 12px 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { position: relative; margin: 0 0 6px; counter-increment: step; }
.steps li::before {
  content: counter(step);
  position: absolute;
  top: 9px;
  left: 10px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--gray);
  font-size: 12px;
  font-weight: 700;
}
.steps li button {
  display: block;
  width: 100%;
  padding: 8px 10px 8px 40px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--gray);
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
}
.steps li.current button { border-color: var(--red-line); background: var(--red-tint); color: var(--navy); }
.steps li.current::before { background: var(--red); color: #ffffff; }
.steps li.done::before { background: var(--navy); color: #ffffff; }

.flow-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.flow-controls button,
#detail-back {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font-size: 14px;
}
.flow-controls .primary { border-color: var(--navy); background: var(--navy); color: #ffffff; }
#flow-close { margin-left: auto; }
#detail-back { margin-top: 16px; }

.resource-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.resource-list code {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--bg);
  font: 12.5px var(--mono);
}

.page-footer { padding-top: 8px; padding-bottom: 32px; color: var(--gray); font-size: 12.5px; }

/* Diagram states, driven by architecture.js */
.node { cursor: pointer; transition: opacity 0.25s ease; }
.node:focus { outline: none; }
.node .tile { transition: stroke 0.2s ease, stroke-width 0.2s ease; }
.node:hover .tile,
.node:focus-visible .tile { stroke: var(--navy); stroke-width: 1.6; }
.node:hover .hit,
.node:focus-visible .hit { stroke: var(--line); }
.edge,
.edge-label { transition: opacity 0.25s ease, stroke 0.2s ease; }

.future { opacity: 0.16; }
.node.new .tile { stroke: var(--red); stroke-width: 2; }

.flowing .node:not(.active),
.flowing .edge:not(.active),
.flowing .edge-label:not(.active) { opacity: 0.22; }
.flowing .node.new:not(.active) .tile { stroke: var(--line); stroke-width: 1; }
.flowing .node.new:not(.active) .hit { stroke: none; }
.node.active .tile { stroke: var(--red); stroke-width: 2.4; }
.group.active .group-frame { stroke-width: 3; }
.edge-label.active { fill: var(--red); }
.edge.active {
  stroke: var(--red);
  stroke-width: 2.4;
  stroke-dasharray: 8 6;
  animation: flow 0.9s linear infinite;
}
@keyframes flow { to { stroke-dashoffset: -14; } }

@media (prefers-reduced-motion: reduce) {
  .edge.active { animation: none; }
  .node,
  .node .tile,
  .edge,
  .edge-label { transition: none; }
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .panel { position: static; }
}

@media (max-width: 760px) {
  .lockup { gap: 14px; }
  .lockup-aws { height: 32px; }
  .lockup-ping { height: 45px; }
  .lockup-divider { height: 51px; }
  .control-row { width: 100%; }
  .segmented { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .diagram svg { min-width: 820px; }
  .scroll-hint { display: block; }
}
