/* ================================================================
   Gal Cohen — the project popup
   ================================================================

   Loaded by the site and by the project editor in wp-admin, so the popup an
   editor previews is the one a visitor gets rather than a second thing that
   looks similar. It carries its own copies of the four theme variables it
   uses: on the site they would be inherited from :root, and inside wp-admin
   there is no :root to inherit from — declaring them on .lightbox keeps them
   out of the admin's own styles.
   ================================================================ */

.lightbox {
  --white: #ffffff;
  --ink: #1e1e1e;
  --ink-soft: #6d6d6d;
  --transition: 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
  font-family: "Noto Sans Hebrew", sans-serif;
  line-height: 1.8;
  direction: rtl;
  text-align: right;
}

/* wp-admin sets box-sizing on its own elements, not on ours. */
.lightbox *,
.lightbox *::before,
.lightbox *::after { box-sizing: border-box; }

/* The site hides it with a class rule that beats the UA sheet; in wp-admin
   that rule is not loaded, so the popup states its own. */
.lightbox[hidden] { display: none !important; }

/* Follows the approved gallery mock: square-cornered white panel, centred head
   with a meta line, arrows and counter sitting inside the image, muted thumbs. */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 40px 24px;
}

.lightbox[hidden] { display: none; }

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 14, 13, 0.82);
  animation: lbFade 0.3s ease;
}

.lightbox-panel:focus { outline: none; }

.lightbox-panel {
  position: relative;
  z-index: 1;
  /* The 3:2 stage derives its height from this width, so the width is capped
     to whatever leaves room for the heading and the thumbnail strip. */
  width: min(1280px, 94%, calc((100vh - 430px) * 1.5 + 104px));
  max-height: 100%;
  /* A column, so the stage can give back height when the description runs long
     or the window is short, instead of pushing the panel off screen. */
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--white);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.4);
  animation: lbRise 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes lbFade { from { opacity: 0; } }
@keyframes lbRise { from { opacity: 0; transform: translateY(18px); } }

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 5;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  color: var(--ink);
  cursor: pointer;
  transition: color var(--transition);
}

.lightbox-close:hover { color: var(--ink-soft); }
.lightbox-close svg { width: 22px; height: 22px; }

.lightbox-head { padding: 34px 52px 0; text-align: center; }

.lightbox-head h3 {
  font-weight: 400;
  font-size: 30px;
  line-height: 1.8;
  margin-bottom: 4px;
}

.lightbox-meta {
  font-size: 13px;
  font-weight: 300;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.lightbox-meta:empty { display: none; }

.lightbox-desc {
  max-width: 640px;
  margin: 0 auto 20px;
  font-size: 15px;
  font-weight: 300;
  color: var(--ink-soft);
}

.lightbox-head,
.lightbox-thumbs { flex: 0 0 auto; }

.lightbox-stage {
  position: relative;
  margin: 0 52px;
  flex: 0 0 auto;
}

.lightbox-viewport {
  overflow: hidden;
  /* A 3:2 window. A landscape shot fills it edge to edge, cropped to fit; a
     portrait shot sits inside it whole, with margins either side. Which of
     the two is decided per image, from its own ratio. */
  width: 100%;
  aspect-ratio: 3 / 2;
  background: #f4f3f0;
}

.lightbox-track {
  display: flex;
  height: 100%;
  direction: ltr; /* index-based transform math stays LTR regardless of page dir */
  transition: transform var(--transition);
}

.lightbox-track img {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}

/* Anything wider than it is tall fills the frame. */
.lightbox-track img.is-landscape { object-fit: cover; }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.92);
  border: none;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(20, 20, 20, 0.18);
  transition: background var(--transition);
}

.lightbox-nav:hover { background: var(--white); }
.lightbox-nav svg { width: 20px; height: 20px; }

.lightbox-prev { inset-inline-start: 16px; }
.lightbox-next { inset-inline-end: 16px; }

.lightbox-counter {
  position: absolute;
  bottom: 14px;
  inset-inline-end: 16px;
  padding: 3px 12px;
  font-size: 13px;
  background: rgba(20, 20, 20, 0.65);
  color: var(--white);
  direction: ltr;
}

.lightbox-thumbs {
  display: flex;
  gap: 10px;
  justify-content: safe center;
  overflow-x: auto;
  padding: 18px 52px 30px;
  scrollbar-width: thin;
}

.lightbox-thumbs button {
  flex: 0 0 96px;
  height: 72px;
  padding: 0;
  border: none;
  background: none;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity var(--transition);
}

.lightbox-thumbs button.active,
.lightbox-thumbs button:hover { opacity: 1; }
.lightbox-thumbs img { width: 100%; height: 100%; object-fit: cover; }

body.lb-open { overflow: hidden; }

/* A short laptop window leaves the stage very little once the heading and the
   thumbnail strip take their share, so both give some back. */
@media (min-width: 861px) and (max-height: 820px) {
  .lightbox { padding: 20px; }
  /* The chrome is trimmed below, so the stage can take a bigger share. */
  .lightbox-panel { width: min(1280px, 94%, calc((100vh - 320px) * 1.5 + 104px)); }
  .lightbox-head { padding-top: 24px; }
  .lightbox-head h3 { font-size: 25px; line-height: 1.5; }
  .lightbox-desc { margin-bottom: 14px; }
  .lightbox-thumbs { padding: 12px 52px 18px; }
  .lightbox-thumbs button { flex-basis: 68px; height: 51px; }
}

/* Shorter still. A narrow panel wraps the description onto more lines, which
   would eat the height the stage just won back — so it is capped at two lines
   and the chrome stops growing. */
@media (min-width: 861px) and (max-height: 700px) {
  .lightbox-panel { width: min(1280px, 94%, calc((100vh - 265px) * 1.5 + 104px)); }
  .lightbox-head { padding-top: 18px; }
  .lightbox-head h3 { font-size: 22px; margin-bottom: 2px; }
  .lightbox-desc {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    margin-bottom: 10px;
  }
  .lightbox-thumbs { padding: 10px 52px 14px; }
  .lightbox-thumbs button { flex-basis: 60px; height: 45px; }
}

@media (max-width: 860px) {
  .lightbox { padding: 0; }
  .lightbox-panel { width: 100%; min-height: 100%; }
  .lightbox-close { top: 10px; right: 10px; }
  .lightbox-head { padding: 60px 22px 0; }
  .lightbox-head h3 { font-size: 23px; }
  .lightbox-meta { font-size: 12px; }
  .lightbox-desc { font-size: 14.5px; margin-bottom: 22px; }
  .lightbox-stage { margin: 0 22px; }
  .lightbox-stage { margin: 0 22px; }
  .lightbox-nav { width: 38px; height: 38px; }
  .lightbox-prev { inset-inline-start: 8px; }
  .lightbox-next { inset-inline-end: 8px; }
  .lightbox-thumbs { padding: 16px 22px 30px; gap: 8px; }
  .lightbox-thumbs button { flex-basis: 68px; height: 51px; }
}
