/* ==========================================================================
   Image lightbox — click a product image to enlarge it in place.
   Loaded by index.html and products.html. No page navigation, no external
   dependency, works from file:// and from any static host.
   --------------------------------------------------------------------------
   Sizing note: the source product photos are 317–900 px wide, so the overlay
   sizes the image explicitly (fit-to-viewport) rather than letting CSS
   max-width handle it. A CSS "contain" box would letterbox the image and
   break the zoom maths; an explicit box keeps zoom and pan pixel-exact.
   ========================================================================== */

/* ---------- the zoomable thumbnail affordance ---------- */
.lb-fig{position:relative}
.lb-fig img{cursor:zoom-in;outline:none}
.lb-fig img:focus-visible{outline:2px solid #0066CC;outline-offset:4px}
.lb-fig::after{
  content:"";position:absolute;right:10px;bottom:10px;width:30px;height:30px;
  border-radius:50%;pointer-events:none;opacity:0;transform:translateY(4px) scale(.9);
  transition:opacity .2s ease,transform .2s ease;
  background:rgba(10,53,86,.82) center/15px 15px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3Cpath d='M10.5 7.8v5.4M7.8 10.5h5.4'/%3E%3C/svg%3E");
}
.lb-fig:hover::after{opacity:1;transform:none}

/* ---------- overlay shell ---------- */
.lb{
  position:fixed;inset:0;z-index:300;display:none;
  font-family:var(--sans);
  color:#fff;
}
.lb.on{display:block}
.lb-backdrop{
  position:absolute;inset:0;background:rgba(6,12,20,.9);backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);opacity:0;transition:opacity .22s ease;
}
.lb.on .lb-backdrop{opacity:1}

/* ---------- image stage ---------- */
.lb-stage{
  position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  overflow:hidden;touch-action:none;cursor:zoom-in;
}
.lb-stage.zoomed{cursor:grab}
.lb-stage.zoomed .lb-img{cursor:grab}
.lb-stage.zoomed.dragging .lb-img{cursor:grabbing}
.lb-img{
  display:block;max-width:none;max-height:none;width:auto;height:auto;
  object-fit:contain;transform-origin:center center;will-change:transform;
  user-select:none;-webkit-user-drag:none;-webkit-user-select:none;
  opacity:0;transition:opacity .2s ease;
  box-shadow:0 26px 80px rgba(0,0,0,.5);
}
.lb.on .lb-img{opacity:1}

/* ---------- bottom bar: tools / caption / counter ---------- */
.lb-bar{
  position:absolute;left:0;right:0;bottom:0;display:flex;align-items:center;
  justify-content:center;gap:18px;padding:16px 20px calc(16px + env(safe-area-inset-bottom));
  background:linear-gradient(180deg,rgba(6,12,20,0),rgba(6,12,20,.85));
  opacity:0;transition:opacity .24s ease .05s;
}
.lb.on .lb-bar{opacity:1}
.lb-tools{display:flex;align-items:center;gap:6px;margin-right:auto}
.lb-caption{
  display:flex;align-items:center;gap:10px;min-width:0;justify-content:center;
  flex-wrap:wrap;row-gap:4px;
}
.lb-tag{
  font-family:var(--mono);font-size:9px;letter-spacing:.13em;text-transform:uppercase;font-weight:500;
  color:var(--ink);background:var(--paper);padding:4px 8px;white-space:nowrap;
}
.lb-title{font-family:var(--display);font-size:1.15rem;font-weight:400;letter-spacing:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:52vw}
.lb-meta{font-family:var(--mono);font-size:10px;color:rgba(247,244,237,.62);font-variant-numeric:tabular-nums;letter-spacing:.02em}
.lb-count{
  margin-left:auto;font-family:var(--mono);font-size:10px;color:rgba(247,244,237,.55);font-variant-numeric:tabular-nums;
  letter-spacing:.08em;white-space:nowrap;
}

/* ---------- buttons ---------- */
.lb-btn{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  height:34px;min-width:34px;padding:0 10px;border:1px solid rgba(255,255,255,.22);
  border-radius:9px;background:rgba(255,255,255,.1);color:#fff;cursor:pointer;
  font:inherit;font-size:13px;line-height:1;
  transition:background .18s ease,border-color .18s ease,transform .12s ease;
}
.lb-btn:hover{background:rgba(255,255,255,.22);border-color:rgba(255,255,255,.45)}
.lb-btn:active{transform:scale(.94)}
.lb-btn:focus-visible{outline:2px solid #7FC4FF;outline-offset:2px}
.lb-btn svg{width:16px;height:16px;display:block}
.lb-btn[hidden]{display:none}

.lb-close{position:absolute;top:18px;right:18px;z-index:3;width:42px;height:42px;padding:0;border-radius:50%}
.lb-nav{
  position:absolute;top:50%;transform:translateY(-50%);z-index:3;width:48px;height:48px;
  padding:0;border-radius:50%;
}
.lb-prev{left:20px}
.lb-next{right:20px}

/* ---------- mobile ---------- */
@media (max-width:760px){
  .lb-nav{width:40px;height:40px;background:rgba(10,53,86,.55)}
  .lb-prev{left:10px}
  .lb-next{right:10px}
  .lb-close{top:12px;right:12px;width:38px;height:38px}
  .lb-bar{flex-wrap:wrap;justify-content:center;gap:12px;padding-bottom:calc(14px + env(safe-area-inset-bottom))}
  .lb-tools{margin-right:0;order:3}
  .lb-count{margin-left:0;order:2}
  .lb-caption{order:1;width:100%}
  .lb-title{max-width:74vw}
}

@media (prefers-reduced-motion:reduce){
  .lb-backdrop,.lb-bar,.lb-img{transition:none}
}
