/* Hero diagram styling
   ──────────────────────────────────────────────────────────── */

.hd {
  position: relative;
  width: 100%;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--fg);
}

.hd-grid {
  display: grid;
  grid-template-columns: 1fr 200px 1fr;
  gap: 16px;
  align-items: stretch;
}
@media (max-width: 780px) {
  .hd-grid { grid-template-columns: 1fr; }
  .hd-gateway { order: 2; }
  .hd-card--left { order: 1; }
  .hd-card--right { order: 3; }
  .hd-wire { display: none; }
}

.hd-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 18px 14px;
  display: flex; flex-direction: column;
  min-height: 200px;
  position: relative;
  overflow: hidden;
}

.hd-card-head {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.74rem;
  color: var(--fg-dim);
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.hd-pin {
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 25%, transparent);
}
.hd-pin--cloud { background: var(--fg-dim); box-shadow: 0 0 0 3px oklch(54% 0.01 70 / 0.2); }
.hd-card-label { color: var(--fg); font-weight: 500; letter-spacing: 0.02em; }
.hd-card-meta { margin-left: auto; color: var(--fg-dim); }

.hd-prompt {
  flex: 1;
  font-family: var(--sans);
  font-size: 0.96rem;
  line-height: 1.55;
  color: var(--fg);
  word-break: break-word;
}

.hd-prompt--out { color: var(--fg-muted); }
.hd-prompt--out.hd-prompt--visible { color: var(--fg); }
.hd-prompt--response { font-style: normal; }

.hd-prompt--scanning {
  background: linear-gradient(90deg, transparent 0%, color-mix(in oklab, var(--accent) 18%, transparent) 50%, transparent 100%);
  background-size: 30% 100%;
  background-repeat: no-repeat;
  background-position: -30% 0;
  animation: hd-scan 1.4s linear;
  border-radius: 4px;
}
@keyframes hd-scan {
  to { background-position: 130% 0; }
}

.hd-plain { color: var(--fg); }

.hd-flag {
  display: inline;
  border-radius: 3px;
  padding: 1px 2px;
  margin: 0 -2px;
  transition: background .35s, color .35s, box-shadow .35s;
}
.hd-flag--hit {
  background: var(--hi-warn-bg);
  color: var(--hi-warn);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--hi-warn) 35%, transparent) inset;
}

.hd-chip {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid color-mix(in oklab, var(--accent) 40%, transparent);
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 1px 6px;
  margin: 0 1px;
  border-radius: 4px;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity .25s, transform .25s;
  vertical-align: baseline;
}
.hd-chip--visible { opacity: 1; transform: none; }

.hd-rehydrated {
  display: inline;
  border-radius: 3px;
  padding: 1px 2px;
  margin: 0 -2px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  opacity: 0;
  transition: opacity .35s;
}
.hd-rehydrated--visible { opacity: 1; }

.hd-card-foot {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.78rem;
  color: var(--fg-dim);
  min-height: 24px;
}
.hd-finding { transition: color .3s; }
.hd-finding--hit { color: var(--accent-strong); }

.hd-tag {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--fg-dim);
}
.hd-tag--ok { color: var(--accent-strong); border-color: color-mix(in oklab, var(--accent) 35%, transparent); background: var(--accent-soft); }
.hd-tag--flight { color: var(--hi-warn); border-color: color-mix(in oklab, var(--hi-warn) 35%, transparent); background: var(--hi-warn-bg); }

/* gateway column
   ──────────────────────────────────────────────────────────── */
.hd-gateway {
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.hd-gateway-box {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 18px 14px;
  text-align: center;
  width: 100%;
  position: relative;
  z-index: 2;
  box-shadow: 0 1px 0 oklch(100% 0 0 / 0.04) inset;
}
.hd-gateway-mark {
  width: 32px; height: 32px;
  margin: 0 auto 12px;
  color: var(--accent-strong);
  display: grid; place-items: center;
}
.hd-gateway-lines {
  display: flex; gap: 3px; justify-content: center;
  margin-bottom: 12px;
  height: 14px;
  align-items: end;
}
.hd-gateway-lines span {
  width: 3px; background: var(--accent);
  border-radius: 2px;
  animation: hd-bar 1.6s ease-in-out infinite;
  opacity: 0.55;
}
.hd-gateway-lines span:nth-child(1) { height: 60%; animation-delay: 0s; }
.hd-gateway-lines span:nth-child(2) { height: 100%; animation-delay: .15s; }
.hd-gateway-lines span:nth-child(3) { height: 70%; animation-delay: .3s; }
.hd-gateway-lines span:nth-child(4) { height: 85%; animation-delay: .45s; }
@keyframes hd-bar {
  0%, 100% { transform: scaleY(0.6); opacity: 0.4; }
  50%      { transform: scaleY(1);   opacity: 1; }
}
.hd-gateway-label {
  font-family: var(--sans);
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--fg);
}
.hd-gateway-phase {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim);
  transition: color .2s;
}
.hd-gateway-phase--active { color: var(--accent-strong); }

