/* =========================================================
   Photos app — all selectors scoped under .app-photos
   Uses CSS custom properties from reset.css for dark-mode
   ========================================================= */

/* ── Root layout: sidebar + main pane ── */
.app-photos .photos-app-root {
  display: flex;
  height: 100%;
  background: var(--win-bg);
  color: var(--win-fg);
  overflow: hidden;
  position: relative;
}

/* ─────────────────────────────────────────────
   SIDEBAR
   ───────────────────────────────────────────── */
.app-photos .ph-sidebar {
  width: 196px;
  flex: 0 0 196px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 0.5px solid var(--sidebar-border);
  padding: 14px 10px 10px;
  overflow-y: auto;
  font-size: 13px;
}

.app-photos .ph-sb-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--win-muted);
  padding: 10px 8px 4px;
}

.app-photos .ph-sb-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--sidebar-fg);
  cursor: default;
  font-size: 13px;
  transition: background 0.12s ease;
}

.app-photos .ph-sb-row:hover {
  background: var(--win-hover);
}

.app-photos .ph-sb-row.active {
  background: var(--accent);
  color: #fff;
}

.app-photos .ph-sb-icon {
  width: 20px;
  text-align: center;
  font-size: 14px;
}

/* ─────────────────────────────────────────────
   MAIN AREA
   ───────────────────────────────────────────── */
.app-photos .ph-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--win-bg);
}

/* ── Toolbar / Segmented Control ── */
.app-photos .ph-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-bottom: 0.5px solid var(--win-border);
  background: var(--win-bg);
}

.app-photos .ph-seg-ctrl {
  display: inline-flex;
  background: var(--control-bg);
  border-radius: 9px;
  padding: 2px;
  gap: 1px;
}

.app-photos .ph-seg-btn {
  padding: 5px 16px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--win-fg);
  cursor: default;
  transition: background 0.14s ease, color 0.14s ease;
}

.app-photos .ph-seg-btn:hover:not(.active) {
  background: var(--win-hover);
}

.app-photos .ph-seg-btn.active {
  background: var(--win-bg);
  color: var(--win-fg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

html.dark .app-photos .ph-seg-btn.active {
  background: rgba(255,255,255,0.14);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* ── Scrollable grid area ── */
.app-photos .ph-grid-area {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

/* ── Group label ── */
.app-photos .ph-group {
  margin-bottom: 20px;
}

.app-photos .ph-group-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--win-fg);
  margin-bottom: 8px;
  padding: 0 2px;
}

/* ── Photo grid ── */
.app-photos .ph-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 5px;
}

/* ── Photo cell ── */
.app-photos .ph-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  cursor: default;
  transition: transform 0.14s var(--ease-out), box-shadow 0.14s ease;
}

.app-photos .ph-cell:hover {
  transform: scale(1.025);
  box-shadow: 0 6px 20px rgba(0,0,0,0.28);
  z-index: 1;
}

.app-photos .ph-cell:active {
  transform: scale(0.97);
}

/* Caption: revealed on hover */
.app-photos .ph-cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 18px 8px 6px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.45) 100%);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
  line-height: 1.3;
}

.app-photos .ph-cell:hover .ph-cap {
  opacity: 1;
}

/* Heart: top-right, visible on hover + always visible when favorited */
.app-photos .ph-heart {
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 15px;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.12s ease;
  cursor: default;
  background: none;
  border: none;
  padding: 2px;
  border-radius: 4px;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.app-photos .ph-cell:hover .ph-heart,
.app-photos .ph-heart:not([data-fav="false"]) {
  opacity: 1;
}

/* Always show heart if the content is ❤️ (favorited) */
.app-photos .ph-heart:first-child {
  opacity: 0;
}

.app-photos .ph-cell:hover .ph-heart {
  opacity: 1;
}

/* Target the heart that contains the red heart emoji */
.app-photos .ph-heart[title="Unfavorite"] {
  opacity: 1;
}

.app-photos .ph-heart:hover {
  transform: scale(1.25);
}

/* ── Empty state ── */
.app-photos .ph-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 20px;
  color: var(--win-muted);
  font-size: 14px;
  height: 100%;
}

.app-photos .ph-empty-icon {
  font-size: 52px;
  opacity: 0.5;
}

/* ─────────────────────────────────────────────
   LIGHTBOX
   ───────────────────────────────────────────── */
.app-photos .ph-lightbox {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: ph-lb-in 0.18s var(--ease-out) forwards;
}

.app-photos .ph-lightbox.hidden {
  display: none;
}

@keyframes ph-lb-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.app-photos .ph-lb-panel {
  position: relative;
  display: grid;
  /* prev | image | next stacked, with info and counter and actions below */
  grid-template-columns: 48px 1fr 48px;
  grid-template-rows: 1fr auto auto auto;
  width: min(90%, 700px);
  height: min(88%, 560px);
  gap: 0;
}

/* Close button — top-right of lightbox */
.app-photos .ph-lb-close {
  position: absolute;
  top: -36px;
  right: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: default;
  transition: background 0.12s ease;
  border: none;
  line-height: 1;
}

.app-photos .ph-lb-close:hover {
  background: rgba(255,255,255,0.30);
}

/* Image tile */
.app-photos .ph-lb-img {
  grid-column: 2;
  grid-row: 1;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  min-height: 0;
}

/* Nav buttons */
.app-photos .ph-lb-nav {
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: rgba(255,255,255,0.9);
  cursor: default;
  border: none;
  background: none;
  border-radius: 8px;
  transition: background 0.12s ease, color 0.12s ease;
  padding: 0;
  line-height: 1;
}

.app-photos .ph-lb-prev { grid-column: 1; }
.app-photos .ph-lb-next { grid-column: 3; }

.app-photos .ph-lb-nav:hover:not(.disabled) {
  background: rgba(255,255,255,0.14);
}

.app-photos .ph-lb-nav.disabled {
  color: rgba(255,255,255,0.25);
  cursor: default;
  pointer-events: none;
}

/* Info row: caption + date */
.app-photos .ph-lb-info {
  grid-column: 1 / 4;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 0 6px;
}

.app-photos .ph-lb-caption {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

.app-photos .ph-lb-date {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
}

/* Counter */
.app-photos .ph-lb-counter {
  grid-column: 1 / 4;
  grid-row: 3;
  text-align: center;
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  padding-bottom: 4px;
}

/* Actions bar */
.app-photos .ph-lb-actions {
  grid-column: 1 / 4;
  grid-row: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 0 0;
}

.app-photos .ph-lb-heart,
.app-photos .ph-lb-action {
  font-size: 20px;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: default;
  border: none;
  transition: background 0.14s ease, transform 0.1s ease;
}

.app-photos .ph-lb-heart:hover,
.app-photos .ph-lb-action:hover {
  background: rgba(255,255,255,0.24);
  transform: scale(1.1);
}

.app-photos .ph-lb-heart:active,
.app-photos .ph-lb-action:active {
  transform: scale(0.92);
}
