/*
Theme Name: Craig's Tool Box
Theme URI: https://craigstoolbox.com
Author: Craig
Author URI: https://craigstoolbox.com
Description: A fast, colourful, ad-ready theme for a free online tools site: calculators, converters, generators and utilities. Includes a Tool post type, 12 working starter tools, live search, favourites, dark mode and AdSense slots.
Version: 1.1.0
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: craigs-toolbox
Tags: custom-logo, custom-menu, featured-images, two-columns, accessibility-ready, blog
*/

/* ==========================================================================
   1. Tokens  (colours come straight from the Tool Box logo tiles)
   ========================================================================== */
:root {
	--blue: #2A72E5;   --blue-d: #1D5BC4;   --blue-l: #E8F0FD;
	--green: #1E8A45;  --green-d: #166B35;  --green-l: #E4F4EA;
	--yellow: #F7B500; --yellow-d: #D99B00; --yellow-l: #FEF5D6; --on-yellow: #2B1F00;
	--red: #E5442D;    --red-d: #C43420;    --red-l: #FDEAE6;

	--ink: #0F172A;  --ink-2: #334155;  --muted: #64748B;
	--line: #E2E8F0; --line-2: #CBD5E1;
	--bg: #F7F9FC;   --surface: #FFFFFF; --surface-2: #F1F5F9;

	--shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 2px 8px rgba(15, 23, 42, .05);
	--shadow: 0 2px 4px rgba(15, 23, 42, .04), 0 12px 32px rgba(15, 23, 42, .08);
	--shadow-lg: 0 4px 8px rgba(15, 23, 42, .05), 0 24px 56px rgba(15, 23, 42, .14);

	--r-sm: 14px; --r: 20px; --r-lg: 26px; --pill: 999px;
	--font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	--wrap: 1280px;
	--focus: 0 0 0 4px rgba(42, 114, 229, .25);
}

[data-theme="dark"] {
	--ink: #F1F5F9; --ink-2: #CBD5E1; --muted: #94A3B8;
	--line: #24314A; --line-2: #334155;
	--bg: #0B1220; --surface: #111A2E; --surface-2: #182338;
	--blue-l: #16284D; --green-l: #12301F; --yellow-l: #3A2E08; --red-l: #3B1813;
	--shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
	--shadow: 0 12px 32px rgba(0, 0, 0, .35);
	--shadow-lg: 0 24px 56px rgba(0, 0, 0, .5);
	--focus: 0 0 0 4px rgba(90, 152, 255, .35);
	color-scheme: dark;
}

