/* ── Profile Setup: card, pill inputs, dropdowns, form ── */

/* Page layout — centre the card vertically and horizontally */
.ps-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 6rem); /* account for topbar */
  padding: 2rem 1rem;
}

/* ── Card ──────────────────────────────────────── */
.ps-card {
  max-width: 680px;
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 2.5rem;
  position: relative;
  overflow: visible;
}

/* Teal accent line at top of card */
.ps-card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  height: 3px;
  background: var(--teal);
  border-radius: 16px 16px 0 0;
  z-index: 1;
}

/* ── Progress Bar ─────────────────────────────── */
.ps-progress {
  display: flex;
  gap: 4px;
  margin-bottom: 1.5rem;
  margin-top: 0.25rem;
}

.ps-progress__seg {
  flex: 1;
  height: 3px;
  background: var(--bg-2);
  border-radius: 999px;
  transition: background 0.3s ease;
}

.ps-progress__seg--filled {
  background: var(--teal);
}

/* ── Steps ────────────────────────────────────── */
.ps-step {
  display: none;
  opacity: 0;
  transform: translateX(20px);
}

.ps-step--active {
  display: block;
  opacity: 1;
  transform: translateX(0);
}

.ps-step--exit-left {
  animation: ps-exit-left 0.3s ease forwards;
}

.ps-step--enter-right {
  animation: ps-enter-right 0.3s ease forwards;
}

.ps-step--exit-right {
  animation: ps-exit-right 0.3s ease forwards;
}

.ps-step--enter-left {
  animation: ps-enter-left 0.3s ease forwards;
}

@keyframes ps-exit-left {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-20px); }
}

@keyframes ps-enter-right {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes ps-exit-right {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

@keyframes ps-enter-left {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Section Label ─────────────────────────────── */
.ps-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ink-faint);
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  margin-top: 0.5rem;
}

/* ── Heading ───────────────────────────────────── */
.ps-heading {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.75rem;
  color: var(--ink);
  margin-bottom: 1.5rem;
  line-height: 1.2;
}

/* ── The Sentence ──────────────────────────────── */
.ps-sentence {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--ink-dim);
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.3rem;
}

.ps-word {
  white-space: nowrap;
}

/* ── Inline Pill Input ─────────────────────────── */
.ps-pill-field {
  display: inline-block;
  position: relative;
  vertical-align: baseline;
  z-index: 1;
}

.ps-pill-field input {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--teal);
  background: var(--teal-dim);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  outline: none;
  min-width: 140px;
  max-width: 100%;
  height: 2.2rem;
  vertical-align: baseline;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  caret-color: var(--teal);
}

.ps-pill-field input::placeholder {
  color: var(--ink-faint);
  font-weight: 500;
}

.ps-pill-field input:focus {
  border-color: var(--teal);
  background: rgba(69, 216, 197, 0.18);
  box-shadow: 0 0 0 3px rgba(69, 216, 197, 0.08);
}

.ps-pill-field .ps-error-msg {
  position: absolute;
  left: 0;
  top: calc(100% + 2px);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--danger);
  white-space: nowrap;
  max-width: calc(100vw - 4rem);
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.ps-pill-field .ps-error-msg.visible {
  opacity: 1;
  transform: translateY(0);
}

.ps-pill-field input.has-error {
  border-color: var(--danger);
  background: rgba(255, 157, 157, 0.08);
}

/* ── Custom Dropdown ───────────────────────────── */
.ps-dropdown {
  display: inline-block;
  position: relative;
  vertical-align: baseline;
  z-index: 10;
}

.ps-dropdown-trigger {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1;
  height: 2.2rem;
  color: var(--teal);
  background: var(--teal-dim);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.2rem 1.6rem 0.2rem 0.6rem;
  outline: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  z-index: 2;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}

.ps-dropdown-trigger.placeholder {
  color: var(--ink-faint);
  font-weight: 500;
}

.ps-dropdown-trigger:focus,
.ps-dropdown.open .ps-dropdown-trigger {
  border-color: var(--teal);
  background: rgba(69, 216, 197, 0.18);
  box-shadow: 0 0 0 3px rgba(69, 216, 197, 0.08);
}

.ps-dropdown-trigger.has-error {
  border-color: var(--danger);
  background: rgba(255, 157, 157, 0.08);
}

/* Chevron */
.ps-dropdown-trigger::after {
  content: "";
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--teal);
  transition: transform 0.2s ease;
  pointer-events: none;
}

.ps-dropdown-trigger.placeholder::after {
  border-top-color: var(--ink-faint);
}

