/* ========================================
   ACCOUNT / FLOW PAGES
   Shared by: /join/, /join/complete/, /not-a-member/,
   /membership-expired/, /auth/email-required/, /volunteer/
   A single centred card that fits the viewport inside the app shell
   (sticky 56px top bar; 64px tab bar on phones), plus form controls.
   ======================================== */

.flow-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  /* top bar is 56px + 1px bottom border */
  min-height: calc(100dvh - var(--shell-topbar-h) - 1px - var(--safe-top));
  padding: var(--space-6) var(--page-gutter) 0;
  color-scheme: dark; /* dark native checkboxes/radios/scrollbars */
}

@media (max-width: 767px) {
  .flow-page {
    min-height: calc(100dvh - var(--shell-topbar-h) - 1px - var(--safe-top) - var(--shell-tabbar-h) - var(--safe-bottom));
    padding-top: var(--space-4);
  }
}

/* Card sits in the optical centre when there's room, top-aligned otherwise */
.flow-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 30rem;
}

.flow-main--wide {
  max-width: 40rem;
}

.flow-card {
  background: var(--surface-1);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: var(--space-8);
  color: var(--text-default);
}

@media (max-width: 480px) {
  .flow-card {
    padding: var(--space-6) var(--space-5);
  }
}

/* Headings: sentence case (fonts.css uppercases every h1/h2) */
.flow-page :is(h1, h2, h3) {
  text-transform: none;
  letter-spacing: -0.01em;
}

.flow-hero {
  text-align: center;
  margin-bottom: var(--space-6);
}

.flow-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-4);
  display: block;
  object-fit: contain;
}

.flow-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--yellow-light);
  font-size: 1.5rem;
}

.flow-icon--success {
  background: rgba(123, 198, 126, 0.18);
  color: #9be09e;
}

.flow-icon--warn {
  background: rgba(239, 123, 109, 0.18);
  color: var(--coral-light, #F4A79E);
}

.flow-eyebrow {
  margin: 0 0 var(--space-1);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--yellow-light);
}

.flow-title {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-strong);
}

.flow-subtitle {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-strong);
}

.flow-lede {
  margin: var(--space-2) 0 0;
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--text-default);
}

/* Markdown content: first paragraph is the lede, lists are checklists */
.flow-content {
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--text-default);
}

.flow-content p {
  margin: 0 0 var(--space-3);
}

.flow-content strong {
  color: var(--text-strong);
  font-weight: 600;
}

.flow-content ul {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.flow-content li {
  position: relative;
  padding-left: 1.75rem;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.flow-content li::before {
  content: "\f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  left: 0;
  top: 0.0625rem;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  background: rgba(255, 192, 81, 0.18);
  color: var(--yellow-light);
  font-size: 0.625rem;
  line-height: 1.125rem;
  text-align: center;
}

/* Longer explanatory pages (e.g. /rwgps-access/): headings and plain bullets */
.flow-content--doc h2 {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-strong);
}

.flow-content--doc ul { margin-top: 0; margin-bottom: var(--space-3); }

.flow-content--doc h3 {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-strong);
}

.flow-content--doc code {
  font-size: 0.9em;
  padding: 0.05em 0.3em;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
}

.flow-content--doc li::before {
  content: "";
  top: 0.55em;
  left: 0.5rem;
  width: 0.375rem;
  height: 0.375rem;
  background: var(--yellow-light, #FFC051);
}

.flow-content--doc a { color: var(--yellow-light, #FFC051); }

.flow-hero + .flow-content {
  margin-top: calc(-1 * var(--space-2));
}

.flow-center {
  text-align: center;
}

/* Numbered steps */
.flow-steps {
  margin: var(--space-5) 0 0;
  padding: var(--space-4) var(--space-5);
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.flow-steps-title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-strong);
}

.flow-steps ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: flow-step;
  display: grid;
  gap: var(--space-2);
}

.flow-steps li {
  counter-increment: flow-step;
  position: relative;
  padding-left: 2rem;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-default);
}

.flow-steps li::before {
  content: counter(flow-step);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-strong);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.375rem;
  text-align: center;
}

