/* ────────────────────────────────────────────────────────────
   Debugging C++ in Release Mode — page-specific styles
   ──────────────────────────────────────────────────────────── */

/* ── Comparison block: debug build vs release build, side by side ── */
.dbg-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.75rem 0;
}

@media (max-width: 720px) {
  .dbg-compare { grid-template-columns: 1fr; }
}

.dbg-compare .dbg-card {
  background: var(--tut-surface);
  border: 1px solid var(--tut-border);
  border-radius: 10px;
  overflow: hidden;
}

.dbg-compare .dbg-card-head {
  padding: 0.55rem 0.9rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tut-muted);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--tut-border-soft);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.dbg-compare .dbg-card-head::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--tut-muted);
}

.dbg-compare .dbg-card.debug .dbg-card-head::before { background: var(--tut-info); }
.dbg-compare .dbg-card.release .dbg-card-head::before { background: var(--tut-accent); }

.dbg-compare pre.code {
  border-radius: 0;
  background: var(--tut-code-bg);
  font-size: 0.78rem;
  padding: 0.85rem 1rem;
}

/* ── Build-flag table (used in §3) ── */
.flag-table-wrap {
  margin: 1.5rem 0 1.8rem;
  overflow-x: auto;
  border: 1px solid var(--tut-border);
  border-radius: 10px;
  background: var(--tut-surface);
}

.flag-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  color: var(--tut-soft);
}

.flag-table th, .flag-table td {
  padding: 0.55rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--tut-border-soft);
  vertical-align: top;
}

.flag-table th {
  background: rgba(167, 139, 250, 0.06);
  color: var(--tut-accent);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--tut-border);
}

.flag-table tbody tr:last-child td { border-bottom: none; }
.flag-table tbody tr:hover { background: rgba(167, 139, 250, 0.04); }

.flag-table code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: rgba(167, 139, 250, 0.10);
  border: 1px solid var(--tut-border-soft);
  padding: 0.05em 0.4em;
  border-radius: 4px;
  color: var(--tut-text);
}

/* ── Optimizer ladder widget ── */
.opt-ladder {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
}

@media (max-width: 900px) {
  .opt-ladder { grid-template-columns: repeat(2, 1fr); }
}

