/**
 * ZAI COFFEE — Contact page form
 * -----------------------------------------------------------------------------
 * Phase 8.6. Loaded on the Contact page (`iletisim`) only.
 *
 * SCOPE CONTRACT
 * --------------
 * Every selector in this file is prefixed with `.zai-cform` or is scoped under
 * `.zai-page--contact`. `17-content.css` is NOT edited: a page-specific feature
 * must never change another page's cascade, and 17-content.css is shared by the
 * About, Guide, FAQ and legal documents.
 *
 * The single hero-scoped block at the top is the only rule that touches an
 * element this module does not own. It is gated on the `.zai-hero--contact`
 * modifier, which exists on the Contact hero and nowhere else, and it only
 * adds a grid in which the existing text keeps the left column unchanged.
 *
 * @package zaicoffeetheme
 * @since   1.9.2
 */

/* ==========================================================================
   1. Two-column hero
   --------------------------------------------------------------------------
   The hero already exists and is centred text inside a 46rem plate. On desktop
   the previously empty right half becomes the form's column:
     - the text column is constrained to its authored 40rem measure, so its
       line lengths and every glyph position are unchanged;
     - the grid gap replaces the whitespace the design already used;
     - below 1024px everything stacks, text first, exactly as before.
   ========================================================================== */

@media (min-width: 1024px) {
	.zai-hero--contact {
		display: grid;
		grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr);
		align-items: start;
		gap: var(--zai-space-10);
	}

	/* The hero's generic `> *` rule caps every child at the 1320px container and
	   re-applies the gutter. Both are already satisfied by the grid track, so the
	   padding is removed here to keep the two columns optically balanced. */
	.zai-hero--contact > .zai-hero__text,
	.zai-hero--contact > .zai-cform {
		width: 100%;
		max-width: none;
		margin-inline: 0;
		padding-inline: 0;
	}

	.zai-hero--contact > .zai-hero__text {
		max-width: 40rem;
		padding-block-start: var(--zai-space-2);
	}
}

/* ==========================================================================
   2. The form card
   ========================================================================== */

.zai-cform {
	position: relative;
	box-sizing: border-box;
	width: 100%;
	min-width: 0;
	padding: clamp(1.5rem, 3vw, 2.25rem);
	background-color: var(--zai-bg);
	border: var(--zai-border-width) solid var(--zai-border-color);
	border-radius: var(--zai-radius);
	text-align: start;
}

/* A single green hairline along the top edge is the only decoration. */
.zai-cform::before {
	content: "";
	position: absolute;
	inset-block-start: calc(var(--zai-border-width) * -1);
	inset-inline-start: -1px;
	width: 4.5rem;
	height: var(--zai-border-width-strong);
	background-color: var(--zai-green);
}

.zai-cform__intro {
	margin-block-end: var(--zai-space-6);
}

.zai-cform__eyebrow {
	margin: 0 0 var(--zai-space-2);
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-eyebrow);
	font-weight: var(--zai-fw-semibold);
	line-height: var(--zai-lh-normal);
	letter-spacing: var(--zai-ls-caps);
	text-transform: uppercase;
	color: var(--zai-green);
}

.zai-cform__title {
	margin: 0 0 var(--zai-space-2);
	font-family: var(--zai-font-display);
	font-size: var(--zai-fs-h4);
	font-weight: var(--zai-fw-light);
	line-height: var(--zai-lh-tight);
	letter-spacing: var(--zai-ls-tighter);
	color: var(--zai-ink);
	text-wrap: balance;
}

.zai-cform__hint {
	margin: 0;
	max-width: 44ch;
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-sm);
	line-height: var(--zai-lh-relaxed);
	color: var(--zai-text-muted);
	text-wrap: pretty;
}


/* ==========================================================================
   3. Field grid
   --------------------------------------------------------------------------
   Two columns from 640px for the short pairs (e-mail / phone), one column below
   so a phone keyboard never has to share the viewport with a second field.
   ========================================================================== */

.zai-cform__form {
	margin: 0;
}

.zai-cform__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--zai-space-5) var(--zai-space-5);
}

@media (min-width: 640px) {
	.zai-cform__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.zai-cform__field--half {
		grid-column: span 1;
	}
}

.zai-cform__field--full {
	grid-column: 1 / -1;
}

.zai-cform__field {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

/* ==========================================================================
   4. Labels
   --------------------------------------------------------------------------
   Manrope, small-caps rhythm, one step darker than the input text so the label
   reads as a caption rather than competing with the value.
   ========================================================================== */

.zai-cform__label {
	display: block;
	margin: 0 0 var(--zai-space-2);
	padding: 0;
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-xs);
	font-weight: var(--zai-fw-semibold);
	line-height: var(--zai-lh-snug);
	letter-spacing: var(--zai-ls-wide);
	text-transform: uppercase;
	color: var(--zai-text-muted);
}

