/* ============================================================
   INTAKE WIZARD — styles for the site-plan.md §11.1 component.
   Colour: the 13 semantic slots only (CLR-01). Zero raw values.
   Requires: styles/primitives.css + styles/tokens/<division>.css
             + styles/tokens/motion.css (durations, easings, faces,
             scale stops — this file declares none of its own)
   ============================================================ */

/* Self-contained box model, for the same reason as rail.css: the
   panel and fields are sized from tokens and must not depend on the
   host page carrying a reset. */
.intake,
.intake *,
.intake *::before,
.intake *::after,
.intake-modal,
.intake-modal *,
.intake-modal *::before,
.intake-modal *::after { box-sizing: border-box; }

.intake {
  --intake-pad: 1.25rem;
  --intake-gap: 0.75rem;
  --intake-radius: 0.75rem;
  --step-dir: 1;

  display: block;
  background: var(--surface-1);
  color: var(--text-hi);
  font-family: var(--face-body);
  /* TYP-03: no exceptions — this component collects a timestamp. */
  font-variant-numeric: tabular-nums;
  padding: var(--intake-pad);
}

/* ---------- head + progress ------------------------------------- */

.intake__eyebrow {
  margin: 0;
  font-family: var(--face-mono);
  font-size: var(--fs-label);
  line-height: 1.3;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.intake__title {
  margin: 0.25rem 0 0;
  font-family: var(--face-display);
  font-size: var(--fs-display-md);
  line-height: 1.25;
  font-weight: 600;
  color: var(--text-hi);
}

.intake__dots {
  display: flex;
  gap: 0.375rem;
  margin-block: 0.875rem;
}

.intake__dot {
  inline-size: 1.5rem;
  block-size: 0.1875rem;
  border-radius: 999px;
  background: var(--surface-3);
  transition: background-color var(--t-fast) var(--e-out);
}

.intake__dot.is-on { background: var(--interactive); }

/* The current step reads as the brightest thing in the row; the
   completed ones stay accent but quieter (CLR-03 formula). */
.intake__dot.is-on:not(.is-current) { opacity: 0.5; }

/* Screen-reader progress. The dots carry it visually. */
.intake__progress {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- panes + MTN-07 step travel --------------------------- */

.intake__panes {
  /* Holds the frame steady while a pane swaps, so the dialog never
     collapses between steps. Not animated (MTN-09). */
  min-block-size: 15rem;
}

.intake__pane {
  display: block;
  opacity: 1;
  transform: none;
  transition: opacity var(--t-base) var(--e-out), transform var(--t-base) var(--e-out);
}

/* Forward (--step-dir 1): the outgoing pane pushes left and the
   incoming one arrives from the right. Back inverts both, because
   --step-dir flips to -1. MTN-07, 28px. */
.intake__pane.is-leaving {
  opacity: 0;
  transform: translateX(calc(-28px * var(--step-dir)));
  transition: opacity var(--t-fast) var(--e-in), transform var(--t-fast) var(--e-in);
}

.intake__pane.is-entering {
  opacity: 0;
  transform: translateX(calc(28px * var(--step-dir)));
  transition: none;
}

/* ---------- option lists (steps 1 and 2) ------------------------- */

.intake__options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.intake__group {
  margin: 0.75rem 0 0;
  font-family: var(--face-mono);
  font-size: var(--fs-label);
  line-height: 1.3;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.intake__option {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  inline-size: 100%;
  padding: 0.75rem 0.875rem;
  text-align: start;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  --hover-base: var(--surface-2);
  background: var(--hover-base);
  color: var(--text-hi);
  font-family: inherit;
  transition: background-color var(--t-fast) var(--e-out), transform var(--t-instant) var(--e-out);
}

.intake__option-label {
  font-size: var(--fs-body);
  line-height: 1.4;
  font-weight: 500;
}

.intake__option-hint {
  font-size: var(--fs-body-sm);
  line-height: 1.5;
  color: var(--text-dim);
}

@media (hover: hover) and (pointer: fine) {
  .intake__option:hover { background: color-mix(in oklab, var(--hover-base), var(--hover-pole, white) 6%); }
}

.intake__option:active { transform: scale(0.965); }

/* Returning via Back must show what was chosen. Accent edge rather
   than a second border colour (CLR-06). */
.intake__option[aria-pressed='true'] {
  border-color: var(--interactive);
  box-shadow: inset 2px 0 0 var(--interactive);
}

/* ---------- review line ------------------------------------------ */

.intake__review {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding-block-end: 0.75rem;
  border-block-end: 1px solid var(--border);
  font-size: var(--fs-body-sm);
  line-height: 1.5;
  color: var(--text-dim);
}

.intake__review-part { color: var(--text-hi); }

.intake__review-sep { color: var(--border); }

.intake__review-route {
  font-family: var(--face-mono);
  font-size: var(--fs-label);
  line-height: 1.3;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--link-gold, var(--interactive));
}

/* ---------- fields (CMP-03) -------------------------------------- */

.intake__form {
  display: flex;
  flex-direction: column;
  gap: var(--intake-gap);
}

.intake__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.intake__label {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--face-mono);
  font-size: var(--fs-label);
  line-height: 1.3;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.intake__optional {
  letter-spacing: 0.08em;
  opacity: 0.7;
}

.intake__input {
  inline-size: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  /* CMP-03: fields sit one surface up. */
  background: var(--surface-2);
  color: var(--text-hi);
  font-family: inherit;
  font-size: var(--fs-body);
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--t-fast) var(--e-out);
}

.intake__input--area {
  resize: vertical;
  min-block-size: 4.5rem;
  line-height: 1.5;
}

.intake__input::placeholder { color: var(--text-dim); }

/* The helper slot. The error message replaces this text in place —
   same element, so nothing below it shifts. */
.intake__help {
  margin: 0;
  font-size: var(--fs-body-sm);
  line-height: 1.5;
  color: var(--text-dim);
}

.intake__field.is-error .intake__input { border-color: var(--danger); }

.intake__field.is-error .intake__help { color: var(--danger); }

/* ---------- submit failure --------------------------------------- */

.intake__formerror {
  margin: 0;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--danger);
  border-radius: 0.5rem;
  background: var(--surface-2);
  font-size: var(--fs-body-sm);
  line-height: 1.5;
  color: var(--text-hi);
}

