/*
Theme Name:        PatzIT Dev
Theme URI:         https://dev.patzit.ca/
Author:            PatzIT
Description:       Custom theme for dev.patzit.ca: app pages, dev notes, a terminal-inspired look with dark and light modes. Pairs with the PatzIT Dev Apps plugin.
Version:           1.0.0
Requires at least: 6.5
Tested up to:      7.1
Requires PHP:      8.1
License:           GPL-2.0-or-later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html
Text Domain:       patzit-dev
Update URI:        false
*/

/* ---------- Tokens ---------- */
:root {
	--bg: #0b0f14;
	--bg-alt: #10161d;
	--surface: #141b23;
	--surface-2: #1a232d;
	--border: #263241;
	--text: #e3e9ef;
	--muted: #93a1b0;
	--accent: #39d98a;          /* phosphor green */
	--accent-ink: #062314;
	--accent-2: #ffb547;        /* amber */
	--link: #6fe3a8;
	--focus: #ffb547;

	--status-idea: #93a1b0;
	--status-development: #6aa8ff;
	--status-testing: #ffb547;
	--status-beta: #c792ea;
	--status-released: #39d98a;
	--status-archived: #6b7785;

	--font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

	--radius: 10px;
	--wrap: 1160px;
	--wrap-narrow: 760px;
	--gap: clamp(1rem, 2.5vw, 1.75rem);
	--shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px rgba(0, 0, 0, .25);

	color-scheme: dark;
}

@media (prefers-color-scheme: light) {
	:root {
		--bg: #f7f9fb;
		--bg-alt: #eef2f6;
		--surface: #ffffff;
		--surface-2: #f2f5f8;
		--border: #d7dee6;
		--text: #17202a;
		--muted: #5a6877;
		--accent: #0f9d58;
		--accent-ink: #ffffff;
		--accent-2: #b26a00;
		--link: #0b7d46;
		--focus: #b26a00;
		--status-idea: #5a6877;
		--status-development: #1f63d6;
		--status-testing: #a35f00;
		--status-beta: #7b3fb5;
		--status-released: #0b7d46;
		--status-archived: #6b7785;
		--shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 18px rgba(16, 24, 40, .06);
		color-scheme: light;
	}
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 400 1.0625rem/1.65 var(--font-sans);
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

.site-main { flex: 1; outline: none; }

img, svg, video { max-width: 100%; height: auto; }

a { color: var(--link); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 3px; }

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .6em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 4.5vw, 3rem); }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.75rem); }
h3 { font-size: 1.2rem; }

p, ul, ol, dl, figure, blockquote, pre, table { margin: 0 0 1.2em; }

code, kbd, pre, samp { font-family: var(--font-mono); font-size: .92em; }
:not(pre) > code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: .1em .35em; }
pre {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1rem 1.25rem;
	overflow-x: auto;
	line-height: 1.5;
}

hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }

blockquote {
	border-left: 3px solid var(--accent);
	padding: .25rem 0 .25rem 1.25rem;
	color: var(--muted);
	margin-left: 0;
}

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { border-bottom: 1px solid var(--border); padding: .6rem .75rem; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }

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

.skip-link {
	position: absolute; left: 1rem; top: -4rem; z-index: 100;
	background: var(--accent); color: var(--accent-ink);
	padding: .6rem 1rem; border-radius: 6px; font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 1rem; }

.muted { color: var(--muted); font-size: .9em; }

/* ---------- Layout ---------- */
.wrap { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; }
.wrap--narrow { width: min(100% - 2.5rem, var(--wrap-narrow)); }

.section { padding-block: clamp(2.5rem, 6vw, 4.5rem); }
.section--alt { background: var(--bg-alt); border-block: 1px solid var(--border); }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.section__title { margin: 0; font-family: var(--font-mono); font-size: 1.15rem; text-transform: lowercase; letter-spacing: .02em; }
.section__title::before { content: "## "; color: var(--accent); }
.section__more { font-family: var(--font-mono); font-size: .9rem; text-decoration: none; }

.grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
	gap: var(--gap);
}

/* ---------- Header ---------- */
.site-header {
	position: sticky; top: 0; z-index: 50;
	background: color-mix(in srgb, var(--bg) 86%, transparent);
	backdrop-filter: saturate(150%) blur(10px);
	-webkit-backdrop-filter: saturate(150%) blur(10px);
	border-bottom: 1px solid var(--border);
}
.admin-bar .site-header { top: 32px; }
@media (max-width: 782px) { .admin-bar .site-header { top: 0; position: relative; } }

.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4rem; }

