/* Mobile product stage: native scrolling, one shared 3D canvas, real-image fallback. */
#product-grid[hidden],
.mobile-product-gallery [hidden],
.mobile-product-gallery[hidden],
.mobile-product-sheet [hidden] {
  display: none !important;
}

.mobile-product-gallery {
  display: none;
}

/* 데스크톱 카드 밑 «이름 · 도메인 · 한 줄 설명» 규칙은 style.css 가 원천이다.
   여기에 같은 규칙을 또 두면 한쪽만 고쳐져 조용히 어긋난다(실제로 padding 한 줄이 달랐다). */

.mobile-product-sheet {
  width: min(620px, 100%);
  max-width: 100%;
  max-height: 88svh;
  max-height: 88dvh;
  margin: auto auto 0;
  padding: 0;
  inset: auto 0 0;
  border: 1px solid #d9b46a50;
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: #10100e;
  color: #eee7d8;
  overflow: hidden;
  box-shadow: 0 -20px 90px #000a;
}

.mobile-product-sheet[open] {
  display: flex;
  flex-direction: column;
}

.mobile-product-sheet::backdrop {
  background: #000b;
  backdrop-filter: blur(9px);
}

.mobile-product-sheet-head {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 5px;
}

.mobile-product-sheet-head h2 {
  font-size: 20px;
  line-height: 1.4;
  letter-spacing: -.8px;
  font-weight: 400;
}

.mobile-product-sheet-close {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 1px solid #d9b46a38;
  border-radius: 50%;
  background: transparent;
  color: var(--light-gold, #f0d698);
  font-size: 23px;
}

.mobile-product-sheet-close svg {
  width: 19px;
  height: 19px;
}

.mobile-product-sheet-filters {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px 15px;
  padding: 0 20px;
  border-bottom: 1px solid #d9b46a26;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

.mobile-product-sheet-filters::-webkit-scrollbar {
  display: none;
}

.mobile-product-sheet-filters button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 10px 0 11px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #a49a86;
  font-size: 11px;
  line-height: 1.5;
  white-space: nowrap;
}

.mobile-product-sheet-filters button[aria-pressed="true"] {
  border-bottom-color: var(--gold, #d9b46a);
  color: var(--light-gold, #f0d698);
}

.mobile-product-thumbnails {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, max(6.25rem, calc((100% - 18px) / 3))), 1fr));
  align-content: start;
  gap: 12px 9px;
  min-height: 0;
  padding: 16px 15px max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: #d9b46a66 transparent;
}

.mobile-product-thumbnail {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 5px 11px;
  border: 1px solid #d9b46a20;
  border-radius: 10px;
  background: #d9b46a04;
  text-align: center;
  transition: border-color .2s, background .2s;
}

.mobile-product-thumbnail[aria-current="true"],
.mobile-product-thumbnail[aria-pressed="true"] {
  border-color: #d9b46aaa;
  background: #d9b46a0d;
}

.mobile-product-thumbnail img {
  width: 100%;
  height: 116px;
  object-fit: contain;
  margin-bottom: 3px;
}

.mobile-product-thumbnail > span {
  color: #e4ddce;
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: -.35px;
  overflow-wrap: anywhere;
}

.mobile-product-thumbnail small {
  color: #a79570;
  font-size: 9px;
  line-height: 1.4;
  word-break: keep-all;
}

