/* The patient form only. The staff page loads base.css and staff/staff.css. Rules shared by both pages are in base.css. */

.layout {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-4) var(--space-14);
}

.step-count {
  margin: 0;
}

.step-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-1) 2px var(--space-2);
  min-height: 44px;
}

.progress {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--orchid), var(--brand));
  transition: width 0.25s ease;
}

.consent {
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--line);
}

.consent .choice {
  font-size: var(--fs-body);
}

.post-buttons {
  flex-direction: column;
}

#welcome button {
  width: 100%;
  margin-top: var(--space-2);
}

#review-text {
  min-height: 320px;
  line-height: 1.6;
  overflow: auto;
}

#review-text:disabled {
  background: var(--tint);
  color: var(--ink);
  opacity: 1;
}

.consent.invalid {
  padding: var(--space-5) var(--space-4);
  border: 1.5px solid var(--error);
  border-radius: var(--radius-lg);
  background: var(--error-wash-form);
}

.consent.invalid > p strong {
  color: var(--error);
}

#post-hint {
  background: var(--accent-soft);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-3);
  margin-top: var(--space-3);
}

.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@media (min-width: 560px) {
  .post-buttons {
      flex-direction: row;
    }

  .post-buttons > button {
      flex: 1;
    }
}

.intro {
  font-size: var(--fs-menu);
}

.photo-preview {
  display: block;
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  margin-top: var(--space-3);
}

#wrap-photo {
  margin-top: var(--space-6);
}

/* The list of parts. Phone: a panel that slides in from the left. Wide screen: a sidebar (below). */
.stages {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: min(320px, 86vw);
  padding: var(--space-4) var(--space-4) var(--space-6);
  overflow-y: auto;
  background: var(--card);
  border-right: 1px solid var(--line);
  transform: translateX(-100%);
  visibility: hidden;
  /* Closing: stay visible until the slide-out has finished. */
  transition:
    transform 0.2s ease,
    visibility 0s linear 0.2s;
}

.stages.open {
  transform: none;
  visibility: visible;
  /* Opening: visible at once, so the panel can take the keyboard focus. */
  transition: transform 0.2s ease;
}

.stages-overlay {
  position: fixed;
  inset: 0;
  z-index: 15;
  background: rgb(0 0 0 / 0.35);
}

.stages-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stages-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

#stages-summary {
  margin: 0 0 var(--space-3);
}

.stages-note {
  margin: var(--space-4) var(--space-1) 0;
}

#stage-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stage {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 44px;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: 1.3;
  text-align: left;
}

.stage:hover:not(:disabled) {
  background: var(--bg);
}

.stage-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--field);
  border-radius: 50%;
  color: var(--muted);
  font-size: var(--fs-md);
  font-weight: 600;
}

.stage.is-current {
  background: var(--accent-soft);
  font-weight: 600;
}

.stage.is-current .stage-mark {
  border-color: var(--accent);
  color: var(--accent);
}

.stage.is-done .stage-mark {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.stage.is-attention .stage-mark {
  border-color: var(--error);
  color: var(--error);
}

.stage.is-locked {
  color: var(--muted);
}

@media (min-width: 900px) {
  .layout.has-stages {
      display: grid;
      grid-template-columns: 290px minmax(0, 640px);
      gap: var(--space-8);
      align-items: start;
      justify-content: center;
      max-width: none;
    }

  .stages {
      position: sticky;
      inset: auto;
      top: calc(var(--masthead) + 16px);
      z-index: auto;
      width: auto;
      max-height: calc(100vh - var(--masthead) - 32px);
      padding: var(--space-5) var(--space-4);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      transform: none;
      visibility: visible;
      transition: none;
    }

  .stages-overlay,
    #stages-open,
    #stages-close {
      display: none !important;
    }
}

#save-review {
  width: 100%;
  margin-top: var(--space-4);
}

/* The status line sits above the review box ("Writing your review…", "You can edit the text below."). */
#review-status {
  margin-bottom: var(--space-2);
}

.encourage {
  margin-top: var(--space-6);
  padding: var(--space-5) var(--space-5) var(--space-2);
  background: var(--accent-soft);
  border-radius: var(--radius);
}

.encourage h2 {
  margin: 0 0 var(--space-1);
  font-size: clamp(26px, 2.2vw + 18px, 32px);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--brand);
}

.encourage-sub {
  margin: 0 0 var(--space-4);
  font-size: clamp(19px, 0.9vw + 15px, 22px);
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
}

.encourage ul {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-5);
}

.encourage li {
  margin-bottom: var(--space-2);
}

/* The form's dialogs: "Write a different version" (the patient's own style choices) and the overlay before a review platform opens. */
.linklike {
  display: block;
  width: auto;
  margin: 0 0 var(--space-4);
  padding: var(--space-1) 0;
  border-radius: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
}

.linklike:hover:not(:disabled) {
  background: none;
  text-decoration-thickness: 2px;
}

.sheet {
  width: min(520px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  padding: var(--space-6) var(--space-5) var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  overflow-y: auto;
}

.sheet::backdrop {
  background: rgba(20, 16, 50, 0.55);
}

.restyle-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.restyle-head .linklike {
  margin: 0;
  flex: none;
}

.sheet h2 {
  margin: 0 0 var(--space-2);
  font-size: 20px;
}

.restyle-actions {
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-3);
  margin-top: var(--space-1);
}

@media (min-width: 560px) {
  .restyle-actions {
      flex-direction: row;
    }

  .restyle-actions > button {
      flex: 1;
    }
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  padding: 0;
  border: 0;
}

