/* The order form in the site's document modal. Colors, type and spacing come from the design system tokens and from
   the sheet variables that legal.css defines for the modal's paper. */

.tc-part [hidden] {
  display: none !important;
}

.od {
  --od-danger: var(--red-500);
  --od-button: var(--ember-600);
  --od-button-hover: var(--ember-700);
  --od-button-ink: var(--text-on-accent);
  --od-client: var(--stone-150);
  margin-top: var(--sp-6);
}

.tc-part[data-paper="dark"] .od {
  --od-danger: var(--red-100);
  --od-button: var(--ember-400);
  --od-button-hover: var(--ember-300);
  --od-button-ink: var(--night-950);
  --od-client: var(--night-700);
}

.od-form p,
.od-field p,
.od-listings p,
.od-check + p {
  margin: 0;
}

.tc-part .od {
  margin-top: 0;
}

/* The order view uses the whole sheet; legal.css limits other views to a reading measure, so only the running
   text of the order view keeps one. */
.tc-part .legal-doc.od-doc {
  max-width: none;
}

.od-note,
.od-quote,
.od-order-summary,
.od-result,
.od-general,
.od-hint,
.od-notice,
.od-switch {
  max-width: 62ch;
}

/* The shared heading is the modal's title: the order view has no other. */
.tc-part .od-head h2,
.tc-part .od-step h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(28px, 3.2vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 16px 0 18px;
  padding-top: 0;
  border-top: 0;
}

.tc-part .od-head h2 {
  margin-bottom: var(--sp-5);
}

/* The headings of the sections under it. */
.tc-part .od-step h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(22px, 2.4vw, 28px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 var(--sp-4);
}

.od-head h2:focus-visible,
.od-step h2:focus-visible,
.od-step h3:focus-visible,
.od-note:focus-visible,
.od-result:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
}

/* The steps: a numbered sequence. */
.tc-part .od-progress {
  list-style: none;
  margin: 0 0 var(--sp-8);
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-3);
}

.tc-part .od-progress-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-2);
  min-width: 0;
  margin: 0;
  padding-top: var(--sp-3);
  border-top: 2px solid var(--rule);
  color: var(--ink-faint);
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  line-height: var(--lh-heading);
}

.od-progress-mark {
  position: relative;
  flex: none;
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  width: var(--sp-6);
  height: var(--sp-6);
  border: 1px solid currentColor;
  border-radius: var(--r-pill);
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  line-height: 1;
}

.od-progress-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tc-part .od-progress-item[data-state="done"],
.tc-part .od-progress-item[data-state="current"] {
  border-top-color: var(--structure);
}

.tc-part .od-progress-item[data-state="done"] {
  color: var(--ink-muted);
}

.od-progress-item[data-state="done"] .od-progress-mark {
  border-color: var(--structure);
  background: var(--structure);
  color: transparent;
}

.od-progress-item[data-state="done"] .od-progress-mark::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 9px;
  border: solid var(--sheet);
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -60%) rotate(45deg);
}

.tc-part .od-progress-item[data-state="current"] {
  color: var(--ink);
  font-weight: var(--fw-semibold);
}

.od-progress-item[data-state="current"] .od-progress-mark {
  border-color: var(--structure);
  background: var(--wash);
  color: var(--structure);
}

@media (min-width: 480px) {
  .tc-part .od-progress-item {
    flex-direction: row;
    align-items: center;
    font-size: var(--fs-body-s);
  }
}

.od-note,
.od-quote,
.od-order-summary,
.od-switch {
  margin: 0 0 var(--sp-4);
}

.od-note,
.od-order-summary,
.od-result,
.od-switch {
  padding: var(--sp-4) var(--sp-5);
  border-left: 3px solid var(--structure);
  background: var(--wash);
  color: var(--ink);
}

.od-quote {
  color: var(--ink);
}

.od-order-price {
  margin: 0 0 var(--sp-4);
  color: var(--ink);
  font-size: var(--fs-h3);
  font-weight: var(--fw-semibold);
  line-height: 1.25;
}

.od-general a,
.od-error a,
.od-note a,
.od-result a {
  color: inherit;
  text-decoration: underline;
}

