/* =====================================================================
   Kakobuy Journal — mobile adaptation layer
   PC remains the master design; every rule below is scoped to phones/
   small tablets and only adjusts presentation, never information.
   ===================================================================== */

/* Mobile-only elements must never render in the desktop/master design */
.mbar { display: none; }

@media (max-width: 820px) {
  :root { --safe-b: env(safe-area-inset-bottom, 0px); }

  /* ---------- Header: keep a usable search entry on mobile ---------- */
  .hd-in { gap: 10px; padding: 8px 0 0; }
  .hd .brand { padding: 6px 0; font-size: 17px; }
  .hd-tools { display: flex; margin-left: auto; align-items: center; }
  .hd-tools .btn.ghost {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 40px; padding: 0 16px; font-size: 14px;
  }
  .hd nav.nav {
    gap: 18px; margin-top: 8px; padding: 6px 0 10px; min-width: 0; flex: 1 1 auto;
    -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
  }
  .hd nav.nav a { padding: 8px 0; scroll-snap-align: start; flex: 0 0 auto; }

  /* ---------- Generic content rhythm ---------- */
  .wrap { width: calc(100% - 24px); }
  main { padding-left: 12px !important; padding-right: 12px !important; }
  .pdgrid { gap: 14px; }
  .pdcrumb { margin-bottom: 10px; line-height: 1.55; }
  .pdsec { padding-top: 20px; }

  /* grid children must allow long product names to wrap, never overflow */
  .pdgrid > div, .pdh1, .pddesc li, .pddesc-v { min-width: 0; }

  /* ---------- Home hero grid: stop intrinsic-width blowout ---------- */
  .wrap.hg { grid-template-columns: minmax(0, 1fr); width: 100%; }
  .wrap.hg > * { min-width: 0; width: 100%; max-width: 100%; }
  .hsearch { width: 100%; flex-wrap: nowrap; }
  .hsearch input { min-width: 0; width: 100%; flex: 1 1 auto; }
  .hsearch button { flex: 0 0 auto; }
  .qjump { flex-wrap: wrap; gap: 8px; }

  /* Category grid: equal, shrinkable columns (the "coming soon" card
     otherwise keeps its intrinsic width and forces page overflow) */
  .cats, .cat6 .cats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cat { min-width: 0; }
  .cat .ctt, .cat .cat-n, .cat .cat-c, .cat span { min-width: 0; max-width: 100%; }
  /* compact home category cards: let the long count line wrap instead of
     holding its intrinsic width and forcing the two-column grid to overflow */
  .cat6 .cat { padding: 10px 12px; gap: 8px; }
  .cat6 .ctt { flex: 1 1 auto; min-width: 0; }
  .cat6 .ctt > span { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }

  /* Home brand quick-jump cells: shrinkable columns so long brand names
     cannot force the two-column strip past a narrow viewport */
  .brands { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bcell { min-width: 0; }
  .bcell .bn, .bcell .bc { min-width: 0; max-width: 100%; }

  /* Home editor's picks: shrinkable cards; the two action links must wrap
     rather than push the narrow card past a 280-320px viewport */
  .picks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pcard, .pbody, .pacts { min-width: 0; }
  .pacts { flex-wrap: wrap; row-gap: 6px; }
  .pbtn, .pghost { min-width: 0; }

  /* ---------- Product gallery: portrait-friendly frame ---------- */
  .gmain { aspect-ratio: 4 / 5; }
  .gmain img { object-fit: contain; }
  /* thumbnail strip: on narrow phones the full set of thumbs cannot fit,
     so make it a horizontally scrollable rail instead of an overflowing grid */
  .thumbs {
    display: flex; flex-wrap: nowrap; overflow-x: auto;
    gap: 6px; margin-top: 8px; padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .thumb { flex: 0 0 68px; width: 68px; min-width: 68px; height: 68px; aspect-ratio: 1 / 1; }

  /* ---------- Product typography ---------- */
  .pdh1 { font-size: 22px; line-height: 1.32; margin: 8px 0; }
  .pdpr { font-size: 22px; }
  .pddesc { margin: 16px 0 4px; }
  .pddesc li, .pddesc .pddesc-v, .pddesc .pddesc-f { font-size: 14.5px; line-height: 1.7; }

  /* ---------- Order block: large touch targets ---------- */
  .pdbuy { margin-top: 16px; }
  .ags { gap: 8px; }
  .ag { min-height: 48px; padding: 10px 6px; }
  .ags.solo { max-width: 100%; }
  .morebtn {
    width: 100%; min-height: 44px; margin-top: 10px;
    display: inline-flex; align-items: center; justify-content: center; font-size: 14px;
  }

  /* ---------- QC / recommendation sections ---------- */
  .qcl li { font-size: 14.5px; line-height: 1.8; }
  .pdrec { gap: 10px; }
  .pdrec .rt { font-size: 13px; }

  /* ---------- Mobile sticky order bar (product pages only) ---------- */
  .mbar {
    display: flex; align-items: center; gap: 12px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    padding: 10px 12px calc(10px + var(--safe-b));
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 14px rgba(20, 22, 26, 0.08);
  }
  .mbar-price { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .mbar-btn {
    flex: 1; min-height: 48px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--ink); color: #fff; font-size: 15px; font-weight: 600; border-radius: 3px;
  }
  .mbar-btn:active { background: var(--red); }
  /* keep the bar from covering footer content */
  body.has-mbar { padding-bottom: calc(72px + var(--safe-b)); }

  /* ---------- Footer ---------- */
  .foot { padding-bottom: calc(28px + var(--safe-b)); }

  /* ---------- Landed-cost calculator: shrink fixed panels ---------- */
  .lc2 { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .panel { width: 100%; max-width: 100%; box-sizing: border-box; padding: 18px 16px; }
  .panel h2 { font-size: 15px; }
  .irow, .field, .itemrows { min-width: 0; max-width: 100%; }
  .irow { flex-wrap: nowrap; gap: 8px; }
  .irow input, .field input, .field select {
    min-width: 0; width: 100%; max-width: 100%; flex: 1 1 auto;
  }
  .irow button { flex: 0 0 auto; }
  .addbtn { width: 100%; min-height: 44px; }
  .resline, .total, .regime, .note2 { min-width: 0; max-width: 100%; }
  .two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  .hd .brand { font-size: 16px; }
  .pdh1 { font-size: 20px; }
  .thumbs { gap: 5px; }
  .mbar-price { font-size: 16px; }
}

/* Respect users who prefer reduced motion; disable the sticky blur cost */
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .hd { backdrop-filter: none; }
  .pdLB-track { transition: none !important; }
}

/* Intermediate desktop (small laptops / large tablets in landscape):
   the fixed 400px New Arrivals sidebar overflows the hero grid below ~1190px.
   Narrow the panel and let both tracks shrink instead of forcing page width. */
@media (min-width: 960px) and (max-width: 1180px) {
  .hg { grid-template-columns: minmax(0, 1fr) minmax(0, 320px); gap: 28px; }
  .lpanel { min-width: 0; }
  .lhead, .lwrap, .lnote { min-width: 0; }
  .lrow { grid-template-columns: 40px minmax(0, 1fr) 56px; }
}

/* =====================================================================
   Product image lightbox — full-screen detail viewer.
   Base styles apply at every breakpoint; mobile tweaks are scoped below.
   ===================================================================== */
.gmain { position: relative; cursor: zoom-in; }
.gmain img { cursor: zoom-in; }

/* Tappable "expand" affordance so the gesture is discoverable */
.gzoom {
  position: absolute; right: 10px; bottom: 10px;
  width: 38px; height: 38px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%;
  background: rgba(20, 22, 26, 0.62); color: #fff;
  cursor: pointer;
}
.gzoom svg { width: 18px; height: 18px; }

.pdLB {
  position: fixed; inset: 0; z-index: 1000;
  background: #0e0f11;
  display: flex; flex-direction: column;
}
.pdLB[hidden] { display: none; }

.pdLB-top {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  color: #fff;
}
.pdLB-count { font-size: 13.5px; letter-spacing: .4px; color: #d8d9db; }
.pdLB-close {
  flex: 0 0 auto;
  width: 44px; height: 44px; padding: 0;
  border: 0; background: transparent; color: #fff;
  font-size: 30px; line-height: 1; cursor: pointer;
}

.pdLB-vp { flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden; }
.pdLB-track {
  display: flex; height: 100%;
  transition: transform .26s ease;
  will-change: transform; touch-action: none;
}
.pdLB-slide {
  flex: 0 0 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 4px 12px; box-sizing: border-box;
}
.pdLB-slide img {
  max-width: 100%; max-height: 100%;
  object-fit: contain; user-select: none; -webkit-user-drag: none;
}

.pdLB-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 46px; height: 46px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.14); color: #fff;
  font-size: 30px; line-height: 1; cursor: pointer; z-index: 2;
}
.pdLB-nav.prev { left: max(10px, env(safe-area-inset-left, 0px)); }
.pdLB-nav.next { right: max(10px, env(safe-area-inset-right, 0px)); }
.pdLB-nav:disabled { opacity: .28; cursor: default; }

body.lb-open { overflow: hidden; }

/* Visible but refined keyboard focus ring for every lightbox control */
.gzoom:focus-visible,
.pdLB-close:focus-visible,
.pdLB-nav:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.75);
  outline-offset: 2px;
}
.pdLB-nav:focus-visible { border-radius: 50%; }

