/**
 * Join wizard — mobile-first, scoped to .join-flow-shell (no html class dependency).
 */

/* Header: Tips / Help chips */
#setup-view .pg-brand {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
}

#setup-view .pg-brand .tagline {
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}

.join-header-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  width: 100%;
}

.join-top-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 0;
}

button.join-icon-chip {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  font-family: var(--font);
  line-height: 1.2;
  box-sizing: border-box;
}

.join-icon-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.4rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.join-icon-chip:active {
  transform: scale(0.98);
}

/* Header Tips / Help — high contrast on dark and branded backgrounds */
.join-top-actions .join-icon-chip {
  justify-content: flex-start;
  gap: 0.3rem;
  min-height: 2.5rem;
  padding: 0.4rem 0.75rem 0.4rem 0.6rem;
  border: 1.5px solid var(--border-strong);
  background: color-mix(in srgb, var(--surface) 82%, var(--link) 18%);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 700;
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 color-mix(in srgb, var(--text) 8%, transparent);
}

.join-top-actions .join-icon-chip:active {
  border-color: var(--link);
  background: color-mix(in srgb, var(--surface) 68%, var(--link) 32%);
}

.join-top-actions .join-icon-chip:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), 0 2px 10px rgba(0, 0, 0, 0.28);
}

.join-top-actions .join-icon-chip-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1.125rem;
  height: 1.125rem;
  line-height: 0;
  color: var(--link);
}

.join-top-actions .join-icon-chip-glyph:empty {
  display: none;
  width: 0;
  height: 0;
  overflow: hidden;
}

.join-top-actions .join-icon-chip-glyph svg {
  display: block;
  width: 1.125rem;
  height: 1.125rem;
}

.join-top-actions .join-icon-chip-text {
  line-height: 1;
  font-weight: 700;
}

.join-icon-chip-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
  color: inherit;
}

.join-icon-chip-glyph svg {
  display: block;
  width: 100%;
  height: 100%;
}

.join-icon-chip-text {
  line-height: 1.2;
  font-weight: 600;
}

.join-flow-shell {
  --join-accent-glow: color-mix(in srgb, var(--accent) 28%, transparent);
}

.join-flow-head {
  margin-bottom: 1rem;
}

.join-flow-progress {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.35rem;
  margin-bottom: 1rem;
  list-style: none;
  padding: 0;
}

.join-step-pill {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-width: 0;
  min-height: 3.25rem;
  padding: 0.45rem 0.35rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  opacity: 0.5;
  transition: opacity 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.join-step-pill.is-active {
  opacity: 1;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: linear-gradient(
    165deg,
    color-mix(in srgb, var(--accent) 14%, var(--bg-elevated)),
    var(--bg-elevated)
  );
  box-shadow: 0 0 0 1px var(--join-accent-glow), 0 6px 20px var(--join-accent-glow);
}

.join-step-pill.is-done {
  opacity: 0.9;
  border-color: color-mix(in srgb, var(--success, #3dd68c) 45%, var(--border));
}

.join-step-pill-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  background: var(--border);
  color: var(--text-secondary);
  line-height: 1;
}

.join-step-pill.is-active .join-step-pill-num {
  background: var(--accent);
  color: var(--accent-contrast, #fff);
}

.join-step-pill.is-done .join-step-pill-num {
  background: color-mix(in srgb, var(--success, #3dd68c) 75%, var(--border));
  color: #fff;
}

.join-step-pill-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  line-height: 1.1;
  text-align: center;
}

.join-step-pill.is-active .join-step-pill-label {
  color: var(--accent);
}

.join-flow-step-title {
  margin: 0 0 0.4rem;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.join-flow-step-lead {
  margin: 0 0 1.1rem;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.join-flow-step:not(.join-flow-step--active) {
  display: none !important;
}

.join-flow-step--active {
  display: block;
}

/* Code step */
.join-code-field {
  margin-bottom: 0.85rem;
}

.join-code-field .pg-input {
  margin-bottom: 0;
  min-height: 3rem;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: center;
}

.join-scan-card {
  margin-top: 0.65rem;
}

.join-scan-card-btn {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  min-height: 3.5rem;
  padding: 0.75rem 1rem;
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-elevated));
  color: var(--text);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.join-scan-card-btn:active {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-elevated));
}

.join-scan-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 18%, var(--bg-elevated));
  color: var(--accent);
}

.join-scan-card-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.join-scan-card-text strong {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
}

.join-scan-card-text span {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.join-code-hint {
  margin: 0.65rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Board name */
.join-board-name-card--compact {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: 14px;
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--accent) 8%, var(--bg-elevated)),
    var(--bg-elevated)
  );
}

