/* ============================================
   GPT-Image-2 Prompt Gallery — Styles
   Deep editorial / Gallery Museum aesthetic
   ============================================ */

/* --- CSS Variables --- */
:root {
  --bg-primary: #08080c;
  --bg-secondary: #0f1014;
  --bg-tertiary: #16171d;
  --accent: #c4956a;
  --accent-dim: #9a7352;
  --text-primary: #e8e4df;
  --text-secondary: #8a8580;
  --text-tertiary: #5a5550;
  --border: #1e1f26;
  --border-hover: #2a2b34;
  --code-bg: #0c0d12;
  --overlay: rgba(4, 4, 6, 0.92);

  --font-display: 'Cormorant Garamond', 'Noto Serif SC', serif;
  --font-body: 'Noto Sans SC', -apple-system, 'Helvetica Neue', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

body.modal-open {
  overflow: hidden;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: var(--text-primary);
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* --- Grain Overlay --- */
.grain-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.028;
}

/* --- Hero --- */
.hero {
  position: relative;
  padding: 5rem 2rem 3.5rem;
  text-align: center;
}

.hero__inner {
  max-width: 720px;
  margin: 0 auto;
  animation: fadeInUp 0.9s var(--ease-out-expo) both;
}

.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent-dim);
  margin-bottom: 1.5rem;
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  letter-spacing: 0.08em;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.hero__title--light {
  font-weight: 300;
  font-style: italic;
  color: var(--accent);
  display: block;
  font-size: 0.72em;
  letter-spacing: 0.15em;
  margin-top: 0.15em;
}

.hero__subtitle {
  font-size: 0.95rem;
  font-weight: 300;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  margin-bottom: 2.5rem;
}

.hero__stats {
  display: inline-flex;
  align-items: center;
  gap: 2rem;
  animation: fadeInUp 0.9s var(--ease-out-expo) 0.15s both;
}

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

.hero__stat-number {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 300;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

.hero__stat-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.hero__stat-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
}

.hero__border {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(90%, 600px);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border) 30%, var(--border) 70%, transparent);
}

/* --- Filter Bar --- */
.filter-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 8, 12, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  animation: fadeInUp 0.7s var(--ease-out-expo) 0.25s both;
}

.filter-bar__inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.filter-bar__tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  flex: 1;
  padding-bottom: 2px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.filter-bar__tabs::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  flex-shrink: 0;
  padding: 0.4rem 0.95rem;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 100px;
  transition: all 0.25s var(--ease-out-quart);
  white-space: nowrap;
}
.filter-tab:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: var(--bg-tertiary);
}
.filter-tab.active {
  color: var(--bg-primary);
  background: var(--accent);
  border-color: var(--accent);
}

.filter-tab__count {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  opacity: 0.6;
  margin-left: 0.35rem;
}

.filter-bar__search {
  position: relative;
  flex-shrink: 0;
  width: 220px;
}

.filter-bar__search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.filter-bar__search-input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 100px;
  outline: none;
  transition: all 0.3s;
}
.filter-bar__search-input::placeholder {
  color: var(--text-tertiary);
}
.filter-bar__search-input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(196, 149, 106, 0.08);
}

/* --- Gallery Section --- */
.gallery-section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}

/* Masonry via CSS columns */
.gallery {
  column-count: 4;
  column-gap: 1rem;
}

/* --- Card --- */
.card {
  break-inside: avoid;
  margin-bottom: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.35s var(--ease-out-expo),
              border-color 0.3s,
              box-shadow 0.35s var(--ease-out-expo);
  animation: cardReveal 0.5s var(--ease-out-expo) both;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.card__image-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: var(--bg-tertiary);
  min-height: 120px;
}

.card__image {
  width: 100%;
  display: block;
  opacity: 0;
  transition: opacity 0.5s var(--ease-out-quart);
}
.card__image.loaded {
  opacity: 1;
}

/* Shimmer skeleton */
.card__shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    var(--bg-tertiary) 30%,
    var(--border) 50%,
    var(--bg-tertiary) 70%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}
