/*
Theme Name: TechScribe
Theme URI: https://example.com/techscribe
Author: TechScribe
Description: A modern, responsive, eye-friendly WordPress theme for technical blogs. Features a light/dark mode toggle, built-in search, a widget-ready sidebar, and a post calendar that highlights days with published posts.
Version: 1.0.0
Requires at least: 5.8
Tested up to: 6.7
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: techscribe
Tags: blog, two-columns, right-sidebar, custom-logo, custom-menu, dark-mode, featured-images, threaded-comments, translation-ready, widgets
*/

/* ==========================================================================
   1. Design tokens
   ========================================================================== */
:root {
	--bg: #f6f7f9;
	--surface: #ffffff;
	--surface-2: #eef1f5;
	--text: #1f2630;
	--text-muted: #5b6676;
	--border: #dde2e9;
	--accent: #3b6fd4;
	--accent-hover: #2a58b3;
	--accent-soft: #e4ecfb;
	--code-bg: #eef1f5;
	--code-text: #b3245c;
	--pre-bg: #1e2430;
	--pre-text: #e6eaf2;
	--shadow: 0 1px 2px rgba(20, 30, 50, .05), 0 4px 14px rgba(20, 30, 50, .05);
	--radius: 12px;
	--font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
	--content-width: 1180px;
}

:root[data-theme="dark"] {
	--bg: #14181f;
	--surface: #1c222c;
	--surface-2: #252c38;
	--text: #d8dde6;
	--text-muted: #98a2b3;
	--border: #2f3744;
	--accent: #7aa2f7;
	--accent-hover: #9dbbff;
	--accent-soft: #26324a;
	--code-bg: #252c38;
	--code-text: #f2a0c0;
	--pre-bg: #10141a;
	--pre-text: #d8dde6;
	--shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-body);
	font-size: 17px;
	line-height: 1.7;
	transition: background-color .25s ease, color .25s ease;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

h1, h2, h3, h4, h5, h6 { line-height: 1.3; margin: 1.6em 0 .6em; color: var(--text); }
h1 { font-size: 2rem; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.28rem; }

p { margin: 0 0 1.2em; }

blockquote {
	margin: 1.5em 0;
	padding: .6em 1.2em;
	border-left: 4px solid var(--accent);
	background: var(--accent-soft);
	border-radius: 0 var(--radius) var(--radius) 0;
	color: var(--text);
}

code, kbd, samp {
	font-family: var(--font-mono);
	font-size: .88em;
	background: var(--code-bg);
	color: var(--code-text);
	padding: .15em .4em;
	border-radius: 5px;
}

pre {
	background: var(--pre-bg);
	color: var(--pre-text);
	padding: 1.1em 1.3em;
	border-radius: var(--radius);
	overflow-x: auto;
	font-size: .9rem;
	line-height: 1.6;
	border: 1px solid var(--border);
}
pre code { background: none; color: inherit; padding: 0; }

table { border-collapse: collapse; width: 100%; margin-bottom: 1.4em; }
th, td { border: 1px solid var(--border); padding: .55em .8em; text-align: left; }
th { background: var(--surface-2); }

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

.screen-reader-text {
	border: 0; clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%);
	height: 1px; width: 1px; margin: -1px; overflow: hidden; padding: 0;
	position: absolute !important; word-wrap: normal !important;
}
.skip-link:focus {
	clip: auto; clip-path: none; height: auto; width: auto; background: var(--surface);
	padding: .8em 1.2em; z-index: 1000; top: 8px; left: 8px; border-radius: 6px;
}

.alignleft { float: left; margin: 0 1.5em 1em 0; }
.alignright { float: right; margin: 0 0 1em 1.5em; }
.aligncenter { display: block; margin-left: auto; margin-right: auto; }
.wp-caption { max-width: 100%; }
.wp-caption-text, figcaption { font-size: .85rem; color: var(--text-muted); text-align: center; }
.sticky .entry-title::before { content: "\1F4CC "; }
.bypostauthor { display: block; }
.gallery-caption { display: block; }

/* ==========================================================================
   3. Layout
   ========================================================================== */
.container { width: 100%; max-width: var(--content-width); margin: 0 auto; padding: 0 20px; }

