/* state-system.html — Context State Stack Visualizer */

.doc-cstv {
  margin: 1.05rem 0 0;
  border-radius: 16px;
  border: 1px solid rgba(120, 140, 200, 0.22);
  background: linear-gradient(168deg,
      rgba(14, 18, 32, 0.9) 0%,
      rgba(8, 12, 24, 0.82) 55%,
      rgba(12, 10, 28, 0.88) 100%);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.45) inset,
    0 12px 36px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.doc-cstv__stage {
  padding: 0.75rem 0.9rem 0.85rem;
  background: rgba(4, 8, 18, 0.55);
  border-bottom: 1px solid rgba(110, 150, 210, 0.12);
}

.doc-cstv__split {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 0.85rem;
  align-items: stretch;
}

.doc-cstv__stage-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.doc-cstv__preview-wrap {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(110, 150, 210, 0.16);
  background: rgba(5, 10, 22, 0.65);
}

.doc-cstv__preview-wrap canvas[data-cstv-canvas] {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
}

.doc-cstv__scene-hud {
  position: absolute;
  left: 0.65rem;
  top: 0.65rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  pointer-events: none;
}

.doc-cstv__badge {
  padding: 0.22rem 0.42rem;
  border-radius: 7px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border: 1px solid rgba(120, 190, 255, 0.22);
  background: rgba(8, 12, 24, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.doc-cstv__badge.is-ok {
  color: rgba(120, 255, 190, 0.95);
  border-color: rgba(80, 220, 150, 0.35);
}

.doc-cstv__badge.is-leak {
  color: #ffb878;
  border-color: rgba(255, 120, 50, 0.55);
  background: rgba(36, 16, 8, 0.92);
  box-shadow: 0 0 14px rgba(255, 90, 30, 0.28);
}

.doc-cstv__panel {
  height: 100%;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid rgba(94, 200, 255, 0.12);
  background: rgba(6, 10, 22, 0.72);
  padding: 0.65rem 0.7rem 0.75rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.doc-cstv__panel-title {
  margin: 0 0 0.5rem;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(190, 208, 240, 0.88);
}

.doc-cstv__depth {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 10px;
  border: 1px solid rgba(94, 200, 255, 0.14);
  background: rgba(4, 8, 18, 0.65);
}

.doc-cstv__depth-k {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(150, 185, 230, 0.65);
}

.doc-cstv__depth-v {
  font-size: 0.78rem;
  font-weight: 800;
  color: rgba(130, 235, 255, 0.95);
}

.doc-cstv__depth-v.is-warn {
  color: rgba(255, 175, 110, 0.98);
}

.doc-cstv__stack-title {
  margin: 0 0 0.38rem;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(150, 185, 230, 0.62);
}

.doc-cstv__stack {
  display: flex;
  flex-direction: column-reverse;
  gap: 0.35rem;
  margin: 0 0 0.55rem;
  padding: 0;
  list-style: none;
  max-height: 9.5rem;
  overflow-y: auto;
}

.doc-cstv__frame {
  padding: 0.38rem 0.45rem;
  border-radius: 10px;
  border: 1px solid rgba(110, 150, 210, 0.16);
  background: rgba(8, 12, 24, 0.55);
  font-size: 0.66rem;
  line-height: 1.35;
  color: rgba(180, 200, 235, 0.82);
}

.doc-cstv__frame.is-active {
  border-color: rgba(46, 231, 242, 0.45);
  background: rgba(12, 28, 42, 0.75);
  box-shadow:
    0 0 0 1px rgba(46, 231, 242, 0.12) inset,
    0 0 16px rgba(46, 231, 242, 0.12);
  color: rgba(220, 240, 255, 0.95);
}

.doc-cstv__frame.is-ghost {
  opacity: 0.26;
  background: transparent;
  border: 1px dashed rgba(255, 140, 80, 0.32);
  box-shadow: none;
  color: rgba(160, 175, 200, 0.42);
}

.doc-cstv__frame.is-ghost .doc-cstv__frame-id {
  color: rgba(255, 160, 90, 0.5);
  text-decoration: line-through;
}

.doc-cstv__frame.is-ghost .doc-cstv__frame-meta {
  opacity: 0.65;
}

.doc-cstv__frame.is-push {
  animation: doc-cstv-stack-push 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.doc-cstv__frame.is-pop {
  animation: doc-cstv-stack-pop 0.2s ease-in;
}

@keyframes doc-cstv-stack-push {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes doc-cstv-stack-pop {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
  }
}

.doc-cstv__frame-id {
  font-weight: 800;
  color: rgba(130, 235, 255, 0.9);
}

.doc-cstv__frame-meta {
  display: block;
  margin-top: 0.12rem;
  font-size: 0.6rem;
  color: rgba(150, 175, 210, 0.72);
}

.doc-cstv__inspector {
  margin-bottom: 0.55rem;
  padding: 0.45rem 0.5rem;
  border-radius: 12px;
  border: 1px solid rgba(94, 200, 255, 0.1);
  background: rgba(4, 8, 18, 0.55);
}

.doc-cstv__inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.doc-cstv__inspector-title {
  margin: 0;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(150, 185, 230, 0.65);
}

.doc-cstv__matrix {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  border: 1px solid rgba(110, 150, 210, 0.2);
  background: rgba(5, 10, 22, 0.8);
  flex-shrink: 0;
}

.doc-cstv__kv {
  display: grid;
  gap: 0.28rem;
  margin: 0;
}

.doc-cstv__kv-row {
  display: grid;
  grid-template-columns: 5.2rem 1fr;
  gap: 0.35rem;
  align-items: baseline;
  font-size: 0.64rem;
}

.doc-cstv__kv-k {
  color: rgba(150, 185, 230, 0.62);
  font-weight: 700;
}

.doc-cstv__kv-v {
  color: rgba(200, 220, 250, 0.92);
  font-weight: 700;
  word-break: break-all;
}

.doc-cstv__kv-v.is-leak {
  color: rgba(255, 175, 110, 0.98);
}

.doc-cstv__kv-v.is-clip-active {
  color: rgba(92, 224, 255, 0.98);
}

.doc-cstv__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  margin-bottom: 0.45rem;
}

.doc-cstv__btn {
  flex: 1 1 auto;
  min-width: 4.8rem;
  padding: 0.38rem 0.55rem;
  border-radius: 10px;
  border: 1px solid rgba(110, 150, 210, 0.22);
  background: rgba(12, 18, 34, 0.85);
  color: rgba(210, 228, 255, 0.92);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.doc-cstv__btn:hover:not(:disabled):not(.is-disabled) {
  border-color: rgba(46, 231, 242, 0.35);
  background: rgba(16, 28, 48, 0.95);
}

.doc-cstv__btn:disabled,
.doc-cstv__btn.is-disabled {
  opacity: 0.34;
  cursor: not-allowed;
  pointer-events: none;
  filter: saturate(0.5);
}

.doc-cstv__btn--restore:disabled,
.doc-cstv__btn--restore.is-disabled {
  border-color: rgba(110, 130, 170, 0.16);
  color: rgba(140, 155, 185, 0.55);
}

.doc-cstv__btn--save {
  border-color: rgba(46, 231, 242, 0.35);
  color: rgba(130, 255, 245, 0.95);
}

.doc-cstv__btn--restore {
  border-color: rgba(181, 108, 255, 0.35);
  color: rgba(220, 190, 255, 0.95);
}

.doc-cstv__btn--reset {
  flex: 1 1 100%;
  border-color: rgba(150, 170, 210, 0.2);
  color: rgba(170, 190, 220, 0.85);
}

.doc-cstv__checks {
  display: grid;
  gap: 0.35rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(110, 150, 210, 0.1);
}

.doc-cstv__check {
  display: flex;
  align-items: flex-start;
  gap: 0.42rem;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.76rem;
  line-height: 1.35;
  color: rgba(190, 208, 240, 0.88);
}

.doc-cstv__check input {
  margin-top: 0.1rem;
  accent-color: #ffb060;
}

.doc-cstv__caption {
  margin: 0;
  padding: 0.75rem 0.9rem 0.85rem;
  font-size: 0.82rem;
  line-height: 1.52;
  color: rgba(165, 188, 228, 0.82);
  border-top: 1px solid rgba(110, 150, 210, 0.1);
}

@media (max-width: 1040px) {
  .doc-cstv__split {
    grid-template-columns: 1fr;
  }

  .doc-cstv__panel {
    height: auto;
  }

  .doc-cstv__preview-wrap {
    min-height: 16rem;
  }
}

@media (max-width: 560px) {
  .doc-cstv__kv-row {
    grid-template-columns: 1fr;
    gap: 0.12rem;
  }
}
