/*
 * NepalTechHub — Phase 28C Single + Archive UI hardening
 * 2026-09-08
 *
 * Purpose:
 * - close the image/layout gaps left by the three legacy single-template
 *   families (phones, laptops, TVs) without rewriting their PHP templates;
 * - keep all product imagery containment-first (never crop to fill);
 * - normalize archive chrome around the existing truth-safe Neo card renderer;
 * - add only restrained pointer/focus motion, with reduced-motion and touch
 *   safeguards.
 *
 * No data, price, seller, affiliate, tracking or Commerce behavior lives here.
 */

/* =========================================================
 * 1. Canonical presentation aliases
 * =======================================================*/
body.nth-single-product-ui-v21c1,
body:is(
  .post-type-archive-phones,.post-type-archive-laptops,.post-type-archive-tablets,
  .post-type-archive-tvs,.post-type-archive-earbuds,.post-type-archive-headphones,
  .post-type-archive-speakers,.post-type-archive-smartwatches,.post-type-archive-cameras,
  .post-type-archive-refrigerators,.post-type-archive-washing_machines,
  .post-type-archive-air_conditioners,.tax-brand,.tax-chipset,.tax-price_band
){
  --nth28c-surface:var(--nth-color-surface,var(--card,#fff));
  --nth28c-bg:var(--nth-color-bg,var(--bg,#f8fafc));
  --nth28c-text:var(--nth-color-text,var(--ink,#0f172a));
  --nth28c-muted:var(--nth-color-muted,var(--muted,#64748b));
  --nth28c-line:var(--nth-color-border,var(--border,#e2e8f0));
  --nth28c-brand:var(--nth-color-brand,var(--brand,#1d4ed8));
  --nth28c-brand-strong:var(--nth-color-brand-strong,var(--brand-dark,#1e40af));
  --nth28c-success:var(--nth-color-success,#059669);
  --nth28c-radius:var(--nth-radius-xl,18px);
  --nth28c-shadow:var(--nth-shadow-raised,0 10px 28px rgba(15,23,42,.06));
  --nth28c-focus:var(--nth-focus-ring-color,rgba(37,99,235,.22));
}

/* =========================================================
 * 2. Single pages — shell + the three legacy hero families
 * =======================================================*/
body.nth-single-product-ui-v21c1 :where(.nth-phone-wrap,.nth-laptop-wrap,.nth-tv-page .nth-wrap,.nth-wrap){
  min-width:0;
  max-width:var(--nth-container-max,var(--container,1400px));
  box-sizing:border-box;
}

/* Phase 21C already normalizes generic .nth-hero. Phones/laptops use special
 * media wrappers and TVs use an entirely special hero namespace, so bridge
 * those exact gaps here rather than duplicating the whole single-page system. */
body.nth-single-product-ui-v21c1 :where(.nth-phone-hero,.nth-laptop-hero,.nth-tv-hero){
  min-width:0;
  max-width:100%;
  border:1px solid var(--nth28c-line)!important;
  border-radius:20px!important;
  background:linear-gradient(145deg,#f8fbff 0%,#fff 56%,#f8fafc 100%)!important;
  box-shadow:var(--nth28c-shadow)!important;
  overflow:hidden;
}

@media (min-width:920px){
  body.nth-single-product-ui-v21c1 .nth-phone-hero{
    grid-template-columns:minmax(280px,340px) minmax(0,1fr)!important;
  }
  body.nth-single-product-ui-v21c1 .nth-laptop-hero{
    grid-template-columns:minmax(290px,350px) minmax(0,1fr)!important;
  }
  body.nth-single-product-ui-v21c1 .nth-tv-hero{
    display:grid!important;
    grid-template-columns:minmax(320px,400px) minmax(0,1fr)!important;
    align-items:start!important;
    gap:clamp(22px,3vw,40px)!important;
    padding:clamp(22px,2.8vw,34px)!important;
  }
}

body.nth-single-product-ui-v21c1 :where(.nth-phone-img-col,.nth-laptop-img-col,.nth-tv-media-card){
  min-width:0;
  width:100%;
  margin:0!important;
  box-sizing:border-box;
}

/* Main image wells: stable height, complete image, no crop/zoom. */
body.nth-single-product-ui-v21c1 :where(.nth-phone-thumb,.nth-laptop-thumb,.nth-tv-media-frame){
  position:relative;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  width:100%!important;
  min-width:0!important;
  min-height:0!important;
  max-height:360px!important;
  aspect-ratio:4/3!important;
  padding:clamp(10px,1.3vw,16px)!important;
  box-sizing:border-box!important;
  overflow:hidden!important;
  border:1px solid var(--nth28c-line)!important;
  border-radius:15px!important;
  background:linear-gradient(180deg,#fff,#f8fafc)!important;
}
body.nth-single-product-ui-v21c1 .nth-tv-media-frame{
  aspect-ratio:16/10!important;
}

body.nth-single-product-ui-v21c1 :where(.nth-phone-thumb,.nth-laptop-thumb,.nth-tv-media-frame) img{
  display:block!important;
  width:100%!important;
  height:100%!important;
  max-width:100%!important;
  max-height:100%!important;
  margin:auto!important;
  padding:0!important;
  box-sizing:border-box!important;
  object-fit:contain!important;
  object-position:center!important;
  transform:none!important;
  background:transparent!important;
}

/* Small gallery thumbnails should show the whole object too. */
body.nth-single-product-ui-v21c1 :where(.nth-phone-thumbs,.nth-laptop-thumbs){
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  min-width:0;
}
body.nth-single-product-ui-v21c1 :where(.nth-phone-thumbs,.nth-laptop-thumbs) .nth-thumb-btn{
  flex:0 0 66px;
  width:66px!important;
  height:58px!important;
  min-height:44px!important;
  padding:4px!important;
  border:1px solid var(--nth28c-line)!important;
  border-radius:10px!important;
  background:var(--nth28c-surface)!important;
  overflow:hidden;
}
body.nth-single-product-ui-v21c1 :where(.nth-phone-thumbs,.nth-laptop-thumbs) .nth-thumb-btn img{
  width:100%!important;height:100%!important;object-fit:contain!important;object-position:center!important;transform:none!important;
}

/* TV template bridge: map its prefixed UI into the shared Phase 21C visual
 * hierarchy without touching its data or markup. */
body.nth-single-product-ui-v21c1 .nth-tv-title{
  margin:0!important;
  color:var(--nth28c-text)!important;
  font-size:clamp(27px,3.5vw,36px)!important;
  line-height:1.14!important;
  letter-spacing:-.025em!important;
  overflow-wrap:anywhere;
}
body.nth-single-product-ui-v21c1 .nth-tv-sub{
  color:var(--nth28c-muted)!important;
  font-size:14px!important;
  line-height:1.65!important;
}
body.nth-single-product-ui-v21c1 .nth-tv-meta{
  display:flex;
  flex-wrap:wrap;
  gap:8px!important;
  min-width:0;
}
body.nth-single-product-ui-v21c1 .nth-tv-price-strip{
  display:grid!important;
  grid-template-columns:repeat(auto-fit,minmax(160px,1fr))!important;
  gap:10px!important;
  margin-top:16px!important;
}
body.nth-single-product-ui-v21c1 .nth-tv-price-card{
  min-width:0;
  border-color:var(--nth28c-line)!important;
  border-radius:14px!important;
  background:var(--nth28c-surface)!important;
  box-shadow:0 4px 14px rgba(15,23,42,.04)!important;
}
body.nth-single-product-ui-v21c1 .nth-tv-price-card .value{
  font-variant-numeric:tabular-nums;
}
body.nth-single-product-ui-v21c1 .nth-tv-action-row{
  display:flex!important;
  flex-wrap:wrap!important;
  gap:9px!important;
  margin-top:14px!important;
}
body.nth-single-product-ui-v21c1 .nth-tv-btn{
  min-height:44px!important;
  display:inline-flex!important;
  align-items:center!important;
  justify-content:center!important;
  box-sizing:border-box!important;
}
body.nth-single-product-ui-v21c1 .nth-tv-sec{
  min-width:0;
  max-width:100%;
  margin:18px 0!important;
  padding:20px!important;
  border:1px solid var(--nth28c-line)!important;
  border-radius:var(--nth28c-radius)!important;
  background:var(--nth28c-surface)!important;
  box-shadow:0 1px 2px rgba(15,23,42,.02)!important;
  scroll-margin-top:104px;
}
body.nth-single-product-ui-v21c1 .nth-tv-sec > h2{
  margin:0 0 14px!important;
  color:var(--nth28c-text)!important;
  font-size:clamp(19px,2vw,24px)!important;
  line-height:1.25!important;
  letter-spacing:-.015em!important;
}
body.nth-single-product-ui-v21c1 .nth-tv-card{
  border-color:var(--nth28c-line)!important;
  border-radius:16px!important;
  background:var(--nth28c-surface)!important;
  box-shadow:0 4px 16px rgba(15,23,42,.035)!important;
}

/* =========================================================
 * 3. Single galleries + related images — explicit no-crop safety
 * =======================================================*/
body.nth-single-product-ui-v21c1 :where(.nth-gallery,.nth-tv-gallery,.nth-gallery-grid,.nth21c4-gallery) img{
  max-width:100%!important;
  object-fit:contain!important;
  object-position:center!important;
  transform:none!important;
}
body.nth-single-product-ui-v21c1 :where(.nth-gallery,.nth-tv-gallery) > img{
  width:100%!important;
  height:auto!important;
  aspect-ratio:4/3;
  padding:10px!important;
  box-sizing:border-box!important;
  border:1px solid var(--nth28c-line)!important;
  border-radius:14px!important;
  background:var(--nth28c-surface)!important;
}
body.nth-single-product-ui-v21c1 :where(.nth-related-thumb,.nth-tv-related-thumb,.nth-related-img){
  min-height:0;
  overflow:hidden;
  background:var(--nth28c-bg);
}
body.nth-single-product-ui-v21c1 :where(.nth-related-thumb,.nth-tv-related-thumb,.nth-related-img) img{
  width:100%!important;
  height:100%!important;
  object-fit:contain!important;
  object-position:center!important;
  transform:none!important;
}
body.nth-single-product-ui-v21c1 :where(.nth-related-price,.nth-tv-related-price,.nth-price-value,.nth-price-main,.nth-wtb-price,.nth-emi-amount){
  font-variant-numeric:tabular-nums;
}

/* Long model/SKU/spec strings must wrap instead of widening the page. */
body.nth-single-product-ui-v21c1 :where(.nth-table,.nth-tv-table,.nth-spec-table) :where(th,td),
body.nth-single-product-ui-v21c1 :where(.nth-related-body,.nth-tv-related-body,.nth-wtb-row) :where(h3,h4,p,span,a){
  overflow-wrap:anywhere;
  word-break:normal;
}

/* Existing phone/laptop sticky actions: preserve safe-area clearance. */
body.nth-single-product-ui-v21c1 .nth-sticky{
  padding-bottom:max(10px,env(safe-area-inset-bottom,0px));
}

/* =========================================================
 * 4. Archives — normalize two header/filter families
 * =======================================================*/
body:is(
  .post-type-archive-phones,.post-type-archive-laptops,.post-type-archive-tablets,
  .post-type-archive-tvs,.post-type-archive-earbuds,.post-type-archive-headphones,
  .post-type-archive-speakers,.post-type-archive-smartwatches,.post-type-archive-cameras,
  .post-type-archive-refrigerators,.post-type-archive-washing_machines,
  .post-type-archive-air_conditioners
) :is(main[id^="nth-"],main.nth-archive-page){
  width:min(100%,var(--nth-container-max,var(--container,1400px)));
  max-width:var(--nth-container-max,var(--container,1400px));
  min-width:0;
  margin:clamp(14px,2vw,24px) auto 48px;
  padding-inline:clamp(12px,1.7vw,20px);
  box-sizing:border-box;
}

body:is(
  .post-type-archive-phones,.post-type-archive-tablets,.post-type-archive-earbuds,
  .post-type-archive-headphones,.post-type-archive-speakers,.post-type-archive-smartwatches,
  .post-type-archive-cameras
) .nth-hero,
body:is(
  .post-type-archive-laptops,.post-type-archive-tvs,.post-type-archive-refrigerators,
  .post-type-archive-washing_machines,.post-type-archive-air_conditioners
) .nth-archive-header{
  min-width:0;
  padding:clamp(18px,2vw,26px)!important;
  border:1px solid var(--nth28c-line)!important;
  border-radius:var(--nth28c-radius)!important;
  background:linear-gradient(135deg,#fff,#f7faff)!important;
  box-shadow:0 5px 18px rgba(15,23,42,.04)!important;
}

body:is(
  .post-type-archive-phones,.post-type-archive-laptops,.post-type-archive-tablets,
  .post-type-archive-tvs,.post-type-archive-earbuds,.post-type-archive-headphones,
  .post-type-archive-speakers,.post-type-archive-smartwatches,.post-type-archive-cameras,
  .post-type-archive-refrigerators,.post-type-archive-washing_machines,
  .post-type-archive-air_conditioners
) :is(.nth-toolbar,.nth-filter-panel,.nth-brand-box,.nth-seo-intro,.nth-faq){
  min-width:0;
  max-width:100%;
  border-color:var(--nth28c-line)!important;
  border-radius:var(--nth28c-radius)!important;
  background:var(--nth28c-surface)!important;
  box-shadow:0 4px 16px rgba(15,23,42,.035)!important;
}

body:is(
  .post-type-archive-phones,.post-type-archive-laptops,.post-type-archive-tablets,
  .post-type-archive-tvs,.post-type-archive-earbuds,.post-type-archive-headphones,
  .post-type-archive-speakers,.post-type-archive-smartwatches,.post-type-archive-cameras,
  .post-type-archive-refrigerators,.post-type-archive-washing_machines,
  .post-type-archive-air_conditioners
) :is(.nth-toolbar input,.nth-toolbar select,.nth-toolbar button,.nth-filter-panel input,.nth-filter-panel select,.nth-filter-panel button,.nth-pill,.nth-tag){
  min-height:42px;
  box-sizing:border-box;
}

body:is(
  .post-type-archive-phones,.post-type-archive-laptops,.post-type-archive-tablets,
  .post-type-archive-tvs,.post-type-archive-earbuds,.post-type-archive-headphones,
  .post-type-archive-speakers,.post-type-archive-smartwatches,.post-type-archive-cameras,
  .post-type-archive-refrigerators,.post-type-archive-washing_machines,
  .post-type-archive-air_conditioners
) :where(.nth-brand-pills,.nth-tags,.nth-band-links){
  max-width:100%;
}

/* All 12 archives render the shared Neo cards. Keep WordPress responsive
 * images intact, shorten only the desktop media well, and never zoom/crop. */
body:is(
  .post-type-archive-phones,.post-type-archive-laptops,.post-type-archive-tablets,
  .post-type-archive-tvs,.post-type-archive-earbuds,.post-type-archive-headphones,
  .post-type-archive-speakers,.post-type-archive-smartwatches,.post-type-archive-cameras,
  .post-type-archive-refrigerators,.post-type-archive-washing_machines,
  .post-type-archive-air_conditioners,.tax-brand,.tax-chipset,.tax-price_band
) .nth-neo-card .nth-neo-media{
  min-height:0!important;
  overflow:hidden!important;
  background:linear-gradient(145deg,#fff,#f8fafc)!important;
}
@media (min-width:1100px){
  body:is(
    .post-type-archive-phones,.post-type-archive-laptops,.post-type-archive-tablets,
    .post-type-archive-tvs,.post-type-archive-earbuds,.post-type-archive-headphones,
    .post-type-archive-speakers,.post-type-archive-smartwatches,.post-type-archive-cameras,
    .post-type-archive-refrigerators,.post-type-archive-washing_machines,
    .post-type-archive-air_conditioners,.tax-brand,.tax-chipset,.tax-price_band
  ) .nth-neo-card .nth-neo-media{aspect-ratio:16/11!important}
}
body:is(
  .post-type-archive-phones,.post-type-archive-laptops,.post-type-archive-tablets,
  .post-type-archive-tvs,.post-type-archive-earbuds,.post-type-archive-headphones,
  .post-type-archive-speakers,.post-type-archive-smartwatches,.post-type-archive-cameras,
  .post-type-archive-refrigerators,.post-type-archive-washing_machines,
  .post-type-archive-air_conditioners,.tax-brand,.tax-chipset,.tax-price_band
) .nth-neo-card .nth-neo-media img{
  width:100%!important;
  height:100%!important;
  max-width:100%!important;
  max-height:100%!important;
  object-fit:contain!important;
  object-position:center!important;
  transform:none!important;
}

/* =========================================================
 * 5. Focus + restrained motion
 * =======================================================*/
body.nth-single-product-ui-v21c1 :where(a,button,input,select,summary):focus-visible,
body:is(
  .post-type-archive-phones,.post-type-archive-laptops,.post-type-archive-tablets,
  .post-type-archive-tvs,.post-type-archive-earbuds,.post-type-archive-headphones,
  .post-type-archive-speakers,.post-type-archive-smartwatches,.post-type-archive-cameras,
  .post-type-archive-refrigerators,.post-type-archive-washing_machines,
  .post-type-archive-air_conditioners
) :where(a,button,input,select,summary):focus-visible{
  outline:3px solid var(--nth28c-focus)!important;
  outline-offset:3px;
}

@media (hover:hover) and (pointer:fine) and (prefers-reduced-motion:no-preference){
  body.nth-single-product-ui-v21c1 :where(.nth-tv-btn,.nth-action-btn,.nth-btn,.nth-share-btn){
    transition:transform var(--nth-motion-fast,.18s ease),box-shadow var(--nth-motion-fast,.18s ease),border-color var(--nth-motion-fast,.18s ease),background-color var(--nth-motion-fast,.18s ease);
  }
  body.nth-single-product-ui-v21c1 :where(.nth-tv-btn,.nth-action-btn,.nth-btn,.nth-share-btn):hover{
    transform:translateY(-1px);
  }
  body.nth-single-product-ui-v21c1 :where(.nth-related-card,.nth-tv-related-card){
    transition:transform var(--nth-motion-base,.22s ease),box-shadow var(--nth-motion-base,.22s ease),border-color var(--nth-motion-base,.22s ease);
  }
  body.nth-single-product-ui-v21c1 :where(.nth-related-card,.nth-tv-related-card):hover{
    transform:translateY(-2px);
    box-shadow:0 10px 24px rgba(15,23,42,.075);
    border-color:#cbd5e1;
  }
}

/* =========================================================
 * 6. Mobile closeout
 * =======================================================*/
@media (max-width:767px){
  body.nth-single-product-ui-v21c1 :where(.nth-phone-hero,.nth-laptop-hero,.nth-tv-hero){
    grid-template-columns:minmax(0,1fr)!important;
    padding:14px!important;
    gap:14px!important;
  }
  body.nth-single-product-ui-v21c1 :where(.nth-phone-thumb,.nth-laptop-thumb,.nth-tv-media-frame){
    max-height:none!important;
    aspect-ratio:4/3!important;
  }
  body.nth-single-product-ui-v21c1 .nth-tv-media-frame{aspect-ratio:16/10!important}
  body.nth-single-product-ui-v21c1 .nth-tv-title{font-size:clamp(23px,7vw,28px)!important}
  body.nth-single-product-ui-v21c1 .nth-tv-sec{padding:15px!important;margin:14px 0!important}
  body.nth-single-product-ui-v21c1 .nth-tv-action-row{
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:7px!important;
  }
  body.nth-single-product-ui-v21c1 .nth-tv-action-row .nth-tv-btn{width:100%!important;min-width:0!important}

  body:is(
    .post-type-archive-phones,.post-type-archive-laptops,.post-type-archive-tablets,
    .post-type-archive-tvs,.post-type-archive-earbuds,.post-type-archive-headphones,
    .post-type-archive-speakers,.post-type-archive-smartwatches,.post-type-archive-cameras,
    .post-type-archive-refrigerators,.post-type-archive-washing_machines,
    .post-type-archive-air_conditioners
  ) :is(main[id^="nth-"],main.nth-archive-page){
    margin-top:12px;
    padding-inline:12px;
  }
  body:is(
    .post-type-archive-phones,.post-type-archive-laptops,.post-type-archive-tablets,
    .post-type-archive-tvs,.post-type-archive-earbuds,.post-type-archive-headphones,
    .post-type-archive-speakers,.post-type-archive-smartwatches,.post-type-archive-cameras,
    .post-type-archive-refrigerators,.post-type-archive-washing_machines,
    .post-type-archive-air_conditioners
  ) :is(.nth-toolbar-form,.nth-filter-form){
    grid-template-columns:minmax(0,1fr)!important;
  }
}

@media (max-width:390px){
  body.nth-single-product-ui-v21c1 :where(.nth-phone-thumbs,.nth-laptop-thumbs) .nth-thumb-btn{
    flex-basis:58px;width:58px!important;height:54px!important;
  }
  body.nth-single-product-ui-v21c1 .nth-tv-price-strip,
  body.nth-single-product-ui-v21c1 .nth-tv-action-row{
    grid-template-columns:minmax(0,1fr)!important;
  }
}

/* Touch/coarse pointers must never keep a hover transform after a tap. */
@media (hover:none),(pointer:coarse){
  body.nth-single-product-ui-v21c1 :where(.nth-related-card,.nth-tv-related-card,.nth-tv-btn,.nth-action-btn,.nth-btn,.nth-share-btn),
  body:is(
    .post-type-archive-phones,.post-type-archive-laptops,.post-type-archive-tablets,
    .post-type-archive-tvs,.post-type-archive-earbuds,.post-type-archive-headphones,
    .post-type-archive-speakers,.post-type-archive-smartwatches,.post-type-archive-cameras,
    .post-type-archive-refrigerators,.post-type-archive-washing_machines,
    .post-type-archive-air_conditioners
  ) .nth-neo-card{
    transform:none!important;
  }
}

@media (prefers-reduced-motion:reduce){
  body.nth-single-product-ui-v21c1 :where(.nth-related-card,.nth-tv-related-card,.nth-tv-btn,.nth-action-btn,.nth-btn,.nth-share-btn),
  body:is(
    .post-type-archive-phones,.post-type-archive-laptops,.post-type-archive-tablets,
    .post-type-archive-tvs,.post-type-archive-earbuds,.post-type-archive-headphones,
    .post-type-archive-speakers,.post-type-archive-smartwatches,.post-type-archive-cameras,
    .post-type-archive-refrigerators,.post-type-archive-washing_machines,
    .post-type-archive-air_conditioners
  ) .nth-neo-card{
    transition:none!important;
    transform:none!important;
  }
}