.od .od-packages {
  display: grid;
  gap: var(--sp-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.od .od-packages li + li {
  margin-top: 0;
}

.od .od-package {
  display: block;
  width: 100%;
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: var(--fw-semibold);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.od .od-package:hover {
  border-color: var(--action);
  color: var(--action);
}

.od .od-package:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

/* Forms */

.od-form {
  display: grid;
  gap: var(--sp-5);
}

.od-field {
  display: grid;
  gap: var(--sp-2);
  min-width: 0;
}

.od-field label {
  color: var(--ink);
  font-weight: var(--fw-medium);
}

.od-field input,
.od-field textarea {
  width: 100%;
  padding: var(--sp-3);
  border: 1px solid var(--ink-faint);
  border-radius: var(--r-md);
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
}

.od-field textarea {
  min-height: 7em;
  resize: vertical;
}

.od-field input:focus-visible,
.od-field textarea:focus-visible {
  border-color: var(--action);
  outline: 2px solid var(--action);
  outline-offset: 2px;
}

.od-field [aria-invalid="true"] {
  border: 2px solid var(--od-danger);
}

.od-listings {
  display: grid;
  gap: var(--sp-4);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.od-listings #od-listing-fields {
  display: grid;
  gap: var(--sp-4);
}

.od-listings legend {
  padding: 0;
  color: var(--ink);
  font-weight: var(--fw-medium);
}

/* Address picker under a listing field: suggestions, then the address, its floor and area controls, and the parts. */

.od-picker {
  display: grid;
  gap: var(--sp-2);
  min-width: 0;
}

.od-picker:empty {
  display: none;
}

.od-suggestions {
  display: grid;
  margin: 0;
  padding: var(--sp-1);
  list-style: none;
  border: 1px solid var(--ink-faint);
  border-radius: var(--r-md);
  background: var(--sheet-raised);
}

.od-suggestion {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--ink);
  cursor: pointer;
}

.od-suggestion:hover,
.od-suggestion[aria-selected="true"] {
  background: var(--wash);
  box-shadow: inset 3px 0 0 var(--action);
}

.od-picker-stage {
  display: grid;
  min-width: 0;
}

.od-picked {
  display: grid;
  gap: var(--sp-3);
  min-width: 0;
  padding: var(--sp-3) var(--sp-4);
  border-left: 3px solid var(--action);
  background: var(--wash);
}

.od-picked-address {
  color: var(--ink);
  font-weight: var(--fw-medium);
}

.od-picked-label {
  color: var(--ink-muted);
}

.od-picker-field {
  display: grid;
  gap: var(--sp-1);
}

.od-picked .od-picker-field label {
  color: var(--ink);
  font-weight: var(--fw-medium);
}

.od-picked select {
  width: 100%;
  padding: var(--sp-3);
  border: 1px solid var(--ink-faint);
  border-radius: var(--r-md);
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
}

.od-picked select:focus-visible {
  border-color: var(--action);
  outline: 2px solid var(--action);
  outline-offset: 2px;
}

.od-matches {
  display: grid;
  gap: var(--sp-2);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.od-matches legend {
  padding: 0;
  color: var(--ink);
  font-weight: var(--fw-medium);
}

.od-matches-list {
  display: grid;
  gap: var(--sp-2);
}

.od-match {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-3);
  align-items: start;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: var(--sheet);
  color: var(--ink);
}

.od-match input {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0.15rem 0 0;
  padding: 0;
  border: 0;
  accent-color: var(--action);
}

.od-match input:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
}

.od-match label {
  min-width: 0;
  font-weight: normal;
  cursor: pointer;
}

.od-matches .od-secondary {
  justify-self: start;
}

.od-picked .od-link {
  justify-self: start;
}

.od-hint,
.od-notice,
.od-switch-fine {
  font-size: var(--fs-body-s);
  color: var(--ink-faint);
}

.od-notice {
  color: var(--ink-muted);
}

.od-error {
  font-size: var(--fs-body-s);
  color: var(--od-danger);
}

.od-error:empty,
.od-note:empty,
.od-result:empty {
  display: none;
}

.od-general {
  padding: var(--sp-3) var(--sp-4);
  border-left: 3px solid var(--od-danger);
}

.od-check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-3);
  align-items: start;
  color: var(--ink);
}

.od-check input {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0.15rem 0 0;
  accent-color: var(--action);
}

.od-check input[aria-invalid="true"] {
  outline: 2px solid var(--od-danger);
  outline-offset: 2px;
}

.od-check input:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
}

.od-check label {
  min-width: 0;
}

.od-check a {
  color: var(--action);
}

.od-turnstile {
  min-width: 0;
}

/* Buttons */

.od-button,
.od-secondary {
  display: inline-block;
  max-width: 100%;
  min-height: 44px;
  padding: var(--sp-3) var(--sp-6);
  border: 0;
  border-radius: var(--r-pill);
  font: inherit;
  font-weight: var(--fw-semibold);
  line-height: var(--lh-heading);
  text-align: center;
  cursor: pointer;
}

.od-button {
  background: var(--od-button);
  color: var(--od-button-ink);
  box-shadow: var(--shadow-ember);
  transition: background-color var(--dur-fast) var(--ease-out);
}

.od-button:hover {
  background: var(--od-button-hover);
}

.od-secondary {
  border: 1px solid var(--ink-faint);
  background: transparent;
  color: var(--ink);
}

