/* ================================================================
   OUR MOMENT — FORM MODAL
   6-step personalisation form overlay
================================================================ */

/* ── Overlay ────────────────────────────────────────────────── */
.fm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}
.fm-overlay.fm-overlay--open {
  opacity: 1;
  pointer-events: all;
}

.fm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(35, 25, 18, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ── Panel ──────────────────────────────────────────────────── */
.fm-panel {
  position: relative;
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(24px);
  transition: transform 350ms cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.fm-overlay--open .fm-panel {
  transform: translateY(0);
}

/* ── Top bar: progress + close ──────────────────────────────── */
.fm-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 0;
  flex-shrink: 0;
}

.fm-progress-track {
  flex: 1;
  height: 4px;
  background: var(--color-border);
  border-radius: 99px;
  overflow: hidden;
}
.fm-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 99px;
  transition: width 400ms cubic-bezier(0.22, 1, 0.36, 1);
}

.fm-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--color-surface-dark);
  color: var(--color-text-mid);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--ease-fast), color var(--ease-fast);
}
.fm-close:hover {
  background: var(--color-border);
  color: var(--color-text);
}

/* ── Step header ────────────────────────────────────────────── */
.fm-step-header {
  padding: 20px 24px 0;
  flex-shrink: 0;
}
.fm-step-label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: 6px;
}
.fm-step-title {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.25;
  margin-bottom: 6px;
}
.fm-step-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-light);
  line-height: 1.5;
}

/* ── Content area ───────────────────────────────────────────── */
.fm-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  overscroll-behavior: contain;
}
.fm-content-inner {
  animation: fm-slide-in 280ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.fm-content-inner.fm-slide-back {
  animation: fm-slide-in-back 280ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes fm-slide-in {
  from { opacity: 0; transform: translateX(32px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes fm-slide-in-back {
  from { opacity: 0; transform: translateX(-32px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Fields ─────────────────────────────────────────────────── */
.fm-field {
  margin-bottom: 20px;
}
.fm-field:last-child {
  margin-bottom: 0;
}

.fm-label {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}
.fm-label--sub {
  font-weight: 600;
  color: var(--color-text-mid);
  margin-top: 12px;
}
.fm-required {
  color: var(--color-primary);
}
.fm-label-hint {
  font-weight: 400;
  color: var(--color-text-light);
}
.fm-hint {
  font-size: var(--text-xs);
  color: var(--color-text-light);
  margin-top: 6px;
  line-height: 1.5;
}

.fm-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-text);
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
  outline: none;
}
.fm-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(200, 122, 94, 0.15);
}
.fm-input.fm-input--error {
  border-color: var(--color-error);
}

.fm-textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-text);
  resize: vertical;
  min-height: 80px;
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
  outline: none;
  line-height: 1.6;
}
.fm-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(200, 122, 94, 0.15);
}

.fm-error-msg {
  font-size: var(--text-xs);
  color: var(--color-error);
  margin-top: 5px;
}

/* ── Chips ──────────────────────────────────────────────────── */
.fm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 3px;
}

.fm-chip {
  padding: 7px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-white);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-mid);
  cursor: pointer;
  transition: all var(--ease-fast);
  user-select: none;
  white-space: nowrap;
}
.fm-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(200, 122, 94, 0.04);
}
.fm-chip--selected {
  border-color: var(--color-primary);
  background: rgba(200, 122, 94, 0.1);
  color: var(--color-primary);
  transform: scale(1.03);
}

/* ── Age stepper ────────────────────────────────────────────── */
.fm-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  width: fit-content;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-white);
}
.fm-stepper-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--color-surface);
  color: var(--color-text-mid);
  font-size: 20px;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--ease-fast), color var(--ease-fast);
  flex-shrink: 0;
  line-height: 1;
}
.fm-stepper-btn:hover {
  background: var(--color-border);
  color: var(--color-primary);
}
.fm-stepper-input {
  width: 64px;
  height: 44px;
  border: none;
  border-left: 1.5px solid var(--color-border);
  border-right: 1.5px solid var(--color-border);
  background: var(--color-white);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  outline: none;
}
.fm-stepper-input:focus {
  background: rgba(200, 122, 94, 0.05);
}

