/*
 * The contact page: page-contact.php and template-parts/message-form.php.
 * Which fields show for which topic is decided by the rules that
 * nicky_enqueue_contact() in functions.php adds after this file.
 */

.contact-page { background: var(--cream); padding-top: clamp(2rem, 4vw, 4rem); }
.contact-page__grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 8fr); gap: clamp(2rem, 5vw, 5rem); align-items: start; }
.contact-page__words { position: sticky; top: 2rem; }
@media (max-width: 960px) {
	.contact-page__grid { grid-template-columns: minmax(0, 1fr); }
	.contact-page__words { position: static; }
}

/* The sheet is white because the sent state shows the face mark, which only ever sits on white. */
.contact { padding: clamp(1.25rem, 3.2vw, 3rem); border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--paper); scroll-margin-top: 1.5rem; }

/* Topics */
.topics { margin: 0; padding: 0; border: 0; min-width: 0; }
.contact__legend { padding: 0; margin-bottom: 1rem; font-weight: 900; font-stretch: 62%; font-size: clamp(1.9rem, 3vw, 2.5rem); line-height: 1; text-transform: uppercase; }
.topics__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.topic { position: relative; display: grid; align-content: start; gap: 0.35rem; min-height: 5.5rem; padding: 1rem 1rem 1rem 3.1rem; border: 1px solid rgb(33 28 26 / 0.3); border-radius: 14px; cursor: pointer; transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s; }
.topic:hover { border-color: var(--ink); }
.topic input { position: absolute; left: 1rem; top: 1rem; width: 22px; height: 22px; margin: 0; appearance: none; border: 2px solid var(--ink); border-radius: 50%; background: var(--paper); cursor: pointer; }
.topic input::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--tomato-deep); transform: scale(0); transition: transform 0.2s var(--ease); }
.topic input:checked::before { transform: scale(1); }
.topic input:focus-visible { outline: none; }
.topic:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 3px; }
.topic:has(input:checked) { border-color: var(--ink); background: var(--cream); box-shadow: inset 0 0 0 1px var(--ink); }
.topic__name { font-weight: 900; font-stretch: 62%; font-size: 1.45rem; line-height: 1; text-transform: uppercase; }
.topic__summary { font-size: 0.95rem; line-height: 1.4; color: var(--ink-soft); }

/*
 * Fields. Each field is a subgrid over the same six rows (label, hint, control,
 * count, file list, error), so two fields side by side keep their inputs level
 * when only one of them has a hint or an error.
 */
