/*
Theme Name: Lantern
Author: หมาซอยปลอดภัย
Description: A warm, easy-to-scan classic blog theme with a card grid post list, a right sidebar, an expandable header search panel, and a grouped multi-column footer.
Version: 2.4.6
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/

/* ------------------------------------------------------------------
   Base tokens
------------------------------------------------------------------ */
:root {
	--bg: #f6f1e4;
	--fg: #2c2924;
	--muted: #7d7466;
	--border: #ddd2bc;
	--radius: 10px;
	--shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
	--accent: #c99a2e;
	--accent-dark: #a37c1d;
	--surface: #fdfaf3;
	--sidebar-w: 320px;
	--gap: 28px;
	--media-ratio: 16 / 9;
	--thumb-ratio: 16 / 9;
}

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

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

body {
	margin: 0;
	background-color: var(--bg);
	background-image: radial-gradient(rgba(44, 41, 36, 0.05) 1px, transparent 1px);
	background-size: 9px 9px;
	color: var(--fg);
	font-family: 'Kanit', system-ui, sans-serif;
	font-size: 16px;
	line-height: 1.75;
	overflow-wrap: break-word;
}

img {
	max-width: 100%;
	height: auto;
	display: block;
}

a {
	color: var(--fg);
	text-decoration-color: var(--accent);
	text-underline-offset: 3px;
	transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

a:hover,
a:focus {
	color: var(--accent-dark);
}

h1, h2, h3, h4, h5, h6 {
	line-height: 1.35;
	font-weight: 700;
	margin: 0 0 0.6em;
}

p {
	margin: 0 0 1.2em;
}

ul, ol {
	margin: 0 0 1.2em;
	padding-left: 1.4em;
}

blockquote {
	margin: 0 0 1.2em;
	padding: 0.4em 1.2em;
	border-left: 3px solid var(--accent);
	background: var(--surface);
	border-radius: 0 var(--radius) var(--radius) 0;
	color: var(--muted);
}

table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 1.2em;
}

th, td {
	border: 1px solid var(--border);
	padding: 0.5em 0.8em;
	text-align: left;
}

.table-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin-bottom: 1.2em;
	border-radius: var(--radius);
}

.table-scroll table {
	margin-bottom: 0;
}

input[type="text"],
input[type="search"],
input[type="email"],
input[type="url"],
textarea {
	width: 100%;
	padding: 0.55em 0.9em;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--fg);
	font: inherit;
}

input:focus,
textarea:focus {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
	border-color: var(--accent);
}

button,
input[type="submit"] {
	font: inherit;
	cursor: pointer;
}

/* ------------------------------------------------------------------
   Utility classes
------------------------------------------------------------------ */
.u-wrap {
	max-width: 1180px;
	margin-left: auto;
	margin-right: auto;
	padding-left: 20px;
	padding-right: 20px;
}

.u-flex {
	display: flex;
	align-items: center;
}

.u-flex-between {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

.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;
}

.screen-reader-text:focus {
	position: fixed !important;
	top: 10px;
	left: 10px;
	width: auto;
	height: auto;
	clip: auto;
	padding: 0.6em 1em;
	background: var(--fg);
	color: var(--bg);
	border-radius: var(--radius);
	z-index: 1000;
}

/* Buttons — filled, rounded, high contrast */
.btn,
.search-submit,
input[type="submit"],
.comment-form .submit {
	display: inline-block;
	padding: 0.55em 1.4em;
	background: var(--accent);
	color: var(--fg);
	border: 1px solid var(--fg);
	border-radius: var(--radius);
	font-weight: 600;
	text-decoration: none;
	line-height: 1.4;
}

.btn:hover,
.btn:focus,
.search-submit:hover,
.search-submit:focus,
input[type="submit"]:hover,
input[type="submit"]:focus,
.comment-form .submit:hover,
.comment-form .submit:focus {
	background: var(--accent-dark);
	border-color: var(--fg);
	color: var(--bg);
}

/* ------------------------------------------------------------------
   Header — logo left, menu right, not sticky
------------------------------------------------------------------ */
.site-header {
	background: var(--surface);
	border-bottom: 2px solid var(--fg);
	box-shadow: var(--shadow);
	position: relative;
	z-index: 100;
}

.header-inner {
	min-height: 64px;
}

.site-branding a {
	font-size: 1.45rem;
	font-weight: 700;
	text-decoration: none;
	letter-spacing: 0.01em;
}

