/* ============================================================
   DEMO — interactive simulator
   Inherits palette + type from styles.css
   ============================================================ */

/* ─── HEADER ─────────────────────────────────────────────────── */
.demo-header {
  padding: 88px 32px 56px;
  text-align: center;
  max-width: 920px;
  margin: 0 auto;
}

.demo-h1 {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: clamp(34px, 5.5vw, 58px);
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin: 18px auto 22px;
  color: var(--text);
}
.demo-h1 em {
  font-style: italic;
  color: var(--accent);
  font-weight: 400;
}

.demo-sub {
  font-size: clamp(15px, 1.4vw, 18px);
  line-height: 1.6;
  color: var(--text-2);
  max-width: 620px;
  margin: 0 auto 36px;
}

.demo-meta {
  font-size: 13px;
  color: var(--text-3);
  font-family: var(--f-mono);
  margin-top: 24px;
}

/* ─── CONTROLS ───────────────────────────────────────────────── */
.demo-controls {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 14px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
}

.ctl-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--f-body);
  transition: all 0.18s var(--ease);
  border: none;
  cursor: pointer;
}
.ctl-btn:hover { background: var(--accent-soft); transform: translateY(-1px); }
.ctl-btn:active { transform: translateY(0); }
.ctl-btn[disabled] { opacity: 0.6; cursor: not-allowed; transform: none; }

.ctl-btn-ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text);
}
.ctl-btn-ghost:hover { background: var(--bg-elev-2); border-color: var(--accent-line); }

.ctl-ico {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
}

/* Toggle */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text-2);
  font-family: var(--f-mono);
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  transition: all 0.2s var(--ease);
}
.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: var(--text-3);
  border-radius: 50%;
  transition: all 0.2s var(--ease);
}
.toggle input:checked + .toggle-track {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.toggle input:checked + .toggle-track .toggle-thumb {
  left: 18px;
  background: var(--accent);
}
.toggle input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.toggle-text strong {
  color: var(--text);
  font-weight: 500;
}

/* Speed selector */
.speed {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  font-family: var(--f-mono);
}
.speed select {
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  color: var(--text);
  border-radius: 8px;
  font-family: var(--f-mono);
  font-size: 13px;
  cursor: pointer;
}

/* ─── MAIN GRID ──────────────────────────────────────────────── */
.demo-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr 1fr;
  gap: 18px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 32px 64px;
  align-items: stretch;
}

@media (max-width: 1100px) {
  .demo-grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  min-height: 540px;
}

.panel-head {
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.panel-tag {
  display: inline-block;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-soft);
  margin-bottom: 6px;
}

.panel-h2 {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.25;
}

/* ─── USERS PANEL ────────────────────────────────────────────── */
.users {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.user {
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.user.active { border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(232,223,199,0.06); }
.user.blocked { border-color: rgba(232,153,153,0.28); box-shadow: 0 0 0 3px rgba(232,153,153,0.06); }

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--f-display);
  font-style: italic;
  font-size: 16px;
  color: var(--text);
  flex-shrink: 0;
}

.user-meta { flex: 1; min-width: 0; }
.user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.005em;
  margin-bottom: 2px;
}
.user-tag {
  font-family: var(--f-mono);
  font-size: 10px;
  color: #E89999;
  background: rgba(232,153,153,0.1);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
  font-weight: 400;
}
.user-plan {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--f-mono);
}

