/* ==========================================================================
   SortMyHome – front end
   Path: sortmyhome/assets/css/smh.css

   - Everything is scoped under .smh-app and prefixed smh- so themes can't clash.
   - Mobile first. From 768px wide the same layout simply gets roomier:
     wider column, bigger heading, suburb + "Sort it" side by side.
   - Colours live in custom properties on .smh-app; override them there if needed.
   ========================================================================== */

/* Fonts: bundled in assets/fonts and declared by SMH_Assets::font_faces() with full URLs,
   under private names ("SMH Archivo", "SMH Unbounded") so theme fonts can't mix in. */

.smh-app {
	/* Brand */
	--smh-bg: #ffffff;
	--smh-ink: #221e1b;
	--smh-black: #000000;
	--smh-muted: #5c5751;
	--smh-line: #e8e4de;
	--smh-charcoal: #2f2a26;       /* buttons, locations */
	--smh-on-charcoal: #ffffff;
	--smh-totara: #7c3a22;         /* links and small icons */
	--smh-tussock: #d4a017;        /* Sort it, selected trade, our mates */
	--smh-on-tussock: #2a1c00;
	--smh-tussock-light: #f0c75a;
	--smh-brick: #b8492f;          /* logo "My" and the wishes link only */
	--smh-brick-hover: #cf5a3e;
	--smh-brick-on-dark: #d9644a;        /* the wishes link on the dark header: 4.6:1, readable */
	--smh-brick-on-dark-hover: #e37558;
	/* Dark header */
	--smh-h-bg: #231f1c;
	--smh-h-ink: #f6f1ea;
	--smh-h-muted: #c9bfb4;
	--smh-h-tile: #312b27;
	--smh-h-line: #4a423c;
	--smh-placeholder: #736b64;
	--smh-focus: #d4a017;
	/* Shape and type */
	--smh-r: 6px;
	--smh-font: "SMH Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--smh-logo-font: "SMH Unbounded", "SMH Archivo", system-ui, sans-serif;
	--smh-gutter: 20px;
	--smh-max: 880px;

	background: var(--smh-bg);
	color: var(--smh-ink);
	font-family: var(--smh-font);
	font-size: 16px;
	font-weight: 400;          /* some themes use a light 300 body weight – too thin to read easily */
	line-height: 1.45;
	letter-spacing: normal; /* themes often tighten body text; our components set their own */
	word-spacing: normal;
	-webkit-text-size-adjust: 100%;
	text-align: left;
	margin-block: 0;
}

/* ---------- Scoped reset: undo common theme styles ---------- */
.smh-app *,
.smh-app *::before,
.smh-app *::after { box-sizing: border-box; }

/* :where() keeps these at single-class strength, so the component rules below always win. */
.smh-app :where(h1, h2, h3, p, ul, li, fieldset, legend, form, header) { margin: 0; padding: 0; border: 0; }

/* Our fonts on everything inside the block – themes often set fonts on headings, paragraphs,
   buttons and inputs directly, which would otherwise win over inheritance. */
.smh-app,
.smh-app * { font-family: var(--smh-font) !important; }
.smh-app .smh-logo,
.smh-app .smh-logo * { font-family: var(--smh-logo-font) !important; }
/* Text inside our components takes its weight from the component, not from theme span/a rules. */
.smh-app :where(span, i, a, strong, label, legend) { font-weight: inherit; }

.smh-app h1,
.smh-app h2,
.smh-app h3 {
	text-transform: none;
	letter-spacing: normal;
	clear: none;
}

.smh-app :where(ul) { list-style: none; }
.smh-app li::before,
.smh-app li::marker { content: none; }

.smh-app a { text-decoration: none; box-shadow: none; border: 0; }
.smh-app a:hover,
.smh-app a:focus { text-decoration: none; }

.smh-app button,
.smh-app input {
	font: inherit;
	letter-spacing: normal;
	text-transform: none;
	box-shadow: none;
	margin: 0;
	min-height: 0;
	line-height: 1.2;
}

