/* The contact page under its page head: the form on a raised panel with its
   topic cards and field errors, the notices for sent, not sent and offline,
   and beside them what happens next, over the Dallas skyline at dusk. */

.contact {
    display: grid;
    gap: var(--space-12);
    padding-block: var(--space-5) var(--space-24);
}

.contact-main {
    min-inline-size: 0;
    max-inline-size: var(--container-2xl);
}

/* From --breakpoint-lg the aside stands at the end, beside the form. */
@media (min-width: 56.25rem) {
    .contact {
        grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
        align-items: start;
        gap: var(--space-16);
    }

    .contact-main {
        max-inline-size: none;
    }
}

/* ---- Notices ---- */

/* Hidden until contact.php redirects to one (:target) or contact.js sets
   data-state on .contact. */
.notice {
    display: none;
    align-items: flex-start;
    gap: var(--space-4);
    margin-block-end: var(--space-6);
    padding: var(--space-6);
    border: var(--border-width) solid var(--border);
    border-inline-start-width: var(--space-1);
    border-radius: var(--radius-md);
    background: var(--card);
    color: var(--card-foreground);
}

.notice:target,
.contact[data-state="sent"] #sent,
.contact[data-state="offline"] #offline,
.contact[data-state="failed"] #failed {
    display: flex;
}

/* Focused only so a screen reader reads it out; it is not a control. */
.notice:focus {
    outline: none;
}

.notice > div {
    min-inline-size: 0;
}

.notice-icon {
    display: grid;
    place-items: center;
    flex: none;
    inline-size: var(--space-10);
    block-size: var(--space-10);
    border-radius: var(--radius-sm);
}

.notice-success {
    border-inline-start-color: var(--success);
}

.notice-success .notice-icon {
    background: var(--success);
    color: var(--success-foreground);
}

.notice-error {
    border-inline-start-color: var(--destructive);
}

.notice-error .notice-icon {
    background: var(--destructive);
    color: var(--background);
}

.notice-warning {
    border-inline-start-color: var(--warning);
}

.notice-warning .notice-icon {
    background: var(--warning);
    color: var(--warning-foreground);
}

.notice h2 {
    margin: 0;
    font-size: var(--text-xl);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-snug);
}

.notice p {
    margin-block: var(--space-2) 0;
    color: var(--muted-foreground);
    font-size: var(--text-body);
    overflow-wrap: anywhere;
}

/* Once sent, the thank-you stands in for the form. */
.contact:has(#sent:target) .contact-form,
.contact[data-state="sent"] .contact-form {
    display: none;
}

/* ---- Form ---- */

/* A raised Carbon panel; the fields inside sit on the ground, a step darker. */
.contact-form {
    display: grid;
    gap: var(--space-7);
    padding-block: var(--space-6) var(--space-7);
    padding-inline: var(--space-5);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card);
}

@media (min-width: 40rem) {
    .contact-form {
        padding: var(--space-10);
    }
}

.field {
    display: grid;
    gap: var(--space-2);
    min-inline-size: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.field label,
.field legend {
    font-size: var(--text-ui);
    font-weight: var(--weight-semibold);
}

.field legend {
    margin-block-end: var(--space-2);
    padding: 0;
}

.field input:not([type="radio"]),
.field textarea {
    inline-size: 100%;
    min-block-size: var(--button-height);
    padding-block: var(--space-3);
    padding-inline: var(--space-4);
    border: var(--border-width) solid var(--input);
    border-radius: var(--radius-sm);
    background: var(--background);
    color: var(--foreground);
    font: inherit;
    font-size: var(--text-body);
}

.field input:not([type="radio"]):hover,
.field textarea:hover {
    border-color: var(--muted-foreground);
}

/* A field with an error keeps its error colour while it has focus. */
.field input:not([type="radio"], [aria-invalid="true"]):focus-visible,
.field textarea:not([aria-invalid="true"]):focus-visible {
    border-color: var(--ring);
    box-shadow: var(--shadow-halo);
}

.field textarea {
    resize: vertical;
}

.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"],
.choice:has([aria-invalid="true"]) {
    border-color: var(--destructive);
}

.field-error {
    margin: 0;
    color: var(--destructive);
    font-size: var(--text-ui);
    font-weight: var(--weight-medium);
}

.field-error:empty {
    display: none;
}

/* ---- Topic cards ---- */

.choices {
    display: grid;
    gap: var(--space-3);
}

/* The radio is kept for the keyboard and screen readers; the card shows it.
   Quiet until chosen: only the chosen card takes the Neon. */
.choice {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-block-size: var(--space-16);
    padding-block: var(--space-3);
    padding-inline: var(--space-4);
    border: var(--border-width) solid var(--input);
    border-radius: var(--radius-sm);
    background: var(--background);
    color: var(--foreground);
    cursor: pointer;
}

.choice:hover {
    border-color: var(--muted-foreground);
}

.choice input {
    position: absolute;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.choice-icon {
    display: grid;
    place-items: center;
    flex: none;
    inline-size: var(--space-10);
    block-size: var(--space-10);
    border: var(--border-width) solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--muted-foreground);
}

.choice-label {
    min-inline-size: 0;
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
}

.choice-hint {
    display: block;
    margin-block-start: var(--space-1);
    color: var(--muted-foreground);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: var(--weight-normal);
}

.choice-tick {
    display: grid;
    place-items: center;
    flex: none;
    inline-size: var(--icon-size-lg);
    block-size: var(--icon-size-lg);
    margin-inline-start: auto;
    border: var(--border-width) solid var(--border-strong);
    border-radius: var(--radius-full);
    color: var(--primary-foreground);
}

.choice-tick .icon {
    inline-size: var(--icon-size-sm);
    block-size: var(--icon-size-sm);
    scale: 0;
}

.choice:has(:checked) {
    border-color: var(--primary);
    box-shadow: var(--shadow-halo);
}

.choice:has(:checked) .choice-icon {
    border-color: var(--primary);
    background: var(--tint);
    color: var(--primary);
}

.choice:has(:checked) .choice-tick {
    border-color: var(--primary);
    background: var(--primary);
}

.choice:has(:checked) .choice-tick .icon {
    scale: 1;
}

.choice:has(:focus-visible) {
    outline: var(--focus-width) solid var(--ring);
    outline-offset: var(--focus-offset);
}

/* The honeypot: out of sight and out of the tab order for people. */
.form-trap {
    display: none;
}

/* ---- Sending ---- */

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-4) var(--space-6);
    padding-block-start: var(--space-2);
}

