/* ---- Variables (primary blue #312e8e) ---- */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #5a5a72; 
  --accent: #312e8e;
  --accent-hover: #27257a;
  --success: #312e8e;
  --success-bg: #e8e8f4;
  --locked: #8b95a5;
  --locked-bg: #eef0f4;
  --line: #dde1e6;
  --line-done: #312e8e;
  --shadow: 0 4px 20px rgba(49, 46, 142, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

/* ---- Animations ---- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes headerFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes progressShine {
  0% { opacity: 1; }
  50% { opacity: 0.7; box-shadow: 0 0 12px rgba(49, 46, 142, 0.4); }
  100% { opacity: 1; box-shadow: none; }
}

@keyframes unlockPop {
  0% { transform: scale(0.92); opacity: 0.6; }
  60% { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes iconBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

@keyframes completePulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(49, 46, 142, 0.08); }
  50% { box-shadow: 0 0 0 4px rgba(49, 46, 142, 0.25), 0 4px 24px rgba(49, 46, 142, 0.15); }
}

@keyframes stepDone {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

@keyframes lockFadeOut {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.8); }
}

@keyframes doneMessagePop {
  0% { opacity: 0; transform: scale(0.6); }
  70% { opacity: 1; transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}

/* ---- Base ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  position: relative;
}

/* Full-page background image (keeps content readable with an overlay) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('mortgage-timeline.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: -2;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(245, 246, 248, 0.82);
  z-index: -1;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

/* ---- Header ---- */
.header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.header-logo {
  display: block;
  max-width: 220px;
  height: auto;
  margin: 0 auto 1rem;
}

.header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 400;
  color: var(--text);
  margin: 0 0 0.35em;
  animation: headerFadeIn 0.6s ease-out forwards;
}

.subtitle {
  color: var(--text-muted);
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  opacity: 0;
  animation: headerFadeIn 0.5s ease-out 0.15s forwards;
}

.progress-bar {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--success), #4542a8);
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.progress-fill.progress-fill--updated {
  animation: progressShine 0.6s ease-out;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  transition: transform 0.2s ease;
}

.progress-text.progress-text--updated {
  transform: scale(1.05);
}

/* ---- Timeline ---- */
.timeline-wrap {
  position: relative;
}

.timeline-line {
  position: absolute;
  left: 23px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--line);
  border-radius: 2px;
  z-index: 0;
}

.timeline-line::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 0;
  background: var(--line-done);
  border-radius: 2px;
  transition: height 0.5s ease;
}

/* ---- Module ---- */
.module {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  opacity: 0;
  animation: fadeInUp 0.5s ease-out forwards;
}

.module:nth-child(2) { animation-delay: 0.05s; }
.module:nth-child(3) { animation-delay: 0.14s; }
.module:nth-child(4) { animation-delay: 0.23s; }
.module:nth-child(5) { animation-delay: 0.32s; }

.module:last-child {
  margin-bottom: 0;
}

.module.module--just-unlocked .module-card {
  animation: unlockPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.module.module--just-unlocked .module-icon {
  animation: iconBounce 0.5s ease-out forwards;
}

.module.module--just-unlocked .lock-badge {
  animation: lockFadeOut 0.3s ease-out forwards;
  pointer-events: none;
}

.module.module--just-completed .module-card {
  animation: completePulse 0.8s ease-out forwards;
}

.module.module--just-completed .module-icon {
  animation: iconBounce 0.4s ease-out forwards;
}

.module-marker {
  flex-shrink: 0;
  position: relative;
}

.module-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: var(--shadow);
  transition: background 0.3s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.module:not(.locked):hover .module-icon {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(49, 46, 142, 0.35);
}

.module:not(.locked) .module-icon {
  cursor: default;
}

.module.locked .module-icon {
  background: var(--locked);
  color: var(--bg);
}

.module.completed .module-icon {
  background: var(--success);
  color: white;
}

.lock-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--locked);
  background: var(--card);
  padding: 2px 6px;
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.module:not(.locked) .lock-badge {
  display: none;
}

