/* Instant Estimate Calculator - page-scoped additions only */

.estimate-page .calculator-form {
  max-width: 920px;
  margin: 0 auto;
}

.estimate-page .calculator-results {
  max-width: 1120px;
  margin: var(--space-8) auto 0;
  background: var(--color-surface);
}

.estimate-page .wizard-progress[hidden],
.estimate-page .estimate-wizard[hidden] {
  display: none !important;
}

.estimate-page .wizard-choice {
  min-height: 44px;
  position: relative;
  padding-right: calc(var(--space-5) + 28px);
}

.estimate-page .wizard-choice::after,
.estimate-page .wizard-choice::before {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.estimate-page .wizard-choice::after {
  content: "";
  top: var(--space-3);
  right: var(--space-3);
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-surface);
  transform: scale(0.72);
}

.estimate-page .wizard-choice::before {
  content: "";
  z-index: 1;
  top: calc(var(--space-3) + 6px);
  right: calc(var(--space-3) + 5px);
  width: 10px;
  height: 6px;
  border-bottom: 2px solid var(--color-text-on-dark);
  border-left: 2px solid var(--color-text-on-dark);
  transform: rotate(-45deg) scale(0.72);
}

.estimate-page .wizard-choice.is-selected::after {
  opacity: 1;
  transform: scale(1);
}

.estimate-page .wizard-choice.is-selected::before {
  opacity: 1;
  transform: rotate(-45deg) scale(1);
}

.estimate-page .wizard-choice-icon {
  width: 52px;
  height: 52px;
  color: var(--color-primary);
}

.estimate-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.estimate-svg svg {
  width: 100%;
  height: 100%;
  display: block;
}

.estimate-choice-note,
.estimate-step-note {
  font-size: var(--text-sm);
  color: var(--color-text-light);
  line-height: var(--leading-normal);
}

.estimate-step-note {
  margin: calc(-1 * var(--space-2)) 0 var(--space-4);
}

.estimate-choice-note {
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
}

.estimate-reference-strip {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin: 0 0 var(--space-4);
}

.estimate-reference-strip .estimate-svg {
  width: 56px;
  height: 56px;
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
}

.estimate-reference-photo {
  display: grid;
  grid-template-columns: minmax(86px, 112px) 1fr;
  gap: var(--space-3);
  align-items: center;
  margin: 0 0 var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
}

.estimate-reference-photo-media {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.estimate-reference-photo img,
.estimate-learn-visual img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.estimate-reference-photo figcaption {
  margin: 0;
  color: var(--color-text);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.estimate-learn {
  margin-top: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
  overflow: hidden;
}

.estimate-learn summary {
  cursor: pointer;
  padding: var(--space-4);
  color: var(--color-text-heading);
  font-weight: var(--font-semibold);
}

.estimate-learn summary::marker {
  color: var(--color-primary);
}

.estimate-learn[open] summary {
  border-bottom: 1px solid var(--color-border);
}

.estimate-learn-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  padding: var(--space-4);
}

.estimate-learn-item {
  display: grid;
  grid-template-columns: minmax(132px, 168px) 1fr;
  gap: var(--space-4);
  align-items: start;
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.estimate-learn-visual {
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg-alt);
}

.estimate-learn-illustration .estimate-svg {
  width: 82%;
  height: 82%;
}

.estimate-learn-item h4 {
  margin: 0 0 var(--space-2);
  color: var(--color-text-heading);
  font-size: var(--text-lg);
  line-height: var(--leading-tight);
}

.estimate-learn-item p {
  margin: 0;
  color: var(--color-text);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.estimate-learn-item p + p {
  margin-top: var(--space-2);
}

.estimate-learn-link {
  display: inline-flex;
  margin-top: var(--space-3);
  color: var(--color-primary);
  font-weight: var(--font-semibold);
  text-decoration: none;
}

.estimate-learn-link:hover {
  text-decoration: underline;
}

.estimate-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

.wizard-enabled .estimate-fieldset > legend {
  display: block;
  margin-bottom: var(--space-4);
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  color: var(--color-text-heading);
}

.estimate-checkbox-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

.estimate-checkbox-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-3);
  align-items: start;
  min-height: 44px;
  padding: var(--space-4);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
}