.od-secondary:hover {
  border-color: var(--action);
  color: var(--action);
}

.od-button:focus-visible,
.od-secondary:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.od-button:disabled,
.od-secondary:disabled {
  opacity: 0.6;
  cursor: progress;
  box-shadow: none;
}

.od-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
}

/* The question before an open order gives way to another package: the card keeps the note surface, and its last row
   sits flush with the card's padding. */
.od-switch .od-actions {
  margin-bottom: 0;
}

/* Conversation: a framed chat. The frame has no overflow, so the message box can stick to the bottom of the modal's
   scroller. */

.od-chat-frame {
  min-width: 0;
  border: 1px solid var(--rule);
  border-radius: var(--r-xl);
  background: var(--sheet-raised);
}

.tc-part .od-chat-frame p {
  margin: 0;
}

.od-chat-head {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--rule);
}

.od-mark {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  background: var(--wash);
  color: var(--structure);
}

.od-chat-name {
  color: var(--ink);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-heading);
}

.od-chat-sub {
  color: var(--ink-faint);
  font-size: var(--fs-caption);
  line-height: var(--lh-heading);
}

/* The summary at the top of the frame on the order step; the log's top rule is the one line between it and the
   messages. */
.od-pinned {
  padding: var(--sp-4) var(--sp-5) 0;
}

.tc-part .od-pinned p {
  margin: 0 0 var(--sp-3);
}

.od-pinned .od-rows {
  margin: 0;
}

.od-pinned .od-rows > div:last-child {
  border-bottom: 0;
}

.od-pinned:not([hidden]) + .od-log {
  border-top: 1px solid var(--rule);
}

/* The summary and the last pair rise into place when the summary first arrives; the keyframe ends at the resting
   state, so nothing stays offset when the class outlives the animation. */
.od-arriving .od-pinned,
.od-arriving .od-log .od-msg:not([hidden]) {
  animation: od-arrive calc(var(--dur-med) * 1.25) var(--ease-out) backwards;
}

@keyframes od-arrive {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.od-log {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  box-sizing: border-box;
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
}

.od-msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  max-width: 100%;
  color: var(--ink);
}

.od-msg + .od-msg-client,
.od-msg-client + .od-msg-assistant {
  margin-top: var(--sp-2);
}

.od-msg-client {
  align-items: flex-end;
}

.od-msg .od-text {
  max-width: min(88%, 62ch);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-xl);
}

.od-msg-assistant .od-text {
  border-top-left-radius: var(--r-sm);
  background: var(--wash);
}

.od-msg-client .od-text {
  border-top-right-radius: var(--r-sm);
  background: var(--od-client);
}

.od-msg-client .od-edit {
  margin: var(--sp-1) var(--sp-1) 0 0;
}

.od-msg.od-later {
  opacity: 0.38;
}

.od-msg.od-editing .od-text {
  box-shadow: 0 0 0 2px var(--action);
}

.od-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* A message that arrives while the view is open rises into place. */
.od-new {
  animation: od-rise calc(var(--dur-med) * 1.25) var(--ease-out) backwards;
}

.od-msg-client.od-new {
  animation-name: od-rise-right;
}

@keyframes od-rise {
  from {
    opacity: 0;
    transform: translate(-6px, 10px);
  }
}

@keyframes od-rise-right {
  from {
    opacity: 0;
    transform: translate(6px, 10px);
  }
}

/* Three dots in the look of an assistant message; the words stay in the status element for screen readers. */
.od-typing {
  margin: 0 0 var(--sp-3);
  padding: 0 var(--sp-5);
}

.od-typing-bubble {
  display: inline-flex;
  gap: var(--sp-2);
  align-items: center;
  padding: var(--sp-4);
  border-radius: var(--r-xl);
  border-top-left-radius: var(--r-sm);
  background: var(--wash);
}

.od-dot {
  width: var(--sp-2);
  height: var(--sp-2);
  border-radius: var(--r-pill);
  background: var(--ink-muted);
  animation: od-dot-pulse calc(var(--dur-slow) * 3) var(--ease-in-out) infinite;
}

.od-dot:nth-child(2) {
  animation-delay: var(--dur-slow);
}

.od-dot:nth-child(3) {
  animation-delay: calc(var(--dur-slow) * 2);
}

@keyframes od-dot-pulse {
  0%,
  60%,
  100% {
    opacity: 0.3;
  }

  30% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .od-new {
    animation: none;
  }

  .od-arriving .od-pinned,
  .od-arriving .od-log .od-msg:not([hidden]) {
    animation: none;
  }

  .od-dot {
    animation: none;
    opacity: 0.6;
  }
}

.od-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Answer options under the open question */

