/* KHT v15: product archive (archive-kht_product.php) and product page (single-kht_product.php).
   Layout classes (.catalog .item .detail .feat .chips) come from site.css; this file adds what only these pages have:
   chips as links, the gallery thumbs, the spec table printed by inc/spec-table.php, the after-sales block,
   the lightbox and the admin-only tools (product-detail.js and product-pdf-sync.js find them by class / data attribute). */

/* ---------- archive ---------- */
a.chip { display: inline-flex; align-items: center; }
a.chip:hover { color: var(--ink); }
.chip[aria-current="page"] { background: var(--ink); color: #fff; box-shadow: none; }
.chip[aria-current="page"] span { color: #a9a9b0; }
.catalog-list { padding-top: 0; }

/* ---------- product page ---------- */
.product-head { padding-bottom: clamp(48px, 7vw, 96px); }
.product-title h1 { margin-top: 8px; }
.detail .ph.detail-photo { cursor: zoom-in; }
.product-thumb-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 10px; }
.product-thumb-grid .thumb { position: relative; aspect-ratio: 1; background: #f4f4f2; border-radius: var(--r-sm); overflow: hidden; cursor: pointer; }
.product-thumb-grid .thumb img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; padding: 8%; }
.product-thumb-grid .thumb.active { box-shadow: inset 0 0 0 1px var(--ink); }
.product-content > * { margin: 18px 0 0; font-size: 15px; color: var(--ink-2); }
.product-content img { height: auto; }

/* spec table from inc/spec-table.php, drawn like the mockup's .spec: heading, table, then the source note under it.
   The note sits inside .kht-spec-head before the table; display: contents lets flex order move it below. */
.spec-holder .kht-spec { display: flex; flex-direction: column; padding-top: 0; }
.kht-spec-head { display: contents; }
.kht-spec-head h2 { order: 0; }
.kht-spec-scroll { order: 1; margin-top: 24px; overflow-x: auto; border-top: 1px solid var(--ink); }
.kht-spec-head p { order: 2; margin-top: 14px; font-size: 12.5px; color: var(--ink-3); max-width: 760px; }
.kht-spec-features { order: 3; }
.kht-spec-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.kht-spec-table th, .kht-spec-table td {
  padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: top; white-space: nowrap; font-weight: 400; color: var(--ink-2);
}
.kht-spec-table thead th { font-weight: 600; color: var(--ink); }
/* the row label stays in view while a wide table scrolls sideways */
.kht-spec-table th:first-child { position: sticky; left: 0; z-index: 1; background: var(--bg); }
.kht-spec-table tbody th[scope="row"] { white-space: normal; min-width: 200px; color: var(--ink); }
.kht-spec-th { display: block; }
.kht-spec-table tbody th small { display: block; color: var(--ink-3); font-size: 12px; }
.kht-spec-unit, .kht-spec-table td.kht-spec-unit { color: var(--ink-3); }
.kht-spec-group th { padding-top: 22px; font-weight: 600; color: var(--ink); border-bottom-color: var(--ink); }
.kht-spec-features { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(24px, 4vw, 56px); margin-top: 40px; }
.kht-spec-features h3 { font-size: 15px; }
.kht-spec-features ul { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line); font-size: 14px; }
.kht-spec-features li { padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.kht-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.others { padding-top: 0; }

/* after-sales facts: four quiet columns on a hairline */
.after-sales-proof { padding-top: 0; }
.after-sales-proof .wrap { border-top: 1px solid var(--line); padding-top: clamp(48px, 7vw, 88px); }
.asp-title { margin-top: 10px; }
.asp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 32px 24px; margin-top: 36px; }
.asp-item { display: flex; flex-direction: column; gap: 6px; }
.asp-item h3 { font-size: 15px; }
.asp-item p { font-size: 14px; flex: 1; }
.asp-item a { margin-top: 8px; font-size: 14px; }
.asp-item a:hover .arrow { transform: translateX(3px); color: var(--ink); }