.site-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 320px;
	gap: 32px;
	padding: 36px 0 60px;
	align-items: start;
}

/* ==========================================================================
   4. Header
   ========================================================================== */
.site-header {
	position: sticky;
	top: 0;
	z-index: 100;
	background: color-mix(in srgb, var(--surface) 92%, transparent);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--border);
}
.admin-bar .site-header { top: 32px; }
@media (max-width: 782px) { .admin-bar .site-header { top: 46px; } }

.header-inner { display: flex; align-items: center; gap: 18px; min-height: 66px; }

.site-branding { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.site-branding img { max-height: 40px; width: auto; }
.site-title { margin: 0; font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; }
.site-title a { color: var(--text); }
.site-title a:hover { text-decoration: none; color: var(--accent); }
.site-description { margin: 0; font-size: .78rem; color: var(--text-muted); line-height: 1.2; }

.main-navigation ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; }
.main-navigation a {
	display: block; padding: .45em .85em; border-radius: 8px;
	color: var(--text); font-size: .95rem; font-weight: 500;
}
.main-navigation a:hover,
.main-navigation .current-menu-item > a,
.main-navigation .current_page_item > a {
	background: var(--accent-soft); color: var(--accent); text-decoration: none;
}
.main-navigation li { position: relative; }
.main-navigation ul ul {
	display: none; position: absolute; top: 100%; left: 0; min-width: 200px;
	flex-direction: column; background: var(--surface); border: 1px solid var(--border);
	border-radius: 10px; padding: 6px; box-shadow: var(--shadow);
}
.main-navigation li:hover > ul,
.main-navigation li:focus-within > ul { display: flex; }

.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
	display: inline-flex; align-items: center; justify-content: center;
	width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
	background: var(--surface); color: var(--text); cursor: pointer;
	transition: background-color .2s, border-color .2s;
}
.icon-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.menu-toggle { display: none; }

/* Search drawer in header */
.header-search {
	display: none;
	border-top: 1px solid var(--border);
	background: var(--surface);
	padding: 14px 0;
}
.header-search.is-open { display: block; }

/* ==========================================================================
   5. Search form
   ========================================================================== */