.od-choices {
  display: grid;
  gap: var(--sp-3);
  min-width: 0;
  max-width: 100%;
  margin: 0 0 var(--sp-3);
  padding: 0 var(--sp-5);
  border: 0;
}

.od-choices legend {
  padding: 0;
  margin-bottom: var(--sp-3);
  color: var(--ink-muted);
  font-size: var(--fs-body-s);
  font-weight: var(--fw-medium);
}

.od-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.od-chip {
  min-height: 44px;
  max-width: 100%;
  padding: var(--sp-2) var(--sp-5);
  border: 1px solid var(--ink-faint);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.od-chip:hover {
  border-color: var(--action);
  color: var(--action);
}

.od-chip[aria-pressed="true"] {
  border-color: var(--action);
  background: var(--wash);
}

.od-chip:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
}

.od-chip:disabled {
  opacity: 0.6;
  cursor: progress;
}

.od-checks {
  display: grid;
  gap: var(--sp-1);
}

.od-checks .od-check {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
}

.od-checks .od-check:hover {
  background: var(--wash);
}

.od-checks .od-check label {
  cursor: pointer;
}

.od-checks .od-check input:disabled,
.od-checks .od-check input:disabled + label {
  opacity: 0.6;
  cursor: progress;
}

.od-editnote {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  align-items: baseline;
  padding: var(--sp-3) var(--sp-4);
  border-left: 3px solid var(--action);
  background: var(--wash);
  color: var(--ink);
  font-size: var(--fs-body-s);
}

/* The message box is docked: it sticks to the bottom of the modal's scroller while the conversation scrolls under it. */

.od-chat-form {
  position: sticky;
  bottom: 0;
  z-index: 2;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--rule);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  background: var(--sheet-raised);
}

.od-chat-form .od-field {
  gap: var(--sp-2);
}

.od-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--sp-3);
  align-items: end;
}

.od-chat-form .od-box textarea {
  min-height: 0;
  max-height: 40vh;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-xl);
  line-height: 1.4;
  resize: none;
  overflow-y: auto;
}

.od-send {
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--od-button);
  color: var(--od-button-ink);
  font: inherit;
  font-size: var(--fs-h3);
  font-weight: var(--fw-semibold);
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.od-send:hover {
  background: var(--od-button-hover);
}

.od-send:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.od-send:disabled {
  opacity: 0.6;
  cursor: progress;
}

.od-under {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-4);
  justify-content: space-between;
}

.od-under .od-hint {
  font-size: var(--fs-caption);
}

.od-link {
  padding: var(--sp-1) 0;
  border: 0;
  background: none;
  color: var(--action);
  font: inherit;
  font-size: var(--fs-body-s);
  font-weight: var(--fw-medium);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.od-link:hover {
  color: var(--action-hover);
}

.od-link:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
}

.od-link:disabled {
  opacity: 0.6;
  cursor: progress;
}

.od-over {
  color: var(--od-danger);
}

/* Summary */

.od-rows {
  display: grid;
  margin: 0 0 var(--sp-4);
  border-top: 1px solid var(--rule);
}

.od-rows > div {
  display: grid;
  gap: var(--sp-1);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--rule);
}

.od-rows dt {
  color: var(--ink-muted);
  font-size: var(--fs-body-s);
  font-weight: var(--fw-medium);
}

.od-rows dd {
  margin: 0;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* A row the assistant changed in its last answer, until the client writes again. */
.od-rows > .od-row-updated {
  margin: 0 calc(-1 * var(--sp-3));
  padding-right: var(--sp-3);
  padding-left: var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--wash);
}

.od-row-mark {
  margin-left: var(--sp-1);
  color: var(--action);
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
}

.od-restart {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-4);
  margin-top: var(--sp-10);
  font-size: var(--fs-body-s);
}

.od-restart-confirm {
  display: grid;
  gap: var(--sp-4);
  justify-items: start;
  box-sizing: border-box;
  max-width: min(46ch, 100%);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--od-danger);
  border-radius: 0 var(--r-lg) var(--r-lg) 0;
  background: var(--sheet-raised);
  font-size: var(--fs-body);
}

.od-restart-confirm p {
  margin: 0;
}

.od-restart a {
  color: var(--action);
}

@media (min-width: 640px) {
  .od-rows > div {
    grid-template-columns: minmax(10rem, 1fr) 2fr;
    gap: var(--sp-4);
  }
}

@media (max-width: 480px) {
  .legal-header,
  .legal-sheet,
  .legal-footer {
    padding-left: var(--sp-4);
    padding-right: var(--sp-4);
  }

  .od-button,
  .od-secondary,
  .od-chip {
    width: 100%;
  }

  .od-restart .od-secondary {
    width: auto;
  }

  .od-restart-confirm .od-secondary {
    width: 100%;
  }

  .od-actions {
    flex-direction: column;
  }
}