/* Each tool inherits one of the four brand colours. */
.is-blue   { --c: var(--blue);   --c-d: var(--blue-d);   --c-l: var(--blue-l);   --c-ink: #fff; }
.is-green  { --c: var(--green);  --c-d: var(--green-d);  --c-l: var(--green-l);  --c-ink: #fff; }
.is-yellow { --c: var(--yellow); --c-d: var(--yellow-d); --c-l: var(--yellow-l); --c-ink: var(--on-yellow); }
.is-red    { --c: var(--red);    --c-d: var(--red-d);    --c-l: var(--red-l);    --c-ink: #fff; }

/* ==========================================================================
   2. Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
	margin: 0; background: var(--bg); color: var(--ink);
	font: 400 1rem/1.6 var(--font); -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
a { color: var(--blue); }
h1, h2, h3, h4 { line-height: 1.15; letter-spacing: -.02em; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--blue); color: #fff; }

.screen-reader-text {
	position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
	clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link:focus {
	clip: auto; width: auto; height: auto; margin: 0; z-index: 999; top: 8px; left: 8px;
	background: var(--blue); color: #fff; padding: 12px 18px; border-radius: 10px;
}

.ctb-container { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 28px; }
.ctb-container--narrow { max-width: 860px; }
.ctb-main { padding-bottom: 72px; min-height: 60vh; }
.ctb-i { flex: none; }

/* ==========================================================================
   3. Header
   ========================================================================== */
.ctb-header {
	position: sticky; top: 0; z-index: 50;
	background: color-mix(in srgb, var(--surface) 88%, transparent);
	-webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
	border-bottom: 1px solid var(--line);
}
.ctb-header__in { display: flex; align-items: center; gap: 28px; min-height: 84px; }

.ctb-logo {
	display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink);
	font-weight: 800; font-size: 1.5rem; letter-spacing: -.03em; line-height: 1; flex: none;
}
.ctb-logo__mark { display: block; }
.ctb-logo__img { display: block; height: 46px; width: auto; }

.ctb-nav { margin-left: auto; }
.ctb-menu { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; }
.ctb-nav .ctb-menu { padding: 5px; border: 1px solid var(--line); border-radius: var(--pill); background: var(--surface); }
.ctb-nav .ctb-menu a {
	display: block; padding: 9px 20px; border-radius: var(--pill); text-decoration: none;
	color: var(--ink-2); font-weight: 600; transition: background .15s, color .15s;
}
.ctb-nav .ctb-menu a:hover,
.ctb-nav .current-menu-item > a,
.ctb-nav .current_page_item > a { background: var(--blue-l); color: var(--blue); }
[data-theme="dark"] .ctb-nav .ctb-menu a:hover,
[data-theme="dark"] .ctb-nav .current-menu-item > a { color: #8DB8FF; }

.ctb-header--search .ctb-header__in { gap: 32px; }
.ctb-search { position: relative; flex: 1; max-width: 780px; margin: 0 auto; }
.ctb-search input[type="search"] {
	width: 100%; height: 60px; padding: 0 64px 0 28px; border-radius: var(--pill);
	background: var(--surface); color: var(--ink); font-size: 1.08rem; -webkit-appearance: none; appearance: none;
	border: 1.5px solid #B9D0F8;
	box-shadow: 0 0 0 6px rgba(42, 114, 229, .08), 0 8px 28px rgba(42, 114, 229, .14);
	transition: border-color .15s, box-shadow .15s;
}
[data-theme="dark"] .ctb-search input[type="search"] { border-color: #2C4A80; }
.ctb-search input[type="search"]::placeholder { color: var(--muted); }
.ctb-search input[type="search"]:focus {
	outline: 0; border-color: var(--blue);
	box-shadow: 0 0 0 6px rgba(42, 114, 229, .18), 0 10px 32px rgba(42, 114, 229, .25);
}
.ctb-search button {
	position: absolute; right: 9px; top: 9px; width: 42px; height: 42px; border: 0; border-radius: 50%;
	background: transparent; color: var(--muted); display: grid; place-items: center; transition: background .15s, color .15s;
}
.ctb-search button:hover { background: var(--blue-l); color: var(--blue); }

.ctb-iconbtn {
	flex: none; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
	background: var(--surface); color: var(--ink-2); display: grid; place-items: center; transition: background .15s, color .15s;
}
.ctb-iconbtn:hover { background: var(--blue-l); color: var(--blue); }
.ctb-header:not(.ctb-header--search) .ctb-nav + .ctb-iconbtn { margin-left: 0; }
.ctb-i-moon { display: none; }
[data-theme="dark"] .ctb-i-sun { display: none; }
[data-theme="dark"] .ctb-i-moon { display: inline-flex; }

/* ==========================================================================
   4. Directory (home / tools / category)
   ========================================================================== */
.ctb-filterbar { padding: 30px 0 6px; }
.ctb-dirtitle { text-align: center; font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 800; margin-bottom: 18px; }
.ctb-container > .ctb-dirtitle { text-align: left; margin: 36px 0 24px; }

.ctb-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.ctb-chips--left { justify-content: flex-start; gap: 10px; margin-bottom: 22px; }
.ctb-chip {
	display: inline-flex; align-items: center; gap: 7px; padding: 12px 24px; border-radius: var(--pill);
	background: var(--surface); border: 1.5px solid var(--line-2); color: var(--ink-2);
	font-weight: 600; font-size: 1.02rem; transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}
.ctb-chip:hover { border-color: var(--blue); color: var(--blue); }
.ctb-chip[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 6px 16px rgba(42, 114, 229, .3); }

.ctb-directory { padding-top: 26px; }
.ctb-grid { display: grid; gap: 24px; grid-template-columns: repeat(auto-fill, minmax(214px, 1fr)); }
.ctb-empty { text-align: center; color: var(--muted); font-size: 1.1rem; padding: 48px 0; }

.ctb-card {
	position: relative; display: flex; flex-direction: column; padding: 24px 24px 26px;
	background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
	transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.ctb-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--c) 45%, var(--line)); }
.ctb-card:focus-within { border-color: var(--c); }
.ctb-tile {
	flex: none; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
	background: var(--c); color: #fff; box-shadow: 0 6px 14px color-mix(in srgb, var(--c) 35%, transparent);
}
.is-yellow .ctb-tile { color: #fff; }
.ctb-card__title { font-size: 1.28rem; font-weight: 800; margin: 18px 0 6px; letter-spacing: -.02em; }
.ctb-card__title a { color: var(--ink); text-decoration: none; }
.ctb-card__title a::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-lg); }
.ctb-card__title a:focus-visible { outline: 0; }
.ctb-card__desc { color: var(--muted); font-size: .98rem; line-height: 1.5; flex: 1; margin: 0 0 22px; }
.ctb-fav {
	position: absolute; top: 18px; right: 18px; z-index: 2; width: 36px; height: 36px; border-radius: 50%;
	border: 0; background: transparent; color: var(--line-2); display: grid; place-items: center; transition: color .15s, background .15s, transform .15s;
}
.ctb-fav:hover { background: var(--yellow-l); color: var(--yellow-d); }
.ctb-fav[aria-pressed="true"] { color: var(--yellow); }
.ctb-fav[aria-pressed="true"] svg { fill: currentColor; }
.ctb-fav:active { transform: scale(.88); }

/* ==========================================================================
   5. Buttons
   ========================================================================== */
.ctb-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 28px;
	border: 0; border-radius: var(--pill); font-weight: 700; font-size: 1.05rem; text-decoration: none; line-height: 1;
	transition: filter .15s, transform .1s, box-shadow .15s, background .15s;
}
.ctb-btn:active { transform: translateY(1px); }
.ctb-btn:disabled { opacity: .45; cursor: not-allowed; }
.ctb-btn--tool { width: 100%; background: var(--c); color: var(--c-ink); }
.ctb-card:hover .ctb-btn--tool { filter: brightness(1.07); box-shadow: 0 8px 18px color-mix(in srgb, var(--c) 35%, transparent); }
.ctb-btn--primary { background: var(--blue); color: #fff; box-shadow: 0 8px 20px rgba(42, 114, 229, .3); }
.ctb-btn--primary:hover:not(:disabled) { background: var(--blue-d); }
.ctb-btn--primary.is-done { background: var(--green); box-shadow: 0 8px 20px rgba(30, 138, 69, .3); }
.ctb-btn--ghost { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line-2); }
.ctb-btn--ghost:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.ctb-btn--block { width: 100%; }
.ctb-link { background: none; border: 0; padding: 0; color: var(--blue); font-weight: 600; text-decoration: underline; }

