/* ==========================================================
   PROJECT VIEWER (Portfolio lightbox)
   Preview | Full Website tabs + Previous / Next Project
   ========================================================== */

body.pv-open {
  overflow: hidden;
}

.gallery .gallery-item {
  cursor: pointer;
}

.pv {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 12, 22, .82);
  font-family: var(--font-default, 'Poppins', sans-serif);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
}

.pv.is-open {
  opacity: 1;
  visibility: visible;
}

.pv-dialog {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1200px;
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .45);
  transform: translateY(16px) scale(.985);
  transition: transform .25s ease;
  outline: none;
}

.pv.is-open .pv-dialog {
  transform: none;
}

/* ---------- Header ---------- */

.pv-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 14px 18px 14px 24px;
  border-bottom: 1px solid #e6e8ee;
}

.pv-title {
  min-width: 0;
}

.pv-title h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pv-count {
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #8a8f9c;
}

.pv-tabs {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: #f1f2f6;
  border-radius: 999px;
}

.pv-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: #444;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s ease, color .2s ease;
}

.pv-tab:hover {
  color: var(--color-primary, #0032d3);
}

.pv-tab[aria-selected="true"] {
  background: var(--color-primary, #0032d3);
  color: #fff;
}

.pv-tab:focus-visible,
.pv-close:focus-visible,
.pv-nav:focus-visible {
  outline: 2px solid var(--color-primary, #0032d3);
  outline-offset: 2px;
}

.pv-tab[hidden] {
  display: none;
}

/* Project without a -full.jpg yet: hide the tab switch */
.pv-dialog[data-single] .pv-tabs {
  visibility: hidden;
}

.pv-close {
  justify-self: end;
  appearance: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #f1f2f6;
  color: #222;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}

.pv-close:hover {
  background: #111;
  color: #fff;
}

/* ---------- Stage ---------- */

.pv-stage-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pv-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  touch-action: pan-x pan-y;
  overflow: auto;
  overscroll-behavior: contain;
  background: #eef0f4;
}

/* Preview: image fits inside the stage */
.pv-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 24px;
}

.pv-preview img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 230px);
  max-height: calc(100dvh - 230px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .12);
}

/* Preview image that is itself a tall page screenshot: let it scroll */
.pv-preview.is-tall {
  align-items: flex-start;
}

.pv-preview.is-tall img {
  max-height: none;
  width: 100%;
  max-width: 1100px;
}

/* Full website: browser frame that scrolls */
.pv-full {
  padding: 24px;
}

.pv-browser {
  max-width: 1100px;
  margin: 0 auto;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .14);
}

.pv-browser-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  background: #e4e6eb;
}

.pv-browser-bar span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #c4c7cf;
}

.pv-browser-bar span:nth-child(1) { background: #ff5f57; }
.pv-browser-bar span:nth-child(2) { background: #febc2e; }
.pv-browser-bar span:nth-child(3) { background: #28c840; }

.pv-browser-bar em {
  flex: 1;
  margin-left: 10px;
  font-style: normal;
  font-size: 12px;
  color: #6b7080;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pv-browser img {
  display: block;
  width: 100%;
  height: auto;
}

[hidden].pv-preview,
[hidden].pv-full {
  display: none;
}

/* Loading spinner */
.pv-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border: 3px solid rgba(0, 50, 211, .2);
  border-top-color: var(--color-primary, #0032d3);
  border-radius: 50%;
  animation: pvSpin .8s linear infinite;
  pointer-events: none;
}

.pv-loading[hidden] {
  display: none;
}

@keyframes pvSpin {
  to { transform: rotate(360deg); }
}

/* "Scroll to explore" hint */
.pv-hint {
  position: sticky;
  bottom: 18px;
  display: table;
  margin: -54px auto 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(17, 17, 17, .82);
  color: #fff;
  font-size: 13px;
  pointer-events: none;
  transition: opacity .4s ease;
}

.pv-hint.is-hidden {
  opacity: 0;
}

/* ---------- Zoom ---------- */

.pv-full img {
  cursor: zoom-in;
  -webkit-user-drag: none;
  user-select: none;
}

.pv-stage.is-zoomed .pv-full img {
  cursor: grab;
}

/* Keep the side padding when the page is wider than the window */
.pv-stage.is-zoomed .pv-full {
  width: max-content;
  min-width: 100%;
}

.pv-stage.is-dragging,
.pv-stage.is-dragging .pv-full img {
  cursor: grabbing;
  user-select: none;
}

.pv-zoom {
  position: absolute;
  right: 28px;
  bottom: 18px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: rgba(17, 17, 17, .86);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}

.pv-zoom[hidden] {
  display: none;
}

.pv-zoom button {
  appearance: none;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s ease, opacity .2s ease;
}

.pv-zoom button:hover:not(:disabled) {
  background: var(--color-primary, #0032d3);
}

.pv-zoom button:disabled {
  opacity: .35;
  cursor: default;
}

.pv-zoom button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

.pv-zoom .pv-zoom-level {
  min-width: 56px;
  font-size: 13px;
  font-weight: 500;
}

/* ---------- Footer ---------- */

.pv-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid #e6e8ee;
}

.pv-nav {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 48%;
  border: 0;
  background: transparent;
  padding: 8px 14px;
  border-radius: 10px;
  font: inherit;
  color: #111;
  cursor: pointer;
  text-align: left;
  transition: background .2s ease;
}

.pv-nav:hover {
  background: #f1f2f6;
}

.pv-nav-next {
  margin-left: auto;
  text-align: right;
  background: var(--color-primary, #0032d3);
  color: #fff;
}

.pv-nav-next:hover {
  background: #111;
}

.pv-nav i {
  font-size: 18px;
  flex: none;
}

.pv-nav small {
  display: block;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .7;
}

.pv-nav strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pv-nav span {
  min-width: 0;
}

/* ---------- Mobile ---------- */

@media (max-width: 767px) {
  .pv {
    padding: 0;
  }

  .pv-dialog {
    max-width: none;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }

  .pv-head {
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 12px 12px 12px 16px;
  }

  .pv-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
  }

  .pv-dialog[data-single] .pv-tabs {
    display: none;
  }

  .pv-tab {
    flex: 1;
    padding: 8px 10px;
  }

  .pv-title h3 {
    font-size: 16px;
  }

  .pv-preview,
  .pv-full {
    padding: 12px;
  }

  .pv-preview img {
    max-height: calc(100dvh - 220px);
  }

  .pv-foot {
    padding: 10px 12px;
  }

  .pv-zoom {
    right: 12px;
    bottom: 12px;
  }

  .pv-hint {
    bottom: 64px;
    font-size: 12px;
  }

  .pv-nav {
    padding: 8px 10px;
  }

  .pv-nav small {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pv,
  .pv-dialog,
  .pv-hint {
    transition: none;
  }
}
