:root {
    color-scheme: light dark;
    font-family:
        system-ui,
        -apple-system,
        Segoe UI,
        Roboto,
        sans-serif;
    --fg: #111;
    --fg-muted: #555;
    --bg: #fafafa;
    --bg-elev: #fff;
    --border: #d4d4d8;
    --border-strong: #71717a;
    --accent: #5b21b6;
    --accent-fg: #fff;
    --error: #b91c1c;
    --error-bg: #fef2f2;
}

@media (prefers-color-scheme: dark) {
    :root {
        --fg: #f4f4f5;
        --fg-muted: #a1a1aa;
        --bg: #09090b;
        --bg-elev: #18181b;
        --border: #3f3f46;
        --border-strong: #a1a1aa;
        --accent: #a78bfa;
        --accent-fg: #1e1b4b;
        --error: #fca5a5;
        --error-bg: #450a0a;
    }
}

* {
    box-sizing: border-box;
}

/* The HTML `hidden` attribute should always win over our display:flex rules. */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    place-items: start center;
    background: var(--bg);
    color: var(--fg);
    padding: 1.5rem 1rem;
}

main {
    width: 100%;
    max-width: 28rem;
}

header {
    margin-bottom: 1.5rem;
    text-align: left;
}

h1 {
    margin: 0 0 0.5rem;
    font-size: 1.625rem;
    font-weight: 600;
    line-height: 1.2;
}

.lede {
    margin: 0;
    color: var(--fg-muted);
    font-size: 0.95rem;
    line-height: 1.45;
}

form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
}

fieldset {
    border: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

legend {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
}

select,
input[type='tel'] {
    width: 100%;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.4;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-elev);
    color: var(--fg);
    appearance: none;
    -webkit-appearance: none;
}

select:focus-visible,
input:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-color: var(--accent);
}

input[aria-invalid='true'] {
    border-color: var(--error);
}

.hint {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--fg-muted);
}

.error {
    margin: 0;
    padding: 0.5rem 0.625rem;
    font-size: 0.875rem;
    color: var(--error);
    background: var(--error-bg);
    border-radius: 0.375rem;
}

.info {
    padding: 0.75rem 0.875rem;
    border: 1px solid #fcd34d;
    background: #fffbeb;
    color: #78350f;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.45;
}

.info p {
    margin: 0;
}

@media (prefers-color-scheme: dark) {
    .info {
        border-color: #b45309;
        background: #1c1300;
        color: #fcd34d;
    }
}

.consent label {
    display: flex;
    gap: 0.625rem;
    align-items: flex-start;
    font-weight: 400;
    font-size: 0.9rem;
    line-height: 1.4;
    cursor: pointer;
}

.consent input[type='checkbox'] {
    flex-shrink: 0;
    width: 1.125rem;
    height: 1.125rem;
    margin: 0.125rem 0 0;
    accent-color: var(--accent);
}

button {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 0.5rem;
    background: var(--accent);
    color: var(--accent-fg);
    cursor: pointer;
    transition: opacity 120ms ease;
}

button[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

.status {
    margin: 0;
    font-size: 0.9rem;
    color: var(--fg-muted);
    min-height: 1.25rem;
}

#step-accept,
#step-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 2rem 1.5rem;
    text-align: center;
}

.step__title {
    margin: 0;
    font-size: 1.375rem;
    font-weight: 600;
    line-height: 1.25;
}

.step__lede {
    margin: 0;
    color: var(--fg-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 22rem;
}

.cta {
    align-self: stretch;
    padding: 1rem 1.25rem;
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    box-shadow:
        0 1px 0 rgba(0, 0, 0, 0.04),
        0 6px 16px -8px color-mix(in srgb, var(--accent) 60%, transparent);
    transition:
        transform 120ms ease,
        opacity 120ms ease,
        box-shadow 120ms ease;
}

.cta:hover:not([disabled]):not([aria-busy='true']) {
    transform: translateY(-1px);
    box-shadow:
        0 1px 0 rgba(0, 0, 0, 0.05),
        0 12px 24px -10px color-mix(in srgb, var(--accent) 70%, transparent);
}

.cta:active:not([disabled]):not([aria-busy='true']) {
    transform: translateY(0);
}

.cta--secondary {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
    box-shadow: none;
}

.cta--secondary:hover:not([disabled]):not([aria-busy='true']) {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    box-shadow: none;
}

.cta--ghost {
    background: transparent;
    color: var(--fg-muted);
    border: none;
    box-shadow: none;
    padding: 0.625rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 0.2em;
    text-decoration-thickness: 1px;
    text-decoration-color: color-mix(in srgb, var(--fg-muted) 40%, transparent);
}

.cta--ghost:hover:not([disabled]):not([aria-busy='true']) {
    color: var(--fg);
    background: transparent;
    box-shadow: none;
    text-decoration-color: var(--fg);
}

/* Signal — animated phone with concentric ripple rings. */
.signal {
    position: relative;
    width: 8rem;
    height: 8rem;
    display: grid;
    place-items: center;
    margin: 0.5rem 0;
}

.signal__phone {
    position: relative;
    z-index: 1;
    font-size: 3rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
    animation: signal-bob 2.4s ease-in-out infinite;
}

.signal__ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--accent);
    opacity: 0;
    animation: signal-pulse 2.4s ease-out infinite;
}

.signal__ring--1 {
    animation-delay: 0s;
}
.signal__ring--2 {
    animation-delay: 0.8s;
}
.signal__ring--3 {
    animation-delay: 1.6s;
}

.signal--burst .signal__ring {
    animation-duration: 1.2s;
    border-color: #16a34a;
}
.signal--burst .signal__phone {
    animation: signal-burst 0.6s ease-out 1;
}

/* Click-fire: re-trigger ripple + phone burst when a fresh send happens. */
.signal--firing .signal__ring {
    animation: signal-pulse 0.9s ease-out 2;
    border-color: #16a34a;
}
.signal--firing .signal__phone {
    animation: signal-burst 0.5s ease-out 1;
}

#success-status {
    font-size: 1rem;
    font-weight: 600;
    color: #15803d;
    min-height: 1.4rem;
}

#success-status:not(:empty) {
    animation: status-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 1;
}

@media (prefers-color-scheme: dark) {
    #success-status {
        color: #86efac;
    }
}

@keyframes status-pop {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes signal-pulse {
    0% {
        transform: scale(0.5);
        opacity: 0.7;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

@keyframes signal-bob {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

@keyframes signal-burst {
    0% {
        transform: scale(0.7);
        opacity: 0;
    }
    60% {
        transform: scale(1.15);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .signal__phone,
    .signal__ring {
        animation: none;
    }
    .signal__ring {
        opacity: 0.25;
    }
}

button[aria-busy='true'] {
    cursor: progress;
    opacity: 0.92;
}

button[aria-busy='true']::after {
    content: '';
    display: inline-block;
    width: 0.875rem;
    height: 0.875rem;
    margin-left: 0.625rem;
    vertical-align: -0.15em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-rotate 0.65s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    button[aria-busy='true']::after {
        animation: none;
        border-right-color: currentColor;
        opacity: 0.6;
    }
}

@media (min-width: 480px) {
    body {
        padding: 3rem 1.5rem;
    }
    form,
    #step-accept,
    #step-success {
        padding: 1.75rem;
    }
    h1 {
        font-size: 1.875rem;
    }
}