/* ==========================================================================
   6. Tool page shell
   ========================================================================== */
.ctb-pagehead {
	display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 460px); gap: 32px; align-items: end; padding: 40px 0 30px;
}
.ctb-crumbs { display: flex; gap: 8px; flex-wrap: wrap; font-size: .92rem; color: var(--muted); margin-bottom: 14px; }
.ctb-crumbs a { color: var(--muted); text-decoration: none; font-weight: 600; }
.ctb-crumbs a:hover { color: var(--blue); }
.ctb-titlerow { display: flex; align-items: center; gap: 18px; }
.ctb-titlerow .ctb-tile { width: 56px; height: 56px; border-radius: 16px; }
.ctb-pagehead h1 { font-size: clamp(2rem, 4.4vw, 3.2rem); font-weight: 800; letter-spacing: -.035em; margin: 0; }
.ctb-sub { color: var(--muted); font-size: 1.18rem; margin: 12px 0 0; max-width: 640px; }

/* Ads */
.ctb-ad { min-height: 90px; margin: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ctb-ad--bottom { margin: 34px 0 0; }
.ctb-ad--placeholder {
	border: 2px dashed var(--line-2); border-radius: var(--r-sm); color: var(--muted); font-size: .9rem; text-align: center; padding: 14px 18px; background: var(--surface);
}

.ctb-about { margin-top: 44px; }
.ctb-related { margin-top: 56px; }
.ctb-related h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 20px; }

/* ==========================================================================
   6b. Panels (shared by tools and content pages)
   ========================================================================== */
.ctb-panel {
	position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
	box-shadow: var(--shadow); padding: 34px 32px 32px;
}
.ctb-panel::before {
	content: ""; position: absolute; left: 32px; right: 32px; top: -1px; height: 4px; border-radius: 0 0 6px 6px; background: var(--c, var(--blue));
}
.ctb-panel--wide { padding: 32px; }
.ctb-panel__label { font-size: .82rem; font-weight: 700; letter-spacing: .04em; color: var(--muted); margin: 0 0 20px; }

/* ==========================================================================
   7. Generic content (pages, posts)
   ========================================================================== */
