/* Onboarding Wizard Styles */

/* Modal Container - using established dialog patterns */
.onboarding-modal {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 640px;
  height: 90vh;
  max-height: 800px;
  margin: auto;
  padding: 0;
  border: 1px solid var(--color-border-darker);
  border-radius: var(--fieldset-border-radius, 1em);
  background: var(--color-bg);
  box-shadow: 0 0 1em oklch(var(--lch-black) / 0.2);
  overflow: hidden;
}

.onboarding-modal::backdrop {
  background: oklch(var(--lch-black) / 0.5);
  backdrop-filter: blur(4px);
}

/* Modal inner container - fill dialog height */
.onboarding-modal__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Modal header with progress indicator */
.onboarding-modal__header {
  border-block-end: 1px solid var(--color-border);
}

.onboarding-modal__header h2 {
  margin-block-start: var(--block-space-half);
}

.onboarding-modal__header-row {
  align-items: end;
  margin-block-end: var(--block-space-half);
  min-height: var(--btn-size);
}

/* Business context indicator below step title */
.wizard-business-context {
  align-items: center;
  color: var(--color-text-subtle);
  display: flex;
  font-size: 0.8rem;
  gap: 0.4em;
  margin-block-start: 0.25em;
}

.wizard-business-context form {
  align-items: center;
  display: flex;
  gap: 0.4em;
}

.wizard-business-context__select {
  appearance: none;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: inherit;
  cursor: pointer;
  font: inherit;
  outline: none !important;
  padding: 0;
}

.wizard-business-context__name {
  font-weight: 500;
}

/* Modal footer with actions */
.onboarding-modal__footer {
  border-block-start: 1px solid var(--color-border-darker);
}

/* Progress bar in modal header */
.onboarding-modal__progress {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
}

.onboarding-modal__progress-bar {
  height: 100%;
  background: var(--color-text);
  border-radius: 2px;
  transition: width 300ms ease;
}

/* Scrollable content area - hide scrollbar but maintain scroll */
.onboarding-modal main {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
  outline: none;
  /* Responsive X-axis padding - larger on desktop, smaller on mobile */
  padding-inline: clamp(var(--inline-space), 5vw, calc(var(--inline-space) * 3));
}

@media (max-width: 640px) {
  .onboarding-modal main {
    padding-inline: var(--inline-space);
  }
}

.onboarding-modal main::-webkit-scrollbar {
  display: none; /* Chrome/Safari/Opera */
}

/* Nametag adjustments within modal */
.onboarding-modal .nametag {
  margin-block-start: var(--block-space);
  margin-block-end: var(--block-space);
  margin-inline: auto;
  max-inline-size: 50ch;
}

/* Panel adjustments within modal - keep the panel styling but adjust margins */
.onboarding-modal .panel {
  margin-block: var(--block-space);
}

/* Video container for responsive embeds */
.video-container {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  height: 0;
  overflow: hidden;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Interview step - remove padding from main for full-bleed chat */
.onboarding-modal main:has(.interview-step) {
  padding: 0;
}

/* Interview step container */
.interview-step {
  height: 100%;
}

.interview-chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Turbo frame needs to fill container */
.interview-chat-frame,
turbo-frame#interview-messages {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Interview chat - uses established patterns for messaging */
.interview-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0; /* Allow flex shrinking */
}

.interview-chat__messages {
  flex: 1;
  min-height: 0; /* Allow flex shrinking */
  overflow-y: auto !important;
  overscroll-behavior: contain;
  /* Override utility class scroll-snap which prevents programmatic scrolling */
  scroll-snap-type: none !important;
  scroll-behavior: auto !important;
  display: flex;
  flex-direction: column;
}

/* Messages container takes available space, typing indicator at bottom */
.interview-chat .interview-chat__messages > .messages {
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--block-space-half);
  /* Override messages.css grid display to use flexbox for typing indicator positioning */
  display: block !important;
}

/* Input wrapper - fixed at bottom, contains typing indicator and form */
.interview-chat__input-wrapper {
  flex: none;
  position: relative;
  background: var(--color-shade);
  border: none !important;
}

