/* ============================================================
   Story of US - submission wizard and fixed thank-you signature
   ============================================================ */

.submit-hero {
  padding-block: clamp(2.5rem, 6vw, 4.5rem) 1rem;
  text-align: left;
}

.submit-hero h1 {
  max-width: 14ch;
  font-size: clamp(2.35rem, 5vw, 4rem);
  line-height: 0.98;
  letter-spacing: -0.035em;
  text-wrap: balance;
  margin-bottom: clamp(1.35rem, 3vw, 2rem);
}

.submit-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: start;
}

.submit-intro p {
  max-width: 58ch;
  color: var(--ink-body);
  margin: 0;
  text-wrap: pretty;
}

.submit-intro p:last-child {
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.submit-section {
  padding-block: clamp(2rem, 5vw, 3.25rem) 5rem;
}

/* --- Wizard shell: a quiet document, structured by hairlines only --- */

.wizard {
  min-width: 0;
}

.wizard-errors {
  background: rgba(163, 45, 45, 0.08);
  border: 1px solid var(--error);
  border-radius: var(--radius-input);
  color: var(--error);
  font-weight: 600;
  padding: 1rem 1.2rem;
  margin-bottom: 1.6rem;
}

.wizard-errors p {
  margin: 0;
}

/* --- Progress --- */

.wizard-progress {
  margin-bottom: 2.4rem;
}

/* The legend below already names the section, so this carries only the count
   and the functional progress track. */

.wizard-progress-count {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  font-family: var(--font-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--ink-muted);
  margin: 0 0 0.65rem;
}

.wizard-progress-count [data-progress-current] {
  color: var(--red);
}

.wizard-progress-slash {
  padding-inline: 0.3rem;
}

.wizard-progress-track {
  height: 2px;
  border-radius: var(--radius-pill);
  background: var(--hairline);
  overflow: hidden;
}

.wizard-progress-fill {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--red);
  transform: scaleX(0.125);
  transform-origin: left center;
  transition: transform 280ms var(--ease-out);
  will-change: transform;
}

/* --- Steps --- */

.wizard-step {
  min-width: 0;
  border: 0;
  padding: 0;
  margin: 0 0 2.6rem;
  min-inline-size: 0;
}

.wizard-step legend {
  max-width: 100%;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  color: var(--ink);
  margin-bottom: 1rem;
  padding: 0;
}

.wizard-step legend:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 5px;
  border-radius: 2px;
}

.step-count {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 0.35rem;
}