/* The required mark is a glyph plus hidden text, so it never depends on colour. */
.zai-cform__req {
	margin-inline-start: 0.3em;
}

/* ==========================================================================
   5. Inputs — bottom-rule treatment
   --------------------------------------------------------------------------
   The editorial direction calls for thin rules rather than boxed fields. The
   control keeps a transparent full border so its 48px hit area and the focus
   ring are unaffected, and only the bottom edge carries a visible stroke. A
   warm tint appears on hover/focus so it still reads unmistakably as a control.
   ========================================================================== */

.zai-cform__input {
	display: block;
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	/* Never below the theme's 48px control height / 44px touch target. */
	min-height: var(--zai-control-height);
	margin: 0;
	padding: var(--zai-space-2) 0;
	background-color: transparent;
	border: 0;
	border-block-end: var(--zai-border-width) solid var(--zai-border-color-strong);
	border-radius: 0;
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-base);
	font-weight: var(--zai-fw-regular);
	line-height: var(--zai-lh-snug);
	color: var(--zai-ink);
	appearance: none;
	transition:
		border-color var(--zai-dur-fast) var(--zai-ease),
		background-color var(--zai-dur-fast) var(--zai-ease),
		padding-inline var(--zai-dur-fast) var(--zai-ease);
}

.zai-cform__input::placeholder {
	color: var(--zai-text-subtle);
	font-size: var(--zai-fs-sm);
	opacity: 1;
}

.zai-cform__input:hover {
	border-block-end-color: var(--zai-text-subtle);
}

/*
 * Focus: the rule becomes ZAI Green and a soft warm tint confirms the active
 * field. The outline is the accessible indicator — it survives high-contrast
 * mode and is never suppressed — while the colour change is the refinement.
 */
.zai-cform__input:focus,
.zai-cform__input:focus-visible {
	padding-inline: var(--zai-space-2);
	background-color: var(--zai-bg-soft);
	border-block-end-color: var(--zai-green);
	outline: var(--zai-focus-width) solid var(--zai-focus-color);
	outline-offset: 1px;
}

.zai-cform__input:disabled {
	background-color: var(--zai-bg-alt);
	color: var(--zai-text-subtle);
	cursor: not-allowed;
}

/* --- Textarea ------------------------------------------------------------ */

.zai-cform__textarea {
	min-height: 7.5rem;
	padding-block: var(--zai-space-3);
	line-height: var(--zai-lh-relaxed);
	resize: vertical;
}

/* --- Select -------------------------------------------------------------- */

.zai-cform__select-wrap {
	position: relative;
	display: block;
	min-width: 0;
}

.zai-cform__select {
	padding-inline-end: var(--zai-space-7);
	cursor: pointer;
}

/* The native arrow is replaced by the theme glyph, so the control matches the
   rest of the set. The element is decorative; the select keeps its semantics. */
.zai-cform__select-icon {
	position: absolute;
	inset-block-start: 50%;
	inset-inline-end: var(--zai-space-1);
	display: flex;
	align-items: center;
	transform: translateY(-50%);
	pointer-events: none;
	color: var(--zai-text-subtle);
	transition: color var(--zai-dur-fast) var(--zai-ease);
}

/* ==========================================================================
   6. Consent row
   --------------------------------------------------------------------------
   The checkbox keeps native sizing (inherited from 03-base.css) so it stays a
   familiar, reliably clickable control. The label is reset from the global
   `label` rule, which would otherwise uppercase it and add a bottom margin.
   ========================================================================== */

.zai-cform__field--consent {
	margin-block-start: var(--zai-space-6);
}

.zai-cform__check {
	display: flex;
	align-items: flex-start;
	gap: var(--zai-space-3);
}

.zai-cform__check input[type="checkbox"] {
	margin-block-start: 0.2em;
	flex-shrink: 0;
	accent-color: var(--zai-green);
}

.zai-cform__check input[type="checkbox"]:focus-visible {
	outline: var(--zai-focus-width) solid var(--zai-focus-color);
	outline-offset: var(--zai-focus-offset);
}

.zai-cform__check-label {
	display: block;
	margin: 0;
	padding: 0;
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-xs);
	font-weight: var(--zai-fw-regular);
	line-height: var(--zai-lh-normal);
	letter-spacing: var(--zai-ls-normal);
	text-transform: none;
	color: var(--zai-text-muted);
	cursor: pointer;
}

