/* diagram.css — interactive building cutaway: signals, devices, alarm choreography */

.diagram { position: relative; }

/* ── control bar ── */
.diagram-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.btn-play {
  font-family: var(--font-display); font-weight: 600; font-size: 15px;
  border-radius: 999px; padding: 12px 22px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 10px; transition: transform .12s, box-shadow .2s, background .2s, border-color .2s;
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-2);
}
.btn-play:hover { transform: translateY(-1px); border-color: var(--lora); }
.btn-play .ico-pause, .btn-play .ico-play { width: 12px; height: 13px; flex: none; position: relative; }
.btn-play .ico-pause::before, .btn-play .ico-pause::after {
  content: ""; position: absolute; top: 0; width: 4px; height: 13px; border-radius: 1px; background: var(--lora);
}
.btn-play .ico-pause::before { left: 0; } .btn-play .ico-pause::after { right: 0; }
.btn-play .ico-play::before {
  content: ""; position: absolute; top: 0; left: 1px;
  border-style: solid; border-width: 6.5px 0 6.5px 11px; border-color: transparent transparent transparent var(--lora);
}
.diagram-controls .hint { font-size: 13px; color: var(--ink-3); font-family: var(--font-mono); margin-left: auto; }

/* scenario trigger buttons */
.btn-trigger {
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  border-radius: 999px; padding: 11px 18px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  display: inline-flex; align-items: center; gap: 8px; transition: transform .12s, border-color .2s, background .2s;
}
.btn-trigger::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.btn-trigger:hover { transform: translateY(-1px); }
.btn-trigger.fire::before { background: var(--red-2); box-shadow: 0 0 6px var(--red-glow); }
.btn-trigger.fire:hover { border-color: var(--red); }
.btn-trigger.mcp::before { background: var(--amber); box-shadow: 0 0 6px rgba(255,176,32,.6); }
.btn-trigger.mcp:hover { border-color: var(--amber); }

/* ── prominent step caption ── */
.step-caption {
  display: flex; align-items: center; gap: 18px;
  background: var(--surface); border: 1px solid var(--line-2); border-left: 4px solid var(--lora);
  border-radius: var(--radius-sm); padding: 16px 20px; margin-bottom: 16px;
  transition: border-color .3s, background .3s;
}
.step-caption.active { border-left-color: var(--lora); }
.step-caption.alarm { border-left-color: var(--red); background: rgba(237,28,36,.09); animation: capflash .7s steps(1) infinite; }
@keyframes capflash { 50% { background: rgba(237,28,36,.18); } }

.cap-badge {
  flex: none; width: 56px; height: 56px; border-radius: 14px;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 26px; color: var(--lora);
  background: rgba(24,224,208,.1); border: 1px solid rgba(24,224,208,.3);
  transition: color .3s, background .3s, border-color .3s;
}
.step-caption.alarm .cap-badge { color: var(--red-2); background: rgba(237,28,36,.14); border-color: var(--red); }
.cap-watch { width: 12px; height: 12px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(31,203,107,.6); animation: dotpulse 2.2s infinite; }
@keyframes dotpulse { 0% { box-shadow: 0 0 0 0 rgba(31,203,107,.55);} 70% { box-shadow: 0 0 0 8px rgba(31,203,107,0);} 100% { box-shadow: 0 0 0 0 rgba(31,203,107,0);} }

.cap-text { flex: 1; min-width: 0; }
.cap-kicker { font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--lora-2); margin-bottom: 4px; }
.step-caption.alarm .cap-kicker { color: var(--red-2); }
.cap-title { font-family: var(--font-display); font-weight: 700; font-size: 23px; color: var(--ink); line-height: 1.12; }
.cap-detail { font-size: 14px; color: var(--ink-2); margin-top: 3px; }

.cap-pips { display: flex; gap: 8px; flex: none; }
.cap-pip { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); transition: background .3s, transform .3s, box-shadow .3s; }
.cap-pip.on { background: var(--lora); }
.cap-pip.cur { transform: scale(1.5); box-shadow: 0 0 8px var(--lora-glow); }
.step-caption.alarm .cap-pip.on { background: var(--red-2); }
.step-caption.alarm .cap-pip.cur { box-shadow: 0 0 8px var(--red-glow); }

.diagram-svg { width: 100%; height: auto; display: block; overflow: visible; }