.estimate-checkbox-card input {
  margin-top: var(--space-1);
  accent-color: var(--color-primary);
}

.estimate-checkbox-card span {
  color: var(--color-text-heading);
  font-weight: var(--font-semibold);
}

.estimate-checkbox-card small {
  grid-column: 2;
  color: var(--color-text-light);
  line-height: var(--leading-normal);
}

.estimate-checkbox-card:focus-within {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.estimate-inline-button {
  margin-top: var(--space-3);
  min-height: 44px;
}

.estimate-field-error {
  min-height: 1.4em;
  margin-top: var(--space-2);
  color: var(--color-emergency);
  font-size: var(--text-sm);
}

.estimate-framing {
  max-width: 760px;
  margin: var(--space-3) auto 0;
  color: var(--color-text);
}

.estimate-confidence {
  max-width: 560px;
  margin: var(--space-5) auto 0;
  padding: var(--space-4);
  text-align: left;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
}

.estimate-confidence[hidden] {
  display: none !important;
}

.estimate-confidence-head {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  justify-content: space-between;
  color: var(--color-text-heading);
  font-weight: var(--font-semibold);
}

.estimate-confidence-head strong {
  color: var(--color-primary);
  font-size: var(--text-lg);
  white-space: nowrap;
}

.estimate-confidence-track {
  height: 10px;
  margin-top: var(--space-3);
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
}

.estimate-confidence-bar {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-accent-metal), var(--color-primary));
}

.estimate-confidence p {
  margin: var(--space-2) 0 0;
  color: var(--color-text-light);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.estimate-tier-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

.estimate-tier-card,
.estimate-plan-card,
.estimate-note-card,
.estimate-wide-result {
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.estimate-tier-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  border-top: 3px solid var(--color-border);
}

.estimate-tier-card.is-featured {
  border-color: var(--color-primary);
  border-top-color: var(--color-accent-metal);
  box-shadow: var(--shadow-lg);
}

.estimate-tier-kicker {
  width: fit-content;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--color-primary-tint);
  color: var(--color-primary-text);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}

.estimate-tier-card h3,
.estimate-lead-card h3,
.estimate-subhead,
.estimate-plan-card h4 {
  margin: 0;
  color: var(--color-text-heading);
}

.estimate-tier-card p,
.estimate-note-card p,
.estimate-wide-result p,
.estimate-plan-card p,
.estimate-lead-card p {
  margin: 0;
  color: var(--color-text);
  line-height: var(--leading-relaxed);
}

.estimate-price-range {
  color: var(--color-primary);
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.estimate-monthly {
  color: var(--color-text-heading);
  font-weight: var(--font-semibold);
  font-variant-numeric: tabular-nums;
}

.estimate-tier-card ul {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-5);
  color: var(--color-text);
}

.estimate-tier-card li + li {
  margin-top: var(--space-1);
}

.estimate-details {
  margin-top: var(--space-6);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
}

.estimate-details summary {
  cursor: pointer;
  color: var(--color-text-heading);
  font-weight: var(--font-semibold);
}

.estimate-driver-list {
  margin: var(--space-3) 0 0;
  padding-left: var(--space-5);
  color: var(--color-text);
}

.estimate-driver-list li + li {
  margin-top: var(--space-2);
}

.estimate-result-actions,
.estimate-lead-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-5);
}

.estimate-copy-status,
.estimate-lead-status,
.estimate-footnote,
.estimate-photo-note {
  color: var(--color-text-light);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.estimate-copy-status,
.estimate-lead-status {
  min-height: 1.4em;
  margin-top: var(--space-2);
}

.estimate-footnote {
  margin-top: var(--space-4);
}

.estimate-repair-grid,
.estimate-plan-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

.estimate-repair-grid .result-detail-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.estimate-repair-grid .result-detail-item p {
  margin: 0;
  color: var(--color-text);
  line-height: var(--leading-normal);
}

.estimate-subhead {
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
}

.estimate-plan-card strong,
.estimate-wide-result span {
  display: block;
  margin: var(--space-2) 0;
  color: var(--color-primary);
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  font-variant-numeric: tabular-nums;
}

.estimate-commercial-result strong,
.estimate-wide-result strong {
  display: block;
  color: var(--color-text-heading);
  font-size: var(--text-xl);
}

.estimate-commercial-fee {
  margin-top: var(--space-4) !important;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  font-weight: var(--font-medium);
}

.estimate-lead-card {
  margin-top: var(--space-8);
  padding: var(--space-6);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-accent-metal);
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
}

