:root {
  --bg: #ffffff;
  --ink: #0d0d0d;
  --muted: #767676;
  --border: #d6d6d6;
  --border-soft: #e9e9e9;
  --hover-bg: #f4f4f4;
  --card: #ffffff;
  --accent: #0d0d0d;
  --accent-ink: #ffffff;
  --radius: 2px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; text-decoration: none; }

.site-header {
  padding: 48px 32px 24px;
  border-bottom: 2px solid var(--ink);
}

.wordmark {
  font-family: "Instrument Serif", "Bricolage Grotesque", serif;
  font-weight: 400;
  font-style: italic;
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  letter-spacing: 0;
  line-height: 1;
  display: inline-block;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 32px 80px;
}

/* Filters */

.filters {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 8px;
}

.filter-row.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-row.pills.scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.pill {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.pill:hover { border-color: var(--ink); background: var(--hover-bg); }

.pill.is-active,
.pill-outline.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

/* Multi-select pills shade darkest-to-lightest in the order they were
   picked, so it's obvious at a glance which filter went in first. filters.js
   stamps a data-rank (1 = most recently... actually 1 = first selected) on
   each active pill; rank 6+ all share the lightest shade since going
   further wouldn't stay visually distinct. */
.pill.is-active[data-rank="1"] { background: #0d0d0d; border-color: #0d0d0d; color: #fff; }
.pill.is-active[data-rank="2"] { background: #454545; border-color: #454545; color: #fff; }
.pill.is-active[data-rank="3"] { background: #8c8c8c; border-color: #8c8c8c; color: #0d0d0d; }
.pill.is-active[data-rank="4"] { background: #b0b0b0; border-color: #9c9c9c; color: #0d0d0d; }
.pill.is-active[data-rank="5"] { background: #cfcfcf; border-color: #b5b5b5; color: #0d0d0d; }
.pill.is-active[data-rank="6"] { background: #e4e4e4; border-color: #c2c2c2; color: #0d0d0d; }

.filter-row.utility {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.filter-row.utility input {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  transition: border-color 0.12s ease;
}

.filter-row.utility input:focus {
  outline: none;
  border-color: var(--ink);
}

#search-input { flex: 2 1 260px; }
#client-input, #agency-input, #category-input { flex: 1 1 160px; }

.filter-row.utility input::placeholder { color: var(--muted); }

.text-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 12px 6px;
}

.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0 18px;
}

.result-count {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}

#sort-toggle {
  padding: 4px 6px;
}

.banner {
  padding: 12px 16px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
  font-size: 0.9rem;
}

/* Grid + cards */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.card:hover {
  box-shadow: 6px 6px 0 var(--ink);
  transform: translate(-3px, -3px);
}

.card-thumb {
  position: relative;
  margin: -18px -18px 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--ink);
  border-bottom: 1.5px solid var(--ink);
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-thumb .card-top {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  margin: 0;
}

.card-top {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 5px 10px;
  border-radius: 999px;
}

.badge-accent { background: var(--ink); color: var(--bg); }
.badge-year { background: var(--card); color: var(--ink); border: 1.5px solid var(--ink); }
.badge-outline { border: 1.5px solid var(--border); color: var(--ink); background: transparent; }
.badge-muted { border: 1.5px solid transparent; color: var(--muted); background: var(--hover-bg); }

.card-title {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  line-height: 1.15;
  margin: 0;
}

.card-meta {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  padding: 60px 0;
}

/* Inline expanded card (homepage trial) */

.card.is-expand-hidden { display: none; }

.card-expanded {
  grid-column: 1 / -1;
  border: 1.5px solid var(--ink);
  background: var(--card);
  padding: 24px;
  position: relative;
  animation: expand-in 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes expand-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.expanded-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  z-index: 2;
  transition: background 0.12s ease, color 0.12s ease;
}
.expanded-close:hover { background: var(--ink); color: var(--bg); }

.expanded-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 760px) {
  .expanded-inner {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 40px;
  }
}

.expanded-media {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.expanded-title {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1.1;
  margin: 8px 0 2px;
}

.expanded-byline {
  color: var(--muted);
  font-weight: 600;
  margin: 0;
}
.expanded-byline .sep { color: var(--border); }

.expanded-copy {
  display: flex;
  flex-direction: column;
}
.expanded-copy section {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.expanded-copy section:first-child { padding-top: 0; }
.expanded-copy h2 {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 0 0 6px;
}
.expanded-copy p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.expanded-fullpage {
  display: inline-block;
  margin-top: 16px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--muted);
}
.expanded-fullpage:hover { color: var(--ink); }

/* Ad detail page */

.back-link {
  display: inline-block;
  font-weight: 700;
  color: var(--muted);
}
.back-link:hover { color: var(--ink); }

.back-link-bottom {
  margin-top: 28px;
}

.not-found .back-link { margin-top: 16px; }

.ad-detail { max-width: 900px; margin: 0 auto; }

.embed-frame {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: var(--ink);
  border: 1.5px solid var(--ink);
}
.embed-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.embed-linkout {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 40px 28px;
  border: 1.5px solid var(--ink);
  background: var(--card);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.embed-linkout:hover {
  box-shadow: 6px 6px 0 var(--ink);
  transform: translate(-3px, -3px);
}
.embed-linkout-label {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800;
  font-size: 1.4rem;
}
.embed-linkout-url {
  color: var(--muted);
  font-size: 0.85rem;
  word-break: break-all;
}
.embed-linkout-arrow {
  font-size: 1.6rem;
  color: var(--accent);
}

.embed-linkout-image {
  position: relative;
  padding: 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  display: block;
}
.embed-linkout-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.embed-linkout-image .embed-linkout-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 20px 18px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
}
.embed-linkout-image .embed-linkout-label { color: #fff; }
.embed-linkout-image .embed-linkout-url { color: rgba(255, 255, 255, 0.75); }
.embed-linkout-image .embed-linkout-arrow { color: #fff; }

.embed-missing {
  padding: 40px 28px;
  border: 2px dashed var(--border);
  color: var(--muted);
  text-align: center;
}

.ad-header { margin: 28px 0 20px; }

.ad-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.ad-header h1 {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800;
  font-size: clamp(1.8rem, 5vw, 3rem);
  line-height: 1.05;
  margin: 0 0 10px;
}

.ad-byline {
  font-size: 1.1rem;
  color: var(--muted);
  font-weight: 600;
  margin: 0;
}
.ad-byline .sep { color: var(--border); }

.ad-director {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 300;
  margin: 4px 0 0;
}

.expanded-director { font-style: italic; }

.ad-sections {
  border-top: 2px solid var(--ink);
  margin-top: 24px;
}

.ad-sections section {
  padding: 26px 0;
  border-bottom: 1px solid var(--border);
}

.ad-sections h2 {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 0 0 10px;
}

.ad-sections p {
  font-size: 1.15rem;
  line-height: 1.55;
  margin: 0;
  max-width: 68ch;
}

.not-found {
  text-align: center;
  padding: 80px 0;
}
.not-found h1 {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800;
  font-size: 5rem;
  margin: 0;
  color: var(--accent);
}

@media (max-width: 640px) {
  .site-header { padding: 32px 20px 20px; }
  main { padding: 20px 16px 60px; }
}