/* ── sound toggle ── */
.sound-toggle {
  position: absolute; top: 0; right: 0; z-index: 20;
  width: 26px; height: 26px; border-radius: 7px;
  display: grid; place-items: center; cursor: pointer; padding: 0;
  background: var(--surface); border: 1px solid var(--line-2); color: var(--ink-3);
  transition: color .2s, border-color .2s, background .2s;
}
.sound-toggle:hover { color: var(--ink); border-color: var(--ink-3); }
.sound-toggle.on { color: var(--lora); border-color: rgba(24,224,208,.4); }
.sound-toggle:not(.on) { animation: sndhint 2.8s ease-in-out infinite; }
@keyframes sndhint { 0%,100% { box-shadow: 0 0 0 0 rgba(24,224,208,0); } 50% { box-shadow: 0 0 0 4px rgba(24,224,208,.1); } }
.diagram.is-alarm .sound-toggle.on { color: var(--red-2); border-color: var(--red); background: rgba(237,28,36,.12); }
.diagram.is-alarm .sound-toggle:not(.on) { color: var(--red-2); border-color: var(--red); animation: sndhintred 1s ease-in-out infinite; }
@keyframes sndhintred { 0%,100% { box-shadow: 0 0 0 0 rgba(237,28,36,0); } 50% { box-shadow: 0 0 0 5px rgba(237,28,36,.2); } }
.sound-toggle svg{width:14px;height:14px}
.snd-wave { animation: sndwave 1.1s ease-in-out infinite; }
@keyframes sndwave { 0%,100% { opacity: .45; } 50% { opacity: 1; } }

/* ── building labels ── */
.floor-label { font-family: var(--font-display); font-weight: 600; font-size: 17px; fill: var(--ink); }
.floor-sub   { font-family: var(--font-mono); font-size: 11px; fill: var(--ink-3); letter-spacing: .03em; }
.riser-label { font-family: var(--font-mono); font-size: 10px; fill: var(--ink-3); letter-spacing: .18em; }

/* ── LoRa coverage rings ── */
.gw-rings .ring { fill: none; stroke: var(--lora); stroke-width: 1.4; opacity: 0; transform-box: fill-box; transform-origin: center; animation: ring-out linear infinite; }
@keyframes ring-out { 0% { transform: scale(0.5); opacity: .55; } 100% { transform: scale(3.6); opacity: 0; } }
.gw-rings.alarm .ring { stroke: var(--red-2); }

