/* Shared look for every micro-flow demo page. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #0f1117;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 16px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #e2e8f0;
}

h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 1.5rem;
  text-align: center;
}

/* ── Arena ── */
.arena {
  position: relative;
  width: 640px;
  height: 400px;
  border: 2px solid #1e293b;
  border-radius: 12px;
  background: #13192a;
  overflow: hidden;
}

/* grid lines (decorative) */
.arena::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 64px 40px;
}

/* ── Box ── */
.box {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 0 24px rgba(99,102,241,.55);
  transition: left 0.28s ease, top 0.28s ease, background 0.2s, box-shadow 0.2s;
  /* position is set via JS using % of arena size */
}

.box.flash {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  box-shadow: 0 0 36px rgba(239,68,68,.8);
}

/* ── Status panel ── */
.status-panel {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  width: 260px;
  background: rgba(15,17,23,.9);
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 1rem 1.2rem;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  font-size: 0.82rem;
}

.status-panel h2 {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #475569;
  margin-bottom: 0.75rem;
}

.stat-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 0.7rem;
}

.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #475569;
}

.stat-value {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: #a5b4fc;
  overflow-wrap: anywhere;
}

.step-type-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-family: monospace;
  padding: 2px 8px;
  border-radius: 999px;
  background: #1e2d45;
  color: #60a5fa;
  margin-bottom: 0.7rem;
}

.counter {
  font-size: 0.75rem;
  color: #64748b;
  border-top: 1px solid #1e293b;
  padding-top: 0.6rem;
  margin-top: 0.2rem;
}

.counter span {
  color: #a5b4fc;
  font-weight: 600;
}

/* ── Demo index ── */
.demo-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  width: min(960px, 100% - 32px);
}

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

.demo-list li { display: flex; }
.demo-list a { flex: 1; }

.demo-list a {
  display: block;
  padding: 1rem 1.2rem;
  border: 1px solid #1e293b;
  border-radius: 12px;
  background: #13192a;
  color: #a5b4fc;
  font-family: 'Courier New', monospace;
  text-decoration: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.demo-list a:hover {
  border-color: #6366f1;
  box-shadow: 0 0 24px rgba(99,102,241,.25);
}

.demo-list .demo-desc {
  display: block;
  margin-top: 0.3rem;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 0.75rem;
  color: #64748b;
}

/* ── Button ── */
.button {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  box-shadow: 0 0 24px rgba(99,102,241,.4);
  cursor: pointer;
  transition: box-shadow 0.2s, opacity 0.2s;
}

.button:hover:not(:disabled) {
  box-shadow: 0 0 32px rgba(99,102,241,.7);
}

.button:disabled {
  opacity: 0.4;
  cursor: default;
}

.button.ghost {
  background: transparent;
  border: 1px solid #1e293b;
  color: #a5b4fc;
  box-shadow: none;
}

.button.ghost:hover:not(:disabled) {
  border-color: #6366f1;
  box-shadow: 0 0 24px rgba(99,102,241,.25);
}

/* ── Server Status panel (backend demos) ── */
.server-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 260px;
  max-height: calc(100vh - 290px);
  display: flex;
  flex-direction: column;
  background: rgba(15,17,23,.92);
  border: 1px solid #1e293b;
  border-top: 2px solid #34d399;
  border-radius: 12px;
  padding: 1rem 1.2rem 0.8rem;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  font-size: 0.82rem;
}

.server-panel h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #475569;
  margin-bottom: 0.75rem;
}

.server-panel .step-type-badge { align-self: flex-start; background: rgba(52,211,153,.12); color: #34d399; }

.server-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #475569;
}

.server-dot.live { background: #34d399; box-shadow: 0 0 8px rgba(52,211,153,.8); }
.server-dot.down { background: #ef4444; }

.server-events {
  list-style: none;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  margin-top: 0.6rem;
  scrollbar-width: thin;
  scrollbar-color: #1e293b transparent;
}

.server-event {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 6px;
  padding: 2px 0;
  font-family: 'Courier New', monospace;
  font-size: 0.62rem;
  line-height: 1.35;
}

.server-event-time    { color: #334155; grid-row: span 2; }
.server-event-name    { color: #34d399; overflow-wrap: anywhere; }
.server-event-subject { color: #a5b4fc; overflow-wrap: anywhere; }
.server-event.good .server-event-name { color: #6ee7b7; }
.server-event.warn .server-event-name { color: #f59e0b; }
.server-event.bad  .server-event-name { color: #ef4444; }

.server-source {
  margin-top: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px solid #1e293b;
  font-family: 'Courier New', monospace;
  font-size: 0.56rem;
  color: #334155;
  overflow-wrap: anywhere;
}

/* Narrower than the arena plus both corner panels: the panels join the
   page flow below the demo instead of covering it. */
@media (max-width: 1199px) {
  .status-panel, .server-panel {
    position: static;
    width: min(640px, 100%);
    max-height: none;
    margin-top: 1rem;
  }
  .server-panel .server-events { max-height: 16rem; }
}

/* Phones: tall pages start at the top, and the status panel becomes a
   compact bar pinned to the bottom of the screen. Tap it to expand. */
@media (max-width: 700px) {
  /* room for the status bar (on html, so page-specific body padding
     doesn't override it) */
  html { padding-bottom: 3.5rem; }

  body { justify-content: flex-start; }

  h1 {
    font-size: 0.95rem;
    letter-spacing: 0.06em;
    margin-bottom: 1rem;
  }

  .status-panel {
    position: fixed;
    top: auto;
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: auto;
    margin: 0;
    z-index: 50;
    padding: 0.55rem 2rem 0.55rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .status-panel::after {
    content: '▴';
    position: absolute;
    top: 0.5rem;
    right: 0.8rem;
    color: #475569;
  }

  .status-panel:not(.expanded) h2,
  .status-panel:not(.expanded) .stat-label,
  .status-panel:not(.expanded) .stat-row + .stat-row,
  .status-panel:not(.expanded) .counter { display: none; }

  .status-panel:not(.expanded) .step-type-badge { margin: 0; flex-shrink: 0; }

  .status-panel:not(.expanded) .stat-row {
    margin: 0;
    min-width: 0;
  }

  .status-panel:not(.expanded) .stat-value {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .status-panel.expanded {
    display: block;
    max-height: 60vh;
    overflow-y: auto;
    padding: 1rem 1.2rem;
  }

  .status-panel.expanded::after { content: '▾'; top: 0.9rem; }
}