.site-branding a::after {
	content: "";
	display: block;
	height: 3px;
	width: 42%;
	margin-top: 2px;
	background: var(--accent);
	border-radius: 2px;
}

.main-nav {
	margin-left: auto;
}

.main-nav ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.main-nav > ul {
	display: flex;
	align-items: center;
	gap: 4px;
}

.main-nav li {
	position: relative;
}

.main-nav a {
	display: block;
	padding: 0.55em 0.85em;
	text-decoration: none;
	font-weight: 500;
	border-radius: var(--radius);
}

.main-nav a:hover,
.main-nav a:focus {
	background: var(--bg);
	color: var(--accent-dark);
}

.main-nav .menu-item-has-children > a::after {
	content: "▾";
	margin-left: 6px;
	font-size: 0.75em;
	color: var(--muted);
}

.main-nav .sub-menu {
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 260px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-top: 3px solid var(--accent);
	border-radius: 0 0 var(--radius) var(--radius);
	box-shadow: var(--shadow);
	opacity: 0;
	visibility: hidden;
	transform: translateY(4px);
	transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
	z-index: 200;
}

.main-nav .sub-menu a {
	border-radius: 0;
	font-weight: 400;
	padding: 0.5em 1em;
}

.main-nav li:hover > .sub-menu,
.main-nav li:focus-within > .sub-menu,
.main-nav li.menu-open > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

/* Search icon button + expandable panel */
.header-actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	color: var(--fg);
}

.icon-btn:hover,
.icon-btn:focus,
.icon-btn[aria-expanded="true"] {
	background: var(--accent);
	border-color: var(--fg);
	color: var(--fg);
}

.icon-btn svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
}

.nav-toggle {
	display: none;
}

.search-panel {
	display: none;
	border-top: 1px dashed var(--border);
	background: var(--bg);
	padding: 16px 0;
}

.search-panel.is-open {
	display: block;
}

.search-panel .search-form {
	max-width: 560px;
	margin: 0 auto;
}

/* Search form */
.search-form {
	display: flex;
	gap: 8px;
}

.search-form .search-field {
	flex: 1;
}

/* ------------------------------------------------------------------
   Layout — content left, sidebar right (320px)
------------------------------------------------------------------ */
.site-content {
	padding-top: 36px;
	padding-bottom: 48px;
}

.layout {
	display: flex;
	gap: var(--gap);
	align-items: flex-start;
}

.content-area {
	flex: 1 1 auto;
	min-width: 0;
}

.sidebar {
	flex: 0 0 var(--sidebar-w);
	width: var(--sidebar-w);
}

.side-block {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 20px;
	margin-bottom: var(--gap);
}

.side-block h2 {
	font-size: 1.05rem;
	margin-bottom: 0.7em;
	padding-bottom: 0.4em;
	border-bottom: 2px solid var(--accent);
	display: inline-block;
}

.side-block ul {
	list-style: none;
	padding: 0;
	margin: 0;
}

.side-block li {
	padding: 0.3em 0;
	border-bottom: 1px dashed var(--border);
}

.side-block li:last-child {
	border-bottom: 0;
}

.side-block a {
	text-decoration: none;
}

.side-block a:hover,
.side-block a:focus {
	color: var(--accent-dark);
	text-decoration: underline;
	text-decoration-color: var(--accent);
}

.side-block .search-form {
	flex-direction: column;
}

/* ------------------------------------------------------------------
   Hero — text only, centered
------------------------------------------------------------------ */
.hero {
	text-align: center;
	padding: 44px 20px 40px;
	margin-bottom: 36px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-top: 4px solid var(--accent);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

.hero-title {
	font-size: 2.1rem;
	margin-bottom: 0.3em;
}

.hero-text {
	max-width: 640px;
	margin: 0 auto;
	color: var(--muted);
	font-size: 1.05rem;
}

/* ------------------------------------------------------------------
   Archive header
------------------------------------------------------------------ */
.archive-header {
	margin-bottom: 28px;
	padding-bottom: 14px;
	border-bottom: 3px solid var(--accent);
}

.archive-header h1 {
	font-size: 1.7rem;
	margin-bottom: 0.15em;
}

.archive-header p {
	color: var(--muted);
	margin: 0;
}

/* ------------------------------------------------------------------
   Post list — card grid
------------------------------------------------------------------ */
.post-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: var(--gap);
}

.post-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	display: flex;
	flex-direction: column;
}

.post-card:hover {
	border-color: var(--accent);
}

