/*
Theme Name: Klaluay News
Theme URI: https://www.klaluay-news.com
Author: กล้าลุยนิวส์
Description: ธีมสำนักข่าวสำหรับ klaluay-news.com หน้าแรกจัดข่าวอัตโนมัติจากหมวดที่มีข่าวมากที่สุด รองรับฟีด TikTok และโพสต์อัตโนมัติจาก Facebook
Version: 1.2.1
Requires at least: 6.0
Requires PHP: 7.4
License: GPL-2.0-or-later
Text Domain: klaluay
*/

/* Layout: utility bar / white masthead with logo / sticky pink nav, then 6-3-3 hero, paired category blocks, deep-pink clip band, 4-up rows */
:root {
	--bg: #FBF6F8; --surface: #FFFFFF; --ink: #24141B; --muted: #6B5761; --line: #F0DEE6;
	--brand: #A8124F; --brand-deep: #730C37; --on-brand: #FFFFFF;
	--accent: #F9CADC; --on-accent: #5A0828; --cat: #A8124F; --navy: #1F3A8A;
	--serif: "IBM Plex Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
	--sans: "IBM Plex Sans Thai", "Leelawadee UI", "Segoe UI", Tahoma, sans-serif;
	color-scheme: light; /* always white-pink, ignores the device dark mode */
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.7 var(--sans); -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--brand); }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 1240px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.t { font-family: var(--serif); font-weight: 700; line-height: 1.42; text-wrap: balance; margin: 0; transition: color .15s; }
a:hover .t { color: var(--cat); }
.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link:focus { position: fixed !important; left: 16px; top: 16px; width: auto; height: auto; clip: auto; z-index: 99; background: var(--accent); color: var(--on-accent); padding: 8px 14px; }

