/* Copyright (c) 2026 Brownie, LLC. All rights reserved. */

/*
 * The setup wizard (#/setup) and the Next steps card, from the approved
 * design (W1–W6, WP1, WP3, N1). Built on the tokens and components in
 * app.css, so dark mode follows them.
 */

/* ---------- The wizard has its own bar: no rail, tabs or top bar ---------- */

body.app[data-setup] {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "content";
  grid-template-rows: 1fr;
}

body.app[data-setup] .app-rail,
body.app[data-setup] .app-top-bar,
body.app[data-setup] .app-tabs {
  display: none;
}

body.app[data-setup] .app-content {
  padding: 0;
}

.setup {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

.setup-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -16px;
  padding: 12px clamp(16px, 3vw, 32px);
  background: var(--color-surface);
  /* The bar's white and its bottom line reach both edges of the window,
     while its brand and Finish later stay lined up with the column below.
     Shadows, unlike a wider box, never make the page scroll sideways. */
  box-shadow:
    0 0 0 100vmax var(--color-surface),
    0 1px 0 100vmax var(--color-border);
  clip-path: inset(0 -100vmax -1px);
}

.setup-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 700 1.6rem var(--font-display);
}

.setup-finish-later {
  display: flex;
  align-items: center;
  min-height: var(--size-control);
  color: var(--color-accent-strong);
  font-weight: 600;
}

/* ---------- Where you are ---------- */

.setup-steps ol {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.setup-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  color: var(--color-text-muted);
}

.setup-step.is-done {
  color: var(--color-text);
}

.setup-step.is-current {
  background: var(--color-accent-soft);
  color: var(--color-accent-strong);
}

.setup-step-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--color-control-border);
  border-radius: 50%;
  background: var(--color-surface);
  font-size: 0.8rem;
}

.setup-step.is-done .setup-step-dot,
.setup-step.is-current .setup-step-dot {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-on-accent);
}

/* On a phone: "Setup · step 3 of 5" and a bar, in place of the list. */
.setup-compact-progress {
  display: none;
  flex-direction: column;
  gap: 8px;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.setup-bar-track,
.next-steps-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  background: var(--color-track);
}

.setup-bar-track span,
.next-steps-bar span {
  border-radius: 3px;
  background: var(--color-accent);
}

/* ---------- A step ---------- */

.setup-intro {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setup-intro h1 {
  margin: 0;
  font: 700 2.5rem/1 var(--font-display);
}

.setup-intro h1:focus:not(:focus-visible) {
  outline: none;
}

.setup-intro p {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 1rem;
}

.setup-card {
  gap: 16px;
  padding: 20px 22px;
}

.setup-aside {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.setup-problems:empty {
  display: none;
}

.setup-problems p {
  margin: 0;
}

.setup-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.setup-actions.is-end {
  justify-content: flex-end;
}

.setup-actions-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.setup-skip {
  padding: 0 12px;
}

/* What are you setting up: three large choices. */
.setup-choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
}

.setup-choice {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  cursor: pointer;
}

.setup-choice:has(input:checked) {
  border: 2px solid var(--color-accent);
  padding: 17px 19px;
}

.setup-choice:has(input:disabled) {
  opacity: 0.6;
  cursor: default;
}

/* The wizard's radios and checkboxes: large, in the accent color. */
.setup input[type="radio"],
.setup input[type="checkbox"] {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--color-accent);
}

.setup-choice input {
  margin-top: 2px;
}

.setup-choice > span {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setup-choice b {
  font-size: 1.1rem;
}

.setup-choice > span > span {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
}

.setup-invited {
  margin: 0;
}

.setup-check {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--size-control);
}

.setup-grades {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin: 0;
  padding: 0;
  border: 0;
}

.setup-grades legend {
  margin-bottom: 6px;
  padding: 0;
  font-weight: 600;
}

.setup-grades legend span {
  color: var(--color-text-muted);
  font-weight: 400;
}

.setup-grades .form-field {
  flex: 0 1 180px;
}

.setup-grades .field-help {
  flex: 1 1 100%;
}

/* Archers: a row of fields per archer; labels show only on a phone. */
.setup-archer-rows,
.setup-invite-rows {
  display: grid;
  gap: 10px;
}

