/* ── Flow Form Styles ────────────────────────────────────────────────────── */
/* All values use CSS custom properties set by the theme system */

/* Reset */
.flow-container *,
.flow-container *::before,
.flow-container *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Container */
.flow-container {
  font-family: var(--flow-font);
  color: var(--flow-text);
  background: var(--flow-bg);
  position: relative;
  overflow: hidden;
  width: 100%;
}

.flow-container--fullpage {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Progress ──────────────────────────────────────────────────────────── */

.flow-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: calc(var(--flow-spacing) * 2);
}

.flow-progress-track {
  height: 4px;
  background: color-mix(in srgb, var(--flow-text) 10%, transparent);
  border-radius: 2px;
  overflow: hidden;
}

.flow-progress-fill {
  height: 100%;
  background: var(--flow-primary);
  border-radius: 2px;
  transition: width var(--flow-duration) cubic-bezier(0.16, 1, 0.3, 1);
}

.flow-progress--percentage,
.flow-progress--fraction {
  text-align: right;
  font-size: 0.875rem;
  color: var(--flow-muted);
  font-variant-numeric: tabular-nums;
}

.flow-progress--dots {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.flow-progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--flow-text) 15%, transparent);
  transition:
    background var(--flow-duration) cubic-bezier(0.16, 1, 0.3, 1),
    transform var(--flow-duration) cubic-bezier(0.16, 1, 0.3, 1);
}

.flow-progress-dot--active {
  background: var(--flow-primary);
  transform: scale(1.2);
}

/* ── Screens (Welcome / End / Submitting) ──────────────────────────────── */

.flow-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(var(--flow-spacing) * 6);
  min-height: 100%;
  flex: 1;
  gap: calc(var(--flow-spacing) * 3);
}

.flow-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-wrap: balance;
  line-height: 1.15;
}

.flow-description {
  font-size: 1.125rem;
  color: var(--flow-muted);
  max-width: 480px;
  line-height: 1.6;
}

.flow-end-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--flow-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
}

/* ── Question ──────────────────────────────────────────────────────────── */

.flow-question {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(var(--flow-spacing) * 6);
  padding-top: calc(var(--flow-spacing) * 10);
  min-height: 100%;
  flex: 1;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  gap: calc(var(--flow-spacing) * 4);
}

.flow-question-header {
  display: flex;
  align-items: flex-start;
  gap: calc(var(--flow-spacing) * 1.5);
}

.flow-question-number {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--flow-primary);
  background: color-mix(in srgb, var(--flow-primary) 12%, transparent);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.flow-question-arrow {
  color: var(--flow-primary);
  font-size: 1rem;
  margin-top: 3px;
  flex-shrink: 0;
}

.flow-question-title {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.flow-question-description {
  font-size: 1rem;
  color: var(--flow-muted);
  margin-top: calc(var(--flow-spacing) * 0.5);
  line-height: 1.5;
}

.flow-question-body {
  padding-left: calc(
    28px + var(--flow-spacing) * 1.5 + 1rem + var(--flow-spacing) * 1.5
  );
}

.flow-question-footer {
  padding-left: calc(
    28px + var(--flow-spacing) * 1.5 + 1rem + var(--flow-spacing) * 1.5
  );
  display: flex;
  align-items: center;
  gap: calc(var(--flow-spacing) * 2);
}

/* ── Inputs ────────────────────────────────────────────────────────────── */

.flow-input-wrapper {
  width: 100%;
}

.flow-input,
.flow-textarea {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 2px solid color-mix(in srgb, var(--flow-text) 20%, transparent);
  color: var(--flow-text);
  font-family: var(--flow-font);
  font-size: 1.25rem;
  padding: calc(var(--flow-spacing) * 1.5) 0;
  outline: none;
  transition: border-color 200ms ease;
}

.flow-input:focus,
.flow-textarea:focus {
  border-color: var(--flow-primary);
}

.flow-input--error {
  border-color: var(--flow-error);
}

.flow-input::placeholder,
.flow-textarea::placeholder {
  color: color-mix(in srgb, var(--flow-text) 30%, transparent);
}

.flow-textarea {
  resize: vertical;
  min-height: 100px;
}

.flow-input--date {
  color-scheme: dark;
}

/* ── Choices ───────────────────────────────────────────────────────────── */

.flow-choices {
  display: flex;
  flex-direction: column;
  gap: calc(var(--flow-spacing) * 1.5);
  width: 100%;
}

.flow-choice {
  display: flex;
  align-items: center;
  gap: calc(var(--flow-spacing) * 1.5);
  padding: calc(var(--flow-spacing) * 2) calc(var(--flow-spacing) * 2.5);
  background: color-mix(in srgb, var(--flow-text) 5%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--flow-text) 12%, transparent);
  border-radius: var(--flow-radius);
  color: var(--flow-text);
  font-family: var(--flow-font);
  font-size: 1rem;
  cursor: pointer;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
  text-align: left;
  width: 100%;
}