/* On phones the on-screen arrows are secondary to swiping; keep them
   compact so they never cover the garment detail. */
@media (max-width: 820px) {
  .pdLB-nav { width: 40px; height: 40px; font-size: 26px; }
  .pdLB-slide { padding: 4px 8px; }
}

/* =====================================================================
   Desktop interaction layer — mouse-only, never applied to touch.
   Hovering the main image pans a magnified 900px view; clicking still
   opens the full lightbox. Gated by a real hover/fine pointer and the
   two-column desktop layout.
   ===================================================================== */
@media (hover: hover) and (pointer: fine) and (min-width: 880px) {
  .gmain.zooming { overflow: hidden; }
  .gmain.zooming img {
    transform: scale(2);
    transition: transform .16s ease;
    cursor: zoom-in;
  }
  .gmain.zooming.gm-active img { transition: transform .05s linear; }

  /* Thumbnails give an immediate hover cue before the click */
  .thumb:hover { border-color: var(--ink); }

  /* Slight emphasis on the expand affordance while the gallery is hovered */
  .gmain:hover .gzoom { background: rgba(20, 22, 26, 0.82); }
}

/* 2026-11-22 · mobile navigation: wrap all six entries onto two rows
   instead of clipping them at the right edge. Chips keep a 40px tap target. */
