/* SPDX-License-Identifier: Apache-2.0 */
.estimator-demo-card {
  overflow: hidden;
  margin: 42px 0 0;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(20,32,26,0.04);
}

.fingerprint-estimator {
  --estimator-bg: #071012;
  --estimator-line: rgba(220, 234, 230, 0.16);
  --estimator-text: #f4f1e8;
  --estimator-muted: #9caaa6;
  --estimator-accent: #d9ff43;
  color: var(--estimator-text);
  background:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px),
    var(--estimator-bg);
  background-size: 24px 24px;
}

.fingerprint-estimator__topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--estimator-line);
}

.fingerprint-estimator__topline > span {
  color: var(--estimator-muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fingerprint-estimator__play {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 8px;
  color: var(--estimator-text);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.fingerprint-estimator__play-icon {
  width: 9px;
  height: 12px;
  border-color: transparent transparent transparent currentColor;
  border-style: double;
  border-width: 0 0 0 9px;
}

.fingerprint-estimator.is-paused .fingerprint-estimator__play-icon {
  border-style: solid;
  border-width: 6px 0 6px 9px;
}

.fingerprint-estimator__pipeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 360px;
}

.fingerprint-estimator__stage {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  min-width: 0;
  padding: 24px 20px 22px;
  border-right: 1px solid var(--estimator-line);
}

.fingerprint-estimator__stage:last-child { border-right: 0; }
.fingerprint-estimator__stage::after {
  position: absolute;
  z-index: 2;
  top: 48%;
  right: -9px;
  width: 16px;
  height: 16px;
  color: var(--estimator-muted);
  background: var(--estimator-bg);
  content: "→";
  font-family: var(--mono);
  line-height: 16px;
  text-align: center;
}
.fingerprint-estimator__stage:last-child::after { display: none; }

.fingerprint-estimator__stage.is-active {
  background: linear-gradient(180deg, rgba(217,255,67,0.055), transparent 72%);
}

.fingerprint-estimator__stage.is-active .fingerprint-estimator__stage-index {
  color: var(--estimator-accent);
  border-color: var(--estimator-accent);
}

.fingerprint-estimator__stage-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
}

.fingerprint-estimator__stage-index {
  display: inline-grid;
  width: 25px;
  height: 25px;
  place-items: center;
  color: var(--estimator-muted);
  border: 1px solid var(--estimator-line);
  font-family: var(--mono);
  font-size: 0.67rem;
}

.fingerprint-estimator__stage-heading strong {
  font-size: 0.84rem;
  letter-spacing: 0.01em;
}

.fingerprint-estimator__stage-visual {
  display: grid;
  min-height: 190px;
  place-items: center;
}

.fingerprint-estimator__stage-copy {
  min-height: 58px;
  margin: 0;
  color: var(--estimator-muted);
  font-size: 0.73rem;
  line-height: 1.5;
}

.fingerprint-estimator__stage-copy code { color: var(--estimator-text); }

.fingerprint-estimator__stack {
  position: relative;
  width: 142px;
  height: 142px;
  transform: translate(-8px, -2px);
}

.fingerprint-estimator__image {
  position: absolute;
  inset: 8px;
  overflow: hidden;
  background:
    radial-gradient(circle at 68% 32%, rgba(242,190,128,0.9) 0 12%, transparent 13%),
    linear-gradient(145deg, transparent 0 47%, rgba(22,76,66,0.68) 48% 65%, transparent 66%),
    linear-gradient(180deg, #b6d2d7 0 52%, #798d78 53% 100%);
  border: 1px solid rgba(244,241,232,0.52);
  box-shadow: 0 9px 18px rgba(0,0,0,0.28);
  transform: translate(calc(var(--layer) * 4px), calc(var(--layer) * -4px));
}

.fingerprint-estimator__stack-badge {
  position: absolute;
  z-index: 10;
  right: -12px;
  bottom: -6px;
  padding: 5px 7px;
  color: var(--estimator-bg);
  background: var(--estimator-accent);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 800;
}

.fingerprint-estimator__kernel-demo {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  max-width: 240px;
}

.fingerprint-estimator__pixels {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--estimator-line);
}

.fingerprint-estimator__pixels span {
  background: rgb(var(--pixel), var(--pixel), var(--pixel));
  border: 0.5px solid rgba(255,255,255,0.05);
}

.fingerprint-estimator__pixels span.is-neighbor { box-shadow: inset 0 0 0 2px #8db4c9; }
.fingerprint-estimator__pixels span.is-center { box-shadow: inset 0 0 0 3px var(--estimator-accent); }

.fingerprint-estimator__kernel {
  display: grid;
  grid-template-columns: repeat(3, 24px);
  grid-template-rows: repeat(3, 24px);
  border: 1px solid var(--estimator-line);
}

.fingerprint-estimator__kernel span {
  display: grid;
  place-items: center;
  color: var(--estimator-muted);
  border: 0.5px solid var(--estimator-line);
  font-family: var(--mono);
  font-size: 0.64rem;
}
.fingerprint-estimator__kernel span:nth-child(5) { color: var(--estimator-accent); }

.fingerprint-estimator__kernel-wrap {
  display: grid;
  gap: 9px;
  justify-items: center;
}

.fingerprint-estimator__kernel-wrap > code {
  color: var(--estimator-text);
  font-family: var(--mono);
  font-size: 0.62rem;
}

.fingerprint-estimator__phase-demo {
  display: grid;
  grid-template-columns: 1fr auto 0.72fr;
  gap: 8px;
  align-items: center;
  width: 100%;
  max-width: 245px;
}

.fingerprint-estimator__raster-wrap,
.fingerprint-estimator__phase-bin-wrap {
  display: grid;
  gap: 7px;
}

.fingerprint-estimator__raster-wrap > span,
.fingerprint-estimator__phase-bin-wrap > span {
  color: var(--estimator-muted);
  font-family: var(--mono);
  font-size: 0.52rem;
  letter-spacing: 0.02em;
  text-align: center;
}

.fingerprint-estimator__raster,
.fingerprint-estimator__phase-cell,
.fingerprint-estimator__map {
  display: grid;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid var(--estimator-line);
}
.fingerprint-estimator__raster { grid-template-columns: repeat(8, 1fr); }
.fingerprint-estimator__phase-cell,
.fingerprint-estimator__map { grid-template-columns: repeat(4, 1fr); }
.fingerprint-estimator__raster span {
  opacity: 0.58;
  background: var(--phase-color);
  border: 0.5px solid rgba(255,255,255,0.1);
  transition: opacity 120ms linear, background 120ms linear, box-shadow 120ms linear;
}
.fingerprint-estimator__raster span.is-cell-right-edge { border-right: 2px solid rgba(244,241,232,0.74); }
.fingerprint-estimator__raster span.is-cell-bottom-edge { border-bottom: 2px solid rgba(244,241,232,0.74); }
.fingerprint-estimator__raster span.is-phase-active {
  z-index: 1;
  opacity: 1;
  background: var(--estimator-accent);
  box-shadow: inset 0 0 0 1px var(--estimator-bg);
}
.fingerprint-estimator__phase-cell span {
  display: grid;
  place-items: center;
  color: var(--estimator-muted);
  background: rgba(255,255,255,0.04);
  border: 0.5px solid var(--estimator-line);
  font-family: var(--mono);
  font-size: 0.48rem;
}
.fingerprint-estimator__phase-cell span.is-phase-active {
  color: var(--estimator-bg);
  background: var(--estimator-accent);
}
.fingerprint-estimator__phase-arrow { color: var(--estimator-muted); font-family: var(--mono); }

.fingerprint-estimator__running-mean-demo {
  display: grid;
  gap: 8px;
  width: min(100%, 148px);
}
.fingerprint-estimator__colorbar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  color: var(--estimator-muted);
  font-family: var(--mono);
  font-size: 0.44rem;
  line-height: 1;
}
.fingerprint-estimator__colorbar i {
  grid-column: 1 / -1;
  height: 6px;
  margin-bottom: 4px;
  background: linear-gradient(90deg, #315c78, #b9d0d9, #f7f5f0, #ddb3a6, #96473f);
  border: 1px solid rgba(220,234,230,.28);
}
.fingerprint-estimator__colorbar span:nth-of-type(1) { text-align: left; }
.fingerprint-estimator__colorbar span:nth-of-type(2) { text-align: center; }
.fingerprint-estimator__colorbar span:nth-of-type(3) { text-align: right; }

.fingerprint-estimator__running-label {
  color: var(--estimator-muted);
  font-family: var(--mono);
  font-size: 0.52rem;
  text-align: center;
}
.fingerprint-estimator__running-label output { color: var(--estimator-accent); }

.fingerprint-estimator__map span { border: 0.5px solid rgba(7,16,18,0.14); }

.fingerprint-estimator__mean-equations {
  display: grid;
  gap: 3px;
  color: var(--estimator-text);
  font-family: var(--mono);
  font-size: 0.58rem;
  text-align: center;
}

.fingerprint-estimator__controls {
  display: grid;
  grid-template-columns: minmax(230px, 0.9fr) minmax(250px, 0.75fr) minmax(280px, 1.35fr);
  gap: 26px;
  align-items: center;
  min-height: 106px;
  padding: 18px 22px;
  border-top: 1px solid var(--estimator-line);
}

.fingerprint-estimator__range-label {
  display: grid;
  gap: 8px;
  margin: 0;
  color: var(--estimator-text);
  font-family: var(--mono);
  font-size: 0.74rem;
}
.fingerprint-estimator__range-label output { color: var(--estimator-accent); }
.fingerprint-estimator__range-label input { width: 100%; margin: 0; accent-color: var(--estimator-accent); }

.fingerprint-estimator__signal {
  display: grid;
  gap: 8px;
}
.fingerprint-estimator__signal-row {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 9px;
  align-items: center;
  color: var(--estimator-muted);
  font-size: 0.65rem;
}
.fingerprint-estimator__signal-track {
  height: 7px;
  overflow: hidden;
  background: rgba(255,255,255,0.07);
}
.fingerprint-estimator__signal-track i { display: block; height: 100%; }
.fingerprint-estimator__signal-content { width: 92%; background: #8db4c9; transition: width 120ms linear; }
.fingerprint-estimator__signal-phase { width: 68%; background: var(--estimator-accent); }

.fingerprint-estimator__state {
  margin: 0;
  color: var(--estimator-muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.estimator-demo-card figcaption {
  padding: 20px 24px 24px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}
.estimator-demo-card figcaption strong { color: var(--ink); }

@media (max-width: 1040px) {
  .fingerprint-estimator__pipeline { grid-template-columns: 1fr 1fr; }
  .fingerprint-estimator__stage:nth-child(2) { border-right: 0; }
  .fingerprint-estimator__stage:nth-child(-n+2) { border-bottom: 1px solid var(--estimator-line); }
  .fingerprint-estimator__stage:nth-child(2)::after { content: "↓"; top: auto; right: 50%; bottom: -9px; }
  .fingerprint-estimator__stage:nth-child(3)::after { content: "→"; }
  .fingerprint-estimator__controls { grid-template-columns: 1fr 1fr; }
  .fingerprint-estimator__state { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .fingerprint-estimator__topline { flex-wrap: wrap; align-items: flex-start; }
  .fingerprint-estimator__pipeline { grid-template-columns: 1fr; }
  .fingerprint-estimator__stage { min-height: 290px; padding: 20px 18px; border-right: 0; border-bottom: 1px solid var(--estimator-line); }
  .fingerprint-estimator__stage-visual { min-height: 160px; }
  .fingerprint-estimator__stage-copy { min-height: 0; }
  .fingerprint-estimator__stage:last-child { border-bottom: 0; }
  .fingerprint-estimator__stage:nth-child(1)::after,
  .fingerprint-estimator__stage:nth-child(2)::after,
  .fingerprint-estimator__stage:nth-child(3)::after {
    top: auto;
    right: 50%;
    bottom: -9px;
    content: "↓";
  }
  .fingerprint-estimator__controls { grid-template-columns: 1fr; gap: 18px; padding: 16px 18px; }
  .fingerprint-estimator__signal-row { grid-template-columns: minmax(0, 1fr); gap: 5px; }
  .fingerprint-estimator__state { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .fingerprint-estimator__signal-content,
  .fingerprint-estimator__raster span { transition: none; }
}