/* ---- Module card ---- */
.module-card {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid transparent;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

.module:not(.locked):hover .module-card {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(49, 46, 142, 0.12);
}

.module:not(.locked) .module-card {
  border-color: rgba(49, 46, 142, 0.25);
}

.module.completed .module-card {
  border-color: rgba(49, 46, 142, 0.25);
  background: linear-gradient(to bottom, var(--success-bg), var(--card));
}

.module.locked .module-card {
  background: var(--locked-bg);
  opacity: 0.92;
}

.module-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0 0 0.35em;
}

.module-title-row h2 {
  margin: 0;
  flex: 1 1 12rem;
  min-width: 0;
}

.lottie-phase-title-complete {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  pointer-events: none;
  position: relative;
}

.lottie-phase-title-complete svg {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.module-card h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.35rem;
  font-weight: 400;
  margin: 0 0 0.35em;
  color: var(--text);
}

.module.locked .module-card h2 {
  color: var(--text-muted);
}

.module-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

/* ---- Steps ---- */
.steps {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
}

.step {
  position: relative;
  margin-bottom: 0.5rem;
}

.step:last-child {
  margin-bottom: 0;
}

.step label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.4rem 0;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.module.locked .step label {
  cursor: not-allowed;
  color: var(--text-muted);
}

.step label:hover:not(.step--done label) {
  background: rgba(0, 0, 0, 0.03);
}

.module.locked .step label:hover {
  background: transparent;
}

