/*
Theme Name: DIY Server Guide
Theme URI: https://diyserver.guide/
Description: Child theme of Twenty Twenty-Five for DIY Server Guide. A clean, readable notebook for people who run their own servers.
Author: DIY Server Guide
Template: twentytwentyfive
Version: 1.2.0
Requires at least: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: diyserver
*/

/* Raised surfaces (cards, form fields) sit a touch lighter than the soft page. */
:root {
	--diy-raised: #F1EEE8;
}

.wp-block-post-comments-form :is(input[type="text"], input[type="email"], input[type="url"], textarea),
.wp-block-search__input {
	background-color: var(--diy-raised);
}

/* ---------- Brand: notebook touches ---------- */

.wp-block-site-title a {
	text-decoration: none;
}

.diy-brand-mark {
	display: inline-grid;
	place-items: center;
	width: 2.25rem;
	height: 2.25rem;
	border-radius: 8px;
	background: var(--wp--preset--color--accent-1);
	color: var(--wp--preset--color--contrast);
	font-family: var(--wp--preset--font-family--fira-code);
	font-weight: 700;
	font-size: 0.95rem;
	transform: rotate(-4deg);
	box-shadow: 2px 2px 0 var(--wp--preset--color--contrast);
}

/* Handwritten "margin note" label used above section headings */
.is-style-margin-note,
p.is-style-margin-note {
	font-family: var(--wp--preset--font-family--caveat);
	font-size: 1.5rem;
	line-height: 1;
	color: var(--wp--preset--color--accent-2);
	margin-bottom: 0.25rem !important;
}

/* Hero: faint ruled-paper lines with a red margin, the one nod to the old notebook */
.diy-hero {
	background-color: var(--wp--preset--color--base);
	background-image:
		linear-gradient(90deg, transparent calc(var(--diy-margin, 3rem) - 1px), color-mix(in srgb, var(--wp--preset--color--accent-2) 45%, transparent) calc(var(--diy-margin, 3rem) - 1px), color-mix(in srgb, var(--wp--preset--color--accent-2) 45%, transparent) var(--diy-margin, 3rem), transparent var(--diy-margin, 3rem)),
		repeating-linear-gradient(180deg, transparent 0, transparent 31px, var(--wp--preset--color--accent-6) 31px, var(--wp--preset--color--accent-6) 32px);
	border-bottom: 1px solid var(--wp--preset--color--accent-6);
}

@media (max-width: 781px) {
	.diy-hero {
		--diy-margin: 1rem;
	}
}

/* Highlighter effect for a word in a heading: wrap it in <mark> */
.diy-hero mark,
.wp-block-heading mark {
	background: linear-gradient(180deg, transparent 55%, var(--wp--preset--color--accent-1) 55%, var(--wp--preset--color--accent-1) 92%, transparent 92%);
	color: inherit;
	padding: 0 0.1em;
}

/* ---------- Topic cards ---------- */

.diy-topic-card {
	border: 1px solid var(--wp--preset--color--accent-6);
	border-radius: 10px;
	background: var(--diy-raised);
	transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
	height: 100%;
}

.diy-topic-card:hover,
.diy-topic-card:focus-within {
	border-color: var(--wp--preset--color--contrast);
	box-shadow: 3px 3px 0 var(--wp--preset--color--contrast);
	transform: translate(-1px, -1px);
}

.diy-topic-card h3 a {
	text-decoration: none;
}

.diy-topic-card h3 a::after {
	content: "";
	position: absolute;
	inset: 0;
}

.diy-topic-card {
	position: relative;
}

/* ---------- Post lists ---------- */

.diy-post-card {
	border-top: 1px solid var(--wp--preset--color--accent-6);
}

.diy-post-card .wp-block-post-title a {
	text-decoration: none;
}

.diy-post-card .wp-block-post-title a:hover {
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.2em;
}

.wp-block-post-terms.is-style-diy-pill a {
	display: inline-block;
	padding: 0.15rem 0.6rem;
	border-radius: 999px;
	background: var(--wp--preset--color--accent-5);
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
	font-size: 0.8rem;
	font-weight: 600;
}

.wp-block-post-terms.is-style-diy-pill .wp-block-post-terms__separator {
	display: none;
}

.wp-block-post-terms.is-style-diy-pill {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

/* ---------- Article typography ---------- */

.wp-block-post-content > * + h2 {
	margin-top: var(--wp--preset--spacing--60);
}

.wp-block-post-content > * + h3 {
	margin-top: var(--wp--preset--spacing--50);
}

.wp-block-post-content img {
	height: auto;
	max-width: 100%;
	border-radius: 6px;
}

/* Classic-editor content from older posts: centred headings and inline images */
.wp-block-post-content h1,
.wp-block-post-content h2,
.wp-block-post-content h3,
.wp-block-post-content h4 {
	text-align: left;
}

.wp-block-post-content .aligncenter {
	display: block;
	margin-left: auto;
	margin-right: auto;
}

.wp-block-post-content table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.95em;
	display: block;
	overflow-x: auto;
}

