/*
Theme Name: D-Star Thailand
Theme URI: https://www.dstarthailand.com
Author: E21DDP
Author URI: https://www.dstarthailand.com
Description: ธีมเรียบง่าย โทนสีสบายตา สำหรับเว็บแบ่งปันความรู้วิทยุสื่อสาร (D-STAR, DMR, AllStarLink, EchoLink) อ่านภาษาไทยได้ง่าย รองรับโค้ด ตาราง และโหมดมืดอัตโนมัติ
Version: 1.3.1
Requires at least: 6.0
Tested up to: 7.0
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: dstarthailand
Tags: blog, two-columns, right-sidebar, custom-logo, custom-menu, featured-images, threaded-comments, translation-ready
*/

/* ---------- Tokens ---------- */
:root {
	--bg: #f6f5f1;
	--surface: #ffffff;
	--text: #2d3236;
	--muted: #6b7378;
	--border: #e3e1da;
	--accent: #2f6b85;        /* ฟ้าอมเทา นุ่มตา */
	--accent-soft: #e6eef2;
	--accent-2: #5f8a5a;      /* เขียวหม่น ใช้กับป้าย */
	--code-bg: #f0efea;
	--radius: 8px;
	--maxw: 1140px;
	--font: "Sarabun", "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
	--mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #1b1f22;
		--surface: #22272b;
		--text: #d9dcde;
		--muted: #9aa3a8;
		--border: #343b40;
		--accent: #7fb0c8;
		--accent-soft: #263239;
		--accent-2: #94b98f;
		--code-bg: #1a1e21;
	}
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: 17px;
	line-height: 1.8;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover, a:focus { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { line-height: 1.4; margin: 1.6em 0 .6em; font-weight: 600; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.25rem; } h4 { font-size: 1.1rem; }
p { margin: 0 0 1.1em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
blockquote {
	margin: 1.5em 0; padding: .8em 1.2em;
	border-left: 4px solid var(--accent);
	background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0;
}
code, kbd, pre { font-family: var(--mono); font-size: .9em; }
:not(pre) > code { background: var(--code-bg); padding: .1em .4em; border-radius: 4px; }
pre {
	background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius);
	padding: 1em 1.2em; overflow-x: auto; line-height: 1.6;
}
table { width: 100%; border-collapse: collapse; margin: 1.5em 0; font-size: .95em; }
th, td { border: 1px solid var(--border); padding: .55em .75em; text-align: left; vertical-align: top; }
th { background: var(--accent-soft); font-weight: 600; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.screen-reader-text {
	position: absolute !important; clip: rect(1px,1px,1px,1px); width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus {
	position: fixed; top: 8px; left: 8px; z-index: 999; clip: auto; width: auto; height: auto;
	background: var(--surface); padding: .5em 1em; border-radius: var(--radius);
}
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ---------- Top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); font-size: .85rem; color: var(--muted); }
.topbar .container { display: flex; justify-content: space-between; align-items: center; gap: 1em; min-height: 34px; flex-wrap: wrap; }
.topbar a { color: var(--muted); }
.topbar a:hover { color: var(--accent); }
.social-links { display: flex; gap: 1em; list-style: none; margin: 0; padding: 0; }

/* ---------- Header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 1.5em; min-height: 72px; flex-wrap: wrap; }
.site-branding { display: flex; align-items: center; gap: .8em; }
.site-branding .custom-logo { max-height: 50px; width: auto; display: block; }
.site-logo { display: block; line-height: 0; }
.site-logo svg { height: 58px; width: auto; display: block; }
@media (max-width: 760px) { .site-logo svg { height: 44px; } }
.site-title { margin: 0; font-size: 1.3rem; font-weight: 700; line-height: 1.2; }
.site-title a { color: var(--text); }
.site-description { margin: 0; font-size: .85rem; color: var(--muted); }

.main-navigation ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .2em; }
.main-navigation li { position: relative; }
.main-navigation a {
	display: block; padding: .45em .8em; color: var(--text); border-radius: 6px; 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 ul ul {
	display: none; position: absolute; top: 100%; left: 0; z-index: 50; min-width: 200px;
	flex-direction: column; background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius); padding: .3em; box-shadow: 0 6px 18px rgba(0,0,0,.06);
}
.main-navigation li:hover > ul,
.main-navigation li:focus-within > ul { display: flex; }
.menu-toggle {
	display: none; background: none; border: 1px solid var(--border); color: var(--text);
	border-radius: 6px; padding: .4em .8em; font: inherit; cursor: pointer;
}

/* ---------- Layout ---------- */
.site-content { padding: 2rem 0 3rem; }
.content-area { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 2rem; }
.no-sidebar .content-area { grid-template-columns: minmax(0, 1fr); }
.no-sidebar .site-main { max-width: none; width: 100%; }
.full-width .site-main { max-width: none; }

.card {
	background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}

/* ---------- Page header (archive/search) ---------- */
.page-header { margin-bottom: 1.5rem; }
.page-title { margin: 0 0 .3em; font-size: 1.5rem; }
.archive-description { color: var(--muted); }

/* ---------- Post list ---------- */
.post-list { display: flex; flex-direction: column; gap: 1.2rem; }
.post-item { display: grid; grid-template-columns: 220px 1fr; gap: 1.2rem; padding: 1.1rem; }
.post-item.no-thumb { grid-template-columns: 1fr; }
.post-item .thumb { display: block; border-radius: 6px; overflow: hidden; aspect-ratio: 16 / 10; background: var(--accent-soft); }
.post-item .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-item .entry-title { font-size: 1.2rem; margin: .2em 0 .3em; }
.post-item .entry-title a { color: var(--text); }
.post-item .entry-title a:hover { color: var(--accent); text-decoration: none; }
.post-item .entry-summary { color: var(--muted); font-size: .95rem; }
.post-item .entry-summary p { margin: 0; }

.cat-links { display: flex; flex-wrap: wrap; gap: .35em; font-size: .78rem; }
.cat-links a {
	background: var(--accent-soft); color: var(--accent); padding: .1em .6em; border-radius: 999px; font-weight: 500;
}
.cat-links a:hover { text-decoration: none; filter: brightness(.95); }
.entry-meta { font-size: .85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .3em .9em; }
.entry-meta a { color: var(--muted); }

/* ---------- Single ---------- */
.single-article { padding: 1.8rem 2rem; }
.single-article .entry-header { margin-bottom: 1.4rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.single-article .entry-title { margin: .4em 0 .4em; font-size: 1.85rem; }
.single-article .post-thumbnail { margin: 0 0 1.5rem; }
.single-article .post-thumbnail img { border-radius: var(--radius); width: 100%; }
.entry-content > *:first-child { margin-top: 0; }
.entry-content img { border-radius: 6px; }
.entry-content figure { margin: 1.5em 0; }
.entry-content figcaption, .wp-caption-text { font-size: .85rem; color: var(--muted); text-align: center; margin-top: .4em; }
.entry-content .table-wrap, .entry-content .wp-block-table { overflow-x: auto; }
.alignleft { float: left; margin: .3em 1.5em 1em 0; }
.alignright { float: right; margin: .3em 0 1em 1.5em; }
.aligncenter { display: block; margin-left: auto; margin-right: auto; }
.alignwide, .alignfull { width: 100%; }
.sticky .post-item, .post-item.sticky { border-left: 4px solid var(--accent); }

.entry-footer { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: .9rem; color: var(--muted); }
.tag-links a { display: inline-block; margin: 0 .3em .3em 0; padding: .05em .55em; border: 1px solid var(--border); border-radius: 4px; color: var(--muted); font-size: .85rem; }

.post-navigation { margin-top: 1.5rem; }
.post-navigation .nav-links { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.post-navigation a { display: block; padding: .9rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.post-navigation a:hover { border-color: var(--accent); text-decoration: none; }
.post-navigation .meta-nav { display: block; font-size: .8rem; color: var(--muted); }
.post-navigation .nav-next { text-align: right; }

.breadcrumbs { font-size: .85rem; color: var(--muted); margin-bottom: 1rem; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs .sep { margin: 0 .4em; opacity: .6; }

/* ---------- Pagination ---------- */
.pagination { margin-top: 2rem; }
.pagination .nav-links { display: flex; flex-wrap: wrap; gap: .4em; justify-content: center; }
.page-numbers {
	display: inline-block; min-width: 2.4em; padding: .35em .75em; text-align: center;
	background: var(--surface); border: 1px solid var(--border); border-radius: 6px; color: var(--text);
}
.page-numbers.current { background: var(--accent); border-color: var(--accent); color: #fff; }
a.page-numbers:hover { border-color: var(--accent); text-decoration: none; }

/* ---------- Sidebar / widgets ---------- */
.widget-area .widget { padding: 1.1rem 1.2rem; margin-bottom: 1.2rem; font-size: .95rem; }
.widget-title, .widget .wp-block-heading {
	font-size: 1rem; margin: 0 0 .7em; padding-bottom: .5em; border-bottom: 2px solid var(--accent-soft);
}
.widget ul { list-style: none; margin: 0; padding: 0; }
.widget li { padding: .35em 0; border-bottom: 1px dashed var(--border); }
.widget li:last-child { border-bottom: 0; }
.widget li a { color: var(--text); }
.widget li a:hover { color: var(--accent); }
.widget ul ul { padding-left: 1em; margin-top: .3em; }

/* Search form */
.search-form { display: flex; gap: .4em; }
.search-field, input[type="text"], input[type="email"], input[type="url"], input[type="search"], textarea {
	width: 100%; padding: .55em .75em; font: inherit; color: var(--text);
	background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
}
.search-field:focus, input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
button, .button, input[type="submit"], .search-submit {
	padding: .55em 1em; font: inherit; font-weight: 500; cursor: pointer;
	background: var(--accent); color: #fff; border: 0; border-radius: 6px;
}
button:hover, input[type="submit"]:hover { filter: brightness(1.08); }

/* ---------- Comments ---------- */
.comments-area { margin-top: 1.5rem; padding: 1.5rem 2rem; }
.comment-list { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.comment-list .children { list-style: none; padding-left: 1.5rem; }
.comment-body { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.comment-author { font-weight: 600; }
.comment-author .avatar { border-radius: 50%; vertical-align: middle; margin-right: .5em; }
.comment-metadata { font-size: .8rem; }
.comment-metadata a { color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); color: var(--muted); font-size: .9rem; }
.footer-widgets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; padding: 2rem 0 1rem; }
.footer-widgets .widget-title { color: var(--text); }
.site-info { padding: 1rem 0; border-top: 1px solid var(--border); display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5em; }
.site-info a { color: var(--muted); }
.footer-menu { list-style: none; display: flex; gap: 1em; margin: 0; padding: 0; flex-wrap: wrap; }

/* ---------- หน้าแรก: เมนูซ้าย 20% + บทความ 2 คอลัมน์ 40% / 40% ---------- */
.home-layout .content-area { grid-template-columns: minmax(0, 25%) minmax(0, 1fr); gap: 1.5rem; }
.home-left { position: sticky; top: 1rem; align-self: start; }
.home-left .widget { padding: 1rem; margin-bottom: 1rem; font-size: .95rem; }
.side-menu-list { list-style: none; margin: 0; padding: 0; }
.home-left, .home-left .widget { text-align: left; }
.side-menu-list li {
	display: flex; flex-wrap: wrap; align-items: center; padding: 0; border: 0; margin: 0;
}
.side-menu-list a {
	flex: 1 1 auto; display: block; padding: .4em .5em; border-radius: 6px; color: var(--text);
}
.side-menu-list .count {
	flex: 0 0 auto; margin-left: .4em; min-width: 1.8em; padding: 0 .45em; text-align: center;
	font-size: .78rem; line-height: 1.6; color: var(--muted);
	background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
}
.side-menu-list li > ul { flex: 0 0 100%; }
.side-menu-list a:hover,
.side-menu-list .current-menu-item > a,
.side-menu-list .current-cat > a { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.side-menu-list ul { list-style: none; padding-left: .8em; margin: 0; }
.home-left .search-form { flex-direction: column; }

.post-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }
.post-grid .post-item { grid-template-columns: 1fr; align-content: start; gap: .8rem; }
.post-grid .post-item .entry-title { font-size: 1.1rem; }

/* ซ่อนฟอร์ม Newsletter ที่ปลั๊กอินแทรกเข้ามาในหน้าแรก */
.home-layout .widget_mc4wp_form_widget,
.home-layout .mc4wp-form,
.home-layout .mailpoet_form,
.home-layout .tnp,
.home-layout .tnp-subscription,
.home-layout .widget_newsletterwidget,
.home-layout .wp-block-jetpack-subscriptions,
.home-layout .newsletter,
.home-layout [class*="newsletter"] { display: none !important; }

/* ---------- 404 / none ---------- */
.not-found { padding: 2rem; text-align: center; }
.not-found .search-form { max-width: 420px; margin: 1rem auto 0; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
	.content-area { grid-template-columns: minmax(0, 1fr); }
	.home-layout .content-area { grid-template-columns: minmax(0, 1fr); }
	.home-left { position: static; }
	.footer-widgets { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
	.post-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
	body { font-size: 16px; }
	.menu-toggle { display: inline-block; }
	.main-navigation { width: 100%; }
	.main-navigation > div > ul,
	.main-navigation > ul { display: none; flex-direction: column; padding-bottom: .8em; }
	.main-navigation.toggled > div > ul,
	.main-navigation.toggled > ul { display: flex; }
	.main-navigation ul ul { display: flex; position: static; border: 0; box-shadow: none; padding-left: 1em; }
	.site-header .container { padding-top: .6em; padding-bottom: .6em; }
	.post-item { grid-template-columns: 1fr; }
	.single-article, .comments-area { padding: 1.2rem; }
	.single-article .entry-title { font-size: 1.5rem; }
	.post-navigation .nav-links { grid-template-columns: 1fr; }
	.footer-widgets { grid-template-columns: 1fr; }
}

/* กันกรณีปลั๊กอินส่งหมวดหมู่มาเป็น <ul> */
.cat-links ul, .cat-links .post-categories { display: flex; flex-wrap: wrap; gap: .35em; list-style: none; margin: 0; padding: 0; }
