/* ========== Public pages (catalog, product detail, inquiry) ==========
   Owned by the public package. Tokens come from base.css; gallery/lightbox/sticky CTA/counter live in
   public-gallery.css (P4b). Checked at 360px and 1280px: no horizontal page scroll (design Appendix A). */

/* ========== Public shell ========== */
.public-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.kk-skip-link {
  position: absolute;
  left: 0.75rem;
  top: -100px;
  z-index: 200;
  padding: 0.6rem 1rem;
  border-radius: var(--kk-radius-sm);
  background: var(--kk-ink);
  color: #fff;
  font-weight: 600;
}
.kk-skip-link:focus,
.kk-skip-link:focus-visible {
  top: 0.5rem;
  color: #fff;
  opacity: 1;
}
.pub-main:focus { outline: none; }

.pub-header {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--kk-header-h); /* F22: min-height, never a fixed box the content can spill out of */
  display: flex;
  align-items: center;
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  background: rgba(255, 252, 249, 0.82);
  border-bottom: 1px solid var(--kk-line);
}

.pub-header-inner {
  width: 100%;
  max-width: var(--kk-max);
  margin: 0 auto;
  padding: 0 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.04em;
  color: var(--kk-ink);
  white-space: nowrap;
  word-break: keep-all;
  min-width: 0;
}
.brand-mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--kk-gold), #d4a574);
  box-shadow: 0 0 0 3px var(--kk-gold-soft);
  align-self: center;
  flex: none;
}
.brand-sub {
  font-weight: 400;
  color: var(--kk-text-secondary);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pub-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
}
.pub-nav a {
  white-space: nowrap;
  word-break: keep-all;
}
.pub-nav .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pager .btn,
.category-filter .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pub-main {
  flex: 1;
  width: 100%;
  max-width: var(--kk-max);
  margin: 0 auto;
  padding: 1.5rem 1.1rem 4rem;
  min-width: 0;
}

.pub-footer {
  border-top: 1px solid var(--kk-line);
  background: rgba(255, 252, 249, 0.6);
  padding: 2rem 1.1rem;
  text-align: center;
}
.pub-footer .foot-brand {
  font-weight: 650;
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
}
.pub-footer .foot-note {
  font-size: 0.82rem;
  color: var(--kk-text-secondary);
  word-break: keep-all;
}

/* ========== Catalog hero / toolbar ========== */
.catalog-hero {
  margin-bottom: 1.25rem;
  padding: 0.25rem 0 0;
}
.catalog-hero h1 {
  font-size: clamp(1.65rem, 3.5vw, 2.15rem);
  font-weight: 680;
  letter-spacing: -0.035em;
  margin: 0 0 0.45rem;
}
.catalog-hero .lead-muted { word-break: keep-all; }

.catalog-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
  min-width: 0;
}
.search-bar {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  background: var(--kk-surface);
  border: 1px solid var(--kk-line);
  border-radius: var(--kk-radius);
  padding: 0.35rem;
  box-shadow: var(--kk-shadow);
  max-width: 520px;
  margin: 0;
}
.search-bar input {
  flex: 1;
  min-width: 0;
  border: none;
  box-shadow: none;
  min-height: var(--kk-touch); /* F71 */
  background: transparent;
  padding: 0 0.85rem;
  color: var(--kk-text);
  border-radius: 12px;
}
.search-bar input:focus { outline: none; }
.search-bar:focus-within {
  border-color: var(--kk-gold);
  box-shadow: 0 0 0 3px var(--kk-gold-soft);
}
.search-bar .btn {
  border-radius: 12px;
  min-height: var(--kk-touch); /* F71 */
  padding-inline: 1.25rem;
  flex: none;
}

.chip-row { margin: 0; }
a.chip { text-decoration: none; }
a.chip:hover { opacity: 1; }
a.chip.active:hover { color: #fff; }

/* Sticky search + type chips on phones (F73, design "검색 상단 sticky") */
@media (max-width: 767.98px) {
  .catalog-toolbar {
    position: sticky;
    top: var(--kk-header-h);
    z-index: 90;
    gap: 0.5rem;
    margin: 0 -1.1rem 1rem;
    padding: 0.6rem 1.1rem 0.35rem;
    background: rgba(255, 250, 247, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--kk-line);
  }
  .chip-row { flex-wrap: nowrap; }
}

.category-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  margin: 0 0 1.25rem;
  max-width: 520px;
}
.category-filter .form-select {
  flex: 1 1 12rem;
  min-width: 0;
  width: auto;
  min-height: var(--kk-touch);
}
.category-filter .btn { flex: none; }

