/**
Theme Name: Crumley
Theme URI: https://crumley.metzae.media
Author: The Duumvirati
Description: Front end for the process server tool (product name deferred). One template: a splash when signed out, the app when signed in. Mobile-first, because the field is where it gets used.
Version: 0.1.0
Requires at least: 6.0
Requires PHP: 8.0
License: GPL-2.0-or-later
Text Domain: crumley
*/

/* Palette follows Ryan's design guidelines from the prototype: dark, high
   contrast, status colours that mean one thing each. Amber is "attempted"
   and nothing else. */
:root {
	--bg: #09090b;
	--bg-2: #111114;
	--card: #18181b;
	--card-2: #1f1f23;
	--border: #27272a;
	--fg: #fafafa;
	--fg-2: #d4d4d8;
	--muted: #a1a1aa;
	--muted-2: #71717a;
	--primary: #3b82f6;
	--primary-2: #2563eb;
	--served: #10b981;
	--attempted: #f59e0b;
	--failed: #f43f5e;
	--new: #3b82f6;
	--cyan: #22d3ee;
	--radius: 10px;
	--nav-h: 58px;
	--font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
	--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font: 15px/1.45 var(--font);
	text-wrap: pretty;
}
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; height: auto; display: block; }
iframe[src*="youtube"], iframe[src*="vimeo"] { aspect-ratio: 16 / 9; width: 100%; height: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- splash (signed out) ---------- */
.splash {
	min-height: 100svh;
	display: grid;
	place-items: center;
	padding: 24px;
	text-align: center;
	background: radial-gradient(circle at 50% 30%, rgba(59,130,246,0.18), transparent 60%), var(--bg);
}
.splash__mark {
	width: 72px; height: 72px; border-radius: 50%;
	background: #000; color: #fff;
	display: grid; place-items: center;
	font-weight: 800; font-size: 34px;
	margin: 0 auto 16px;
	border: 1px solid var(--border);
}
.splash__title { font-size: 26px; margin-bottom: 6px; }
.splash__sub { color: var(--muted); margin-bottom: 20px; max-width: 32ch; margin-inline: auto; }
.splash .btn { min-width: 180px; }

/* ---------- shell ---------- */
.shell { min-height: 100svh; display: flex; flex-direction: column; }
.topbar {
	position: sticky; top: 0; z-index: 20;
	display: flex; align-items: center; gap: 10px;
	height: 52px; padding: 0 14px;
	background: rgba(9,9,11,0.85); backdrop-filter: blur(12px);
	border-bottom: 1px solid var(--border);
}
.topbar__brand { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.topbar__brand span { color: var(--primary); }
.topbar__spacer { flex: 1; }
.topbar__user { color: var(--muted); font-size: 13px; white-space: nowrap; }
.main { flex: 1; padding: 14px 14px calc(var(--nav-h) + 20px); width: 100%; max-width: 900px; margin: 0 auto; }
.main > * + * { margin-top: 14px; }

.nav {
	position: fixed; inset: auto 0 0 0; z-index: 20;
	height: var(--nav-h);
	display: grid; grid-template-columns: repeat(4, 1fr);
	background: rgba(17,17,20,0.96); backdrop-filter: blur(12px);
	border-top: 1px solid var(--border);
	padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
	display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
	color: var(--muted); font-size: 11px; font-weight: 500;
}
.nav a svg { width: 22px; height: 22px; }
.nav a.is-active { color: var(--primary); }

@media (min-width: 768px) {
	.shell { flex-direction: row; }
	.nav {
		position: sticky; top: 0; inset: auto;
		height: 100svh; width: 200px; flex: 0 0 200px;
		display: flex; flex-direction: column; gap: 2px;
		padding: 14px 10px;
		border-top: 0; border-right: 1px solid var(--border);
	}
	.nav a { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 14px; }
	.nav a.is-active { background: rgba(59,130,246,0.12); }
	.nav__brand { display: block; font-weight: 700; padding: 6px 10px 14px; font-size: 15px; }
	.nav__brand span { color: var(--primary); }
	.topbar { display: none; }
	.main { padding: 24px 28px 40px; }
	.main > * + * { margin-top: 18px; }
}
.nav__brand { display: none; }

/* ---------- pieces ---------- */
.card {
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 12px 14px;
}
.card > * + * { margin-top: 8px; }
.card--tap { cursor: pointer; transition: border-color 0.12s; }
.card--tap:hover, .card--tap:focus-visible { border-color: rgba(59,130,246,0.6); outline: none; }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }

.pill {
	display: inline-flex; align-items: center; gap: 5px;
	padding: 2px 8px; border-radius: 999px;
	font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap;
	background: rgba(161,161,170,0.15); color: var(--fg-2);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--new { color: var(--new); background: rgba(59,130,246,0.14); }
.pill--in_progress, .pill--attempted { color: var(--attempted); background: rgba(245,158,11,0.14); }
.pill--served { color: var(--served); background: rgba(16,185,129,0.14); }
.pill--failed, .pill--returned, .pill--refused, .pill--wrong_address, .pill--unable_to_locate { color: var(--failed); background: rgba(244,63,94,0.14); }
.pill--not_home, .pill--other { color: var(--muted); }
.pill--rush { color: #fff; background: var(--failed); }
.pill--rush::before { display: none; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(5, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.stat__n { font-size: 26px; font-weight: 750; line-height: 1.1; }
.stat__l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat--warn .stat__n { color: var(--attempted); }
.stat--bad .stat__n { color: var(--failed); }
.stat--good .stat__n { color: var(--served); }

.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-height: 42px; padding: 0 16px; border-radius: 9px;
	border: 1px solid var(--border); background: var(--card-2); color: var(--fg);
	font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
	transition: background 0.12s, transform 0.06s;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-2); }
.btn--danger { color: var(--failed); }
.btn--ghost { background: transparent; }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn svg { width: 18px; height: 18px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
	flex: 0 0 auto; min-height: 32px; padding: 0 12px; border-radius: 999px;
	border: 1px solid var(--border); background: var(--card); color: var(--muted);
	font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip.is-active { background: rgba(59,130,246,0.16); border-color: var(--primary); color: var(--fg); }

.field { display: block; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.input, .select, .textarea {
	width: 100%; min-height: 42px; padding: 8px 11px;
	background: var(--bg-2); border: 1px solid var(--border); border-radius: 9px;
	font-size: 16px; /* 16px stops iOS zooming the page on focus */
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.25); }
.textarea { min-height: 88px; resize: vertical; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 42px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }

.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .choices { grid-template-columns: repeat(3, 1fr); } }
.choice {
	min-height: 48px; padding: 8px 10px; border-radius: 9px;
	border: 1px solid var(--border); background: var(--card); color: var(--fg-2);
	font-weight: 600; font-size: 14px; cursor: pointer; text-align: left;
}
.choice.is-active { border-color: var(--primary); background: rgba(59,130,246,0.14); color: var(--fg); }
.choice--served.is-active { border-color: var(--served); background: rgba(16,185,129,0.14); }
.choice--bad.is-active { border-color: var(--failed); background: rgba(244,63,94,0.14); }

.gps { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; background: var(--bg-2); border: 1px dashed var(--border); }
.gps--ok { border-style: solid; border-color: rgba(16,185,129,0.5); }
.gps--bad { border-color: rgba(244,63,94,0.5); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted-2); flex: 0 0 auto; }
.gps--ok .dot { background: var(--served); box-shadow: 0 0 0 4px rgba(16,185,129,0.2); }
.gps--bad .dot { background: var(--failed); }
.gps--wait .dot { background: var(--attempted); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: 0.35; } }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.photos .add { aspect-ratio: 1; display: grid; place-items: center; border: 1px dashed var(--border); border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 12px; text-align: center; padding: 6px; }
.photos .add input { display: none; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 12px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--muted-2); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline li.is-served::before { background: var(--served); }
.timeline li.is-bad::before { background: var(--failed); }
.timeline li.is-not_home::before { background: var(--attempted); }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty strong { display: block; color: var(--fg-2); margin-bottom: 4px; }

.fab {
	position: fixed; right: 16px; bottom: calc(var(--nav-h) + 14px); z-index: 15;
	width: 54px; height: 54px; border-radius: 50%;
	background: var(--primary); color: #fff; border: 0;
	box-shadow: 0 8px 24px rgba(59,130,246,0.45);
	display: grid; place-items: center; cursor: pointer;
}
.fab svg { width: 26px; height: 26px; }
@media (min-width: 768px) { .fab { bottom: 24px; right: 24px; } }

.toast {
	position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px); transform: translateX(-50%);
	z-index: 50; max-width: min(92vw, 420px);
	padding: 10px 14px; border-radius: 9px;
	background: var(--card-2); border: 1px solid var(--border); color: var(--fg);
	font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.toast--err { border-color: var(--failed); }
.toast--ok { border-color: var(--served); }
@media (min-width: 768px) { .toast { bottom: 24px; } }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .btn--block { grid-column: 1 / -1; }
.head { display: flex; align-items: flex-start; gap: 10px; }
.head h1 { flex: 1; min-width: 0; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.back svg { width: 16px; height: 16px; }
