/*!
 * NanoBox v1.0.0 — nanobox.css
 */
:root {
  --nb-z: 9999;
  --nb-dur: 280ms;
  --nb-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --nb-r: 8px;
  --nb-shadow: 0 16px 60px rgba(0, 0, 0, 0.8);
  --nb-overlay: rgba(6, 6, 10, 0.92);
}

/* overlay */
.nb-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--nb-z);
  background: var(--nb-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--nb-dur) var(--nb-ease);
}
.nb-overlay.nb-on {
  opacity: 1;
  pointer-events: auto;
}

/*
  WRAP — centering layer
  ─────────────────────
  overflow-y:auto collapses the flex container height to its content.
  min-height:100vh restores the full viewport height so that
  align-items:center + justify-content:center can actually centre
  the child in both axes.
*/
.nb-wrap {
  position: fixed;
  inset: 0;
  z-index: calc(var(--nb-z) + 1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 100vh;
  padding: 20px;
  outline: none;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.96) translateY(8px);
  transition:
    opacity var(--nb-dur) var(--nb-ease),
    transform var(--nb-dur) var(--nb-ease);
}
.nb-wrap.nb-on {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

/* box — no fixed dimensions; sized by its content or by JS */
.nb-box {
  position: relative;
  flex-shrink: 0;
  max-width: calc(100vw - 40px);
}

/* close button */
.nb-close {
  position: absolute;
  top: -13px;
  right: -13px;
  z-index: 2;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  outline: none;
  transition:
    background var(--nb-dur),
    transform var(--nb-dur);
}
.nb-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}
.nb-close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 2px;
}

/* spinner */
.nb-spin {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  min-width: 160px;
  min-height: 120px;
  pointer-events: none;
  z-index: 1;
}
.nb-spin.on {
  display: flex;
}
.nb-ring {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #fff;
  animation: nb-spin 0.65s linear infinite;
}
@keyframes nb-spin {
  to {
    transform: rotate(360deg);
  }
}

/*
  IMAGE
  ─────
  Plain <img> appended directly to .nb-box — no wrapper, no iframe.
  JS sets explicit px width + height after onload so the box
  hugs the image exactly and flex centering works correctly.
  max-* are safety fallbacks only.
*/
.nb-img {
  display: block;
  /* width + height set by JS after onload */
  max-width: min(900px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  border-radius: var(--nb-r);
  box-shadow: var(--nb-shadow);
  user-select: none;
  -webkit-user-select: none;
}

/*
  VIDEO / IFRAME  (the "youtube style")
  ──────────────
  Fixed width + 16:9 padding-bottom ratio wrapper.
  The image now matches this centering behaviour.
*/
.nb-vid-wrap {
  width: min(900px, calc(100vw - 40px));
  border-radius: var(--nb-r);
  overflow: hidden;
  box-shadow: var(--nb-shadow);
  background: #000;
}
.nb-ratio {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%;
}
.nb-ratio iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* INLINE */
.nb-inline-wrap {
  width: min(580px, calc(100vw - 40px));
  max-height: 80vh;
  overflow-y: auto;
  border-radius: var(--nb-r);
  background: #fff;
  color: #111;
  padding: 32px 36px;
  box-shadow: var(--nb-shadow);
  font-family: system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
}

/* error */
.nb-error {
  padding: 24px 32px;
  margin: 0;
  color: #ff6b6b;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--nb-r);
  font-family: system-ui, sans-serif;
  font-size: 0.95rem;
}

@media (max-width: 600px) {
  .nb-close {
    width: 30px;
    height: 30px;
    top: -10px;
    right: -8px;
  }
  .nb-inline-wrap {
    padding: 20px 18px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .nb-overlay,
  .nb-wrap {
    transition-duration: 1ms !important;
  }
  .nb-ring {
    animation-duration: 1.5s;
  }
}