.card-thumb {
	display: block;
	border-bottom: 1px solid var(--border);
	border-radius: calc( var(--radius) - 1px ) calc( var(--radius) - 1px ) 0 0;
	overflow: hidden;
}

.card-thumb img {
	width: 100%;
	aspect-ratio: var(--media-ratio);
	object-fit: cover;
}

.card-body {
	padding: 18px 20px 20px;
	display: flex;
	flex-direction: column;
	flex: 1;
}

.card-title {
	font-size: 1.2rem;
	margin-bottom: 0.3em;
}

.card-title a {
	text-decoration: none;
}

.card-meta {
	font-size: 0.85rem;
	color: var(--muted);
	margin-bottom: 0.7em;
}

.card-excerpt {
	color: var(--fg);
	flex: 1;
}

.card-excerpt p {
	margin-bottom: 0.9em;
}

/* ------------------------------------------------------------------
   Pagination
------------------------------------------------------------------ */
.pagination {
	margin-top: 36px;
}

.pagination .nav-links {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
}

.pagination .page-numbers {
	display: inline-block;
	padding: 0.4em 0.9em;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	text-decoration: none;
}

.pagination .page-numbers.current {
	background: var(--accent);
	border-color: var(--fg);
	font-weight: 700;
}

.pagination a.page-numbers:hover,
.pagination a.page-numbers:focus {
	border-color: var(--accent);
	color: var(--accent-dark);
}

/* ------------------------------------------------------------------
   Single post
------------------------------------------------------------------ */
.entry-header {
	margin-bottom: 20px;
}

.entry-title {
	font-size: 1.9rem;
	margin-bottom: 0.25em;
}

.entry-meta {
	color: var(--muted);
	font-size: 0.9rem;
	margin-bottom: 0;
}

.entry-meta a {
	font-weight: 500;
}

.entry-featured {
	margin: 0 0 24px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
	box-shadow: var(--shadow);
}

.entry-content {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 24px 28px;
	margin-bottom: 24px;
}

.entry-content h2 { font-size: 1.4rem; margin-top: 1.4em; }
.entry-content h3 { font-size: 1.2rem; margin-top: 1.3em; }

.entry-content a {
	color: var(--accent-dark);
	font-weight: 500;
}

/* Article note — after body, before tags */
.article-note {
	background: #f3e8c8;
	border: 1px dashed var(--accent-dark);
	border-radius: var(--radius);
	padding: 16px 20px;
	margin-bottom: 24px;
	font-size: 0.95rem;
}

.article-note p:last-child {
	margin-bottom: 0;
}

/* Tags */
.entry-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 28px;
}

.entry-tags a {
	display: inline-block;
	padding: 0.25em 0.9em;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 0.85rem;
	text-decoration: none;
}

.entry-tags a:hover,
.entry-tags a:focus {
	background: var(--accent);
	border-color: var(--fg);
	color: var(--fg);
}

/* Author bio — after tags, before related posts */
.author-bio {
	background: var(--surface);
	border: 1px solid var(--border);
	border-left: 4px solid var(--accent);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 20px 24px;
	margin-bottom: 32px;
}

.bio-name {
	font-size: 1.05rem;
	margin-bottom: 0.3em;
}

.author-bio p {
	color: var(--muted);
	margin-bottom: 0;
}

/* Related posts — 4 columns */
.related-posts {
	margin-bottom: 32px;
}

.related-title {
	font-size: 1.35rem;
	padding-bottom: 0.35em;
	border-bottom: 3px solid var(--accent);
	display: inline-block;
}

.related-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: var(--gap);
	margin-top: 20px;
}

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

.rel-card:hover {
	border-color: var(--accent);
}

.rel-card .card-thumb img {
	aspect-ratio: var(--thumb-ratio);
}

.rel-card h3 {
	font-size: 0.98rem;
	line-height: 1.45;
	padding: 12px 14px 14px;
	margin: 0;
}

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

/* ------------------------------------------------------------------
   Comments
------------------------------------------------------------------ */
.comments-area {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 24px 28px;
}

.comments-title {
	font-size: 1.3rem;
	border-bottom: 2px solid var(--accent);
	display: inline-block;
	padding-bottom: 0.3em;
}

.comment-list {
	list-style: none;
	padding: 0;
	margin: 0 0 1.5em;
}

.comment-list .comment {
	border-bottom: 1px dashed var(--border);
	padding: 1em 0;
}

.comment-list .children {
	list-style: none;
	padding-left: 1.6em;
}

.comment-author {
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: 600;
}