/* wires (the lines connecting gateway to cards) */
.hd-wire {
  position: absolute;
  top: 50%;
  height: 2px;
  width: 50%;
  z-index: 1;
  pointer-events: none;
}
.hd-wire path {
  stroke: var(--border-strong);
  stroke-width: 1.5;
  stroke-dasharray: 3 4;
  fill: none;
  vector-effect: non-scaling-stroke;
}
.hd-wire--in  { left: -50%; }
.hd-wire--out { right: -50%; }

/* packets (the moving dots) */
.hd-packet {
  position: absolute;
  top: 50%;
  width: 10px; height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 22%, transparent);
  margin-top: -5px;
  opacity: 0;
  z-index: 3;
}
.hd-packet--out { left: 50%; }
.hd-packet--in  { left: 50%; background: var(--accent-strong); }

.hd-packet--out.hd-packet--run {
  animation: hd-packet-right 1.2s ease-in-out forwards;
}
.hd-packet--in.hd-packet--run {
  animation: hd-packet-left 1.2s ease-in-out forwards;
}
@keyframes hd-packet-right {
  0%   { opacity: 0; transform: translateX(0); }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(120px); }
}
@keyframes hd-packet-left {
  0%   { opacity: 0; transform: translateX(0); }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-120px); }
}

/* legend */
.hd-legend {
  margin-top: 18px;
  display: flex; flex-wrap: wrap; gap: 16px;
  font-size: 0.74rem;
  color: var(--fg-dim);
  letter-spacing: 0.04em;
}
.hd-sw {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
  background: var(--hi-warn);
  opacity: 0.85;
}

/* CSS-only loop (no JavaScript) */
.hd--loop .hd-flag { animation: hd-flag-hit 12s ease-in-out infinite; }
.hd--loop .hd-chip { animation: hd-chip-show 12s ease-in-out infinite; opacity: 0; }
.hd--loop .hd-prompt--out { animation: hd-out-show 12s ease-in-out infinite; opacity: 0.4; }
.hd--loop .hd-gateway-phase::before { content: "Sanitising"; animation: hd-phase-text 12s steps(1) infinite; }
.hd--loop .hd-packet--out { animation: hd-packet-right 12s ease-in-out infinite; }
.hd--loop .hd-packet--in { animation: hd-packet-left 12s ease-in-out infinite; animation-delay: 6s; }
@keyframes hd-flag-hit {
  0%, 18% { background: transparent; color: inherit; box-shadow: none; }
  22%, 55% { background: var(--hi-warn-bg); color: var(--hi-warn); box-shadow: 0 0 0 1px color-mix(in oklab, var(--hi-warn) 35%, transparent) inset; }
  60%, 100% { background: transparent; color: inherit; box-shadow: none; }
}
@keyframes hd-chip-show {
  0%, 28% { opacity: 0; transform: translateY(2px); }
  32%, 58% { opacity: 1; transform: none; }
  62%, 100% { opacity: 0; }
}
@keyframes hd-out-show {
  0%, 30% { opacity: 0.35; }
  34%, 100% { opacity: 1; }
}
@keyframes hd-phase-text {
  0%, 25% { content: "Idle"; }
  30%, 55% { content: "Sanitising"; }
  60%, 75% { content: "Sending"; }
  80%, 100% { content: "Rehydrating"; }
}
@media (prefers-reduced-motion: reduce) {
  .hd--loop .hd-flag, .hd--loop .hd-chip, .hd--loop .hd-prompt--out, .hd--loop .hd-packet--out, .hd--loop .hd-packet--in { animation: none; }
  .hd--loop .hd-flag { background: var(--hi-warn-bg); color: var(--hi-warn); }
  .hd--loop .hd-chip { opacity: 1; transform: none; }
  .hd--loop .hd-prompt--out { opacity: 1; }
}