.ctb-panel--article { margin-top: 40px; padding: 40px; }
.ctb-panel--article::before { display: none; }
.ctb-article-title { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; margin-bottom: 18px; }
.ctb-article-title a { color: var(--ink); text-decoration: none; }
.ctb-prose { max-width: 72ch; font-size: 1.06rem; color: var(--ink-2); }
.ctb-prose h2 { font-size: 1.6rem; color: var(--ink); margin-top: 1.4em; font-weight: 800; }
.ctb-prose h3 { font-size: 1.25rem; color: var(--ink); margin-top: 1.3em; }
.ctb-prose ul, .ctb-prose ol { padding-left: 1.3em; }
.ctb-prose li { margin-bottom: .4em; }
.ctb-prose img { height: auto; border-radius: var(--r-sm); }
.ctb-about .ctb-prose {
	max-width: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 34px 38px; box-shadow: var(--shadow-sm);
}
.ctb-about .ctb-prose > :first-child { margin-top: 0; }
.ctb-about .ctb-prose > :last-child { margin-bottom: 0; }
.ctb-otherresults { margin-top: 30px; }
.ctb-404 { text-align: center; padding-top: 80px; }
.ctb-404 h1 { font-size: clamp(2rem, 5vw, 3rem); margin-top: 22px; }
.ctb-404 p { color: var(--muted); font-size: 1.15rem; }
.ctb-pager { margin-top: 30px; }

/* ==========================================================================
   8. Footer
   ========================================================================== */
.ctb-footer { border-top: 1px solid var(--line); background: var(--surface); }
.ctb-footer__in { display: flex; flex-wrap: wrap; gap: 14px 40px; align-items: center; justify-content: space-between; padding-top: 26px; padding-bottom: 26px; }
.ctb-footer .ctb-menu { gap: 6px 30px; }
.ctb-footer .ctb-menu a { color: var(--ink-2); text-decoration: none; font-weight: 500; }
.ctb-footer .ctb-menu a:hover { color: var(--blue); text-decoration: underline; }
.ctb-footer__copy { margin: 0; color: var(--muted); font-size: .95rem; }

/* ==========================================================================
   9. Responsive
   ========================================================================== */
@media (max-width: 960px) {
	.ctb-pagehead { grid-template-columns: 1fr; align-items: start; }
	.ctb-header--search .ctb-header__in { flex-wrap: wrap; gap: 14px 16px; padding-top: 14px; padding-bottom: 14px; }
	.ctb-header--search .ctb-search { order: 3; flex: 1 1 100%; max-width: none; }
	.ctb-header--search .ctb-iconbtn { margin-left: auto; }
}
@media (max-width: 640px) {
	.ctb-container { padding: 0 18px; }
	.ctb-header__in { min-height: 70px; gap: 12px; }
	.ctb-logo { font-size: 1.2rem; }
	.ctb-logo__mark { width: 36px; height: auto; }
	.ctb-nav .ctb-menu a { padding: 8px 12px; font-size: .95rem; }
	.ctb-nav { margin-left: auto; }
	.ctb-search input[type="search"] { height: 54px; font-size: 1rem; }
	.ctb-chip { padding: 10px 18px; font-size: .95rem; }
	.ctb-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
	.ctb-card { padding: 18px 16px 18px; }
	.ctb-card__title { font-size: 1.05rem; }
	.ctb-card__desc { font-size: .88rem; }
	.ctb-btn--tool { min-height: 44px; font-size: .95rem; padding: 0 12px; }
	.ctb-titlerow .ctb-tile { width: 46px; height: 46px; }
	.ctb-panel--article, .ctb-about .ctb-prose { padding: 24px; }
}
@media (max-width: 400px) {
	.ctb-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- All-tools index, contact form, notices ---------- */
.ctb-alltools h2 { margin: 1.6em 0 .4em; font-size: 1.35rem; }
.ctb-alltools h2 a { color: var(--ink); text-decoration: none; }
.ctb-alltools ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ctb-alltools li { padding: 12px 16px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-sm); }
.ctb-alltools li a { color: var(--blue-d); text-decoration: none; }
.ctb-alltools li a:hover { text-decoration: underline; }
.ctb-alltools li span { color: var(--muted); }
.ctb-form { display: grid; gap: 16px; max-width: 620px; margin: 22px 0 8px; }
.ctb-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.ctb-notice { padding: 14px 18px; border-radius: var(--r-sm); font-weight: 600; margin: 16px 0; max-width: 620px; }
.ctb-notice--ok { background: var(--green-l); color: var(--green-d); }
.ctb-notice--err { background: var(--red-l); color: var(--red-d); }
.ctb-prose table, .ctb-panel--article table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: .95em; }
.ctb-prose th, .ctb-prose td, .ctb-panel--article th, .ctb-panel--article td { padding: 10px 14px; border: 1px solid var(--line); text-align: left; }
.ctb-prose th, .ctb-panel--article th { background: var(--surface-2, var(--line)); }