.wp-block-post-content th,
.wp-block-post-content td {
	border: 1px solid var(--wp--preset--color--accent-6);
	padding: 0.5rem 0.75rem;
	text-align: left;
}

/* ---------- Code ---------- */

:where(.wp-block-post-content, .wp-block-post-excerpt, .wp-block-comment-content) :not(pre) > code,
:where(.wp-block-post-content) kbd {
	font-family: var(--wp--preset--font-family--fira-code);
	font-size: 0.88em;
	background: var(--wp--preset--color--accent-5);
	border: 1px solid var(--wp--preset--color--accent-6);
	border-radius: 4px;
	padding: 0.1em 0.35em;
	word-break: break-word;
}

.wp-block-post-content pre,
.wp-block-code {
	font-family: var(--wp--preset--font-family--fira-code);
	font-size: 0.875rem;
	line-height: 1.6;
	background: #10171f;
	color: #e6edf3;
	border-radius: 8px;
	padding: 1rem 1.25rem;
	overflow-x: auto;
	tab-size: 4;
	border: 0;
}

.wp-block-post-content pre code,
.wp-block-code code {
	background: transparent;
	border: 0;
	padding: 0;
	color: inherit;
	font-size: inherit;
}

/* Copy button (added by assets/copy-code.js) */
.diy-code-wrap {
	position: relative;
}

.diy-copy-btn {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	font: 600 0.75rem/1 var(--wp--preset--font-family--manrope);
	color: #e6edf3;
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 6px;
	padding: 0.4rem 0.6rem;
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.15s ease;
}

.diy-code-wrap:hover .diy-copy-btn,
.diy-copy-btn:focus-visible,
.diy-copy-btn.is-copied {
	opacity: 1;
}

@media (hover: none) {
	.diy-copy-btn {
		opacity: 1;
	}
}

/* ---------- Callouts (block styles on core/group) ---------- */

.wp-block-group.is-style-sticky-note,
.wp-block-group.is-style-warning-note,
.wp-block-group.is-style-info-note {
	border-radius: 8px;
	padding: 1rem 1.25rem;
	margin-top: var(--wp--preset--spacing--40);
	margin-bottom: var(--wp--preset--spacing--40);
}

.wp-block-group.is-style-sticky-note {
	background: #efe1a6;
	border-left: 5px solid var(--wp--preset--color--accent-1);
}

.wp-block-group.is-style-warning-note {
	background: #ecd3cd;
	border-left: 5px solid var(--wp--preset--color--accent-2);
}

.wp-block-group.is-style-info-note {
	background: #d3deec;
	border-left: 5px solid var(--wp--preset--color--accent-3);
}

.wp-block-group.is-style-sticky-note > :first-child,
.wp-block-group.is-style-warning-note > :first-child,
.wp-block-group.is-style-info-note > :first-child {
	margin-top: 0;
}

.wp-block-group.is-style-sticky-note > :last-child,
.wp-block-group.is-style-warning-note > :last-child,
.wp-block-group.is-style-info-note > :last-child {
	margin-bottom: 0;
}

/* ---------- Author box ---------- */

.diy-author-box {
	border: 1px solid var(--wp--preset--color--accent-6);
	border-radius: 10px;
	background: var(--wp--preset--color--accent-5);
}

.diy-author-box .wp-block-avatar img {
	border-radius: 50%;
}

/* ---------- Header / footer ---------- */

.diy-header {
	border-bottom: 1px solid var(--wp--preset--color--accent-6);
	background: color-mix(in srgb, var(--wp--preset--color--base) 92%, transparent);
	backdrop-filter: saturate(1.4) blur(8px);
	position: sticky;
	top: 0;
	z-index: 20;
}

.admin-bar .diy-header {
	top: var(--wp-admin--admin-bar--height, 32px);
}

@media (max-width: 600px) {
	.admin-bar .diy-header {
		top: 0;
	}
}

.diy-header .wp-block-navigation a {
	text-decoration: none;
	font-weight: 600;
}

.diy-header .wp-block-navigation a:hover {
	text-decoration: underline;
	text-underline-offset: 0.3em;
}

.diy-footer a {
	text-decoration: none;
}

.diy-footer a:hover {
	text-decoration: underline;
}

/* Visible focus for keyboard users */
a:focus-visible,
button:focus-visible,
input:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent-3);
	outline-offset: 2px;
}

.wp-block-post-date.diy-updated::before {
	content: "· Updated ";
}

.diy-topic-badge {
	display: inline-block;
	font-family: var(--wp--preset--font-family--fira-code);
	font-size: 0.8rem;
	font-weight: 600;
	line-height: 1;
	padding: 0.35rem 0.55rem;
	border-radius: 6px;
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--accent-1);
	margin-bottom: 0.5rem !important;
}

/* Old classic posts sometimes contain empty <pre> blocks */
.wp-block-post-content pre:empty,
.wp-block-post-content pre:has(> code:only-child:empty) {
	display: none;
}

.diy-brand-mark {
	flex-shrink: 0;
}

@media (max-width: 600px) {
	.diy-header .wp-block-site-tagline {
		display: none;
	}
}