/* THE WAY THROUGH, ON ITS OWN LINES. Three regions, because a visitor
   who cannot use the form should not also have to guess which of three
   people is theirs. The label is dim and the address is the room's
   link: the region is a signpost, the address is the thing to press. */
.intake__fallback {
  display: block;
  margin-block-start: 0.5rem;
  color: var(--text-dim);
}

.intake__fallback-list {
  display: grid;
  gap: 0.375rem;
  margin-block-start: 0.25rem;
}

/* THE REGION SITS ABOVE ITS ADDRESS, not beside it. Side by side, the
   longest label and the longest address are wider than a 198px card
   and the address is one unbroken token — so it clipped rather than
   wrapped, and the address you could not read was the first one. */
.intake__fallback-line {
  display: flex;
  flex-direction: column;
}

.intake__fallback-region {
  font-family: var(--face-mono);
  font-size: 0.6875rem;          /* 11px — TYP-02's floor is 10.5 */
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.intake__fallback-mail {
  /* An address has no spaces to break at, so it is told where it may. */
  overflow-wrap: anywhere;
  color: var(--link-gold, var(--interactive));
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.intake__ref {
  font-family: var(--face-mono);
  color: var(--text-dim);
}

/* ---------- buttons (CMP-01 / CMP-02) ---------------------------- */

.intake__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--intake-gap);
  margin-block-start: 0.5rem;
}

.intake__actions--solo { justify-content: flex-start; }

.intake__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-block-size: 2.75rem;
  padding: 0 1.125rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  --hover-base: transparent;
  background: var(--hover-base);
  color: var(--text-hi);
  font-family: inherit;
  font-size: var(--fs-body-sm);
  font-weight: 600;
  transition: background-color var(--t-fast) var(--e-out), transform var(--t-instant) var(--e-out);
}

.intake__btn--primary {
  border-color: var(--interactive);
  --hover-base: var(--interactive);
  background: var(--hover-base);
  color: var(--on-interactive);   /* CLR-03: never --surface-0 */
}

.intake__btn--ghost { border-color: var(--border); }

@media (hover: hover) and (pointer: fine) {
  .intake__btn:hover:not(:disabled) { background: color-mix(in oklab, var(--hover-base), var(--hover-pole, white) 6%); }
}

.intake__btn:active:not(:disabled) { transform: scale(0.965); }

/* CMP-01: loading keeps the label and the locked width; only the
   spinner is added. Never collapses to a lone spinner. */
