/*
Theme Name: Phunnara Steel
Theme URI: https://phunnara.co.th
Author: Digi Era
Author URI: https://digi-era.co
Description: Custom block theme สำหรับ Phunnara Steel — ผู้ผลิตและติดตั้งรางน้ำฝนสแตนเลส 304 กลุ่มเป้าหมาย B2B แก้ไขเนื้อหาด้วย Gutenberg / Site Editor ไม่ต้องใช้ page builder
Version: 1.1.0
Requires at least: 6.6
Tested up to: 6.8
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: phunnara
*/

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-font-smoothing: antialiased; }
img { height: auto; }
.wp-site-blocks > footer { margin-block-start: 0; }
.wp-site-blocks > main,
.wp-site-blocks > header + * { margin-block-start: 0; }

:where(a, button, input, select, textarea, summary, .wp-element-button):focus-visible {
	outline: 3px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

.screen-reader-text:focus {
	clip: auto !important; clip-path: none; height: auto; width: auto;
	display: block; padding: 12px 16px; background: #fff; z-index: 100000;
	left: 8px; top: 8px; position: fixed;
}

/* ---------- Typography helpers ---------- */
.ph-eyebrow {
	font-family: "IBM Plex Mono", "IBM Plex Sans Thai", ui-monospace, monospace;
	font-size: var(--wp--preset--font-size--x-small);
	letter-spacing: 0.08em;
	font-weight: 600;
	text-transform: uppercase;
	color: var(--wp--preset--color--accent);
}
.has-ink-background-color .ph-eyebrow,
.ph-on-dark .ph-eyebrow { color: var(--wp--preset--color--accent-soft); }
.ph-mono { font-family: var(--wp--preset--font-family--plex-mono); }
.ph-lead { font-size: var(--wp--preset--font-size--large); color: var(--wp--preset--color--steel); }
.has-ink-background-color .ph-lead { color: var(--wp--preset--color--on-dark); }
.ph-meta { font-family: var(--wp--preset--font-family--plex-mono); font-size: var(--wp--preset--font-size--x-small); color: var(--wp--preset--color--muted); }

/* ---------- Header ---------- */
.ph-topbar a { color: var(--wp--preset--color--white); text-decoration: none; }
.ph-topbar a:hover { text-decoration: underline; }
.ph-header .wp-block-site-title a:hover { color: var(--wp--preset--color--accent); }
.ph-header .wp-block-navigation-item__content { padding-block: 6px; border-bottom: 2px solid transparent; }
.ph-header .wp-block-navigation-item.current-menu-item > .wp-block-navigation-item__content,
.ph-header .wp-block-navigation-item__content[aria-current="page"] {
	color: var(--wp--preset--color--accent);
	border-bottom-color: var(--wp--preset--color--accent);
}
.ph-header-phone a { font-family: var(--wp--preset--font-family--plex-mono); font-weight: 600; color: var(--wp--preset--color--ink); text-decoration: none; }
.ph-header .wp-block-navigation__responsive-container-open {
	width: 44px; height: 44px; justify-content: center; align-items: center;
	border: 1px solid var(--wp--preset--color--line-strong); border-radius: 4px;
}
.ph-header .wp-block-navigation__responsive-container.is-menu-open {
	padding: 24px;
}
.ph-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
	font-size: 1.0625rem; font-weight: 600;
}
.ph-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
	min-height: 48px; display: flex; align-items: center;
}

@media (max-width: 900px) {
	.ph-hide-sm { display: none !important; }
	.ph-topbar .ph-topbar-note { display: none; }
}
@media (min-width: 901px) {
	.ph-show-sm, .wp-block-buttons.ph-mobile-cta { display: none !important; }
}

