/* Guided estimate presentation layer. Pricing, availability, and submission
   behavior remain owned by app.js and the existing estimate helpers. */

.estimate-page--guided {
  --clean-serif: "Fraunces", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --clean-sans: "DM Sans", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --guided-rail-width: 19.5rem;
  --guided-mobile-bar-h: 3.75rem;
  padding-bottom: calc(var(--guided-mobile-bar-h) + 1.5rem);
  font-family: var(--clean-sans);
}

.estimate-page--guided .hero h1,
.estimate-page--guided h2,
.estimate-page--guided h3,
.estimate-page--guided .estimate-nav__brand strong,
.estimate-page--guided .estimate-nav__brand small,
.estimate-page--guided .guided-summary-rail__amount,
.estimate-page--guided .guided-mobile-summary__amount {
  font-family: var(--clean-serif);
}

/* Compact opening keeps the first customer decision above the fold. */
.estimate-page--guided .estimate-hero--compact {
  padding: 0.85rem 1rem 3.25rem;
}

.estimate-page--guided .estimate-hero__inner--compact {
  display: block;
  max-width: 1120px;
}

.estimate-page--guided .estimate-hero--compact h1 {
  max-width: 18ch;
  font-size: clamp(1.85rem, 5.2vw, 2.85rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.estimate-page--guided .estimate-hero__lead-compact {
  max-width: 38rem;
  margin: 0.55rem 0 0;
  color: rgba(199, 216, 213, 0.88);
  font-size: clamp(0.92rem, 1.6vw, 1.05rem);
  line-height: 1.5;
}

.estimate-page--guided .estimate-hero--compact .estimate-hero__trust {
  gap: 0.4rem;
  margin-top: 0.85rem;
}

.estimate-page--guided .estimate-hero--compact .estimate-hero__trust span {
  padding: 0.38rem 0.7rem;
  font-size: 0.68rem;
}

.estimate-page--guided .estimate-nav {
  min-height: 64px;
}

.estimate-page--guided .estimate-nav__brand img {
  width: 58px;
  height: 58px;
  min-width: 58px;
  border-width: 4px;
}

.estimate-page--guided .estimate-nav__brand strong {
  font-size: 1.05rem;
}

.estimate-page--guided .estimate-nav__brand small {
  font-size: 0.62rem;
}

/* Guided workspace and stage chrome. */
.estimate-page--guided .guided-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 1.25rem;
  max-width: 1180px;
  margin-top: -1.6rem;
  margin-bottom: 2.5rem;
}

.estimate-page--guided .guided-main {
  min-width: 0;
}

.estimate-page--guided .estimate-card-shell {
  padding: clamp(1rem, 2.5vw, 1.55rem);
}

.estimate-page--guided .guided-stage-meta {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.95rem;
  border-bottom: 1px solid var(--line);
}

.estimate-page--guided .guided-stage-meta .section-kicker {
  margin: 0;
}

.guided-progress-trail {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.guided-progress-trail li {
  position: relative;
  display: flex;
}

.guided-progress-trail li + li::before {
  content: "";
  position: absolute;
  top: 50%;
  right: calc(100% + 0.05rem);
  width: 0.35rem;
  height: 2px;
  background: color-mix(in srgb, var(--line) 80%, transparent);
  transform: translateY(-50%);
  pointer-events: none;
}

.guided-progress-trail li:has(.is-complete) + li::before,
.guided-progress-trail li:has(.is-active) + li::before {
  background: color-mix(in srgb, var(--clean-green) 55%, var(--line));
}

.guided-progress-dot {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
  font-family: var(--clean-sans);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 180ms cubic-bezier(0.22, 1, 0.36, 1),
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease;
}

.guided-progress-dot.is-complete {
  border-color: color-mix(in srgb, var(--clean-green) 65%, var(--line));
  background: color-mix(in srgb, var(--clean-green) 22%, var(--surface-3));
  color: var(--text);
}

.guided-progress-dot.is-active {
  border-color: var(--clean-wine);
  background: var(--clean-wine);
  color: #edf5f4;
  box-shadow: 0 8px 18px rgba(124, 36, 41, 0.28);
  transform: scale(1.06);
}

.guided-progress-dot:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.guided-progress-dot:not(:disabled):hover {
  transform: translateY(-1px);
}

.guided-progress-dot:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

/* app.js owns [hidden] as the eligibility source. This class only selects
   which eligible stage is currently presented. */
.estimate-page--guided .flow-step:not([hidden]):not(.is-guided-active),
.estimate-page--guided .customer-info:not([hidden]):not(.is-guided-active),
.estimate-page--guided .slots-wrap:not([hidden]):not(.is-guided-active) {
  display: none !important;
}

.estimate-page--guided .flow-step.is-guided-active,
.estimate-page--guided .customer-info.is-guided-active,
.estimate-page--guided .slots-wrap.is-guided-active {
  display: grid;
  margin-top: 0;
  animation: guidedStageIn 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

.estimate-page--guided .guided-estimate-source {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  pointer-events: none !important;
}

.estimate-page--guided .guided-legacy-continue {
  display: none !important;
}

/* Back/continue controls deliberately stay compact on wide screens. */
.guided-nav {
  display: grid;
  grid-template-columns: auto minmax(10rem, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.guided-nav__back,
.guided-nav__continue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 7.5rem;
  min-height: 48px;
  margin: 0;
  padding: 0.7rem 1.15rem;
  border-radius: 2px;
  font-family: var(--clean-sans);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.guided-nav__back {
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--text);
}

.guided-nav__back:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
  transform: translateY(-1px);
}

.guided-nav__back:disabled,
.guided-nav__continue:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.guided-nav__continue {
  border: 1px solid var(--clean-wine);
  background: var(--clean-wine);
  color: #fff8f3;
  box-shadow: 0 8px 22px rgba(124, 36, 41, 0.24);
}

.guided-nav__continue:hover:not(:disabled) {
  background: color-mix(in srgb, var(--clean-wine) 88%, #000);
  box-shadow: 0 12px 28px rgba(124, 36, 41, 0.34);
  transform: translateY(-1px);
}

.guided-nav__continue:focus-visible,
.guided-nav__back:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--clean-wine) 70%, #fff);
  outline-offset: 3px;
}

.guided-nav__hint {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: center;
}

.guided-nav.is-final-stage .guided-nav__continue {
  display: none;
}

.guided-nav.is-final-stage {
  grid-template-columns: auto 1fr;
}

.estimate-page--guided.guided-complete-mode .guided-nav,
.estimate-page--guided.guided-complete-mode .guided-mobile-summary,
.estimate-page--guided.guided-complete-mode .guided-summary-rail {
  display: none !important;
}

.guided-review-strip {
  margin-top: 0.25rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: color-mix(in srgb, var(--brand) 6%, var(--surface-3));
}

.guided-review-strip__title {
  margin: 0 0 0.45rem;
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.guided-review-strip__list {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  color: var(--text);
  font-size: 0.88rem;
  list-style: none;
}

.guided-review-strip__list li {
  display: flex;
  gap: 0.45rem;
  line-height: 1.4;
}

.guided-review-strip__list li::before {
  content: "✓";
  color: var(--clean-green);
  font-weight: 800;
}

/* Desktop summary rail. */
.guided-summary-rail {
  display: none;
}

.guided-summary-rail__inner {
  position: sticky;
  top: 1rem;
  padding: 1.15rem 1.1rem 1.25rem;
  border: 2px solid var(--clean-border);
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent 6rem),
    var(--card);
  box-shadow: var(--shadow-soft);
}

:root[data-theme="dark"] .guided-summary-rail__inner {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 6rem),
    var(--card);
}

.guided-summary-rail__eyebrow {
  margin: 0 0 0.65rem;
  color: var(--kicker);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.guided-summary-rail__progress {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.guided-summary-rail__progress span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.guided-summary-rail__bar {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 18%, var(--surface-3));
}

.guided-summary-rail__bar i {
  display: block;
  width: 16.66%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--clean-green), color-mix(in srgb, var(--clean-green) 60%, var(--clean-wine)));
  transition: width 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.guided-summary-rail__amount-wrap {
  display: grid;
  gap: 0.2rem;
  margin-bottom: 0.45rem;
}

.guided-summary-rail__amount-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.guided-summary-rail__amount {
  color: var(--text);
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.guided-summary-rail__breakdown,
.guided-summary-rail__hint {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  line-height: 1.45;
}

.guided-summary-selections {
  display: grid;
  gap: 0.55rem;
  margin: 1rem 0 0;
  padding: 0.85rem 0 0;
  border-top: 1px solid var(--line);
}

.guided-summary-selections > div {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  align-items: start;
  gap: 0.45rem;
}

.guided-summary-selections dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.guided-summary-selections dd {
  margin: 0;
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.guided-summary-rail__promise {
  margin: 1rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

/* Mobile summary behaves as a proper modal sheet when expanded. */
.guided-mobile-summary {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  padding: 0.55rem 0.75rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  box-shadow: 0 -10px 30px rgba(3, 18, 23, 0.12);
  backdrop-filter: blur(14px);
}

.estimate-page--guided.guided-sheet-open {
  overflow: hidden;
}

.guided-mobile-summary__bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 48px;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface-3);
  color: var(--text);
  font-family: var(--clean-sans);
  text-align: left;
  cursor: pointer;
}

.guided-mobile-summary__bar:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.guided-mobile-summary__step {
  flex: 0 0 auto;
  min-width: 2.75rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.guided-mobile-summary__amount {
  flex: 1 1 auto;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.2;
}

.guided-mobile-summary__chevron {
  color: var(--muted);
  font-size: 0.85rem;
  transition: transform 180ms ease;
}

.guided-mobile-summary.is-open .guided-mobile-summary__chevron {
  transform: rotate(180deg);
}

.guided-mobile-sheet {
  position: fixed;
  right: 0.5rem;
  bottom: calc(var(--guided-mobile-bar-h) + env(safe-area-inset-bottom, 0px) + 0.35rem);
  left: 0.5rem;
  z-index: 45;
  max-height: min(70vh, 28rem);
  overflow: auto;
  padding: 1rem 1.05rem 1.15rem;
  border: 2px solid var(--clean-border);
  border-radius: 4px 4px 2px 2px;
  background: var(--card);
  box-shadow: 0 18px 50px rgba(3, 18, 23, 0.28);
  animation: guidedSheetIn 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

.guided-mobile-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(3, 18, 23, 0.42);
}

.guided-mobile-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.guided-mobile-sheet__head strong {
  font-family: var(--clean-serif);
  font-size: 1.15rem;
}

.guided-mobile-sheet__close {
  width: auto;
  min-width: 44px;
  min-height: 44px;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface-3);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.guided-mobile-sheet__breakdown,
.guided-mobile-sheet__hint {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  line-height: 1.45;
}

.estimate-page--guided label > select,
.estimate-page--guided label > input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
.estimate-page--guided label > textarea,
.estimate-page--guided .estimate-select__trigger,
.estimate-page--guided .addon-option,
.estimate-page--guided .slot-option,
.estimate-page--guided .day-btn,
.estimate-page--guided .estimate-submit,
.estimate-page--guided .icon-btn {
  min-height: 44px;
}

.estimate-page--guided .estimate-submit {
  min-height: 52px;
  font-family: var(--clean-sans);
  font-weight: 800;
}

.estimate-page--guided .estimate-in-person-callout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.75rem;
  max-width: 44rem;
  margin-top: 0.9rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(166, 190, 188, 0.42);
  border-radius: 4px;
  background: linear-gradient(120deg, rgba(51, 103, 106, 0.32), rgba(18, 48, 45, 0.82));
  color: #edf5f4;
  box-shadow: inset 4px 0 0 rgba(90, 145, 140, 0.82);
}

.estimate-page--guided .estimate-in-person-callout__icon {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(237, 245, 244, 0.12);
  color: #a6d0d3;
  font-size: 1rem;
}

.estimate-page--guided .estimate-in-person-callout strong,
.estimate-page--guided .estimate-in-person-callout p {
  display: block;
  margin: 0;
}

.estimate-page--guided .estimate-in-person-callout p {
  margin-top: 0.18rem;
  color: rgba(237, 245, 244, 0.78);
  font-size: 0.84rem;
  line-height: 1.45;
}

.estimate-page--guided .estimate-in-person-callout a {
  color: #fff;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

.estimate-page--guided .form-section__head h3 {
  font-size: clamp(1.35rem, 3.2vw, 1.85rem);
  line-height: 1.12;
}

.estimate-page--guided .submission-complete {
  position: relative;
  overflow: hidden;
}

html.estimate-motion-ready:not(.estimate-motion-reduced) .estimate-page--guided .submission-complete {
  animation: guidedCompleteIn 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

html.estimate-motion-ready:not(.estimate-motion-reduced) .estimate-page--guided .submission-complete::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--clean-green), var(--clean-wine), var(--clean-green));
  background-size: 200% 100%;
  animation: guidedCompleteBar 1.4s ease both;
}

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

@keyframes guidedCompleteBar {
  from { background-position: 100% 0; opacity: 0; }
  20% { opacity: 1; }
  to { background-position: 0 0; opacity: 1; }
}

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

#homeSizeHint.guided-validation-pulse {
  color: var(--danger-text);
  font-weight: 700;
  animation: guidedHintPulse 700ms ease;
}