/* Two-column card on wide screens: pitch left, steps + actions right */
.flow-main--split {
  max-width: 30rem;
}

@media (min-width: 1100px) {
  .flow-main--split {
    max-width: 60rem;
  }

  .flow-card--split {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: var(--space-4) var(--space-10);
    align-items: start;
    padding: var(--space-10);
  }

  .flow-card--split .flow-span {
    grid-column: 1 / -1;
  }

  .flow-card--split .flow-span .flow-alert {
    margin: 0;
  }

  .flow-card--split .flow-hero {
    text-align: left;
  }

  .flow-card--split .flow-mark {
    margin-left: 0;
  }

  .flow-card--split .flow-steps {
    margin-top: 0;
  }

  .flow-card--split .flow-actions {
    margin-top: var(--space-5);
  }
}

/* ── Buttons ──────────────────────────── */

.flow-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.flow-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.625rem var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}

.flow-btn:focus-visible {
  border-radius: var(--radius-md);
}

.flow-btn-primary {
  background: var(--yellow-light);
  border-color: var(--yellow-light);
  color: #2e3a31;
}

.flow-btn-primary:hover:not(:disabled) {
  background: #ffcc70;
  border-color: #ffcc70;
  color: #2e3a31;
}

.flow-btn-secondary {
  background: var(--surface-2);
  border-color: var(--border-default);
  color: var(--text-strong);
}

.flow-btn-secondary:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text-strong);
}

.flow-btn-ghost {
  background: transparent;
  color: var(--text-default);
}

.flow-btn-ghost:hover {
  background: var(--surface-1);
  color: var(--text-strong);
}

.flow-btn-danger {
  background: transparent;
  border-color: rgba(239, 123, 109, 0.5);
  color: #fbd0ca;
}

.flow-btn-danger:hover {
  background: rgba(239, 123, 109, 0.16);
  color: #fff;
}

.flow-btn:disabled,
.flow-btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.flow-note {
  margin: var(--space-5) 0 0;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-default);
  text-align: center;
}

.flow-note a,
.flow-alert a {
  color: var(--yellow-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.flow-note a:hover {
  color: #ffd68a;
}

.flow-note--small {
  font-size: var(--text-xs);
  color: var(--text-subtle);
}

/* ── Alerts ───────────────────────────── */

.flow-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: rgba(239, 123, 109, 0.16);
  border: 1px solid rgba(239, 123, 109, 0.45);
  color: var(--text-strong);
  font-size: var(--text-sm);
  line-height: 1.5;
  text-align: left;
}

.flow-alert > i {
  margin-top: 0.1875rem;
  color: #f8b4ab;
}

.flow-alert:empty {
  display: none;
}

/* ── Form controls ────────────────────── */

.flow-form {
  display: grid;
  gap: var(--space-5);
}

.flow-form--card {
  margin-top: var(--space-6);
}

@media (min-width: 1100px) {
  .flow-card--split .flow-form--card {
    margin-top: 0;
    padding: var(--space-5);
    background: var(--surface-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
  }
}

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

.flow-field-row {
  display: grid;
  gap: var(--space-5);
}

@media (min-width: 640px) {
  .flow-field-row {
    grid-template-columns: 1fr 1fr;
  }
}

.flow-label,
.flow-legend {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-strong);
}

.flow-label .flow-req,
.flow-legend .flow-req {
  color: var(--yellow-light);
  margin-left: 0.125rem;
}

.flow-optional {
  font-weight: 400;
  color: var(--text-subtle);
  margin-left: 0.25rem;
}

.flow-hint {
  margin: calc(-1 * var(--space-1)) 0 0;
  font-size: var(--text-xs);
  color: var(--text-subtle);
}

.flow-input {
  width: 100%;
  min-height: 48px;
  padding: 0.625rem var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  color: var(--text-strong);
  font-family: inherit;
  font-size: max(16px, 1rem);
  line-height: 1.4;
  transition: border-color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur-fast);
  -webkit-appearance: none;
  appearance: none;
}

textarea.flow-input {
  min-height: 96px;
  resize: vertical;
}

