/* 프로그래밍 언어론 9강 전용 스타일: 그림 속 글씨 크기, 코드 상자, 메모리 칸, 포인터 화살표, 실행 시간 스택 */

/* 그림 속 글씨는 12px 이상 */
.viz text.s,
.viz text.n,
.viz text.v-num { font-size: 12px; }
.viz text.v-num.big { font-size: 20px; }
.viz text.k { fill: var(--key); font-weight: 700; }
.viz text.v { fill: var(--value); font-weight: 700; }
.viz text.bad { font-weight: 700; }
.viz text.tag { font-size: 12px; font-weight: 700; fill: var(--muted); }
.viz text.fx { transition: opacity 0.3s ease, fill 0.3s ease; }
.viz text.dim { opacity: 0.35; }

/* 코드 글씨 */
.viz text.code {
  font-family: var(--mono);
  font-size: 12.5px;
  fill: var(--text);
}
.viz text.code.m { fill: var(--muted); }
.viz text.code.on { fill: var(--accent); }
.viz text.code.k { fill: var(--key); }
.viz text.code.bad { fill: var(--value); }
.viz text.code tspan { transition: fill 0.3s ease, fill-opacity 0.3s ease; }
.viz text.code tspan.on { fill: var(--accent); font-weight: 700; }
.viz text.code tspan.k { fill: var(--key); font-weight: 700; }
.viz text.code tspan.v,
.viz text.code tspan.bad { fill: var(--value); font-weight: 700; }
.viz text.code tspan.m { fill: var(--muted); }
.viz text.code tspan.hide { fill-opacity: 0; }

