/* ==========================================================================
   Newsletter opt-in — v11 "Graph paper"
   --------------------------------------------------------------------------
   The form is rendered by Contact Form 7 (inc/optin-form/cf7.php) with the
   theme's own classes on its fields; the rules below also neutralise CF7's
   default styles (list-item margins, red tips, bordered response box).

   One component in four places — the join band's panel, the sidebar widget,
   the modal and any [st_optin_form] shortcode — so there is a single
   treatment: a ruled ink field like a ledger entry, a square checkbox ticked
   in red pencil, a full-width red button that lifts off the page, and the
   publisher's notice set small underneath.
   ========================================================================== */

.st-optin {
	display: flex;
	flex-direction: column;
	gap: 0.95rem;
	width: 100%;
}

.st-optin__hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px; height: 1px;
	overflow: hidden;
}

.st-optin__field { position: relative; display: block; width: 100%; }

/* CF7 wrappers: make them transparent to the layout. */
.wpcf7:has(> .st-optin) { width: 100%; }
.st-optin .wpcf7-form-control-wrap { display: block; position: relative; }
.st-optin .wpcf7-list-item { display: block; margin: 0; }

/* ── Email field ──────────────────────────────────────────────────────── */
.st-optin__input {
	width: 100%;
	min-height: 54px;
	padding: 0.85rem 1rem 0.85rem 2.9rem;
	border: 1px solid var(--ink);
	border-radius: var(--radius, 3px);
	background: var(--field);
	color: var(--ink);
	font-family: var(--font-mono);
	font-size: 1rem; /* 16px keeps iOS from zooming on focus */
	line-height: 1.4;
	transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
	-webkit-appearance: none;
	appearance: none;
}
/* An "@" set in the margin of the field, drawn in the accent. */
.st-optin__field--email::before {
	content: "@";
	position: absolute;
	z-index: 1;
	top: 14px; left: 1rem;
	font-family: var(--font-display);
	font-size: 1.25rem;
	line-height: 1;
	color: var(--mint);
	pointer-events: none;
}
.st-optin__input::placeholder { color: var(--muted); opacity: 1; }
.st-optin__input:focus {
	outline: none;
	border-color: var(--mint);
	box-shadow: 3px 3px 0 var(--mint);
}

/* ── Consent ──────────────────────────────────────────────────────────── */
.st-optin__consent-label,
.st-optin__consent .wpcf7-list-item > label {
	display: grid;
	grid-template-columns: 20px minmax(0, 1fr);
	gap: 0.7rem;
	align-items: start;
	cursor: pointer;
}
.st-optin__checkbox {
	-webkit-appearance: none;
	appearance: none;
	width: 20px; height: 20px;
	margin: 0.1rem 0 0;
	border: 1px solid var(--ink);
	border-radius: 2px;
	background: var(--surface);
	cursor: pointer;
	display: grid;
	place-content: center;
	transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.st-optin__checkbox::after {
	content: "";
	width: 11px; height: 6px;
	margin-top: -3px;
	border-left: 2.5px solid var(--mint);
	border-bottom: 2.5px solid var(--mint);
	transform: rotate(-45deg) scale(0);
	transition: transform 0.18s var(--ease);
}
.st-optin__checkbox:checked { border-color: var(--mint); }
.st-optin__checkbox:checked::after { transform: rotate(-45deg) scale(1); }
.st-optin__checkbox:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }

.st-optin__consent-text,
.st-optin__consent .wpcf7-list-item-label {
	font-size: 0.8rem;
	line-height: 1.5;
	color: var(--ink-2);
}
.st-optin__consent .wpcf7-list-item-label a,
.st-optin__consent-text a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--mint); text-underline-offset: 2px; }
.st-optin__consent .wpcf7-list-item-label a:hover,
.st-optin__consent-text a:hover { color: var(--mint); }

