/* ════════════════════════════════════════════════════════════
   DT Gallery — Image Search UI
   ════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:    #1a73e8;
  --accent-hv: #1558b0;
  --bg:        #fff;
  --surface:   #f8f9fa;
  --border:    #dadce0;
  --text:      #202124;
  --muted:     #5f6368;
  --chip-bg:   #f1f3f4;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.15);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.18);
  --radius:    24px;
  --drawer-w:  420px;
  --topbar-h:  64px;
  --filter-h:  52px;
  font-family: 'Inter', system-ui, sans-serif;
}

html { font-size: 15px; color: var(--text); background: var(--bg); }
body { min-height: 100vh; }

/* ── Utilities ─────────────────────────────────────────────── */
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Scrollbar (WebKit) ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* ══════════════════════════════════════════════════════════════
   LOGO
   ══════════════════════════════════════════════════════════════ */
.logo { font-size: 2.8rem; font-weight: 700; letter-spacing: -1px; line-height: 1; }
.logo-d { color: #4285f4; }
.logo-t { color: #ea4335; }
.logo-g { color: var(--muted); font-size: 2rem; margin-left: 4px; font-weight: 400; }

/* ══════════════════════════════════════════════════════════════
   SEARCH BOX (shared)
   ══════════════════════════════════════════════════════════════ */
.search-box {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  transition: box-shadow .2s, border-color .2s;
  overflow: hidden;
}
.search-box:focus-within {
  box-shadow: 0 1px 6px rgba(32,33,36,.28);
  border-color: transparent;
}
.search-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  color: var(--muted);
  margin: 0 12px;
}
.search-box input[type="search"] {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  color: var(--text);
  padding: 0;
}
.search-box input[type="search"]::-webkit-search-cancel-button { display: none; }

/* ══════════════════════════════════════════════════════════════
   LANDING PAGE
   ══════════════════════════════════════════════════════════════ */
.landing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}
.landing-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  max-width: 680px;
}
.landing-sub {
  color: var(--muted);
  font-size: .95rem;
}
.landing-form { width: 100%; }
.landing-search-box {
  height: 52px;
  padding: 0 8px 0 0;
  box-shadow: var(--shadow-sm);
}
.landing-search-box input { font-size: 1.05rem; padding: 0 4px; }

/* Primary button */
.btn-primary {
  padding: 0 22px;
  height: 36px;
  background: var(--accent);
  color: #fff;
  border-radius: 20px;
  font-size: .9rem;
  font-weight: 500;
  flex-shrink: 0;
  margin: 0 4px;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hv); }

/* Chip suggestions */
.landing-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.chip {
  padding: 6px 14px;
  background: var(--chip-bg);
  border-radius: 20px;
  font-size: .85rem;
  color: var(--text);
  transition: background .15s;
}
.chip:hover { background: #e2e5e9; }

.landing-albums {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}
.landing-albums-label {
  font-size: .8rem;
  color: var(--text-muted, #888);
  white-space: nowrap;
}
.album-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 14px;
  background: var(--chip-bg);
  border-radius: 20px;
  font-size: .85rem;
  color: var(--text);
  text-decoration: none;
  transition: background .15s;
}
.album-link:hover { background: #e2e5e9; }

/* ══════════════════════════════════════════════════════════════
   RESULTS PAGE
   ══════════════════════════════════════════════════════════════ */
.results-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-right: 0;
  transition: padding-right .3s;
}
.results-page.drawer-open { padding-right: var(--drawer-w); }

/* ── Top bar ──────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}
.topbar-logo {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}
.topbar-form { flex: 1; max-width: 640px; }
.topbar-search-box {
  height: 44px;
  padding: 0 4px 0 0;
}
.topbar-search-box input { font-size: .95rem; padding: 0 4px; }

.btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  flex-shrink: 0;
  transition: background .15s;
}
.btn-icon:hover { background: var(--chip-bg); }
.btn-icon svg { width: 18px; height: 18px; }

.topbar-actions { margin-left: auto; flex-shrink: 0; }
.filter-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: .85rem;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.filter-toggle:hover { background: var(--chip-bg); }
.filter-toggle.active { border-color: var(--accent); color: var(--accent); background: #e8f0fd; }
.filter-toggle svg { width: 16px; height: 16px; }

/* ── Filter bar ──────────────────────────────────────────── */
.filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--topbar-h);
  z-index: 99;
}
.filter-bar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: var(--filter-h);
  flex-wrap: wrap;
}
.filter-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .875rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.filter-label input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
.slider-label { gap: 10px; }
.slider-label input[type="range"] {
  width: 120px;
  accent-color: var(--accent);
  cursor: pointer;
}
.filter-divider { width: 1px; height: 24px; background: var(--border); flex-shrink: 0; }
.filter-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: .85rem;
  color: var(--muted);
  background: var(--bg);
  outline: none;
  cursor: pointer;
}