.step-optional {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.step-note {
  color: var(--ink-muted);
  font-size: 0.95rem;
  margin-bottom: 1.6rem;
}

html.js-enabled .wizard[data-wizard] .wizard-step {
  display: none;
}

html.js-enabled .wizard[data-wizard] .wizard-step.is-current {
  display: block;
}

html.js-enabled .wizard.is-wizard .wizard-step.is-current.is-step-enter {
  animation: step-in 280ms var(--ease-out);
}

html.js-enabled .wizard.is-wizard .wizard-step.is-current.from-prev.is-step-enter {
  animation-name: step-in-reverse;
}

@keyframes step-in {
  from {
    opacity: 0;
    transform: translateX(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes step-in-reverse {
  from {
    opacity: 0;
    transform: translateX(-14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --- Fields --- */

/* Narrative prompts are questions, not labels. Section 1 keeps the compact sans
   labels so factual fields still read as a form and the interview stands apart. */

.field-prompt {
  margin-bottom: 2.6rem;
}

.field-prompt > label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-wrap: balance;
  margin-bottom: 0.5rem;
}

.field-prompt > .field-hint {
  max-width: 62ch;
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
}

.wizard-step > .field:last-child,
.wizard-step > .field-quote:last-child,
.wizard-step > .field-blank:last-child {
  margin-bottom: 0;
}

/* Section 6 composes the sentence that becomes the story's pull quote, so it is
   set here in the voice it will be published in. */

.field-quote {
  margin-bottom: 2.6rem;
}

.field-quote-mark {
  display: block;
  font-family: var(--font-display);
  font-size: 4.5rem;
  line-height: 0.4;
  padding-top: 1.4rem;
  color: var(--red);
}

.field-quote .field-prompt,
.field-blank .field-prompt {
  margin-bottom: 0;
}

.field-quote .field-prompt > label {
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  line-height: 1.2;
  margin-bottom: 0.9rem;
}

.field-quote textarea {
  min-height: 6.5rem;
  height: 6.5rem;
  padding: 0.4rem 0 0.7rem;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.2rem, 2.6vw, 1.5rem);
  line-height: 1.4;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid var(--hairline-strong);
  border-radius: 0;
}

/* "This nation is ___." is a blank to fill, not a box to complete. */

.field-blank {
  margin-bottom: 2.6rem;
}

.field-blank input[type="text"] {
  padding: 0.5rem 0 0.6rem;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  line-height: 1.3;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid var(--hairline-strong);
  border-radius: 0;
}

.field-quote textarea:focus,
.field-blank input[type="text"]:focus {
  border-bottom-color: var(--red);
  box-shadow: none;
}

.field-quote textarea::placeholder,
.field-blank input[type="text"]::placeholder {
  font-style: italic;
  color: var(--ink-muted);
}

.field-quote .has-error textarea,
.field-blank .has-error input[type="text"] {
  border-bottom-color: var(--error);
}

.field-row {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.2rem;
}

.field,
.field-row > *,
.choice-field,
.required-tag-group {
  min-width: 0;
}

.city-autocomplete {
  position: relative;
  min-width: 0;
}

.city-suggestions {
  position: absolute;
  z-index: 12;
  inset: calc(100% - 1rem) 0 auto;
  overflow: hidden;
  max-height: min(19rem, 46vh);
  overflow-y: auto;
  background: var(--paper-raised);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-input);
  box-shadow: var(--shadow-soft);
}

.city-suggestions ul {
  list-style: none;
  margin: 0;
  padding: 0.35rem;
}

.city-suggestion {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  border: 0;
  border-radius: calc(var(--radius-input) - 3px);
  background: transparent;
  color: var(--ink-body);
  font: inherit;
  text-align: left;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
}

.city-suggestion:hover,
.city-suggestion[aria-selected="true"] {
  background: var(--paper-deep);
  color: var(--ink);
}

.required-tag-group {
  border-radius: var(--radius-input);
}

.required-tag-group[aria-invalid="true"] {
  outline: 2px solid var(--error);
  outline-offset: 5px;
}

.required-tag-group:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 5px;
}

.choice-field .choice-label {
  display: block;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.7rem;
  font-size: 0.95rem;
}

/* Django renders radio and checkbox groups as div > div > label, so .choice-list
   is the wrapper we control and its single child div is the option container. */

.choice-list > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 1.2rem;
}

.choice-list > div > div,
.choice-list label {
  min-width: 0;
}

.choice-list label {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-weight: 400;
  color: var(--ink-body);
  font-size: 0.97rem;
  margin: 0;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.choice-list input[type="radio"],
.choice-list input[type="checkbox"],
.consent-option input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.18rem;
  accent-color: var(--red);
  flex: none;
}

/* Identity and generation choices reuse the map page's .filter-tag pill, since
   the site has one interactive shape. The :has() guard matters: without it a
   browser would render pills that never show a selected state, so unsupported
   browsers keep the plain checkbox list instead. */

@supports selector(:has(*)) {
  .choice-list > div {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
  }

  .choice-list > div > div {
    display: flex;
    max-width: 100%;
  }

  .choice-list label {
    position: relative;
    min-height: 44px;
    max-width: 100%;
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 0.42rem 1rem;
    border: 1.5px solid var(--hairline-strong);
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink);
    text-align: left;
    transition:
      background-color var(--dur-state) var(--ease-out),
      color var(--dur-state) var(--ease-out),
      border-color var(--dur-state) var(--ease-out);
  }

  .choice-list label:has(input:checked) {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--on-ink);
  }

  .choice-list label:has(input:focus-visible) {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
  }

  .choice-field.has-error .choice-list label {
    border-color: var(--error);
  }

  .choice-list input[type="radio"],
  .choice-list input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  @media (hover: hover) and (pointer: fine) {
    .choice-list label:hover {
      border-color: var(--ink);
    }
  }
}

/* The plate carries the drop-zone chrome so the file input can stay bare and
   the chosen file can be shown back rather than just named by the browser. */

.upload-plate {
  padding: 1rem;
  background: var(--paper-deep);
  border: 1.5px dashed var(--hairline-strong);
  border-radius: var(--radius);
}

