/* ECHOES — system diagram, drawn in HTML/SVG.
   Desktop follows the original board: four stages left→right, the parallel
   context agent across the top, the knowledge base under the agent.
   Phones stack the same parts in reading order. */

.sysmap {
  --line: rgba(255, 255, 255, .14);
  --wire: rgba(255, 255, 255, .55);
  max-width: 1360px; margin: 56px auto 0; padding: 0 24px; text-align: left;
  display: grid;
  grid-template-columns: 1fr 52px 1fr 84px 1fr 52px 1fr;
  grid-template-rows: auto 40px auto 78px auto auto;
  /* blur-reveal of the whole block is too heavy here; parts draw in instead */
  filter: none !important; transform: none !important; opacity: 1 !important;
}
.sysmap h3 { margin: 0; font-weight: 900; font-size: 1.02rem; letter-spacing: -.005em }
.sysmap svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round }

/* ---------- Placement ---------- */
.ctx { grid-column: 3 / 8; grid-row: 1 }
.w-ctx-down { grid-column: 5; grid-row: 2 }
.w-ctx-up { grid-column: 7; grid-row: 2 }
.st-capture { grid-column: 1; grid-row: 3 }
.a1 { grid-column: 2; grid-row: 3 }
.st-ground { grid-column: 3; grid-row: 3 }
.a2 { grid-column: 4; grid-row: 3 }
.st-agent { grid-column: 5; grid-row: 3 }
.a3 { grid-column: 6; grid-row: 3 }
.st-output { grid-column: 7; grid-row: 3 }
.loop { grid-column: 5; grid-row: 4 }
.kb { grid-column: 4 / 7; grid-row: 5 }
.w1 { grid-column: 1 } .w2 { grid-column: 3 } .w3 { grid-column: 5 } .w4 { grid-column: 7 }
.why { grid-row: 6 }

/* ---------- Context agent ---------- */
.ctx { display: flex; align-items: center; gap: 16px; padding: 14px 20px; border: 1px solid var(--line); border-radius: 14px }
.ctx-icon { flex: none; width: 28px; height: 28px; color: #fff }
.ctx-name { flex: none; font-weight: 900 }
.ctx-name em { font-family: "Playfair Display", Georgia, serif; font-weight: 400; color: var(--muted); margin-left: 4px }
.ctx-desc { color: var(--muted); font-size: .9rem; line-height: 1.45 }

/* ---------- Wires & arrows ---------- */
.wire { position: relative; justify-self: center; width: 1px; height: 100%; background: var(--wire) }
.wire::after { content: ""; position: absolute; left: -4px; border-left: 4.5px solid transparent; border-right: 4.5px solid transparent }
.w-ctx-down::after { bottom: -1px; border-top: 7px solid var(--wire) }
.w-ctx-up::after { top: -1px; border-bottom: 7px solid var(--wire) }
.arrow { position: relative; align-self: center; height: 1px; margin: 0 8px; background: var(--wire) }
.arrow::after { content: ""; position: absolute; right: -1px; top: -4px; border-left: 7px solid var(--wire); border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent }
.arrow small { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); white-space: nowrap; text-align: center; font-size: .68rem; line-height: 1.3; color: var(--dim) }

/* ---------- Stages ---------- */
.st { display: flex; flex-direction: column; gap: 14px; padding: 20px; border: 1px solid var(--line); border-radius: 18px }
.st > p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.45 }