/* ── Story goal grid ────────────────────────────────────────── */
.fm-goal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.fm-goal {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 14px 16px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-white);
  cursor: pointer;
  text-align: left;
  transition: all var(--ease-fast);
}
.fm-goal:hover {
  border-color: var(--color-primary);
  background: rgba(200, 122, 94, 0.04);
}
.fm-goal--selected {
  border-color: var(--color-primary);
  background: rgba(200, 122, 94, 0.08);
}
.fm-goal-icon {
  font-size: 20px;
  line-height: 1;
}
.fm-goal-label {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}
.fm-goal--selected .fm-goal-label {
  color: var(--color-primary);
}

/* ── Sub-pickers (habit / change) ───────────────────────────── */
.fm-subpicker {
  margin-top: 16px;
  padding: 16px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}
.fm-l2-chips {
  margin-top: 12px;
}

/* ── Parchment (step 3) ─────────────────────────────────────── */
.fm-parchment {
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border);
  background: #FDFBF7;
  overflow: hidden;
  transition: border-color 200ms;
}
.fm-parchment .fm-textarea {
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  resize: none;
  padding: 16px;
}
.fm-parchment .fm-textarea:focus {
  box-shadow: none;
}
.fm-parchment--nudge {
  border-color: #D4A07A;
  animation: fm-shake 400ms ease;
}
@keyframes fm-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}
.fm-nudge-msg {
  font-size: var(--text-xs);
  color: #A07050;
  margin-top: 6px;
}

/* ── Photo upload ───────────────────────────────────────────── */
.fm-photo-upload {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2px dashed var(--color-border);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  transition: border-color var(--ease-fast);
  position: relative;
}
.fm-photo-upload:hover {
  border-color: var(--color-primary);
}
.fm-photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--color-text-light);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  padding: 8px;
}
.fm-photo-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.fm-privacy {
  font-size: var(--text-xs);
  color: var(--color-text-light);
  margin-top: 10px;
}
.fm-privacy-link {
  color: var(--color-primary);
  text-decoration: none;
}
.fm-privacy-link:hover {
  text-decoration: underline;
}

/* ── Footer ─────────────────────────────────────────────────── */
.fm-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
  gap: 12px;
}

.fm-btn-back {
  padding: 10px 20px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: transparent;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-mid);
  cursor: pointer;
  transition: all var(--ease-fast);
}
.fm-btn-back:hover {
  border-color: var(--color-text-mid);
  color: var(--color-text);
}
.fm-btn-back:disabled,
.fm-btn-back[hidden] {
  visibility: hidden;
}

.fm-btn-next {
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-white);
  cursor: pointer;
  transition: background var(--ease-fast), opacity var(--ease-fast), transform var(--ease-fast);
  box-shadow: var(--shadow-cta);
}
.fm-btn-next:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
}
.fm-btn-next:active {
  transform: translateY(0);
}
.fm-btn-next--disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}
.fm-btn-next--disabled:hover {
  background: var(--color-primary);
  transform: none;
}

/* ── Loading state ──────────────────────────────────────────── */
.fm-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  gap: 20px;
}
.fm-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: fm-spin 800ms linear infinite;
}
@keyframes fm-spin {
  to { transform: rotate(360deg); }
}
.fm-loading-msg {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  color: var(--color-text);
  font-style: italic;
}

/* ── Success state ──────────────────────────────────────────── */
.fm-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 32px;
  text-align: center;
  gap: 16px;
}
.fm-success-icon {
  font-size: 52px;
  line-height: 1;
}
.fm-success-title {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
}
.fm-success-body {
  font-size: var(--text-base);
  color: var(--color-text-mid);
  line-height: 1.6;
  max-width: 340px;
}
.fm-success-btn {
  margin-top: 8px;
  padding: 12px 32px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-white);
  cursor: pointer;
  box-shadow: var(--shadow-cta);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  .fm-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .fm-panel {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92vh;
  }
  .fm-goal-grid {
    grid-template-columns: 1fr 1fr;
  }
  .fm-step-title {
    font-size: var(--text-lg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fm-overlay, .fm-panel, .fm-chip, .fm-btn-next, .fm-content-inner {
    transition: none;
    animation: none;
  }
}