/* ── Submit ───────────────────────────────────────────────────────────── */
.st-optin__submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.55rem;
	width: 100%;
	min-height: 54px;
	padding: 0.8rem 1.4rem;
	border: 1px solid var(--mint);
	border-radius: var(--radius, 3px);
	background: var(--mint);
	color: var(--mint-ink);
	font-family: var(--font-body);
	font-size: 1rem;
	font-weight: 700;
	letter-spacing: 0.01em;
	cursor: pointer;
	transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), background-color 0.2s;
}
.st-optin__submit svg {
	width: 18px; height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	transition: transform 0.25s var(--ease);
}
.st-optin__submit:hover { background: var(--mint-2); border-color: var(--ink); transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--shadow-ink, var(--ink)); }
.st-optin__submit:hover svg { transform: translateX(4px); }
.st-optin__submit:active { transform: none; box-shadow: none; }
.st-optin__submit:disabled { opacity: 0.6; cursor: progress; transform: none; box-shadow: none; }

/* While CF7 submits, the arrow is replaced by a turning "∑". */
.st-optin.submitting .st-optin__submit svg { opacity: 0; }
.st-optin.submitting .st-optin__submit::after {
	content: "∑";
	margin-left: -1.6rem;
	font-family: var(--font-display);
	font-size: 1.1rem;
	animation: st-optin-spin 0.9s linear infinite;
}
@keyframes st-optin-spin { to { transform: rotate(360deg); } }
.st-optin .wpcf7-spinner { display: none; }

/* ── Messages ─────────────────────────────────────────────────────────── */
.wpcf7 form.st-optin.wpcf7-form .wpcf7-response-output {
	margin: 0;
	padding: 0.75rem 0.9rem;
	border: 1px solid var(--line-2);
	border-left: 3px solid var(--danger);
	border-radius: 0;
	background: var(--surface);
	font-size: 0.86rem;
	line-height: 1.45;
	color: var(--ink);
}
.wpcf7 form.st-optin.wpcf7-form .wpcf7-response-output:empty { display: none; }
.wpcf7 form.st-optin.sent .wpcf7-response-output { border-left-color: var(--mint); }

.st-optin .wpcf7-not-valid-tip {
	margin-top: 0.4rem;
	font-family: var(--font-mono);
	font-size: 0.75rem;
	color: var(--danger);
}
.st-optin .st-optin__input[aria-invalid="true"] { border-color: var(--danger); }
.st-optin .st-optin__checkbox[aria-invalid="true"] { border-color: var(--danger); }
.st-optin__consent .wpcf7-not-valid-tip { padding-left: calc(20px + 0.7rem); }
.st-optin.sent .st-optin__submit { background: var(--ink); border-color: var(--ink); }

