/* nBUN Work v2 — Grid + Modal + Duotone (Style Updated V4.4: JS SVG Sync) */

:root {
  --nbun-black: #111;
  --nbun-white: #fff;
  --nbun-duo-shadow: #c2c2c2;
  --nbun-duo-highlight: #fff;
  --nbun-duo-outline: #777;
  
  --nbun-font: 'Google Sans Code', monospace; 
  --nbun-font-mono: 'Google Sans Code', monospace; 
  
  --nbun-z-overlay: 9999;
  --nbun-z-filters: 9998;
}

.nbunpg-root {
  width: 100vw; max-width: 100vw;
  position: relative; left: 50%; right: 50%;
  margin-left: -50vw; margin-right: -50vw;
padding: 8% 2% 2%;
  box-sizing: border-box; overflow-x: hidden;
  background: #efeff0;
  font-family: var(--nbun-font) !important;
}

.nbunpg-root * { font-family: inherit; }

html.nbunpg-locked, body.nbunpg-locked {
  overflow: hidden !important; height: 100vh !important;
}

.nbunpg-grid {
  display: grid !important; width: 100%;
  margin: 0; padding: 0; gap: 0;
  grid-auto-flow: row dense;
  justify-items: stretch; align-items: start;
}

@media (min-width: 1440px) { .nbunpg-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 768px) and (max-width: 1439px) { .nbunpg-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 767px) { .nbunpg-grid { grid-template-columns: repeat(3, 1fr); } }

.nbunpg-card {
  display: block; position: relative !important;
  box-sizing: border-box; overflow: hidden; margin: 0 !important;
}
.nbunpg-card.w2 { grid-column: span 2; }
@media (max-width: 767px) { .nbunpg-card.w2 { grid-column: span 2; } }

.nbunpg-card .thumb {
  position: relative; width: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 30% 18%;
  background: transparent; border: 0;
  cursor: pointer; overflow: hidden;
}
.nbunpg-card.w2 .thumb { padding: 12.5% 10%; }

/* --- 修復版 Thumb 樣式 (移除 GPU 強制加速) --- */
.nbunpg-card .thumb img {
  display: block; width: 100%; height: auto;
  object-fit: contain;
  
  /* 濾鏡維持原樣 */
  filter: url('#nbunDuotone') 
          drop-shadow(1px 0 0 var(--nbun-duo-outline)) 
          drop-shadow(-1px 0 0 var(--nbun-duo-outline)) 
          drop-shadow(0 1px 0 var(--nbun-duo-outline)) 
          drop-shadow(0 -1px 0 var(--nbun-duo-outline))
          
          drop-shadow(-1px -2.5px 3px rgba(0, 0, 0, 0.25)) 
          drop-shadow(4px 4px 3px rgba(255, 255, 255, 0.9)) !important;
          
  transition: filter 0.3s ease;
  
  /* ★ 刪除以下兩行，解決橫條紋破圖問題 ★ */
  /* backface-visibility: hidden; */
  /* transform: translateZ(0); */
}

.nbunpg-card .meta-line {
  position: absolute; inset: 0 0 auto 0;
  padding-top: 6px; z-index: 10;
  pointer-events: none;
  display: flex; justify-content: space-between; align-items: flex-start;
}

.nbunpg-card .meta-line::before {
  content: ""; position: absolute; left: 0; right: 0; top: 5px; height: 1px;
  background: var(--nbun-black); opacity: 0.9;
}
.nbunpg-card .meta-line::after {
  content: ""; position: absolute; left: 0; top: 6px; height: 25px;
  border-left: 1px solid var(--nbun-black); opacity: 0.9;
}

.nbunpg-card .meta-left {
  display: flex; flex-direction: column;
  padding-left: 14px; 
  pointer-events: auto; 
  margin-right: 40px; 
  margin-top: 8px; 
  text-decoration: none; cursor: pointer;
}
.nbunpg-card .meta-left:hover .meta-row-title { opacity: 0.7; }

.nbunpg-card .meta-row-title,
.nbunpg-card .meta-row-sub {
  color: #0e0e0e;
  font-family: var(--nbun-font) !important;
  text-transform: uppercase;
  text-align: left;
  line-height: 1.4;
}
.nbunpg-card .meta-row-title {
  font-size: 11px; font-weight: 400; letter-spacing: 0px;
}
.nbunpg-card .meta-row-sub {
  font-size: 10px; font-weight: 400; opacity: 0.85; letter-spacing: 0px;
}

.nbunpg-card .meta-mobile-id { display: none; }

/* =========================================
   ICON 互動邏輯 (Desktop: Cross-Dissolve)
   ========================================= */

/* ★ 全域設定：隱藏 JS 插入的實體 SVG (電腦版不顯示) */
.nbunpg-card .meta-right-icon svg { display: none; }

/* 1. Icon 容器 */
.nbunpg-card .meta-right-icon {
  position: absolute; top: 10px; right: 10px; 
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0; 
  transform: translateY(5px);
  transition: opacity 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), 
              transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 2. 懸停卡片時浮現 */
.nbunpg-card:hover .meta-right-icon {
  opacity: 1;
  transform: translateY(0);
}