/* Masthead */
.masthead { background: var(--surface); }
.masthead .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding-block: 16px; }
.brand { display: flex; align-items: center; gap: 16px; }
.brand-logo { flex: none; width: auto; height: 120px; object-fit: contain; }
.brand-name { display: block; font: 700 34px/1.1 var(--serif); color: var(--brand); }
.brand-en { display: block; font-size: 16px; font-weight: 700; color: var(--navy); letter-spacing: .06em; margin-top: 2px; }
.brand-sub { display: block; font-size: 15px; color: var(--muted); }
@media (max-width: 640px) { .brand-logo { height: 80px; } .brand-name { font-size: 26px; } .brand-en { font-size: 13px; } .brand-sub { font-size: 13px; } }
/* Search: one rounded pill, magnifier inside, round button */
.search { display: flex; align-items: center; gap: 4px; padding: 4px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--accent); }
.search input { border: 0; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B5761' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 14px center / 20px; color: var(--ink); font: inherit; font-size: 16px; padding: 8px 12px 8px 44px; width: 240px; min-width: 0; }
.search input:focus { outline: none; }
.search input::placeholder { color: var(--muted); }
.search button { border: 0; border-radius: 999px; background: var(--brand); color: var(--on-brand); font: 700 16px var(--sans); padding: 10px 24px; cursor: pointer; transition: background .15s; }
.search button:hover { background: var(--brand-deep); }
@media (max-width: 640px) { .masthead .search { width: 100%; } .search input { flex: 1; width: auto; } }

/* Main nav */
.mainnav { background: var(--brand); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
.admin-bar .mainnav { top: 32px; }
@media (max-width: 782px) { .admin-bar .mainnav { top: 0; } }
.mainnav .wrap { display: flex; align-items: center; gap: 12px; }
.mainnav ul { flex: 1; min-width: 0; list-style: none; margin: 0; padding: 0; display: flex; overflow-x: auto; scrollbar-width: none; }
.mainnav ul::-webkit-scrollbar { display: none; }
.mainnav a { display: block; padding: 18px 20px; color: var(--on-brand); font-weight: 700; font-size: 17px; white-space: nowrap; transition: background .15s; }
.mainnav a:hover { background: rgba(0,0,0,.12); }
.mainnav .current-menu-item > a, .mainnav .current-cat > a, .mainnav a[aria-current] { background: var(--brand-deep); }

/* Shared pieces */
.img { position: relative; aspect-ratio: 16 / 10; max-width: 100%; overflow: hidden; border-radius: 10px; background: var(--line); }
.img img { width: 100%; height: 100%; object-fit: cover; transition: transform .45s ease; }
a:hover .img img { transform: scale(1.035); }
.ph { background: radial-gradient(120% 90% at 20% 15%, hsl(var(--h, 335) 30% 78% / .9), transparent 60%), linear-gradient(140deg, hsl(var(--h, 335) 24% 58%), hsl(calc(var(--h, 335) + 20) 30% 30%)); display: grid; place-items: center; }
.ph::after { content: "ก"; font: 700 clamp(28px, 4vw, 56px)/1 var(--serif); color: rgba(255,255,255,.35); }
.kicker { display: inline-block; font-size: 14px; font-weight: 700; line-height: 1.5; color: #fff; background: var(--brand); padding: 2px 12px; border-radius: 6px; margin-bottom: 8px; }
.k1 { background: var(--navy); }
.k2 { background: #2E7D32; }
.k3 { background: #C2410C; }
.k4 { background: #0E7490; }
.meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12.5px; color: var(--muted); margin-top: 8px; font-variant-numeric: tabular-nums; }
.panel { background: var(--surface); border-top: 3px solid var(--brand); padding: 14px 18px 6px; }
.panel-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font: 700 18px/1.3 var(--serif); margin: 0 0 4px; }
.panel-h small { font: 500 12px var(--sans); color: var(--muted); }

/* Card variants */
.card .body { padding-top: 10px; }
/* Picture card: headline sits on the photo */
/* News card: photo on top, headline below on a white card */
.card-md > a { position: relative; display: flex; flex-direction: column; height: 100%; border-radius: 12px; overflow: hidden; background: var(--surface); box-shadow: 0 1px 3px rgba(36,20,27,.08), 0 6px 18px rgba(36,20,27,.06); transition: box-shadow .2s; }
.card-md > a:hover { box-shadow: 0 2px 6px rgba(36,20,27,.12), 0 12px 28px rgba(36,20,27,.1); }
.card-md .img { aspect-ratio: 16 / 10; border-radius: 0; }
.card-md .body { padding: 14px 16px 16px; }
.card-md .t { font-size: 19px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-lg .t { font-size: 22px; }
.ex { margin: 6px 0 0; color: var(--muted); font-size: 14.5px; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-mini { padding-block: 12px; border-top: 1px solid var(--line); }
.card-mini:first-child { border-top: 0; padding-top: 0; }
.card-mini > a { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; align-items: start; }
.card-mini .img { aspect-ratio: 4 / 3; }
.card-mini .body { padding-top: 0; }
.card-mini .t { font: 600 15px/1.5 var(--sans); }
.card-mini .kicker { display: none; }
.card-row { padding-block: 20px; border-top: 1px solid var(--line); }
.card-row > a { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; }
.card-row .body { padding-top: 0; }
.card-row .t { font-size: 21px; }
@media (max-width: 600px) { .card-row > a { grid-template-columns: 120px minmax(0, 1fr); gap: 12px; } .card-row .t { font-size: 16px; } .card-row .ex { display: none; } }
.card-clip > a { display: block; }
.card-clip .img { aspect-ratio: 9 / 16; border-radius: 6px; }
.card-clip .img::before { content: ""; position: absolute; z-index: 1; left: 50%; top: 45%; transform: translate(-40%, -50%); border-left: 18px solid rgba(255,255,255,.92); border-top: 11px solid transparent; border-bottom: 11px solid transparent; }
.card-clip .body { position: absolute; inset: auto 0 0 0; padding: 40px 12px 12px; background: linear-gradient(transparent, rgba(0,0,0,.78)); color: #fff; }
.card-clip { position: relative; }
.card-clip .t { font: 600 14px/1.45 var(--sans); color: #fff; }
.card-clip .kicker, .card-clip .meta { display: none; }

/* Hero */
.hero { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; padding-block: 24px 32px; }
.hero-lead > a { position: relative; display: block; height: 100%; overflow: hidden; border-radius: 12px; background: var(--brand-deep); }
.hero-lead .img { aspect-ratio: 4 / 3; height: 100%; border-radius: 0; }
.hero-lead .over { position: absolute; inset: auto 0 0 0; padding: 80px 36px 26px; background: linear-gradient(180deg, transparent, rgba(20,6,12,.45) 35%, rgba(20,6,12,.8)); color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.35); }
.hero-lead .t { font-size: clamp(26px, 3vw, 42px); line-height: 1.35; color: #fff; }
.hero-lead a:hover .t { color: #fff; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 6px; text-decoration-thickness: 2px; }
.hero-lead .meta { color: rgba(255,255,255,.75); font-size: 15px; margin-top: 12px; }
/* Two picture cards stacked to the lead's height */
.stack { display: grid; grid-template-rows: 1fr 1fr; gap: 12px; }
.stack .card-md, .stack .card-md > a { height: 100%; }
.stack .card-md > a { display: block; background: var(--brand-deep); }
.stack .card-md .body { position: absolute; inset: auto 0 0 0; padding: 56px 18px 16px; background: linear-gradient(180deg, transparent, rgba(20,6,12,.45) 35%, rgba(20,6,12,.82)); color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.35); }
.stack .card-md .t, .stack .card-md a:hover .t { color: #fff; }
.stack .card-md .meta { color: rgba(255,255,255,.8); }
.stack .card-md .img { aspect-ratio: auto; height: 100%; min-height: 200px; }
.stack .card-md .t { font-size: clamp(18px, 1.7vw, 24px); }
.rank ol { list-style: none; margin: 0; padding: 0; counter-reset: r; }
.rank li { counter-increment: r; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 8px; padding-block: 11px; border-top: 1px solid var(--line); }
.rank li:first-child { border-top: 0; }
.rank li::before { content: counter(r); font: 700 24px/1.1 var(--serif); color: var(--cat); }
.rank .t { font: 600 15px/1.5 var(--sans); }
.rank time { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
@media (max-width: 900px) {
	.hero { grid-template-columns: minmax(0, 1fr); }
	.stack { grid-template-rows: none; grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.stack .card-md .img { aspect-ratio: 4 / 3; height: auto; min-height: 0; }
}
@media (max-width: 560px) {
	.hero { padding-top: 12px; }
	.stack { grid-template-columns: minmax(0, 1fr); }
	.hero-lead .over { padding: 80px 18px 18px; }
}

/* Sections */
.sec { padding-block: 8px 36px; }
.sec-h { display: flex; align-items: center; gap: 14px; margin: 0 0 18px; }
.sec-h h2 { margin: 0; background: var(--brand); color: var(--on-brand); font: 700 18px/1.3 var(--serif); padding: 6px 16px; border-radius: 2px; }
.sec-h .line { flex: 1; height: 2px; background: var(--brand); }
.sec-h .more { font-size: 14px; font-weight: 600; color: var(--cat); white-space: nowrap; }
.sec-h .more:hover { text-decoration: underline; }
.duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 36px; }
.block { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; }
@media (max-width: 960px) { .duo { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 520px) { .block, .grid4 { grid-template-columns: minmax(0, 1fr); } }

.vband { background: var(--brand-deep); color: #fff; padding-block: 28px 34px; margin-bottom: 36px; }
.vband .sec-h h2 { background: var(--accent); color: var(--on-accent); }
.vband .sec-h .line { background: rgba(255,255,255,.22); }
.vband .sec-h .more { color: var(--accent); }
.clips { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; }
.clips > * { scroll-snap-align: start; }

/* Article */
.with-rail { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 44px; padding-block: 28px 48px; }
@media (max-width: 980px) { .with-rail { grid-template-columns: minmax(0, 1fr); } }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--cat); font-weight: 600; }
.entry-title { font: 700 clamp(26px, 3.5vw, 40px)/1.36 var(--serif); margin: 0 0 12px; text-wrap: balance; }
.dek { font-size: 18px; line-height: 1.65; color: var(--muted); margin: 0 0 18px; max-width: 68ch; }
.byline { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-block: 14px; border-block: 1px solid var(--line); margin-bottom: 22px; }
.byline .avatar { border-radius: 50%; width: 44px; height: 44px; }
.who b { display: block; font-size: 15px; }
.who span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.share { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.share a, .share button { font: 600 13px var(--sans); padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.share .fb:hover { background: #1877F2; border-color: #1877F2; color: #fff; }
.share .ln:hover { background: #06C755; border-color: #06C755; color: #fff; }
.share .copy:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.feat { margin: 0 0 24px; }
.feat img { width: 100%; border-radius: 3px; }
.feat figcaption { font-size: 13px; color: var(--muted); padding-top: 8px; }
.entry-content { font-size: 18px; line-height: 1.9; }
.entry-content > * { max-width: 68ch; }
.entry-content > .alignwide, .entry-content > .alignfull, .entry-content > figure, .entry-content > .wp-block-embed { max-width: 100%; }
.entry-content p { margin: 0 0 1.25em; }
.entry-content h2 { font: 700 25px/1.45 var(--serif); margin: 1.6em 0 .6em; }
.entry-content h3 { font: 700 21px/1.45 var(--serif); margin: 1.4em 0 .5em; }
.entry-content a { color: var(--cat); text-decoration: underline; text-underline-offset: 3px; }
.entry-content a.btn { color: var(--on-brand); text-decoration: none; font-size: 17px; padding: 12px 28px; }
.map-embed { margin: 16px 0 28px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.map-embed iframe { display: block; width: 100%; height: 380px; border: 0; }
@media (max-width: 640px) { .map-embed iframe { height: 300px; } }
.entry-content blockquote { margin: 1.6em 0; padding: 4px 0 4px 20px; border-left: 4px solid var(--accent); font: 600 20px/1.7 var(--serif); }
.entry-content figure { margin: 1.6em 0; }
.entry-content figcaption { font-size: 13px; color: var(--muted); }
.entry-content iframe { max-width: 100%; }
.entry-content ul, .entry-content ol { padding-left: 1.3em; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.tags a { font-size: 13px; padding: 4px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.tags a:hover { border-color: var(--cat); color: var(--cat); }
.author-box { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 14px; background: var(--surface); border-top: 3px solid var(--brand); padding: 18px; margin-top: 32px; }
.author-box .avatar { border-radius: 50%; width: 64px; height: 64px; }
.author-box b { display: block; }
.author-box p { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.note { font-size: 13.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 10px 14px; margin-top: 24px; }

/* Follow-on-Facebook card */
.fb-card { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 24px; align-items: center; background: var(--surface); border-top: 3px solid var(--brand); padding: 24px; }
.fb-card .brand-logo { width: auto; height: 120px; }
.fb-card .t { font-size: 22px; margin-bottom: 6px; }
.fb-card p { margin: 0 0 16px; color: var(--muted); max-width: 60ch; }
.rail .fb-card { margin-top: 24px; grid-template-columns: 64px minmax(0, 1fr); gap: 14px; padding: 18px; align-items: start; }
.rail .fb-card .brand-logo { height: 76px; }
.rail .fb-card .t { font-size: 17px; }
.rail .fb-card p { font-size: 14px; }
@media (max-width: 520px) { .fb-card { grid-template-columns: 72px minmax(0, 1fr); gap: 14px; padding: 18px; align-items: start; } .fb-card .brand-logo { height: 84px; } }
.btn { display: inline-block; background: var(--brand); color: var(--on-brand); font-weight: 600; padding: 10px 22px; border-radius: 999px; margin: 0 8px 8px 0; transition: background .15s; }
.btn:hover { background: var(--brand-deep); }
.btn.ghost { background: transparent; color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand); }
.btn.ghost:hover { background: var(--accent); }

/* Listing, pages, 404 */
.arch-h { padding-bottom: 8px; border-bottom: 3px solid var(--brand); }
.arch-h h1 { font: 700 30px/1.3 var(--serif); margin: 0; }
.arch-desc { color: var(--muted); }
.arch-desc p { margin: 6px 0 0; }
.pagination .nav-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 28px; }
.page-numbers { padding: 6px 13px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; border-radius: 2px; }
.page-numbers.current { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
a.page-numbers:hover { border-color: var(--cat); color: var(--cat); }
.page-wrap { max-width: 820px; margin: 0 auto; padding-block: 36px 60px; }
.empty { text-align: center; padding-block: 72px; }
.empty h1 { font: 700 28px/1.4 var(--serif); margin: 0 0 8px; }
.empty p { color: var(--muted); margin: 0 0 20px; }
.empty .search { max-width: 420px; margin: 0 auto; }
.empty .search input { flex: 1; }

/* Footer */
.site-footer { background: var(--brand-deep); color: rgba(255,255,255,.76); font-size: 14px; }
.site-footer .wrap { display: grid; grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr)); gap: 32px; padding-block: 40px 22px; }
.site-footer .brand-name { color: #fff; }
.site-footer .brand-logo { height: 110px; padding: 8px; background: #fff; border-radius: 14px; } /* white tile keeps the pink logo readable on the dark footer */
.site-footer .brand-en { color: var(--accent); }
.site-footer .brand-sub { display: none; } /* the footer paragraph already carries the tagline */
.site-footer p { margin: 14px 0 0; max-width: 40ch; }
.site-footer h4 { margin: 0 0 10px; color: #fff; font: 700 15px var(--sans); }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.site-footer .sel { user-select: all; color: #fff; }
.legal { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; border-top: 1px solid rgba(255,255,255,.12); padding-top: 16px; font-size: 12.5px; color: rgba(255,255,255,.55); }
@media (max-width: 860px) { .site-footer .wrap { grid-template-columns: repeat(2, minmax(0, 1fr)); } .footer-brand { grid-column: 1 / -1; } }
@media (max-width: 480px) { .site-footer .wrap { grid-template-columns: minmax(0, 1fr); } }

@media (prefers-reduced-motion: reduce) {
	.img img, .t { transition: none; }
	a:hover .img img { transform: none; }
}

/* Back-to-top button */
.to-top { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 26; width: 48px; height: 48px; border: 0; border-radius: 50%; background: var(--brand); color: var(--on-brand); font: 700 22px/1 var(--sans); cursor: pointer; box-shadow: 0 4px 14px rgba(115,12,55,.3); }
.to-top:hover { background: var(--brand-deep); }

/* Phones: article share buttons become a bar fixed to the bottom of the screen */
@media (max-width: 640px) {
	.single-post .share { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; margin: 0; gap: 8px; padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); background: var(--surface); box-shadow: 0 -4px 16px rgba(36,20,27,.12); flex-wrap: nowrap; }
	.single-post .share a, .single-post .share button { flex: 1; text-align: center; padding: 10px 8px; font-size: 14px; }
	.single-post { padding-bottom: 72px; }
	.single-post .to-top { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
}

/* Video page grid */
.clip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }

/* TH | EN switch in the menu bar */
.lang-switch { flex: none; display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(0,0,0,.2); }
.mainnav .lang-switch a { padding: 5px 14px; border-radius: 999px; font-size: 14px; color: var(--on-brand); background: transparent; }
.mainnav .lang-switch a:hover { background: rgba(255,255,255,.15); }
.mainnav .lang-switch a[aria-current] { background: var(--on-brand); color: var(--brand); }
