/* ==========================================================================
   THE PUBLIC TOOLKIT PAGE (/tools/)
   template-parts/tools/index.php

   A solid deep-teal hero with the search in it, a bar of the kinds that stays at
   the top of the window, then one section per kind. Every selector starts with
   .ti, so nothing here reaches the rest of the site.

   Each kind has its colour (the same as the Toolkit in the account) and uses
   it on the small icon tiles only.
   ========================================================================== */

.ti {
	--ti-ink: #01224F;
	--ti-muted: #5C6B7A;
	--ti-line: #DCE8EC;
	color: #16202B;
}

/* --- Hero ------------------------------------------------------------------- */

.ti-hero {
	background: var(--color-primary-ink, #02737A);
	color: #fff;
	padding-block: clamp(44px, 6vw, 84px) clamp(48px, 6.5vw, 88px);
}

.ti-hero__inner {
	display: grid;
	grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
	gap: clamp(32px, 5vw, 80px);
	align-items: center;
}

.ti-hero__title {
	margin: 0;
	font-size: clamp(2.2rem, 4.6vw, 3.75rem);
	line-height: 1.05;
	letter-spacing: -0.03em;
	font-weight: 800;
	color: #fff;
	text-wrap: balance;
}

.ti-hero__lead {
	margin: 20px 0 0;
	max-width: 54ch;
	font-size: 1.125rem;
	line-height: 1.6;
	color: #DDF3F4;
}

.ti-search { margin-top: 32px; max-width: 640px; }

.ti-search__label {
	display: block;
	margin-bottom: 9px;
	font-size: 0.95rem;
	font-weight: 700;
	color: #fff;
}

.ti-search__row {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 6px 6px 18px;
	border-radius: 14px;
	background: #fff;
	box-shadow: 0 14px 34px -16px rgba(1, 34, 79, 0.55);
}

.ti-search__icon { flex: none; color: #5C6B7A; }

.ti-search input[type="search"] {
	flex: 1;
	min-width: 0;
	height: 50px;
	padding: 0 6px;
	border: 0;
	background: transparent;
	font: inherit;
	font-size: 1rem;
	color: #16202B;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
}

.ti-search input[type="search"]::placeholder { color: #6B7886; }

.ti-search input[type="search"]:focus { outline: none; }

.ti-search__row:focus-within { outline: 3px solid #F18F13; outline-offset: 2px; }

.ti-search__go {
	flex: none;
	height: 50px;
	padding: 0 22px;
	border: 0;
	border-radius: 10px;
	background: #F18F13;
	color: #01224F;
	font: inherit;
	font-weight: 800;
	cursor: pointer;
	transition: background-color 0.16s ease;
}

.ti-search__go:hover { background: #FFA42E; }

.ti-search__go:focus-visible { outline: 3px solid #01224F; outline-offset: 2px; }

/* Most used: the tools people reach for first, as the way in for someone who does not want to search. */
.ti-popular h2 {
	margin: 0 0 12px;
	font-size: 0.95rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	color: #CFEDEF;
}

.ti-popular ul { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }

.ti-popular a {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	gap: 14px;
	padding: 13px 16px;
	border-radius: 14px;
	background: #fff;
	color: var(--ti-ink);
	text-decoration: none;
	box-shadow: 0 8px 20px -14px rgba(1, 34, 79, 0.6);
	transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.18s ease;
}

.ti-popular a:hover { transform: translateY(-2px); box-shadow: 0 14px 26px -14px rgba(1, 34, 79, 0.7); }

.ti-popular a:focus-visible { outline: 3px solid #F18F13; outline-offset: 2px; }

.ti-popular__icon {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	border-radius: 12px;
	background: var(--hue-soft);
	color: var(--hue-deep);
}

.ti-popular strong { display: block; font-size: 1rem; line-height: 1.25; }

.ti-popular small { display: block; margin-top: 1px; font-size: 0.85rem; color: var(--ti-muted); }

.ti-popular svg:last-child { color: var(--color-primary-ink, #02737A); }

/* --- The kinds ---------------------------------------------------------------- */

.ti-kinds {
	position: sticky;
	top: 0;
	z-index: 30;
	background: rgba(255, 255, 255, 0.96);
	border-bottom: 1px solid var(--ti-line);
	backdrop-filter: blur(8px);
}

.ti-kinds__inner {
	display: flex;
	gap: 8px;
	padding-block: 10px;
	overflow-x: auto;
	scrollbar-width: none;
}

.ti-kinds__inner::-webkit-scrollbar { display: none; }

.ti-kind {
	display: inline-flex;
	align-items: center;
	flex: none;
	gap: 8px;
	min-height: 42px;
	padding: 5px 15px 5px 6px;
	border: 1px solid var(--ti-line);
	border-radius: 999px;
	background: #fff;
	color: var(--ti-ink);
	font-size: 0.92rem;
	font-weight: 700;
	text-decoration: none;
	transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.ti-kind:hover { border-color: var(--hue-deep); }

.ti-kind:focus-visible { outline: 3px solid var(--color-primary, #028B93); outline-offset: 2px; }

.ti-kind__icon {
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: var(--hue-soft);
	color: var(--hue-deep);
}

.ti-kind.is-current { background: var(--ti-ink); border-color: var(--ti-ink); color: #fff; }

.ti-kind.is-hidden { display: none; }

/* --- The sections -------------------------------------------------------------- */

.ti-body { padding-block: clamp(28px, 4vw, 48px) clamp(56px, 7vw, 96px); }

.ti-cat {
	/* The kinds bar is ~62px; leave room under it when a link or the bar jumps here. */
	scroll-margin-top: 78px;
	padding-block: clamp(24px, 3.4vw, 44px);
}

.ti-cat + .ti-cat { border-top: 1px solid var(--ti-line); }

.ti-cat[hidden] { display: none; }

.ti-cat__head {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	gap: 18px;
	margin-bottom: 24px;
}

.ti-cat__icon {
	display: grid;
	place-items: center;
	width: 60px;
	height: 60px;
	border-radius: 18px;
	background: var(--hue-soft);
	color: var(--hue-deep);
}

.ti-cat__head h2 {
	margin: 0;
	font-size: clamp(1.4rem, 2.2vw, 1.85rem);
	line-height: 1.2;
	letter-spacing: -0.02em;
	color: var(--ti-ink);
}

.ti-cat__head p { margin: 4px 0 0; color: var(--ti-muted); font-size: 1rem; }

.ti-cat__count {
	padding: 5px 12px;
	border-radius: 999px;
	background: var(--hue-soft);
	color: var(--hue-deep);
	font-size: 0.85rem;
	font-weight: 700;
	white-space: nowrap;
}

.ti-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 14px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ti-grid > li[hidden] { display: none; }

.ti-tool {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: start;
	gap: 14px;
	height: 100%;
	padding: 18px;
	border: 1px solid var(--ti-line);
	border-radius: 16px;
	background: #fff;
	color: var(--ti-ink);
	text-decoration: none;
	transition: border-color 0.16s ease, box-shadow 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.ti-tool:hover {
	border-color: var(--hue);
	box-shadow: 0 16px 30px -20px rgba(1, 34, 79, 0.45);
	transform: translateY(-2px);
}

.ti-tool:focus-visible { outline: 3px solid var(--color-primary, #028B93); outline-offset: 2px; }

.ti-tool__icon {
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	border-radius: 14px;
	background: var(--hue-soft);
	color: var(--hue-deep);
}

.ti-tool__text strong { display: block; font-size: 1.05rem; line-height: 1.3; }

.ti-tool__text span { display: block; margin-top: 4px; font-size: 0.92rem; line-height: 1.5; color: var(--ti-muted); }

.ti-tool__go {
	align-self: center;
	color: var(--hue-deep);
	opacity: 0;
	transform: translateX(-6px);
	transition: opacity 0.18s ease, transform 0.18s ease;
}

.ti-tool:hover .ti-tool__go,
.ti-tool:focus-visible .ti-tool__go { opacity: 1; transform: none; }

/* --- Nothing found, and what comes next ---------------------------------------------- */

.ti-empty {
	display: grid;
	justify-items: center;
	gap: 6px;
	padding: 56px 20px;
	text-align: center;
	color: var(--ti-muted);
}

.ti-empty[hidden] { display: none; }

.ti-empty strong { font-size: 1.2rem; color: var(--ti-ink); }

.ti-next {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 20px 40px;
	margin-top: clamp(28px, 4vw, 48px);
	padding: clamp(24px, 3vw, 36px);
	border-radius: 20px;
	background: #E7F6F9;
}

.ti-next h2 { margin: 0; max-width: 34ch; font-size: clamp(1.25rem, 2vw, 1.6rem); line-height: 1.25; letter-spacing: -0.015em; color: var(--ti-ink); text-wrap: balance; }

.ti-next p { margin: 8px 0 0; max-width: 60ch; color: var(--ti-muted); }

/* --- Smaller screens ------------------------------------------------------------------- */

@media (max-width: 1100px) {
	.ti-hero__inner { grid-template-columns: minmax(0, 1fr); }
	.ti-popular ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.ti-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
	.ti-hero__lead { font-size: 1.02rem; }
	.ti-search__row { padding-left: 14px; }
	.ti-search__icon { display: none; }
	/* 16px stops iOS Safari zooming the page when the field takes focus. */
	.ti-search input[type="search"] { font-size: 16px; }
	.ti-search__go { padding: 0 16px; }
	.ti-popular ul { grid-template-columns: minmax(0, 1fr); }
	.ti-kinds__inner { padding-block: 8px; }
	.ti-cat { scroll-margin-top: 68px; }
	.ti-cat__head { grid-template-columns: auto minmax(0, 1fr); gap: 14px; }
	.ti-cat__count { display: none; }
	.ti-cat__icon { width: 50px; height: 50px; border-radius: 15px; }
	.ti-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
	.ti-tool { padding: 15px; }
	.ti-tool__go { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
	.ti-popular a,
	.ti-tool,
	.ti-tool__go,
	.ti-kind,
	.ti-search__go { transition: none; }
	.ti-popular a:hover,
	.ti-tool:hover { transform: none; }
}