.intake__btn.is-loading { opacity: 0.72; }

.intake__btn.is-loading::after {
  content: '';
  inline-size: 0.875rem;
  block-size: 0.875rem;
  border: 2px solid var(--on-interactive);
  border-block-start-color: transparent;
  border-radius: 50%;
  animation: intake-spin 0.7s linear infinite;
}

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

.intake__btn:focus-visible,
.intake__option:focus-visible,
.intake__input:focus-visible,
.intake-modal__close:focus-visible {
  /* CLR-03: ring follows the link fallback chain. */
  outline: 2px solid var(--link-gold, var(--interactive));
  outline-offset: 2px;            /* MTN-06: instant, never animated */
}

/* ---------- sent pane (STA-06: a state change, not a modal) ------ */

.intake__sent {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-block: 1rem;
}

.intake__sent-mark {
  margin: 0;
  font-size: var(--fs-display-lg);
  line-height: 1.15;
  color: var(--success);
}

.intake__sent-lead {
  margin: 0;
  font-family: var(--face-display);
  font-size: var(--fs-display-md);
  line-height: 1.25;
  font-weight: 600;
  color: var(--text-hi);
}

.intake__sent-body {
  margin: 0;
  max-inline-size: 42ch;
  font-size: var(--fs-body-sm);
  line-height: 1.5;
  color: var(--text-dim);
}

/* ============================================================
   MTN-07 modal shell
   ============================================================ */

.intake-modal {
  inset: 0;
  inline-size: 100%;
  max-inline-size: none;
  block-size: 100%;
  max-block-size: none;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: hidden;
}

/* The real scrim is an element, not ::backdrop, so it can be painted
   from a semantic slot and timed with the motion tokens. */
.intake-modal::backdrop { background: transparent; }

.intake-modal__scrim {
  position: absolute;
  inset: 0;
  background: var(--surface-0);
  opacity: 0;
  transition: opacity var(--t-base) var(--e-out);
}

.intake-modal.is-open .intake-modal__scrim { opacity: 0.72; }

.intake-modal.is-closing .intake-modal__scrim {
  opacity: 0;
  transition: opacity var(--t-fast) var(--e-in);
}

.intake-modal__panel {
  position: relative;
  inline-size: min(100% - 2rem, 30rem);
  max-block-size: min(90vh, 44rem);
  margin-inline: auto;
  margin-block: 5vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--intake-radius, 0.75rem);
  /* CLR-02: a floating layer is the one place a shadow belongs. */
  background: var(--surface-1);
  box-shadow: 0 1.5rem 3rem var(--surface-0);

  /* MTN-07: born in place — scales .96 -> 1 and rises 8px. */
  opacity: 0;
  transform: scale(0.96) translateY(8px);
  transition: opacity var(--t-base) var(--e-out), transform var(--t-base) var(--e-out);
}

.intake-modal.is-open .intake-modal__panel {
  opacity: 1;
  transform: none;
}

.intake-modal.is-closing .intake-modal__panel {
  opacity: 0;
  transform: scale(0.96) translateY(8px);
  transition: opacity var(--t-fast) var(--e-in), transform var(--t-fast) var(--e-in);
}

.intake-modal__close {
  position: absolute;
  inset-block-start: 0.5rem;
  inset-inline-end: 0.5rem;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 2.25rem;
  block-size: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  font-size: var(--fs-display-md);
  line-height: 1;
  transition: color var(--t-fast) var(--e-out);
}

/* No surface to mix against, so the icon's own colour is the hover. */
@media (hover: hover) and (pointer: fine) {
  .intake-modal__close:hover { color: var(--text-hi); }
}

/* ---------- MTN-01.6 reduced motion ------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .intake__pane,
  .intake__option,
  .intake__btn,
  .intake__dot,
  .intake__input,
  .intake-modal__scrim,
  .intake-modal__panel,
  .intake-modal__close {
    transition: none;
  }

  .intake__pane.is-leaving,
  .intake__pane.is-entering {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .intake__option:active,
  .intake__btn:active:not(:disabled) { transform: none; }

  .intake-modal__panel { transform: none; }

  .intake__btn.is-loading::after { animation-duration: 1.4s; }
}

/* ---------- >=48rem ---------------------------------------------- */

@media (min-width: 48rem) {
  .intake { --intake-pad: 1.75rem; }
  .intake-modal__panel { margin-block: 8vh; }
}
