/* ===================================================
   PRISM Gallery — style.css
   Dark editorial aesthetic: navy-black + amber + ivory
   =================================================== */

/* ── 1. CSS Variables & Theme ─────────────────────── */
:root {
  --bg:          #0c0d10;
  --bg2:         #13141a;
  --bg3:         #1c1e27;
  --surface:     #20222d;
  --border:      #2a2d3a;
  --border2:     #363a4d;
  --accent:      #e8a24a;
  --accent2:     #c47a28;
  --accent-glow: rgba(232, 162, 74, 0.18);
  --text:        #eae8e0;
  --text2:       #9a9898;
  --text3:       #5a5860;
  --white:       #ffffff;
  --danger:      #e05555;
  --trending:    #f4c430;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-ui:      'DM Sans', sans-serif;
  --font-mono:    'DM Mono', monospace;

  --radius:    8px;
  --radius-lg: 14px;
  --shadow:    0 4px 24px rgba(0,0,0,0.5);
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.35);
  --trans:     0.22s ease;
}

[data-theme="light"] {
  --bg:          #f5f3ee;
  --bg2:         #eeece6;
  --bg3:         #e5e2d9;
  --surface:     #ffffff;
  --border:      #d8d5cc;
  --border2:     #c5c1b5;
  --accent:      #c47a28;
  --accent2:     #a36120;
  --accent-glow: rgba(196, 122, 40, 0.14);
  --text:        #1a1916;
  --text2:       #5a5750;
  --text3:       #9a9790;
  --shadow:      0 4px 24px rgba(0,0,0,0.12);
  --shadow-sm:   0 2px 10px rgba(0,0,0,0.08);
}

/* ── 2. Reset & Base ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--trans), color var(--trans);
}

/* Subtle grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: var(--font-ui); border: none; background: none; }
select { font-family: var(--font-ui); }
input { font-family: var(--font-ui); }
a { color: var(--accent); text-decoration: none; }

/* ── 3. Header ────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Logo */
.logo {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
  text-decoration: none;
}
.logo-mark {
  font-size: 22px;
  color: var(--accent);
  line-height: 1;
}
.logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.12em;
  color: var(--text);
}
.logo-sub {
  font-size: 11px;
  font-weight: 300;
  color: var(--text3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-left: -4px;
}

/* Search */
.search-wrap {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 14px;
  font-size: 18px;
  color: var(--text3);
  pointer-events: none;
  line-height: 1;
}
.search-wrap input {
  width: 100%;
  padding: 9px 40px 9px 40px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 40px;
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--trans), box-shadow var(--trans);
  outline: none;
}
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-wrap input::placeholder { color: var(--text3); }
.search-clear {
  position: absolute;
  right: 12px;
  color: var(--text3);
  font-size: 12px;
  padding: 4px;
  display: none;
  transition: color var(--trans);
}
.search-clear:hover { color: var(--text); }
.search-clear.visible { display: block; }

/* Header actions */
.header-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }

.theme-toggle {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 18px;
  transition: background var(--trans), color var(--trans);
}
.theme-toggle:hover { background: var(--border); color: var(--accent); }

.upload-btn {
  padding: 8px 18px;
  background: var(--accent);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  border-radius: 40px;
  letter-spacing: 0.02em;
  transition: background var(--trans), transform var(--trans);
}
.upload-btn:hover { background: var(--accent2); transform: translateY(-1px); }

/* Filter bar */
.filter-bar {
  border-top: 1px solid var(--border);
  background: var(--bg2);
}
.filter-bar-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.category-filters {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.category-filters::-webkit-scrollbar { display: none; }

.cat-btn {
  padding: 5px 15px;
  border-radius: 40px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text2);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: all var(--trans);
  flex-shrink: 0;
}
.cat-btn:hover { color: var(--text); border-color: var(--border2); background: var(--bg3); }
.cat-btn.active {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

/* Sort */
.sort-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; flex-shrink: 0; }
.sort-wrap { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.sort-wrap select {
  padding: 5px 28px 5px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b6868'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  outline: none;
}
.sort-wrap select:focus { border-color: var(--accent); }

/* ── 4. Layout ─────────────────────────────────────── */
.layout {
  display: flex;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
  gap: 28px;
  padding-top: 24px;
  padding-bottom: 60px;
}

/* ── 5. Sidebar ────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 118px;
  height: fit-content;
}

.sidebar-section {}
.sidebar-heading {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 12px;
}

/* Tag cloud */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pill {
  padding: 3px 10px;
  border-radius: 40px;
  font-size: 11px;
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  transition: all var(--trans);
  background: transparent;
  font-family: var(--font-mono);
}
.tag-pill:hover { border-color: var(--accent); color: var(--accent); }
.tag-pill.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

/* CSS Filters panel */
.css-filters { display: flex; flex-direction: column; gap: 10px; }
.filter-row {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
}
.filter-row input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}
.slider-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.slider-row > span:first-child { font-size: 13px; color: var(--text2); }
.slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}
.slider-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text3);
}
.reset-filters-btn {
  margin-top: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text3);
  transition: all var(--trans);
  text-align: center;
}
.reset-filters-btn:hover { border-color: var(--danger); color: var(--danger); }