.estimate-lead-card form {
  margin-top: var(--space-5);
}

.estimate-contact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

.estimate-lead-actions .btn-primary,
.estimate-lead-actions .btn-secondary,
.estimate-result-actions .btn-secondary {
  min-height: 44px;
}

.estimate-page .hp-field {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.estimate-photo-note {
  margin-top: var(--space-4);
}

@media (min-width: 560px) {
  .estimate-checkbox-grid,
  .estimate-repair-grid,
  .estimate-plan-grid,
  .estimate-contact-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .estimate-count-choices {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 840px) {
  .estimate-tier-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .estimate-learn-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .estimate-opening-choices,
  .estimate-building-choices {
    grid-template-columns: repeat(4, 1fr);
  }

  .estimate-system-choices {
    grid-template-columns: repeat(3, 1fr);
  }

  .estimate-contact-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 559px) {
  .estimate-reference-photo,
  .estimate-learn-item {
    grid-template-columns: 1fr;
  }

  .estimate-reference-photo-media {
    max-width: 168px;
  }

  .estimate-confidence-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .estimate-result-actions,
  .estimate-lead-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .estimate-result-actions .btn-secondary,
  .estimate-lead-actions .btn-primary,
  .estimate-lead-actions .btn-secondary {
    width: 100%;
    text-align: center;
  }

  .estimate-price-range {
    font-size: var(--text-2xl);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .estimate-page .wizard-progress-bar {
    transition: width 260ms ease-out;
  }

  .estimate-page .wizard-enabled .wizard-step.is-active {
    animation: estimateStepIn 240ms ease-out both;
  }

  .estimate-page .wizard-choice {
    transition: border-color 180ms ease-out, box-shadow 180ms ease-out, transform 180ms ease-out, background-color 180ms ease-out;
  }

  .estimate-page .wizard-choice::after,
  .estimate-page .wizard-choice::before {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease-out, transform 180ms ease-out;
  }

  .estimate-page .wizard-choice::after {
    content: "";
    top: var(--space-3);
    right: var(--space-3);
    width: 22px;
    height: 22px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-surface);
    transform: scale(0.72);
  }

  .estimate-page .wizard-choice::before {
    content: "";
    z-index: 1;
    top: calc(var(--space-3) + 6px);
    right: calc(var(--space-3) + 5px);
    width: 10px;
    height: 6px;
    border-bottom: 2px solid var(--color-text-on-dark);
    border-left: 2px solid var(--color-text-on-dark);
    transform: rotate(-45deg) scale(0.72);
  }

  .estimate-page .wizard-choice:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
  }

  .estimate-page .wizard-choice.is-selected::after {
    opacity: 1;
    transform: scale(1);
  }

  .estimate-page .wizard-choice.is-selected::before {
    opacity: 1;
    transform: rotate(-45deg) scale(1);
  }

  .estimate-page .estimate-results.active {
    animation: estimateResultsIn 260ms ease-out both;
  }

  .estimate-page .estimate-results.active .estimate-tier-card {
    opacity: 0;
    animation: estimateTierIn 260ms ease-out both;
  }

  .estimate-page .estimate-results.active .estimate-tier-card:nth-child(2) {
    animation-delay: 60ms;
  }

  .estimate-page .estimate-results.active .estimate-tier-card:nth-child(3) {
    animation-delay: 120ms;
  }

  .estimate-page .estimate-results.active .estimate-confidence-bar {
    transition: width 520ms ease-out;
  }
}

@keyframes estimateStepIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes estimateResultsIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes estimateTierIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .estimate-page .wizard-progress-bar,
  .estimate-page .wizard-enabled .wizard-step.is-active,
  .estimate-page .wizard-choice,
  .estimate-page .wizard-choice::before,
  .estimate-page .wizard-choice::after,
  .estimate-page .estimate-results.active,
  .estimate-page .estimate-tier-card,
  .estimate-page .estimate-confidence-bar {
    animation: none !important;
    transition: none !important;
  }

  .estimate-page .wizard-choice:hover {
    transform: none;
  }
}
