/*
 * bwillia.ms contact form - shared styles
 * Used by the homepage contact section and the Links page drop-down.
 * Markup and behaviour: /js/contact-form.js   Handler: /links/contact.php
 */

/* ---- Drop-down wrapper (Links page: the "Get in touch" card opens the form) ---- */
.cf-toggle {
	cursor: pointer;
	scroll-margin-top: 64px;
}

.cf-toggle:hover i,
.cf-toggle:focus-visible i {
	transform: none;
}

.cf-toggle[aria-expanded="true"] {
	border-color: #fff;
}

.cf-toggle[aria-expanded="true"] i {
	color: #fff;
	transform: rotate(180deg);
}

.cf-panel {
	display: grid;
	grid-template-rows: 0fr;
	visibility: hidden;
	transition: grid-template-rows 0.35s ease, visibility 0s linear 0.35s;
}

.cf-panel.is-open {
	grid-template-rows: 1fr;
	visibility: visible;
	transition: grid-template-rows 0.35s ease, visibility 0s;
}

.cf-panel-inner {
	min-height: 0;
	overflow: hidden;
}

.cf-form,
.cf-success {
	padding: 0 2px 8px 2px;
	color-scheme: dark;
}

.cf-panel-inner .cf-form,
.cf-panel-inner .cf-success {
	padding-top: 28px;
}

.cf-form fieldset {
	border: 0;
	min-width: 0;
	margin-bottom: 24px;
}

.cf-form legend,
.cf-field label {
	display: block;
	margin-bottom: 10px;
	font-size: 0.9rem;
	color: #ccc;
}

.cf-optional {
	color: #8a8a8a;
}

.cf-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.cf-chip {
	position: relative;
	display: inline-block;
}

.cf-chip input {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

.cf-chip span {
	display: inline-block;
	padding: 10px 18px;
	border: 1px solid #555;
	border-radius: 60px;
	font-size: 0.9rem;
	line-height: 1.2;
	color: #fff;
	transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.cf-chip input:hover + span {
	border-color: #fff;
}

.cf-chip input:checked + span {
	background-color: #fff;
	border-color: #fff;
	color: #000;
}

.cf-chip input:focus-visible + span {
	outline: 2px solid #fff;
	outline-offset: 3px;
}

.cf-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 0 16px;
}

.cf-field {
	margin-bottom: 24px;
}

.cf-field input,
.cf-field textarea,
.cf-field select {
	display: block;
	width: 100%;
	padding: 14px 16px;
	border: 1px solid #333;
	border-radius: 10px;
	background-color: transparent;
	color: #fff;
	font-size: 1rem;
	line-height: 1.4;
	outline: none;
	transition: border-color 0.2s;
}

.cf-field textarea {
	min-height: 150px;
	resize: vertical;
}

.cf-field select {
	-webkit-appearance: none;
	appearance: none;
	padding-right: 44px;
	background-color: #000;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 16px center;
}

.cf-field input::placeholder,
.cf-field textarea::placeholder {
	color: #777;
}

.cf-field input:focus,
.cf-field textarea:focus,
.cf-field select:focus {
	border-color: #fff;
}

.cf-field [aria-invalid="true"] {
	border-color: #ff6b6b;
}

/* Trap field for bots: kept out of sight and out of the tab order */
.cf-hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.cf-hold {
	position: relative;
	display: block;
	width: 100%;
	padding: 18px 22px;
	isolation: isolate;
	border: 1px solid #fff;
	border-radius: 10px;
	/* The white fill is the button's own background, growing from the left.
	   Being part of the button it always follows the rounded corners; a
	   separate sliding layer could briefly poke its square corners out. */
	background-color: transparent;
	background-image: linear-gradient(#fff, #fff);
	background-repeat: no-repeat;
	background-position: left center;
	background-size: 0% 100%;
	transition: background-size 0.2s ease-out;
	color: #fff;
	font-size: 1rem;
	font-weight: bold;
	letter-spacing: 1px;
	text-transform: uppercase;
	cursor: pointer;
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
	-webkit-tap-highlight-color: transparent;
	touch-action: none;
}

.cf-hold:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}

.cf-hold.is-holding {
	background-size: 100% 100%;
	transition: background-size 1.1s linear;
}

.cf-hold.is-done {
	background-size: 100% 100%;
	transition: none;
}

.cf-hold-label {
	position: relative;
	mix-blend-mode: difference;
	pointer-events: none;
}

.cf-hold[aria-disabled="true"] {
	cursor: default;
}

.cf-status {
	min-height: 1.5em;
	margin-top: 12px;
	font-size: 0.9rem;
	line-height: 1.5;
	color: #ccc;
}

.cf-status.is-error {
	color: #ff8a8a;
}

.cf-note {
	margin-top: 4px;
	font-size: 0.8rem;
	line-height: 1.5;
	color: #8a8a8a;
}

.cf-success h3 {
	font-size: 1.25rem;
	font-weight: 300;
	margin-bottom: 8px;
	outline: none;
}

.cf-success p {
	font-size: 1rem;
	line-height: 1.6;
	color: #ccc;
}

.cf-again {
	margin-top: 20px;
	padding: 10px 20px;
	border: 1px solid #fff;
	border-radius: 10px;
	background: none;
	color: #fff;
	font-size: 0.9rem;
	cursor: pointer;
	transition: background-color 0.2s;
}

.cf-again:hover,
.cf-again:focus-visible {
	background-color: rgba(255, 255, 255, 0.1);
}

/* ---- Homepage contact section: the form takes the wide first column ---- */
.cf-home {
	grid-column: 1;
	min-width: 0;
}

.cf-home > h3 {
	margin-bottom: 20px;
	font-weight: 300;
}

/* Homepage: a short lead-in and a button that drops the form down */
.cf-lead {
	max-width: 44ch;
	margin-bottom: 20px;
	font-size: 0.95rem;
	line-height: 1.6;
	color: #ccc;
}

.cf-open {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	padding: 12px 22px;
	background: none;
	border: 1px solid #fff;
	border-radius: 10px;
	color: #fff;
	font-size: 0.9rem;
	cursor: pointer;
	transition: background-color 0.3s ease;
}

.cf-open:hover,
.cf-open:focus-visible {
	background-color: rgba(255, 255, 255, 0.1);
}

.cf-open i {
	transition: transform 0.2s;
}

/* The button reads "Get in touch" when closed and "Hide form" when open */
.cf-open .cf-open-hide,
.cf-open[aria-expanded="true"] .cf-open-show {
	display: none;
}

.cf-open[aria-expanded="true"] .cf-open-hide {
	display: inline;
}

.cf-noscript {
	font-size: 0.9rem;
	line-height: 1.6;
	color: #ccc;
}

@media (min-width: 769px) {
	.contact-section--cf {
		grid-template-columns: 2fr 1fr 1fr;
		gap: 20px 40px;
	}
}

@media (max-width: 768px) {
	.cf-home {
		margin-bottom: 30px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cf-chip span,
	.cf-toggle i {
		transition: none;
	}

	.cf-panel,
	.cf-panel.is-open {
		transition: none;
	}
}