/* Typing indicator - minimal, positioned above the input form */
/* Left padding matches .message padding-inline to align with avatar */
.interview-chat__typing-indicator {
  display: none;
  padding: 0.5em var(--inline-space) 0.5em calc(var(--inline-space) + 1vw);
  background: var(--color-shade);
  border: none !important;
  /* Override composer.css absolute positioning */
  position: static !important;
  opacity: 1 !important;
  inset: auto !important;
}

.interview-chat__typing-indicator.typing-indicator--active {
  display: flex;
  align-items: center;
}

/* Animated typing dots - Campfire pattern */
.typing-indicator__dots {
  display: flex;
  gap: 0.15em;
}

.typing-indicator__dots span {
  animation: typing-dot 1.4s infinite;
  background-color: var(--color-ink-medium, #888);
  border-radius: 50%;
  block-size: 0.5em;
  inline-size: 0.5em;
}

.typing-indicator__dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator__dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-dot {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-0.3em); }
}

.interview-chat__input {
  display: flex;
  align-items: center;
  gap: var(--inline-space);
  padding: var(--block-space-half) var(--inline-space);
}

.interview-chat__input .input {
  flex: 1;
}

.interview-chat__input .btn {
  flex: none;
}

/* Hardcoded greeting shown while AI is loading */
.interview-greeting {
  padding: var(--inline-space);
}

.interview-greeting__message {
  line-height: 1.5;
}

.interview-greeting__message p {
  margin: 0;
}

.interview-greeting__message p + p {
  margin-top: 0.5em;
}

/* Simplify message display in interview context */
.interview-chat .message {
  --message-border-radius: 0.5em;
  padding: var(--block-space-half);
  /* Override messages.css which hides messages until JS runs */
  visibility: visible;
}

.interview-chat .message__day-separator {
  display: none;
}

.interview-chat .message__room {
  display: none;
}

/* Show timestamp but remove link styling */
.interview-chat .message__permalink {
  pointer-events: none;
  text-decoration: none;
  color: inherit;
}

/* Hide boosts/reactions in interview context - only RadiantBot messages here */
.interview-chat .boosts,
.interview-chat .message__boosts {
  display: none;
}

/* Interview messages - matches existing message styles */
.interview-message {
  display: flex;
  gap: var(--inline-space);
  padding: var(--block-space-half);
  margin-bottom: var(--block-space-half);
}

.interview-message--bot {
  background: var(--color-border);
  border-radius: 0.5em;
}

.interview-message--user {
  flex-direction: row-reverse;
}

.interview-message__avatar {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-text);
  color: var(--color-text-reversed);
  font-size: 0.875rem;
  font-weight: 600;
}

