/* ============================================================== */
/* developments/css/gallery.css — Gallery browse surface           */
/* (GALLERY-VIEW-SPEC §3). Namespaced .dev-gallery* — zero bleed.   */
/*                                                                  */
/* Expand mechanism MIRRORS admin-v2.css L14-28: when gallery.js    */
/* mounts it sets body[data-gallery-active=1]; that widens #dev-nav */
/* into a WIDE STRIP (not a full overlay) so the map stays visible  */
/* on the left. A MutationObserver in gallery.js drops the attr     */
/* when another panel replaces #dev-nav (admin-v2's unmount rule).  */
/* ============================================================== */

body[data-gallery-active="1"] #dev-nav {
  /* Wide strip: map keeps a ~320-380px sliver on the left; capped at
     1100px so ultra-wide monitors don't stretch cards edge-to-edge. */
  width: min(1100px, calc(100vw - 380px));
}
body[data-gallery-active="1"] .mapboxgl-ctrl-bottom-right {
  right: calc(60px + 16px + min(1100px, 100vw - 380px) + 8px) !important;
}
/* Below 1024px the panel is full-flow (same as admin-v2); take the
   width we're given rather than forcing a strip on small screens. */
@media (max-width: 1023px) {
  body[data-gallery-active="1"] #dev-nav {
    width: 100%;
    max-width: none;
  }
}

/* ==================== shell ==================== */
.dev-gallery {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--text);
}

/* Sticky header so search + sort stay reachable while the grid scrolls. */
.dev-gallery__head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-paper);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 12px;
}
.dev-gallery__titlerow {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}
.dev-gallery__title {
  font-family: var(--font-display, var(--font-body));
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.dev-gallery__count {
  font-size: var(--text-caption);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.dev-gallery__controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.dev-gallery__search {
  position: relative;
  flex: 1 1 200px;
  display: flex;
  align-items: center;
}
.dev-gallery__search-glyph {
  position: absolute;
  left: 10px;
  color: var(--text-faint);
  font-size: 15px;
  pointer-events: none;
}
.dev-gallery__search-input {
  width: 100%;
  height: 34px;
  padding: 0 10px 0 30px;
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
}
.dev-gallery__search-input:focus {
  border-color: var(--gold);
  box-shadow: var(--focus-ring);
}
.dev-gallery__sortwrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-caption);
  color: var(--text-muted);
}
.dev-gallery__sort {
  height: 34px;
  padding: 0 8px;
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.dev-gallery__sort:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: var(--focus-ring);
}
/* "Photos first" toggle — same inline caption idiom as the sort control. */
.dev-gallery__toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-caption);
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.dev-gallery__toggle-input {
  width: 15px;
  height: 15px;
  accent-color: var(--gold);
  cursor: pointer;
}
.dev-gallery__toggle-label {
  white-space: nowrap;
}

/* ==================== body / grid ==================== */
.dev-gallery__body {
  padding: 14px 16px 24px;
}
.dev-gallery__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.dev-gallery__sentinel {
  height: 1px;
}

.dev-gallery__state {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.dev-gallery__state--error p { margin: 0 0 12px; }
.dev-gallery__retry {
  height: 34px;
  padding: 0 16px;
  font: 500 var(--text-sm)/1 var(--font-body);
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.dev-gallery__retry:hover { background: var(--bg-subtle); }
.dev-gallery__empty {
  grid-column: 1 / -1;
  padding: 40px 8px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ==================== card ==================== */
.dev-gallery-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform var(--duration-base, 0.16s) var(--ease-out, ease),
    box-shadow var(--duration-base, 0.16s) var(--ease-out, ease),
    border-color var(--duration-base, 0.16s) var(--ease-out, ease);
}
.dev-gallery-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.dev-gallery-card:focus-visible {
  outline: none;
  border-color: var(--gold);
  box-shadow: var(--focus-ring);
}

.dev-gallery-card__photo {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface-sunken, var(--bg-subtle));
  overflow: hidden;
}
.dev-gallery-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.dev-gallery-card__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono, monospace);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-faint);
  background: var(--surface-sunken, var(--bg-subtle));
}

.dev-gallery-card__count {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border-radius: var(--radius-pill);
  line-height: 1.5;
}
.dev-gallery-card__stage {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: calc(100% - 16px);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  background: rgba(0, 0, 0, 0.62);
  border-radius: var(--radius-pill);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dev-gallery-card__stage-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dev-gallery-card__body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px 12px;
}
.dev-gallery-card__name {
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
  /* clamp to two lines so cards stay even-height in the grid */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dev-gallery-card__addr {
  font-size: var(--text-caption);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dev-gallery-card__specs {
  margin-top: 2px;
  font-size: var(--text-caption);
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.dev-gallery-card__meta {
  font-size: var(--text-caption);
  color: var(--text-faint);
}

/* Reduced motion: no hover lift. */
@media (prefers-reduced-motion: reduce) {
  .dev-gallery-card { transition: none; }
  .dev-gallery-card:hover { transform: none; }
}

/* Narrow panel (mobile / full-flow): single/again-fluid columns. */
@media (max-width: 540px) {
  .dev-gallery__grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
  }
  .dev-gallery__body { padding: 12px 12px 20px; }
}