.contact__fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1.25rem; margin-top: clamp(1.75rem, 3vw, 2.5rem); padding-top: clamp(1.75rem, 3vw, 2.5rem); border-top: 1px solid var(--ink); }
.field { display: grid; grid-row: span 6; grid-template-rows: subgrid; grid-template-columns: minmax(0, 1fr); margin-bottom: 1.5rem; }
.field--textarea, .field--files { grid-column: 1 / -1; }
.field > label { grid-row: 1; font-weight: 700; }
.field__optional { margin-left: 0.35em; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); }
.field__hint { grid-row: 2; margin-top: 0.15rem; font-size: 0.95rem; line-height: 1.4; color: var(--ink-soft); }
.field > input, .field > select, .field > textarea, .drop { grid-row: 3; margin-top: 0.5rem; }
.field > input, .field > select, .field > textarea { width: 100%; min-height: var(--tap); padding: 0.7rem 1rem; border: 1px solid rgb(33 28 26 / 0.55); border-radius: 12px; background-color: var(--paper); transition: border-color 0.2s, box-shadow 0.2s; }
.field > input:hover, .field > select:hover, .field > textarea:hover { border-color: var(--ink); }
.field > input:focus-visible, .field > select:focus-visible, .field > textarea:focus-visible { outline: 3px solid var(--ink); outline-offset: 1px; }
.field > select { appearance: none; padding-right: 2.75rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23211c1a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 6 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; background-size: 16px; cursor: pointer; }
.field > textarea { min-height: 12rem; line-height: 1.55; resize: vertical; }
.field [aria-invalid] { border-color: #a3200a; box-shadow: inset 0 0 0 1px #a3200a; }
.field__count { grid-row: 4; margin-top: 0.35rem; font-size: 0.85rem; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.field--textarea .field__count { justify-self: end; }
.field__count--over { color: #a3200a; font-weight: 700; }
.field__error { grid-row: 6; margin-top: 0.4rem; font-size: 0.95rem; font-weight: 600; line-height: 1.4; color: #a3200a; }

/* Files. The picker needs the script, so it is left out without one. */
html:not(.js) .field--files { display: none; }
.drop { position: relative; display: grid; place-items: center; min-height: 10rem; padding: 1.5rem 1rem; border: 2px dashed rgb(33 28 26 / 0.55); border-radius: 14px; background: var(--cream); text-align: center; transition: border-color 0.2s, background-color 0.2s; }
/* The invisible input covers the whole area, so a click, a drop and the keyboard all reach it. */
.drop input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop:hover { border-color: var(--ink); }
.drop:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 3px; }
.drop.is-dragging { border-color: var(--tomato-deep); border-style: solid; background: var(--peach); }
.drop__face { display: grid; justify-items: center; gap: 0.35rem; pointer-events: none; }
.drop__face svg { margin-bottom: 0.25rem; fill: none; stroke: var(--tomato-deep); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.3s var(--ease); }
.drop.is-dragging svg { transform: translateY(-6px); }
.drop__face strong { font-weight: 900; font-stretch: 62%; font-size: 1.45rem; line-height: 1; text-transform: uppercase; }
.drop__face span { max-width: 26em; font-size: 0.95rem; line-height: 1.4; color: var(--ink-soft); }
.files { grid-row: 5; display: grid; gap: 0.5rem; margin: 0.75rem 0 0; }
.file { display: grid; grid-template-columns: 56px minmax(0, 1fr) 44px; gap: 0.75rem; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 12px; }
.file__thumb { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 8px; background: var(--cream); overflow: hidden; font-weight: 900; font-stretch: 62%; font-size: 1.1rem; }
/* A picture is fitted whole, never cropped, here as everywhere on the site. */
.file__thumb img { width: 100%; height: 100%; object-fit: contain; }
.file__text { display: grid; gap: 0.15rem; min-width: 0; }
.file__text strong { overflow: hidden; font-size: 0.95rem; text-overflow: ellipsis; white-space: nowrap; }
.file__text span { font-size: 0.85rem; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.file progress { appearance: none; display: block; width: 100%; height: 6px; margin-top: 0.2rem; border: 0; border-radius: 999px; background: var(--line); overflow: hidden; }
.file progress::-webkit-progress-bar { background: var(--line); }
.file progress::-webkit-progress-value { background: var(--tomato-deep); transition: width 0.2s linear; }
.file progress::-moz-progress-bar { background: var(--tomato-deep); }
.file button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; transition: background-color 0.2s; }
.file button:hover { background: var(--cream); }
.file button svg { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

/* Sending */
.contact .notice { margin-bottom: 1.25rem; font-weight: 600; }
.contact__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; }
.contact__actions .btn { min-width: 11rem; }
.contact__note { flex: 1 1 16rem; max-width: 30em; font-size: 0.9rem; line-height: 1.5; color: var(--ink-soft); }
.contact__note a { color: var(--tomato-deep); }

/* Sent */
.sent { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: clamp(1.25rem, 3vw, 2.5rem); align-items: center; padding-block: clamp(1rem, 3vw, 2.5rem); }
.sent:focus { outline: none; }
.sent .mark { width: clamp(96px, 13vw, 150px); height: auto; }
.sent__words { display: grid; gap: 1rem; justify-items: start; }
.sent__words strong { overflow-wrap: anywhere; }

@media (max-width: 640px) {
	.topics__list, .contact__fields { grid-template-columns: minmax(0, 1fr); }
	.topic { min-height: 0; }
	.contact__actions .btn { width: 100%; }
	.sent { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: no-preference) {
	/* `is-live` is set at the first change of topic, so nothing moves while the page loads. */
	.contact__form.is-live .field, .file, .sent { animation: contact-in 0.35s var(--ease) both; }
	@keyframes contact-in { from { opacity: 0; transform: translateY(8px); } }
}