.step input[type="checkbox"] {
  width: 1.2em;
  height: 1.2em;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.module.locked .step input[type="checkbox"] {
  cursor: not-allowed;
}

.step.step--done label {
  color: var(--text-muted);
  text-decoration: line-through;
}

.step.step--done.step--just-done label {
  animation: stepDone 0.35s ease-out;
}

.step-details {
  margin-top: 0.5rem;
  margin-left: 1.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.step-details summary {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

/* Ensure injected icons always have a visible layout spot inside the summary. */
#homesteadDetails > summary,
#homeInspectionDetails > summary,
#appraisalDetails > summary,
#insuranceDetails > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

.step-details summary::-webkit-details-marker {
  display: none;
}

.step-details summary::before {
  content: '▶ ';
  font-size: 0.7em;
  transition: transform 0.2s ease;
}

.step-details[open] summary::before {
  transform: rotate(90deg);
}

.step-details-content {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.step-details-content p {
  margin: 0 0 0.5rem;
}

.step-details-content p:last-child,
.step-details-content ul:last-child,
.step-details-content ol:last-child {
  margin-bottom: 0;
}

.step-details-content ul,
.step-details-content ol {
  margin: 0.5rem 0 0.75rem 1.25rem;
  padding: 0;
}

.step-details-content li {
  margin-bottom: 0.35rem;
}

.step-details-content a {
  color: var(--accent);
  text-decoration: none;
}

.step-details-content a:hover {
  text-decoration: underline;
}

/* Step details with hero illustration (credit card, house listing, etc.) */
.step-details-highlight {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.step-details-figure {
  margin: 0;
  flex-shrink: 0;
  line-height: 0;
}

.step-details-illustration {
  display: block;
  width: 64px;
  height: auto;
  max-width: 100%;
}

.step-details-illustration--wide {
  width: 64px;
  max-width: min(100%, 64px);
}

.step-details-illustration--svg-small {
  width: 64px;
  max-width: min(100%, 64px);
}

.step-details-copy {
  flex: 1;
  min-width: 0;
}

@keyframes stepDetailsIllustrationPop {
  0% {
    transform: scale(0.92);
    opacity: 0.65;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.step-details-illustration.step-details-illustration--pop {
  animation: stepDetailsIllustrationPop 0.45s ease-out;
}

@media (max-width: 520px) {
  .step-details-highlight {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

.step-table {
  width: 100%;
  margin: 0.5rem 0 0.75rem;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.step-table th,
.step-table td {
  padding: 0.35rem 0.5rem;
  text-align: left;
  border: 1px solid var(--line);
}

.step-table th {
  background: var(--locked-bg);
  font-weight: 600;
}

.module-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.module.completed .module-status[data-status] {
  color: green;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(49, 46, 142, 0.25);
  background: rgba(232, 232, 244, 0.85);
  box-shadow: 0 6px 16px rgba(49, 46, 142, 0.12);
}

.module.completed .module-status[data-status]::before {
  content: '✓';
  display: inline-block;
  font-weight: 900;
  line-height: 1;
  font-size: 1.15em;
}

/* ---- Progress line fill (done segments) ---- */
.module.completed .module-marker::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 48px;
  bottom: -1.5rem;
  width: 3px;
  margin-left: -1.5px;
  background: var(--line-done);
  z-index: -1;
}

.module:last-child.completed .module-marker::after {
  display: none;
}

/* ---- Modal ---- */
.modal-backdrop[aria-hidden="true"] {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(10, 12, 16, 0.55);
  backdrop-filter: blur(2px);
}

.modal {
  width: min(520px, 100%);
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25);
  padding: 1.1rem 1.1rem 1rem;
}

.modal-title {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
  color: var(--text);
}

.modal-body {
  margin: 0 0 0.9rem;
  color: var(--text-muted);
}

.modal-embed {
  margin: 0 0 0.95rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  min-height: 0;
}

.modal-embed:empty {
  display: none;
}

.modal-embed iframe,
.modal-embed embed,
.modal-embed object {
  display: block;
  width: 100%;
  height: min(52vh, 420px);
  border: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.btn-primary {
  border: 0;
  border-radius: 999px;
  padding: 0.6rem 0.95rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(90deg, var(--success), #26a84f);
  box-shadow: 0 10px 24px rgba(27, 122, 58, 0.22);
}

.btn-primary:hover {
  filter: brightness(1.02);
}

/* ---- Footer ---- */
.footer {
  text-align: center;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.btn-reset {
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease, transform 0.2s ease;
}

.btn-reset:hover {
  color: var(--text);
  border-color: var(--locked);
  background: var(--locked-bg);
  transform: translateY(-1px);
}

.btn-reset:active {
  transform: translateY(0);
}

/* ---- Timeline done message ---- */
.timeline-done-message {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.8);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

.timeline-done-message.show {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  animation: doneMessagePop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.timeline-done-lottie,
.lottie-done-message {
  position: relative;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
  min-width: 100px;
  min-height: 100px;
}

.timeline-done-title {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 400;
  color: var(--success);
  margin: 0;
}

.app.timeline-finished .timeline-wrap {
  pointer-events: none;
  position: relative;
}

.app.timeline-finished .timeline-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(245, 246, 248, 0.75);
  pointer-events: auto;
}

/* ---- Lottie containers ---- */
.lottie-container {
  pointer-events: none;
  position: absolute;
  z-index: 10;
}

.timeline-done-message .lottie-container.lottie-done-message {
  position: relative;
}

.lottie-step-done {
  width: 28px;
  height: 28px;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.lottie-module-complete {
  width: 80px;
  height: 80px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.module-card {
  position: relative;
}

.lottie-unlock {
  width: 56px;
  height: 56px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.lottie-car {
  width: 80px;
  height: 80px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.lottie-key,
.homestead-key-icon,
.inspection-search-icon,
.appraisal-icon,
.insurance-icon {
  width: 32px;
  height: 32px;
  display: inline-block;
  position: relative;
  vertical-align: middle;
  margin-left: 8px;
}

/* Animation should set these, but keep them explicit so the icon never "disappears". */
#homesteadDetails .homestead-key-icon,
#homeInspectionDetails .inspection-search-icon,
#appraisalDetails .appraisal-icon,
#insuranceDetails .insurance-icon {
  opacity: 1;
  z-index: 20;
  flex: 0 0 auto;
}

.homestead-key-icon__img,
.inspection-search-icon__img,
.appraisal-icon__img,
.insurance-icon__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

@keyframes homesteadKeyEntrance {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

#homesteadDetails .lottie-key.lottie-key--entrance,
#homeInspectionDetails .inspection-search-icon.inspection-search-icon--entrance {
  animation: homesteadKeyEntrance 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#appraisalDetails .appraisal-icon.appraisal-icon--entrance {
  animation: homesteadKeyEntrance 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#insuranceDetails .insurance-icon.insurance-icon--entrance {
  animation: homesteadKeyEntrance 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.module-marker {
  position: relative;
}