.user-status {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-elev-2);
  white-space: nowrap;
  transition: all 0.2s var(--ease);
}
.user-status.firing  { color: var(--accent); background: var(--accent-dim); }
.user-status.ok      { color: #99E8B0; background: rgba(153,232,176,0.08); }
.user-status.blocked { color: #E89999; background: rgba(232,153,153,0.10); }

/* Usage bar */
.bar {
  height: 6px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
  border: 1px solid var(--line);
}
.bar-fill {
  height: 100%;
  background: var(--accent-soft);
  border-radius: 999px;
  transition: width 0.4s var(--ease-out), background 0.3s var(--ease);
}
.user.warning  .bar-fill { background: #E8C99B; }
.user.critical .bar-fill { background: #E89999; }
.user.blocked  .bar-fill { background: #E89999; }

.bar-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--text-3);
}

.panel-note,
.wall-note {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-3);
}
.panel-note em,
.wall-note em {
  color: var(--text-2);
  font-style: italic;
}
.wall-note code {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--accent-soft);
  background: var(--accent-dim);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ─── WALL PANEL ─────────────────────────────────────────────── */
.wall-vis {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.wall-stage {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px 0 18px;
  border-bottom: 1px dashed var(--line);
}

.wall-line {
  position: relative;
  height: 2px;
  background: var(--line-strong);
  border-radius: 2px;
}
.wall-line-label {
  position: absolute;
  top: -22px;
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--text-3);
  text-transform: uppercase;
}
.wall-line-in  .wall-line-label { left: 0; }
.wall-line-out .wall-line-label { right: 0; text-align: right; }

.wall-gate {
  position: relative;
  width: 60px;
  height: 60px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: all 0.25s var(--ease);
}
.wall-gate-bar {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 1px solid var(--accent-line);
  transition: all 0.25s var(--ease);
}
.wall-gate-label {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--accent);
  position: relative;
  z-index: 2;
}
.wall-gate.disabled { opacity: 0.35; }
.wall-gate.disabled .wall-gate-bar { border-color: var(--line-strong); border-style: dashed; }
.wall-gate.disabled .wall-gate-label { color: var(--text-3); }

/* Travelling packet */
@keyframes packet-pass {
  0%   { left: -8px;  opacity: 0; }
  10%  { opacity: 1; }
  45%  { left: calc(50% - 4px); opacity: 1; transform: scale(1.2); }
  55%  { left: calc(50% - 4px); opacity: 1; transform: scale(1.2); }
  90%  { opacity: 1; }
  100% { left: 100%; opacity: 0; transform: scale(1); }
}
@keyframes packet-block {
  0%   { left: -8px; opacity: 0; transform: scale(1); }
  10%  { opacity: 1; }
  40%  { left: calc(50% - 24px); opacity: 1; transform: scale(1.3); }
  60%  { left: calc(50% - 24px); transform: scale(1.6); background: #E89999; }
  100% { left: calc(50% - 24px); opacity: 0; transform: scale(0.6); }
}

.packet {
  position: absolute;
  top: -2px;
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(232,223,199,0.5);
}
.packet.pass  { animation: packet-pass  0.9s linear forwards; }
.packet.block { animation: packet-block 0.9s linear forwards; }
.packet.block { background: #E89999; box-shadow: 0 0 14px rgba(232,153,153,0.5); }

/* Wall feed */
.wall-feed {
  flex: 1;
  min-height: 100px;
  max-height: 220px;
  overflow-y: auto;
  font-family: var(--f-mono);
  font-size: 11.5px;
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
  padding-right: 4px;
}
.wall-feed::-webkit-scrollbar { width: 6px; }
.wall-feed::-webkit-scrollbar-track { background: transparent; }
.wall-feed::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

.feed-line {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-2);
  animation: feed-in 0.3s var(--ease-out);
}
@keyframes feed-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.feed-time { color: var(--text-3); font-size: 10.5px; }
.feed-msg  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-tag {
  font-size: 9.5px;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 600;
}
.feed-line.pass  .feed-tag { color: #99E8B0; background: rgba(153,232,176,0.10); }
.feed-line.block .feed-tag { color: #E89999; background: rgba(232,153,153,0.10); }

/* Note: .wall-code (legacy code block) removed in B2C pivot — replaced by .wall-note */

/* ─── DASHBOARD PANEL ────────────────────────────────────────── */
.metric { margin-bottom: 18px; }

.metric-hero {
  padding: 22px 18px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
}
.metric-label {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}
.metric-value {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 44px;
  letter-spacing: -0.025em;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.metric-value.spike { color: #E89999; transition: color 0.3s; }
.metric-value.calm  { color: var(--accent); transition: color 0.3s; }
.metric-sub {
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 8px;
}
.metric-sub.spike { color: #E89999; }
.metric-sub.calm  { color: #99E8B0; }

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.metric-small {
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
}
.metric-label-sm {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}
.metric-value-sm {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.metric-value-sm.metric-good   { color: #99E8B0; }
.metric-value-sm.metric-danger { color: #E89999; }

.alerts {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 200px;
  padding-right: 4px;
}
.alerts::-webkit-scrollbar { width: 6px; }
.alerts::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

.alert {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent-soft);
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
  animation: feed-in 0.3s var(--ease-out);
}
.alert-empty {
  text-align: center;
  color: var(--text-3);
  border-style: dashed;
  border-left-style: dashed;
  border-color: var(--line-strong);
}
.alert-warn { border-left-color: #E8C99B; }
.alert-crit { border-left-color: #E89999; color: var(--text); }
.alert-good { border-left-color: #99E8B0; }
.alert-time {
  display: block;
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-3);
  margin-bottom: 2px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.alert strong { color: var(--text); font-weight: 500; }

/* ─── EXPLAINER ──────────────────────────────────────────────── */
.explainer {
  padding: 100px 32px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-elev) 100%);
  border-top: 1px solid var(--line);
}

.steps {
  list-style: none;
  display: grid;
  gap: 20px;
  margin: 32px 0 48px;
}
.steps li {
  position: relative;
  padding: 22px 26px 22px 76px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.step-n {
  position: absolute;
  top: 22px; left: 26px;
  font-family: var(--f-display);
  font-style: italic;
  font-size: 26px;
  color: var(--accent);
}
.steps h3 {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
  color: var(--text);
}
.steps p {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-2);
}
.steps code {
  font-family: var(--f-mono);
  font-size: 12.5px;
  color: var(--accent-soft);
  background: var(--accent-dim);
  padding: 2px 6px;
  border-radius: 4px;
}

.cta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.cta-btn {
  display: inline-flex;
  align-items: center;
  padding: 14px 22px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.18s var(--ease);
}
.cta-btn:hover { background: var(--accent-soft); transform: translateY(-1px); }
.cta-btn-ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text);
}
.cta-btn-ghost:hover { background: var(--bg-elev); border-color: var(--accent-line); }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 720px) {
  .demo-header { padding: 56px 20px 36px; }
  .demo-controls { padding: 12px; gap: 10px; }
  .demo-grid { padding: 0 20px 56px; }
  .panel { min-height: auto; padding: 20px 18px; }
  .metric-value { font-size: 36px; }
  .metric-value-sm { font-size: 18px; }
  .wall-note  { font-size: 11.5px; }
  .explainer { padding: 64px 20px; }
  .steps li { padding: 18px 18px 18px 64px; }
  .step-n { top: 18px; left: 18px; font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .packet,
  .feed-line,
  .alert {
    animation: none !important;
  }
  .bar-fill { transition: width 0.05s, background 0.05s; }
}