.search-form { display: flex; gap: 8px; width: 100%; }
.search-form label { flex: 1; margin: 0; }
.search-field {
	width: 100%; padding: .65em .9em; font: inherit; font-size: .95rem;
	background: var(--surface-2); color: var(--text);
	border: 1px solid var(--border); border-radius: 10px;
}
.search-field::placeholder { color: var(--text-muted); }
.search-submit {
	padding: .65em 1.1em; font: inherit; font-weight: 600; font-size: .95rem;
	background: var(--accent); color: #fff; border: 0; border-radius: 10px; cursor: pointer;
}
:root[data-theme="dark"] .search-submit { color: #0f1420; }
.search-submit:hover { background: var(--accent-hover); }

/* ==========================================================================
   6. Posts
   ========================================================================== */
.post-card, .entry, .page-header, .no-results, .comments-area {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

.post-card { margin-bottom: 26px; overflow: hidden; transition: transform .2s ease, border-color .2s ease; }
.post-card:hover { transform: translateY(-2px); border-color: var(--accent); }

.post-thumb { display: block; aspect-ratio: 16 / 7; overflow: hidden; background: var(--surface-2); }
.post-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.post-card-body { padding: 24px 28px 26px; }

.entry-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .84rem; color: var(--text-muted); margin-bottom: .6em; }
.entry-meta a { color: var(--text-muted); }
.entry-meta a:hover { color: var(--accent); }

.entry-title { margin: 0 0 .5em; font-size: 1.55rem; letter-spacing: -.01em; }
.entry-title a { color: var(--text); }
.entry-title a:hover { color: var(--accent); text-decoration: none; }

.entry-summary p:last-child { margin-bottom: 0; }

.cat-links a {
	display: inline-block; background: var(--accent-soft); color: var(--accent);
	padding: .1em .65em; border-radius: 999px; font-size: .78rem; font-weight: 600; margin-right: 6px;
}
.cat-links a:hover { text-decoration: none; background: var(--accent); color: #fff; }

.read-more {
	display: inline-block; margin-top: 1em; font-weight: 600; font-size: .92rem;
}

.entry { padding: 34px 38px; }
.entry-header .entry-title { font-size: 2.1rem; }
.entry-featured { margin: 0 -38px 26px; }
.entry-featured img { width: 100%; display: block; }
.entry-content { font-size: 1.04rem; }
.entry-content img { border-radius: 8px; }
.entry-content h2, .entry-content h3 { scroll-margin-top: 90px; }
.entry-footer { margin-top: 2em; padding-top: 1.2em; border-top: 1px solid var(--border); font-size: .88rem; color: var(--text-muted); }
.tags-links a {
	display: inline-block; background: var(--surface-2); color: var(--text-muted);
	padding: .1em .65em; border-radius: 6px; margin: 0 6px 6px 0;
}
.tags-links a:hover { color: var(--accent); text-decoration: none; }

.page-header { padding: 22px 28px; margin-bottom: 26px; }
.page-title { margin: 0; font-size: 1.6rem; }
.archive-description { color: var(--text-muted); margin-top: .4em; }
.no-results { padding: 28px; }

/* Pagination */
.pagination, .post-navigation { margin: 30px 0 0; }
.nav-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }
.pagination .nav-links { justify-content: center; }
.page-numbers {
	display: inline-block; padding: .45em .9em; border: 1px solid var(--border);
	background: var(--surface); border-radius: 8px; color: var(--text); font-size: .92rem;
}
.page-numbers.current, .page-numbers:hover { background: var(--accent); border-color: var(--accent); color: #fff; text-decoration: none; }
.post-navigation .nav-links > div { flex: 1 1 45%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; }
.post-navigation .nav-next { text-align: right; }
.post-navigation .meta-nav { display: block; font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }

/* ==========================================================================
   7. Sidebar and widgets
   ========================================================================== */
.widget-area { display: flex; flex-direction: column; gap: 22px; }
@media (min-width: 901px) {
	.widget-area { position: sticky; top: 90px; }
	.admin-bar .widget-area { top: 122px; }
}

.widget {
	background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow);
	font-size: .94rem; overflow-wrap: anywhere;
}
.widget-title, .widget .wp-block-heading, .widget h2 {
	margin: 0 0 .8em; font-size: .78rem; text-transform: uppercase;
	letter-spacing: .09em; color: var(--text-muted); font-weight: 700;
	padding-bottom: .7em; border-bottom: 1px solid var(--border);
}
.widget ul { list-style: none; margin: 0; padding: 0; }
.widget li { padding: .42em 0; border-bottom: 1px dashed var(--border); line-height: 1.45; }
.widget li:last-child { border-bottom: 0; padding-bottom: 0; }
.widget li:first-child { padding-top: 0; }
.widget li > ul { margin-top: .4em; padding-left: 14px; }
.widget .post-date, .widget .rpwe-time { display: block; font-size: .78rem; color: var(--text-muted); }
.widget .comment-author-link, .widget .wp-block-latest-comments__comment-author { font-weight: 600; }
.widget .wp-block-latest-comments { padding: 0; margin: 0; }
.widget .wp-block-latest-comments__comment { margin-bottom: .7em; }
.widget select { width: 100%; padding: .55em; font: inherit; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; }
.widget .tagcloud a, .widget .wp-block-tag-cloud a {
	display: inline-block; background: var(--surface-2); color: var(--text-muted);
	padding: .15em .65em; margin: 0 4px 6px 0; border-radius: 6px; font-size: .84rem !important;
}
.widget .tagcloud a:hover, .widget .wp-block-tag-cloud a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

/* Calendar: days with posts are highlighted */
.widget_calendar table, .wp-block-calendar table, #wp-calendar { width: 100%; margin: 0; table-layout: fixed; font-size: .86rem; }
#wp-calendar caption { caption-side: top; font-weight: 700; text-align: center; padding-bottom: .6em; color: var(--text); }
#wp-calendar th, #wp-calendar td { border: 0; padding: 0; text-align: center; background: transparent; }
#wp-calendar th { font-size: .72rem; text-transform: uppercase; color: var(--text-muted); padding-bottom: .4em; }
#wp-calendar td { height: 34px; color: var(--text); }
#wp-calendar td a {
	display: flex; align-items: center; justify-content: center;
	width: 30px; height: 30px; margin: 2px auto;
	background: var(--accent); color: #fff; border-radius: 50%;
	font-weight: 700; position: relative;
	box-shadow: 0 0 0 3px var(--accent-soft);
	transition: transform .15s ease;
}
:root[data-theme="dark"] #wp-calendar td a { color: #0f1420; }
#wp-calendar td a:hover { transform: scale(1.12); text-decoration: none; }
#wp-calendar td#today { font-weight: 700; color: var(--accent); }
#wp-calendar td#today:not(:has(a)) { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 50%; }
#wp-calendar td.pad { background: transparent; }
#wp-calendar tfoot td { height: auto; padding-top: .7em; font-size: .82rem; }
#wp-calendar tfoot td#next { text-align: right; }
#wp-calendar tfoot td#prev { text-align: left; }
#wp-calendar tfoot td.pad { display: none; }