.zai-cform__link {
	color: var(--zai-green);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.22em;
	transition: color var(--zai-dur-fast) var(--zai-ease);
}

.zai-cform__link:hover {
	color: var(--zai-green-hover);
}

.zai-cform__link:focus-visible {
	outline: var(--zai-focus-width) solid var(--zai-focus-color);
	outline-offset: var(--zai-focus-offset);
}

/* ==========================================================================
   7. Submit
   ========================================================================== */

.zai-cform__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--zai-space-4);
	margin-block-start: var(--zai-space-6);
}

.zai-cform__submit {
	position: relative;
	min-width: 11rem;
	padding-inline: var(--zai-space-8);
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-sm);
	font-weight: var(--zai-fw-semibold);
	letter-spacing: var(--zai-ls-wide);
	background-color: var(--zai-green);
	border-color: var(--zai-green);
	color: var(--zai-text-inverse);
}

.zai-cform__submit:hover {
	background-color: var(--zai-green-hover);
	border-color: var(--zai-green-hover);
	color: var(--zai-text-inverse);
}

.zai-cform__submit:active {
	background-color: var(--zai-green-active);
	border-color: var(--zai-green-active);
}

.zai-cform__submit:focus-visible {
	outline: var(--zai-focus-width) solid var(--zai-focus-color);
	outline-offset: var(--zai-focus-offset);
}

/* The submitting state is visible, not implied: the label fades and the shared
   coffee cup loader replaces it. `aria-busy` is set by the script and carries the
   same meaning to assistive technology.
   PHASE 8.8 — the form used to draw its own square border spinner here. It now
   renders the sitewide coffee cup component (inc/coffee-loader.php), so only the
   form's own show/hide state remains in this sheet. */
.zai-cform__loader {
	position: absolute;
	inset-block-start: 50%;
	inset-inline-start: 50%;
	/*
	 * `display: none` is re-asserted against the component's own
	 * `.ldr-coffee-cup { display: block }` by matching it with a compound
	 * selector, not by relying on source order alone.
	 */
	display: none;
	margin-block-start: -13px;
	margin-inline-start: -13px;
}

/* The cup must never be visible unless the form is actually submitting. */
.ldr-coffee-cup.zai-cform__loader {
	display: none;
}

.zai-cform.is-submitting .ldr-coffee-cup.zai-cform__loader {
	display: block;
}

/* Hidden rather than removed, so the POST in flight never changes the button's
   width or height. */
.zai-cform.is-submitting .zai-cform__submit-label {
	visibility: hidden;
}

.zai-cform.is-submitting .zai-cform__submit {
	cursor: progress;
}

/* Screen-reader-only live region beside the button. */
.zai-cform__status {
	margin: 0;
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-xs);
	line-height: var(--zai-lh-normal);
	color: var(--zai-text-muted);
}

/* ==========================================================================
   8. Feedback banner
   --------------------------------------------------------------------------
   Success and failure differ by icon, heading weight and border colour, not by
   colour alone — the icon shape is legible in greyscale and in forced-colours
   mode.
   ========================================================================== */

.zai-cform__notice {
	display: flex;
	align-items: flex-start;
	gap: var(--zai-space-3);
	margin-block-end: var(--zai-space-6);
	padding: var(--zai-space-4) var(--zai-space-5);
	border: var(--zai-border-width) solid var(--zai-border-color);
	border-inline-start-width: var(--zai-border-width-strong);
	border-radius: var(--zai-radius);
}

.zai-cform__notice--success {
	background-color: var(--zai-success-bg);
	border-inline-start-color: var(--zai-success);
}

.zai-cform__notice--error {
	background-color: var(--zai-error-bg);
	border-inline-start-color: var(--zai-error);
}

.zai-cform__notice-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	margin-block-start: 0.1em;
}

.zai-cform__notice--success .zai-cform__notice-icon {
	color: var(--zai-success);
}

.zai-cform__notice--error .zai-cform__notice-icon {
	color: var(--zai-error);
}

.zai-cform__notice-text {
	margin: 0;
	max-width: none;
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-sm);
	font-weight: var(--zai-fw-medium);
	line-height: var(--zai-lh-normal);
	color: var(--zai-ink);
}

/* When the page is reached with a status, the anchor lands on the form; this
   keeps the banner clear of the sticky header. */
.zai-cform {
	scroll-margin-block-start: calc(var(--zai-header-height-scrolled) + var(--zai-space-4));
}

/* ==========================================================================
   9. Field errors
   --------------------------------------------------------------------------
   The message is real text in the field's own paragraph, wired through
   aria-describedby, so a colour-blind or screen-reader user learns exactly which
   field failed and why. Colour is reinforcement, never the carrier.
   ========================================================================== */

