/* Chival — homepage "same-visit simulator" (hero demo).
 *
 * A live, draggable recreation of the tech capture screen (tech.html) and
 * the manager review screen (dashboard.html), used as the homepage centerpiece.
 * Reuses the shared design tokens from style.css / marketing.css — no new
 * color system. Vanilla CSS only, no build step.
 */

.hd-honesty {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--status-amber);
  background: var(--status-amber-bg);
  border: 1px solid rgba(138, 92, 16, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 0 0 20px;
}

.hd-honesty .dot-warn {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-amber);
  flex: none;
}

/* -------------------------------------------------------------- progress */

.hd-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
  list-style: none;
  padding: 0;
}

.hd-progress li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-faint);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
}

.hd-progress li .hd-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--line-soft);
  color: var(--ink-faint);
  font-size: 11px;
}

.hd-progress li[aria-current="step"] {
  color: var(--bolt-ink);
  border-color: var(--bolt-strong);
  background: var(--bolt-bg);
}

.hd-progress li[aria-current="step"] .hd-step-num {
  background: var(--bolt);
  color: var(--ink);
}

.hd-progress li.hd-done .hd-step-num {
  background: var(--green-bg);
  color: var(--green);
}

/* ----------------------------------------------------------------- stage */

.hd-stage {
  position: relative;
  min-height: 640px;
}

.hd-panels {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: flex-start;
  position: relative;
  min-height: 620px;
}

.hd-panel {
  position: relative;
  flex: 1 1 380px;
  min-width: 300px;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.hd-panel.hd-dragging {
  box-shadow: var(--shadow-lg);
  z-index: 5;
}

.hd-panel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--ink);
  color: #fff;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.hd-panel-bar:active {
  cursor: grabbing;
}

.hd-panel-bar h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: #fff;
}

.hd-panel-bar .hd-drag-hint {
  font-size: 11px;
  color: var(--on-dark-soft);
  opacity: 1;
  transition: opacity 0.5s ease;
  white-space: nowrap;
}

.hd-panel-bar .hd-drag-hint.hd-faded {
  opacity: 0;
}

.hd-panel-body {
  padding: 18px;
}

/* -------------------------------------------------------- phone framing */

.hd-phone .hd-panel-body {
  padding: 20px 16px 22px;
}

.hd-phone-frame {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--canvas);
  padding: 14px 12px 18px;
}

.hd-tile-zone {
  position: relative;
  min-height: 96px;
  margin-bottom: 14px;
}

.hd-plate-tile {
  display: block;
  width: 100%;
  font: inherit;
  text-align: left;
  border: 2px dashed var(--bolt-strong);
  border-radius: var(--radius-sm);
  background: var(--bolt-bg);
  color: var(--ink);
  padding: 14px 16px;
  cursor: grab;
  font-size: 13.5px;
  line-height: 1.4;
}

.hd-plate-tile strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

.hd-plate-tile:active {
  cursor: grabbing;
}

.hd-plate-tile:focus-visible,
.hd-panel-bar:focus-visible,
.hd-send-btn:focus-visible,
.hd-approve-btn:focus-visible,
.hd-replay:focus-visible,
.hd-tier-input:focus-visible {
  outline: 2px solid var(--bolt-strong);
  outline-offset: 2px;
}

.hd-plate-tile.hd-nudge {
  animation: hd-wiggle 0.7s ease;
}

@keyframes hd-wiggle {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px) rotate(-0.5deg); }
  40% { transform: translateX(4px) rotate(0.5deg); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.hd-plate-tile.hd-dropped {
  display: none;
}

.hd-dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius-sm);
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  color: var(--ink-faint);
  padding: 10px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.hd-dropzone.hd-over {
  border-color: var(--bolt-strong);
  background: var(--bolt-bg);
  color: var(--bolt-ink);
}

.hd-dropzone.hd-filled {
  display: none;
}

.hd-scan-shimmer {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
  margin: 4px 0 16px;
  display: none;
}

.hd-scan-shimmer.hd-active {
  display: block;
}

.hd-scan-shimmer::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--bolt), transparent);
  animation: hd-shimmer 0.9s ease-in-out infinite;
}

@keyframes hd-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

.hd-equipment {
  display: none;
}

.hd-equipment.hd-active {
  display: block;
}

.hd-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.hd-field-row.hd-shown {
  opacity: 1;
  transform: translateY(0);
}

