/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #f5f2ee;
  color: #333;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Header ───────────────────────────────────────────────────────────────── */
header {
  padding: 52px 40px 36px;
  text-align: center;
  border-bottom: 1px solid #e0ddd9;
}

h1 {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 3rem;
  font-weight: 400;
  color: #1a1a1a;
  letter-spacing: -0.02em;
  font-optical-sizing: auto;
}

.subtitle {
  margin-top: 10px;
  color: #999;
  font-size: 15px;
  font-weight: 400;
}

/* ─── Controls ─────────────────────────────────────────────────────────────── */
.controls {
  padding: 20px 40px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  border-bottom: 1px solid #e0ddd9;
  position: sticky;
  top: 0;
  background: rgba(245, 242, 238, 0.96);
  backdrop-filter: blur(8px);
  z-index: 100;
}

/* Search */
.search-wrap {
  position: relative;
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: #aaa;
  pointer-events: none;
}

#search {
  padding: 9px 36px 9px 38px;
  border: 2px solid #ddd;
  border-radius: 25px;
  font-size: 14px;
  background: white;
  width: 240px;
  transition: width 0.25s ease, border-color 0.2s ease;
  outline: none;
  color: #333;
  font-family: inherit;
}

#search:focus {
  width: 320px;
  border-color: #888;
}

#search::placeholder { color: #bbb; }

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #aaa;
  font-size: 13px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}
.search-clear:hover { background: #eee; color: #555; }
.search-clear.hidden { display: none; }

/* Filter pills */
.filter-buttons {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-btn {
  padding: 7px 15px;
  border: 2px solid #ddd;
  border-radius: 25px;
  background: white;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit;
  color: #555;
  white-space: nowrap;
}

.filter-btn:hover { border-color: #aaa; color: #333; }

.filter-btn.active {
  background: #1a1a1a;
  border-color: #1a1a1a;
  color: white;
}

/* Count */
.count-display {
  margin-left: auto;
  color: #aaa;
  font-size: 13px;
  white-space: nowrap;
}

/* ─── Grid ─────────────────────────────────────────────────────────────────── */
main {
  padding: 36px 40px 60px;
  max-width: 1600px;
  margin: 0 auto;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 26px;
}

/* ─── Cards ────────────────────────────────────────────────────────────────── */
.gallery-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.11);
}

.card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #e8e4de;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.gallery-card:hover .card-image img {
  transform: scale(1.05);
}

/* placeholder while image loads */
.card-image img[src=""] {
  visibility: hidden;
}

.card-body {
  padding: 15px 17px 18px;
}

.card-date {
  font-size: 11px;
  color: #bbb;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}

.card-title {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.4;
  color: #1a1a1a;
  font-optical-sizing: auto;
}

/* ─── Card footer ──────────────────────────────────────────────────────────── */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 9px;
}

.card-count { font-size: 12px; color: #ccc; }

.photo-caption {
  font-style: italic;
  font-size: 0.97rem;
  font-weight: 400;
  color: #444;
}

/* Small liked-photo badge on card */
.card-liked-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #e74c3c;
  opacity: 0;
  transition: opacity 0.2s;
}

.card-liked-badge.visible { opacity: 1; }

.card-liked-badge svg {
  width: 12px;
  height: 12px;
  fill: #e74c3c;
  stroke: #e74c3c;
}

/* ─── Lightbox heart button ────────────────────────────────────────────────── */
.lb-footer {
  position: relative;
}