.upload-plate:focus-within {
  border-style: solid;
  border-color: var(--ink);
}

.upload-field.has-error .upload-plate {
  border-color: var(--error);
}

.upload-preview {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--hairline);
  animation: upload-preview-in 180ms var(--ease-out);
}

@keyframes upload-preview-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.upload-thumb {
  width: 96px;
  height: 96px;
  flex: none;
  object-fit: cover;
  border-radius: var(--radius-input);
  background: var(--ink-wash);
}

.upload-meta {
  min-width: 0;
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-body);
  overflow-wrap: anywhere;
}

.upload-field input[type="file"] {
  max-width: 100%;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 0.95rem;
  color: var(--ink-body);
  cursor: pointer;
}

.upload-field input[type="file"]::file-selector-button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--on-ink);
  font: inherit;
  font-weight: 600;
  padding: 0.45rem 1.1rem;
  margin-right: 1rem;
  cursor: pointer;
}

.consent-field {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-input);
  padding: 1rem 1.2rem;
}

.consent-option {
  min-height: 44px;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  font-weight: 500;
  color: var(--ink-body);
  margin: 0;
  cursor: pointer;
}

.wizard-security {
  min-width: 0;
  margin-top: 2rem;
  overflow: visible;
}

.wizard-security .cf-turnstile {
  width: 100%;
  max-width: 100%;
}

html.js-enabled .wizard.is-wizard .step-count {
  display: none;
}

.wizard-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  border-top: 1px solid var(--hairline);
  padding-top: 1.8rem;
}

.wizard-nav .button {
  min-width: 0;
  min-height: 48px;
}

/* Keeps the forward action on the right whether or not Back is in the flow. */
.wizard-nav [data-wizard-next],
.wizard-submit {
  margin-left: auto;
}

.wizard-submit.is-sending {
  opacity: 0.7;
  pointer-events: none;
}

/* --- Thank-you page: one fixed 0, no particle field --- */

.thanks-section {
  min-height: 60vh;
  padding-block: 5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.thanks-mark {
  width: 112px;
  margin-bottom: 1.6rem;
}

.thanks-mark .brand-mark {
  display: block;
  width: 100%;
  height: auto;
}

.thanks-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.thanks-section p {
  max-width: 52ch;
  margin-inline: auto;
}

.thanks-actions {
  margin-top: 2.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

.thanks-actions .button {
  min-height: 48px;
}

@media (max-width: 640px) {
  .submit-hero {
    padding-block: 2rem 0.75rem;
  }

  .submit-hero h1 {
    font-size: clamp(2.2rem, 11vw, 3.15rem);
    line-height: 1;
  }

  .submit-intro {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .submit-section {
    padding-block: 1.75rem 3.5rem;
  }

  .field-row,
  .choice-list > div {
    grid-template-columns: minmax(0, 1fr);
  }

  .city-suggestions {
    max-height: min(17rem, 40vh);
  }

  .wizard-nav {
    flex-direction: column-reverse;
    gap: 0.6rem;
  }

  .wizard-nav .button {
    width: 100%;
    min-height: 44px;
    padding-inline: 0.55rem;
  }

  .wizard-nav [data-wizard-next],
  .wizard-submit {
    margin-left: 0;
  }

  .upload-plate {
    padding: 0.85rem;
  }

  .upload-thumb {
    width: 72px;
    height: 72px;
  }

  .upload-field input[type="file"] {
    font-size: 0.85rem;
  }

  .upload-field input[type="file"]::file-selector-button {
    display: block;
    width: 100%;
    margin: 0 0 0.65rem;
  }

  .thanks-section {
    min-height: calc(100dvh - 72px);
    padding-block: 3.5rem max(3rem, env(safe-area-inset-bottom));
  }

  .thanks-actions {
    width: min(100%, 300px);
    flex-direction: column;
  }

  .thanks-actions .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wizard-progress-fill,
  .choice-list label {
    transition: none;
  }

  .upload-preview {
    animation: none;
  }

  html.js-enabled .wizard.is-wizard .wizard-step.is-current.is-step-enter,
  html.js-enabled .wizard.is-wizard .wizard-step.is-current.from-prev.is-step-enter {
    animation: none;
  }
}