.interview-message__avatar-image {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.interview-message__content {
  flex: 1;
  min-width: 0;
}

.interview-message--user .interview-message__content {
  text-align: right;
}

.interview-message__body {
  line-height: 1.5;
}

.interview-message__body strong {
  font-weight: 600;
}

/* Body scroll lock when modal is open */
body.onboarding-modal-open {
  overflow: hidden;
}

/* Remove focus ring on buttons in modal - dialog auto-focuses first element */
.onboarding-modal .btn:focus-visible {
  outline: none;
}

/* Checklist items - responsive horizontal padding */
.onboarding-checklist li {
  padding-inline: var(--inline-space-double);
}

@media (max-width: 640px) {
  .onboarding-checklist li {
    padding-inline: var(--inline-space);
  }
}

/* Summary item - clickable step navigation */
.onboarding-summary__item {
  cursor: pointer;
  border: none !important;
  border-radius: 0.5em;
  box-shadow: none !important;
  transition: background-color 100ms ease;
}

.onboarding-summary__item:hover,
.onboarding-summary__item:focus,
.onboarding-summary__item:active {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.onboarding-summary__item:hover {
  background-color: var(--color-shade);
}

.onboarding-summary__item:active {
  background-color: var(--color-border);
}

/* Remove any form styling around summary items */
.onboarding-summary form {
  display: contents;
}

/* Plain button - removes all button styling for custom layouts */
.btn--plain {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: inherit;
  cursor: pointer;
}

.btn--plain:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
  border-radius: 0.25em;
}

/* Signature step - structured layout with scrollable pledge */
.signature-step {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  gap: var(--block-space);
}

.signature-step__header {
  flex: none;
}

.signature-step__pledge {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.signature-step__form {
  flex: none;
}

/* Remove padding from main when signature step is present - let step control layout */
.onboarding-modal main:has(.signature-step) {
  padding-block: var(--block-space);
}

/* Pledge text styling - ensure it's readable, not faded */
.pledge-text {
  border: 1px solid var(--color-text) !important;
  outline: none !important;
}

.signature-step__pledge {
  border: 1px solid var(--color-text) !important;
  outline: none !important;
}

.signature-step__pledge:focus,
.signature-step__pledge:focus-visible {
  outline: none !important;
  border-color: var(--color-text) !important;
}

.pledge-text strong {
  font-weight: 600;
}

/* Pledge button - clearer disabled/enabled states */
.onboarding-modal [data-signature-target="submit"]:not(:disabled) {
  /* When enabled, ensure it's clearly visible */
  opacity: 1;
  filter: none;
}

.onboarding-modal [data-signature-target="submit"]:disabled {
  /* More subtle disabled state - not as harsh */
  opacity: 0.4;
  filter: grayscale(50%);
}

/* Profile Approval - Sequential category approval UI */
.profile-approval__progress-container {
  padding: var(--block-space-half);
  background: var(--color-shade);
  border-radius: var(--fieldset-border-radius, 1em);
}

.profile-approval__progress-text {
  margin-bottom: var(--block-space-half);
}

.profile-approval__progress-bar-container {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
}

.profile-approval__progress-bar {
  height: 100%;
  background: var(--color-positive);
  border-radius: 2px;
  transition: width 300ms ease-out;
  width: 0;
}

/* Category sections */
.profile-category {
  border: none;
  border-radius: var(--fieldset-border-radius, 1em);
  overflow: hidden;
  transition: opacity 200ms ease, transform 200ms ease;
}

.profile-category[hidden] {
  display: none;
}

.profile-category--approved {
  background: oklch(var(--lch-positive) / 0.05);
}

.profile-category--approved .profile-category__footer {
  display: none;
}

.profile-category__header {
  padding: var(--block-space-half) var(--inline-space);
  background: var(--color-shade);
  border-bottom: 1px solid var(--color-border);
}

.profile-category--approved .profile-category__header {
  background: oklch(var(--lch-positive) / 0.1);
  border-bottom-color: oklch(var(--lch-positive) / 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
}

.profile-category--approved .profile-category__header:hover {
  background: oklch(var(--lch-positive) / 0.15);
}

.profile-category--approved .profile-category__header .flex {
  flex: 1;
}

.profile-category--approved .profile-category__header::after {
  content: "✓ Approved";
  font-size: var(--text-small);
  color: var(--color-positive);
  font-weight: 600;
  margin-left: auto;
}

/* Approved sections collapse by default (accordion pattern) */
.profile-category--approved .profile-category__content {
  display: none;
}

/* Expanded approved sections show content */
.profile-category--approved.profile-category--expanded .profile-category__content {
  display: block;
}

/* Chevron indicator for accordion state */
.profile-category--approved .profile-category__header::before {
  content: "›";
  font-size: 1.25em;
  color: var(--color-positive);
  margin-right: 0.5ch;
  transition: transform 150ms ease;
}

.profile-category--approved.profile-category--expanded .profile-category__header::before {
  transform: rotate(90deg);
}

.profile-category__content {
  padding: var(--block-space-half);
}

/* Remove borders from profile list items (service types, zip codes, etc.) */
.profile-category__content .fill-shade,
.onboarding-modal .fill-shade.border-radius {
  border: none;
}

.profile-category__footer {
  padding: var(--block-space-half) var(--inline-space);
  border-top: 1px solid var(--color-border);
  background: var(--color-shade);
  display: flex;
  justify-content: center;
}

.profile-category__footer .btn {
  min-width: 200px;
}

/* Pulsing glow for welcome step Continue button */
@keyframes continue-glow {
  0%, 100% { box-shadow: 0 0 0 0 oklch(var(--lch-black) / 0); }
  50% { box-shadow: 0 0 0.75em 0.35em oklch(var(--lch-blue-dark) / 0.35); }
}

.btn--glow {
  animation: continue-glow 2s ease-in-out infinite;
}

/* ==========================================================================
   MOBILE OPTIMIZATIONS (max-width: 640px)
   CRITICAL: All mobile styles are contained within this media query.
   Desktop styles are NEVER affected by anything in this section.
   ========================================================================== */

@media (max-width: 640px) {

  /* --------------------------------------------------------------------------
     MODAL CONTAINER - True Full-Screen
     -------------------------------------------------------------------------- */

  .onboarding-modal {
    width: 100vw;
    height: 100dvh;           /* Dynamic viewport height - adapts to mobile browser chrome */
    max-width: 100%;
    max-height: none;
    border-radius: 0;
    border: none;

    /* Safe area support for iPhone notch and home indicator */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .onboarding-modal__inner {
    height: 100%;
  }

  /* --------------------------------------------------------------------------
     HEADER - Compact
     -------------------------------------------------------------------------- */

  .onboarding-modal__header {
    padding: var(--block-space-half) var(--inline-space);
  }

  .onboarding-modal__header h2 {
    font-size: 1.1rem;
    line-height: 1.3;
  }

  .onboarding-modal__step-counter,
  .onboarding-modal .txt-subtle {
    font-size: 0.75rem;
  }

  /* --------------------------------------------------------------------------
     FOOTER - Safe Area + Touch-Friendly Buttons
     -------------------------------------------------------------------------- */

  .onboarding-modal__footer {
    display: flex;
    align-items: center;
    padding: var(--block-space-half) var(--inline-space);
    /* Additional padding at bottom for safe area */
    padding-bottom: calc(var(--block-space-half) + env(safe-area-inset-bottom));
    min-height: 60px;
  }

  .onboarding-modal__footer > .flex {
    flex: 1;
    flex-wrap: wrap;
    gap: var(--block-space-half);
  }

  /* Touch-friendly button sizing - 44px minimum per Apple HIG */
  .onboarding-modal__footer .btn {
    min-height: 44px;
    padding-block: 0.6em;
  }

  .onboarding-modal__footer .btn--circle {
    min-width: 44px;
    min-height: 44px;
  }

  /* Hide verbose skip messages on mobile to save space */
  .onboarding-modal__skip-message {
    display: none;
  }

  /* --------------------------------------------------------------------------
     CONTENT AREA - Flexible with Touch Scrolling
     -------------------------------------------------------------------------- */

  .onboarding-modal main {
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* --------------------------------------------------------------------------
     WELCOME STEP
     -------------------------------------------------------------------------- */

  .onboarding-modal .nametag img {
    max-height: 35vh;
    object-fit: cover;
  }

  .onboarding-modal .nametag h2,
  .onboarding-modal .welcome-headline {
    font-size: 1.4rem;
  }

  /* --------------------------------------------------------------------------
     VIDEO STEP
     -------------------------------------------------------------------------- */

  .onboarding-modal .video-headline {
    font-size: 1.1rem;
  }

  .onboarding-modal .video-description {
    font-size: 0.85rem;
  }

  /* --------------------------------------------------------------------------
     SIGNATURE STEP
     -------------------------------------------------------------------------- */

  .signature-step {
    gap: var(--block-space-half);
  }

  .signature-step__headline {
    font-size: 1.1rem;
  }

  .signature-step__pledge {
    max-height: 40vh;
    font-size: 0.9rem;
    line-height: 1.6;
  }

  .signature-step__form {
    flex-direction: column;
  }

  .signature-step__form .btn {
    width: 100%;
    font-size: 1rem;
  }

  /* --------------------------------------------------------------------------
     INFO/FINAL STEPS
     -------------------------------------------------------------------------- */

  .onboarding-modal .info-headline {
    font-size: 1.2rem;
  }

  .onboarding-checklist li {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* --------------------------------------------------------------------------
     CONFIRMATION STEP (Profile Approval)
     -------------------------------------------------------------------------- */

  .profile-category__header {
    padding: var(--block-space-half) var(--inline-space);
  }

  .profile-category__content {
    padding: var(--block-space-half);
  }

  .profile-category__footer {
    padding: var(--block-space-half) var(--inline-space);
  }

  .profile-category__footer .btn {
    width: 100%;
    min-height: 44px;
  }

  /* Compact service type selector container on mobile */
  .profile-category__content .fill-shade.pad {
    padding: var(--inline-space-half);
  }

  /* --------------------------------------------------------------------------
     INVITE STEP
     -------------------------------------------------------------------------- */

  .onboarding-modal .invite-link-container {
    flex-direction: column;
  }

  .onboarding-modal .invite-link-container .btn {
    width: 100%;
  }

  /* --------------------------------------------------------------------------
     SUMMARY NAVIGATION
     -------------------------------------------------------------------------- */

  .onboarding-summary__item {
    padding: var(--block-space-half) var(--inline-space);
    min-height: 44px;
  }

  /* --------------------------------------------------------------------------
     CHAT/INTERVIEW STEP - Campfire Pattern
     This is CRITICAL - must match Campfire behavior exactly
     -------------------------------------------------------------------------- */

  /* Full-bleed chat - remove content padding */
  .onboarding-modal main:has(.interview-step),
  .onboarding-modal main:has(.interview-chat) {
    padding: 0;
  }

  .interview-step,
  .interview-chat-container,
  .interview-chat {
    height: 100%;
  }

  /* Messages area - scrollable with touch optimization */
  .interview-chat__messages {
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  .interview-chat__messages > .messages {
    padding: var(--block-space-half) var(--inline-space);
  }

  /* Input wrapper - no safe area padding here since footer handles it */
  .interview-chat__input-wrapper {
    flex: none;
  }

  /* Typing indicator - compact */
  .interview-chat__typing-indicator {
    padding: 0.4em var(--inline-space);
  }

  .interview-chat__typing-text {
    font-size: 0.8rem;
  }

  /* Input form - touch-friendly */
  .interview-chat__input {
    padding: var(--block-space-half) var(--inline-space);
    gap: calc(var(--inline-space) / 2);
  }

  /* Prevent iOS zoom on focus - minimum 16px font size */
  .interview-chat__input .input {
    font-size: max(16px, 1rem);
    padding: 0.6em;
  }

  /* Touch-friendly send button */
  .interview-chat__input .btn {
    min-width: 44px;
    min-height: 44px;
  }

  /* Smaller avatars on mobile */
  .interview-chat .message__avatar,
  .interview-message__avatar {
    --avatar-size: 2rem;
    width: 2rem;
    height: 2rem;
  }

  /* Message styling */
  .interview-chat .message,
  .interview-message {
    padding: var(--block-space-half);
  }

  .interview-chat .message__body,
  .interview-message__body {
    font-size: 0.95rem;
    line-height: 1.5;
  }

} /* End @media (max-width: 640px) */


/* ==========================================================================
   PWA STANDALONE MODE
   Additional adjustments when running as installed PWA
   ========================================================================== */

@media (display-mode: standalone) {
  @media (max-width: 640px) {
    .onboarding-modal {
      /* In PWA mode, no browser chrome to account for */
      height: 100dvh;
    }
  }
}


/* ==========================================================================
   iOS-SPECIFIC OPTIMIZATIONS
   Prevent rubber-band scrolling on iOS
   ========================================================================== */

@supports (-webkit-touch-callout: none) {
  @media (max-width: 640px) {
    .onboarding-modal {
      overscroll-behavior: none;
    }

    .interview-chat__messages {
      overscroll-behavior: contain;
    }
  }
}

/* Inline edit - tap-to-edit pattern for profile values */
.inline-edit__form {
  background: var(--color-shade);
  border-radius: 0.5em;
  padding: var(--block-space-half);
  margin-top: 0.25em;
}

.btn--text,
.btn--text:focus,
.btn--text:focus-visible,
.btn--text:active {
  background: transparent;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0;
  text-decoration: none;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.btn--text:hover {
  opacity: 0.7;
}

.btn--text img {
  opacity: 0.5;
  margin-left: 0.25em;
}

.btn--text:hover img {
  opacity: 1;
}

.btn--small {
  padding: 0.25em 0.5em;
  font-size: var(--text-small);
}

/* Fix spinner centering in onboarding modal - override inset for horizontal centering */
.onboarding-modal .spinner::before {
  inset: 50%;
  margin-inline: calc((var(--dot-size, 1.25em) / 2) * -1);
}