.smh-app svg { display: block; flex: none; }

.smh-app :focus-visible {
	outline: 3px solid var(--smh-focus);
	outline-offset: 2px;
}

.smh-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.smh-wrap {
	width: 100%;
	max-width: var(--smh-max);
	margin-inline: auto;
	padding-inline: var(--smh-gutter);
}

/* ==========================================================================
   Dark header with the search
   ========================================================================== */
.smh-hero {
	background: var(--smh-h-bg);
	color: var(--smh-h-ink);
	padding-bottom: 26px;
}

/* width="full": the dark header runs edge to edge.
   Desktop: border-image paints the background out to the screen edges as one layer, without
   changing the layout or causing sideways scrolling. Phones: break the whole block out of the
   theme's padding, so the content isn't squeezed by two sets of margins (phone scrollbars take
   no space, so 100vw is safe there). */
/* Sit flush at the top of the page content: themes put a gap above every block but the first,
   and the editor often leaves an empty paragraph above ours. */
.smh-page .smh-app { margin-block-start: 0 !important; }
.smh-page :where(.entry-content, .wp-block-post-content) > p:empty { display: none; }

.smh-app--full .smh-hero {
	border-image: linear-gradient(var(--smh-h-bg), var(--smh-h-bg)) fill 0 / 0 / 0 100vmax;
}

@media (max-width: 767px) {
	.smh-app.smh-app--full {
		width: 100vw !important;
		max-width: 100vw !important;
		margin-left: calc(50% - 50vw) !important;
		margin-right: calc(50% - 50vw) !important;
	}
}

.smh-top {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	padding-top: 18px;
}

.smh-app .smh-logo {
	display: inline-block;
	padding: 12px 0;   /* 44px tall tap area… */
	margin: -12px 0;   /* …without moving anything */
	font-weight: 700;
	font-size: 20px;
	letter-spacing: -0.03em;
	line-height: 1;
	color: var(--smh-h-ink);
}
.smh-app .smh-logo span { color: var(--smh-brick); }

.smh-tagline {
	display: grid;
	justify-items: end;
	font-size: 12px;
	line-height: 1.35;
	text-align: right;
}
.smh-tagline span { color: var(--smh-h-muted); }
.smh-app .smh-tagline a {
	display: inline-block;
	padding: 11px 0;   /* 44px tall tap area without moving anything */
	margin: -9px 0;
	color: var(--smh-brick-on-dark);
	font-weight: 700;
	font-size: 13px;
	text-decoration: none;
}
.smh-app .smh-tagline a:hover { color: var(--smh-brick-on-dark-hover); text-decoration: underline; text-underline-offset: 2px; }

.smh-form {
	display: grid;
	gap: 12px;
	padding-top: 30px;
}
.smh-form > *,
.smh-row > * { min-width: 0; }

.smh-app .smh-eyebrow {
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--smh-tussock);
}

/* "Kia ora." on its own line, 8px bigger than "What needs sorting?" underneath. */
.smh-app .smh-heading {
	--smh-ask: clamp(24px, 7.6vw, 30px);
	margin: -4px 0 8px;
	font-size: var(--smh-ask);
	line-height: 1.08;
	font-weight: 800;
	letter-spacing: -0.02em;
	color: var(--smh-h-ink);
}
.smh-heading__hi,
.smh-heading__ask { display: block; }
.smh-heading__hi { font-size: calc(var(--smh-ask) + 8px); line-height: 1.05; }
.smh-heading__ask { white-space: nowrap; }
@media (max-width: 339px) { .smh-heading__ask { white-space: normal; } }

/* ---------- Trade tiles (radio buttons, so it works without JavaScript) ---------- */
.smh-trades {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 10px;
	min-width: 0;
}

.smh-trade { position: relative; display: grid; cursor: pointer; }