/* 코드 상자와 줄 강조 */
.v-code { fill: #0a0c10; stroke: var(--line); }
.v-codeblock { transition: opacity 0.3s ease; }
.v-codeblock.dim { opacity: 0.4; }
.v-codeblock.hide { opacity: 0; }
.v-hl { fill: var(--accent); opacity: 0.2; }
.v-hl.bad { fill: var(--value); opacity: 0.24; }
.v-hl.k { fill: var(--key); opacity: 0.22; }
.v-hl.hide { opacity: 0; }

/* 칩: 틀림(붉은 테두리), 청록 */
.v-chip.bad rect { fill: none; stroke: var(--value); stroke-width: 1.5; }
.v-chip.bad text { fill: var(--value); }
.v-chip.k rect { fill: none; stroke: var(--key); stroke-width: 1.5; }
.v-chip.k text { fill: var(--key); }
.v-chip.kk rect { fill: var(--key); }
.v-chip.kk text { fill: var(--on-accent); }

/* 메모리 칸, 표의 칸 */
.v-cellbox {
  fill: var(--surface-2);
  stroke: transparent;
  stroke-width: 1.5;
  transition: stroke 0.25s ease, fill 0.3s ease, opacity 0.3s ease;
}
.v-cellbox.k { stroke: var(--key); }
.v-cellbox.on { stroke: var(--accent); fill: color-mix(in srgb, var(--accent) 20%, var(--surface)); }
.v-cellbox.bad { stroke: var(--value); fill: color-mix(in srgb, var(--value) 20%, var(--surface)); }
.v-cellbox.dim { opacity: 0.4; }

/* 체크와 가위표 */
.v-mark {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.3s ease;
}
.v-mark.bad { stroke: var(--value); }
.v-mark.hide { opacity: 0; }

/* 틀, 상자 */
.v-frame { transition: stroke 0.3s ease, opacity 0.3s ease; }
.v-frame.bad { stroke: var(--value); }
.v-frame.k { stroke: var(--key); }
.v-frame.soft { fill: none; stroke-dasharray: 3 3; }
.v-box rect { transition: stroke 0.3s ease; }
.v-box.fx { transition: opacity 0.3s ease; }
.v-step { transition: opacity 0.3s ease; }
.v-step.dim { opacity: 0.4; }
.v-step.bad .bg { stroke: var(--value); }

/* 곧은 점선 (V.path 는 길이를 1로 맞추므로 점선은 따로 그린다) */
.v-rule { fill: none; stroke: var(--line); stroke-width: 1.2; }
.v-rule.dot { stroke: var(--muted); stroke-dasharray: 3 4; }
.v-rule.on { stroke: var(--accent); }

/* 선과 화살표의 색 바꾸기 */
.v-line.fx { transition: opacity 0.3s ease, stroke 0.3s ease, stroke-width 0.3s ease; }
.v-line.hide, .v-vector.hide { opacity: 0; }
.v-line.soft { stroke: var(--line); }
.v-vector { transition: opacity 0.3s ease; }
.v-vector line, .v-vector path { transition: stroke 0.3s ease; }
.v-vector.k line, .v-vector.k path { stroke: var(--key); }
.v-vector.bad line, .v-vector.bad path { stroke: var(--value); }
.v-vector.dim { opacity: 0.35; }

.v-line.docline { stroke: #4b5263; }
.v-bar.badsoft { fill: color-mix(in srgb, var(--value) 32%, var(--surface-2)); }
.v-dot.k { fill: var(--key); }
.v-dot.bad { fill: var(--value); }
.v-dot.m { fill: var(--muted); }
.v-bar { transition: opacity 0.3s ease; }
.v-bar.dim { opacity: 0.3; }
.v-tri { fill: var(--accent); }
.v-tri.bad { fill: var(--value); }
.v-grid rect.hide { opacity: 0; }

.fx.off { opacity: 0.18; }
.nb { white-space: nowrap; }

/* --- 메모리 칸, 포인터 화살표 (5강의 것을 옮겨 왔다) --- */

/* 메모리 칸의 여러 상태 */
.v-cellbox.free { fill: none; stroke: var(--line); stroke-dasharray: 3 3; }
.v-cellbox.ta { fill: color-mix(in srgb, var(--accent) 30%, var(--surface-2)); }
.v-cellbox.tb { fill: color-mix(in srgb, var(--key) 30%, var(--surface-2)); }
.v-cellbox.tk { stroke: var(--key); fill: color-mix(in srgb, var(--key) 18%, var(--surface)); }
.v-cellbox.hide { opacity: 0; }
.v-cellbox.soft { fill: var(--surface); stroke: var(--line); }

/* 칸 속 글씨 */
.viz text.v-num { transition: opacity 0.3s ease, fill 0.3s ease; }
.viz text.v-num.k { fill: var(--key); }
.viz text.v-num.m { fill: var(--muted); }
.viz text.hide { opacity: 0; }
.viz text.big2 { font-size: 22px; font-weight: 700; }

/* 포인터 화살표 (굽은 선 + 머리) */
.v-ptr { transition: opacity 0.3s ease; }
.v-ptr .ln { fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; transition: stroke 0.3s ease; }
.v-ptr .hd { fill: var(--muted); transition: fill 0.3s ease; }
.v-ptr.on .ln { stroke: var(--accent); }
.v-ptr.on .hd { fill: var(--accent); }
.v-ptr.k .ln { stroke: var(--key); }
.v-ptr.k .hd { fill: var(--key); }
.v-ptr.bad .ln { stroke: var(--value); }
.v-ptr.bad .hd { fill: var(--value); }
.v-ptr.dash .ln { stroke-dasharray: 4 4; }
.v-ptr.hide { opacity: 0; }
.v-ptr.dim { opacity: 0.35; }

/* 막대와 띠 */
.v-seg { fill: var(--surface-2); stroke: transparent; stroke-width: 1.5; transition: stroke 0.3s ease, fill 0.3s ease, opacity 0.3s ease; }
.v-seg.on { fill: color-mix(in srgb, var(--accent) 26%, var(--surface)); stroke: var(--accent); }
.v-seg.k { fill: color-mix(in srgb, var(--key) 30%, var(--surface-2)); }
.v-seg.run { fill: color-mix(in srgb, var(--key) 45%, var(--surface-2)); }
.v-seg.stop { fill: var(--value); }
.v-seg.acc { fill: var(--accent); }
.v-seg.hide { opacity: 0; }

/* 틀 */
.v-frame.fx { transition: stroke 0.3s ease, opacity 0.3s ease; }
.v-frame.dim { opacity: 0.4; }
.v-frame.hide { opacity: 0; }
.v-frame.dashk { fill: none; stroke: var(--key); stroke-dasharray: 4 3; }

/* 동그란 표시 */
.v-badge { fill: var(--surface); stroke: var(--muted); stroke-width: 1.5; transition: stroke 0.3s ease, fill 0.3s ease; }
.v-badge.on { stroke: var(--accent); }
.v-badge.bad { stroke: var(--value); }
.v-dot.fx { transition: opacity 0.3s ease, fill 0.3s ease; }
.v-dot.hide { opacity: 0; }
.v-ring { fill: none; stroke: var(--accent); stroke-width: 2; transition: opacity 0.3s ease; }
.v-ring.hide { opacity: 0; }

.v-step.k .bg { stroke: var(--key); }
.v-line.soft.on { stroke: var(--accent); }
.v-line.soft.k { stroke: var(--key); }
.v-line.soft.bad { stroke: var(--value); }
.v-chip.hide { opacity: 0; }
.v-chip.off { opacity: 0.18; }

@media (prefers-reduced-motion: reduce) {
  .viz * { transition: none !important; }
}

/* --- 9강에서 더한 것: 실행 시간 스택과 활성 레코드 인스턴스 --- */

/* 인스턴스 하나 (쌓일 때 위에서 내려앉고, 걷힐 때 위로 뜬다) */
.v-ari { transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1); }
.v-ari.hide { opacity: 0; transform: translateY(-14px); }
.v-ari.dim { opacity: 0.48; }

/* 인스턴스 안의 칸 */
.v-arcell {
  fill: var(--surface-2);
  stroke: transparent;
  stroke-width: 1.5;
  transition: stroke 0.25s ease, fill 0.3s ease, opacity 0.3s ease;
}
.v-arcell.fold { fill: none; stroke: var(--line); stroke-dasharray: 3 3; }
.v-arcell.free { fill: none; stroke: var(--line); stroke-dasharray: 3 3; }
.v-arcell.on { stroke: var(--accent); fill: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.v-arcell.k { stroke: var(--key); fill: color-mix(in srgb, var(--key) 20%, var(--surface)); }
.v-arcell.bad { stroke: var(--value); fill: color-mix(in srgb, var(--value) 20%, var(--surface)); }
.v-arcell.dim { opacity: 0.4; }

/* 접어 그린 인스턴스 (상자 하나) */
.v-arblock {
  fill: var(--surface-2);
  stroke: transparent;
  stroke-width: 1.5;
  transition: stroke 0.25s ease, fill 0.3s ease, opacity 0.3s ease;
}
.v-arblock.on { stroke: var(--accent); fill: color-mix(in srgb, var(--accent) 20%, var(--surface)); }
.v-arblock.k { stroke: var(--key); fill: color-mix(in srgb, var(--key) 18%, var(--surface)); }
.v-arblock.bad { stroke: var(--value); fill: color-mix(in srgb, var(--value) 18%, var(--surface)); }
.v-arblock.dim { opacity: 0.4; }
.v-arblock.free { fill: none; stroke: var(--line); stroke-dasharray: 3 3; }

/* 링크 칸의 점, 인스턴스 묶음 선 */
.v-linkdot { fill: var(--key); }
.v-linkdot.sl { fill: var(--accent); }
.v-brace { fill: none; stroke: var(--muted); stroke-width: 1.2; }

/* 정적 링크 화살표: 노란 점선. 동적 링크는 청록 실선(.k) */
.v-ptr .ln { transition: stroke 0.3s ease, stroke-width 0.3s ease; }
.v-ptr.sl .ln { stroke: var(--accent); stroke-dasharray: 4 3; }
.v-ptr.sl .hd { fill: var(--accent); }
.v-ptr.hot .ln { stroke-width: 3; }
.v-ptr.off { opacity: 0.3; }

/* 환경 포인터(EP)와 그 밖의 표시 */
.v-ep { transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.3s ease; }
.v-ep path { fill: var(--accent); transition: fill 0.3s ease; }
.v-ep.hide { opacity: 0; }
.v-ep.bad text { fill: var(--value); }
.v-ep.bad path { fill: var(--value); }
.v-ep.k text { fill: var(--key); }
.v-ep.k path { fill: var(--key); }

/* 실행 표시(지금 실행 중인 줄) */
.v-run { fill: var(--accent); transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.3s ease; }
.v-run.hide { opacity: 0; }

/* 쪽지 */
.v-memo { fill: color-mix(in srgb, var(--accent) 16%, var(--surface)); stroke: var(--accent); stroke-width: 1.2; transition: opacity 0.3s ease; }
.v-memo.k { fill: color-mix(in srgb, var(--key) 16%, var(--surface)); stroke: var(--key); }

/* 그림 속 글씨 */
.viz text.code.b { font-weight: 700; }
.viz text.code.dim { opacity: 0.35; }
.viz text.on.dim, .viz text.k.dim, .viz text.b.dim { opacity: 0.35; }
.viz text.big3 { font-size: 17px; font-weight: 700; }
.fxg { transition: opacity 0.3s ease; }
.fxg.hide { opacity: 0; }
.fxg.dim { opacity: 0.35; }
.v-step.off { opacity: 0.25; }
.v-rule.k { stroke: var(--key); }

/* 흐린 칸과 걷힌 인스턴스의 글씨도 읽히게 */
.v-ari text.dim { opacity: 0.62; }
.v-ari.dim { opacity: 0.6; }
.v-arblock.gone { fill: none; stroke: var(--muted); stroke-dasharray: 4 3; }
.viz text.num20 { font-family: var(--mono); font-size: 20px; font-weight: 700; fill: var(--text); }
.viz text.num20.on { fill: var(--accent); }
.viz text.num20.dim { opacity: 0.3; }