.comment-author .avatar {
	border-radius: 50%;
	border: 1px solid var(--border);
}

.comment-metadata {
	font-size: 0.8rem;
	color: var(--muted);
}

.comment-reply-link {
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--accent-dark);
}

.comment-respond {
	margin-top: 1.5em;
}

.comment-form label {
	display: block;
	font-weight: 500;
	margin-bottom: 0.25em;
}

.comment-form .comment-form-cookies-consent {
	display: flex;
	align-items: center;
	gap: 8px;
}

.comment-form .comment-form-cookies-consent input {
	width: auto;
}

.comment-form .comment-form-cookies-consent label {
	display: inline;
	font-weight: 400;
	margin: 0;
}

/* ------------------------------------------------------------------
   Footer — multi-column grid
------------------------------------------------------------------ */
.site-footer {
	background: var(--fg);
	color: #d8d2c4;
	margin-top: 12px;
	border-top: 4px solid var(--accent);
}

.footer-inner {
	padding-top: 44px;
	padding-bottom: 28px;
}

.f-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
	gap: var(--gap);
}

.f-brand-name {
	display: inline-block;
	font-size: 1.3rem;
	font-weight: 700;
	color: var(--bg);
	text-decoration: none;
}

.f-brand-name::after {
	content: "";
	display: block;
	height: 3px;
	width: 42%;
	margin-top: 2px;
	background: var(--accent);
	border-radius: 2px;
}

.f-col-title-link {
	color: var(--bg);
	text-decoration: none;
}

.f-col-title-link:hover,
.f-col-title-link:focus {
	color: var(--accent);
}

.f-col-title {
	display: block;
	font-size: 1rem;
	font-weight: 700;
	color: var(--bg);
	margin-bottom: 1em;
	padding-bottom: 0.55em;
	border-bottom: 2px solid var(--accent);
}

.f-col-list {
	list-style: none;
	padding: 0;
	margin: 0;
}

.f-col-list li {
	margin-bottom: 0.45em;
}

.f-col-list a {
	color: #d8d2c4;
	text-decoration: none;
	font-size: 0.95rem;
}

.f-col-list a:hover,
.f-col-list a:focus {
	color: var(--accent);
}

.footer-note {
	margin: 32px 0 0;
	padding-top: 16px;
	border-top: 1px solid rgba(216, 210, 196, 0.25);
	font-size: 0.85rem;
	color: rgba(216, 210, 196, 0.7);
}

.copyright {
	margin: 10px 0 0;
	font-size: 0.85rem;
	color: rgba(216, 210, 196, 0.7);
}

/* ------------------------------------------------------------------
   404 / no results
------------------------------------------------------------------ */
.not-found-panel {
	text-align: center;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 48px 24px;
}

.not-found-panel h1 {
	font-size: 1.8rem;
}

.not-found-panel .search-form {
	max-width: 480px;
	margin: 24px auto 0;
}

/* ------------------------------------------------------------------
   Responsive
------------------------------------------------------------------ */
@media (max-width: 1020px) {
	.post-grid {
		grid-template-columns: repeat(2, 1fr);
	}

	.related-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 860px) {
	.layout {
		flex-direction: column;
	}

	.sidebar {
		flex: none;
		width: 100%;
	}

	.header-inner {
		flex-wrap: wrap;
		padding-top: 10px;
		padding-bottom: 10px;
	}

	.nav-toggle {
		display: inline-flex;
	}

	.header-actions {
		margin-left: auto;
	}

	.main-nav {
		display: none;
		flex-basis: 100%;
		order: 3;
		margin-left: 0;
		padding-top: 10px;
	}

	.main-nav.is-open {
		display: block;
	}

	.main-nav > ul {
		flex-direction: column;
		align-items: stretch;
	}

	.main-nav .sub-menu {
		position: static;
		opacity: 1;
		visibility: visible;
		transform: none;
		box-shadow: none;
		border: 0;
		border-left: 3px solid var(--accent);
		border-radius: 0;
		margin-left: 14px;
		display: none;
	}

	.main-nav li.menu-open > .sub-menu,
	.main-nav li:focus-within > .sub-menu,
	.main-nav li:hover > .sub-menu {
		display: block;
	}
}

@media (max-width: 560px) {
	.post-grid,
	.related-grid {
		grid-template-columns: 1fr;
	}

	.entry-content,
	.comments-area {
		padding: 18px 20px;
	}

	.entry-title {
		font-size: 1.55rem;
	}

	.hero-title {
		font-size: 1.6rem;
	}
}
