/* FreePicHub — inherits Ascentek design language */

:root {
  --paper:    #f8f6f1;
  --paper-2:  #f0ede6;
  --surface:  #ffffff;
  --ink:      #0e1016;
  --ink-80:   rgba(14,16,22,.80);
  --ink-40:   rgba(14,16,22,.40);
  --ink-12:   rgba(14,16,22,.12);
  --ink-6:    rgba(14,16,22,.06);
  --accent:   #E8522A;
  --accent-h: #C93F1A;
  --green:    #0b7c5e;
  --serif:    'DM Serif Display', Georgia, serif;
  --sans:     'DM Sans', Helvetica, Arial, sans-serif;
  --radius:   16px;
  --hdr:      60px;
  --ease:     .18s ease;
}

html.dark {
  --paper:   #0e0e0c;
  --paper-2: #181714;
  --surface: #1e1d1a;
  --ink:      #f0ede8;
  --ink-80:   rgba(240,237,232,.80);
  --ink-40:   rgba(240,237,232,.40);
  --ink-12:   rgba(240,237,232,.12);
  --ink-6:    rgba(240,237,232,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  font-weight: 300;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 32px; }
@media (max-width: 640px) { .wrap { padding: 0 16px; } }

/* ── Header ─────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--hdr);
  background: rgba(248,246,241,.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--ink-12);
}

html.dark .site-header { background: rgba(14,14,12,.92); }

.header-inner {
  height: 100%; display: flex; align-items: center; gap: 16px;
}

.site-logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.logo-mark {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 14px;
  letter-spacing: -.5px; flex-shrink: 0;
}

.logo-name {
  font-size: 15px; font-weight: 500;
  letter-spacing: .01em; line-height: 1.2; display: block;
}

.logo-sub {
  font-size: 11px; color: var(--ink-40);
  display: block; letter-spacing: .02em;
}

.search-form {
  flex: 1; max-width: 520px;
  display: flex; align-items: center;
  background: var(--surface);
  border: 1px solid var(--ink-12);
  border-radius: 10px; overflow: hidden;
  transition: border-color var(--ease), box-shadow var(--ease);
}

.search-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232,82,42,.12);
}

.search-form input {
  flex: 1; padding: 9px 14px;
  border: none; background: transparent;
  color: var(--ink); font-size: 14px;
  outline: none; font-family: inherit; font-weight: 300;
}
.search-form input::placeholder { color: var(--ink-40); }

.search-form button {
  padding: 9px 13px; border: none; background: transparent;
  color: var(--ink-40); display: flex; align-items: center;
  transition: color var(--ease);
}
.search-form button:hover { color: var(--accent); }

.back-link {
  font-size: 12px; color: var(--ink-40);
  white-space: nowrap; padding: 5px 10px;
  border: 1px solid var(--ink-12); border-radius: 7px;
  transition: all var(--ease); letter-spacing: .01em;
}
.back-link:hover { color: var(--ink-80); border-color: var(--ink-40); }

/* ── Hero bar ────────────────────────────── */
.hero-bar {
  text-align: center;
  padding: 11px 20px;
  font-size: 14px;
  letter-spacing: .04em;
  color: var(--green);
  border-bottom: 1px solid var(--ink-6);
}
html.dark .hero-bar { color: #52c4a0; }

/* ── Tagline bar (between featured and filters) ── */
.tagline-bar {
  text-align: center;
  padding: 14px 20px;
  font-size: 13.5px;
  letter-spacing: .03em;
  color: var(--green);
}
html.dark .tagline-bar { color: #52c4a0; }

/* ── Filter bar ─────────────────────────── */
.filter-bar {
  border-bottom: 1px solid var(--ink-12);
  padding: 10px 0;
  background: var(--paper);
  position: sticky; top: var(--hdr); z-index: 90;
}

.filter-inner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}

.filter-label {
  font-size: 11px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-40);
}

.filter-select {
  appearance: none; -webkit-appearance: none;
  padding: 5px 26px 5px 10px;
  border: 1px solid var(--ink-12); border-radius: 8px;
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 7px center;
  color: var(--ink); font-size: 13px;
  font-family: inherit; font-weight: 300;
  transition: border-color var(--ease);
}
.filter-select:focus { outline: none; border-color: var(--accent); }

.filter-sep { width: 1px; height: 18px; background: var(--ink-12); }

.filter-count { font-size: 12px; color: var(--ink-40); margin-left: auto; }

.fav-toggle {
  padding: 5px 12px; border: 1px solid var(--ink-12); border-radius: 8px;
  background: transparent; color: var(--ink-40);
  font-size: 13px; transition: all var(--ease);
}
.fav-toggle:hover { border-color: var(--accent); color: var(--accent); }
.fav-toggle[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* ── Featured ───────────────────────────── */
.featured-section { padding: 28px 0 4px; }

.section-eyebrow {
  font-size: 0.72rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-40);
  margin-bottom: 12px;
}

.featured-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px; margin-bottom: 28px;
}
@media (max-width: 640px) {
  .featured-grid { grid-template-columns: 1fr; }
}

/* ── Gallery ────────────────────────────── */
.gallery-section { padding: 20px 0 72px; }

.image-grid {
  columns: 4 220px;
  gap: 14px;
}

/* ── Image Card ─────────────────────────── */
.image-card {
  break-inside: avoid;
  margin-bottom: 14px;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--ink-6);
}

.card-img-wrap { position: relative; overflow: hidden; display: block; }