.smh-trade input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	margin: 0;
}

.smh-trade__tile {
	display: grid;
	justify-items: center;
	align-content: center;
	gap: 6px;
	min-height: 84px;
	padding: 14px 6px 12px;
	background: var(--smh-h-tile);
	border: 2px solid var(--smh-h-line);
	border-radius: var(--smh-r);
	color: var(--smh-h-ink);
	font-weight: 700;
	font-size: 14px;
	text-align: center;
	transition: border-color 0.15s;
}
.smh-trade__tile .smh-icon { width: 30px; height: 30px; color: var(--smh-h-muted); }
.smh-trade:hover .smh-trade__tile { border-color: #6b6159; }

.smh-trade input:focus-visible + .smh-trade__tile {
	outline: 3px solid var(--smh-focus);
	outline-offset: 2px;
}

/* Selected trade: a brick-and-gold gradient that travels round the border. */
@property --smh-spin {
	syntax: "<angle>";
	inherits: false;
	initial-value: 0deg;
}

.smh-trade input:checked + .smh-trade__tile {
	border-color: transparent;
	color: var(--smh-tussock);
	background:
		linear-gradient(var(--smh-h-tile), var(--smh-h-tile)) padding-box,
		conic-gradient(from var(--smh-spin), var(--smh-brick), var(--smh-tussock), var(--smh-tussock-light), var(--smh-tussock), var(--smh-brick), var(--smh-brick)) border-box;
	animation: smh-spin 2.8s linear infinite;
}
.smh-trade input:checked + .smh-trade__tile .smh-icon { color: var(--smh-tussock); }

@keyframes smh-spin { to { --smh-spin: 360deg; } }

/* "Sort it" with no trade or no location: a quick wiggle and a gold outline on what's missing. */
.smh-trades.is-nudged,
.smh-field.is-nudged { animation: smh-nudge 0.4s ease-in-out; }
.smh-trades.is-nudged .smh-trade__tile { border-color: var(--smh-tussock); }
.smh-field.is-nudged .smh-input { box-shadow: 0 0 0 3px var(--smh-tussock); }
@keyframes smh-nudge {
	25% { transform: translateX(-6px); }
	75% { transform: translateX(6px); }
}

/* ---------- Suburb + Sort it ---------- */
.smh-row { display: grid; gap: 12px; }

.smh-field { position: relative; }
.smh-field .smh-icon {
	position: absolute;
	z-index: 1;
	left: 15px;
	top: 50%;
	width: 24px;
	height: 24px;
	margin-top: -12px;
	color: var(--smh-totara);
	pointer-events: none;
}

.smh-app .smh-input {
	display: block;
	width: 100%;
	height: 56px;
	padding: 0 16px 0 48px;
	border: 0;
	border-radius: var(--smh-r);
	background: #ffffff;
	color: var(--smh-ink);
	font-size: 18px; /* 16px+ stops iPhones zooming in */
	font-weight: 600;
	outline-offset: 2px;
}
.smh-app .smh-input::placeholder { color: var(--smh-placeholder); font-size: 15px; font-weight: 500; opacity: 1; }
.smh-app .smh-input::-webkit-calendar-picker-indicator { opacity: 0; } /* hide Chrome's datalist arrow */

.smh-app .smh-go {
	width: 100%;
	height: 58px;
	padding: 0 24px;
	border: 0;
	border-radius: var(--smh-r);
	background: var(--smh-tussock);
	color: var(--smh-on-tussock);
	font-size: 19px;
	font-weight: 800;
	cursor: pointer;
	transition: background-color 0.15s;
}
.smh-app .smh-go:hover { background: #e0ae24; }

.smh-go__busy { display: none; }
.smh-go.is-busy { cursor: progress; }
.smh-go.is-busy .smh-go__idle { display: none; }
.smh-go.is-busy .smh-go__busy { display: inline-block; }

/* "Sorting . . ." – the dots appear one by one (0.15s, 0.45s, 0.75s), then start again.
   The animation restarts every time the button goes busy. smh.js keeps it busy for at least
   a full run, so all three dots always show. */
.smh-dots { display: inline-block; width: 2.1em; text-align: left; }
.smh-dots i { font-style: normal; margin-left: 0.28em; opacity: 0; animation: 1.2s steps(1, end) infinite; }
.smh-dots i:nth-child(1) { animation-name: smh-dot1; }
.smh-dots i:nth-child(2) { animation-name: smh-dot2; }
.smh-dots i:nth-child(3) { animation-name: smh-dot3; }
@keyframes smh-dot1 { 0% { opacity: 0; } 12.5% { opacity: 1; } 90% { opacity: 0; } }
@keyframes smh-dot2 { 0% { opacity: 0; } 37.5% { opacity: 1; } 90% { opacity: 0; } }
@keyframes smh-dot3 { 0% { opacity: 0; } 62.5% { opacity: 1; } 90% { opacity: 0; } }

/* "38,420 mahi looked up" – centred at the bottom of the header */
.smh-app .smh-mahi {
	margin: 18px 0 0;
	text-align: center;
	font-size: 13px;
	letter-spacing: 0.02em;
	color: var(--smh-h-muted);
}
.smh-app .smh-mahi[hidden] { display: none; }
.smh-app .smh-mahi strong { color: var(--smh-tussock); font-weight: 800; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Results
   ========================================================================== */
.smh-results { padding: 26px 0 32px; }
.smh-results.is-loading { opacity: 0.55; transition: opacity 0.2s; }

.smh-results__head { margin-bottom: 18px; }

.smh-app .smh-results__title {
	margin: 0; /* explicit: themes often add big heading margins */
	font-size: 23px;
	line-height: 1.2;
	font-weight: 800;
	letter-spacing: -0.01em;
	color: var(--smh-black);
	scroll-margin-top: 90px; /* room for sticky theme headers */
}
.smh-app .smh-results__title:focus { outline: none; }

.smh-app .smh-results__sub {
	margin: 4px 0 0;
	font-size: 15px;
	color: var(--smh-charcoal);
}

.smh-list { display: grid; gap: 12px; }

.smh-list__divider {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 10px;
	color: var(--smh-muted);
	font-size: 14px;
	font-weight: 600;
}
.smh-list__divider::after { content: ""; flex: 1; height: 1px; background: var(--smh-line); }

/* ---------- Cards (shared) ---------- */
.smh-card {
	position: relative;
	background: #ffffff;
	border: 1px solid var(--smh-line);
	border-radius: var(--smh-r);
	padding: 16px;
}

.smh-app .smh-card__name {
	font-size: 18px;
	line-height: 1.25;
	font-weight: 700;
	color: var(--smh-black);
}

.smh-where .smh-icon,
.smh-details .smh-icon { width: 17px; height: 17px; color: var(--smh-totara); }

/* ---------- Free listing: name + suburb on the left, website on the right ---------- */
.smh-card--free {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
}
.smh-card__main { flex: 1; min-width: 0; }

.smh-app .smh-where {
	display: flex;
	align-items: center;
	gap: 5px;
	margin-top: 8px;
	color: var(--smh-charcoal);
	font-size: 15px;
	font-weight: 500;
}

.smh-app .smh-visit {
	flex: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	max-width: 48%;
	min-height: 44px;
	padding: 0 4px;
	color: var(--smh-totara);
	font-size: 15px;
	font-weight: 700;
	text-align: right;
	text-decoration: underline;
	text-underline-offset: 3px;
	overflow-wrap: anywhere;
}
.smh-visit .smh-icon { width: 15px; height: 15px; }

/* ---------- Our mates (paid) ---------- */
.smh-card--mate { border: 2px solid var(--smh-tussock); }
.smh-card--mate .smh-card__name { padding-right: 112px; } /* clear of the badge */

.smh-badge {
	position: absolute;
	top: 16px;
	right: 16px;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 2px 6px 2px 9px;
	border-radius: 4px;
	background: var(--smh-tussock);
	color: var(--smh-on-tussock);
	font-size: 12px;
	font-weight: 300;
	letter-spacing: 0.02em;
	line-height: 1.5;
}
.smh-badge .smh-icon { width: 16px; height: 16px; }

.smh-details { display: grid; gap: 2px; margin-top: 8px; }
.smh-app .smh-details a {
	display: flex;
	align-items: center;
	gap: 6px;
	min-height: 32px;
	color: var(--smh-charcoal);
	font-size: 15px;
	font-weight: 500;
	overflow-wrap: anywhere;
}
.smh-app .smh-details a:hover span:not(.smh-sr) { text-decoration: underline; text-underline-offset: 3px; }

.smh-actions {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
	gap: 8px;
	margin-top: 14px;
}

.smh-app .smh-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: 50px;
	border: 2px solid var(--smh-charcoal);
	border-radius: var(--smh-r);
	background: var(--smh-charcoal);
	color: var(--smh-on-charcoal);
	font-size: 16px;
	font-weight: 700;
}
.smh-app .smh-btn:hover { background: #45403b; border-color: #45403b; }
.smh-btn .smh-icon { width: 18px; height: 18px; }

.smh-app .smh-btn--outline { background: #ffffff; color: var(--smh-charcoal); }
.smh-app .smh-btn--outline:hover { background: #f4f1ec; color: var(--smh-charcoal); }

/* ---------- Our mates page: one group per trade ---------- */
.smh-group + .smh-group { margin-top: 28px; }
.smh-app .smh-group__title {
	margin: 0 0 12px;
	font-size: 18px;
	font-weight: 800;
	color: var(--smh-black);
}

/* ---------- "Our mates in …" links: 2 × 2 on phones ---------- */
.smh-mates-links .smh-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.smh-app .smh-mates-links .smh-links a {
	justify-content: center;
	width: 100%;
	height: 100%;
	padding: 8px 10px;
	font-size: 14px;
	line-height: 1.25;
	text-align: center;
}
@media (min-width: 768px) {
	.smh-mates-links .smh-links { display: flex; flex-wrap: wrap; }
	.smh-app .smh-mates-links .smh-links a { width: auto; padding: 0 14px; font-size: 15px; }
}

/* ---------- Under the list: one sentence about it, and "See all … in <city>" ---------- */
.smh-after { display: grid; gap: 10px; margin-bottom: 30px; }
.smh-app .smh-summary { margin: 0; font-size: 14px; line-height: 1.5; color: var(--smh-muted); }
.smh-app .smh-all { margin: 0; }
.smh-app .smh-all a {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	color: var(--smh-totara);
	font-size: 15px;
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* ---------- Nothing listed yet ---------- */
.smh-empty {
	padding: 18px 20px;
	background: #f7f4ef;
	border-radius: var(--smh-r);
	color: var(--smh-charcoal);
}

/* ---------- Browse links (this trade by suburb, other trades here) ---------- */
.smh-browse {
	display: grid;
	gap: 24px;
	padding-top: 28px;
	border-top: 1px solid var(--smh-line);
}
/* 30px under the last result (or the "nothing yet" box) before anything else shows. */
.smh-app .smh-results .smh-list,
.smh-app .smh-results .smh-empty,
.smh-app .smh-results .smh-group:last-of-type { margin-bottom: 30px !important; }
.smh-app .smh-results .smh-browse { margin-top: 0 !important; }
.smh-app .smh-results .smh-group .smh-list { margin-bottom: 0 !important; } /* mates page: the gap goes after the last group */
.smh-app .smh-browse__title {
	margin-bottom: 10px;
	font-size: 18px;
	line-height: 1.3;
	font-weight: 800;
	color: var(--smh-black);
}
.smh-links { display: flex; flex-wrap: wrap; gap: 8px; }
.smh-app .smh-links a {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	min-height: 44px;
	padding: 0 14px;
	border: 1px solid var(--smh-line);
	border-radius: var(--smh-r);
	color: var(--smh-charcoal);
	font-size: 15px;
	font-weight: 600;
}
.smh-app .smh-links a:hover { border-color: var(--smh-charcoal); }
.smh-app .smh-links a[aria-current="page"] { border-color: var(--smh-tussock); background: #fdf6e0; }
.smh-links__n { color: var(--smh-muted); font-weight: 400; }

.smh-app .smh-note {
	margin-top: 20px;
	font-size: 12px;
	color: var(--smh-muted);
}

/* If the theme leaves an empty page-title wrapper behind, collapse it. */
.smh-hide-page-title .entry-title:empty,
.smh-hide-page-title .page-title:empty,
.smh-hide-page-title .wp-block-post-title:empty { display: none; }

/* ==========================================================================
   Desktop: same layout, just more room
   ========================================================================== */
@media (min-width: 768px) {
	.smh-app { --smh-gutter: 32px; }

	.smh-hero { padding-bottom: 40px; }
	.smh-top { padding-top: 24px; }
	.smh-app .smh-logo { font-size: 24px; }
	.smh-tagline { font-size: 13px; }
	.smh-app .smh-tagline a { font-size: 14px; }

	.smh-form { gap: 16px; padding-top: 36px; }
	.smh-app .smh-eyebrow { font-size: 14px; }
	.smh-app .smh-heading { --smh-ask: 46px; margin-bottom: 12px; }

	.smh-trades { gap: 14px; }
	.smh-trade__tile { min-height: 112px; font-size: 16px; gap: 10px; }
	.smh-trade__tile .smh-icon { width: 36px; height: 36px; }

	.smh-row { grid-template-columns: minmax(0, 1fr) 220px; }

	.smh-results { padding: 40px 0 48px; }
	.smh-results__head { margin-bottom: 24px; }
	.smh-app .smh-results__title { font-size: 28px; }
	.smh-app .smh-results__sub { font-size: 16px; }

	.smh-card { padding: 20px 24px; }
	.smh-card--mate .smh-badge { top: 20px; right: 24px; }
	.smh-app .smh-card__name { font-size: 20px; }
	.smh-actions { grid-template-columns: repeat(2, 200px); }
	.smh-app .smh-browse__title { font-size: 20px; }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
	.smh-trade input:checked + .smh-trade__tile { animation: none; }
	.smh-trades.is-nudged,
	.smh-field.is-nudged { animation: none; }
	.smh-dots i { animation: none; opacity: 1; }
	.smh-results.is-loading { transition: none; }
}

/* ---------- Tradies by city (home page) ---------- */
.smh-cities { margin-top: 30px; }
.smh-cities__list { list-style: none; margin: 0; padding: 0; }
.smh-cities__list li { display: grid; grid-template-columns: 6.4em 1fr; align-items: center; column-gap: 10px; border-bottom: 1px solid var(--smh-line); }
.smh-cities__links { display: flex; flex-wrap: wrap; column-gap: 10px; }
.smh-app .smh-cities__name, .smh-app .smh-cities__list a { font-size: 15px; }
.smh-app .smh-cities__name { font-weight: 600; color: var(--smh-charcoal); }
.smh-app .smh-cities__list a { display: inline-flex; align-items: center; min-height: 44px; color: var(--smh-totara); text-decoration: underline; text-underline-offset: 3px; }
.smh-app .smh-cities__list a:hover { text-decoration-thickness: 2px; }
@media (min-width: 700px) {
	.smh-cities__list li { grid-template-columns: 10em 1fr; }
	.smh-app .smh-cities__name, .smh-app .smh-cities__list a { font-size: 16px; }
	.smh-cities__links { column-gap: 20px; }
}
