/* ================== Base Reset ================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  background-color: #ffffff;
  color: #222;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a {
  color: #3f51b5;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ================== Header ================== */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f0f0f0;
  padding: 1rem 2rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo-img {
  width: 160px;
  height: auto;
  user-select: none;
  pointer-events: none;
  filter: grayscale(80%) brightness(0) drop-shadow(0 0 2px #3f51b5);
}

.site-tagline {
  font-style: italic;
  font-size: 0.9rem;
  color: #555;
}

/* ================== Search ================== */
.search-container {
  max-width: 300px;
}

.search-container input {
  padding: 0.5rem 1.2rem;
  border-radius: 25px;
  border: 1px solid #ccc;
  width: 250px;
  font-size: 1rem;
  background-color: #fff;
  color: #222;
  transition: box-shadow 0.3s ease;
}

.search-container input::placeholder {
  color: #999;
}

.search-container input:focus {
  outline: none;
  box-shadow: 0 0 8px #3f51b5;
}

/* ================== Theme Toggle ================== */
.theme-toggle {
  margin-left: auto;
}

#theme-toggle-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  transition: transform 0.2s ease;
}

#theme-toggle-btn:hover {
  transform: scale(1.1);
}

/* ================== Main Layout ================== */
main {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  margin: auto;
  width: 100%;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.gallery-item {
  background-color: #e3e3e3;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: transform 0.3s ease;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
}

.gallery-item img {
  width: 100%;
  object-fit: cover;
  display: block;
  aspect-ratio: 4 / 3;
  user-select: none;
}

.gallery-item .info {
  padding: 0.8rem 1rem;
}

.gallery-item .info h2 {
  font-size: 1.2rem;
  color: #333;
}

.gallery-item .info p {
  font-size: 0.9rem;
  color: #555;
}

.meta {
  font-size: 0.8rem;
  color: #777;
  margin-top: 0.5rem;
  font-style: italic;
}

.tags {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  background-color: #e0e0e0;
  color: #333;
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: 12px;
  font-weight: 500;
  border: 1px solid #ccc;
}

/* ================== Pagination ================== */
.pagination {
  margin-top: 2rem;
  text-align: center;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pagination button {
  background-color: #f1f1f1;
  border: 1px solid #ccc;
  color: #222;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.3s ease;
}

.pagination button:hover:not(:disabled) {
  background-color: #3f51b5;
  color: white;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ================== Active Page Button ================== */
.pagination button.active {
  background-color: #3f51b5;
  color: white;
  border-color: #3f51b5;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(63, 81, 181, 0.18);
}

.pagination button:focus-visible {
  outline: 3px solid rgba(63, 81, 181, 0.18);
  outline-offset: 2px;
}

body.dark-mode .pagination button.active {
  background-color: #5c6bc0;
  color: #fff;
  border-color: #5c6bc0;
}

/* ================== Lightbox ================== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 2rem;
  font-size: 3rem;
  color: white;
  cursor: pointer;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  margin-bottom: 1rem;
}

.lightbox-caption {
  color: #ddd;
  text-align: center;
  font-size: 1rem;
  line-height: 1.5;
  max-width: 90vw;
}

/* Lightbox arrows */
.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
  color: white;
  background: none;
  border: none;
  cursor: pointer;
  padding: 1rem;
  z-index: 10000;
}

.lightbox-prev {
  left: 20px;
}
.lightbox-next {
  right: 20px;
}

/* ================== Footer ================== */
.site-footer {
  background-color: #f0f0f0;
  color: #555;
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.footer-links a {
  color: #3f51b5;
}

.footer-bottom {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: center;
}

.footer-attribution {
  font-size: 0.95rem;
  color: #666;
}

.footer-license {
  font-size: 0.8rem;
  color: #888;
}

/* ================== Dark Mode ================== */
body.dark-mode {
  background-color: #121212;
  color: #eaeaea;
}

body.dark-mode .site-header {
  background-color: #1e1e1e;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

body.dark-mode .logo-img {
  filter: drop-shadow(0 0 2px #3f51b5);
}

body.dark-mode .site-tagline {
  color: #eee;
}

body.dark-mode .site-footer {
  background-color: #1e1e1e;
  color: #bbb;
}

body.dark-mode .search-container input {
  background-color: #2a2a2a;
  color: #eee;
  border: 1px solid #444;
}

body.dark-mode .gallery-item {
  background-color: #1c1c1c;
}

body.dark-mode .gallery-item .info h2 {
  color: #fff;
}

body.dark-mode .gallery-item .info p,
body.dark-mode .meta,
body.dark-mode .tag {
  color: #ccc;
}

body.dark-mode .tag {
  background-color: #333;
  border: 1px solid #555;
}

body.dark-mode .pagination button {
  background-color: #222;
  color: #eee;
  border-color: #444;
}

body.dark-mode .pagination button:hover {
  background-color: #3f51b5;
  color: white;
}

body.dark-mode .footer-links a {
  color: #7098ff;
}

body.dark-mode .footer-license {
  color: #aaa;
}

/* ================== Responsive ================== */
@media (max-width: 768px) {
  .site-header {
    flex-direction: column;
    gap: 1rem;
  }

  .search-container input {
    width: 100%;
    max-width: 350px;
  }

  .footer-links {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }
}

/* ================== Download Button ================== */
.download-btn {
  display: inline-block;
  margin-top: 0.5rem;
  background-color: #3f51b5;
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  transition: background-color 0.3s ease;
}

.download-btn[aria-disabled="true"] { 
  cursor: not-allowed; 
}

.download-btn:hover {
  background-color: #5c6bc0;
  text-decoration: none;
}

body.dark-mode .download-btn {
  background-color: #5c6bc0;
  color: #fff;
}

body.dark-mode .download-btn:hover {
  background-color: #7986cb;
}

/* ===== Empty state card ===== */
.empty-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vmin;
  background: transparent;
}

.empty-card {
  width: 100%;
  height: 100%;
  text-align: center;
  padding: 6vmin 5vmin;
}

/*======Illustration========*/
.empty-illustration {
  display: flex;
  justify-content: center;
}
.empty-img {
  width: clamp(220px, 40vmin, 520px);
  height: auto;
  opacity: 0.95;
}

/*======Typography scales with viewport=====*/
.empty-title {
  margin: 1vmin 0 1vmin;
  font-size: clamp(25px, 4vmin, 50px);
  line-height: 1.15;
}
.empty-subtitle {
  margin: 0 0 4vmin;
  font-size: clamp(16px, 2.5vmin, 22px);
  color: #aab;
}

/*=====button========*/
.empty-actions {
  display: flex;
  justify-content: center;
}
.empty-home-btn {
  font-size: clamp(16px, 2.2vmin, 22px);
  padding: clamp(12px, 1.8vmin, 18px) clamp(20px, 3.2vmin, 36px);
  border-radius: 12px;
}

/*======Dark mode=======*/
body.dark-mode .empty-img {
  filter: brightness(0.9) saturate(0.9) contrast(1.05);
}
/* Error screen  */
/* ================== Full Page Error Screen ================== */
.error-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background-color: #fafafa;
  gap: 1.5rem;
  padding: 2rem;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.error-vector {
  width: 60vw;
  max-width: 500px;
  height: auto;
  user-select: none;
}

.error-screen h2 {
  font-size: 2rem;
  color: #d32f2f;
}

.error-screen p {
  font-size: 1.1rem;
  color: #555;
  max-width: 600px;
}

#retry-btn {
  background-color: #d32f2f;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

#retry-btn:hover {
  background-color: #b71c1c;
  transform: scale(1.05);
}

/* Dark mode styles */
body.dark-mode .error-screen {
  background-color: #121212;
}

body.dark-mode .error-screen h2 {
  color: #ef5350;
}

body.dark-mode .error-screen p {
  color: #ccc;
}

body.dark-mode #retry-btn {
  background-color: #ef5350;
}

body.dark-mode #retry-btn:hover {
  background-color: #e57373;
}

/* ================== Image fallback (for broken/unreachable images) ================== */
.img-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.6rem;
  color: #6b6b6b; /* uses currentColor for inline SVG */
  background-color: rgba(0, 0, 0, 0.03);
  border-radius: 8px;
  width: 100%;
  aspect-ratio: 4 / 3;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.02);
}

.img-fallback svg {
  width: 68%;
  height: auto;
  max-height: 72%;
}
.img-fallback-caption {
  font-size: 0.9rem;
  color: inherit;
  opacity: 0.9;
  text-align: center;
  padding: 0 0.4rem;
}

/* Light/dark mode adaptations */
body.dark-mode .img-fallback {
  color: #cfcfcf;
  background-color: rgba(255, 255, 255, 0.02);
}

/* Larger fallback when shown in lightbox area */
.lightbox .img-fallback {
  max-width: 90vw;
  max-height: 75vh;
}