.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--text); text-decoration: none; font-family: var(--font-mono); font-weight: 700; }
.brand:hover { color: var(--text); }
.brand__prompt { color: var(--accent); }
.brand__logo { width: 32px; height: 32px; object-fit: contain; border-radius: 6px; }
.brand__prompt::after { content: ""; display: inline-block; width: .55em; height: 1.05em; margin-left: .1em; vertical-align: -.15em; background: var(--accent); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.site-nav .menu { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; }
.site-nav a {
	display: block; padding: .45rem .8rem; border-radius: 7px;
	color: var(--muted); text-decoration: none; font-weight: 500;
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); }
.site-nav .current-menu-item > a,
.site-nav .current_page_item > a,
.site-nav .current-menu-ancestor > a,
.site-nav [aria-current="page"] { color: var(--accent); }

.nav-toggle { display: none; }

@media (max-width: 720px) {
	.nav-toggle {
		display: inline-grid; place-items: center;
		width: 2.75rem; height: 2.75rem;
		background: transparent; border: 1px solid var(--border); border-radius: 8px;
		color: var(--text); cursor: pointer;
	}
	.nav-toggle__bars, .nav-toggle__bars::before, .nav-toggle__bars::after {
		display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; position: relative; content: "";
		transition: transform .2s ease;
	}
	.nav-toggle__bars::before { position: absolute; top: -6px; }
	.nav-toggle__bars::after { position: absolute; top: 6px; }
	.nav-toggle[aria-expanded="true"] .nav-toggle__bars { background: transparent; }
	.nav-toggle[aria-expanded="true"] .nav-toggle__bars::before { transform: translateY(6px) rotate(45deg); }
	.nav-toggle[aria-expanded="true"] .nav-toggle__bars::after { transform: translateY(-6px) rotate(-45deg); }

	.js .site-nav { display: none; }
	.js .site-nav.is-open { display: block; position: absolute; left: 0; right: 0; top: 100%; background: var(--bg); border-bottom: 1px solid var(--border); }
	.site-nav .menu { flex-direction: column; padding: .5rem 1.25rem 1rem; }
	.site-nav a { padding: .75rem .5rem; }
	.site-header__inner { position: relative; flex-wrap: wrap; }
}

/* ---------- Buttons, badges, tags ---------- */
.button, .wp-block-button__link, input[type="submit"] {
	display: inline-flex; align-items: center; gap: .4rem;
	background: var(--accent); color: var(--accent-ink);
	border: 1px solid var(--accent); border-radius: 8px;
	padding: .65rem 1.1rem; font: 600 .95rem/1.2 var(--font-sans);
	text-decoration: none; cursor: pointer;
	transition: filter .15s ease, transform .15s ease;
}
.button:hover, .wp-block-button__link:hover, input[type="submit"]:hover { color: var(--accent-ink); filter: brightness(1.08); }
.button:active { transform: translateY(1px); }
.button--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.button--ghost:hover { color: var(--accent); border-color: var(--accent); filter: none; }
.button--small { padding: .45rem .8rem; font-size: .875rem; }

.badge {
	--c: var(--status-development);
	display: inline-flex; align-items: center; gap: .4rem;
	font: 600 .75rem/1 var(--font-mono); text-transform: uppercase; letter-spacing: .06em;
	color: var(--c);
	border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
	background: color-mix(in srgb, var(--c) 12%, transparent);
	padding: .35rem .55rem; border-radius: 999px;
}
.badge::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; }
.badge--idea { --c: var(--status-idea); }
.badge--testing { --c: var(--status-testing); }
.badge--beta { --c: var(--status-beta); }
.badge--released { --c: var(--status-released); }
.badge--archived { --c: var(--status-archived); }

.tags { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: 0; }
.tags li, .tags a {
	font: 500 .78rem/1 var(--font-mono);
	color: var(--muted);
}
.tags li { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .35rem .5rem; }
.tags li:has(a) { padding: 0; }
.tags a { display: block; padding: .35rem .5rem; text-decoration: none; }
.tags a:hover { color: var(--accent); }

.kicker { font: 500 .85rem/1.4 var(--font-mono); color: var(--accent); margin: 0 0 .75rem; letter-spacing: .02em; }
.kicker a { color: inherit; text-decoration: none; }
.kicker a:hover { text-decoration: underline; }

