/*
Theme Name: Knowledge Diary Notebook
Theme URI: https://knowledgediarybd.com
Author: Knowledge Diary
Author URI: https://knowledgediarybd.com
Description: Notebook-diary learning theme for Knowledge Diary: warm paper, ink-blue headings, a red margin line, handwritten labels, taped photos, index-tab navigation and readable code blocks.
Version: 1.0.0
Requires at least: 6.2
Tested up to: 7.1
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: knowledgediary
*/

:root {
	--paper: #fbf8f1;
	--page: #fffdf8;
	--rule: #dfe7f3;
	--ink: #1d3c78;
	--ink-dark: #142a55;
	--text: #2b2f38;
	--muted: #6b6f7b;
	--margin: #e05a4f;
	--high: #ffe680;
	--note: #fff3b0;
	--tape: rgba(214, 200, 160, .55);
	--line: #e6dfcf;
	--code-bg: #f3f5f9;
	--serif: "Literata", Georgia, "Times New Roman", serif;
	--hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
	--mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	--radius: 6px;
	--wrap: 1180px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--paper);
	color: var(--text);
	font: 400 17px/1.7 var(--serif);
	-webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--margin); }
h1, h2, h3, h4 { font-family: var(--serif); color: var(--ink-dark); line-height: 1.22; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 1em; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.wrap--narrow { max-width: 780px; }
.wrap--mid { max-width: 900px; }

.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(1px, 1px, 1px, 1px); white-space: nowrap; }
.skip-link:focus { position: fixed !important; top: 8px; left: 8px; width: auto; height: auto; clip: auto; z-index: 1000; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: var(--radius); }
:focus-visible { outline: 2px solid var(--margin); outline-offset: 2px; }

/* ---------- binding + header ---------- */
.binding {
	height: 18px;
	background:
		radial-gradient(circle at 12px 9px, var(--paper) 0 4px, var(--ink) 4.5px 6px, transparent 6.5px) 0 0 / 28px 18px repeat-x,
		var(--ink);
}
.site-header { background: var(--page); border-bottom: 1px solid var(--line); position: relative; }
.head-row { display: flex; align-items: center; gap: 14px; min-height: 86px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink-dark); }
.brand-mark { width: 40px; height: 40px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font: 700 27px/1 var(--serif); letter-spacing: -.02em; color: var(--ink-dark); }
.brand-name em { font-style: italic; font-weight: 600; color: var(--ink); }
.brand-sub { font: 500 19px/1.1 var(--hand); color: var(--margin); margin-top: 3px; }
.custom-logo { max-height: 46px; width: auto; }
.head-date { margin-left: auto; font: 500 21px/1 var(--hand); color: var(--muted); }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--ink); width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { border-color: var(--ink); }
.nav-toggle { display: none; }
.header-search { display: none; padding: 14px 0 18px; border-top: 1px dashed var(--line); }
.header-search.is-open { display: block; }

