/* ============================================================
   Shared V2 post viewer.

   A viewport overlay rather than the browser Fullscreen API. This keeps
   Escape/backdrop controls predictable and works in iPhone Safari while
   reserving every remaining pixel for an uncropped image or video.
   ============================================================ */

#post-lightbox {
  --lb-stage: #fff;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  background: rgba(5, 8, 14, .92);
}

[data-theme="dark"] #post-lightbox { --lb-stage: #000; }

.modal--lb {
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  border: 0;
  border-radius: 0;
  background: var(--card);
  overflow: hidden;
}

.lb__content {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* A click on feed media opens the same restrained, media-first lightbox as
   V1. The full post layout remains available to callers such as My activity.
   The media stage follows the selected theme while preserving the V1
   zoom-out close affordance. */
.lb__content--media-only {
  position: relative;
  display: block;
  background: var(--lb-stage);
  cursor: zoom-out;
}

.lb__content--media-only .lb__head {
  position: absolute;
  inset: 0 0 auto;
  z-index: 5;
  justify-content: flex-end;
  border: 0;
  background: transparent;
  pointer-events: none;
}

.lb__content--media-only .lb__avatar,
.lb__content--media-only .lb__who,
.lb__content--media-only .lb__body { display: none; }

.lb__content--media-only .modal__close {
  color: #fff;
  background: rgba(10, 14, 22, .66);
  border-color: rgba(255, 255, 255, .24);
  cursor: pointer;
  pointer-events: auto;
}

.lb__content--media-only .lb__media {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background-color: var(--lb-stage);
  background-image: none;
  cursor: zoom-out;
}

.lb__content--media-only .lb__image,
.lb__content--media-only .lb__video {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

.lb__content--media-only .lb__video {
  background: var(--lb-stage);
}

.lb__head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding:
    max(13px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    13px
    max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
}

.lb__avatar {
  width: 34px;
  height: 34px;
  flex: none;
  font-size: 12px;
  background-position: center 20%;
}

.lb__who { flex: 1; min-width: 0; }
.lb__model {
  color: var(--ink);
  font-weight: 700;
  font-size: 13.5px;
  text-decoration: none;
}
a.lb__model:hover,
a.lb__model:focus-visible { color: var(--brand); }
.lb__date { font-size: 11px; color: var(--ink-soft); }

.lb__media {
  position: relative;
  min-width: 0;
  min-height: 0;
  aspect-ratio: auto;
  background-color: #080b10;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  overscroll-behavior: contain;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.lb__media::after { display: none; }

.lb__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity var(--dur) ease;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  cursor: default;
}

.lb__image.is-ready { opacity: 1; }

.lb__video {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #080b10;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: default;
}

.lb__video-status {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 3;
  transform: translate(-50%, -50%);
  max-width: min(90%, 420px);
  padding: 9px 13px;
  border-radius: var(--radius-pill);
  background: rgba(10, 14, 22, .72);
  color: #fff;
  font-size: 12px;
  text-align: center;
  pointer-events: none;
}

.lb__video-status.is-error { background: rgba(109, 25, 42, .88); }

.lb__media-error {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 3;
  transform: translate(-50%, -50%);
  padding: 9px 13px;
  border-radius: var(--radius-pill);
  background: rgba(10, 14, 22, .72);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
}

.lb__play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-pill);
  background: rgba(10, 14, 22, .55);
  backdrop-filter: blur(3px);
  color: #fff;
}

.lb__body {
  max-height: min(36vh, 320px);
  padding:
    13px
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  overflow-y: auto;
  border-top: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}

.lb__titlerow { display: flex; align-items: baseline; gap: 8px; }

.lb__title {
  flex: 1;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15.5px;
}

.lb__desc {
  margin: 4px 0 9px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.lb__desc:empty { display: none; }

.lb__stats {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* Shown instead of the thread on a locked post — comments belong to people
   who have the post. */
.lb__note {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--card-alt);
  font-size: 11.5px;
  color: var(--ink-soft);
}

@media (max-width: 560px) {
  .lb__head { padding-bottom: 10px; }
  .lb__body { max-height: 42vh; }
}