.flow-input::placeholder {
  color: var(--text-subtle);
}

.flow-input:hover {
  border-color: rgba(255, 255, 255, 0.36);
}

.flow-input:focus,
.flow-input:focus-visible {
  outline: none;
  border-color: var(--yellow-light);
  background: rgba(0, 0, 0, 0.18);
  box-shadow: 0 0 0 3px rgba(255, 192, 81, 0.25);
  border-radius: var(--radius-md);
}

.flow-input[aria-invalid="true"] {
  border-color: #f4a79e;
  background: rgba(239, 123, 109, 0.1);
}

.flow-error {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 500;
  color: #fcd3cd;
}

.flow-error[hidden] {
  display: none;
}

.flow-error i {
  font-size: 0.8125rem;
}

/* Fieldset of checkbox / radio tiles */
.flow-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.flow-fieldset > .flow-legend {
  padding: 0;
  margin-bottom: var(--space-2);
}

.flow-options {
  display: grid;
  gap: var(--space-2);
}

@media (min-width: 640px) {
  .flow-options--2col {
    grid-template-columns: 1fr 1fr;
  }
}

.flow-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 48px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--text-strong);
  font-size: var(--text-sm);
  line-height: 1.35;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}

.flow-option:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.flow-option input {
  width: 20px;
  height: 20px;
  min-height: 20px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--yellow-light);
  cursor: pointer;
}

.flow-option input:focus-visible {
  box-shadow: none;
  outline: 2px solid var(--yellow-light);
  outline-offset: 2px;
}

.flow-option:has(input:checked) {
  border-color: var(--yellow-light);
  background: rgba(255, 192, 81, 0.12);
}

.flow-option > i {
  width: 1.125rem;
  text-align: center;
  color: var(--text-subtle);
}

.flow-option:has(input:checked) > i {
  color: var(--yellow-light);
}

.flow-fieldset[aria-invalid="true"] .flow-option {
  border-color: rgba(244, 167, 158, 0.6);
}

.flow-fieldset .flow-input {
  margin-top: var(--space-2);
}

.flow-fieldset .flow-error {
  margin-top: var(--space-2);
}

/* ── Footer ───────────────────────────── */

.flow-footer {
  width: 100%;
  margin-top: var(--space-6);
  padding: var(--space-5) 0 var(--space-6);
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-subtle);
}

.flow-footer p {
  margin: 0 0 var(--space-1);
}

.flow-footer a {
  color: var(--text-default);
  text-decoration: underline;
}

/* ── Spinner ──────────────────────────── */

.flow-spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--yellow-light);
  border-radius: 50%;
  animation: flow-spin 0.9s linear infinite;
}

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

/* ── Toast (above the phone tab bar) ──── */

.vol-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-6) + var(--safe-bottom));
  z-index: 1100;
  width: max-content;
  max-width: calc(100vw - 2rem);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  background: #2e3a31;
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-3);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 500;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity var(--dur-base), transform var(--dur-base) var(--ease-out);
}

.vol-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 767px) {
  .vol-toast {
    bottom: calc(var(--shell-tabbar-h) + var(--safe-bottom) + var(--space-3));
  }
}

/* ── Not a member: which account, and race day ── */

.flow-page [hidden] { display: none !important; }

.flow-account,
.flow-race {
  margin: var(--space-5) 0 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-default);
  text-align: left;
}

.flow-account {
  margin: 0 0 var(--space-4);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.flow-race {
  background: rgba(255, 192, 81, 0.12);
  border: 1px solid rgba(255, 192, 81, 0.35);
}

.flow-account p,
.flow-race p { margin: 0; text-wrap: pretty; }
.flow-account p + p,
.flow-race p + p { margin-top: var(--space-2); }
.flow-account strong,
.flow-race strong { color: var(--text-strong); }
.flow-account > p > i { margin-right: var(--space-1); color: var(--text-subtle); }
.flow-account-switch { color: var(--text-subtle); }
.flow-account-email { color: var(--text-default); overflow-wrap: anywhere; }

.flow-account a,
.flow-race a {
  color: var(--yellow-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}