.setup-archer-row,
.setup-invite-row {
  display: grid;
  /* First name, Last name, then Gender, Grade, NASP #, School # and History ID. */
  grid-template-columns:
    repeat(2, minmax(0, 1.3fr)) minmax(0, 1fr) minmax(0, 1.25fr)
    repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.setup-invite-row {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

.setup-archer-row .form-field input,
.setup-archer-row .form-field select {
  width: 100%;
}

/* "Row 2": what the step's errors call each row. */
.setup-row-number {
  margin-bottom: 4px;
  padding: 0;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.setup-archer-row:not(:first-child) .form-field > label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.setup-added,
.setup-team-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  list-style: none;
}

.setup-team-list {
  padding: 0;
  border: 0;
  border-top: 1px solid var(--color-divider);
  border-radius: 0;
}

.setup-added li,
.setup-team-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  min-height: 52px;
  border-bottom: 1px solid var(--color-divider);
}

.setup-added li:last-child {
  border-bottom: 0;
}

.setup-added li span {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.setup-team-list li b {
  flex: 1;
}

.setup-csv {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border: 1px dashed var(--color-control-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
}

.setup-csv-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 480px;
}

.setup-csv-text span {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

.setup-csv-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.setup-csv-buttons a {
  display: inline-flex;
  align-items: center;
  min-height: var(--size-control);
  padding: 0 6px;
  color: var(--color-accent-strong);
  font-weight: 600;
}

.setup-csv-status {
  flex: 1 1 100%;
  margin: 0;
}

.setup-csv-status:empty {
  display: none;
}

/* Teams: name, format and Add on one line. */
.setup-team-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.setup-team-form > .form-field {
  flex: 1 1 260px;
}

.setup-format {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.setup-format legend {
  margin-bottom: 6px;
  padding: 0;
  font-weight: 600;
}

.setup-format-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
}

.setup-format-choice:has(input:checked) {
  border: 2px solid var(--color-accent);
  padding: 0 13px;
}

.setup-roles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 10px 24px;
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--color-divider);
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

.setup-roles dt {
  color: var(--color-text);
  font-weight: 700;
}

.setup-roles dd {
  margin: 2px 0 0;
}

.setup-summary {
  padding: 6px 22px;
}

.setup-summary dl {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.setup-summary dl > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
  border-bottom: 1px solid var(--color-divider);
}

.setup-summary dl > div:last-child {
  border-bottom: 0;
}

.setup-summary dt {
  color: var(--color-text-muted);
}

.setup-summary dd {
  margin: 0;
  font-weight: 600;
}

/* ---------- A phone: compact progress, stacked fields ---------- */

@media (max-width: 699px) {
  /* A field moved to by the keyboard stays above the buttons at the foot. */
  html:has(body.app[data-setup]) {
    scroll-padding-bottom: 220px;
  }

  .setup {
    gap: 16px;
    padding-bottom: 24px;
  }

  .setup-steps {
    display: none;
  }

  .setup-compact-progress {
    display: flex;
  }

  .setup-intro h1 {
    font-size: 2rem;
  }

  .setup-archer-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
  }

  .setup-archer-row:not(:first-child) .form-field > label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    white-space: normal;
  }

  .setup-invite-row {
    grid-template-columns: minmax(0, 1fr);
  }

  /* The main button spans the screen at the foot, as on the phone design. */
  .setup-actions {
    position: sticky;
    bottom: 0;
    margin: 0 -16px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--color-page);
  }

  .setup-actions-end {
    flex: 1 1 100%;
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .setup-actions-end .button,
  .setup-actions.is-end .button {
    justify-content: center;
    width: 100%;
  }

  .setup-actions.is-end {
    flex-direction: column-reverse;
    align-items: stretch;
  }
}

/* ---------- Next steps ---------- */

.next-steps-count {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.next-steps-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.next-steps-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-divider);
}

.next-steps-list li:last-child {
  border-bottom: 0;
}

.next-steps-circle {
  flex: none;
  width: 22px;
  height: 22px;
  border: 2px solid var(--color-control-border);
  border-radius: 50%;
}

.next-steps-text {
  display: flex;
  flex: 1 1 220px;
  flex-direction: column;
}

.next-steps-text span {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.next-steps-note {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.today-next-steps:empty {
  display: none;
}
