/* DEVELOPED AND WRITTEN: BilalDevDex */

/* ============ CSS VARIABLES — THEMES ============ */
[data-theme="dark"] {
  --bg:             #0a0a0a;
  --surface:        #111111;
  --surface-hover:  #1a1a1a;
  --text:           #f0eee8;
  --text-secondary: #888888;
  --accent:         #a7c080;
  --border:         #222222;
  --overlay:        rgba(0,0,0,0.85);
}

[data-theme="light"] {
  --bg:             #f2efdf;
  --surface:        #e9e4d0;
  --surface-hover:  #ddd8c4;
  --text:           #2d2d2d;
  --text-secondary: #5c6a72;
  --accent:         #8da101;
  --border:         #d0cbb8;
  --overlay:        rgba(0,0,0,0.6);
}

[data-theme="everforest"] {
  --bg:             #2d353b;
  --surface:        #343f44;
  --surface-hover:  #3d4a50;
  --text:           #d3c6aa;
  --text-secondary: #859289;
  --accent:         #e69875;
  --border:         #3d4a50;
  --overlay:        rgba(0,0,0,0.85);
}

/* ============ RESET ============ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
}

/* ============ NAVBAR ============ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 60px;
  background-color: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  /* subtle blur for depth when scrolling over images */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-icon {
  height: 36px;
  width: 36px;
  object-fit: contain;
}

.brand-name {
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.icon-btn:hover {
  background: var(--surface-hover);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: var(--text);
  fill: none;
}

/* ============ SEARCH ============ */
.search-wrapper {
  padding: 24px 24px 16px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 16px;
  height: 52px;
  transition: border-color 0.2s ease;
}

.search-bar:focus-within {
  border-color: var(--accent);
}

/* search icon from lucide */
.search-icon {
  flex-shrink: 0;
}

.search-bar svg {
  width: 18px;
  height: 18px;
  stroke: var(--text-secondary);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
}

.search-bar input::placeholder {
  color: var(--text-secondary);
}

/* ============ SENTINEL ============ */
#sentinel {
  height: 1px;
  width: 100%;
}

/* ============ MASONRY GRID ============ */
.grid {
  columns: 3;
  column-gap: 12px;
  padding: 16px 24px;
}

.card {
  break-inside: avoid;
  margin-bottom: 12px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: var(--surface);
}

.card img {
  width: 100%;
  display: block;
  transition: transform 0.3s ease;
}

.card:hover img {
  transform: scale(1.03);
}

/* ============ CARD OVERLAY ============ */
.card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px;
  background: linear-gradient(transparent, var(--overlay));
  display: flex;
  gap: 8px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.card:hover .card-overlay {
  opacity: 1;
  transform: translateY(0);
}

.card-overlay button {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.2s ease;
}

.btn-preview {
  background: rgba(255,255,255,0.15);
  color: #ffffff;
  backdrop-filter: blur(4px);
}

.btn-download {
  background: var(--accent);
  color: #0a0a0a;
}

.btn-preview:hover  { background: rgba(255,255,255,0.25); }
.btn-download:hover { filter: brightness(1.1); }

/* ============ MODAL ============ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal.active {
  opacity: 1;
  pointer-events: all;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.9);
}

.modal-content {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.modal-content img {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 8px;
  object-fit: contain;
}

.modal-close {
  position: absolute;
  top: -16px;
  right: -16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.modal-close:hover {
  background: var(--surface-hover);
}

.modal-close svg {
  width: 14px;
  height: 14px;
  stroke: var(--text);
}

.modal-download {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 28px;
  background: var(--accent);
  color: #0a0a0a;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: filter 0.2s ease;
}

.modal-download:hover {
  filter: brightness(1.1);
}

.modal-download svg {
  width: 16px;
  height: 16px;
  stroke: #0a0a0a;
}

.modal-credit {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.modal-credit a {
  color: var(--accent);
  text-decoration: none;
}

.modal-credit a:hover {
  text-decoration: underline;
}

/* ============ END MESSAGE ============ */
.end-message {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  display: none;
}

.end-message.visible {
  display: block;
}

/* ============ RELOAD BUTTON ============ */
.reload-btn {
  display: block;
  margin: 16px auto 0;
  padding: 10px 28px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  transition: background 0.2s ease;
}

.reload-btn:hover {
  background: var(--surface-hover);
}

/* ============ MEDIA QUERIES ============ */
@media (max-width: 1024px) {
  .grid { columns: 3; }
}

@media (max-width: 768px) {
  .grid {
    columns: 2;
    padding: 12px 16px;
  }

  .navbar {
    padding: 0 16px;
  }

 .brand-name {
  white-space: nowrap;
  overflow: visible;
}

  .search-wrapper {
    padding: 16px 16px 12px;
  }
}

@media (max-width: 480px) {
  .grid { columns: 2; }

  .icon-btn {
    width: 36px;
    height: 36px;
  }
}