.result-meta {
  font-size: 0.82rem;
  color: var(--kk-text-secondary);
  margin: 0.25rem 0 1rem;
  overflow-wrap: anywhere;
}

/* ========== Product grid ========== */
/* F13: minmax(0, 1fr) so a long model name can never widen its column or the page. */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 0.7rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
@media (min-width: 768px) {
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem 1.1rem; }
}
@media (min-width: 1100px) {
  .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.75rem 1.25rem; }
}
.product-grid-item { min-width: 0; }

.product-card {
  display: block;
  min-width: 0;
  background: transparent;
  border: none;
  border-radius: var(--kk-radius);
  overflow: visible;
  transition: transform 0.35s var(--kk-ease);
}
.product-card:hover {
  transform: translateY(-3px);
  opacity: 1;
}
.product-card:focus-visible {
  outline: 3px solid var(--kk-ink);
  outline-offset: 4px;
}
.product-card .thumb-wrap {
  position: relative;
  border-radius: var(--kk-radius);
  overflow: hidden;
  background: #e7e5e4;
  box-shadow: var(--kk-shadow);
  transition: box-shadow 0.35s var(--kk-ease);
}
.product-card:hover .thumb-wrap {
  box-shadow: var(--kk-shadow-hover);
}
.product-card .thumb {
  aspect-ratio: 3 / 4;
  object-fit: cover;
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.55s var(--kk-ease);
}
.product-card:hover .thumb {
  transform: scale(1.04);
}
.product-card .meta {
  padding: 0.75rem 0.15rem 0.25rem;
  min-width: 0;
}
/* Up to two lines for Korean captions, then an ellipsis; unbreakable ASCII names wrap anywhere. */
.product-card .model {
  font-weight: 600;
  font-size: 0.94rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--kk-ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.product-card .cat {
  color: var(--kk-text-secondary);
  font-size: 0.78rem;
  margin: 0.2rem 0 0;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.placeholder-thumb {
  aspect-ratio: 3/4;
  background: linear-gradient(145deg, #e7e5e4 0%, #d6d3d1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--kk-ink); /* 8.6:1 on the darkest gradient stop (#d6d3d1); --kk-text-secondary would be 4.2:1 */
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.kk-gallery-empty { border-radius: 20px; }

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2.5rem;
}
.pager .page-num {
  font-size: 0.88rem;
  color: var(--kk-text-secondary);
  min-width: 4rem;
  text-align: center;
}
.pager .disabled { pointer-events: none; opacity: 0.45; }

/* ========== Product detail ========== */
.detail-back { margin: -0.5rem 0 0.75rem; }
.detail-back .back-link { margin-top: 0; min-height: var(--kk-touch); }

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.75rem;
}
@media (min-width: 992px) {
  .detail-layout {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 3rem;
    align-items: start;
  }
}
/* Sticky gallery only when the whole gallery (3:4 slide ≈ 781px at the 1200px container + dots/counter) fits under
   the header. On laptop viewports (1366×768, 1280×720) a sticky gallery would keep its bottom, dots and counter
   below the fold while the customer reads the info column. */
@media (min-width: 992px) and (min-height: 940px) {
  .detail-media {
    position: sticky;
    top: calc(var(--kk-header-h) + 1rem);
  }
}
.detail-media,
.detail-info { min-width: 0; }
/* Tablet single column (R37): a full-width 3:4 slide (≈ 977px tall at 768×1024) would push the title and the tablet
   문의하기 shortcut below the fold. Cap the gallery so the back link, the slide, dots/counter, type line, title and the
   shortcut (~20rem besides the slide) fit under the sticky header (768×1024: 480×640 slide), centred, never
   narrower than 20rem. Phones keep the full width (their slide is well under the viewport height); short landscape
   viewports (< 600px high) are left alone. */
@media (min-width: 576px) and (max-width: 991.98px) and (min-height: 600px) {
  .detail-media {
    width: 100%;
    max-width: min(100%, max(20rem, calc((100vh - var(--kk-header-h) - 20rem) * 3 / 4)));
    max-width: min(100%, max(20rem, calc((100svh - var(--kk-header-h) - 20rem) * 3 / 4)));
    margin-inline: auto;
  }
}

.detail-info .type-line {
  font-size: 0.8rem;
  color: var(--kk-text-secondary);
  letter-spacing: 0.04em;
  margin: 0 0 0.5rem;
}
.detail-info h1 {
  font-size: clamp(1.5rem, 3vw, 1.9rem);
  font-weight: 680;
  letter-spacing: -0.03em;
  margin: 0 0 1rem;
  line-height: 1.25;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.detail-inquiry-link {
  align-items: center;
  margin: 0 0 1rem;
}
.option-pill {
  display: inline-flex;
  max-width: 100%;
  padding: 0.35rem 0.75rem;
  border-radius: var(--kk-radius-pill);
  background: var(--kk-gold-soft);
  color: #7a4a38;
  font-size: 0.82rem;
  font-weight: 550;
  margin-bottom: 1rem;
  overflow-wrap: anywhere;
}
.detail-desc {
  color: var(--kk-text-secondary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
  line-height: 1.65;
  margin: 0 0 1.25rem;
}
.privacy-note {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.9rem 1rem;
  background: rgba(28, 25, 23, 0.03);
  border-radius: var(--kk-radius-sm);
  border: 1px solid var(--kk-line);
  font-size: 0.84rem;
  color: var(--kk-text-secondary);
  margin-bottom: 1.5rem;
  word-break: keep-all;
}
.privacy-note strong {
  color: var(--kk-accent-text);
  font-weight: 650;
  flex: none;
}

/* ========== Inquiry card / form ========== */
.inquiry-card {
  background: var(--kk-surface);
  border: 1px solid var(--kk-line);
  border-radius: var(--kk-radius);
  padding: 1.35rem 1.25rem;
  box-shadow: var(--kk-shadow);
  scroll-margin-top: calc(var(--kk-header-h) + 0.75rem); /* #inquiry anchor below the sticky header */
}
.inquiry-card h2 {
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
}
.inquiry-card .hint {
  font-size: 0.84rem;
  color: var(--kk-text-secondary);
  margin: 0 0 1.1rem;
  word-break: keep-all;
}
.inquiry-title { font-size: 1.75rem; }

.inquiry-product {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--kk-radius-sm);
  border: 1px solid var(--kk-line);
  background: var(--kk-surface);
}
.inquiry-product-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--kk-text-secondary);
}
.inquiry-product a {
  font-weight: 600;
  color: var(--kk-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.form-required-note {
  font-size: 0.78rem;
  color: var(--kk-text-secondary);
  margin: 0 0 0.75rem;
}
.inquiry-form .req { color: #b3261e; margin-left: 0.1rem; }
.inquiry-form .form-text {
  font-size: 0.78rem;
  color: var(--kk-text-secondary);
  margin-top: 0.3rem;
}
.inquiry-count-row {
  display: flex;
  justify-content: flex-end;
}
.inquiry-form .form-control.invalid,
.inquiry-form .form-control[aria-invalid="true"] {
  border-color: #b3261e;
}
.inquiry-form .form-control.invalid:focus {
  box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.18);
}
.inquiry-form .validation-message {
  color: #b3261e;
  font-size: 0.82rem;
  margin-top: 0.3rem;
}
.inquiry-form .validation-errors { display: none; } /* field messages are shown next to each field */
.inquiry-privacy {
  margin-top: 0.75rem;
  word-break: keep-all;
}
.inquiry-card .alert { word-break: keep-all; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1.5rem;
  font-size: 0.88rem;
  color: var(--kk-text-secondary);
  font-weight: 500;
  min-height: var(--kk-touch);
}
.back-link:hover { color: var(--kk-ink); opacity: 1; }

/* ========== Rev 7 B25: "초기화" next to 검색 while a search/type/category is active ========== */
.search-bar .catalog-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-inline: 0.9rem;
}
@media (max-width: 575.98px) {
  .search-bar .btn { padding-inline: 0.9rem; }
  .search-bar .catalog-reset { padding-inline: 0.7rem; }
}

/* ========== Rev 7 B24: "같은 카테고리 상품" under the product ========== */
.related-section {
  margin-top: 3rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--kk-line);
  min-width: 0;
}
.related-title {
  font-size: 1.1rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
  color: var(--kk-ink);
}

/* ========== Rev 7 B26: "최근 본 상품" strip (filled by public.js from localStorage) ========== */
.kk-recent {
  margin-top: 2.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--kk-line);
  min-width: 0;
}
.kk-recent[hidden] { display: none; }
.kk-recent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}
.kk-recent-title {
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--kk-ink);
}
.kk-recent-clear {
  min-height: var(--kk-touch);
  padding: 0 0.75rem;
  border: none;
  border-radius: var(--kk-radius-sm);
  background: transparent;
  color: var(--kk-text-secondary);
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.kk-recent-clear:hover { color: var(--kk-ink); }
.kk-recent-clear:focus-visible {
  outline: 3px solid var(--kk-focus-ring);
  outline-offset: 2px;
}
/* One scrollable row; the page itself never scrolls sideways (min-width: 0 up the tree). */
.kk-recent-list {
  display: flex;
  gap: 0.75rem;
  list-style: none;
  margin: 0;
  padding: 0.25rem 0.1rem 0.6rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.kk-recent-item {
  flex: 0 0 6.5rem;
  min-width: 0;
  scroll-snap-align: start;
}
.kk-recent-card {
  display: block;
  color: var(--kk-ink);
  text-decoration: none;
  border-radius: var(--kk-radius-sm);
}
.kk-recent-card:hover { opacity: 1; color: var(--kk-ink); }
.kk-recent-card:focus-visible {
  outline: 3px solid var(--kk-ink);
  outline-offset: 3px;
}
.kk-recent-thumb {
  display: block;
  aspect-ratio: 3 / 4;
  border-radius: var(--kk-radius-sm);
  overflow: hidden;
  background: #e7e5e4;
  box-shadow: var(--kk-shadow);
}
.kk-recent-thumb.is-empty { background: linear-gradient(145deg, #e7e5e4 0%, #d6d3d1 100%); }
.kk-recent-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.kk-recent-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--kk-text);
  word-break: keep-all;
  overflow-wrap: anywhere;
}

/* ========== Rev 7 B26: "위로" ==========
   Without JS a plain link in the footer. With JS it floats bottom-right and appears after some scrolling
   (public.js adds .is-visible); on phones it sits above the sticky 문의하기 CTA instead of covering it. */
.kk-to-top {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-width: var(--kk-touch);
  min-height: var(--kk-touch);
  margin-top: 0.75rem;
  padding: 0 1rem;
  border: 1px solid var(--kk-line-strong);
  border-radius: var(--kk-radius-pill);
  background: var(--kk-surface);
  color: var(--kk-ink);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}
.kk-to-top:hover { color: var(--kk-ink); opacity: 1; }
.kk-to-top:focus-visible {
  outline: 3px solid var(--kk-focus-ring);
  outline-offset: 2px;
}
.kk-js .kk-to-top {
  position: fixed;
  right: calc(env(safe-area-inset-right, 0px) + 16px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  z-index: 1020; /* below the sticky CTA (1030) and the lightbox (2000) */
  margin: 0;
  box-shadow: 0 6px 18px rgba(61, 47, 42, 0.16);
  opacity: 0;
  visibility: hidden; /* also out of the tab order until it is useful */
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s var(--kk-ease), transform 0.2s var(--kk-ease), visibility 0s linear 0.2s;
}
.kk-js .kk-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition: opacity 0.2s var(--kk-ease), transform 0.2s var(--kk-ease), visibility 0s linear 0s;
}
html.kk-lightbox-open .kk-to-top { display: none; }
@media (max-width: 767.98px) {
  /* The sticky CTA is 52px high, 12px above the bottom edge. */
  .kk-js body:has(.kk-sticky-cta) .kk-to-top {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px + 52px + 12px);
  }
}

/* ========== Rev 7 B12: casual image-saving deterrent on public product photos ==========
   No long-press "save image" callout or text-selection highlight on product photos (public.js also cancels the
   context menu and drag there). A deterrent only; touch-action is left alone, so page pinch-zoom still works. */
.product-card img,
.kk-recent-thumb img,
.kk-gallery-thumb img {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* ========== Small phones ========== */
@media (max-width: 575.98px) {
  .pub-main { padding-top: 1.1rem; }
  /* F22: at 360px the brand subtitle and wide buttons pushed the header out of its bar. */
  .brand-sub { display: none; }
  .pub-nav .btn { padding-inline: 0.8rem; }
  .pub-header-inner { padding: 0 0.85rem; }
}

/* ========== Reduced motion (F97) ========== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .product-card,
  .product-card .thumb,
  .product-card .thumb-wrap { transition: none; }
  .product-card:hover,
  .product-card:hover .thumb { transform: none; }
  .kk-js .kk-to-top,
  .kk-js .kk-to-top.is-visible { transition: none; transform: none; }
}