.chips legend {
  padding: 0;
  margin-bottom: var(--space-2);
  font-size: var(--fs-body);
  font-weight: 600;
}

.chips label {
  cursor: pointer;
}

.chips input {
  position: absolute;
  opacity: 0;
}

.chips span {
  display: inline-block;
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: var(--fs-base);
  line-height: 24px;
}

.chips input:checked + span {
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 600;
}

.chips input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* The line under a written answer, and the gentle ask for more. */
.depth {
  min-height: 22px;
  margin: var(--space-2) 2px 0;
  color: var(--muted);
  font-size: var(--fs-base);
}

.depth.enough {
  color: var(--brand);
}

.error.gentle {
  color: var(--ink);
  font-weight: 400;
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}

.tip {
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-base);
}

/* The mark on a question that needs an answer. */
.req {
  color: var(--error);
  font-weight: 700;
}

.req-note {
  margin: 0 2px var(--space-3);
}

/* The red note under "Your review": check it and make it your own. */
.review-note {
  color: var(--error);
  font-weight: 600;
}

/* A turning mark beside "Writing your review…" so a patient can see the page is working. */
.meta.working::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: var(--space-2);
  vertical-align: -2px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: working-spin 0.9s linear infinite;
}

/* "Would you like to help?" Shown before the post buttons (plan § 23.9). */
.gate {
  margin-top: var(--space-6);
  padding: var(--space-5) var(--space-5) var(--space-2);
  background: var(--accent-soft);
  border-radius: var(--radius);
}

.encourage .gate {
  margin: var(--space-2) 0 0;
  padding: 0;
  background: none;
  border-radius: 0;
}

.gate-buttons {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

/* The patient's name on the form: the clinic's record, shown and not editable. */
.readonly-name {
  margin: 0 0 var(--space-2);
  padding: var(--space-3) var(--space-3);
  background: var(--tint);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Symptoms before treatment, and how each has changed (plan § 36). */
.symptoms .group-title {
  margin: var(--space-4) 0 var(--space-2);
  font-weight: 600;
  color: var(--muted);
  font-size: 0.95rem;
}

/* The heading of a group of options in a tick list (the programme's therapies). */
.option-group {
  margin: var(--space-4) 0 var(--space-2);
  padding-left: var(--space-3);
  color: var(--ink);
  font-size: var(--fs-question);
  font-weight: 600;
}

.symptoms .group-title:first-child {
  margin-top: var(--space-1);
}

.remove-symptom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 24px;
  height: 24px;
  min-width: 0;
  min-height: 0;
  margin-left: auto;
  padding: 0;
  border-radius: 50%;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.remove-symptom:hover {
  background: rgb(var(--ink-rgb) / 0.1);
  color: var(--ink);
}

.rate-row.seg-missing .rate-name {
  color: var(--error);
}

.rate-row.seg-missing .segmented {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

/* The overall-recovery step slider (plan § 44): in its own box, full width. */
.rate-row.recovery-row {
  display: block;
  margin-bottom: var(--space-4);
  padding: var(--space-4) var(--space-4) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

/* "Something else": the added items are ticked options above the box; the box and its Add button sit under them. */
.extras-wrap .add-row {
  margin-top: var(--space-5); /* space above the box, after the last listed option or the last added item */
}

.extras-wrap .choices {
  margin-top: 0;
}

/* Treatments already tried: each ticked one shows how it went (plan § 38). */
.tried-item {
  margin-bottom: var(--space-2);
}

.tried-item .choice {
  margin-bottom: 0;
}

.seg-wrap {
  margin: var(--space-2) 0 var(--space-4);
}

.seg-wrap .segmented {
  margin: 0;
}

.seg-ask {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--muted);
}

/* A treatment that still needs its result, shown when the patient presses Next. */
.seg-missing .segmented {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

.seg-missing .seg-ask {
  color: var(--error);
}

.seg-missing .seg-ask::after {
  content: " Please choose one.";
}

/* The overlay before a review platform opens (plan § 49): a tick, "Your review is copied", one instruction, one button, a small close. */
.post-sheet {
  position: fixed; /* always in the middle of what the patient sees, wherever the page is scrolled */
  inset: 0;
  height: fit-content;
  margin: auto;
  text-align: center;
}

.post-sheet > p {
  margin: 0 0 var(--space-4);
}

.post-sheet > .post-lead {
  font-weight: 600;
  margin-bottom: var(--space-3);
}

/* The steps: a number, an icon, one short line each. */
.post-steps {
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
  counter-reset: post-step;
  text-align: left;
}

.post-steps > li {
  display: grid;
  grid-template-columns: 28px 28px 1fr;
  align-items: start;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--line);
  font-size: var(--fs-body);
  line-height: 1.45;
  counter-increment: post-step;
}

.post-steps > li::before {
  content: counter(post-step);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--brand);
  font-size: var(--fs-md);
  font-weight: 700;
}

.post-step-icon {
  font-size: 22px;
  line-height: 28px;
  text-align: center;
}

.post-sheet > button.primary,
.post-sheet > button.secondary {
  width: 100%;
  margin-top: var(--space-2);
}

.post-sheet > .sheet-tick {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 auto var(--space-3);
  border-radius: 50%;
  background: var(--accent);
  color: var(--card);
  font-size: 24px;
  line-height: 1;
}

.sheet-x {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.sheet-x:hover {
  background: var(--accent-soft);
  color: var(--ink);
}
