/* CompTech Notes: a robot acting out Input → Process → Output on a grid world. */

.scene-comptech {
  background:
    radial-gradient(70% 70% at 74% 62%, rgba(255, 122, 89, 0.12), transparent 70%),
    radial-gradient(60% 60% at 8% 0%, rgba(62, 207, 217, 0.08), transparent 70%),
    linear-gradient(160deg, #18131a, #0c0b10);
  color: #ece4e0;
}

.ct-wrap {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 2.4cqh 2.6cqi;
  padding: 3.6cqh 3.6cqi 3cqh;
  font: 500 max(9.5px, 2cqi)/1.3 var(--mono);
}

/* ---- IPO chart */
.ct-ipo {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
}
.ct-box {
  --c: #3ecfd9;
  min-width: 0;
  padding: 0.75em 0.95em;
  border: 1px solid color-mix(in srgb, var(--c) 28%, transparent);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  transition: background-color 0.18s, border-color 0.18s, box-shadow 0.25s, transform 0.25s var(--ease);
}
.ct-box-1 { --c: #ffc857; }
.ct-box-2 { --c: #ff7a59; }
.ct-box b {
  display: block;
  font-size: max(8px, 0.78em);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--c);
}
.ct-box span {
  display: block;
  margin-top: 0.4em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #b9b0ad;
  transition: color 0.18s;
}
.ct-box.on {
  background: color-mix(in srgb, var(--c) 14%, transparent);
  border-color: var(--c);
  box-shadow: 0 0 22px -6px var(--c), inset 0 0 12px -6px var(--c);
  transform: translateY(-1px);
}
.ct-box.on span { color: #fff6f1; }

.ct-arrow {
  position: relative;
  align-self: center;
  width: 2.6cqi;
  min-width: 12px;
  height: 2px;
  margin: 0 0.5cqi;
  background: rgba(236, 228, 224, 0.18);
  transition: background-color 0.18s, box-shadow 0.18s;
}
.ct-arrow::after {
  content: '';
  position: absolute;
  right: -1px;
  top: -3px;
  border: 4px solid transparent;
  border-right: 0;
  border-left: 6px solid rgba(236, 228, 224, 0.18);
  transition: border-color 0.18s;
}
.ct-arrow.on { background: #ffc857; box-shadow: 0 0 8px #ffc857; }
.ct-arrow.on::after { border-left-color: #ffc857; }

/* ---- pseudocode */
.ct-code {
  --hl: #3ecfd9;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  margin: 0;
  padding: 0.9em 1em;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.32);
  color: #a9a09d;
  font: 500 max(8px, 1.85cqi)/1.55 var(--mono);
  white-space: pre;
  overflow: hidden;
}
.ct-code[data-phase='1'] { --hl: #ffc857; }
.ct-code[data-phase='2'] { --hl: #ff7a59; }
.ct-code .ln { display: block; padding: 0 0.5em; margin: 0 -0.5em; border-radius: 3px; transition: background-color 0.08s, color 0.08s; }
.ct-code .kw { color: #3ecfd9; }
.ct-code .ln.on { background: var(--hl); color: #160e0c; box-shadow: 0 0 14px -4px var(--hl); }
.ct-code .ln.on .kw { color: #160e0c; font-weight: 700; }

/* ---- grid world */
.ct-stage { position: relative; min-width: 0; min-height: 0; }
.ct-stage canvas { touch-action: manipulation; border-radius: 8px; }
/* The canvas draws its own focus ring around the board itself. */
.ct-stage canvas:focus { outline: none; }

.ct-foot {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 2cqi;
  color: rgba(236, 228, 224, 0.5);
  font-size: 0.86em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.ct-hint { overflow: hidden; text-overflow: ellipsis; }
.ct-hint::before { content: '▸ '; color: #ff7a59; }
.ct-tick { font-variant-numeric: tabular-nums; }

.ct-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- narrow or squarer (phone) plates: drop the code listing, keep the chart and the grid */
@container (max-width: 440px) or (max-aspect-ratio: 13 / 10) {
  .ct-wrap { grid-template-columns: minmax(0, 1fr); gap: 2cqh 0; padding: 3.4cqh 3.4cqi 2.6cqh; font-size: max(9px, 2.6cqi); }
  .ct-code { display: none; }
  .ct-box { padding: 0.55em 0.6em; border-radius: 6px; }
  .ct-box b { font-size: 0.8em; letter-spacing: 0.1em; }
  .ct-box span { font-size: 0.92em; }
  .ct-arrow { width: 2cqi; min-width: 8px; margin: 0 0.6cqi; }
  .ct-foot { font-size: 0.82em; letter-spacing: 0.06em; }
}

@media (prefers-reduced-motion: reduce) {
  .ct-box, .ct-box span, .ct-arrow, .ct-arrow::after, .ct-code .ln { transition: none; }
}
