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

/* ---- Shared foundations ---- */
.automatch-wizard,
.po-match-launcher,
.po-phone-dialog {
    box-sizing: border-box;
    color: var(--po-navy, #1c3c63);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    letter-spacing: 0;
}

.automatch-wizard *,
.automatch-wizard *::before,
.automatch-wizard *::after,
.po-match-launcher *,
.po-match-launcher *::before,
.po-match-launcher *::after,
.po-phone-dialog *,
.po-phone-dialog *::before,
.po-phone-dialog *::after {
    box-sizing: border-box;
}

.automatch-wizard button,
.po-match-launcher button,
.po-phone-dialog button {
    appearance: none;
    font: inherit;
    letter-spacing: 0;
}

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

.automatch-step {
    padding: clamp(1.25rem, 4vw, 2.5rem);
    border: 1px solid var(--automatch-border);
    border-radius: 8px;
    background: 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 {
    color: var(--po-navy, #1c3c63);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.18;
    letter-spacing: 0;
    margin-block: 0 0.75rem;
}

.automatch-step > p:not(.automatch-step__eyebrow) {
    color: #33465d;
    font-size: 1rem;
    line-height: 1.65;
}

.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-wizard .automatch-next,
.automatch-wizard .automatch-back,
.automatch-wizard .automatch-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.7rem 1.1rem;
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0;
    color: var(--po-navy, #1c3c63);
    background: transparent;
    border: 1px solid var(--po-navy, #1c3c63);
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
}

.automatch-wizard .automatch-next,
.automatch-wizard .button-primary {
    color: var(--po-white, #fff);
    background: var(--po-primary, #386e99);
    border-color: var(--po-primary, #386e99);
}

.automatch-wizard .automatch-next:hover,
.automatch-wizard .button-primary:hover {
    color: var(--po-white, #fff);
    background: var(--po-navy, #1c3c63);
    border-color: var(--po-navy, #1c3c63);
}

.automatch-wizard .automatch-back:hover,
.automatch-wizard .automatch-reset:hover {
    color: var(--po-white, #fff);
    background: var(--po-navy, #1c3c63);
}

.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-selector__hint {
    margin: -0.35rem 0 0;
    color: #33465d;
    font-size: 0.9rem;
    line-height: 1.5;
}

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

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

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

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

.automatch-wizard button.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;
}

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

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

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

.automatch-wizard button.condition-pill.is-primary {
    background: #c0d1a1 !important;
    border-color: #c0d1a1 !important;
    color: var(--po-navy, #1c3c63) !important;
}

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

.automatch-wizard button.condition-pill--call {
    border-style: dashed !important;
    text-decoration: none;
}

.automatch-wizard button.condition-clear {
    display: inline-grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0 !important;
    border: 2px solid #c0d1a1 !important;
    border-radius: 50% !important;
    color: var(--po-navy, #1c3c63) !important;
    background: #fff !important;
    cursor: pointer;
    font-size: 1.65rem;
    font-weight: 400;
    line-height: 1;
}

.automatch-wizard button.condition-clear:hover {
    color: var(--po-navy, #1c3c63) !important;
    background: #c0d1a1 !important;
}

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

/* ---- Homepage matching launcher ---- */
.po-match-launcher {
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
}

.po-match-launcher__links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.po-match-launcher a.po-match-launcher__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.75rem 1.5rem;
    border: 2px solid #386e99;
    border-radius: 9999px;
    color: #386e99;
    background: transparent;
    cursor: pointer;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.8125rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    transition: background-color 200ms ease, color 200ms ease, transform 150ms ease, box-shadow 200ms ease;
}

.po-match-launcher a.po-match-launcher__link:link,
.po-match-launcher a.po-match-launcher__link:visited {
    color: #386e99 !important;
}

.po-match-launcher a.po-match-launcher__link:hover,
.po-match-launcher a.po-match-launcher__link:active {
    color: #fff !important;
    background: #386e99 !important;
    border-color: #386e99;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 110, 153, 0.15);
    text-decoration: none;
}

.po-match-launcher a.po-match-launcher__link:focus-visible {
    outline: 2px solid var(--po-primary, #386e99);
    outline-offset: 2px;
}

/* ---- Practice phone dialog ---- */
.po-phone-dialog {
    width: min(92vw, 460px);
    max-width: 460px;
    margin: auto;
    padding: 2rem;
    border: 1px solid rgba(28, 60, 99, 0.2);
    border-radius: 8px;
    color: var(--po-navy, #1c3c63);
    background: #fff;
    box-shadow: 0 20px 60px rgba(12, 35, 59, 0.25);
}

.po-phone-dialog::backdrop {
    background: rgba(12, 35, 59, 0.68);
}

.po-phone-dialog h2 {
    margin: 0 2.5rem 0.75rem 0;
    color: var(--po-navy, #1c3c63);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.65rem;
    line-height: 1.2;
    letter-spacing: 0;
}

.po-phone-dialog p {
    margin: 0 0 1.25rem;
    color: #33465d;
}

.po-phone-dialog__close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    color: var(--po-navy, #1c3c63);
    background: transparent;
    cursor: pointer;
    font-size: 1.75rem;
    line-height: 1;
}

.po-phone-dialog__close:hover,
.po-phone-dialog__close:focus-visible {
    color: var(--po-accent, #b65f3f);
}

.po-phone-dialog__call {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1rem;
    border: 1px solid var(--po-primary, #386e99);
    border-radius: 6px;
    color: #fff;
    background: var(--po-primary, #386e99);
    font-weight: 700;
    text-decoration: none;
}

.po-phone-dialog__call:hover,
.po-phone-dialog__call:focus-visible {
    color: #fff;
    background: var(--po-navy, #1c3c63);
    border-color: var(--po-navy, #1c3c63);
    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: 1;
}

/* 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: 8px;
}

/* ---- Wait list form ---- */
.waitlist-form {
    background: var(--po-surface, #fff);
    border-radius: 8px;
    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 {
    box-sizing: border-box;
    width: 100%;
    max-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-step h2 {
        font-size: 1.75rem;
    }
}