/* ── Legal footer ─────────────────────────────────────────────────────── */
.st-optin__footer {
	display: flex;
	flex-wrap: wrap;
	gap: 0.15rem 0.75rem;
	padding-top: 0.85rem;
	border-top: 1px dashed var(--line-2);
	font-family: var(--font-mono);
	font-size: 0.7rem;
	line-height: 1.5;
	letter-spacing: 0.01em;
	color: var(--muted);
}
.st-optin__company { font-weight: 500; color: var(--ink-2); }
.st-optin__support { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.st-optin__support:hover { color: var(--mint); }
.st-optin__parent {
	flex-basis: 100%;
	margin: 0.35rem 0 0;
	font-family: var(--font-body);
	font-size: 0.72rem;
	line-height: 1.5;
	letter-spacing: 0;
	color: var(--muted);
}

.st-optin__recaptcha {
	flex-basis: 100%;
	margin: 0.35rem 0 0;
	font-family: var(--font-body);
	font-size: 0.68rem;
	line-height: 1.5;
	letter-spacing: 0;
	color: var(--muted);
}
.st-optin__recaptcha a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.st-optin__recaptcha a:hover { color: var(--mint); }

/* ── Subscribe modal ──────────────────────────────────────────────────── */
.st-modal {
	position: fixed;
	inset: 0;
	z-index: 300;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}
.st-modal[hidden] { display: none; }

.st-modal__backdrop {
	position: absolute;
	inset: 0;
	background: color-mix(in srgb, var(--scrim) 55%, transparent);
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
	animation: st-modal-fade 0.25s var(--ease);
}

.st-modal__dialog {
	position: relative;
	width: min(480px, 100%);
	max-height: calc(100dvh - 40px);
	overflow-y: auto;
	padding: 2.2rem 2rem 1.75rem;
	border: 1px solid var(--ink);
	border-radius: 0;
	background-color: var(--surface);
	background-image:
		linear-gradient(var(--grid) 1px, transparent 1px),
		linear-gradient(90deg, var(--grid) 1px, transparent 1px);
	background-size: 24px 24px;
	background-position: -1px -1px;
	box-shadow: 10px 10px 0 var(--shadow-ink, var(--ink));
	animation: st-modal-rise 0.4s var(--ease);
}

/* The curve across the top of the card, re-drawn each time it opens. */
.st-modal__plot { display: block; width: 100%; height: 64px; margin-bottom: 0.4rem; overflow: visible; pointer-events: none; }
.st-modal__axis { fill: none; stroke: var(--line-2); stroke-width: 1; vector-effect: non-scaling-stroke; }
.st-modal__curve {
	fill: none;
	stroke: var(--mint);
	stroke-width: 2;
	stroke-linecap: round;
	vector-effect: non-scaling-stroke;
	stroke-dasharray: 1;
	stroke-dashoffset: 1;
	animation: st-modal-draw 1.6s var(--ease) 0.2s forwards;
}
.st-modal__dot { fill: var(--mint); transform-box: fill-box; transform-origin: center; transform: scale(0); animation: st-modal-pop 0.4s var(--ease) 1.6s forwards; }
@keyframes st-modal-draw { to { stroke-dashoffset: 0; } }
@keyframes st-modal-pop { to { transform: scale(1); } }

.st-modal__close {
	position: absolute;
	top: 12px; right: 12px;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px; height: 40px;
	border: 1px solid var(--ink);
	border-radius: var(--radius, 3px);
	background: var(--surface);
	cursor: pointer;
	transition: background-color 0.2s, transform 0.2s var(--ease);
}
.st-modal__close svg { width: 16px; height: 16px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.st-modal__close:hover { transform: rotate(90deg); background: var(--bg); }

.st-modal__kicker {
	font-family: var(--font-mono);
	font-size: 0.72rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--mint);
}
.st-modal__title {
	margin-top: 0.55rem;
	max-width: 15ch;
	font-family: var(--font-display);
	font-size: clamp(1.8rem, 1.4rem + 1.6vw, 2.4rem);
	font-weight: 400;
	letter-spacing: -0.025em;
	line-height: 1.05;
}
.st-modal__sub {
	margin: 0.9rem 0 1.5rem;
	font-family: var(--font-text);
	font-size: 1rem;
	line-height: 1.5;
	color: var(--ink-2);
}

body.st-modal-open { overflow: hidden; }

@keyframes st-modal-fade { from { opacity: 0; } }
@keyframes st-modal-rise { from { opacity: 0; transform: translateY(18px) rotate(-0.6deg); } }

@media (max-width: 480px) {
	.st-modal { padding: 10px; align-items: flex-end; }
	.st-modal__dialog { padding: 1.75rem 1.25rem 1.25rem; max-height: calc(100dvh - 20px); box-shadow: 6px 6px 0 var(--shadow-ink, var(--ink)); }
}

@media (prefers-reduced-motion: reduce) {
	.st-modal__backdrop, .st-modal__dialog, .st-modal__curve, .st-modal__dot { animation: none; }
	.st-modal__curve { stroke-dashoffset: 0; }
	.st-modal__dot { transform: none; }
}