.opt-rung {
  background: var(--tut-code-bg);
  border: 1px solid var(--tut-code-border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 280px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.opt-rung.active {
  border-color: var(--tut-accent);
  box-shadow: 0 6px 22px rgba(167, 139, 250, 0.18);
}

.opt-rung-head {
  padding: 0.45rem 0.7rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--tut-code-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.opt-rung-head .opt-flag { color: var(--tut-accent); }
.opt-rung-head .opt-cycles { color: var(--tut-muted); font-size: 0.66rem; font-weight: 500; }

.opt-rung pre {
  margin: 0;
  padding: 0.7rem 0.85rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.55;
  color: #d8d8e6;
  overflow-x: auto;
  white-space: pre;
  flex: 1;
}

.opt-rung pre .kw { color: #c084fc; }
.opt-rung pre .fn { color: #60a5fa; }
.opt-rung pre .com { color: #5b5b78; font-style: italic; }
.opt-rung pre .op { color: #94a3b8; }
.opt-rung pre .num { color: #fb923c; }
.opt-rung pre .reg { color: #fbbf24; }

.opt-rung pre .hl {
  background: rgba(251, 191, 36, 0.18);
  border-radius: 3px;
  padding: 0 2px;
}

.opt-transforms {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.opt-tag {
  font-family: var(--mono);
  font-size: 0.67rem;
  letter-spacing: 0.04em;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  background: rgba(167, 139, 250, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.2);
  color: var(--tut-soft);
}

.opt-tag.applied {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--tut-success);
}

/* ── Stack frame visualizer ── */
.stack-frame-wrap {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 720px) {
  .stack-frame-wrap { grid-template-columns: 1fr; }
}

.stack-frame {
  background: var(--tut-bg);
  border: 1px solid var(--tut-border);
  border-radius: 8px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.stack-row {
  display: grid;
  grid-template-columns: 110px 1fr 90px;
  align-items: center;
  padding: 0.4rem 0.7rem;
  border-bottom: 1px solid var(--tut-border-soft);
  transition: background 0.15s;
  gap: 0.6rem;
}

.stack-row:last-child { border-bottom: none; }

.stack-row .stack-addr {
  color: var(--tut-muted);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.stack-row .stack-label {
  color: var(--tut-soft);
}

.stack-row .stack-value {
  color: var(--tut-text);
  text-align: right;
  font-size: 0.72rem;
}

.stack-row.frame-base { background: rgba(96, 165, 250, 0.07); }
.stack-row.return-addr { background: rgba(251, 191, 36, 0.07); }
.stack-row.saved-reg { background: rgba(167, 139, 250, 0.05); }
.stack-row.local { background: rgba(52, 211, 153, 0.04); }
.stack-row.spill { background: rgba(248, 113, 113, 0.05); }
.stack-row.highlight {
  outline: 1px solid var(--tut-accent);
  outline-offset: -1px;
  background: rgba(167, 139, 250, 0.18);
}

.stack-side {
  font-size: 0.85rem;
  color: var(--tut-soft);
  line-height: 1.55;
}

.stack-side h5 {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tut-accent);
  margin: 0 0 0.45rem;
}

.stack-side dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 0.7rem;
  margin: 0 0 0.85rem;
  font-family: var(--mono);
  font-size: 0.76rem;
}

.stack-side dt { color: var(--tut-muted); }
.stack-side dd { margin: 0; color: var(--tut-text); }

.stack-frame-controls {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.7rem;
}

.stack-frame-controls .btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.72rem;
}

/* ── Memory grid (used by watchpoint + ASan widgets) ── */
.mem-grid-wrap {
  display: grid;
  gap: 0.7rem;
}

.mem-grid {
  display: grid;
  gap: 2px;
  font-family: var(--mono);
  font-size: 0.65rem;
  background: var(--tut-bg);
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--tut-border-soft);
}

.mem-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.025);
  color: var(--tut-muted);
  border-radius: 3px;
  position: relative;
  transition: background 0.18s, color 0.18s, transform 0.18s;
  min-height: 22px;
}

.mem-cell.live { background: rgba(96, 165, 250, 0.35); color: var(--tut-text); }
.mem-cell.poisoned { background: rgba(248, 113, 113, 0.45); color: #fff; }
.mem-cell.redzone { background: rgba(251, 191, 36, 0.4); color: #1a1a26; }
.mem-cell.freed { background: rgba(120, 120, 140, 0.25); color: var(--tut-muted); text-decoration: line-through; }
.mem-cell.write-hit {
  background: var(--tut-accent);
  color: #fff;
  transform: scale(1.18);
  box-shadow: 0 0 12px var(--tut-accent);
  z-index: 2;
}
.mem-cell.read-hit {
  background: var(--tut-info);
  color: #fff;
  transform: scale(1.12);
  box-shadow: 0 0 10px var(--tut-info);
  z-index: 2;
}
.mem-cell.watched {
  outline: 2px solid var(--tut-accent);
  outline-offset: -2px;
}
.mem-cell.error {
  background: var(--tut-danger);
  color: #fff;
  animation: errorPulse 0.6s ease 3;
}

@keyframes errorPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.6); }
  50%      { box-shadow: 0 0 0 8px rgba(248, 113, 113, 0.0); }
}

.mem-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--tut-muted);
  margin-top: 0.3rem;
}

.mem-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.mem-legend .swatch {
  width: 14px; height: 14px; border-radius: 3px;
  display: inline-block;
}

.mem-legend .swatch.live { background: rgba(96, 165, 250, 0.55); }
.mem-legend .swatch.redzone { background: rgba(251, 191, 36, 0.55); }
.mem-legend .swatch.poisoned { background: rgba(248, 113, 113, 0.55); }
.mem-legend .swatch.freed { background: rgba(120, 120, 140, 0.45); }
.mem-legend .swatch.watched {
  background: transparent;
  border: 2px solid var(--tut-accent);
  box-sizing: border-box;
}

/* ── Sanitizer report log ── */
.san-log {
  background: #07070d;
  color: #d8d8e6;
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.5;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--tut-border-soft);
  border-radius: 6px;
  white-space: pre-wrap;
  min-height: 110px;
  overflow-y: auto;
  max-height: 240px;
}

.san-log .san-tag {
  display: inline-block;
  padding: 0 0.35em;
  border-radius: 3px;
  font-weight: 700;
}

.san-log .san-tag.err { background: rgba(248, 113, 113, 0.2); color: var(--tut-danger); }
.san-log .san-tag.warn { background: rgba(251, 191, 36, 0.18); color: var(--tut-warn); }
.san-log .san-tag.ok { background: rgba(52, 211, 153, 0.18); color: var(--tut-success); }
.san-log .san-tag.info { background: rgba(96, 165, 250, 0.18); color: var(--tut-info); }

.san-log .faint { color: var(--tut-muted); }

/* ── Race detector swim lanes ── */
.race-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(220px, 1fr);
  gap: 1rem;
  align-items: start;
}

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