.form-actions .button {
    font: inherit;
    font-size: var(--text-ui);
    font-weight: var(--weight-semibold);
    cursor: pointer;
}

/* The arrow points the way the page reads. */
.form-actions .button .icon:dir(rtl) {
    scale: -1 1;
}

/* Sending: the button keeps its colour and says so; the arrow gives way to
   dots that pulse in turn, shown only where motion is welcome. */
.form-actions .button:disabled {
    background: var(--primary);
    cursor: progress;
}

.form-actions .button[aria-busy="true"] .icon,
.sending-dots {
    display: none;
}

.sending-dots i {
    inline-size: var(--space-1-5);
    block-size: var(--space-1-5);
    border-radius: var(--radius-full);
    background: currentColor;
}

.form-note {
    flex: 1 1 var(--container-xs);
    margin: 0;
    color: var(--muted-foreground);
    font-size: var(--text-base);
}

/* ---- What happens next ---- */

/* The skyline fills the panel and darkens to the ground at the bottom,
   where the words sit; they read on the ground, not on the photo. The panel
   keeps the photo's shape, and grows if the words need more. */
.contact-aside {
    position: relative;
    isolation: isolate;
    display: grid;
    align-content: end;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-md);
    background: var(--background);
}

.contact-photo {
    position: absolute;
    inset: 0;
    z-index: var(--z-behind);
    margin: 0;
}

.contact-photo img {
    inline-size: 100%;
    block-size: 100%;
    object-fit: cover;
    object-position: 30% 50%;
}

/* Graded toward the Carbon ground: the photo's colour gives way to the
   ground's, then it darkens at the top and most of all where the words sit. */
.contact-photo::before,
.contact-photo::after {
    content: "";
    position: absolute;
    inset: 0;
}

.contact-photo::before {
    background: var(--card);
    mix-blend-mode: color;
}

.contact-photo::after {
    background:
        linear-gradient(to top, var(--background) 34%, color-mix(in srgb, var(--background) 60%, transparent) 62%, transparent 92%),
        linear-gradient(to bottom, color-mix(in srgb, var(--background) 50%, transparent), transparent 40%);
}

.contact-next {
    padding: var(--space-6);
}

.contact-next h2 {
    margin: 0;
    font-size: var(--text-3xl);
    line-height: var(--leading-heading);
    letter-spacing: var(--tracking-heading);
}

.contact-next p {
    margin-block: var(--space-3) 0;
    color: var(--muted-foreground);
    font-size: var(--text-body);
}

.contact-next .contact-direct {
    margin-block-start: var(--space-6);
    padding-block-start: var(--space-4);
    border-block-start: var(--border-width) solid var(--border-strong);
    overflow-wrap: anywhere;
}

/* The address is the other way in, so it reads in white at a tap's height. */
.contact-direct a {
    display: inline-flex;
    align-items: center;
    min-block-size: var(--tap-target);
    color: var(--foreground);
    font-weight: var(--weight-semibold);
}

/* Beside the form, it stays in view while the form is filled in. */
@media (min-width: 56.25rem) {
    .contact-aside {
        position: sticky;
        inset-block-start: var(--space-24);
    }
}

/* Under the form on a tablet, a wide band rather than a tall one. */
@media (40rem <= width < 56.25rem) {
    .contact-aside {
        max-inline-size: var(--container-2xl);
        aspect-ratio: 16 / 9;
    }
}

@media (min-width: 40rem) {
    .contact-next {
        padding: var(--space-8);
    }
}

@keyframes notice-in {
    from {
        opacity: 0;
        translate: 0 var(--space-4);
    }
}

@keyframes dot-pulse {
    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .notice {
        animation: notice-in var(--duration-slower) var(--ease-out) both;
    }

    .choice,
    .field input,
    .field textarea {
        transition:
            border-color var(--duration-base) var(--ease-standard),
            box-shadow var(--duration-medium) var(--ease-out);
    }

    .choice-icon,
    .choice-tick {
        transition:
            background-color var(--duration-base) var(--ease-standard),
            border-color var(--duration-base) var(--ease-standard),
            color var(--duration-base) var(--ease-standard);
    }

    .choice-tick .icon {
        transition: scale var(--duration-medium) var(--ease-out);
    }

    .form-actions .button[aria-busy="true"] .sending-dots {
        display: inline-flex;
        gap: var(--space-1);
    }

    .sending-dots i {
        animation: dot-pulse var(--duration-loop-fast) var(--ease-in-out) infinite;
    }

    .sending-dots i:nth-child(2) {
        animation-delay: var(--stagger-2);
    }

    .sending-dots i:nth-child(3) {
        animation-delay: var(--stagger-4);
    }
}