/* ---------- Buttons ---------- */
.wp-block-button__link { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background-color .15s ease, color .15s ease, border-color .15s ease; }
.wp-block-button.is-style-line .wp-block-button__link { background: var(--wp--preset--color--line-green); color: #fff; }
.wp-block-button.is-style-line .wp-block-button__link:hover { background: #036E31; }
.wp-block-button.is-style-outline-ink .wp-block-button__link {
	background: transparent; color: var(--wp--preset--color--ink);
	border: 1.5px solid var(--wp--preset--color--ink);
}
.wp-block-button.is-style-outline-ink .wp-block-button__link:hover { background: var(--wp--preset--color--ink); color: #fff; }
.wp-block-button.is-style-outline-white .wp-block-button__link {
	background: transparent; color: #fff; border: 1.5px solid #fff;
}
.wp-block-button.is-style-outline-white .wp-block-button__link:hover { background: #fff; color: var(--wp--preset--color--ink); }
.wp-block-button.is-style-white .wp-block-button__link { background: #fff; color: var(--wp--preset--color--ink); }
.wp-block-button.is-style-white .wp-block-button__link:hover { background: var(--wp--preset--color--surface); }
.ph-icon-line .wp-block-button__link::before,
.ph-icon-phone .wp-block-button__link::before {
	content: ""; width: 20px; height: 20px; flex: none;
	background: currentColor;
	-webkit-mask: var(--ph-icon) center / contain no-repeat; mask: var(--ph-icon) center / contain no-repeat;
}
.ph-icon-line { --ph-icon: url("assets/img/icon-chat.svg"); }
.ph-icon-phone { --ph-icon: url("assets/img/icon-phone.svg"); }

/* ---------- Cards & lists ---------- */
.is-style-card {
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 4px;
	background: var(--wp--preset--color--white);
}
.is-style-card-strong {
	border: 1.5px solid var(--wp--preset--color--ink);
	border-radius: 4px;
	background: var(--wp--preset--color--white);
}
.is-style-rule-top { border-top: 3px solid var(--wp--preset--color--ink); padding-top: 1.25rem; }
.equal-cards > .wp-block-column { display: flex; flex-direction: column; }
.equal-cards > .wp-block-column > .wp-block-group { display: flex; flex-direction: column; flex-grow: 1; }
.equal-cards .cta-bottom { margin-top: auto; }

.ph-link-arrow a, a.ph-link-arrow { font-weight: 600; text-decoration: none; display: inline-flex; min-height: 44px; align-items: center; }
.ph-link-arrow a::after { content: " →"; white-space: pre; }

ul.ph-checks { list-style: none; padding-left: 0; }
ul.ph-checks li { position: relative; padding-left: 32px; margin-bottom: 10px; }
ul.ph-checks li::before {
	content: ""; position: absolute; left: 0; top: 4px; width: 20px; height: 20px;
	background: var(--wp--preset--color--accent);
	-webkit-mask: url("assets/img/icon-check.svg") center / contain no-repeat; mask: url("assets/img/icon-check.svg") center / contain no-repeat;
}

/* Spec strip (dl-like, built from columns) */
.ph-spec-strip { border: 1px solid var(--wp--preset--color--line); border-radius: 4px; background: #fff; gap: 0 !important; }
.ph-spec-strip > .wp-block-column { padding: 20px 24px; margin: 0 !important; }
.ph-spec-strip > .wp-block-column + .wp-block-column { border-left: 1px solid var(--wp--preset--color--line); }
.ph-spec-strip .ph-spec-value { font-family: var(--wp--preset--font-family--plex-mono); font-size: 1.875rem; font-weight: 600; line-height: 1.2; margin: 0; }
.ph-spec-strip .ph-spec-label { color: var(--wp--preset--color--muted); font-size: var(--wp--preset--font-size--small); margin: 4px 0 0; }
.has-ink-background-color .ph-spec-strip { background: transparent; border-color: #3A4754; }
.has-ink-background-color .ph-spec-strip > .wp-block-column + .wp-block-column { border-left-color: #3A4754; }
.has-ink-background-color .ph-spec-strip .ph-spec-label { color: var(--wp--preset--color--on-dark); }
@media (max-width: 781px) {
	.ph-spec-strip > .wp-block-column + .wp-block-column { border-left: 0; border-top: 1px solid var(--wp--preset--color--line); }
	.has-ink-background-color .ph-spec-strip > .wp-block-column + .wp-block-column { border-top-color: #3A4754; }
}

/* Process steps */
.ph-steps { counter-reset: none; }
.ph-step-num { font-family: var(--wp--preset--font-family--plex-mono); font-size: var(--wp--preset--font-size--small); color: var(--wp--preset--color--accent-soft); margin: 0; }
.has-white-background-color .ph-step-num, .has-surface-background-color .ph-step-num { color: var(--wp--preset--color--accent); }

/* Tables */
.wp-block-table.is-style-spec table { border-collapse: collapse; width: 100%; }
.wp-block-table.is-style-spec th, .wp-block-table.is-style-spec td { border: 0; border-top: 1px solid var(--wp--preset--color--line); padding: 10px 0; text-align: left; vertical-align: top; }
.wp-block-table.is-style-spec tr:last-child td, .wp-block-table.is-style-spec tr:last-child th { border-bottom: 1px solid var(--wp--preset--color--line); }
.wp-block-table.is-style-spec td:first-child { color: var(--wp--preset--color--muted); width: 42%; padding-right: 12px; }
.wp-block-table.is-style-compare { overflow-x: auto; border: 1px solid var(--wp--preset--color--line); border-radius: 4px; background: #fff; }
.wp-block-table.is-style-compare table { min-width: 640px; border-collapse: collapse; width: 100%; }
.wp-block-table.is-style-compare thead { border: 0; }
.wp-block-table.is-style-compare thead th { background: var(--wp--preset--color--ink); color: #fff; text-align: left; padding: 14px 20px; border: 0; font-weight: 600; }
.wp-block-table.is-style-compare td { padding: 14px 20px; border: 0; border-top: 1px solid var(--wp--preset--color--line); }
.wp-block-table.is-style-compare td:first-child { color: var(--wp--preset--color--muted); font-weight: 500; }

/* Details / FAQ */
.wp-block-details summary { font-weight: 600; font-size: var(--wp--preset--font-size--large); cursor: pointer; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 16px; list-style: none; }
.wp-block-details summary::-webkit-details-marker { display: none; }
.wp-block-details summary::after { content: "+"; font-family: var(--wp--preset--font-family--plex-mono); font-size: 1.5rem; color: var(--wp--preset--color--accent); flex: none; }
.wp-block-details[open] summary::after { content: "−"; }
.wp-block-details > :not(summary) { color: var(--wp--preset--color--steel); }
.ph-faq { border-top: 1px solid var(--wp--preset--color--line); }

/* Breadcrumb */
.ph-breadcrumb { font-size: var(--wp--preset--font-size--small); color: var(--wp--preset--color--muted); }
.ph-breadcrumb ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.ph-breadcrumb li + li::before { content: "/"; margin-right: 8px; color: var(--wp--preset--color--line-strong); }
.ph-breadcrumb a { color: var(--wp--preset--color--muted); }

/* Image placeholders and media */
.ph-media img { border-radius: 4px; width: 100%; object-fit: cover; }
.ph-media-43 img { aspect-ratio: 4 / 3; }
.ph-media-169 img { aspect-ratio: 16 / 9; }
.ph-media-219 img { aspect-ratio: 21 / 9; }
.ph-media-11 img { aspect-ratio: 1 / 1; }
.ph-logos { gap: 16px !important; }
.ph-logos .wp-block-image img { height: 48px; width: 100%; object-fit: contain; filter: grayscale(1); opacity: .85; }

/* Query / cards */
.ph-card-link .wp-block-post-title a::after { content: ""; position: absolute; inset: 0; }
.ph-card-link { position: relative; }
.ph-card-link .wp-block-post-featured-image img { aspect-ratio: 4 / 3; object-fit: cover; border-radius: 4px; }
.ph-card-link:hover .wp-block-post-title a { color: var(--wp--preset--color--accent); }
.ph-spec-mini { border-top: 1px solid var(--wp--preset--color--line); padding-top: 12px; font-size: var(--wp--preset--font-size--small); }
.ph-spec-mini p { margin: 0; }

/* Term chips (filter) */
.ph-chips ul, ul.ph-chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.ph-chips li a, .ph-chips .wp-block-categories li a {
	display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px;
	border: 1px solid var(--wp--preset--color--line-strong); border-radius: 999px;
	background: #fff; color: var(--wp--preset--color--ink); text-decoration: none; font-weight: 600; font-size: var(--wp--preset--font-size--small);
}
.ph-chips li a:hover { border-color: var(--wp--preset--color--ink); }
.ph-chips li.current-cat a, .ph-chips li a[aria-current="page"], .ph-chips li.ph-chip-active a { background: var(--wp--preset--color--ink); border-color: var(--wp--preset--color--ink); color: #fff; }

/* Project spec aside */
.ph-spec-list p { display: flex; justify-content: space-between; gap: 16px; margin: 0; padding: 12px 0; border-top: 1px solid var(--wp--preset--color--line); }
.ph-spec-list p:last-child { border-bottom: 1px solid var(--wp--preset--color--line); }
.ph-spec-list .ph-spec-k { color: var(--wp--preset--color--muted); }
.ph-spec-list .ph-spec-v { font-weight: 600; text-align: right; }
.ph-spec-list .ph-spec-v:empty::before { content: "—"; color: var(--wp--preset--color--line-strong); }

/* Article */
.ph-article .wp-block-post-content { font-size: 1.125rem; line-height: 1.8; }
.ph-article .wp-block-post-content > h2 { margin-top: 2.5rem; font-size: clamp(1.5rem, 2.4vw, 1.75rem); }
.ph-summary { background: var(--wp--preset--color--surface); border-radius: 4px; }
.ph-toc { border: 1px solid var(--wp--preset--color--line); border-radius: 4px; padding: 24px; }
.ph-toc ol { list-style: none; margin: 8px 0 0; padding: 0; }
.ph-toc li a { display: flex; min-height: 40px; align-items: center; color: var(--wp--preset--color--ink); text-decoration: none; border-bottom: 1px solid #EDF1F4; font-size: var(--wp--preset--font-size--small); }
.ph-toc li a:hover { color: var(--wp--preset--color--accent); }
.ph-toc:not(.has-items) { display: none; }
@media (min-width: 1024px) { .ph-sticky { position: sticky; top: 24px; } }

/* Quote form (rendered by Phunnara Core plugin) */
.ph-form, .ph-form * { box-sizing: border-box; }
.ph-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.ph-form .ph-field { display: flex; flex-direction: column; gap: 6px; }
.ph-form .ph-field--full { grid-column: 1 / -1; }
.ph-form label { font-weight: 600; font-size: var(--wp--preset--font-size--small); }
.ph-form .ph-req { color: #B42318; }
.ph-form input[type=text], .ph-form input[type=tel], .ph-form input[type=email], .ph-form input[type=number], .ph-form select, .ph-form textarea {
	font: inherit; height: 48px; padding: 0 14px; border: 1px solid #A9B5C1; border-radius: 4px; background: #fff; color: var(--wp--preset--color--ink); width: 100%;
}
.ph-form textarea { height: auto; min-height: 120px; padding: 12px 14px; resize: vertical; }
.ph-form .ph-help { font-size: var(--wp--preset--font-size--x-small); color: var(--wp--preset--color--muted); }
.ph-form .ph-submit { grid-column: 1 / -1; }
.ph-form button { font: inherit; font-weight: 600; font-size: 1.0625rem; min-height: 52px; width: 100%; border: 0; border-radius: 4px; background: var(--wp--preset--color--accent); color: #fff; cursor: pointer; }
.ph-form button:hover { background: var(--wp--preset--color--accent-dark); }
.ph-form .ph-hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.ph-form-notice { padding: 16px 20px; border-radius: 4px; margin-bottom: 20px; font-weight: 600; }
.ph-form-notice--ok { background: #E7F5EC; color: #035E2A; border: 1px solid #A6D9B8; }
.ph-form-notice--err { background: #FDECEA; color: #8A1C12; border: 1px solid #F3B7B0; }
.ph-form-note { grid-column: 1 / -1; margin: 0; font-size: var(--wp--preset--font-size--x-small); color: var(--wp--preset--color--muted); }

/* ---------- Mobile sticky CTA ---------- */
.ph-mobile-cta { display: none; }
@media (max-width: 900px) {
	.ph-mobile-cta {
		display: flex !important; position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
		margin: 0 !important; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
		background: #fff; border-top: 1px solid var(--wp--preset--color--line);
		box-shadow: 0 -4px 16px rgba(15, 27, 38, .08); gap: 10px;
	}
	.ph-mobile-cta .wp-block-button { flex: 1 1 0; }
	.ph-mobile-cta .wp-block-button__link { width: 100%; }
	body { padding-bottom: 76px; }
}

/* ---------- Footer ---------- */
.ph-footer a { color: var(--wp--preset--color--on-dark); text-decoration: none; }
.ph-footer a:hover { color: #fff; text-decoration: underline; }
.ph-footer .ph-footer-head { color: #fff; font-weight: 600; margin-bottom: 4px; }
.ph-footer p { margin: 0; }

/* ---------- Motion ---------- */
.animate-on-scroll { opacity: 0; transform: translateY(12px); transition: opacity .35s ease-out, transform .35s ease-out; }
.animate-on-scroll.is-visible { opacity: 1; transform: none; }
.no-js .animate-on-scroll, .editor-styles-wrapper .animate-on-scroll { opacity: 1; transform: none; }
.ph-card-hover { transition: border-color .15s ease, box-shadow .15s ease; }
.ph-card-hover:hover { border-color: var(--wp--preset--color--ink); box-shadow: 0 8px 24px rgba(15, 27, 38, .06); }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
	.animate-on-scroll { opacity: 1; transform: none; }
}

/* Contact */
.ph-sec-contact a[href^="mailto:"] { overflow-wrap: anywhere; }
.ph-sec-contact .has-line-green-background-color a { text-decoration: none; }

/* 404 */
ul.ph-404-links { list-style: none; padding: 0; border-top: 1px solid var(--wp--preset--color--line); }
ul.ph-404-links li { border-bottom: 1px solid var(--wp--preset--color--line); }
ul.ph-404-links a { display: flex; justify-content: space-between; min-height: 56px; align-items: center; color: var(--wp--preset--color--ink); text-decoration: none; }
ul.ph-404-links a::after { content: "→"; }
.ph-spec-mini p:empty::before { content: "—"; color: var(--wp--preset--color--line-strong); }
.ph-lead:empty { display: none; }

/* Full-width buttons (class instead of the width setting, which changes between WP versions) */
.wp-block-buttons > .wp-block-button.ph-btn-full { width: 100%; flex-basis: 100%; }
.wp-block-button.ph-btn-full .wp-block-button__link { width: 100%; }
.ph-header .wp-block-button__link { font-size: 0.9375rem; padding: 0.7rem 1.2rem; min-height: 44px; }

/* Logos row on small screens */
@media (max-width: 781px) {
	.ph-sec-logos .wp-block-group.alignwide { flex-direction: column; align-items: flex-start; }
	.ph-logos { width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

.ph-step-index { flex: 0 0 40px; margin: 0; }

.is-layout-constrained > .ph-breadcrumb { max-width: var(--wp--style--global--wide-size) !important; }
.is-layout-constrained > .ph-chips { max-width: var(--wp--style--global--wide-size) !important; }
.ph-avatar { flex: 0 0 56px; width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; padding: 0 !important; margin: 0; }

/* Project gallery */
.wp-block-gallery.ph-gallery { gap: 20px !important; }
.wp-block-gallery.ph-gallery.is-cropped .wp-block-image img { aspect-ratio: 4 / 3; height: auto; border-radius: 4px; }
.wp-block-gallery.ph-gallery .wp-block-image { flex-direction: column !important; }
.wp-block-gallery.ph-gallery .wp-block-image figcaption.wp-element-caption {
	position: static; background: none; color: var(--wp--preset--color--muted); text-shadow: none;
	padding: 10px 0 0; margin: 0; max-height: none; overflow: visible; text-align: left;
	font-family: var(--wp--preset--font-family--plex-thai); font-size: var(--wp--preset--font-size--small); line-height: 1.5;
}
.wp-block-gallery.ph-gallery .wp-block-image figcaption::before { display: none; }
@media (max-width: 600px) { .wp-block-gallery.ph-gallery.columns-3 .wp-block-image { width: calc(50% - 10px) !important; } }