/* ==========================================================================
   8. Comments
   ========================================================================== */
.comments-area { margin-top: 28px; padding: 28px 34px; }
.comments-title, .comment-reply-title { margin-top: 0; font-size: 1.3rem; }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-list .children { list-style: none; padding-left: 28px; }
.comment-body { padding: 16px 0; border-bottom: 1px solid var(--border); }
.comment-meta { display: flex; align-items: center; gap: 10px; font-size: .86rem; color: var(--text-muted); flex-wrap: wrap; }
.comment-meta .avatar { border-radius: 50%; }
.comment-author .fn { font-weight: 700; color: var(--text); font-style: normal; }
.comment-metadata a { color: var(--text-muted); }
.reply a { font-size: .84rem; font-weight: 600; }
.comment-respond label { display: block; font-size: .88rem; margin-bottom: .25em; font-weight: 600; }
.comment-respond input[type="text"], .comment-respond input[type="email"], .comment-respond input[type="url"], .comment-respond textarea {
	width: 100%; padding: .65em .85em; font: inherit; background: var(--surface-2);
	color: var(--text); border: 1px solid var(--border); border-radius: 10px;
}
.comment-respond textarea { min-height: 140px; resize: vertical; }
.form-submit input[type="submit"] {
	padding: .7em 1.4em; font: inherit; font-weight: 600; cursor: pointer;
	background: var(--accent); color: #fff; border: 0; border-radius: 10px;
}
:root[data-theme="dark"] .form-submit input[type="submit"] { color: #0f1420; }
.form-submit input[type="submit"]:hover { background: var(--accent-hover); }

/* ==========================================================================
   9. Footer
   ========================================================================== */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 28px 0; color: var(--text-muted); font-size: .88rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.footer-navigation ul { list-style: none; display: flex; gap: 16px; margin: 0; padding: 0; flex-wrap: wrap; }

.back-to-top {
	position: fixed; right: 20px; bottom: 20px; opacity: 0; visibility: hidden;
	transition: opacity .2s; z-index: 90; box-shadow: var(--shadow);
}
.back-to-top.is-visible { opacity: 1; visibility: visible; }

/* ==========================================================================
   10. Responsive
   ========================================================================== */
@media (max-width: 900px) {
	.site-layout { grid-template-columns: minmax(0, 1fr); }
	.menu-toggle { display: inline-flex; }
	.main-navigation {
		display: none; position: absolute; top: 100%; left: 0; right: 0;
		background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 20px 16px;
	}
	.main-navigation.is-open { display: block; }
	.main-navigation ul { flex-direction: column; }
	.main-navigation ul ul { display: flex; position: static; border: 0; box-shadow: none; padding: 0 0 0 14px; }
}

@media (max-width: 600px) {
	body { font-size: 16px; }
	.post-card-body { padding: 18px 20px 20px; }
	.entry { padding: 22px 20px; }
	.entry-featured { margin: 0 -20px 20px; }
	.entry-header .entry-title { font-size: 1.65rem; }
	.entry-title { font-size: 1.3rem; }
	.comments-area { padding: 20px; }
	.site-description { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	* { transition: none !important; scroll-behavior: auto !important; }
}