/* Stats box */
.stats-box {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stat-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stat-val {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--accent);
  line-height: 1;
}
.stat-lbl { font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text3); }

/* ── 6. Main Content ───────────────────────────────── */
.main-content { flex: 1; min-width: 0; }

.results-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.results-text {
  font-size: 12px;
  color: var(--text3);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}
.active-filters { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.active-tag-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 40px;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  font-size: 11px;
  color: var(--accent);
  font-family: var(--font-mono);
}
.active-tag-badge button { font-size: 10px; color: var(--accent); opacity: 0.7; padding: 0; }
.active-tag-badge button:hover { opacity: 1; }

.sidebar-toggle {
  display: none;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 40px;
  font-size: 12px;
  color: var(--text2);
  transition: all var(--trans);
}
.sidebar-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ── 7. Gallery Grid ───────────────────────────────── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

/* Card */
.gallery-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: transform var(--trans), box-shadow var(--trans), border-color var(--trans);
  animation: cardIn 0.35s ease both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.gallery-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--border2);
}
.gallery-card.trending { border-color: var(--trending); }
.gallery-card.trending::before {
  content: '🔥';
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  font-size: 14px;
  background: rgba(0,0,0,0.55);
  border-radius: 6px;
  padding: 3px 6px;
  line-height: 1.2;
}

.card-img-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4/3;
}
.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.gallery-card:hover .card-img-wrap img { transform: scale(1.06); }

/* Hover overlay */
.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(10,10,14,0.88) 0%, transparent 55%);
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 14px;
}
.gallery-card:hover .card-overlay { opacity: 1; }
.overlay-title {
  font-family: var(--font-display);
  font-size: 14px;
  color: #fff;
  font-style: italic;
  line-height: 1.3;
  margin-bottom: 5px;
}
.overlay-desc { font-size: 11px; color: rgba(255,255,255,0.65); line-height: 1.5; }

/* Views badge */
.views-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.55);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 2;
}

/* Card footer */
.card-info {
  padding: 11px 14px 13px;
  border-top: 1px solid var(--border);
}
.card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-cat {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
}
.card-date { font-size: 10px; color: var(--text3); font-family: var(--font-mono); }

/* ── 8. Empty State ────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 24px;
}
.empty-icon { font-size: 48px; opacity: 0.2; margin-bottom: 16px; }
.empty-title { font-family: var(--font-display); font-size: 22px; color: var(--text2); margin-bottom: 8px; }
.empty-sub { font-size: 14px; color: var(--text3); margin-bottom: 24px; }
.reset-all-btn {
  padding: 10px 24px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 40px;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--trans);
}
.reset-all-btn:hover { background: var(--accent2); }

/* Scroll sentinel */
.scroll-sentinel { height: 40px; }

/* Loading skeletons */
.skeleton {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
}
.skeleton-img {
  aspect-ratio: 4/3;
  background: linear-gradient(90deg, var(--bg3) 25%, var(--border) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
.skeleton-text { height: 12px; background: var(--bg3); border-radius: 4px; margin: 12px; }
.skeleton-text-sm { height: 10px; background: var(--bg3); border-radius: 4px; margin: 6px 12px; width: 60%; }
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ── 9. Lightbox ───────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
}
.lightbox.open { display: flex; }

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6,7,10,0.93);
  backdrop-filter: blur(6px);
  cursor: pointer;
}

