/* ============================================================
   GALLERY CSS — save as /assets/css/gallery.css
   ============================================================ */

/* ── IMAGE PROTECTION ────────────────────────────────────── */
.protected-img { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; pointer-events: none; }
.img-guard { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 2; background: transparent; cursor: pointer; }

/* ── MOSAIC ──────────────────────────────────────────────── */

#mosaic { display: none; position: absolute; inset: 0; background: var(--bg); overflow-y: auto; z-index: 50; }
#mosaic.active { display: flex; flex-direction: column; min-height: 100%; }
#mosaic-inner { padding: 10px 80px 0 20px; flex: 1; }
#mosaic-inner .site-footer .footer-inner { padding: 0; }
#mosaic-header { display: flex; align-items: baseline; justify-content: flex-start; padding: 20px 0 20px; }
#mosaic-title { display: none; }

#mosaic-back,
a#mosaic-back {
  background: none; border: none; cursor: pointer;
  font-family: 'Raleway', sans-serif; font-size: 13px;
  color: #a7a7a7; transition: color 0.2s; padding: 0; text-decoration: none;
}
#mosaic-back:hover, a#mosaic-back:hover { color: #555d62; }

#mosaic-grid {
  /* Row layout is handled by JS inline styles */
}

.mosaic-row { overflow: hidden; }
.mosaic-item { position: relative; cursor: pointer; overflow: hidden; }
.mosaic-item img {
  display: block;
  transition: opacity 0.4s ease;
}
.mosaic-caption { display: none; }
.mosaic-filename { display: none; }
.mosaic-placeholder {
  background: #e8e8e8;
  display: flex; align-items: center; justify-content: center;
}
.mosaic-placeholder svg { width: 24px; height: 24px; stroke: rgba(0,0,0,0.15); stroke-width: 1; fill: none; }
.mosaic-item img.thumb-loading { opacity: 0; }

/* ── VIEWER ──────────────────────────────────────────────── */

#viewer { display: none; position: absolute; inset: 0; overflow: hidden; background: var(--bg); z-index: 50; }
#viewer.active { display: flex; flex-direction: column; }
#viewer-inner { padding: 28px 20px 0 20px; display: flex; flex-direction: column; height: 100%; }
.container { display: flex; flex-direction: column; flex: 1; min-height: 0; }

#image-container {
  position: relative; width: 100%;
  display: flex; justify-content: center; align-items: flex-start;
  cursor: pointer; flex: 1; min-height: 0; overflow: hidden;
  outline: none; caret-color: transparent; -webkit-tap-highlight-color: transparent;
}
#main-image {
  display: block; max-width: 100%; max-height: 100%;
  width: auto; height: 100%; object-fit: contain;
  opacity: 0; transition: opacity var(--transition);
}
#main-image.loaded { opacity: 1; }
#main-image.fading { opacity: 0; }

/* ── CAPTION BAR (title only, matches counter font) ──────── */

#caption-bar { display: flex; flex-direction: column; align-items: center; padding: 10px 0 0px; flex-shrink: 0; width: 100%; }
#caption-bar-inner { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

/* ── BAR BOTTOM ──────────────────────────────────────────── */

#bar-bottom {
  display: flex; align-items: center;
  padding: 4px 0 30px; flex-shrink: 0;
  margin: 0 auto; position: relative;
}
#title-text {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(0,0,0,0.55);
  font-weight: 300;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
#counter {
  font-size: 0.65rem; color: rgba(0,0,0,0.3);
  flex-shrink: 0; min-width: 48px; text-align: center;
}
#bar-controls {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}

.nav-btn, .icon-btn {
  width: 38px; height: 38px; background: none; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0.5; transition: opacity 0.2s; text-decoration: none; padding: 0;
}
.nav-btn:hover, .icon-btn:hover { opacity: 1; }
.nav-btn svg, .icon-btn svg { width: 19px; height: 19px; stroke: #444; stroke-width: 1.5; fill: none; }
#btn-info { opacity: 0.5; }
#btn-info:hover { opacity: 1; }

/* ── INFO VIEW ───────────────────────────────────────────── */

#info-view { display: none; position: absolute; inset: 0; background: var(--bg); overflow-y: auto; z-index: 50; }
#info-view.active { display: flex; flex-direction: column; min-height: 100%; }
#info-inner { padding: 28px 50px 0 20px; flex: 1; }
#info-topbar { display: flex; justify-content: flex-start; padding: 0 0 20px; }
#info-close {
  background: none; border: none; cursor: pointer;
  font-family: 'Raleway', sans-serif; font-size: 13px;
  color: #a7a7a7; transition: color 0.2s; padding: 0;
}
#info-close:hover { color: #555d62; }
#info-content { display: flex; gap: 40px; align-items: flex-start; }
#info-meta { flex: 0 0 280px; min-width: 0; }
#info-right { flex: 1; min-width: 0; }
#info-image-wrap { position: relative; }
#info-image-wrap img { display: block; width: 100%; height: auto; object-fit: contain; }