.flow-choice:hover {
  background: color-mix(in srgb, var(--flow-text) 8%, transparent);
  border-color: color-mix(in srgb, var(--flow-text) 20%, transparent);
}

.flow-choice:active {
  transform: scale(0.98);
}

.flow-choice--selected {
  background: color-mix(in srgb, var(--flow-primary) 12%, transparent);
  border-color: var(--flow-primary);
}

.flow-choice-key {
  font-size: 0.75rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--flow-text) 10%, transparent);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.flow-choice--selected .flow-choice-key {
  background: var(--flow-primary);
  color: white;
}

.flow-choice-icon {
  font-size: 1.25rem;
}

.flow-choice-label {
  flex: 1;
}

.flow-choice-check {
  color: var(--flow-primary);
  font-weight: 700;
  width: 20px;
  text-align: center;
}

.flow-choice--other {
  cursor: default;
}

.flow-choice-other-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--flow-text);
  font-family: var(--flow-font);
  font-size: 1rem;
  outline: none;
}

/* ── Rating ────────────────────────────────────────────────────────────── */

.flow-rating-wrapper {
  display: flex;
  align-items: center;
  gap: calc(var(--flow-spacing) * 2);
}

.flow-rating {
  display: flex;
  gap: calc(var(--flow-spacing) * 0.5);
}

.flow-rating-item {
  background: transparent;
  border: none;
  color: color-mix(in srgb, var(--flow-text) 25%, transparent);
  font-size: 2rem;
  cursor: pointer;
  padding: calc(var(--flow-spacing) * 0.5);
  transition:
    color 150ms ease,
    transform 150ms ease;
  line-height: 1;
}

.flow-rating-item:hover {
  transform: scale(1.15);
}

.flow-rating-item--active {
  color: var(--flow-primary);
}

.flow-rating-item--number {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--flow-text) 5%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--flow-text) 12%, transparent);
}

.flow-rating-item--number.flow-rating-item--active {
  background: var(--flow-primary);
  border-color: var(--flow-primary);
  color: white;
}

.flow-rating-label {
  font-size: 0.875rem;
  color: var(--flow-muted);
}

/* ── Buttons ───────────────────────────────────────────────────────────── */

.flow-button {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--flow-spacing) * 1.5);
  font-family: var(--flow-font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: var(--flow-radius);
  transition:
    background 150ms ease,
    transform 150ms ease,
    opacity 150ms ease;
  text-decoration: none;
}

.flow-button:active {
  transform: scale(0.98);
}

.flow-button--primary {
  background: var(--flow-primary);
  color: white;
  padding: calc(var(--flow-spacing) * 1.5) calc(var(--flow-spacing) * 3);
}

.flow-button--primary:hover {
  opacity: 0.9;
}

.flow-button--secondary {
  background: transparent;
  color: var(--flow-muted);
  padding: calc(var(--flow-spacing) * 1.5) calc(var(--flow-spacing) * 2);
}

.flow-button--secondary:hover {
  color: var(--flow-text);
}

.flow-button-hint {
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.6;
}

