/* Ad Inspiration Feed — Dark Theme, Mobile-First */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0d;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --text: #f0f0f0;
  --text-muted: #888;
  --accent: #5b7cff;
  --pill-bg: #2a2a2a;
  --pill-active: #5b7cff;
  --badge-bg: rgba(0,0,0,0.65);
  --running-bg: rgba(91,124,255,0.85);
  --radius: 10px;
  --gap: 10px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.4;
  min-height: 100vh;
}

/* ─── Header ─── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13,13,13,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 10px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-count {
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Filter bars ─── */
.filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.filter-scroll::-webkit-scrollbar { display: none; }

.pill {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--pill-bg);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.pill.active {
  background: var(--pill-active);
  border-color: var(--pill-active);
  color: #fff;
}
.pill:hover:not(.active) {
  border-color: #555;
  color: var(--text);
}

.type-pills .pill {
  padding: 4px 10px;
  font-size: 11px;
}

/* ─── Grid ─── */
.grid-container {
  padding: var(--gap);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}

@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .grid-container { padding: 14px; }
}

@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
  .grid-container { padding: 18px; }
}

/* ─── Card ─── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.card:hover {
  transform: translateY(-2px);
  border-color: #444;
}

.card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4/5;
  background: var(--surface2);
  overflow: hidden;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}
.card:hover .card-img { transform: scale(1.02); }

.card-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 28px;
}

/* Overlays on image */
.badge-brand {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--badge-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 6px;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-days {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--running-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  white-space: nowrap;
}

.badge-platform {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: var(--badge-bg);
  backdrop-filter: blur(6px);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

/* Card body */
.card-body {
  padding: 10px;
}

.card-headline {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-desc.expanded {
  display: block;
  -webkit-line-clamp: unset;
}

/* ─── Modal ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open {
  display: flex;
}
@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px 32px;
  position: relative;
}
@media (min-width: 600px) {
  .modal {
    border-radius: 16px;
    max-width: 480px;
    max-height: 85vh;
  }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--surface2);
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.modal-img {
  width: 100%;
  border-radius: 10px;
  margin-bottom: 14px;
  object-fit: contain;
  max-height: 70vh;
}

.modal-brand {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.modal-headline {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.35;
}

.modal-body {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 14px;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.modal-meta-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11px;
  color: var(--text-muted);
}
.modal-meta-item span { color: var(--text); font-weight: 600; }

.modal-link {
  display: block;
  text-align: center;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s;
}
.modal-link:hover { opacity: 0.85; }

/* ─── States ─── */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  gap: 12px;
  color: var(--text-muted);
  font-size: 14px;
}

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

.empty-icon { font-size: 36px; }

/* ─── Add to Static Ad Skill button (card overlay) ─── */
.btn-add-skill {
  position: absolute;
  bottom: 8px;
  left: 8px;
  width: 28px;
  height: 28px;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 7px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
}
.card:hover .btn-add-skill { opacity: 1; }
.btn-add-skill:hover { background: rgba(91,124,255,0.85); }

/* Save Copy Pattern button (card overlay) */
.btn-save-copy {
  position: absolute;
  bottom: 8px;
  left: 42px;
  width: 28px;
  height: 28px;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 7px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
}
.card:hover .btn-save-copy { opacity: 1; }
.btn-save-copy:hover { background: rgba(76,175,80,0.85); }

/* ─── Add to Static Ad Skill button (modal) ─── */
.btn-add-skill-modal {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.btn-add-skill-modal:hover { background: #2e2e2e; border-color: #555; }
.btn-add-skill-modal:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-save-copy-modal { border-color: rgba(76,175,80,0.4); }
.btn-save-copy-modal:hover { border-color: rgba(76,175,80,0.7); }

/* ─── Toast notifications ─── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 999;
  background: #1e1e1e;
  border: 1px solid #3a3a3a;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 12px 16px;
  border-radius: 10px;
  max-width: 320px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transform: translateY(20px);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.toast-error { border-color: #c0392b; }