/* ---------- lightbox (product-detail.js toggles .is-open) ---------- */
.product-lightbox { position: fixed; inset: 0; z-index: 100000; display: none; align-items: center; justify-content: center; padding: 48px; background: rgba(23,23,26,.55); backdrop-filter: blur(6px); }
.product-lightbox.is-open { display: flex; }
.product-lightbox img { max-width: min(1100px, 92vw); max-height: 86vh; object-fit: contain; background: #f4f4f2; border-radius: var(--r-lg); padding: 24px; }
.product-lightbox-close, .product-lightbox-nav {
  position: absolute; width: 40px; height: 40px; border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(255,255,255,.92); box-shadow: var(--shadow); color: var(--ink); font-size: 22px; line-height: 1;
}
.product-lightbox-close { top: 18px; right: 18px; }
.product-lightbox-nav { top: 50%; translate: 0 -50%; }
.product-lightbox-nav.prev { left: 18px; }
.product-lightbox-nav.next { right: 18px; }
body.product-lightbox-open { overflow: hidden; }

/* ---------- admin-only tools (inside current_user_can checks), kept plain ---------- */
.kht-admin-image-slot { position: relative; }
.kht-front-image-upload {
  position: absolute; left: 8px; bottom: 8px; z-index: 5; max-width: calc(100% - 16px);
  border: 0; border-radius: 999px; padding: 5px 10px; cursor: pointer;
  background: var(--ink); color: #fff; font: inherit; font-size: 11px; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kht-product-image-delete { position: absolute; right: 6px; top: 6px; z-index: 6; border: 0; border-radius: 999px; padding: 4px 9px; background: #b00020; color: #fff; font: inherit; font-size: 11px; cursor: pointer; }
.kht-product-image-delete:disabled { opacity: .7; cursor: wait; }
.pdf-sync-panel, .kht-product-admin-panel, .kht-product-admin-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pdf-sync-panel { margin-top: 20px; }
.kht-product-admin-panel { justify-content: space-between; margin-bottom: 24px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: var(--r-sm); font-size: 13px; }
.kht-product-admin-panel strong { display: block; font-weight: 600; }
.kht-product-admin-panel span, .pdf-sync-help, .pdf-sync-status { color: var(--ink-3); font-size: 12px; }
.pdf-sync-status.is-error { color: #b00020; }
.pdf-sync-btn, .product-text-edit-btn, .kht-product-admin-link {
  display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); font: inherit; font-size: 12.5px;
}
.pdf-sync-btn:disabled { opacity: .65; cursor: wait; }
.product-title .product-text-edit-btn { margin-top: 10px; }
.product-text-modal { position: fixed; inset: 0; z-index: 100001; display: none; align-items: center; justify-content: center; padding: 24px; background: rgba(23,23,26,.55); }
.product-text-modal.is-open { display: flex; }
.product-text-panel { width: min(760px, 100%); max-height: 92vh; overflow: auto; background: #fff; border-radius: var(--r-md); padding: 22px; box-shadow: var(--shadow); }
.product-text-panel h3 { margin: 0 0 12px; }
.product-text-panel label { display: block; margin: 12px 0; font-size: 14px; font-weight: 500; }
.product-text-panel small { font-weight: 400; color: var(--ink-3); }
.product-text-panel input, .product-text-panel textarea { width: 100%; margin-top: 6px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); font: inherit; font-size: 15px; }
.product-text-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.product-text-actions button { height: 36px; padding: 0 16px; border: 0; border-radius: 999px; cursor: pointer; font: inherit; font-size: 14px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.product-text-actions [data-product-text-save] { background: var(--ink); color: #fff; box-shadow: none; }
.product-text-status { color: #b00020; margin: 10px 0 0; }

/* a long feature list makes the text column much taller than the photo: keep the photo in view beside it */
@media (min-width: 901px) { .product-gallery { position: sticky; top: 88px; } }
@media (max-width: 900px) {
  .asp-grid { grid-template-columns: repeat(2, 1fr); }
  .kht-spec-features { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .asp-grid { grid-template-columns: 1fr; }
  .kht-spec-table tbody th[scope="row"] { min-width: 150px; }
  .product-lightbox { padding: 16px; }
  .product-lightbox img { padding: 12px; }
}
