/* Chapter 3, Features: styles for its interactive figures */

.kernel {
  display: inline-grid;
  grid-template-columns: repeat(3, 4.2rem);
  gap: 0.3rem;
  padding: 0.5rem;
  border: 1px solid rgba(207, 185, 125, 0.45);
  border-radius: 12px;
  background: rgba(207, 185, 125, 0.08);
}

.kernel input {
  width: 100%;
  padding: 0.25rem 0.3rem;
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 7px;
  background: transparent;
  color: inherit;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.kernel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem 1.2rem;
  margin-top: 0.9rem;
}

.kernel-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.sim__pair canvas.sim__canvas {
  background: #111;
}

/* Step-by-step convolution grids */

.steps {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 1.2rem 1.6rem;
}

.steps figure {
  margin: 0;
  text-align: center;
}

.steps figcaption {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  opacity: 0.7;
}

.grid {
  display: grid;
  gap: 3px;
}

.grid span {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 6px;
  background: rgba(128, 128, 128, 0.12);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  transition: background 150ms ease, color 150ms ease;
}

.grid--kernel span {
  background: rgba(207, 185, 125, 0.28);
  font-weight: 700;
}

.grid span.is-window {
  background: rgba(207, 185, 125, 0.55);
  color: #1d1e00;
  font-weight: 700;
}

.grid span.is-current {
  background: #cfb97d;
  color: #1d1e00;
  font-weight: 800;
}

.grid--output span:empty {
  background: rgba(128, 128, 128, 0.06);
}

/* Harris patch figure: scene beside the eigenvalue plot */

.harris-layout {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 0.8rem;
  align-items: start;
}

.harris-layout canvas {
  width: 100%;
  border-radius: 12px;
  touch-action: none;
  cursor: crosshair;
}

.harris-layout canvas + canvas,
.harris-layout figure:last-child canvas {
  background: rgba(128, 128, 128, 0.08);
  cursor: default;
}

.harris-layout figure {
  margin: 0;
}

.harris-layout figcaption {
  margin-top: 0.3rem;
  font-size: 0.85rem;
  opacity: 0.7;
  text-align: center;
}

#grad-sim canvas {
  touch-action: none;
  cursor: crosshair;
}

/* Stacked matching canvas */
#orb-match canvas {
  max-width: 560px;
  margin: 0 auto;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  font-size: 0.82rem;
  opacity: 0.8;
}

.legend span::before {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.35rem;
  border-radius: 3px;
  vertical-align: -1px;
  content: "";
}

.legend .is-flat::before { background: #7aa7ff; }
.legend .is-edge::before { background: #f0a030; }
.legend .is-corner::before { background: #2fbf71; }

@media (max-width: 640px) {
  .harris-layout {
    grid-template-columns: 1fr;
  }

  .harris-layout figure:last-child {
    max-width: 220px;
    margin: 0 auto;
  }

  .grid span {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.75rem;
  }
}
