/* -----------------------------------------------------------------------
   Selfies of the World -- Styles
   ----------------------------------------------------------------------- */

/* -- Reset & base -------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f8f8f8;
  --bg-card: #fff;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #e0e0e0;
  --shadow: rgba(0, 0, 0, 0.08);
  --input-bg: #fff;
  --input-border: #ccc;
  --link: #0066cc;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111;
    --bg-card: #1a1a1a;
    --text: #e8e8e8;
    --text-muted: #999;
    --border: #333;
    --shadow: rgba(0, 0, 0, 0.3);
    --input-bg: #222;
    --input-border: #444;
    --link: #6cb4ee;
  }
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* -- Layout -------------------------------------------------------------- */

header {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2rem 1rem 1rem;
  text-align: center;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.preamble {
  max-width: 40rem;
  margin: 0 auto 1.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* -- Search -------------------------------------------------------------- */

.search-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  max-width: 28rem;
  margin: 1rem auto 1rem;
}

#search {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--input-border);
  border-radius: 0.5rem;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

#search:focus {
  border-color: var(--link);
}

#count {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* -- Image grid ---------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

figure {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 1px 3px var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

figure:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

figure[hidden] {
  display: none;
}

.card-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  background: var(--border);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.card-img.visible {
  opacity: 1;
  transform: none;
}

figcaption {
  padding: 0.5rem 0.625rem;
  font-size: 0.8rem;
  text-align: center;
  color: var(--text-muted);
}

/* -- Footer -------------------------------------------------------------- */

footer {
  text-align: center;
  padding: 2rem 1rem 3rem;
  color: var(--text-muted);
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
}

.github-link:hover {
  color: var(--text);
}

.github-link svg {
  flex-shrink: 0;
}

/* -- Responsive ---------------------------------------------------------- */

@media (max-width: 480px) {
  h1 {
    font-size: 1.5rem;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
  }

  figcaption {
    font-size: 0.7rem;
    padding: 0.375rem 0.5rem;
  }
}