@media (max-width: 720px) {
  #work.work-section {
    padding-block: 32px;
  }

  #work .section-top {
    margin-bottom: 16px;
  }

  #work .section-note,
  #work .work-heading > div > a {
    display: none;
  }

  #work .work-heading h2 {
    font-size: clamp(29px, 8vw, 35px);
    line-height: 1.23;
    letter-spacing: -1.8px;
  }

  #work .work-heading > div {
    margin-top: 13px;
    padding-bottom: 0;
  }

  #work .work-heading p {
    font-size: 11.5px;
    line-height: 1.75;
  }

  #work .product-filters {
    flex-wrap: nowrap;
    gap: 18px;
    margin: 18px 0 8px;
    overflow-x: auto;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }

  #work .product-filters::-webkit-scrollbar {
    display: none;
  }

  #work .product-filters button {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 10px 0;
    font-size: 10.5px;
    line-height: 1.5;
    white-space: nowrap;
  }

  .mobile-product-gallery {
    --mobile-slide-width: clamp(164px, 46vw, 200px);
    --mobile-slide-gap: 12px;
    --mobile-stage-height: clamp(290px, 79.5vw, 330px);
    --mobile-edge: 20px;
    display: block;
    margin-inline: calc(-1 * var(--mobile-edge));
    min-width: 0;
  }

  .mobile-product-stage {
    position: relative;
    height: var(--mobile-stage-height);
    overflow: hidden;
    isolation: isolate;
    background: radial-gradient(ellipse at 50% 76%, #a0793010, transparent 58%);
  }

  .mobile-product-stage > canvas {
    position: absolute;
    z-index: 1;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
  }

  .mobile-product-rail {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    gap: var(--mobile-slide-gap);
    padding-inline: calc((100% - var(--mobile-slide-width)) / 2);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: calc((100% - var(--mobile-slide-width)) / 2);
    scroll-behavior: smooth;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y pinch-zoom;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-product-rail::-webkit-scrollbar {
    display: none;
  }

  .mobile-product-slide {
    position: relative;
    display: block;
    flex: 0 0 var(--mobile-slide-width);
    width: var(--mobile-slide-width);
    height: 100%;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    scroll-snap-align: center;
    scroll-snap-stop: normal;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-product-slide:focus-visible {
    outline-offset: -6px;
    border-radius: 14px;
  }

  .mobile-product-hit {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-product-hit:focus-visible { outline-offset: -6px; border-radius: 14px; }

  /* 편집모드 손잡이 — 폰 «안쪽» 아래에 얹는다.
     레일이 세로를 잘라 내기 때문에 카드 밑에 그냥 붙이면 잘린 바깥으로 나가
     화면엔 보이는데 눌리지는 않는다(2026-09-12 실측: 손잡이 위를 제품 이름이 덮고 있었다). */
  .mobile-product-slide > .admin-card-tools {
    position: absolute;
    z-index: 3;
    left: 0;
    right: 0;
    bottom: 9px;
    margin-top: 0;
    justify-content: center;
    gap: 5px;
  }

  .mobile-product-slide > .admin-card-tools .admin-chip {
    padding: 7px 10px;
    font-size: 11px;
    background: #12100cdd;
  }

  /* 지금 보고 있는 폰에만 손잡이를 둔다 — 옆 폰 것은 반쯤 잘려 방해만 된다. */
  .mobile-product-slide:not([aria-current="true"]) > .admin-card-tools {
    display: none;
  }

  .mobile-product-image {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    pointer-events: none;
  }

  .mobile-product-image > img {
    display: block;
    width: auto;
    height: 88%;
    max-width: 85%;
    object-fit: contain;
    border: 0;
    border-radius: 8px;
    box-shadow: none;
    transition: opacity .2s;
  }

  .mobile-product-image[data-phone-state="ready"] > img {
    opacity: 0;
  }

  .mobile-product-image-placeholder {
    max-width: 130px;
    color: #a79570;
    font-size: 12px;
    line-height: 1.7;
    text-align: center;
    word-break: keep-all;
  }

  .mobile-product-copy {
    padding: 3px var(--mobile-edge) 0;
    text-align: center;
  }

  .mobile-product-status {
    color: #c7ab76;
    font-size: 9px;
    line-height: 1.6;
    letter-spacing: .4px;
  }

  .mobile-product-title {
    margin-top: 5px;
    color: #eee7d8;
    font-size: 25px;
    font-weight: 400;
    line-height: 1.3;
    letter-spacing: -1px;
    overflow-wrap: anywhere;
  }

  .mobile-product-domain {
    display: inline-block;
    margin-top: 5px;
    color: #a69570;
    font: 9px/1.5 ui-monospace, monospace;
    overflow-wrap: anywhere;
  }

  .mobile-product-description {
    max-width: 420px;
    margin: 9px auto 0;
    color: #b1a792;
    font-size: 12px;
    line-height: 1.75;
    word-break: keep-all;
    overflow-wrap: anywhere;
  }

  .mobile-product-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 11px var(--mobile-edge) 0;
  }

  .mobile-product-nav button {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid #d9b46a44;
    border-radius: 50%;
    background: transparent;
    color: var(--light-gold, #f0d698);
    font-size: 21px;
    transition: border-color .2s, background .2s;
  }

  .mobile-product-nav button svg,
  .mobile-product-actions svg {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
  }

  .mobile-product-nav button:disabled {
    border-color: #d9b46a1a;
    color: #d9b46a40;
  }

  .mobile-product-position {
    min-width: 54px;
    color: #ddc28f;
    font: 11px/1.5 ui-monospace, monospace;
    text-align: center;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .mobile-product-progress {
    flex: 1 1 60px;
    max-width: 92px;
    height: 1px;
    background: #d9b46a2b;
    overflow: hidden;
  }

  .mobile-product-progress > span {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--gold, #d9b46a);
    transform-origin: left;
    transition: transform .25s ease, width .25s ease;
  }

  .mobile-product-actions {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 10px;
    padding: 13px var(--mobile-edge) 0;
  }

  .mobile-product-actions button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 46px;
    min-width: 0;
    padding: 11px 9px;
    border: 1px solid #d9b46a50;
    border-radius: 4px;
    background: transparent;
    color: #e7d5b0;
    font-size: 12px;
    line-height: 1.5;
    word-break: keep-all;
  }

  .mobile-product-actions button:last-child {
    border-color: #d9b46a80;
    background: #d9b46a0e;
    color: var(--light-gold, #f0d698);
  }

  .mobile-product-hint {
    margin: 12px var(--mobile-edge) 0;
    color: #8d8067;
    font-size: 10px;
    line-height: 1.5;
    text-align: center;
  }
}

@media (hover: hover) {
  .mobile-product-nav button:not(:disabled):hover,
  .mobile-product-actions button:hover,
  .mobile-product-sheet-close:hover,
  .mobile-product-thumbnail:hover {
    border-color: #d9b46aa8;
    background: #d9b46a14;
  }
}

@media (max-width: 360px) {
  .mobile-product-gallery {
    --mobile-edge: 16px;
  }

  #work .product-filters {
    gap: 14px;
  }

  .mobile-product-thumbnails {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .mobile-product-sheet-filters {
    gap: 13px;
    padding-inline: 16px;
  }

  .mobile-product-sheet-filters button {
    font-size: 10px;
  }
}

@media (max-width: 720px) and (prefers-reduced-motion: no-preference) {
  .mobile-product-gallery[data-entered="true"] .mobile-product-stage {
    animation: mobile-product-arrive .38s ease-out both;
  }
  @keyframes mobile-product-arrive {
    from { opacity: .35; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-product-rail {
    scroll-behavior: auto;
  }

  .mobile-product-gallery *,
  .mobile-product-sheet * {
    transition: none !important;
    animation: none !important;
  }
}
