/* ==========================================================================
   Underground History — submissions modal
   Markup: templates/submit-modal.php. Behaviour: assets/js/submit.js.
   Built on the site's own :root variables in styles.css, so a palette change
   there carries through.
   ========================================================================== */

/* ---------- the dialog ---------------------------------------------------- */

.uh-modal {
	width: min(640px, calc(100vw - 2 * var(--gutter, 24px)));
	max-height: calc(100dvh - 2 * var(--gutter, 24px));
	margin: auto;
	padding: 0;
	border: 1px solid var(--c-rule);
	border-top: 4px solid var(--c-red-700);
	background: var(--c-surface);
	color: var(--c-ink);
	box-shadow: var(--shadow);
	overflow: auto;
	overscroll-behavior: contain;
}
.uh-modal::backdrop {
	background: rgb(0 0 0 / 0.72);
	backdrop-filter: blur(2px);
}

/* open / close motion */
.uh-modal[open] { animation: uh-modal-in 0.28s cubic-bezier(.2, .7, .2, 1); }
.uh-modal[open]::backdrop { animation: uh-fade-in 0.28s ease-out; }
.uh-modal.is-closing { animation: uh-modal-out 0.18s ease-in forwards; }
.uh-modal.is-closing::backdrop { animation: uh-fade-out 0.18s ease-in forwards; }