.cam, .det { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: #000 }
.cam img, .det img { width: 100%; height: 100%; object-fit: cover; object-position: center 28% }
.det img { filter: grayscale(1) contrast(1.15) brightness(1.05) }
.cam .c { position: absolute; width: 16px; height: 16px; border: 0 solid #fff }
.cam .tl { top: 10px; left: 10px; border-top-width: 2px; border-left-width: 2px }
.cam .tr { top: 10px; right: 10px; border-top-width: 2px; border-right-width: 2px }
.cam .bl { bottom: 10px; left: 10px; border-bottom-width: 2px; border-left-width: 2px }
.cam .br { bottom: 10px; right: 10px; border-bottom-width: 2px; border-right-width: 2px }
.det .box { position: absolute; inset: 12% 16% 6% 16%; border: 1.5px dashed #fff; border-radius: 3px }
.det .box b { position: absolute; top: -1px; left: -1px; padding: 2px 7px; background: #fff; color: #0b0e11; font-size: .66rem; font-weight: 800; border-radius: 2px 0 2px 0 }

.voice { display: flex; align-items: center; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: .9rem }
.voice svg { flex: none; width: 22px; height: 22px; color: #fff }
.voice small { display: block; font-size: .72rem; color: var(--dim); margin-bottom: 2px }

.readout { margin: 0 }
.readout div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: .84rem }
.readout dt { color: var(--muted) }
.readout dd { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem }

.net { width: 104px; height: 104px; margin: 4px auto; color: #fff }
.net .edges { stroke: rgba(255, 255, 255, .32); stroke-width: 1 }
.net .nodes circle { fill: var(--bg); stroke: #fff }
.net .nodes circle:last-child { fill: #fff }
.roles, .actions { list-style: none; margin: 0; padding: 0; font-size: .86rem }
.roles li, .actions li { padding: 9px 0; border-top: 1px solid var(--line) }

.hud { padding: 12px 14px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 12px; background: #000 }
.hud-bar { display: flex; justify-content: space-between; align-items: center; font-size: .7rem; color: var(--dim); margin-bottom: 10px }
.hud-bar .bat { width: 18px; height: 9px; border: 1px solid var(--dim); border-radius: 2px; position: relative }
.hud-bar .bat::after { content: ""; position: absolute; inset: 1.5px 5px 1.5px 1.5px; background: var(--dim) }
.hud p { margin: 0; font-size: .82rem; line-height: 1.5 }
.hud p + p { margin-top: 10px; padding-top: 10px; border-top: 1px dotted rgba(255, 255, 255, .25) }
.hud p b { display: inline-block; margin-right: 8px; font-size: .64rem; font-weight: 800; letter-spacing: .08em; color: var(--dim) }

/* ---------- Knowledge-base loop ---------- */
.loop { position: relative; display: grid; grid-template-columns: 1fr 1fr; align-items: center }
.loop::before, .loop::after { content: ""; position: absolute; top: 0; bottom: 0; width: 1px; background: var(--wire) }
.loop::before { left: calc(50% - 12px) }
.loop::after { left: calc(50% + 12px) }
.loop small { font-size: .68rem; line-height: 1.3; color: var(--dim) }
.loop .q { text-align: right; padding-right: 26px }
.loop .r { padding-left: 26px }
.loop .q::after, .loop .r::after { content: ""; position: absolute; border-left: 4.5px solid transparent; border-right: 4.5px solid transparent }
.loop .q::after { left: calc(50% - 16px); bottom: -1px; border-top: 7px solid var(--wire) }
.loop .r::after { left: calc(50% + 8px); top: -1px; border-bottom: 7px solid var(--wire) }

.kb { padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; text-align: center }
.kb h3 { font-size: .96rem }
.kb ul { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px }
.kb li { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); line-height: 1.3 }
.kb li svg { width: 24px; height: 24px; color: #fff }

/* ---------- Why each choice ---------- */
.why { padding-top: 40px; padding-right: 8px }
.why b { display: block; margin-bottom: 8px; font-family: "Playfair Display", Georgia, serif; font-style: italic; font-weight: 600; font-size: 1.12rem }
.why span { display: block; color: var(--muted); font-size: .86rem; line-height: 1.55 }

/* ---------- Draw-in, left to right ---------- */
.sysmap > * { opacity: 0; transform: translateY(14px); transition: opacity .8s ease, transform .9s var(--ease) }
.sysmap .arrow, .sysmap .wire, .sysmap .loop { transform: none }
.sysmap .arrow { transform: scaleX(0); transform-origin: left; transition: transform .6s var(--ease), opacity .3s }
.sysmap.in > * { opacity: 1; transform: none }
.sysmap.in .st-capture { transition-delay: 0s }
.sysmap.in .a1 { transition-delay: .25s }
.sysmap.in .st-ground { transition-delay: .35s }
.sysmap.in .a2 { transition-delay: .6s }
.sysmap.in .st-agent { transition-delay: .7s }
.sysmap.in .loop { transition-delay: .9s }
.sysmap.in .kb { transition-delay: 1s }
.sysmap.in .a3 { transition-delay: 1.1s }
.sysmap.in .st-output { transition-delay: 1.2s }
.sysmap.in .ctx { transition-delay: 1.35s }
.sysmap.in .wire { transition-delay: 1.5s }
.sysmap.in .why { transition-delay: 1.6s }
@media (prefers-reduced-motion: reduce) { .sysmap > * { opacity: 1; transform: none; transition: none } }

/* ---------- Narrower screens: stack in reading order ---------- */
@media (max-width: 1100px) {
  .sysmap { display: flex; flex-direction: column; max-width: 560px }
  .st-capture { order: 10 } .w1 { order: 11 } .a1 { order: 12 }
  .st-ground { order: 20 } .w2 { order: 21 } .a2 { order: 22 }
  .ctx { order: 30 } .w-ctx-down { order: 31 }
  .st-agent { order: 32 } .w3 { order: 33 } .loop { order: 34 } .kb { order: 35 } .a3 { order: 36 }
  .st-output { order: 40 } .w4 { order: 41 }
  .w-ctx-up { display: none }
  .ctx { flex-wrap: wrap }
  .wire { height: 36px; align-self: center }
  .why { padding: 16px 0 0 }
  .arrow { align-self: center; width: 1px; height: 44px; margin: 14px 0; transform-origin: top }
  .sysmap .arrow { transform: scaleY(0) }
  .sysmap.in .arrow { transform: none }
  .arrow::after { right: auto; top: auto; left: -4px; bottom: -1px; border-left: 4.5px solid transparent; border-right: 4.5px solid transparent; border-top: 7px solid var(--wire); border-bottom: 0 }
  .arrow small { bottom: 50%; left: 16px; transform: translateY(50%); text-align: left }
  .arrow small br { display: none }
  .loop { height: 78px }
}
@media (max-width: 520px) { .kb ul { grid-template-columns: 1fr 1fr; row-gap: 18px } }
