/*
Theme Name: Xinhai Used Parts
Theme URI: https://example.com/jinfu-used-parts
Author: Xinhai Used Auto Parts
Description: Lightweight multilingual catalog and inquiry theme for genuine used auto parts.
Version: 1.3.1
Requires at least: 6.4
Requires PHP: 7.4
Text Domain: jinfu-used-parts
*/

:root {
  --paper: #f4f4f1;
  --surface: #fff;
  --ink: #171a1c;
  --muted: #5b6165;
  --rule: #d7d9d8;
  --blue: #1769d2;
  --blue-dark: #0b4da2;
  --green: #176b52;
  --max: 1440px;
  --radius: 6px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", "Noto Sans SC", "Noto Sans Thai", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: 0;
}
html[lang="th"] body { font-family: "Leelawadee UI", Tahoma, system-ui, sans-serif; }
html[lang="km"] body { font-family: "Khmer UI", "Noto Sans Khmer", system-ui, sans-serif; }
html[lang="lo"] body { font-family: "Lao UI", "Leelawadee UI", "Noto Sans Lao", system-ui, sans-serif; }
html[lang="ar"] body { font-family: Tahoma, "Segoe UI", Arial, sans-serif; }
body, button, input { font: inherit; }
a { color: inherit; text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button, .button, .language-link, .filter-button { cursor: pointer; }
::selection { background: #bdd7ff; color: var(--ink); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

.container { width: min(calc(100% - 40px), var(--max)); margin-inline: auto; }
.skip-link { position: fixed; left: 12px; top: -80px; z-index: 1000; background: var(--ink); color: #fff; padding: 10px 14px; }
.skip-link:focus { top: 12px; }

.site-header { position: sticky; top: 0; z-index: 50; background: rgba(244,244,241,.96); border-bottom: 1px solid var(--rule); backdrop-filter: blur(12px); }
.header-row { min-height: 72px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 820; line-height: 1.05; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; background: var(--ink); color: #fff; border-radius: 4px; font-size: 14px; }
.brand-name { display: grid; gap: 3px; }
.brand-name small { color: var(--muted); font-size: 11px; font-weight: 650; }
.main-nav { display: flex; justify-content: center; gap: 26px; }
.main-nav a { text-decoration: none; font-weight: 680; font-size: 14px; }
.main-nav a:hover { color: var(--blue-dark); }
.header-tools { display: flex; align-items: center; gap: 10px; }
.language-menu { position: relative; }
.language-trigger, .icon-button { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); color: var(--ink); }
.language-trigger { width: auto; min-width: 58px; grid-auto-flow: column; gap: 6px; padding: 0 10px; font-size: 13px; font-weight: 760; }
.language-panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 190px; padding: 6px; background: var(--surface); border: 1px solid var(--rule); box-shadow: 0 12px 28px rgba(23,26,28,.14); border-radius: var(--radius); }
.language-panel[hidden] { display: none; }
.language-link { display: flex; justify-content: space-between; gap: 20px; padding: 9px 10px; border-radius: 3px; text-decoration: none; font-size: 14px; }
.language-panel button.language-link { width: 100%; border: 0; background: transparent; color: inherit; text-align: left; }
.language-link:hover, .language-link[aria-current="true"] { background: var(--paper); color: var(--blue-dark); }
[dir="rtl"] .language-panel { right: auto; left: 0; }
[dir="rtl"] .language-panel button.language-link, [dir="rtl"] .faq-question { text-align: right; }
[dir="rtl"] .search-box svg { left: auto; right: 14px; }
[dir="rtl"] .search-input { padding: 0 46px 0 16px; }
[dir="rtl"] .product-state { left: auto; right: 10px; }
[dir="rtl"] .process-step { padding: 28px 0 34px 28px; border-right: 0; border-left: 1px solid #424648; }
[dir="rtl"] .process-step + .process-step { padding-left: 28px; padding-right: 28px; }
[dir="rtl"] .process-step:last-child { border-left: 0; }
[dir="rtl"] .buyer-panel ul { padding-left: 0; padding-right: 20px; }
[dir="rtl"] .faq-answer { padding: 0 0 22px 44px; }
[dir="rtl"] .dialog-thumbs { border-left: 0; border-right: 1px solid var(--rule); }
.menu-toggle { display: none; }
.mobile-nav { display: none; padding: 4px 0 16px; border-top: 1px solid var(--rule); }
.mobile-nav[hidden] { display: none; }
.mobile-nav a { display: block; padding: 10px 0; text-decoration: none; font-weight: 720; }
.button[disabled], .icon-button[disabled] { cursor: not-allowed; opacity: .58; transform: none; }

.hero { min-height: min(760px, calc(100vh - 72px)); position: relative; display: grid; align-items: stretch; overflow: hidden; border-bottom: 1px solid var(--rule); background: var(--ink); color: #fff; }
.hero-grid { position: relative; width: 100%; max-width: none; min-height: inherit; overflow: hidden; }
.hero-copy { position: relative; z-index: 2; width: min(calc(100% - 40px), var(--max)); min-height: inherit; display: flex; flex-direction: column; justify-content: center; margin-inline: auto; padding: 88px 0 140px; }
.hero h1 { max-width: 980px; margin: 0; color: #fff; font-size: 5.5rem; line-height: .98; letter-spacing: 0; text-wrap: balance; }
.hero-lede { max-width: 650px; margin: 28px 0 0; color: rgba(255,255,255,.86); font-size: 1.25rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; }
.button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 18px; border: 1px solid var(--ink); border-radius: 4px; background: var(--ink); color: #fff; font-weight: 760; text-decoration: none; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.button:hover { background: #313638; border-color: #313638; transform: translateY(-1px); }
.button-accent { background: var(--blue); border-color: var(--blue); }
.button-accent:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.button-secondary { background: transparent; color: var(--ink); border-color: var(--rule); }
.button-secondary:hover { background: var(--paper); border-color: var(--ink); }
.hero .button-secondary { color: #fff; border-color: rgba(255,255,255,.72); }
.hero .button-secondary:hover { background: #fff; border-color: #fff; color: var(--ink); }
.hero-notes { max-width: 760px; display: flex; flex-wrap: wrap; gap: 14px 24px; margin: 38px 0 0; padding: 24px 0 0; border-top: 1px solid rgba(255,255,255,.42); color: rgba(255,255,255,.82); font-size: 13px; font-weight: 650; }
.hero-notes span { display: inline-flex; align-items: center; gap: 7px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.hero-product { position: absolute; z-index: 0; inset: 0; overflow: hidden; background: #22282b; }
.hero-product::after { content: ""; position: absolute; inset: 0; background: rgba(9,13,16,.58); }
.hero-product img { width: 100%; height: 100%; object-fit: cover; object-position: center 46%; }
.hero-label { position: absolute; z-index: 1; left: auto; right: max(20px, calc((100vw - var(--max)) / 2 + 20px)); bottom: 22px; width: min(420px, calc(100% - 40px)); display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 20px; padding: 16px 18px; color: #fff; background: rgba(9,13,16,.82); border: 1px solid rgba(255,255,255,.3); border-radius: var(--radius); box-shadow: 0 14px 36px rgba(0,0,0,.24); }
.hero-label strong { display: block; font-size: 1.5rem; line-height: 1.2; }
.hero-label small { color: rgba(255,255,255,.7); }
.hero .stock-code { color: #a8ceff; }
.stock-code { color: var(--blue-dark); font-weight: 820; font-variant-numeric: tabular-nums; white-space: nowrap; }

.section { padding: 88px 0; }
.section-white { background: var(--surface); }
.section-dark { background: var(--ink); color: #fff; }
.section-head { display: grid; grid-template-columns: minmax(0, .8fr) minmax(340px, .4fr); align-items: end; gap: 48px; margin-bottom: 34px; }
.section-head h2 { margin: 0; font-size: clamp(34px, 4vw, 58px); line-height: 1.05; letter-spacing: -.025em; text-wrap: balance; }
.section-head p { margin: 0; color: var(--muted); }
.section-dark .section-head p { color: #b9bdbc; }

.catalog-tools { position: sticky; top: 72px; z-index: 30; padding: 16px 0; background: rgba(244,244,241,.97); border-block: 1px solid var(--rule); backdrop-filter: blur(12px); }
.catalog-tools-row { display: grid; grid-template-columns: minmax(260px, 1fr) auto; gap: 18px; align-items: center; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search-input { width: 100%; min-height: 48px; padding: 0 16px 0 46px; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); color: var(--ink); }
.search-input::placeholder { color: #747a7d; }
.filter-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.filter-button { min-height: 44px; flex: 0 0 auto; padding: 0 14px; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 720; }
.filter-button:hover, .filter-button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.results-bar { display: flex; justify-content: space-between; align-items: center; min-height: 52px; gap: 20px; color: var(--muted); font-size: 14px; }
.results-count { font-variant-numeric: tabular-nums; }
.catalog-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.product-card { min-width: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); transition: transform .2s ease, box-shadow .2s ease; }
.product-card:hover { transform: translateY(-3px); box-shadow: 0 14px 32px rgba(23,26,28,.1); }
.product-image { display: block; position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: #e6e7e4; }
.product-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.product-card:hover .product-image img { transform: scale(1.025); }
.product-state { position: absolute; top: 10px; left: 10px; padding: 5px 8px; border-radius: 3px; background: rgba(23,26,28,.9); color: #fff; font-size: 11px; font-weight: 780; }
.product-body { padding: 16px; }
.product-code { color: var(--blue-dark); font-size: 12px; font-weight: 820; }
.product-title { min-height: 2.9em; margin: 7px 0 15px; font-size: 16px; line-height: 1.42; }
.product-title a { text-decoration: none; }
.product-title a:hover { color: var(--blue-dark); text-decoration: underline; }
.product-actions { display: grid; grid-template-columns: 1fr 44px; gap: 8px; }
.product-actions .button { min-height: 44px; padding-inline: 12px; font-size: 13px; }
.product-actions .icon-button { background: var(--paper); }
.load-more-wrap { display: flex; justify-content: center; margin-top: 34px; }
.empty-state { grid-column: 1 / -1; padding: 52px 20px; text-align: center; border-block: 1px solid var(--rule); }
.empty-state h3 { margin: 0 0 8px; font-size: 24px; }
.empty-state p { margin: 0; color: var(--muted); }

.process-grid { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid #424648; }
.process-step { min-height: 240px; padding: 28px 28px 34px 0; border-right: 1px solid #424648; }
.process-step + .process-step { padding-left: 28px; }
.process-step:last-child { border-right: 0; }
.process-step svg { color: #4d91eb; }
.process-step h3 { margin: 34px 0 10px; font-size: 20px; }
.process-step p { margin: 0; color: #b9bdbc; }

.buyer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
.buyer-panel { min-height: 390px; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(28px, 4vw, 58px); background: var(--surface); }
.buyer-panel h3 { max-width: 520px; margin: 0; font-size: clamp(30px, 3.3vw, 48px); line-height: 1.08; }
.buyer-panel p { max-width: 620px; color: var(--muted); }
.buyer-panel ul { padding-left: 20px; }

.faq-list { max-width: 980px; border-top: 1px solid var(--rule); }
.faq-item { border-bottom: 1px solid var(--rule); }
.faq-question { width: 100%; min-height: 72px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 20px; padding: 16px 0; border: 0; background: transparent; color: var(--ink); text-align: left; font-weight: 760; }
.faq-answer { max-width: 75ch; padding: 0 44px 22px 0; color: var(--muted); }
.faq-answer[hidden] { display: none; }

.contact-band { padding: 72px 0; background: var(--blue); color: #fff; }
.contact-grid { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 40px; }
.contact-grid h2 { max-width: 850px; margin: 0; font-size: clamp(36px, 5vw, 68px); line-height: 1; letter-spacing: -.03em; }
.contact-grid p { max-width: 720px; margin: 18px 0 0; color: #eaf2ff; }
.contact-actions { display: grid; gap: 10px; min-width: 260px; }
.contact-actions .button { background: var(--ink); border-color: var(--ink); }
.placeholder-note { font-size: 12px; color: #d6e6ff; text-align: center; }

.site-footer { padding: 46px 0 28px; background: #0d0f10; color: #fff; }
.footer-grid { display: grid; grid-template-columns: 1fr auto; gap: 40px; padding-bottom: 38px; border-bottom: 1px solid #34383a; }
.footer-copy { max-width: 600px; color: #aeb2b3; }
.footer-links { display: grid; grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 10px 30px; }
.footer-links a { color: #d8dad9; text-decoration: none; }
.footer-bottom { display: flex; justify-content: space-between; gap: 30px; padding-top: 24px; color: #8f9496; font-size: 12px; }

.product-page { padding: 48px 0 88px; }
.breadcrumb { margin-bottom: 24px; color: var(--muted); font-size: clamp(16px, 1.4vw, 19px); font-weight: 700; }
.breadcrumb a { color: var(--blue-dark); text-underline-offset: 4px; }
.product-detail { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); gap: clamp(34px, 5vw, 80px); align-items: start; }
.product-gallery { min-width: 0; }
.product-detail-image { width: 100%; padding: 0; overflow: hidden; border: 0; border-radius: var(--radius); background: #e4e5e2; cursor: zoom-in; touch-action: pan-y; }
.product-detail-image:active { cursor: grabbing; }
.product-detail-image img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; pointer-events: none; user-select: none; }
.gallery-thumbs { display: grid; grid-auto-flow: column; grid-auto-columns: 88px; gap: 8px; margin-top: 10px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; }
.gallery-thumb { width: 88px; aspect-ratio: 1; padding: 0; overflow: hidden; border: 2px solid transparent; border-radius: 4px; background: #e4e5e2; cursor: pointer; }
.gallery-thumb[aria-pressed="true"] { border-color: var(--blue); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-dialog { width: min(1100px, calc(100% - 28px)); max-height: calc(100dvh - 28px); padding: 0; overflow: hidden; border: 0; border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgba(0,0,0,.3); }
.gallery-dialog::backdrop { background: rgba(13,15,16,.82); }
.dialog-head { min-height: 58px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px; padding: 10px 14px 10px 20px; border-bottom: 1px solid var(--rule); }
.dialog-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 780; }
.dialog-close { width: 40px; height: 40px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); font-size: 24px; line-height: 1; cursor: pointer; }
.dialog-body { display: grid; grid-template-columns: minmax(0, 1fr) 116px; min-height: 0; max-height: calc(100dvh - 88px); }
.dialog-stage { min-height: 0; display: grid; place-items: center; overflow: hidden; background: #e5e6e3; cursor: grab; touch-action: pan-y; }
.dialog-stage:active { cursor: grabbing; }
.dialog-stage img { width: 100%; height: 100%; max-height: calc(100dvh - 88px); object-fit: contain; pointer-events: none; user-select: none; }
.dialog-thumbs { padding: 10px; overflow-y: auto; border-left: 1px solid var(--rule); }
.dialog-thumbs .gallery-thumb { display: block; margin-bottom: 8px; }
.product-detail-copy { position: sticky; top: 112px; }
.product-detail-copy > .stock-code { font-size: clamp(18px, 2vw, 24px); line-height: 1.2; }
.product-detail-copy h1 { margin: 10px 0 18px; font-size: clamp(34px, 4vw, 58px); line-height: 1.05; letter-spacing: -.025em; }
.data-list { margin: 30px 0; border-top: 1px solid var(--rule); }
.data-row { display: grid; grid-template-columns: 140px 1fr; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--rule); }
.data-row dt { color: var(--muted); }
.data-row dd { margin: 0; font-weight: 680; }
.notice { margin: 24px 0; padding: 16px; background: #eaf2ff; border-radius: var(--radius); color: #123c78; }

@media (max-width: 1100px) {
  .main-nav { display: none; }
  .header-row { grid-template-columns: 1fr auto; }
  .menu-toggle { display: grid; }
  .mobile-nav:not([hidden]) { display: block; }
  .hero h1 { font-size: 4rem; }
  .catalog-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .process-grid { grid-template-columns: repeat(2, 1fr); }
  .process-step:nth-child(2) { border-right: 0; }
  .process-step:nth-child(n+3) { border-top: 1px solid #424648; }
}

@media (max-width: 760px) {
  .container { width: min(calc(100% - 28px), var(--max)); }
  .header-row { min-height: 64px; gap: 12px; }
  .brand-name span { font-size: 14px; }
  .brand-name small { display: none; }
  .hero { min-height: 660px; }
  .hero-copy { width: calc(100% - 28px); padding: 70px 0 158px; }
  .hero h1 { font-size: 2.625rem; overflow-wrap: anywhere; }
  .hero-lede { margin-top: 22px; font-size: 1.0625rem; }
  .hero-actions { margin-top: 28px; }
  .hero-notes { margin-top: 30px; padding-top: 18px; }
  .hero-label { left: 14px; right: 14px; bottom: 14px; width: auto; padding: 14px; }
  .hero-label strong { font-size: 1.125rem; }
  .section { padding: 64px 0; }
  .section-head { grid-template-columns: 1fr; gap: 16px; }
  .catalog-tools { top: 64px; }
  .catalog-tools-row { grid-template-columns: 1fr; gap: 10px; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .product-body { padding: 12px; }
  .product-title { min-height: 3.2em; font-size: 14px; }
  .product-actions { grid-template-columns: 1fr; }
  .product-actions .icon-button { display: none; }
  .buyer-grid { grid-template-columns: 1fr; }
  .buyer-panel { min-height: 340px; }
  .contact-grid, .footer-grid, .product-detail { grid-template-columns: 1fr; }
  .contact-actions { min-width: 0; }
  .footer-links { grid-template-columns: 1fr 1fr; }
  .footer-bottom { flex-direction: column; gap: 8px; }
  .product-detail-image { aspect-ratio: 3 / 4; }
  .product-detail-image img { height: 100%; aspect-ratio: auto; }
  .product-detail-copy { position: static; }
  .dialog-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 94px; }
  .dialog-thumbs { display: flex; gap: 8px; padding: 8px; overflow-x: auto; overflow-y: hidden; border-top: 1px solid var(--rule); border-left: 0; }
  .dialog-thumbs .gallery-thumb { flex: 0 0 72px; width: 72px; margin: 0; }
}

@media (max-width: 420px) {
  .language-trigger { min-width: 48px; }
  .language-trigger span:last-child { display: none; }
  .hero h1 { font-size: 2.25rem; }
  .hero-label { grid-template-columns: 1fr; gap: 8px; }
  .catalog-grid { grid-template-columns: 1fr; }
  .process-grid { grid-template-columns: 1fr; }
  .process-step, .process-step:nth-child(2) { border-right: 0; border-top: 1px solid #424648; padding-left: 0; }
  .process-step:first-child { border-top: 0; }
  .data-row { grid-template-columns: 110px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-duration: 0s !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