.zai-cform__error {
	margin: var(--zai-space-2) 0 0;
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-xs);
	font-weight: var(--zai-fw-medium);
	line-height: var(--zai-lh-normal);
	color: var(--zai-error);
}

.zai-cform__error[hidden] {
	display: none;
}

/* Invalid controls change colour AND gain a thicker rule, so the state does not
   rely on hue. `aria-invalid` is the machine-readable source of truth. */
.zai-cform__input[aria-invalid="true"] {
	border-block-end-color: var(--zai-error);
	border-block-end-width: var(--zai-border-width-strong);
}

.zai-cform__input[aria-invalid="true"]:focus,
.zai-cform__input[aria-invalid="true"]:focus-visible {
	border-block-end-color: var(--zai-error);
}

.zai-cform__check input[type="checkbox"][aria-invalid="true"] {
	outline: var(--zai-border-width-strong) solid var(--zai-error);
	outline-offset: 2px;
}

/* ==========================================================================
   10. Honeypot
   --------------------------------------------------------------------------
   Removed from the visual and accessibility tree without using
   `display:none` — some bots skip hidden inputs, so the trap is positioned off
   screen and given a zero size instead. It cannot be tabbed into
   (`tabindex="-1"` in the markup) and cannot be scrolled to.
   ========================================================================== */

.zai-cform__hp {
	position: absolute !important;
	inset-inline-start: -9999px;
	width: 1px;
}

/* ==========================================================================
   11. Responsive refinements
   --------------------------------------------------------------------------
   Mobile is not a shrunken desktop: the card loses its border so the form reads
   as part of the page rather than an embedded widget, padding tightens to the
   viewport gutter, and the submit button becomes full width for a comfortable
   thumb target.
   ========================================================================== */

@media (max-width: 1023px) {
	.zai-cform {
		margin-block-start: var(--zai-space-9);
	}
}

@media (max-width: 639px) {
	.zai-cform {
		padding: clamp(1.25rem, 5vw, 1.75rem) clamp(1rem, 4vw, 1.5rem);
		/* Edge-to-edge on the narrowest screens, with the gutter as the only inset. */
		border-inline: 0;
		border-block-end: 0;
		border-radius: 0;
	}

	/* Restore the top hairline as the card's only edge on mobile. */
	.zai-cform::before {
		inset-inline-start: 0;
		width: 100%;
		max-width: 4.5rem;
	}

	.zai-cform__eyebrow {
		font-size: var(--zai-fs-xs);
	}

	.zai-cform__title {
		font-size: var(--zai-fs-h5);
	}

	.zai-cform__actions {
		flex-direction: column;
		align-items: stretch;
		gap: var(--zai-space-3);
	}

	.zai-cform__submit {
		width: 100%;
		/* Well above the 44px minimum on the platform where it matters most. */
		min-height: 3.25rem;
	}

	.zai-cform__status:empty {
		display: none;
	}

	.zai-cform__status {
		text-align: center;
	}
}

/* Tablet: give the form a little more room than the text column so the fields
   never feel cramped between 768px and 1023px, where they are stacked. */
@media (min-width: 768px) and (max-width: 1023px) {
	.zai-cform {
		max-width: 40rem;
		margin-inline: auto;
	}
}

/* ==========================================================================
   12. Forced colours and reduced motion
   ========================================================================== */

@media (forced-colors: active) {
	.zai-cform,
	.zai-cform__input,
	.zai-cform__notice {
		border-color: CanvasText;
	}

	.zai-cform__submit {
		border-color: ButtonText;
	}

	.zai-cform__req,
	.zai-cform__notice-icon {
		color: CanvasText;
	}
}

@media (prefers-reduced-motion: reduce) {
	.zai-cform__input {
		transition: none;
	}
}

/* ==========================================================================
   13. Print
   --------------------------------------------------------------------------
   A printed contact page should show the form as a document, not a card.
   ========================================================================== */

@media print {
	.zai-cform {
		border-color: #000000;
	}

	.zai-cform__submit,
	.zai-cform__hp {
		display: none;
	}
}

/* Visually hidden, still announced: used by the honeypot and the invalid-key
   echo. `clip-path` rather than `display:none` so it stays in the a11y tree. */
.zai-cform__hp,
.zai-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: 0;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.zai-cform__status:empty {
	display: none;
}

/* Select chevron accent. */
.zai-cform__select:hover + .zai-cform__select-icon,
.zai-cform__select:focus + .zai-cform__select-icon {
	font-weight: var(--zai-fw-medium);
	color: var(--zai-green);
}