/* index tabs */
.tabs-row { background: var(--paper); border-top: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.primary-nav ul { list-style: none; margin: 0; padding: 10px 0 0; display: flex; gap: 6px; flex-wrap: wrap; }
.primary-nav li a {
	display: block; padding: 8px 15px 9px; font: 600 14.5px/1.2 var(--serif); color: var(--ink-dark);
	background: var(--page); border: 1px solid var(--line); border-bottom: 0; border-radius: 9px 9px 0 0;
	position: relative; top: 1px;
}
.primary-nav li:nth-child(6n+1) a { box-shadow: inset 0 3px 0 #7aa7e0; }
.primary-nav li:nth-child(6n+2) a { box-shadow: inset 0 3px 0 #e8a33d; }
.primary-nav li:nth-child(6n+3) a { box-shadow: inset 0 3px 0 #67b38b; }
.primary-nav li:nth-child(6n+4) a { box-shadow: inset 0 3px 0 #c87fd0; }
.primary-nav li:nth-child(6n+5) a { box-shadow: inset 0 3px 0 #e05a4f; }
.primary-nav li:nth-child(6n+6) a { box-shadow: inset 0 3px 0 #4fb3c4; }
.primary-nav li a:hover, .primary-nav .current-menu-item a, .primary-nav .current-menu-parent a { background: #fff; color: var(--margin); }

/* ---------- shared bits ---------- */
.kicker {
	display: inline-block; font: 700 20px/1 var(--hand); color: var(--ink);
	background: linear-gradient(transparent 55%, var(--high) 55%); padding: 0 4px; margin-bottom: 8px;
}
.hand-head { font: 700 30px/1.05 var(--hand); color: var(--margin); letter-spacing: 0; margin: 0 0 12px; }
.meta, .dateline { font-size: 14px; color: var(--muted); display: flex; align-items: center; flex-wrap: wrap; gap: 0; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; display: inline-block; margin: 0 10px; opacity: .6; }
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--ink); color: #fff; border: 1px solid var(--ink); border-radius: 999px; padding: 10px 20px; font: 600 15px/1 var(--serif); cursor: pointer; }
.btn:hover { background: var(--ink-dark); color: #fff; }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { background: var(--ink); color: #fff; }
.placeholder-media { aspect-ratio: 16 / 10; background: repeating-linear-gradient(var(--page) 0 27px, var(--rule) 27px 28px); display: grid; place-items: center; font: 700 26px var(--hand); color: var(--ink); }

/* taped photos */
.taped { position: relative; display: block; }
.taped::before {
	content: ""; position: absolute; z-index: 2; top: -11px; left: 50%; width: 92px; height: 24px;
	transform: translateX(-50%) rotate(-3deg); background: var(--tape); box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.taped img { border: 6px solid #fff; box-shadow: 0 2px 10px rgba(30, 40, 60, .12); border-radius: 2px; }

/* ---------- front page ---------- */
.front { padding: 38px 0 18px; }
.front-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 36px; align-items: start; }
.entry-page {
	background: var(--page) repeating-linear-gradient(transparent 0 31px, var(--rule) 31px 32px);
	border: 1px solid var(--line); border-radius: var(--radius); padding: 30px 30px 26px 64px; position: relative;
	box-shadow: 0 1px 0 #fff inset, 0 8px 24px rgba(30, 40, 60, .06);
}
.entry-page::before { content: ""; position: absolute; top: 0; bottom: 0; left: 40px; width: 2px; background: var(--margin); opacity: .75; }
.entry-stamp { font: 600 22px/1.1 var(--hand); color: var(--muted); margin-bottom: 18px; }
.entry-page .entry-stamp { text-align: right; }
.lead-media { margin-bottom: 22px; }
.lead-media img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.lead-story h2 { font-size: clamp(28px, 3.4vw, 40px); margin: 6px 0 12px; }
.lead-story h2 a { color: var(--ink-dark); }
.lead-story h2 a:hover { color: var(--margin); }
.lead-story .deck { font-size: 18.5px; color: #3c414c; }

.contents { background: var(--page); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px 10px; }
.contents-list { list-style: none; margin: 0; padding: 0; counter-reset: c; }
.contents-list li { counter-increment: c; display: grid; grid-template-columns: 34px 1fr auto; column-gap: 8px; padding: 13px 0; border-top: 1px dashed var(--line); align-items: baseline; }
.contents-list li::before { content: counter(c, decimal-leading-zero); font: 700 22px/1 var(--hand); color: var(--margin); grid-row: span 2; }
.contents-cat { grid-column: 2 / 4; font: 600 12px/1.2 var(--serif); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.contents-list a { grid-column: 2; font-weight: 600; font-size: 16px; line-height: 1.35; color: var(--ink-dark); }
.contents-list a:hover { color: var(--margin); }
.contents-list time { grid-column: 3; font: 600 18px/1 var(--hand); color: var(--muted); white-space: nowrap; }

/* chapters */
.chapter { padding: 38px 0 8px; }
.chapter-head { display: grid; grid-template-columns: auto 1fr auto; column-gap: 16px; align-items: baseline; border-bottom: 2px solid var(--ink-dark); padding-bottom: 10px; margin-bottom: 30px; }
.chapter-no { font: 700 26px/1 var(--hand); color: var(--margin); }
.chapter-head h2 { font-size: 28px; margin: 0; }
.chapter-head h2 a { color: var(--ink-dark); }
.chapter-desc { grid-column: 1 / 3; grid-row: 2; margin: 6px 0 0; color: var(--muted); font-size: 15px; font-style: italic; }
.more { font-weight: 600; font-size: 15px; white-space: nowrap; }

.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 34px 28px; }
.card { display: flex; flex-direction: column; }
.card .kicker, .lead-story .kicker { align-self: flex-start; }
.card-media { margin-bottom: 16px; }
.card-media img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.card:nth-child(3n+1) .card-media.taped::before { transform: translateX(-50%) rotate(-4deg); }
.card:nth-child(3n+2) .card-media.taped::before { transform: translateX(-50%) rotate(3deg); left: 35%; }
.card:nth-child(3n) .card-media.taped::before { transform: translateX(-50%) rotate(-1deg); left: 62%; }
.card h3 { font-size: 20px; margin: 0 0 8px; }
.card h3 a { color: var(--ink-dark); }
.card h3 a:hover { color: var(--margin); }
.card .excerpt { color: #4a4f5a; font-size: 15.5px; line-height: 1.6; margin-bottom: 10px; }

.about-strip { padding: 50px 0 60px; }
.sticky-note {
	max-width: 760px; margin: 0 auto; background: var(--note); padding: 30px 34px 28px; transform: rotate(-.6deg);
	box-shadow: 0 10px 24px rgba(60, 50, 10, .12), 0 1px 0 rgba(0,0,0,.04); position: relative;
}
.sticky-note::before { content: ""; position: absolute; top: -12px; left: 50%; width: 110px; height: 26px; transform: translateX(-50%) rotate(2deg); background: var(--tape); }
.sticky-note p { font-size: 16.5px; }

/* ---------- archives / pages ---------- */
.archive-head, .page-head { padding: 42px 0 26px; border-bottom: 2px solid var(--ink-dark); margin-bottom: 34px; }
.archive-head h1, .page-head h1 { font-size: clamp(32px, 4vw, 46px); margin: 4px 0 8px; }
.archive-head p, .standfirst { color: var(--muted); font-size: 18px; margin: 0; max-width: 720px; }
.archive-grid { margin-bottom: 40px; }
.empty-state { padding: 30px 0 60px; color: var(--muted); }
.page-body { padding-bottom: 60px; }
.not-found { text-align: center; padding: 80px 24px; }
.not-found h1 { font-size: 40px; }
.search-form { display: flex; gap: 10px; max-width: 560px; }
.search-input { flex: 1; min-width: 0; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 11px 18px; font: 400 16px var(--serif); color: var(--text); }
.search-form-big { margin-top: 16px; }
.not-found .search-form { margin: 0 auto; }
.nav-links { display: flex; gap: 8px; justify-content: center; padding: 10px 0 50px; flex-wrap: wrap; }
.page-numbers { display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--page); font-weight: 600; }
.page-numbers.current { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- single entry ---------- */
.story-head { padding: 40px 0 26px; }
.story-head .entry-stamp { margin-bottom: 10px; }
.story-head h1 { font-size: clamp(31px, 4.2vw, 48px); margin: 6px 0 14px; max-width: 900px; }
.story-head .deck, .story-head .dateline { max-width: 820px; }
.story-head .deck { font-size: 20px; color: #3c414c; margin-bottom: 14px; }
.story-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 46px; align-items: start; padding-bottom: 30px; }
.article-cover { margin: 8px 0 30px; }
.article-cover img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.article-cover figcaption { font-size: 13.5px; color: var(--muted); margin-top: 10px; }
.article-cover figcaption a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }

.article-body { position: relative; padding-left: 34px; font-size: 18px; line-height: 1.78; }
.article-body::before { content: ""; position: absolute; top: 4px; bottom: 4px; left: 8px; width: 2px; background: var(--margin); opacity: .55; }
.article-body h2 { font-size: 26px; margin: 1.7em 0 .55em; display: inline; background: linear-gradient(transparent 62%, var(--high) 62%); box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.article-body h2::after { content: ""; display: block; margin-bottom: .55em; }
.article-body h3 { font-size: 21px; margin: 1.4em 0 .4em; }
.article-body a { text-decoration: underline; text-decoration-color: rgba(29, 60, 120, .35); text-underline-offset: 3px; }
.article-body a:hover { text-decoration-color: var(--margin); }
.article-body ul, .article-body ol { padding-left: 1.3em; margin: 0 0 1.1em; }
.article-body li { margin-bottom: .45em; }
.article-body blockquote { margin: 1.4em 0; padding: 14px 20px; background: var(--note); border-left: 4px solid #e2c24a; font-style: italic; }
.article-body code { font: 500 .86em var(--mono); background: var(--code-bg); border: 1px solid #e3e8f1; border-radius: 4px; padding: .1em .35em; color: #1a2f63; }
.article-body pre {
	background: #fff repeating-linear-gradient(transparent 0 25px, #eef2f8 25px 26px);
	border: 1px solid #dde4ef; border-left: 4px solid var(--ink); border-radius: var(--radius);
	padding: 14px 18px; overflow-x: auto; margin: 1.3em 0 1.5em; line-height: 26px;
}
.article-body pre code { background: none; border: 0; padding: 0; font-size: 14.5px; color: #1d2433; white-space: pre; }

.sponsored-note { background: #fff; border: 1px dashed var(--muted); padding: 12px 16px; font-size: 14.5px; }
.sources-box {
	margin: 40px 0 26px; background: var(--note); padding: 22px 26px 16px; border-radius: 2px;
	box-shadow: 0 6px 18px rgba(60, 50, 10, .10); transform: rotate(-.3deg);
}
.sources-box ol { margin: 0; padding-left: 1.3em; font-size: 15px; line-height: 1.55; }
.sources-box li { margin-bottom: .6em; word-break: break-word; }
.sources-box .pub { color: #6d6440; }
.tag-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 18px; }
.tag-row a { font-size: 13.5px; border: 1px solid var(--line); background: var(--page); padding: 4px 12px; border-radius: 999px; }
.editorial-note { font-size: 14px; color: var(--muted); font-style: italic; }

.fact-box { position: sticky; top: 70px; }
.fact-inner { background: var(--page) repeating-linear-gradient(transparent 0 29px, var(--rule) 29px 30px); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.fact-inner .hand-head { font-size: 27px; }
.fact-inner dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14.5px; line-height: 24px; }
.fact-inner dt { color: var(--muted); }
.fact-inner dd { margin: 0; font-weight: 600; color: var(--ink-dark); }
.fact-share { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); }
.fact-share a { font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; }
.related { padding-top: 26px; border-top: 1px solid var(--line); margin-top: 20px; }

/* ---------- contact form ---------- */
.contact-form { margin-top: 30px; background: var(--page); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 26px; }
.contact-form h2 { font: 700 28px var(--hand); color: var(--margin); }
.contact-form .lead { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 14.5px; }
.field input, .field textarea { border: 1px solid var(--line); background: #fff; border-radius: var(--radius); padding: 10px 12px; font: 400 16px var(--serif); color: var(--text); }
.field textarea { min-height: 140px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hp { position: absolute; left: -9999px; }
.notice { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 15px; }
.notice--ok { background: #e7f5ec; color: #1d5b36; }
.notice--err { background: #fde9e7; color: #8a2a21; }

/* ---------- footer ---------- */
.site-footer { background: var(--ink-dark); color: #d7def0; margin-top: 30px; padding: 48px 0 26px; }
.site-footer a { color: #fff; }
.site-footer a:hover { color: var(--high); }
.site-footer .brand-name, .site-footer .brand-name em { color: #fff; }
.site-footer .brand-sub { color: var(--high); }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 40px; }
.footer-grid p { font-size: 15px; margin-top: 14px; max-width: 420px; }
.footer-grid h4 { font: 700 24px var(--hand); color: var(--high); margin-bottom: 10px; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; font-size: 15px; line-height: 2; }
.footer-bottom { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-top: 36px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.15); font-size: 13px; color: #aeb8d3; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
	.front-grid { grid-template-columns: 1fr; }
	.story-grid { grid-template-columns: 1fr; }
	.fact-box { position: static; order: -1; }
	.card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
	body { font-size: 16.5px; }
	.wrap { padding: 0 16px; }
	.head-row { min-height: 70px; gap: 10px; }
	.head-date { display: none; }
	.search-toggle { margin-left: auto; }
	.nav-toggle { display: inline-grid; }
	.brand-name { font-size: 22px; }
	.brand-sub { font-size: 17px; }
	.brand-mark { width: 34px; height: 34px; }
	.tabs-row { position: static; }
	.primary-nav { display: none; }
	.primary-nav.is-open { display: block; }
	.primary-nav ul { flex-direction: column; gap: 0; padding: 6px 0 10px; }
	.primary-nav li a { border-radius: 0; border: 0; border-bottom: 1px dashed var(--line); box-shadow: none !important; background: transparent; top: 0; padding: 12px 4px; }
	.entry-page { padding: 22px 18px 20px 40px; }
	.entry-page::before { left: 24px; }
	.card-grid { grid-template-columns: 1fr; }
	.chapter-head { grid-template-columns: 1fr auto; }
	.chapter-no { grid-column: 1 / 3; }
	.chapter-desc { grid-column: 1 / 3; grid-row: auto; }
	.article-body { padding-left: 20px; font-size: 17px; }
	.article-body::before { left: 2px; }
	.field-row { grid-template-columns: 1fr; }
	.footer-grid { grid-template-columns: 1fr; gap: 26px; }
	.sticky-note { padding: 24px 22px; }
}