.ps-dropdown.open .ps-dropdown-trigger::after {
  transform: translateY(-50%) rotate(180deg);
}

.ps-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: max(100%, 160px);
  max-width: calc(100vw - 4rem);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  z-index: 100;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.ps-dropdown.open {
  z-index: 50;
}

.ps-dropdown.open .ps-dropdown-menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.ps-dropdown-option {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink-dim);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s ease, color 0.1s ease;
}

.ps-dropdown-option:hover {
  background: var(--teal-dim);
  color: var(--teal);
}

.ps-dropdown-option.selected {
  color: var(--teal);
}

/* ── Card Footer ───────────────────────────────── */
.ps-footer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-top: 2rem;
  gap: 0.75rem;
}

.ps-footer__row {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

/* ── Back link ─────────────────────────────────── */
.ps-back {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--ink-faint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.7rem 0;
  transition: color 0.15s ease;
}

.ps-back:hover {
  color: var(--ink);
}

/* ── Submit Button (CLI style) ─────────────────── */
.ps-submit {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--bg-0);
  background: var(--teal);
  border: none;
  border-radius: 6px;
  padding: 0.7rem 1.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: filter 0.15s ease, opacity 0.25s ease, transform 0.1s ease;
  white-space: nowrap;
}

.ps-submit:hover:not(:disabled) {
  filter: brightness(0.9);
}

.ps-submit:active:not(:disabled) {
  transform: scale(0.97);
}

.ps-submit:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ps-submit .ps-chevron-icon {
  display: flex;
  align-items: center;
}

.ps-disclaimer {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--ink-faint);
  line-height: 1.5;
}

/* ── Form-level error banner ───────────────────── */
.ps-form-error {
  display: none;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.55;
  color: var(--danger);
  padding: 0.75rem 1rem;
  border: 1px solid var(--danger-line);
  border-radius: 8px;
  background: var(--danger-bg);
  margin-top: 1rem;
}

.ps-form-error.visible {
  display: block;
}

/* ── Measurement span ──────────────────────────── */
.ps-measure {
  position: absolute;
  visibility: hidden;
  height: 0;
  overflow: hidden;
  white-space: pre;
  font-family: var(--font-body);
  font-weight: 600;
}

/* ── Step 2: Proficiency Question ─────────────── */
.ps-question {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--ink-dim);
  margin-bottom: 1rem;
}

.ps-question--tools {
  margin-top: 2rem;
}

.ps-question-sub {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--ink-faint);
  margin-bottom: 1rem;
  margin-top: -0.5rem;
}

/* ── Proficiency Cards ────────────────────────── */
.ps-prof-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.ps-prof-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ps-prof-card:hover {
  border-color: var(--line-hover);
}

.ps-prof-card--selected {
  border-color: var(--teal);
  background: var(--teal-dim);
}

.ps-prof-card__title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}

.ps-prof-card__sub {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--ink-faint);
  line-height: 1.4;
}

.ps-prof-card--selected .ps-prof-card__title {
  color: var(--teal);
}

/* ── AI Tool Pills ────────────────────────────── */
.ps-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ps-tool-pill {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--ink-dim);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.ps-tool-pill:hover {
  border-color: var(--line-hover);
}

.ps-tool-pill--selected {
  border-color: var(--teal);
  background: var(--teal-dim);
  color: var(--teal);
}

/* ── Other Tool Input ────────────────────────── */
.ps-other-tool {
  margin-top: 0.75rem;
}

.ps-other-tool__input {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  color: var(--teal);
  background: var(--teal-dim);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  outline: none;
  width: 100%;
  max-width: 300px;
  caret-color: var(--teal);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.ps-other-tool__input:focus {
  border-color: var(--teal);
  background: rgba(69, 216, 197, 0.18);
}

.ps-other-tool__input::placeholder {
  color: var(--ink-faint);
  font-weight: 500;
}

/* ── Floating Icons Zone ──────────────────────── */
.ps-tools-float {
  position: relative;
  height: 80px;
  margin-bottom: 0.5rem;
  overflow: visible;
  pointer-events: none;
}

.ps-float-icon {
  position: absolute;
  width: 28px;
  height: 28px;
  object-fit: contain;
  opacity: 0;
  pointer-events: none;
  animation: ps-float-in 0.4s ease forwards, ps-float-drift 5s ease-in-out 0s infinite;
  /* Each icon gets a random animation-delay offset via JS style.left */
}

/* Vary drift per icon using nth-child for different timings */
.ps-float-icon:nth-child(odd) {
  animation: ps-float-in 0.4s ease forwards, ps-float-drift-alt 6s ease-in-out 0s infinite;
}

.ps-float-icon--exit {
  animation: ps-float-out 0.3s ease forwards !important;
}

/* Particle burst dot */
.ps-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--teal);
  border-radius: 50%;
  pointer-events: none;
  animation: ps-particle-fly 0.5s ease-out forwards;
}

