/* ==========================================================================
   Sentidental — Patient survey experience
   Shares the brand system with sentidental.css. The one surface a patient
   touches: distinctive frame + one expressive moment, radically simple flow.
   ========================================================================== */

:root {
  --bg: #f5f1e9;
  --paper: #fbf9f4;
  --surface: #ffffff;
  --ink: #1b1815;
  --ink-soft: #4a453d;
  --ink-muted: #726c60;
  --ink-faint: #9a9184;
  --wine: #5e1f2b;
  --wine-deep: #4a1622;
  --wine-soft: #f0e3e1;
  --star: #c7a24e;
  --star-soft: #efe6cf;
  --line: #e4ddce;
  --line-strong: #d6cdb9;
  --pos: #3f6b4f;
  --pos-bg: #eaf1eb;
  --shadow: 0 6px 24px rgba(27, 24, 21, 0.06);
  --shadow-lg: 0 24px 60px -20px rgba(27, 24, 21, 0.20);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body.survey {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(120% 60% at 50% -10%, var(--star-soft) 0%, transparent 45%),
    var(--bg);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

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

/* Orbit watermark behind the card */
.survey__field { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.5; overflow: hidden; }
.survey__field svg { position: absolute; top: 50%; left: 50%; width: min(140vh, 140vw); height: min(140vh, 140vw); transform: translate(-50%, -50%); }
@media (prefers-reduced-motion: no-preference) {
  .survey__field .swirl { transform-origin: center; animation: survey-spin 160s linear infinite; }
}
@keyframes survey-spin { to { transform: rotate(360deg); } }

/* Shell */
.survey__shell {
  position: relative; z-index: 1;
  width: 100%; max-width: 33rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem;
  flex: 1; display: flex; flex-direction: column;
}

/* Practice brand header */
.survey__brand { text-align: center; padding: 1.25rem 0 1.5rem; }
.survey__practice { font-family: var(--serif); font-size: 1.25rem; font-weight: 500; color: var(--ink); letter-spacing: -0.01em; }
.survey__practice-mark {
  width: 40px; height: 40px; border-radius: 50%; margin: 0 auto 0.6rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--wine); color: #fbf3ef; font-family: var(--serif); font-size: 1.05rem; font-weight: 500;
}

/* Card */
.survey__card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: clamp(1.25rem, 4vw, 2rem);
}

/* Progress — small orbit of dots */
.survey__progress { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-bottom: 1.5rem; }
.survey__progress-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); transition: background 0.25s, transform 0.25s; }
.survey__progress-dot.is-active { background: var(--wine); transform: scale(1.25); }
.survey__progress-dot.is-done { background: var(--star); }

/* Steps */
.survey__step { animation: survey-fade 0.35s ease; }
.survey__step[hidden] { display: none; }
@keyframes survey-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.survey__q { font-family: var(--serif); font-size: clamp(1.5rem, 5vw, 1.9rem); font-weight: 480; line-height: 1.12; letter-spacing: -0.01em; margin: 0 0 0.4rem; }
.survey__hint { color: var(--ink-muted); font-size: 0.95rem; margin: 0 0 1.5rem; }