@keyframes guidedHintPulse {
  0%, 100% { transform: none; }
  40% { transform: translateX(3px); }
  70% { transform: translateX(-2px); }
}

@media (min-width: 960px) {
  .estimate-page--guided {
    padding-bottom: 0;
  }

  .estimate-page--guided .guided-layout {
    grid-template-columns: minmax(0, 1fr) var(--guided-rail-width);
    gap: 1.35rem;
  }

  .guided-summary-rail {
    display: block;
  }

  .guided-mobile-summary,
  .guided-mobile-sheet,
  .guided-mobile-sheet-backdrop {
    display: none !important;
  }
}

@media (min-width: 1200px) {
  .estimate-page--guided .guided-layout {
    --guided-rail-width: 21rem;
  }
}

@media (max-width: 640px) {
  .estimate-page--guided .estimate-nav {
    width: min(100% - 1rem, 1120px);
  }

  .estimate-page--guided .estimate-hero--compact {
    padding: 0.55rem 0.85rem 2.75rem;
  }

  .guided-nav {
    grid-template-columns: 1fr 1fr;
  }

  .guided-nav__back,
  .guided-nav__continue {
    width: 100%;
    min-width: 0;
  }

  .guided-nav__hint {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .guided-nav.is-final-stage {
    grid-template-columns: 1fr;
  }

  .guided-progress-dot {
    width: 2.35rem;
    height: 2.35rem;
    min-width: 2.35rem;
    min-height: 2.35rem;
  }

  /* Compact assurances into one easy-to-scan three-row panel on phones. */
  .estimate-page--guided .estimate-assurance article {
    grid-template-columns: 2.15rem minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 0.7rem;
    row-gap: 0.12rem;
    padding: 0.78rem 0.85rem;
  }

  .estimate-page--guided .estimate-assurance__icon {
    display: inline-grid;
    grid-row: 1 / 3;
    place-items: center;
    width: 2.15rem;
    height: 2.15rem;
    margin: 0;
    border: 1px solid color-mix(in srgb, var(--clean-green) 45%, var(--line));
    border-radius: 50%;
    background: color-mix(in srgb, var(--clean-green) 14%, var(--surface-3));
    font-size: 0.68rem;
    letter-spacing: 0.04em;
  }

  .estimate-page--guided .estimate-assurance__title {
    grid-column: 2;
    margin: 0;
    font-size: 0.96rem;
    line-height: 1.18;
  }

  .estimate-page--guided .estimate-assurance p {
    grid-column: 2;
    max-width: none;
    font-size: 0.76rem;
    line-height: 1.4;
  }
}

@media (prefers-reduced-motion: reduce) {
  .estimate-page--guided .flow-step.is-guided-active,
  .estimate-page--guided .customer-info.is-guided-active,
  .estimate-page--guided .slots-wrap.is-guided-active,
  .guided-mobile-sheet,
  #homeSizeHint.guided-validation-pulse {
    animation: none;
  }
}