@media (max-width: 899px) {
  .hd .hd-in { flex-wrap: wrap; }
  .hd .hd-in nav.nav {
    flex: 0 0 100% !important; width: 100% !important; max-width: 100%;
    display: flex; flex-wrap: wrap !important; justify-content: flex-start !important;
    gap: 7px 10px; overflow: visible !important; white-space: normal;
    padding: 2px 0 8px; margin: 0 !important;
  }
  .hd .hd-in nav.nav a {
    flex: 0 0 auto; padding: 7px 11px; border: 1px solid var(--line);
    border-radius: 100px; background: #fff; color: var(--sub);
    font-size: 13px; font-weight: 600; line-height: 1.2; text-decoration: none;
  }
  .hd .hd-in nav.nav a:hover { color: var(--ink); }
}

/* Compact category pager on phones: keep Prev / pages / Next on one row. */
@media (max-width: 640px) {
  main .pager { gap: 5px; }
  main .pager a { padding: 6px 8px; font-size: 12.5px; }
}

/* Experimental guide template (header .wrap.nav) must wrap, not scroll-cut. */
@media (max-width: 899px) {
  header .wrap.nav nav {
    flex-wrap: wrap;
    overflow: visible;
    white-space: normal;
    mask-image: none;
    -webkit-mask-image: none;
    padding-right: 0;
    margin-right: 0;
    width: 100%;
    height: auto;
  }
  header .wrap.nav nav a { flex: 0 0 auto; }
}

/* Very narrow phones: smaller nav chips keep the six links on two rows. */
@media (max-width: 359px) {
  .hd nav.nav a { padding: 6px 10px; font-size: 13px; }
}
