/* ============================================================
   AutoMatch — condition pills + animated card grid.
   ============================================================ */

/* ---- Six-step Wizard ---- */
.automatch-wizard {
    --automatch-card-bg: var(--po-off-white, #fdf8f5);
    --automatch-border: rgba(28, 60, 99, 0.16);
    display: grid;
    gap: 2rem;
}

.automatch-progress {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.5rem;
    padding: 0;
    margin: 0 0 1rem;
    list-style: none;
}

.automatch-progress__item {
    display: grid;
    gap: 0.35rem;
    align-content: start;
    min-width: 0;
    color: rgba(28, 60, 99, 0.48);
}

.automatch-progress__number {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border: 2px solid currentColor;
    border-radius: 999px;
    font-weight: 800;
}

.automatch-progress__label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    overflow-wrap: anywhere;
}

.automatch-progress__item.is-active,
.automatch-progress__item.is-complete {
    color: var(--po-navy, #1c3c63);
}

.automatch-progress__item.is-active .automatch-progress__number {
    background: var(--po-navy, #1c3c63);
    color: var(--po-white, #fff);
}

.automatch-step {
    padding: clamp(1.25rem, 4vw, 2.5rem);
    border: 1px solid var(--automatch-border);
    border-radius: 28px;
    background:
        radial-gradient(circle at top right, rgba(254, 234, 225, 0.9), transparent 34rem),
        var(--automatch-card-bg);
    box-shadow: 0 18px 45px rgba(28, 60, 99, 0.08);
}

.automatch-status {
    min-height: 1.25rem;
    margin: 0;
    color: var(--po-accent, #c97a5a);
    font-weight: 700;
}

.automatch-step[hidden] {
    display: none;
}

.automatch-step h2 {
    margin-block: 0 0.75rem;
}

.automatch-step__eyebrow {
    margin-block: 0 0.5rem;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--po-primary, #386e99);
}

.automatch-step__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-block-start: 1.5rem;
}

.automatch-summary {
    display: grid;
    gap: 0.5rem;
    max-width: 32rem;
    padding: 1rem;
    border: 1px solid var(--automatch-border);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
}

.automatch-summary p,
.automatch-next-message {
    margin: 0;
}

.automatch-live-list {
    display: grid;
    gap: 1rem;
}

/* ---- Age Selector (button group) ---- */
.automatch-age-selector {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-block: 2rem 1rem;
}

.automatch-age-selector__label {
    font-family: var(--po-font-heading, sans-serif);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--po-navy, #1c3c63);
    margin: 0;
}

.automatch-age-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.age-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1.75rem;
    border: 2px solid var(--po-navy, #1c3c63);
    border-radius: 9999px;
    font-family: var(--po-font-heading, sans-serif);
    font-weight: 700;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--po-navy, #1c3c63);
    background: transparent;
    cursor: pointer;
    transition:
        background-color 200ms ease,
        color            200ms ease,
        transform        150ms ease,
        box-shadow       200ms ease;
}

.age-btn:hover {
    background-color: var(--po-cream, #feeae1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 110, 153, 0.15);
}

.age-btn[aria-pressed="true"],
.age-btn.is-active {
    background-color: var(--po-navy, #1c3c63);
    color: var(--po-white, #fff);
    border-color: var(--po-navy, #1c3c63);
}

.age-btn:focus-visible {
    outline: 2px solid var(--po-primary, #386e99);
    outline-offset: 2px;
}

/* ---- Condition Pills ---- */

.condition-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-block: 2rem;
}

.condition-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--po-navy, #1c3c63);
    border-radius: 9999px;
    font-family: var(--po-font-heading, sans-serif);
    font-weight: 700;
    font-size: 0.8125rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--po-navy, #1c3c63);
    background: transparent;
    cursor: pointer;
    transition:
        background-color 200ms ease,
        color            200ms ease,
        border-color     200ms ease,
        transform        150ms ease,
        box-shadow       200ms ease;
}

.condition-pill:hover {
    background-color: var(--po-cream, #feeae1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 110, 153, 0.15);
}

.condition-pill[aria-pressed="true"],
.condition-pill.is-active {
    background-color: var(--po-navy, #1c3c63);
    color: var(--po-white, #fff);
    border-color: var(--po-navy, #1c3c63);
}

.condition-pill.is-primary {
    background-color: var(--po-accent, #c97a5a);
    border-color: var(--po-accent, #c97a5a);
    color: var(--po-white, #fff);
}

.condition-pill:focus-visible {
    outline: 2px solid var(--po-primary, #386e99);
    outline-offset: 2px;
}

.condition-pill--call {
    text-decoration: none;
}

/* ---- Match Results Grid ---- */
.match-results__header {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: baseline;
    margin-block-end: 1.5rem;
    min-height: 1.5rem;
}

.match-results__count,
.match-results__available-count {
    font-family: var(--po-font-heading, sans-serif);
    font-size: 1rem;
    font-weight: 700;
    color: var(--po-navy, #1c3c63);
}

.match-results__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    transition: opacity 300ms ease;
}

/* Card state transitions — managed via JS adding/removing classes */
.psych-card {
    transition:
        opacity    400ms ease,
        transform  400ms ease,
        box-shadow 300ms ease;
    will-change: opacity, transform;
}

/* Hidden state — card for unmatched condition */
.psych-card.is-hidden {
    opacity: 0;
    transform: scale(0.92) translateY(8px);
    pointer-events: none;
    /* Collapse without layout shift */
    position: absolute;
    visibility: hidden;
    width: 0;
    height: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
    border: none;
}

/* Available vs unavailable within a match */
.psych-card.is-unavailable {
    opacity: 0.4;
    filter: grayscale(30%);
    pointer-events: none;
}

/* Appear animation when a card enters the matched set */
.psych-card.is-appearing {
    animation: psych-appear 400ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes psych-appear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Stagger delays for cards appearing together */
.psych-card.is-appearing:nth-child(1) { animation-delay:   0ms; }
.psych-card.is-appearing:nth-child(2) { animation-delay:  60ms; }
.psych-card.is-appearing:nth-child(3) { animation-delay: 120ms; }
.psych-card.is-appearing:nth-child(4) { animation-delay: 180ms; }
.psych-card.is-appearing:nth-child(5) { animation-delay: 240ms; }
.psych-card.is-appearing:nth-child(6) { animation-delay: 300ms; }

/* ---- Match result messages ---- */
.match-results__none {
    text-align: center;
    padding: 3rem;
    background: var(--po-off-white, #fdf8f5);
    border-radius: 24px;
}

/* ---- Wait list form ---- */
.waitlist-form {
    background: var(--po-surface, #fff);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 6px 24px rgba(56, 110, 153, 0.12);
    max-width: 480px;
}

.waitlist-form h3 {
    margin-block-end: 1.5rem;
}

.waitlist-form p {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-block-end: 1rem;
}

.waitlist-form label {
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--po-text-muted, #5a5a5a);
}

.waitlist-form input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid rgba(56, 110, 153, 0.2);
    border-radius: 12px;
    font-size: 1rem;
    transition: border-color 200ms ease;
}

.waitlist-form input:focus {
    outline: none;
    border-color: var(--po-primary, #386e99);
}

.waitlist-form__msg {
    font-size: 0.875rem;
    color: var(--po-accent, #c97a5a);
    min-height: 1.25rem;
}

/* ---- Loading state ---- */
.match-results__grid.is-loading {
    opacity: 0.5;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .psych-card, .psych-card.is-appearing, .condition-pill {
        animation: none !important;
        transition: opacity 200ms ease !important;
    }
}

@media (max-width: 600px) {
    .automatch-progress {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