.hd-field-row .hd-field-label {
  width: 78px;
  flex: none;
  color: var(--ink-faint);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hd-field-row .hd-field-value {
  font-family: var(--mono);
  color: var(--ink);
  flex: 1;
}

.hd-field-row .hd-conf-val {
  font-size: 11px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.hd-age-badge {
  display: none;
  margin-top: 8px;
}

.hd-age-badge.hd-active {
  display: inline-flex;
}

.hd-findings {
  display: none;
  margin-top: 16px;
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.hd-findings.hd-active {
  display: block;
}

.hd-findings h4 {
  margin: 0 0 4px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}

.hd-no-cost {
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hd-no-cost::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  flex: none;
}

.hd-send-btn {
  display: none;
  width: 100%;
  margin-top: 16px;
  font: inherit;
  font-weight: 650;
  font-size: 14px;
  padding: 11px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--bolt);
  color: var(--ink);
  cursor: pointer;
}

.hd-send-btn.hd-active {
  display: block;
}

.hd-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ------------------------------------------------------ desktop framing */

.hd-desktop-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  padding: 16px;
  min-height: 300px;
}

.hd-empty-review {
  color: var(--ink-faint);
  font-size: 13.5px;
  text-align: center;
  padding: 40px 10px;
}

.hd-review {
  display: none;
}

.hd-review.hd-active {
  display: block;
}

.hd-review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.hd-review-head h4 {
  margin: 0;
  font-size: 15px;
}

.hd-badge-replace {
  background: var(--red-bg);
  color: var(--red);
}

.hd-review-sub {
  font-size: 12.5px;
  color: var(--ink-faint);
  margin: 0 0 14px;
}

.hd-drafting {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-faint);
  padding: 10px 0;
}

.hd-drafting.hd-active {
  display: flex;
}

.hd-drafting .hd-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--bolt-strong);
  animation: hd-spin 0.7s linear infinite;
}

@keyframes hd-spin {
  to { transform: rotate(360deg); }
}

.hd-tiers {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.hd-tier {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 12px;
  position: relative;
}

.hd-tier.hd-popular {
  border-color: var(--bolt-strong);
  box-shadow: 0 0 0 3px var(--bolt-bg);
}

.hd-tier-popular-tag {
  position: absolute;
  top: -10px;
  left: 10px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bolt);
  color: var(--ink);
  padding: 2px 8px;
  border-radius: 999px;
}

.hd-tier-key {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bolt-ink);
  font-weight: 700;
  margin-bottom: 2px;
}

.hd-tier-total {
  display: block;
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 8px;
  color: var(--ink);
}

.hd-tier-items {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 11.5px;
  color: var(--ink-soft);
}

.hd-tier-items li {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 0;
  border-top: 1px dashed var(--line-soft);
}

.hd-tier-items li:first-child {
  border-top: 0;
}

.hd-line-name {
  flex: 1;
}

.hd-line-total {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hd-editable-line {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
  border-top: 1px dashed var(--line-soft);
}

.hd-editable-line .hd-line-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.hd-editable-line .hd-unit-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hd-tier-input {
  width: 72px;
  font: inherit;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  padding: 2px 6px;
  border: 1px solid var(--bolt-strong);
  border-radius: 5px;
  background: var(--bolt-bg);
  color: var(--ink);
}

.hd-editable-hint {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bolt-ink);
  font-weight: 700;
}

.hd-review-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.hd-approve-btn {
  font: inherit;
  font-weight: 650;
  font-size: 14px;
  padding: 10px 18px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--green);
  color: #fff;
  cursor: pointer;
}

.hd-approve-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hd-approved-chip {
  display: none;
}

.hd-approved-chip.hd-active {
  display: inline-block;
}

.hd-autopilot {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.hd-autopilot .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  margin-bottom: 6px;
}

.hd-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
  margin: 6px 0;
}

.hd-bar > span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--bolt), var(--green));
  transition: width 0.6s ease;
}

.hd-autopilot-caption {
  font-size: 12px;
  color: var(--ink-faint);
  min-height: 32px;
}

/* --------------------------------------------------------------- footer */

.hd-controls {
  margin-top: 18px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.hd-replay {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
}

.hd-replay:hover {
  background: var(--bolt-bg);
  color: var(--bolt-ink);
  border-color: var(--bolt-strong);
}

.hd-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ----------------------------------------------------------- responsive */

@media (max-width: 899px) {
  .hd-stage {
    min-height: 0;
  }

  .hd-panels {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .hd-panel {
    position: static !important;
    max-width: 100%;
    width: 100% !important;
  }

  .hd-panel-bar {
    cursor: default;
    touch-action: auto;
  }

  .hd-tiers {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .hd-panel-body {
    padding: 14px 12px;
  }
}

/* ------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  .hd-plate-tile.hd-nudge {
    animation: none;
  }

  .hd-scan-shimmer::after {
    animation: none;
  }

  .hd-drafting .hd-spinner {
    animation: none;
  }

  .hd-field-row,
  .hd-bar > span,
  .hd-panel-bar .hd-drag-hint {
    transition: none;
  }
}