.info-table { width: 100%; border-collapse: collapse; }
.info-table tr { border-bottom: 1px solid rgba(0,0,0,0.06); }
.info-table tr:last-child { border-bottom: none; }
.info-table td {
  font-family: 'Raleway', sans-serif; font-weight: 300; font-size: 0.72rem;
  color: rgba(0,0,0,0.45); padding: 7px 0; vertical-align: top;
}
.info-table td:first-child {
  color: rgba(0,0,0,0.3); letter-spacing: 0.08em;
  font-size: 0.6rem; width: 90px; padding-right: 12px;
}
.info-table td:last-child { color: rgba(0,0,0,0.55); }

#info-bar { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 0 0; }
#info-bar-controls { display: flex; align-items: center; gap: 10px; }
#info-counter {
  font-size: 0.65rem; color: rgba(0,0,0,0.3);
  min-width: 48px; text-align: center;
}

/* ── PASSWORD GATE ───────────────────────────────────────── */

.password-gate {
  display: flex; align-items: center; justify-content: center; height: 100vh;
}
.password-form { text-align: center; font-family: 'Raleway', sans-serif; }
.password-form label { display: block; font-size: 0.85rem; color: #888; margin-bottom: 16px; }
.password-form input {
  font-family: 'Raleway', sans-serif; font-size: 0.85rem;
  padding: 8px 14px; border: 1px solid #ccc; outline: none; margin-right: 8px;
}
.password-form button {
  font-family: 'Raleway', sans-serif; font-size: 0.85rem;
  padding: 8px 18px; background: #555; color: #fff; border: none; cursor: pointer;
}
.password-form button:hover { background: #333; }

.viewer-footer { display: none; }

/* ── CLEAN VIEW MODE ─────────────────────────────────────── */

#clean-view-exit {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  background: rgba(255,255,255,0.15);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
#clean-view-exit:hover { background: rgba(255,255,255,0.3); }
#clean-view-exit svg { width: 18px; height: 18px; stroke: #fff; stroke-width: 1.5; fill: none; }

@media (min-width: 1200px) {
  #viewer.clean-view #clean-view-exit { display: flex; }
}

#viewer.clean-view #viewer-inner { padding: 0; }
#viewer.clean-view #caption-bar,
#viewer.clean-view #bar-bottom { display: none; }
#viewer.clean-view #image-container {
  flex: 1;
  align-items: center;
  justify-content: center;
}
#viewer.clean-view #main-image {
  max-height: 100vh;
  max-width: 100%;
  height: 100%;
  object-fit: contain;
}
/* Fullscreen mode — #main fills entire screen */
#main:fullscreen,
#main:-webkit-full-screen {
  background: #000;
  width: 100vw;
  height: 100vh;
}
#main:fullscreen #viewer.clean-view,
#main:-webkit-full-screen #viewer.clean-view {
  background: #000;
}

/* ── NON-DESKTOP VIEWER BAR ─────────────────────────────── */

@media (max-width: 1199px) {
  #bar-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    align-self: center;
    padding: 4px 0 8px;
  }
  #title-text {
    text-align: center;
    padding: 0 0 4px;
  }
  #bar-controls {
    position: static;
    left: auto;
    transform: none;
    justify-content: center;
  }
}

/* ── TABLET LANDSCAPE ────────────────────────────────────── */

@media (max-width: 1199px) and (min-width: 1025px) {
  #viewer-inner {
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #image-container {
    flex: 0 1 auto;
    min-height: 0;
  }
  #main-image {
    max-height: calc(100vh - 180px);
    height: auto;
  }
  #caption-bar { flex-shrink: 0; }
  #bar-bottom { flex-shrink: 0; }
}

/* ── MOBILE ──────────────────────────────────────────────── */

@media (max-width: 1024px) {
  #mosaic-inner, .site-footer { padding-left: 20px; padding-right: 20px; }
  #mosaic-header { padding-left: 40px; }
  #info-inner { padding-left: 20px; padding-right: 20px; }
  #mosaic-grid .mosaic-row { flex-wrap: wrap; }
  #info-content { flex-direction: column-reverse; gap: 24px; }
  #info-meta { flex: none; width: 100%; }
  #info-right { width: 100%; }

  #viewer-inner {
    padding: 14px 20px 0 20px;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  #image-container {
    flex: 0 1 auto;
    min-height: 0;
    align-items: flex-start;
  }
  #main-image {
    max-height: calc(100vh - 160px);
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
  }
  #caption-bar { padding: 4px 0 0; }
}