@keyframes ps-float-in {
  from { opacity: 0; transform: translate(0, 20px) scale(0.5); }
  to   { opacity: 1; transform: translate(0, 0) scale(1); }
}

@keyframes ps-float-out {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: translateY(-15px) scale(0.4); }
}

@keyframes ps-float-drift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(12px, -10px); }
  50%  { transform: translate(-8px, -18px); }
  75%  { transform: translate(15px, -6px); }
  100% { transform: translate(0, 0); }
}

@keyframes ps-float-drift-alt {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-14px, -8px); }
  50%  { transform: translate(10px, -15px); }
  75%  { transform: translate(-6px, -12px); }
  100% { transform: translate(0, 0); }
}

@keyframes ps-particle-fly {
  from { opacity: 1; transform: translate(0, 0) scale(1); }
  to   { opacity: 0; transform: translate(var(--px), var(--py)) scale(0); }
}

/* ── Success Overlay ───────────────────────────── */
.ps-success-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-0);
  background-image: radial-gradient(rgba(237, 238, 236, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.ps-success-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.ps-success-content {
  text-align: center;
  transform: translateY(12px);
  transition: transform 0.5s ease;
}

.ps-success-overlay.visible .ps-success-content {
  transform: translateY(0);
}

.ps-success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--teal-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.ps-success-icon svg {
  width: 24px;
  height: 24px;
}

.ps-success-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.75rem;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.ps-success-sub {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-faint);
}

.ps-success-links {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.ps-success-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6em 1.1em;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  transition: background 150ms, border-color 150ms;
}

.ps-success-link--wa {
  color: #25D366;
  background: rgba(37, 211, 102, 0.08);
  border: 1px solid rgba(37, 211, 102, 0.25);
}
.ps-success-link--wa:hover {
  background: rgba(37, 211, 102, 0.15);
  border-color: rgba(37, 211, 102, 0.4);
}

.ps-success-link--li {
  color: #0A66C2;
  background: rgba(10, 102, 194, 0.08);
  border: 1px solid rgba(10, 102, 194, 0.25);
}
.ps-success-link--li:hover {
  background: rgba(10, 102, 194, 0.15);
  border-color: rgba(10, 102, 194, 0.4);
}

.ps-success-link svg {
  flex-shrink: 0;
}

.ps-success-skip {
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-faint);
}
.ps-success-skip a {
  color: var(--ink-dim);
  text-decoration: none;
  transition: color 150ms;
}
.ps-success-skip a:hover {
  color: var(--teal);
}

/* ── Reduced motion ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ps-dropdown-menu { transition: none; }
  .ps-success-overlay, .ps-success-content { transition: none; }
  .ps-step--exit-left,
  .ps-step--enter-right,
  .ps-step--exit-right,
  .ps-step--enter-left { animation: none; }
  .ps-float-icon {
    animation: none;
    opacity: 1;
  }
  .ps-float-icon--exit {
    animation: none;
    opacity: 0;
  }
  .ps-particle { animation: none; display: none; }
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 600px) {
  .ps-page {
    padding: 1rem;
    align-items: flex-start;
    padding-top: 2rem;
  }

  .ps-card {
    padding: 1.5rem;
    border-radius: 12px;
  }

  .ps-heading {
    font-size: 1.4rem;
  }

  .ps-sentence {
    font-size: 1.15rem;
    line-height: 2.2;
  }

  .ps-pill-field input {
    font-size: 1.15rem;
  }

  .ps-dropdown-trigger {
    font-size: 1.15rem;
  }

  .ps-question {
    font-size: 1.15rem;
  }

  .ps-submit {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .ps-prof-cards {
    grid-template-columns: 1fr;
  }

  .ps-pill-field input {
    min-width: 100px;
  }

  .ps-footer__row {
    flex-direction: row;
  }

  .ps-footer__row .ps-submit {
    flex: 1;
  }
}

@media (max-width: 380px) {
  .ps-card {
    padding: 1.25rem;
  }

  .ps-sentence {
    font-size: 1.05rem;
  }

  .ps-pill-field input {
    font-size: 1.05rem;
    min-width: 80px;
  }

  .ps-dropdown-trigger {
    font-size: 1.05rem;
  }

  .ps-question {
    font-size: 1.05rem;
  }
}