/* ── Status bar ───────────────────────────────────────────── */
.status-bar {
  padding: 10px 20px 4px;
  font-size: .8rem;
  color: var(--muted);
  min-height: 28px;
}

/* ── Results grid (CSS columns masonry) ──────────────────── */
.grid-container { padding: 4px 8px 40px; }

.results-grid {
  columns: 5 200px;
  column-gap: 8px;
}

.image-card {
  break-inside: avoid;
  margin-bottom: 8px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--chip-bg);
  transition: transform .2s, box-shadow .2s;
}
.image-card:hover { transform: scale(1.015); box-shadow: var(--shadow-md); z-index: 1; }
.image-card:hover .card-overlay { opacity: 1; }

.card-img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 12px;
  background: var(--chip-bg);
}
.card-img.portrait { aspect-ratio: 2/3; }
.card-img.landscape { aspect-ratio: 4/3; }
.card-img.square { aspect-ratio: 1; }

/* Fade-in on load */
.card-img { opacity: 0; transition: opacity .3s; }
.card-img.loaded { opacity: 1; }

/* Overlay on hover */
.card-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 28px 10px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
  border-radius: 0 0 12px 12px;
  opacity: 0;
  transition: opacity .2s;
}
.card-name {
  color: #fff;
  font-size: .8rem;
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.card-badge {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(0,0,0,.45);
  color: #fff;
  border-radius: 10px;
  padding: 2px 7px;
  font-size: .7rem;
  font-weight: 500;
}

/* ── Load more ────────────────────────────────────────────── */
.load-more-area { display: flex; justify-content: center; padding: 24px 0; }
.btn-load-more {
  padding: 10px 32px;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: .9rem;
  color: var(--accent);
  font-weight: 500;
  transition: background .15s;
}
.btn-load-more:hover { background: var(--chip-bg); }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 80px 20px;
  color: var(--muted);
  text-align: center;
}
.empty-state svg { width: 56px; height: 56px; color: #ccc; }
.empty-state p { font-size: 1rem; }
.empty-hint { font-size: .85rem; }

/* ══════════════════════════════════════════════════════════════
   DETAIL DRAWER (right panel, Google-style)
   ══════════════════════════════════════════════════════════════ */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 199;
}
.detail-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: var(--drawer-w);
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.detail-drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-close {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  transition: background .15s;
}
.drawer-close:hover { background: var(--chip-bg); }
.drawer-close svg { width: 18px; height: 18px; }

.drawer-body {
  overflow-y: auto;
  flex: 1;
  padding: 0 0 32px;
}

/* Full image inside drawer */
.drawer-full-img {
  width: 100%;
  object-fit: contain;
  max-height: 360px;
  background: #000;
  display: block;
}

/* Drawer sections */
.drawer-section { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer-section:last-child { border-bottom: none; }

.drawer-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.4;
}
.drawer-subtitle {
  font-size: .8rem;
  color: var(--muted);
}

/* Metadata rows */
.meta-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 8px;
  font-size: .85rem;
}
.meta-key {
  color: var(--muted);
  min-width: 80px;
  flex-shrink: 0;
}
.meta-val { color: var(--text); }

/* Tag chips inside drawer */
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag-chip {
  padding: 3px 10px;
  background: var(--chip-bg);
  border-radius: 12px;
  font-size: .78rem;
  color: var(--muted);
}

/* Drawer action buttons */
.drawer-actions {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.btn-drawer {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--accent);
  text-align: center;
  transition: background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
.btn-drawer:hover { background: #e8f0fd; border-color: var(--accent); text-decoration: none; }

/* Score badge */
.score-bar-wrap { margin-top: 6px; }
.score-bar-label {
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.score-bar-track {
  height: 4px;
  background: var(--chip-bg);
  border-radius: 2px;
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .4s;
}

/* ══════════════════════════════════════════════════════════════
   SPINNER
   ══════════════════════════════════════════════════════════════ */
.spinner-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  pointer-events: none;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root {
    --drawer-w: 100vw;
  }
  .results-page.drawer-open { padding-right: 0; }
  .results-grid { columns: 2 140px; }
  .topbar-logo { display: none; }
}

@media (max-width: 480px) {
  .results-grid { columns: 2 120px; }
  .filter-bar-inner { gap: 10px; padding: 0 12px; }
  .slider-label input[type="range"] { width: 80px; }
}
