/* Size Cam — clinical instrument, played straight. */

:root {
  --bg:        #08090a;
  --panel:     #0e1012;
  --ink:       #e8e8e4;
  --ink-dim:   #8b9095;
  --ink-faint: #4a4f55;
  --rule:      #1b1f23;
  --signal:    #ff4d19;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --gutter: clamp(1.25rem, 5vw, 2.5rem);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  overflow-x: hidden;
}

/* Faint scanline texture over the whole instrument. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.014) 0 1px,
    transparent 1px 3px
  );
}

/* ─────────── chrome ─────────── */

.chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem var(--gutter);
  border-bottom: 1px solid var(--rule);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.chrome__mark { color: var(--ink); }

.chrome__meta {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  color: var(--ink-faint);
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--signal);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.25; }
}

/* ─────────── screens ─────────── */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.1rem, 3.2vh, 1.75rem);
  padding: clamp(1.25rem, 4vh, 2.5rem) var(--gutter) clamp(1.25rem, 3vh, 2rem);
  text-align: center;
  animation: rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

body[data-screen="landing"] #landing,
body[data-screen="scan"]    #scan,
body[data-screen="result"]  #result { display: flex; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ─────────── landing ─────────── */

.reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(78vw, 30rem);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.5;
}

.reticle__corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 1px solid var(--ink-faint);
}
.reticle__corner--tl { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.reticle__corner--tr { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.reticle__corner--bl { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.reticle__corner--br { bottom: 0; right: 0; border-left: 0; border-top: 0; }

.reticle__crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 1px;
  transform: translate(-50%, -50%);
  background: linear-gradient(to right, transparent, var(--rule) 20%, var(--rule) 80%, transparent);
}

.reticle__sweep {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255, 77, 25, 0.55), transparent);
  animation: sweep 6s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

@keyframes sweep {
  0%, 100% { top: 6%;  opacity: 0; }
  10%      { opacity: 1; }
  90%      { opacity: 1; }
  50%      { top: 94%; }
}

.display {
  position: relative;
  margin: 0;
  font-size: clamp(3rem, 15vw, 5.5rem);
  font-weight: 500;
  line-height: 0.92;
  letter-spacing: -0.045em;
}

.lede {
  position: relative;
  max-width: 44ch;
  margin: -0.75rem 0 0;
  color: var(--ink-dim);
  font-size: 0.875rem;
  line-height: 1.7;
  text-wrap: balance;
}

.specsheet {
  position: relative;
  display: grid;
  gap: 0;
  width: min(100%, 26rem);
  margin: 0;
  border-top: 1px solid var(--rule);
}

.specsheet > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}

.specsheet dt,
.metrics dt {
  color: var(--ink-faint);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.specsheet dd,
.metrics dd {
  margin: 0;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.finewrap { margin: 0; max-width: 40ch; }

.fine {
  color: var(--ink-faint);
  font-size: 0.6875rem;
  line-height: 1.7;
}

/* ─────────── buttons ─────────── */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0 1.75rem;
  border: 1px solid transparent;
  border-radius: 2px;
  font-family: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn--primary {
  background: var(--signal);
  color: #0a0503;
  font-weight: 600;
}
.btn--primary:hover { background: #ff6438; }

.btn--ghost {
  background: transparent;
  border-color: var(--rule);
  color: var(--ink-dim);
}
.btn--ghost:hover { border-color: var(--ink-faint); color: var(--ink); }

.btn:focus-visible {
  outline: 1px solid var(--signal);
  outline-offset: 3px;
}

/* ─────────── scan ─────────── */

.screen--scan { justify-content: center; gap: 2rem; }

.frame {
  position: relative;
  width: min(100%, 30rem);
  aspect-ratio: 3 / 4;
  max-height: 52svh;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--rule);
}

.frame__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.7) contrast(1.08) brightness(0.85);
}

.frame__overlay { position: absolute; inset: 0; }

.scanline {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--signal);
  box-shadow: 0 0 14px 2px rgba(255, 77, 25, 0.55);
  animation: scan 1.7s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

@keyframes scan {
  0%, 100% { top: 2%; }
  50%      { top: 98%; }
}

.bracket {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.55);
}
.bracket--tl { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.bracket--tr { top: 10px; right: 10px; border-left: 0; border-bottom: 0; }
.bracket--bl { bottom: 10px; left: 10px; border-right: 0; border-top: 0; }
.bracket--br { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }

.nodes { position: absolute; inset: 0; }

.node {
  position: absolute;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border: 1px solid var(--signal);
  opacity: 0;
  animation: node-in 0.4s ease-out forwards;
}

@keyframes node-in {
  from { opacity: 0; transform: scale(2.4); }
  to   { opacity: 1; transform: scale(1); }
}

.readout { width: min(100%, 30rem); text-align: left; }

.steps {
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.6rem;
}

.steps li {
  display: grid;
  grid-template-columns: 1.5rem 1fr;
  align-items: baseline;
  font-size: 0.8125rem;
  color: var(--ink-faint);
  transition: color 0.3s ease;
}

.steps li::before {
  content: "·";
  color: var(--ink-faint);
}

.steps li[data-state="active"] { color: var(--ink); }
.steps li[data-state="active"]::before {
  content: "▸";
  color: var(--signal);
  animation: pulse 1s ease-in-out infinite;
}

.steps li[data-state="done"] { color: var(--ink-dim); }
.steps li[data-state="done"]::before { content: "✓"; color: var(--ink-faint); }

.progress {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding-top: 1.125rem;
  border-top: 1px solid var(--rule);
}

.progress__bar {
  flex: 1;
  height: 2px;
  background: var(--rule);
  overflow: hidden;
}

.progress__fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--signal);
  transition: width 0.4s linear;
}

.progress__pct {
  min-width: 3.5ch;
  color: var(--ink-dim);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ─────────── result ─────────── */

.stamp {
  margin: 0;
  color: var(--signal);
  font-size: 0.6875rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.figure { display: grid; gap: 0.5rem; }

.figure__primary {
  font-size: clamp(4rem, 21vw, 7.5rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.05em;
  word-spacing: -0.18em;
  font-variant-numeric: tabular-nums;
}

.figure__unit {
  color: var(--ink-dim);
  font-size: 0.5em;
  vertical-align: super;
  letter-spacing: 0;
}

.figure__secondary {
  color: var(--ink-dim);
  font-size: 0.9375rem;
  letter-spacing: 0.06em;
}

.metrics {
  display: grid;
  width: min(100%, 26rem);
  margin: 0;
  border-top: 1px solid var(--rule);
}

.metrics > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}

.accent { color: var(--signal); }

.thumb {
  width: 4.5rem;
  height: 6rem;
  object-fit: cover;
  border: 1px solid var(--rule);
  filter: grayscale(1) brightness(0.7);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