/* ---------- Hero / page heads ---------- */
.hero {
	padding-block: clamp(3.5rem, 10vw, 7rem) clamp(2.5rem, 6vw, 4rem);
	background:
		radial-gradient(60rem 30rem at 10% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
		radial-gradient(40rem 24rem at 100% 0%, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent 60%);
	border-bottom: 1px solid var(--border);
}
.hero__title { font-size: clamp(2.4rem, 6vw, 4rem); margin-bottom: .35em; }
.hero__lead { font-size: clamp(1.1rem, 2vw, 1.3rem); color: var(--muted); max-width: 44rem; }
.hero__lead p:last-child { margin-bottom: 0; }
.hero__actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }

.page-head { padding-block: clamp(2.5rem, 7vw, 4.5rem) clamp(1.5rem, 4vw, 2.5rem); border-bottom: 1px solid var(--border); }
.page-head__title { margin-bottom: .3em; }
.page-head__lead { font-size: 1.2rem; color: var(--muted); max-width: 46rem; margin-bottom: 0; }
.page-head__meta { margin-top: 1.25rem; }
.page-head .search-form { margin-top: 1.5rem; }
.page-head--app {
	background: radial-gradient(50rem 24rem at 0% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%);
}

/* ---------- Cards ---------- */
.card {
	position: relative;
	display: flex; flex-direction: column;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	overflow: hidden;
	transition: border-color .15s ease, transform .15s ease;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); transform: translateY(-2px); }
.card:focus-within { border-color: var(--accent); }
.card__media img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.card__body { display: flex; flex-direction: column; gap: .75rem; padding: 1.35rem 1.35rem 1.5rem; flex: 1; }
.card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.card__platform { font-size: .85rem; color: var(--muted); }
.card__title { margin: 0; font-size: 1.35rem; }
.card__link { color: var(--text); text-decoration: none; }
.card__link::after { content: ""; position: absolute; inset: 0; } /* whole card is clickable */
.card__link:hover { color: var(--accent); }
.card__text { color: var(--muted); font-size: .98rem; flex: 1; }
.card__text p { margin: 0; }
.card .tags { position: relative; } /* stays above the card link overlay for text selection */

/* ---------- Notes list ---------- */
.notes { display: grid; gap: 0; }
.note { padding-block: 1.35rem; border-bottom: 1px solid var(--border); }
.note:first-child { padding-top: 0; }
.note:last-child { border-bottom: 0; }
.note__meta { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; font: .85rem/1.4 var(--font-mono); color: var(--muted); margin-bottom: .35rem; }
.note__app { color: var(--accent-2); text-decoration: none; }
.note__app::before { content: "#"; }
.note__title { margin: 0 0 .35rem; font-size: 1.25rem; }
.note__title a { color: var(--text); text-decoration: none; }
.note__title a:hover { color: var(--accent); }
.note__text { color: var(--muted); }
.note__text p { margin: 0; }

/* ---------- App page ---------- */
.app__layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 320px;
	gap: clamp(2rem, 5vw, 4rem);
	padding-block: clamp(2rem, 5vw, 3.5rem);
	align-items: start;
}
@media (max-width: 900px) {
	.app__layout { grid-template-columns: 1fr; }
	.app__aside { order: -1; }
}
.app__aside { display: grid; gap: 1.25rem; position: sticky; top: 5.5rem; }
@media (max-width: 900px) { .app__aside { position: static; } }
.app__hero, .entry__hero { margin: 0 0 2rem; }
.app__hero img, .entry__hero img { border-radius: var(--radius); border: 1px solid var(--border); display: block; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.35rem; box-shadow: var(--shadow); }
.panel__title { font: 600 .8rem/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 1rem; }
.panel__subtitle { font: 600 .8rem/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 1.25rem 0 .6rem; }
.panel p:last-child { margin: 1.25rem 0 0; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: .55rem 1rem; margin: 0; font-size: .95rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; }

.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .65rem; font-size: .95rem; }
.link-list .muted { display: block; font-size: .8rem; }

/* ---------- Entry content ---------- */
.entry-content { padding-block: clamp(2rem, 5vw, 3rem); }
.app__content.entry-content { padding-block: 0; }
.entry-content > *:first-child { margin-top: 0; }
.entry-content h2 { margin-top: 2.2em; padding-top: .2em; }
.entry-content h2::before { content: "# "; color: var(--accent); font-family: var(--font-mono); font-weight: 500; }
.entry-content h3 { margin-top: 1.8em; }
.entry-content ul, .entry-content ol { padding-left: 1.3em; }
.entry-content li { margin-bottom: .45em; }
.entry-content li::marker { color: var(--accent); }
.entry-content .lead, .entry-content p.lead { font-size: 1.2rem; color: var(--text); }
.entry-content .note, .entry-content p.note, .callout {
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-left: 3px solid var(--accent-2);
	border-radius: 8px;
	padding: .85rem 1rem;
	font-size: .95rem;
	color: var(--muted);
}
.entry-content img { border-radius: 8px; }
.entry-content .wp-block-image figcaption, .entry-content figcaption { color: var(--muted); font-size: .875rem; text-align: center; margin-top: .5rem; }
.entry-content .alignwide { width: min(100vw - 2.5rem, var(--wrap)); max-width: none; margin-left: 50%; transform: translateX(-50%); }
.entry-content .alignfull { width: 100vw; max-width: none; margin-left: 50%; transform: translateX(-50%); }
.app__content .alignwide, .app__content .alignfull { width: auto; margin-left: 0; transform: none; }
.wp-block-code { border-radius: var(--radius); }