.lb-actions {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lb-like-btn {
  flex-shrink: 0;
  background: white;
  border: 2px solid #ddd;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, border-color 0.15s, background 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.lb-like-btn:hover {
  transform: scale(1.1);
  border-color: #e74c3c;
}

.lb-like-btn svg {
  width: 20px;
  height: 20px;
  stroke: #aaa;
  fill: none;
  transition: stroke 0.15s, fill 0.15s;
}

.lb-like-btn:hover svg { stroke: #e74c3c; }

.lb-like-btn.active {
  border-color: #e74c3c;
  background: #fff0ee;
}

.lb-like-btn.active svg {
  fill: #e74c3c;
  stroke: #e74c3c;
}

@keyframes likePopIn {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.lb-like-btn.pop { animation: likePopIn 0.3s ease; }

/* ─── Favs filter button ───────────────────────────────────────────────────── */
.favs-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.favs-btn.active {
  background: #e74c3c;
  border-color: #e74c3c;
  color: white;
}

.favs-btn.active:hover {
  background: #c0392b;
  border-color: #c0392b;
}

.favs-btn.active svg { stroke: white; }

/* ─── Stars filter button ──────────────────────────────────────────────────── */
.stars-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stars-btn.active {
  background: #e6a817;
  border-color: #e6a817;
  color: white;
}

.stars-btn.active:hover {
  background: #c98f10;
  border-color: #c98f10;
}

.stars-btn.active svg { stroke: white; fill: white; }

/* ─── Star badges on cards ─────────────────────────────────────────────────── */
.card-stars-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #e6a817;
  opacity: 0;
  transition: opacity 0.2s;
}

.card-stars-badge.visible { opacity: 1; }

.card-stars-badge svg {
  width: 11px;
  height: 11px;
  fill: #e6a817;
  stroke: #e6a817;
}

/* ─── Star count in lightbox ───────────────────────────────────────────────── */
.lb-stars {
  height: 44px;
  padding: 0 14px;
  border: 2px solid #e6a817;
  border-radius: 22px;
  background: white;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 20px;
  color: #e6a817;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  white-space: nowrap;
}

.lb-stars svg {
  width: 20px;
  height: 20px;
  fill: #e6a817;
  stroke: #e6a817;
  flex-shrink: 0;
}

.lb-stars.hidden { display: none; }

/* ─── States ───────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 40px;
  color: #bbb;
  font-size: 16px;
}

.empty-state.hidden { display: none; }

/* ─── Load More ────────────────────────────────────────────────────────────── */
#load-more {
  display: block;
  margin: 44px auto 0;
  padding: 13px 30px;
  background: #1a1a1a;
  color: white;
  border: none;
  border-radius: 25px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
  font-family: inherit;
}

#load-more:hover { background: #444; }
#load-more.hidden { display: none; }

/* ─── Lightbox ─────────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: #f5f2ee;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lightbox.hidden { display: none; }

#lb-close {
  position: absolute;
  top: 18px;
  right: 22px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #999;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
  z-index: 10;
  flex-shrink: 0;
}

#lb-close:hover { background: rgba(0,0,0,0.07); color: #333; }

.lb-header {
  padding: 22px 70px 14px 48px;
  flex-shrink: 0;
}

#lb-title {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 500;
  color: #1a1a1a;
  line-height: 1.35;
  font-optical-sizing: auto;
}

.lb-meta {
  margin-top: 4px;
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: #aaa;
}

/* Stage: prev | image | next */
.lb-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 16px;
  overflow: hidden;
}

.lb-image-wrap {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  display: block;
  transition: opacity 0.2s ease;
}

.lb-image-wrap.loading {
  background: #e8e4de;
  border-radius: 4px;
}

.lb-image-wrap.loading #lb-img {
  opacity: 0;
}

.lb-next-wrap {
  position: relative;
  flex-shrink: 0;
}

#lb-prev, #lb-next, #lb-next-gallery {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  background: white;
  border: 2px solid #ddd;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  color: #555;
}

#lb-next-gallery {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
}

#lb-prev:hover, #lb-next:hover, #lb-next-gallery:hover {
  background: #1a1a1a;
  border-color: #1a1a1a;
  color: white;
}

#lb-prev:disabled, #lb-next:disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

.lb-footer {
  flex-shrink: 0;
  padding: 30px 80px 24px;
  text-align: center;
  position: relative;
}

#lb-caption {
  font-size: 14px;
  color: #777;
  line-height: 1.55;
  font-style: italic;
  min-height: 22px;
}

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  h1 { font-size: 2.2rem; }
  header { padding: 36px 24px 28px; }
  .controls { padding: 16px 20px; }
  main { padding: 24px 20px 48px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
}

@media (max-width: 600px) {
  .gallery-grid { grid-template-columns: 1fr; }
  #search, #search:focus { width: 200px; }
  .lb-header { padding: 18px 56px 12px 20px; }
  .lb-stage { padding: 0 4px; }
  #lb-prev, #lb-next, #lb-next-gallery { display: none; }
  .lb-footer { padding: 12px 20px 20px; }
}