.card__shimmer.hidden {
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.card__body {
  padding: 0.85rem 1rem 1rem;
}

.card__title {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--accent-dim);
  background: rgba(196, 149, 106, 0.08);
  border: 1px solid rgba(196, 149, 106, 0.12);
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
  margin-bottom: 0.55rem;
}

.card__prompt-preview {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  line-height: 1.55;
  color: var(--text-tertiary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}

/* --- Empty State --- */
.gallery__empty {
  text-align: center;
  padding: 5rem 2rem;
}
.gallery__empty-icon {
  font-size: 2.5rem;
  color: var(--text-tertiary);
  margin-bottom: 1rem;
}
.gallery__empty-text {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}
.gallery__empty-hint {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

/* --- Loader --- */
.gallery__loader {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 0;
}
.gallery__loader[hidden] {
  display: none;
}
.gallery__loader-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: loaderPulse 1s ease-in-out infinite;
}
.gallery__loader-dot:nth-child(2) { animation-delay: 0.15s; }
.gallery__loader-dot:nth-child(3) { animation-delay: 0.3s; }

/* --- Infinite-scroll sentinel (invisible trigger element) --- */
.gallery__sentinel {
  width: 100%;
  height: 1px;
  pointer-events: none;
}

/* --- Modal --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s, visibility 0.35s;
}
.modal.open {
  opacity: 1;
  visibility: visible;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal__container {
  position: relative;
  width: min(92vw, 900px);
  max-height: 90vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.4s var(--ease-out-expo);
  scrollbar-width: thin;
  scrollbar-color: var(--text-tertiary) transparent;
}
.modal.open .modal__container {
  transform: scale(1) translateY(0);
}

.modal__close {
  position: sticky;
  top: 0;
  float: right;
  z-index: 10;
  width: 40px;
  height: 40px;
  font-size: 1.5rem;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin: 0.75rem 0.75rem 0 0;
  transition: color 0.2s, background 0.2s;
}
.modal__close:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.modal__body {
  padding: 0 2rem 2rem;
}

.modal__image-wrap {
  margin: -40px auto 1.5rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-tertiary);
}

.modal__image {
  width: 100%;
  display: block;
}

.modal__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.modal__meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.modal__category-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: rgba(196, 149, 106, 0.1);
  border: 1px solid rgba(196, 149, 106, 0.15);
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
}

.modal__source {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.modal__prompt-section {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.modal__prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal__prompt-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.modal__copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-tertiary);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: color 0.2s, background 0.2s;
}
.modal__copy-btn:hover {
  color: var(--accent);
  background: var(--bg-tertiary);
}
.modal__copy-btn.copied {
  color: #6ecf8e;
}

.modal__prompt-code {
  padding: 1rem 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}

/* --- Footer --- */
.footer {
  border-top: 1px solid var(--border);
  padding: 2rem;
}

.footer__inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer__left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.footer__brand {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.footer__sep {
  color: var(--text-tertiary);
}

.footer__link {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}
.footer__link:hover {
  color: var(--accent);
}

.footer__note {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-hover);
  padding: 0.55rem 1.2rem;
  border-radius: 100px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s var(--ease-out-expo);
  z-index: 2000;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardReveal {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes loaderPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

/* --- Responsive --- */
@media (max-width: 1440px) {
  .gallery { column-count: 3; }
}

@media (max-width: 1024px) {
  .gallery { column-count: 2; }
  .filter-bar__inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .filter-bar__search {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .gallery { column-count: 1; }

  .hero {
    padding: 3rem 1.25rem 2.5rem;
  }
  .hero__title {
    letter-spacing: 0.04em;
  }
  .hero__stats {
    gap: 1.5rem;
  }
  .hero__stat-number {
    font-size: 1.6rem;
  }

  .filter-bar {
    padding: 0.75rem 1rem;
  }

  .gallery-section {
    padding: 1.25rem 1rem 3rem;
  }

  .modal__body {
    padding: 0 1.25rem 1.5rem;
  }
  .modal__title {
    font-size: 1.2rem;
  }
  .modal__prompt-code {
    font-size: 0.72rem;
    max-height: 220px;
  }

  .footer__inner {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }
}