/* ── Hints & Errors ────────────────────────────────────────────────────── */

.flow-hint {
  font-size: 0.875rem;
  color: var(--flow-muted);
  margin-top: calc(var(--flow-spacing) * 0.5);
}

.flow-error {
  font-size: 0.875rem;
  color: var(--flow-error);
  margin-top: calc(var(--flow-spacing));
}

/* ── Spinner ───────────────────────────────────────────────────────────── */

.flow-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid color-mix(in srgb, var(--flow-text) 15%, transparent);
  border-top-color: var(--flow-primary);
  border-radius: 50%;
  animation: flow-spin 0.8s ease-in-out infinite;
}

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

/* ── Validation Shake ──────────────────────────────────────────────────── */

.flow-shake {
  animation: flow-shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes flow-shake {
  10%,
  90% {
    transform: translateX(-2px);
  }
  20%,
  80% {
    transform: translateX(4px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-6px);
  }
  40%,
  60% {
    transform: translateX(6px);
  }
}

/* ── Transitions (Horizontal Slide) ────────────────────────────────────── */
/* Follows 12 Principles: ease-out entrance, anticipation via slight overshoot */
/* GPU-accelerated with translate3d + will-change */

.flow-question,
.flow-screen {
  will-change: transform, opacity;
}

.flow-slide-forward {
  animation: flow-slide-in-right var(--flow-duration)
    cubic-bezier(0.16, 1, 0.3, 1) both;
}

.flow-slide-backward {
  animation: flow-slide-in-left var(--flow-duration)
    cubic-bezier(0.16, 1, 0.3, 1) both;
}

.flow-slide-in {
  animation: flow-fade-in var(--flow-duration) cubic-bezier(0.16, 1, 0.3, 1)
    both;
}

/* Parallax stagger: header enters slightly before body */
.flow-slide-forward .flow-question-header,
.flow-slide-backward .flow-question-header {
  animation: flow-fade-in calc(var(--flow-duration) * 0.8)
    cubic-bezier(0.16, 1, 0.3, 1) both;
}

.flow-slide-forward .flow-question-body,
.flow-slide-forward .flow-question-footer,
.flow-slide-backward .flow-question-body,
.flow-slide-backward .flow-question-footer {
  animation: flow-fade-in calc(var(--flow-duration) * 0.9)
    cubic-bezier(0.16, 1, 0.3, 1) 60ms both;
}

/* Submit button entrance on last question */
.flow-submit-enter {
  animation: flow-submit-fade-up 0.4s ease both;
}

@keyframes flow-submit-fade-up {
  from {
    opacity: 0;
    transform: translate3d(0, 20px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes flow-slide-in-right {
  from {
    opacity: 0;
    transform: translate3d(60px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes flow-slide-in-left {
  from {
    opacity: 0;
    transform: translate3d(-60px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes flow-fade-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateZ(0);
  }
  to {
    opacity: 1;
    transform: scale(1) translateZ(0);
  }
}

/* ── Touch device: hide keyboard hints ─────────────────────────────────── */

@media (hover: none) and (pointer: coarse) {
  .flow-button-hint {
    display: none;
  }
}

/* ── Reduced Motion ────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .flow-slide-forward,
  .flow-slide-backward,
  .flow-slide-in {
    animation: flow-fade-only 200ms ease both;
  }

  @keyframes flow-fade-only {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  .flow-progress-fill,
  .flow-progress-dot,
  .flow-choice,
  .flow-rating-item,
  .flow-button {
    transition-duration: 0.01ms !important;
  }
}

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .flow-question {
    padding: calc(var(--flow-spacing) * 3);
    padding-top: calc(var(--flow-spacing) * 8);
  }

  .flow-question-body,
  .flow-question-footer {
    padding-left: 0;
  }

  .flow-screen {
    padding: calc(var(--flow-spacing) * 3);
  }

  .flow-rating-item {
    font-size: 1.5rem;
  }

  .flow-rating-item--number {
    width: 36px;
    height: 36px;
  }
}