@keyframes uh-modal-in  { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes uh-modal-out { to   { opacity: 0; transform: translateY(8px); } }
@keyframes uh-fade-in   { from { opacity: 0; } }
@keyframes uh-fade-out  { to   { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
	.uh-modal[open], .uh-modal[open]::backdrop,
	.uh-modal.is-closing, .uh-modal.is-closing::backdrop { animation: none; }
}

html.uh-modal-lock { overflow: hidden; }

/* No JavaScript: a link to #submit targets the closed <dialog> (and
   #submit-correction / #submit-other target markers inside it), and this shows
   it as an overlay. submit.js adds .is-enhanced, which switches this off. */
.uh-modal:target:not([open]):not(.is-enhanced),
.uh-modal:has(:target):not([open]):not(.is-enhanced) {
	display: block;
	position: fixed;
	inset: 0;
	z-index: 1000;
	box-shadow: var(--shadow), 0 0 0 100vmax rgb(0 0 0 / 0.72);
}

.uh-modal__close {
	position: absolute;
	top: 12px;
	right: 12px;
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid transparent;
	background: transparent;
	color: var(--c-muted);
	font: 400 1.75rem/1 var(--f-body);
	text-decoration: none;
	cursor: pointer;
	transition: color var(--t-fast), border-color var(--t-fast);
}
.uh-modal__close:hover,
.uh-modal__close:focus-visible { color: var(--c-ink); border-color: var(--c-rule); }

/* ---------- shared content (modal + page) --------------------------------- */

.uh-submit { position: relative; padding: 32px; border: 1px solid var(--c-rule);}

.uh-submit__kicker {
	margin: 0 0 var(--gap-sm);
	color: var(--c-hi);
	font-size: var(--fs-xs);
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}
.uh-submit__title {
	margin: 0 48px var(--gap-sm) 0;
	font-family: var(--f-display);
	font-size: var(--fs-h1);
	font-weight: 600;
	line-height: var(--lh-heading);
	text-transform: uppercase;
}
.uh-submit__intro {
	margin: 0 0 24px;
	color: var(--c-muted);
	font-size: var(--fs-sm);
	line-height: var(--lh-body);
}

.uh-submit__form { display: grid; gap: 20px; }

.uh-submit__row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 20px;
}
@media (max-width: 560px) {
	.uh-submit { padding: 24px 20px; }
	.uh-submit__row { grid-template-columns: 1fr; }
}

.uh-submit__field { display: grid; gap: 6px; }

.uh-submit__label {
	padding: 0;
	color: var(--c-ink);
	font-size: var(--fs-xs);
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}
.uh-submit__label small {
	color: var(--c-muted);
	font-size: inherit;
	font-weight: 500;
	letter-spacing: 0.06em;
	text-transform: none;
}

/* Fields. Written against the form's own classes: the site's global `input`
   rule (the jukebox switch) would otherwise hide them. */
.uh-submit__form input[type="text"],
.uh-submit__form input[type="email"],
.uh-submit__form input[type="url"],
.uh-submit__form textarea {
	position: static;
	width: 100%;
	height: auto;
	opacity: 1;
	box-sizing: border-box;
	padding: 12px 14px;
	border: 1px solid var(--c-rule);
	border-radius: var(--radius);
	background: var(--c-page);
	color: var(--c-ink);
	font: 400 var(--fs-base)/1.4 var(--f-body);
	transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.uh-submit__form textarea { min-height: 140px; resize: vertical; line-height: var(--lh-body); }
.uh-submit__form ::placeholder { color: rgb(243 242 242 / 0.35); }

.uh-submit__form input:focus,
.uh-submit__form textarea:focus {
	outline: none;
	border-color: var(--c-hi);
	box-shadow: 0 0 0 1px var(--c-hi);
}
.uh-submit__form.was-tried input:invalid,
.uh-submit__form.was-tried textarea:invalid { border-color: var(--c-hi); }

/* ---------- type switch (segmented) --------------------------------------- */

.uh-submit__types { margin: 0; padding: 0; border: 0; min-width: 0; }
.uh-submit__types legend { margin-bottom: 8px; }

.uh-submit__seg {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	border: 1px solid var(--c-rule);
}
@media (max-width: 560px) { .uh-submit__seg { grid-template-columns: 1fr; } }

.uh-submit__seg-opt { position: relative; display: block; cursor: pointer; }
.uh-submit__seg-opt + .uh-submit__seg-opt { border-left: 1px solid var(--c-rule); }
@media (max-width: 560px) {
	.uh-submit__seg-opt + .uh-submit__seg-opt { border-left: 0; border-top: 1px solid var(--c-rule); }
}
.uh-submit__seg-opt input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}
.uh-submit__seg-opt span {
	display: block;
	padding: 11px 10px;
	color: var(--c-muted);
	font-size: var(--fs-sm);
	font-weight: 700;
	text-align: center;
	transition: background var(--t-fast), color var(--t-fast);
}
.uh-submit__seg-opt:hover span { color: var(--c-ink); background: var(--c-surface-2); }
.uh-submit__seg-opt input:checked + span { background: var(--c-red); color: var(--c-ink); }
.uh-submit__seg-opt input:focus-visible + span { outline: 2px solid var(--c-hi); outline-offset: -2px; }

/* Show the label/field for the chosen type only. Pure CSS (:has), so the
   no-JavaScript page behaves the same as the modal. */
.uh-submit__form:has(input[name="type"][value="story"]:checked)      [data-uh-show]:not([data-uh-show="story"]),
.uh-submit__form:has(input[name="type"][value="correction"]:checked) [data-uh-show]:not([data-uh-show="correction"]),
.uh-submit__form:has(input[name="type"][value="other"]:checked)      [data-uh-show]:not([data-uh-show="other"]) {
	display: none;
}

/* ---------- honeypot, footer, status -------------------------------------- */

.uh-submit__trap {
	position: absolute !important;
	left: -10000px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.uh-submit__foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px 20px;
	margin-top: 4px;
}

.uh-submit__foot .btn{
	border: 1px solid var(--c-rule) !important;
}
.uh-submit__form[data-sending] button[type="submit"] { opacity: 0.6; cursor: progress; }

.uh-submit__note { margin: 0; font-size: var(--fs-sm); color: var(--c-muted); }
.uh-submit__note:empty { display: none; }
.uh-submit__note[data-state="ok"]  { color: var(--c-ink); }
.uh-submit__note[data-state="err"] { color: var(--c-hi); }

/* after a successful send in the modal */
.uh-submit__done { display: grid; gap: 20px; justify-items: start; }
.uh-submit__done p { margin: 0; color: var(--c-ink); line-height: var(--lh-body); }