/* ── LoRa links (heartbeat pulses) ── */
.lora-base { fill: none; stroke: var(--line-2); stroke-width: 1.2; opacity: .5; }
.lora-pulse { fill: var(--lora); filter: drop-shadow(0 0 6px var(--lora-glow)); }
.tx-ring { fill: none; stroke: var(--lora); stroke-width: 1.6; }
@keyframes dashflow { to { stroke-dashoffset: -120; } }
.lora-link.seed .lora-base { stroke: var(--red); opacity: .8; }
.lora-burst { fill: #fff; filter: drop-shadow(0 0 7px var(--red-2)); }

/* dim the idle LoRa traffic during an alarm so the active/command paths read */
.diagram.is-alarm .lora-link:not(.active):not(.downlink) .lora-pulse,
.diagram.is-alarm .lora-link:not(.active):not(.downlink) .tx-ring { opacity: .12 !important; }
.diagram.is-alarm .gw-rings:not(.alarm) .ring { opacity: .12; }

/* downlink command pulse: control room → strobes building-wide */
.lora-link.downlink .lora-base { stroke: var(--red); opacity: .6; }
.lora-cmd { fill: var(--amber); filter: drop-shadow(0 0 7px rgba(255,176,32,.8)); }

/* ── Ethernet trunk ── */
.eth-base { fill: none; stroke: var(--line-2); stroke-width: 1.6; }
.eth-flow { fill: none; stroke: var(--data); stroke-width: 2; stroke-dasharray: 3 11; opacity: .7; animation: dashflow linear infinite; filter: drop-shadow(0 0 3px rgba(59,130,246,.5)); }
.eth-link.active .eth-flow { stroke: var(--red-2); opacity: 1; filter: drop-shadow(0 0 6px var(--red-glow)); }
.eth-burst { fill: #fff; filter: drop-shadow(0 0 7px var(--red-2)); }
.diagram.is-alarm .eth-link:not(.active) .eth-flow { opacity: .15; }

/* ── inter-gateway coordination link (gateways talk directly; workstation only receives) ── */
.gwl-base { fill: none; stroke: var(--line-2); stroke-width: 1.4; stroke-dasharray: 4 5; opacity: .45; }
.gw-link.active .gwl-base { stroke: var(--amber); opacity: .4; }
.gwl-flow { fill: none; stroke: var(--amber); stroke-width: 2.4; stroke-dasharray: 3 9; opacity: .95; animation: dashflow linear infinite; filter: drop-shadow(0 0 6px rgba(255,176,32,.7)); }
.gwl-burst { fill: #fff; filter: drop-shadow(0 0 8px rgba(255,176,32,.9)); }

/* ── HCP data link ── */
.data-base { fill: none; stroke: var(--line-2); stroke-width: 1.4; }
.data-flow { fill: none; stroke: var(--ok); stroke-width: 1.8; stroke-dasharray: 2 10; opacity: .6; animation: dashflow linear infinite; }
.hcp-link.active .data-flow { stroke: var(--red-2); opacity: .9; }

/* ── Gateways ── */
.gw-body { fill: #1B2334; stroke: var(--lora); stroke-width: 1.4; }
.gw-led  { fill: var(--lora); filter: drop-shadow(0 0 5px var(--lora-glow)); animation: blink 1.8s infinite; }
.gw-ant  { stroke: var(--lora-2); stroke-width: 1.6; }
.gw-slot { fill: var(--line-2); }
.gw-label { font-family: var(--font-display); font-weight: 600; font-size: 13px; fill: var(--ink); }
.gw-code  { font-family: var(--font-mono); font-size: 10px; fill: var(--ink-3); }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.gateway.alarm .gw-body { stroke: var(--red-2); fill: #2A1417; animation: gw-shake .4s infinite; }
.gateway.alarm .gw-led  { fill: var(--red-2); filter: drop-shadow(0 0 7px var(--red-glow)); animation: blink .35s infinite; }
.gateway.alarm .gw-ant  { stroke: var(--red-2); }
@keyframes gw-shake { 0%,100% { transform: translateX(0);} 25% { transform: translateX(-1px);} 75% { transform: translateX(1px);} }

/* ── Workstation ── */
.ws-bezel { fill: #0A0E16; stroke: var(--line-2); stroke-width: 1.5; }
.ws-screen { fill: #0B1018; }
.ws-stand { fill: var(--line-2); }
.workstation.alarm .ws-bezel { stroke: var(--red); filter: drop-shadow(0 0 10px var(--red-glow)); }

.ws-ui { width: 100%; height: 100%; font-family: var(--font-mono); color: var(--ink-2); padding: 6px 7px; box-sizing: border-box; overflow: hidden; }
.ws-idle { display: flex; flex-direction: column; height: 100%; justify-content: space-between; }
.ws-row { display: flex; justify-content: space-between; font-size: 7px; letter-spacing: .04em; }
.ws-row .ok, .ok { color: var(--ok); }
.ws-bars { display: flex; align-items: flex-end; gap: 3px; height: 22px; }
.ws-bars i { width: 7px; background: linear-gradient(var(--lora), rgba(24,224,208,.2)); border-radius: 1px; }
.ws-ui.alarm { background: rgba(237,28,36,.14); animation: wsflash .6s steps(1) infinite; }
@keyframes wsflash { 50% { background: rgba(237,28,36,.30); } }
.ws-alarm { display: flex; flex-direction: column; gap: 4px; height: 100%; }
.ws-alarm-top { color: var(--red-2); font-weight: 700; font-size: 8px; letter-spacing: .06em; }
.ws-alarm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; flex: 1; }
.ws-map { position: relative; background: repeating-linear-gradient(45deg,#141b28,#141b28 4px,#10161f 4px,#10161f 8px); border: 1px solid var(--line-2); border-radius: 2px; }
.ws-pin { position: absolute; top: 40%; left: 55%; width: 6px; height: 6px; border-radius: 50%; background: var(--red-2); box-shadow: 0 0 0 0 var(--red-glow); animation: pin 1s infinite; }
@keyframes pin { 0% { box-shadow: 0 0 0 0 var(--red-glow);} 70% { box-shadow: 0 0 0 6px rgba(237,28,36,0);} 100% { box-shadow: 0 0 0 0 rgba(237,28,36,0);} }
.ws-cam { position: relative; background: #05080d; border: 1px solid var(--line-2); border-radius: 2px; font-size: 6px; color: var(--ink-3); padding: 2px 3px; }
.ws-rec { position: absolute; top: 3px; right: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--red-2); animation: blink 1s infinite; }

/* ── HikCentral Pro ── */
.hcp-body { fill: #141B28; stroke: var(--line-2); stroke-width: 1.4; }
.hcp-unit { fill: #0E1420; stroke: var(--line); }
.hcp-led  { fill: var(--ok); animation: blink 2.2s infinite; }
.hcp-line { stroke: var(--line-2); stroke-width: 1; }

/* ── Devices (realistic product illustrations) ── */
.device { cursor: default; }
.device.clickable { cursor: pointer; }
.dev-body { transition: transform .15s; transform-box: fill-box; transform-origin: center; }
.device.hover .dev-body { transform: scale(1.12); }
.dev-halo { fill: rgba(24,224,208,0); transition: fill .2s; }
.device.hover .dev-halo { fill: rgba(24,224,208,.16); }
.dev-status { fill: var(--ok); filter: drop-shadow(0 0 3px rgba(31,203,107,.6)); animation: blink 2.4s infinite; }

/* round ceiling detector (smoke / heat) */
.det-rim { fill: #0A0E16; }
.det-shell { fill: url(#det); stroke: #8C99AB; stroke-width: .8; }
.det-ring { fill: none; stroke: #9DA9B9; stroke-width: 1; opacity: .8; }
.det-vent { stroke: #95A1B2; stroke-width: 1; stroke-linecap: round; opacity: .65; }
.det-chamber { fill: #D6DCE6; stroke: #9098A6; stroke-width: .7; }
.det-led { fill: var(--ok); }
.det-led.alt { fill: var(--lora); }
.device.hover .det-shell { stroke: var(--lora); }

/* red manual call point */
.mcp-shell { fill: url(#red3d); stroke: #7C0D13; stroke-width: 1; }
.mcp-face { fill: #F4F6FA; opacity: .9; }
.mcp-btn { fill: var(--red); stroke: #fff; stroke-width: 1.3; }
.device.hover .mcp-shell { stroke: var(--lora); }

/* sounder strobe */
.str-shell { fill: url(#strBody); stroke: #9AA6B6; stroke-width: .9; }
.str-lens { fill: url(#strLens); stroke: #D2641A; stroke-width: 1; opacity: .92; }
.str-core { fill: #FFF3D6; }
.str-grille { stroke: #93A0B1; stroke-width: 1.5; stroke-linecap: round; }
.device.hover .str-shell { stroke: var(--lora); }

/* fire state — seed detector ignites */
.device.fire .det-shell { fill: url(#red3d); stroke: var(--red-2); }
.device.fire .det-ring, .device.fire .det-vent { stroke: #FFE; opacity: .9; }
.device.fire .det-chamber { fill: #FFF; stroke: var(--red); }
.device.fire .det-led, .device.fire .det-led.alt { fill: #fff; }
.device.fire .dev-body { animation: gw-shake .35s infinite; }
.device.fire .dev-status { fill: var(--red-2); animation: blink .3s infinite; }

/* manual call point — pressed state (mcp scenario seed) */
.press-ring { fill: none; stroke: var(--red-2); stroke-width: 2; opacity: 0; transform-box: fill-box; transform-origin: center; animation: pressring 1s ease-out infinite; }
@keyframes pressring { 0% { transform: scale(.6); opacity: .8; } 100% { transform: scale(2.2); opacity: 0; } }
.device.pressed .mcp-shell { fill: url(#red3d); stroke: #fff; animation: gw-shake .35s infinite; }
.device.pressed .mcp-btn { fill: #fff; }
.device.pressed .mcp-face { fill: #FFD9DB; }
.device.pressed .dev-status { fill: var(--red-2); animation: blink .3s infinite; }

.fire-flame { animation: flame .5s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center bottom; }
@keyframes flame { from { transform: scaleY(.85) scaleX(1.05);} to { transform: scaleY(1.12) scaleX(.92);} }

/* strobe flashing during alarm */
.device.strobing .str-lens { animation: strobeLens .42s steps(1) infinite; }
.device.strobing .str-core { animation: strobeCore .42s steps(1) infinite; }
.device.strobing .dev-body { animation: strobeGlow .42s steps(1) infinite; transform-box: fill-box; transform-origin: center; }
@keyframes strobeLens { 0%,100% { fill: url(#strLens);} 50% { fill: #fff;} }
@keyframes strobeCore { 0%,100% { fill: #FFF3D6;} 50% { fill: #fff;} }
@keyframes strobeGlow { 0%,100% { filter: none;} 50% { filter: drop-shadow(0 0 7px var(--amber));} }
.fire-room { animation: roomglow 1.4s ease-in-out infinite alternate; }

/* ── device legend callouts (top floor) ── */
.dev-callout { pointer-events: none; }
.co-tick { stroke: var(--lora); stroke-width: 1.2; opacity: .55; }
.co-dot { fill: var(--lora); }
.co-name { font-family: var(--font-body); font-weight: 600; font-size: 12.5px; fill: var(--ink); }
.co-code { font-family: var(--font-mono); font-size: 10.5px; fill: var(--lora-2); letter-spacing: .02em; }

/* ── live monitoring readout (signal + battery) ── */
/* ── system-status panel inside the scene (right side) ── */
.status-fo { overflow: visible; }
.scene-status {
  font-family: var(--font-body);
  background: rgba(12,17,26,.82);
  border: 1px solid var(--line-2);
  border-left: 4px solid var(--lora);
  border-radius: 18px;
  padding: 24px 26px;
  backdrop-filter: blur(6px);
  box-shadow: 0 26px 60px -28px rgba(0,0,0,.8);
  display: flex; flex-direction: column; gap: 13px;
}
.scene-status.alarm { border-left-color: var(--red); background: rgba(34,12,14,.86); animation: capflash .7s steps(1) infinite; }

.ss-head { display: flex; align-items: center; gap: 14px; }
.ss-badge {
  width: 56px; height: 56px; border-radius: 15px; flex: none;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 27px; color: var(--lora);
  background: rgba(24,224,208,.1); border: 1px solid rgba(24,224,208,.3);
}
.scene-status.alarm .ss-badge { color: var(--red-2); background: rgba(237,28,36,.14); border-color: var(--red); }
.ss-watch { width: 14px; height: 14px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(31,203,107,.6); animation: dotpulse 2.2s infinite; }
.ss-kicker { font-family: var(--font-mono); font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--lora-2); }
.scene-status.alarm .ss-kicker { color: var(--red-2); }
.ss-title { font-family: var(--font-display); font-weight: 700; font-size: 31px; line-height: 1.1; color: var(--ink); }
.ss-detail { font-size: 16.5px; line-height: 1.5; color: var(--ink-2); }
.ss-pips { display: flex; gap: 9px; margin-top: 4px; }
.ss-pip { width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); transition: background .3s, transform .3s, box-shadow .3s; }
.ss-pip.on { background: var(--lora); }
.ss-pip.cur { transform: scale(1.5); box-shadow: 0 0 8px var(--lora-glow); }
.scene-status.alarm .ss-pip.on { background: var(--red-2); }
.scene-status.alarm .ss-pip.cur { box-shadow: 0 0 8px var(--red-glow); }

.dev-monitor { pointer-events: none; }
.mon-bg { fill: rgba(11,16,24,.92); stroke: var(--line-2); stroke-width: 1; }
.mon-bar { fill: var(--line-2); }
.mon-bar.on { fill: var(--lora); filter: drop-shadow(0 0 2px var(--lora-glow)); }
.mon-cell { fill: none; stroke: var(--ink-3); stroke-width: 1; }
.mon-tip { fill: var(--ink-3); }
.mon-fill { fill: var(--ok); }
.mon-fill.low { fill: var(--amber); }
.mon-pct { font-family: var(--font-mono); font-size: 9.5px; fill: var(--ink-2); }
.mon-pct.low { fill: var(--amber); }
@keyframes roomglow { from { opacity: .5;} to { opacity: .95;} }

/* ── tooltip ── */
.tip-fo { overflow: visible; pointer-events: none; }
.dev-tip {
  background: rgba(12,17,26,.96); border: 1px solid var(--lora); border-radius: 10px;
  padding: 11px 13px; box-shadow: 0 14px 36px -10px rgba(0,0,0,.7), 0 0 0 1px rgba(24,224,208,.12);
  font-family: var(--font-body); backdrop-filter: blur(4px);
}
.tip-code { font-family: var(--font-mono); font-size: 11px; color: var(--lora-2); letter-spacing: .04em; }
.tip-name { font-size: 14px; font-weight: 600; color: var(--ink); margin: 2px 0 7px; }
.tip-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--ink-2); font-family: var(--font-mono); }
.tip-sig { display: inline-flex; align-items: flex-end; gap: 2px; }
.tip-sig i { width: 3px; height: 5px; background: var(--line-2); border-radius: 1px; }
.tip-sig i:nth-child(2){ height: 8px;} .tip-sig i:nth-child(3){ height: 11px;} .tip-sig i:nth-child(4){ height: 14px;}
.tip-sig i.on { background: var(--lora); box-shadow: 0 0 4px var(--lora-glow); }
.tip-gw { margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--line); font-size: 11px; color: var(--ink-3); font-family: var(--font-mono); }

@media (max-width: 720px) {
  .diagram-controls .hint { display: none; }
}