/* Feeling scale — the expressive, brandable moment */
.feelings { border: 0; padding: 0; margin: 0 0 0.5rem; }
.feelings__track { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; padding: 0.5rem 0 0.25rem; }
.feelings__track::before {
  content: ""; position: absolute; left: 10%; right: 10%; top: calc(0.5rem + 13px);
  height: 2px; background: linear-gradient(90deg, var(--line-strong), var(--wine-line, #d9c4c1), var(--star));
  border-radius: 2px; z-index: 0;
}
.feeling { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; cursor: pointer; padding: 0.25rem 0; }
.feeling__dot {
  width: 26px; height: 26px; border-radius: 50%; background: var(--surface);
  border: 2px solid var(--line-strong); transition: all 0.2s ease;
}
.feeling__word { font-size: 0.8rem; color: var(--ink-muted); font-weight: 500; transition: color 0.2s; }
.feeling:hover .feeling__dot { border-color: var(--wine); }
.feeling input:checked ~ .feeling__dot {
  background: var(--wine); border-color: var(--wine);
  box-shadow: 0 0 0 4px var(--wine-soft);
  transform: scale(1.05);
}
.feeling input:checked ~ .feeling__word { color: var(--wine); font-weight: 600; }
.feeling input:focus-visible ~ .feeling__dot { outline: 2px solid var(--wine); outline-offset: 3px; }
.feelings__caption { text-align: center; min-height: 1.4rem; margin-top: 0.75rem; font-family: var(--serif); font-style: italic; color: var(--wine); font-size: 1.05rem; }

/* Text + voice */
.survey__textarea {
  width: 100%; min-height: 120px; resize: vertical; padding: 0.85rem;
  font-family: var(--sans); font-size: 1rem; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}
.survey__textarea:focus { outline: 2px solid var(--wine); outline-offset: 1px; border-color: var(--wine); }

.voice { margin-top: 1rem; border: 1px dashed var(--line-strong); border-radius: var(--r); padding: 1rem; text-align: center; background: var(--paper); }
.voice__btn {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1.1rem;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px;
  font-family: var(--sans); font-size: 0.9rem; font-weight: 500; color: var(--ink); cursor: pointer;
}
.voice__btn:hover { border-color: var(--wine); color: var(--wine); }
.voice__timer { margin-top: 0.6rem; font-size: 0.82rem; color: var(--ink-muted); }

/* Consent toggles */
.consent { display: flex; flex-direction: column; gap: 0.35rem; }
.consent__item {
  display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.85rem;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--paper);
  cursor: pointer; transition: border-color 0.18s;
}
.consent__item:hover { border-color: var(--line-strong); }
.consent__item:has(input:checked) { border-color: var(--wine); background: var(--wine-soft); }
.consent__box {
  flex: none; width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line-strong);
  background: var(--surface); margin-top: 1px; display: flex; align-items: center; justify-content: center;
  transition: all 0.18s;
}
.consent__item input { position: absolute; opacity: 0; pointer-events: none; }
.consent__item input:checked ~ .consent__box { background: var(--wine); border-color: var(--wine); }
.consent__item input:checked ~ .consent__box::after { content: "✓"; color: #fff; font-size: 0.75rem; line-height: 1; }
.consent__item input:focus-visible ~ .consent__box { outline: 2px solid var(--wine); outline-offset: 2px; }
.consent__label { font-size: 0.92rem; color: var(--ink-soft); }

.survey__contact {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}
.survey__contact[hidden] { display: none; }
.survey__contact-lead { margin: 0 0 1rem; color: var(--ink-muted); font-size: 0.92rem; }
.survey__error {
  margin: 1rem 0 0;
  padding: 0.75rem 0.9rem;
  border-radius: var(--r-sm);
  background: #f6e6e1;
  color: #8f3529;
  font-size: 0.9rem;
}
.survey__error[hidden] { display: none; }

/* Actions */
.survey__actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 1.75rem; }
.survey__actions .grow { flex: 1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-family: var(--sans); font-size: 1rem; font-weight: 500; cursor: pointer;
  padding: 0.8rem 1.4rem; border-radius: var(--r-sm); border: 1px solid transparent;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.btn:focus-visible { outline: 2px solid var(--wine); outline-offset: 2px; }
.btn--primary { background: var(--wine); color: #fbf3ef; width: 100%; }
.btn--primary:hover { background: var(--wine-deep); }
.btn--back { background: none; color: var(--ink-muted); border-color: var(--line-strong); padding: 0.8rem 1rem; }
.btn--back:hover { color: var(--ink); border-color: var(--ink); }

/* Simple form fields (enrollment) */
.survey__intro { color: var(--ink-muted); margin: 0 0 1.5rem; }
.survey__form { display: flex; flex-direction: column; gap: 1.1rem; }
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
.field input {
  padding: 0.75rem 0.85rem; font: inherit; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}
.field input:focus { outline: 2px solid var(--wine); outline-offset: 1px; border-color: var(--wine); }

/* Copyable link (confirmation) */
.survey__url {
  margin: 0.5rem 0; padding: 0.75rem 0.85rem; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem;
  color: var(--wine); word-break: break-all;
}
.survey__note { font-size: 0.85rem; color: var(--ink-faint); margin: 0.5rem 0 0; }

/* Auth (Devise) */
.auth__wordmark { font-family: var(--serif); font-size: 1.5rem; font-weight: 500; color: var(--ink); letter-spacing: -0.01em; text-decoration: none; }
.auth__dot { color: var(--wine); }
.auth__lead { color: var(--ink-muted); margin: 0 0 1.5rem; }
.auth__row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin: 0.25rem 0 0.5rem; }
.auth__remember { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; color: var(--ink-soft); }
.auth__remember input { width: 16px; height: 16px; accent-color: var(--wine); }
.auth__alt { text-align: center; margin-top: 1.5rem; font-size: 0.9rem; color: var(--ink-muted); }
.auth__alt a { color: var(--wine); font-weight: 500; }
.auth__errors {
  background: #f6e6e1; color: #8f3529; border: 1px solid #eccfc8;
  border-radius: var(--r-sm); padding: 0.75rem 1rem; margin-bottom: 1.25rem; font-size: 0.9rem;
}
.auth__errors ul { margin: 0.25rem 0 0; padding-left: 1.1rem; }

/* Powered by */
.survey__powered { text-align: center; margin-top: 1.5rem; font-size: 0.78rem; color: var(--ink-faint); letter-spacing: 0.02em; }
.survey__powered b { color: var(--ink-muted); font-weight: 600; }
.survey__powered a { color: var(--ink-muted); text-decoration: none; }
.survey__powered a:hover { color: var(--wine); }

/* Flash */
.survey__flash { border-radius: var(--r-sm); padding: 0.75rem 1rem; margin-bottom: 1rem; font-size: 0.9rem; }
.survey__flash.alert { background: #f6e6e1; color: #8f3529; }
.survey__flash.notice { background: var(--pos-bg); color: var(--pos); }

/* Thank-you */
.thanks { text-align: center; }
.thanks__orbit { width: 180px; height: 180px; margin: 0.5rem auto 1.5rem; }
.thanks__title { font-family: var(--serif); font-size: 1.9rem; font-weight: 480; margin: 0 0 0.5rem; }
.thanks__text { color: var(--ink-muted); margin: 0 auto 1.25rem; max-width: 34ch; }
.thanks__review { display: inline-flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; font-weight: 500; }
@media (prefers-reduced-motion: no-preference) {
  .thanks__join { animation: thanks-join 1.4s ease forwards; }
}
@keyframes thanks-join {
  0% { opacity: 0; transform: translate(40px, -40px) scale(0.6); }
  100% { opacity: 1; transform: none; }
}

.thanks__referral {
  text-align: left;
  margin: 1.75rem 0 1.5rem;
  padding: 1.35rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--paper);
}
.thanks__referral-title {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 500;
  margin: 0 0 0.35rem;
  color: var(--ink);
}
.thanks__incentive {
  background: #f3ecd6;
  border: 1px solid #e4ddce;
  border-radius: var(--r-sm);
  padding: 0.75rem 0.9rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin: 0 0 1rem;
}
.thanks__link-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-muted);
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.thanks__link-row { display: flex; gap: 0.5rem; align-items: stretch; }
.thanks__link-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 0.65rem 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  color: var(--wine);
  background: #fff;
}
.thanks__link-row .btn { flex: 0 0 auto; white-space: nowrap; width: auto; padding: 0.65rem 1rem; }

.survey__intro--referral { color: var(--wine); font-weight: 500; margin-bottom: 0.35rem; }
.survey__referral-incentive {
  background: #f3ecd6;
  border: 1px solid #e4ddce;
  border-radius: var(--r-sm);
  padding: 0.75rem 0.9rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin: 0 0 1rem;
}

@media (max-width: 540px) {
  .thanks__link-row { flex-direction: column; }
}