.entry__footer { display: grid; gap: 1.25rem; padding-bottom: 2rem; }

/* ---------- Post navigation ---------- */
.post-nav { padding-block: 2rem 3.5rem; }
.post-nav .nav-links { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.post-nav .nav-next { text-align: right; grid-column: 2; }
.post-nav a {
	display: block; height: 100%;
	background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
	padding: 1rem 1.25rem; color: var(--text); text-decoration: none; font-weight: 600;
}
.post-nav a:hover { border-color: var(--accent); color: var(--accent); }
.post-nav__label { display: block; font: 500 .78rem/1.4 var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .25rem; }
@media (max-width: 600px) { .post-nav .nav-links { grid-template-columns: 1fr; } .post-nav .nav-next { grid-column: 1; text-align: left; } }

.pagination { margin-top: 2.5rem; }
.pagination .nav-links { display: flex; flex-wrap: wrap; gap: .4rem; }
.pagination .page-numbers { display: inline-block; padding: .45rem .8rem; border: 1px solid var(--border); border-radius: 7px; text-decoration: none; color: var(--text); font-family: var(--font-mono); font-size: .9rem; }
.pagination .page-numbers.current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- Forms ---------- */
input[type="text"], input[type="email"], input[type="url"], input[type="search"], input[type="password"], textarea, select {
	width: 100%;
	background: var(--surface); color: var(--text);
	border: 1px solid var(--border); border-radius: 8px;
	padding: .65rem .8rem; font: inherit; font-size: 1rem;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
label { display: inline-block; font-weight: 500; margin-bottom: .35rem; }

.search-form { display: flex; gap: .5rem; max-width: 34rem; }
.search-form__input { flex: 1; }

/* ---------- Comments ---------- */
.comments { padding-block: 2rem; border-top: 1px solid var(--border); }
.comment-list { list-style: none; padding: 0; margin: 0 0 2rem; }
.comment-list .children { list-style: none; padding-left: clamp(1rem, 4vw, 2.5rem); }
.comment-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.comment-meta { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: center; font-size: .875rem; color: var(--muted); margin-bottom: .5rem; }
.comment-meta a { color: var(--muted); }
.comment-author .avatar { border-radius: 50%; vertical-align: middle; margin-right: .5rem; }
.comment-author .says { display: none; }
.reply a { font-size: .875rem; }
.comment-form p { margin-bottom: 1rem; }
.comment-form-cookies-consent { display: flex; gap: .5rem; align-items: flex-start; }
.comment-form-cookies-consent label { font-weight: 400; font-size: .9rem; color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-alt); color: var(--muted); font-size: .92rem; }
.site-footer__inner { padding-block: 2rem; display: grid; gap: 1.5rem; }
.site-footer__widgets { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; }
.site-footer .widget-title { font: 600 .8rem/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.site-footer__bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; }
.site-footer__copy { margin: 0; font-family: var(--font-mono); font-size: .85rem; }
.site-footer__copy a { color: var(--text); text-decoration: none; }
.footer-menu { display: flex; flex-wrap: wrap; gap: 1rem; list-style: none; margin: 0; padding: 0; }
.footer-menu a { color: var(--muted); text-decoration: none; }
.footer-menu a:hover { color: var(--accent); }

/* ---------- Core alignment classes ---------- */
.alignleft { float: left; margin: .3rem 1.5rem 1rem 0; }
.alignright { float: right; margin: .3rem 0 1rem 1.5rem; }
.aligncenter { display: block; margin-inline: auto; }
.wp-caption-text { color: var(--muted); font-size: .875rem; }
.sticky .note__title::after { content: " ★"; color: var(--accent-2); font-size: .8em; }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
	.site-header, .site-footer, .post-nav, .comments, .nav-toggle, .app__aside { display: none !important; }
	body { background: #fff; color: #000; }
	.app__layout { display: block; }
}