/* 3. 設定 CSS Icon 共用屬性 (::before/::after) */
.nbunpg-card .meta-right-icon::before,
.nbunpg-card .meta-right-icon::after {
  font-family: 'Material Symbols Sharp';
  font-weight: normal; font-style: normal;
  font-size: 24px; line-height: 1;
  text-transform: none; white-space: nowrap; direction: ltr;
  color: #111;
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
  
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* A. 放大圖示 (預設顯示) */
.nbunpg-card .meta-right-icon::before {
  content: 'expand_content';
  opacity: 1; 
  transform: translate(-50%, -50%) scale(1);
}

/* B. 眼睛圖示 (預設隱藏) */
.nbunpg-card .meta-right-icon::after {
  content: 'preview';
  opacity: 0; 
  transform: translate(-50%, -50%) scale(0.8);
  text-shadow: 0 0 13px rgba(233, 255, 111, 0.8);
}

/* 互動：移到文字區時切換 */
.nbunpg-card .meta-left:hover ~ .meta-right-icon::before {
  opacity: 0;
  transform: translate(-50%, -50%) scale(1.2);
}

.nbunpg-card .meta-left:hover ~ .meta-right-icon::after {
  opacity: 1;
  color: #000;
  transform: translate(-50%, -50%) scale(1);
}

/* =========================================
   手機版 (Mobile) - 顯示 JS SVG
   ========================================= */
@media (max-width: 767px) {
  
  .nbunpg-card .meta-left { display: none; }
  
  .nbunpg-card .meta-mobile-id {
    display: block;
    padding: 6px 0 0 11px;
    font-size: 10px; 
    font-weight: 400; 
    color: #111;
    text-transform: uppercase; 
    letter-spacing: 0px;
    line-height: 12px;
  }
  
  .nbunpg-card .meta-line::after { height: 18px; }

  /* Icon 容器 (靜態化) */
  .nbunpg-card .meta-right-icon {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    
    top: 5px; right: 4px;
    width: 24px; height: 24px;
    align-items: center; /* 讓箭頭置中 */
    justify-content: center;
    display: flex !important;
  }

  /* ★ 1. 隱藏 CSS 產生的舊 Icon */
  .nbunpg-card .meta-right-icon::before,
  .nbunpg-card .meta-right-icon::after {
    display: none !important;
  }
  
  /* ★ 2. 顯示 JS 插入的 SVG */
  .nbunpg-card .meta-right-icon svg {
    display: block !important;
    width: 14px; 
    height: 14px;
    /* 如果 SVG 裡面有設 fill，這裡可以不用寫，或者強制覆蓋 */
  }
}

/* Modal */
.nbunpg-overlay {
  position: fixed; inset: 0;
  z-index: var(--nbun-z-overlay);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .24s ease-out;
}
.nbunpg-overlay.is-open { opacity: 1; pointer-events: auto; }

.nbunpg-overlay-bg {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0); 
  backdrop-filter: blur(0px); 
  -webkit-backdrop-filter: blur(0px);
}

.nbunpg-modal {
  position: relative; z-index: 2;
  max-width: min(100vw - 40px, 1200px);
  max-height: min(100vh - 40px, 820px);
  transform: translateY(100vh); opacity: 1; 
  transition: transform .5s cubic-bezier(0.19, 1, 0.22, 1);
}
.nbunpg-overlay.is-open .nbunpg-modal { transform: translateY(0); }

.nbunpg-modal-imgwrap {
  position: relative; display: inline-block;
  max-width: 90vw; max-height: 90vh;
  overflow: visible;
}

.nbunpg-modal-img-main {
  display: block; max-width: 100%; max-height: 80vh;
  object-fit: contain; background-color: #fff;
  border: 1px solid #000;
  filter: none; 
  box-shadow: rgba(20,0,0,0.2) 0px 26px 80px 14px, rgba(0,0,0,0.7) 0px 2px 3px 1px;
}

.nbunpg-modal-close,
.nbunpg-modal-arrow,
.nbunpg-modal-counter {
  background: transparent;
  color: #fff; 
  mix-blend-mode: difference;
  font-family: var(--nbun-font) !important;
  z-index: 20;
}

.nbunpg-modal-close {
  position: absolute; right: 6px; top: 6px;
  width: 40px; height: 40px;
  border: 0; border-radius: 999px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}

.nbunpg-modal-arrow {
  position: absolute; 
  width: 40px; height: 40px;
  border: 0; border-radius: 6px;
  cursor: pointer; display: none; 
  align-items: center; justify-content: center;
  transition: opacity .2s;
  top: 50%; transform: translateY(-50%);
  bottom: auto;
}
.nbunpg-modal-arrow:hover { opacity: 0.7; }
.nbunpg-modal-imgwrap.has-multiple .nbunpg-modal-arrow { display: flex; }

.nbunpg-modal-prev { left: 0; justify-content: flex-start; }
.nbunpg-modal-next { right: 0; justify-content: flex-end; }

.nbunpg-modal-counter {
  position: absolute; 
  right: 40px; 
  top: 50%; transform: translateY(-50%);
  bottom: auto;
  font-size: 13px; font-weight: 500;
  padding: 0 8px; 
  height: 40px;
  pointer-events: none; display: none;
  align-items: center; justify-content: flex-end; 
}
.nbunpg-modal-counter.is-visible { display: flex; }
.nbunpg-modal-counter svg { display: none; }

@media (max-width: 600px) {
  .nbunpg-modal { max-width: calc(100vw - 24px); max-height: calc(100vh - 32px); }
  .nbunpg-modal-img-main { max-height: calc(100vh - 96px); }
}

.nbunpg-card.is-hidden { display: none !important; }
html.nbunpg-locked .nbun-nav-left a,
html.nbunpg-locked .nbun-menu-link { display: none !important; }