.race-canvas-wrap {
  background: var(--tut-bg);
  border: 1px solid var(--tut-border-soft);
  border-radius: 8px;
  padding: 0.6rem;
}

.race-readout {
  background: var(--tut-bg);
  border: 1px solid var(--tut-border-soft);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--tut-text);
  line-height: 1.6;
}

.race-readout .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px dashed var(--tut-border-soft);
  padding: 0.25rem 0;
}

.race-readout .row:last-child { border-bottom: none; }

.race-readout .lbl {
  color: var(--tut-muted);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.race-readout .val.bad { color: var(--tut-danger); }
.race-readout .val.good { color: var(--tut-success); }

/* ── Disassembly fingerprinter ── */
.fp-game {
  display: grid;
  gap: 0.85rem;
}

.fp-snippet {
  background: var(--tut-code-bg);
  border: 1px solid var(--tut-code-border);
  border-radius: 8px;
  padding: 0.75rem 0.95rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.6;
  color: #d8d8e6;
  white-space: pre;
  overflow-x: auto;
}

.fp-snippet .com { color: #5b5b78; font-style: italic; }
.fp-snippet .fn { color: #60a5fa; }
.fp-snippet .reg { color: #fbbf24; }
.fp-snippet .num { color: #fb923c; }
.fp-snippet .hl { background: rgba(167, 139, 250, 0.22); border-radius: 2px; padding: 0 2px; }

.fp-options {
  display: grid;
  gap: 0.45rem;
}

.fp-opt {
  text-align: left;
  background: var(--tut-bg);
  border: 1px solid var(--tut-border);
  color: var(--tut-soft);
  font-family: inherit;
  font-size: 0.92rem;
  padding: 0.6rem 0.85rem;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
}

.fp-opt:hover:not(:disabled) {
  border-color: var(--tut-accent);
  background: rgba(167, 139, 250, 0.06);
  color: var(--tut-text);
}

.fp-opt.right {
  border-color: var(--tut-success);
  background: rgba(52, 211, 153, 0.08);
  color: var(--tut-text);
}

.fp-opt.wrong {
  border-color: var(--tut-danger);
  background: rgba(248, 113, 113, 0.08);
  color: var(--tut-text);
}

.fp-explain {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--tut-soft);
  background: rgba(167, 139, 250, 0.05);
  border-left: 2px solid var(--tut-accent);
  padding: 0.6rem 0.85rem;
  border-radius: 0 6px 6px 0;
}

.fp-explain[hidden] { display: none; }

.fp-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--tut-muted);
}

/* ── Tip-list (numbered tip cards) ── */
.tip-list {
  display: grid;
  gap: 0.7rem;
  margin: 1.5rem 0 2rem;
  padding: 0;
  list-style: none;
  counter-reset: tipnum;
}

.tip-list li {
  counter-increment: tipnum;
  background: var(--tut-surface);
  border: 1px solid var(--tut-border);
  border-radius: 8px;
  padding: 0.75rem 1rem 0.85rem 3.2rem;
  position: relative;
  font-size: 0.96rem;
  line-height: 1.6;
  color: var(--tut-soft);
}

.tip-list li::before {
  content: counter(tipnum, decimal-leading-zero);
  position: absolute;
  top: 0.7rem;
  left: 0.95rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--tut-accent);
  background: rgba(167, 139, 250, 0.12);
  padding: 0.2em 0.45em;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.tip-list li strong { color: var(--tut-text); }
.tip-list li code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(167, 139, 250, 0.08);
  padding: 0.05em 0.35em;
  border-radius: 3px;
  color: var(--tut-text);
}

/* ── Mobile tweaks ── */
@media (max-width: 720px) {
  .opt-ladder { grid-template-columns: 1fr; }
  .stack-row { grid-template-columns: 90px 1fr; }
  .stack-row .stack-value { display: none; }
}
