/*
 * SMTM Mail and Contact: the Contact us pop-up.
 *
 * Colours: the pop-up reads the SMTM colour variables (--smtm-accent and friends) when the page has them, and
 * otherwise the plugin's own accent colour (--smtmmc-accent, set on the settings screen and written into the page by
 * the plugin). Everything is scoped to .smtm-ct-dialog, so it cannot change anything else on the page.
 */

.smtm-ct-dialog {
	--ct-accent: var(--smtm-accent, var(--smtmmc-accent, #1b2d5e));
	--ct-accent-fg: var(--smtm-accent-fg, var(--smtmmc-accent-fg, #ffffff));
	--ct-accent-text: var(--smtm-accent-text, var(--ct-accent));
	--ct-text: var(--smtm-text, #1a1a2e);
	--ct-surface: var(--smtm-surface, #ffffff);
	--ct-muted: color-mix(in srgb, var(--ct-text) 62%, var(--ct-surface));
	--ct-line: color-mix(in srgb, var(--ct-text) 20%, var(--ct-surface));
	--ct-ring: color-mix(in srgb, var(--ct-accent) 24%, transparent);

	position: fixed;
	inset: 0;
	margin: auto;
	height: fit-content;
	max-height: calc(100% - 24px);
	overflow: auto;
	border: 0;
	border-radius: 17px;
	padding: 0 30px 14px;
	max-width: 490px;
	width: calc(100% - 32px);
	box-sizing: border-box;
	box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
	background: var(--ct-surface);
	color: var(--ct-text);
	font-family: inherit;
	line-height: 1.5;
}
.smtm-ct-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.smtm-ct-dialog *, .smtm-ct-dialog *::before, .smtm-ct-dialog *::after { box-sizing: border-box; }

/* Header band with the envelope icon, the title and the close button. */
.smtm-ct-top {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 18px;
	margin: 0 -30px 12px;
	padding: 14px 30px 12px;
	background: linear-gradient(125deg, color-mix(in srgb, var(--ct-accent) 10%, var(--ct-surface)), color-mix(in srgb, var(--ct-accent) 3%, var(--ct-surface)));
}
.smtm-ct-brand {
	flex: none;
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 12px;
	background: var(--ct-accent);
	color: var(--ct-accent-fg);
}
.smtm-ct-heading { flex: 1; min-width: 0; }
.smtm-ct-top h2 { margin: 0; font-family: inherit; font-weight: 700; font-size: 1.55rem; line-height: 1.2; letter-spacing: -.01em; color: var(--ct-text); }
.smtm-ct-sub { margin: 6px 0 0; font-size: .92rem; line-height: 1.5; color: var(--ct-muted); }
/*
 * The two buttons (close and send) are written as ".smtm-ct-dialog .smtm-ct-..." on purpose. Many themes style every
 * button on the site (for example an outline, a colour and padding), and a rule of the same weight that loads later
 * wins. The extra ".smtm-ct-dialog" makes these rules stronger, so the buttons look the same on any theme. The hover
 * and focus rules say the colours out loud for the same reason, because themes also style those states.
 */
.smtm-ct-dialog .smtm-ct-close {
	flex: none;
	align-self: flex-start;
	width: 30px;
	height: 30px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	color: inherit;
	box-shadow: none;
	text-decoration: none;
	cursor: pointer;
}
.smtm-ct-dialog .smtm-ct-close:focus { background: transparent; color: inherit; }
.smtm-ct-dialog .smtm-ct-close:hover { background: color-mix(in srgb, var(--ct-text) 8%, transparent); color: inherit; }
.smtm-ct-dialog .smtm-ct-close:focus-visible, .smtm-ct-dialog .smtm-ct-send:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ct-ring); }

/* The answer shown after sending. */
.smtm-ct-msg { padding: 12px 14px; border-radius: 12px; border: 1px solid; margin: 0 0 16px; font-size: .92rem; line-height: 1.45; }
.smtm-ct-msg[hidden] { display: none; }
.smtm-ct-msg.ok { background: rgba(46, 125, 50, .1); border-color: #2e7d32; }
.smtm-ct-msg.bad { background: rgba(198, 40, 40, .1); border-color: #c62828; }

/* The form. */
.smtm-ct-form { display: flex; flex-direction: column; gap: 8px; }
.smtm-ct-form[hidden] { display: none; }
.smtm-ct-form .smtm-ct-field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.smtm-ct-form .smtm-ct-field > span { font-size: .9rem; font-weight: 600; }
.smtm-ct-form input[type=text],
.smtm-ct-form input[type=email],
.smtm-ct-form select,
.smtm-ct-form textarea {
	width: 100%;
	border: 1px solid var(--ct-line);
	border-radius: 9px;
	font: inherit;
	font-size: 1rem;
	background: var(--ct-surface);
	color: var(--ct-text);
	box-shadow: none;
}
.smtm-ct-form input[type=text], .smtm-ct-form input[type=email], .smtm-ct-form select { height: 40px; padding: 0 14px; }
.smtm-ct-form textarea { min-height: 62px; padding: 9px 14px; line-height: 1.5; resize: vertical; }
.smtm-ct-form select {
	appearance: none;
	-webkit-appearance: none;
	padding-right: 40px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none' stroke='%238a90a3' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5l4 4 4-4'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 16px center;
}
.smtm-ct-form input:focus, .smtm-ct-form select:focus, .smtm-ct-form textarea:focus {
	outline: none;
	border-color: var(--ct-accent);
	box-shadow: 0 0 0 3px var(--ct-ring);
}

/* The security sum. */
.smtm-ct-form .smtm-ct-sum {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin: 0;
	padding: 8px 12px;
	border-radius: 10px;
	background: color-mix(in srgb, var(--ct-accent) 11%, var(--ct-surface));
}
.smtm-ct-sum-t { display: flex; flex-direction: column; font-size: .9rem; line-height: 1.4; }
.smtm-ct-sum-t b { font-weight: 600; }
.smtm-ct-sum-t > span { color: var(--ct-muted); }
.smtm-ct-form .smtm-ct-sum input { flex: none; width: 76px; height: 38px; padding: 0 10px; border-radius: 10px; text-align: center; font-size: 1.05rem; }

/* The "also send my answers" box, with its preview. */
.smtm-ct-share { padding: 12px 14px; border: 1px solid var(--ct-line); border-radius: 12px; font-size: .9rem; }
.smtm-ct-share[hidden] { display: none; }
.smtm-ct-share label { display: flex; flex-direction: row; gap: 8px; align-items: flex-start; margin: 0; font-weight: 500; cursor: pointer; }
.smtm-ct-share input.smtm-ct-share-ok { width: auto; height: auto; flex: none; margin: 3px 0 0; }
.smtm-ct-share details { margin-top: 8px; }
.smtm-ct-share summary { cursor: pointer; font-size: .85rem; }
.smtm-ct-share pre { margin: 8px 0 0; max-height: 180px; overflow: auto; white-space: pre-wrap; font: 12px/1.5 ui-monospace, monospace; background: transparent; border: 0; padding: 0; color: inherit; }

/* The send button and the small print. */
.smtm-ct-dialog .smtm-ct-send {
	width: 100%;
	height: 48px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 9px;
	background: var(--ct-accent);
	color: var(--ct-accent-fg);
	font: inherit;
	font-size: 1rem;
	font-weight: 600;
	box-shadow: none;
	text-decoration: none;
	cursor: pointer;
	text-transform: none;
	letter-spacing: normal;
}
.smtm-ct-dialog .smtm-ct-send span { margin-left: 8px; font-size: 1.3em; vertical-align: -1px; }
.smtm-ct-dialog .smtm-ct-send:hover,
.smtm-ct-dialog .smtm-ct-send:focus { background: var(--ct-accent); color: var(--ct-accent-fg); filter: brightness(1.08); }
.smtm-ct-dialog .smtm-ct-send:disabled { opacity: .6; cursor: default; }
.smtm-ct-help { margin: 0; font-size: .82rem; line-height: 1.5; text-align: center; color: var(--ct-muted); }

/* The ready-made [smtmmc_contact_button]. A theme can restyle it freely. */
.smtm-ct-open { cursor: pointer; }

@media (max-width: 520px) {
	.smtm-ct-dialog { padding: 0 18px 20px; width: calc(100% - 20px); }
	.smtm-ct-top { margin: 0 -18px 16px; padding: 20px 18px; gap: 12px; }
	.smtm-ct-brand { width: 44px; height: 44px; }
	.smtm-ct-top h2 { font-size: 1.3rem; }
	.smtm-ct-form { gap: 11px; }
}