.join-board-name-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.join-board-name-main .join-board-name-avatar {
  flex: 0 0 auto;
  margin: 0;
}

.join-board-name-text {
  flex: 1 1 auto;
  min-width: 0;
}

.join-board-name-card--compact .join-board-name-label {
  margin: 0 0 0.15rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.join-board-name-card--compact .alter-ego-name {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.join-board-name-hint {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
}

.join-shuffle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-shrink: 0;
  min-height: 2.75rem;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.join-shuffle-btn:active {
  transform: scale(0.98);
}

.join-device-path {
  margin-bottom: 0.85rem;
}

.join-device-path-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.join-device-path-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-height: 3.5rem;
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.72);
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.join-device-path-sub {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary, #666);
  line-height: 1.3;
}

.join-device-path-btn--active {
  border-color: rgba(16, 185, 129, 0.65);
  background: rgba(16, 185, 129, 0.12);
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.25);
}

/* Stats */
.join-stats-row--compact {
  display: grid;
  grid-template-columns: minmax(4.5rem, 1fr) minmax(0, 1.5fr);
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.85rem;
}

.join-stats-row--compact:has(.join-field-compact--age:only-child) {
  grid-template-columns: 1fr;
}

.join-field-compact--age .field-hint {
  margin-top: 0.35rem;
  margin-bottom: 0;
}

.join-field-compact .pg-label {
  margin-bottom: 0.35rem;
}

.join-field-compact .pg-input {
  margin-bottom: 0;
  min-height: 2.75rem;
}

.join-gender-pick {
  display: flex;
  gap: 0.35rem;
}

.join-gender-opt {
  flex: 1 1 0;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0 0.2rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1.1;
  font-family: var(--font);
}

.join-gender-opt--active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-elevated));
  color: var(--accent);
}

#gender {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.join-weight-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.join-weight-field {
  flex: 1 1 auto;
  min-width: 0;
}

.join-weight-field .pg-input {
  margin-bottom: 0;
  min-height: 2.75rem;
}

.join-weight-toggle-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  flex: 0 0 auto;
  padding-bottom: 0.2rem;
}

.join-weight-toggle-label {
  margin: 0 !important;
  font-size: 0.625rem !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Connect */
.join-connect-checklist {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem 0.85rem 1.75rem;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 5%, var(--bg-elevated));
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.join-connect-checklist li {
  margin-bottom: 0.4rem;
}

.join-connect-checklist li:last-child {
  margin-bottom: 0;
}

.join-store-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 3rem;
  margin-bottom: 0.85rem;
  padding: 0.75rem 1rem;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-elevated));
  color: var(--accent);
  font-size: 0.9375rem;
  font-weight: 700;
  text-decoration: none;
}

.join-store-link--checking {
  opacity: 0.72;
  pointer-events: none;
}

.join-input-action-row {
  display: flex;
  align-items: stretch;
  gap: 0.45rem;
}

.join-input-grow {
  flex: 1 1 auto;
  min-width: 0;
}

.join-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.85rem;
  height: 2.85rem;
  min-width: 2.85rem;
  min-height: 2.85rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.join-icon-btn--accent {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-elevated));
  color: var(--accent);
}

.join-help-text-btn {
  display: block;
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.65rem;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: var(--font);
  text-align: center;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* Footer — always styled */
.join-flow-footer {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.55rem;
  margin-top: 1.35rem;
  padding-top: 1rem;
  padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

.join-flow-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  flex: 0 0 auto;
  min-height: 3.25rem;
  padding: 0 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
}

.join-flow-back-btn.hidden {
  display: none;
}

.join-flow-next-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 3.25rem;
  padding: 0 1.25rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 82%, #000));
  color: var(--accent-contrast, #fff);
  font-size: 1.0625rem;
  font-weight: 800;
  font-family: var(--font);
  cursor: pointer;
  box-shadow: 0 6px 22px var(--join-accent-glow);
  letter-spacing: 0.01em;
}

.join-flow-next-btn:active {
  transform: scale(0.99);
}

.join-primary-card {
  padding-bottom: 0.25rem;
}

.join-connect-hero,
#connect-btn.join-flow-legacy-connect {
  display: none !important;
}

@media (max-width: 360px) {
  .join-step-pill-label {
    font-size: 0.625rem;
  }

  .join-gender-opt {
    font-size: 0.625rem;
  }
}