.lightbox-inner {
  position: relative;
  z-index: 2;
  max-width: 820px;
  width: calc(100vw - 48px);
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 32px 80px rgba(0,0,0,0.7);
  animation: lbIn 0.28s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes lbIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

.lb-media { position: relative; background: #000; }
.lb-media img { width: 100%; max-height: 55vh; object-fit: contain; display: block; }
.lb-trending {
  position: absolute; top: 14px; left: 14px;
  background: var(--trending);
  color: #000;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
}

.lb-info { padding: 20px 24px 24px; }
.lb-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-style: italic;
  color: var(--text);
  margin-bottom: 10px;
}
.lb-meta { display: flex; gap: 16px; margin-bottom: 12px; }
.lb-cat { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); font-weight: 700; }
.lb-date { font-size: 12px; color: var(--text3); font-family: var(--font-mono); }
.lb-views { font-size: 12px; color: var(--text3); font-family: var(--font-mono); }
.lb-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.lb-tag {
  padding: 3px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 40px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text2);
}

/* Lightbox buttons */
.lb-btn {
  position: absolute;
  z-index: 3;
  background: rgba(20,21,28,0.85);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--trans), transform var(--trans);
}
.lb-btn:hover { background: var(--accent); color: var(--bg); }
.lb-close { top: 14px; right: 14px; width: 34px; height: 34px; font-size: 14px; }
.lb-prev  { top: 50%; left: 12px; transform: translateY(-50%); width: 40px; height: 40px; font-size: 22px; }
.lb-next  { top: 50%; right: 12px; transform: translateY(-50%); width: 40px; height: 40px; font-size: 22px; }
.lb-prev:hover { transform: translateY(-50%) scale(1.1); }
.lb-next:hover { transform: translateY(-50%) scale(1.1); }

/* ── 10. Upload Modal ──────────────────────────────── */
.upload-modal {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: none;
  align-items: center;
  justify-content: center;
}
.upload-modal.open { display: flex; }
.upload-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6,7,10,0.88);
  backdrop-filter: blur(6px);
  cursor: pointer;
}
.upload-inner {
  position: relative;
  z-index: 2;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 18px;
  padding: 32px;
  width: calc(100vw - 48px);
  max-width: 440px;
  box-shadow: var(--shadow);
  animation: lbIn 0.25s ease both;
}
.upload-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--trans);
}
.upload-close:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.upload-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-style: italic;
  color: var(--text);
  margin-bottom: 20px;
}
.dropzone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  margin-bottom: 20px;
  transition: border-color var(--trans), background var(--trans);
  color: var(--text3);
  font-size: 14px;
}
.dropzone.drag-over { border-color: var(--accent); background: var(--accent-glow); }
.drop-icon { font-size: 36px; color: var(--text3); margin-bottom: 10px; }
.drop-sub { margin: 6px 0; font-size: 12px; }
.browse-btn {
  padding: 7px 18px;
  border: 1px solid var(--border2);
  border-radius: 40px;
  font-size: 12px;
  color: var(--text2);
  margin-top: 10px;
  transition: all var(--trans);
  display: inline-block;
}
.browse-btn:hover { border-color: var(--accent); color: var(--accent); }

.upload-form { display: flex; flex-direction: column; gap: 10px; }
.upload-form input[type="text"],
.upload-form select {
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--trans);
}
.upload-form input:focus, .upload-form select:focus { border-color: var(--accent); }
.upload-form input::placeholder { color: var(--text3); }
.confirm-upload-btn {
  padding: 11px;
  background: var(--accent);
  color: var(--bg);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: background var(--trans);
}
.confirm-upload-btn:hover { background: var(--accent2); }

/* ── 11. Responsive ────────────────────────────────── */
@media (max-width: 1100px) {
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    height: 100dvh;
    z-index: 200;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    padding: 80px 20px 24px;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 240px;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .sidebar-toggle { display: flex; }
  .layout { padding-top: 20px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
}

@media (max-width: 600px) {
  .header-inner { padding: 0 16px; gap: 10px; }
  .logo-sub { display: none; }
  .filter-bar-inner { padding: 0 16px; }
  .layout { padding: 16px 16px 40px; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .lb-prev { left: 6px; }
  .lb-next { right: 6px; }
  .lb-info { padding: 14px 16px 18px; }
}

@media (max-width: 380px) {
  .gallery-grid { grid-template-columns: 1fr; }
}

/* ── 12. Utilities ─────────────────────────────────── */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 199;
  background: rgba(0,0,0,0.5);
}
.sidebar-overlay.open { display: block; }