.card-img {
  width: 100%; height: auto; display: block;
  transition: transform .45s ease;
}
.image-card:hover .card-img { transform: scale(1.04); }

/* Featured cards: enforce uniform aspect-ratio so all 3 are the same height */
.card-featured .card-img { object-fit: cover; }

.card-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(14,16,22,.0) 35%,
    rgba(14,16,22,.65) 100%
  );
  opacity: 0; transition: opacity var(--ease);
  display: flex; flex-direction: column;
  justify-content: space-between; padding: 10px;
}
.image-card:hover .card-overlay { opacity: 1; }

.overlay-top { display: flex; justify-content: flex-end; }
.overlay-bot { display: flex; align-items: flex-end; justify-content: space-between; }

.overlay-btn {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(255,255,255,.14);
  backdrop-filter: blur(8px);
  color: #fff; border: 1px solid rgba(255,255,255,.22);
  display: grid; place-items: center;
  font-size: 15px; transition: background var(--ease), transform var(--ease);
}
.overlay-btn:hover { background: rgba(255,255,255,.26); transform: scale(1.08); }
.overlay-btn.is-faved { color: #FF6B6B; }

.source-badge {
  font-size: 10px; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase;
  color: rgba(255,255,255,.95);
  background: rgba(14,16,22,.5);
  backdrop-filter: blur(6px);
  padding: 3px 8px; border-radius: 5px;
  border: 1px solid rgba(255,255,255,.1);
}
.source-badge.source-pixabay { background: rgba(27,130,72,.7); }
.source-badge.source-pexels  { background: rgba(4,126,234,.7); }
.source-badge.source-cgfaces { background: rgba(140,50,190,.7); }

/* ── Grid status ────────────────────────── */
.grid-status {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 56px 0;
  color: var(--ink-40); font-size: 14px;
}
.grid-status.hidden { display: none; }

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--ink-12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pagination ─────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; padding: 36px 0 8px;
}
.pagination button {
  padding: 9px 24px; border: 1px solid var(--ink-12); border-radius: 9px;
  background: var(--surface); color: var(--ink-80);
  font-size: 14px; font-weight: 300;
  transition: all var(--ease);
}
.pagination button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pagination button:disabled { opacity: .3; cursor: not-allowed; }
#pageInfo { font-size: 13px; color: var(--ink-40); min-width: 56px; text-align: center; }

/* ── Modal ──────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(14,16,22,.78);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade-in .15s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }

.modal-box {
  background: var(--surface);
  border-radius: 20px;
  max-width: 940px; width: 100%;
  max-height: 90vh; overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 296px;
  position: relative;
  border: 1px solid var(--ink-12);
  animation: slide-up .22s ease;
}
@keyframes slide-up {
  from { transform: translateY(16px); opacity: 0 }
  to   { transform: none; opacity: 1 }
}

@media (max-width: 640px) {
  .modal-box {
    grid-template-columns: 1fr;
    max-height: 95vh;
    overflow-y: auto;
  }
}

.modal-close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; border: none;
  background: rgba(14,16,22,.5); backdrop-filter: blur(8px);
  border-radius: 50%; color: #fff; font-size: 18px;
  z-index: 10; display: grid; place-items: center;
  transition: background var(--ease);
}
.modal-close:hover { background: rgba(14,16,22,.75); }

.modal-preview {
  background: var(--paper-2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  border-radius: 20px 0 0 20px;
  min-height: 340px;
}
@media (max-width: 640px) {
  .modal-preview { border-radius: 20px 20px 0 0; min-height: 220px; }
}

.modal-preview img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}

.modal-side {
  padding: 28px 22px 22px;
  display: flex; flex-direction: column; gap: 20px;
  overflow-y: auto;
  border-left: 1px solid var(--ink-12);
}

.modal-eyebrow {
  font-size: 0.72rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-40);
}

.modal-title {
  font-family: var(--serif);
  font-size: 18px; line-height: 1.45;
  color: var(--ink);
}

.modal-specs {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 0;
  border-top: 1px solid var(--ink-6);
  border-bottom: 1px solid var(--ink-6);
}
.spec-row {
  display: flex; align-items: center;
  justify-content: space-between; font-size: 13px;
}
.spec-label { color: var(--ink-40); }
.spec-val   { font-weight: 400; color: var(--ink-80); }

.license-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 7px;
}
.license-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 10px;
  background: var(--paper-2);
  border-radius: 9px; font-size: 12px;
  color: var(--ink-80);
}
.ok { color: #16a34a; }
.no { color: var(--ink-40); }

.modal-actions {
  margin-top: auto; display: flex; flex-direction: column; gap: 8px;
}

.btn-dl {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 16px; border-radius: 11px;
  background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 500; border: none;
  text-decoration: none; font-family: inherit;
  transition: background var(--ease), transform var(--ease);
}
.btn-dl:hover { background: var(--accent-h); transform: translateY(-1px); }

.btn-fav {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: 11px;
  background: transparent; color: var(--ink-80);
  font-size: 14px; border: 1px solid var(--ink-12);
  font-family: inherit; transition: all var(--ease);
}
.btn-fav:hover { border-color: var(--accent); color: var(--accent); }

.pexels-note {
  font-size: 11.5px; color: var(--ink-40);
  text-align: center; line-height: 1.65;
}

/* ── Footer ─────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--ink-12);
  padding: 28px 0;
  font-size: 13px; color: var(--ink-40);
  text-align: center; line-height: 2;
}
.site-footer a { border-bottom: 1px solid var(--ink-12); }
.site-footer a:hover { color: var(--ink-80); }
