/* Trendly · Ads page — ads-specific styles */
/* Relies on ../interface.css for all design tokens and shared components. */

/* ── Nav: three-item overflow fix ─────────────────────────────────────── */
.nav-short { display: none; }
@media (max-width: 520px) {
  .nav-full  { display: none; }
  .nav-short { display: inline; }
  .view-nav a { padding: 6px 8px; font-size: 10px; }
}

/* ── Intro tweaks ─────────────────────────────────────────────────────── */
.ads-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 44px;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
  padding-bottom: 14px;
}
.ads-meta-bar p { margin: 0; }

/* ── Section wrappers ─────────────────────────────────────────────────── */
.brands-section { margin-bottom: 0; }
.ads-section    { margin-top: 36px; }

/* ── Brand leaderboard table ─────────────────────────────────────────── */
.brand-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 0;
}
.brand-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}
.brand-table th,
.brand-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.brand-table thead tr:first-child th:first-child { border-top-left-radius:  11px; }
.brand-table thead tr:first-child th:last-child  { border-top-right-radius: 11px; }
.brand-table th {
  background: var(--soft);
  font-weight: 500;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 1;
}
.brand-table th:hover { color: var(--ink); }
.brand-table th[aria-sort="ascending"]::after  { content: ' ↑'; }
.brand-table th[aria-sort="descending"]::after { content: ' ↓'; }
.brand-table th[data-nosort] { cursor: default; }
.brand-table tr:last-child td { border-bottom: 0; }
.brand-table tbody tr:hover td { background: var(--soft); }
.brand-table tbody tr.row-active td { background: var(--soft); }
.brand-table tbody tr { cursor: pointer; }
.brand-table .brand-col { font-weight: 500; }
.brand-table .num { font-variant-numeric: tabular-nums; }
.delta-pos { color: var(--accent); }
.delta-neg { color: #a05c3e; }
:root[data-theme=dark] .delta-neg { color: #e08866; }
.table-link {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.table-link:hover { color: var(--ink); }

/* ── Sparkline ───────────────────────────────────────────────────────── */
.sparkline {
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
  overflow: visible;
}
.sparkline-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Brand mobile stacked cards ──────────────────────────────────────── */
.brand-mobile-cards { display: none; }
.brand-mobile-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
}
.brand-mobile-card:hover,
.brand-mobile-card.row-active { border-color: var(--accent); background: var(--soft); }
.brand-mobile-card-name { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.brand-mobile-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 12px;
  color: var(--muted);
}
.brand-mobile-card-stats strong { color: var(--ink); font-weight: 500; }
.brand-mobile-card-links { margin-top: 8px; display: flex; gap: 12px; font-size: 11px; }

/* ── Ads toolbar ─────────────────────────────────────────────────────── */
.ads-toolbar { flex-wrap: wrap; row-gap: 8px; }
.select-field input[type="search"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background-color: var(--surface);
  width: 100%;
  font-size: 13px;
  min-height: 42px;
  color: var(--ink);
  -webkit-appearance: none;
}
.select-field input[type="search"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.select-field input[type="search"]::placeholder { color: var(--muted); }

/* ── Ad cards grid ───────────────────────────────────────────────────── */
.ads-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px 16px;
}
.ad-card { min-width: 0; }
.ad-open {
  padding: 0;
  text-align: left;
  display: block;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--surface);
  transition: border-color 0.15s;
}
.ad-open:hover,
.ad-open:focus-visible { border-color: var(--accent); outline: none; }
.ad-open:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }

/* Creative image box */
.ad-creative {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--soft);
  overflow: hidden;
}
.ad-creative img {
  object-fit: cover;
  width: 100%;
  height: 100%;
  display: block;
}
.ad-creative .image-missing {
  aspect-ratio: 1 / 1;
  font-size: 10px;
}

/* Video badge */
.video-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 9px;
  font-weight: 700;
  background: var(--ink);
  color: var(--paper);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  pointer-events: none;
}

/* Ad card caption */
.ad-caption { padding: 12px 12px 14px; }
.ad-brand {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 5px;
}
.ad-running {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 5px;
  font-variant-numeric: tabular-nums;
}
.ad-running.long-run { color: var(--accent); }
.ad-title {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink);
  margin-bottom: 5px;
}
.ad-open:hover .ad-title,
.ad-open:focus-visible .ad-title {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.ad-body {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  margin-bottom: 6px;
}
.ad-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0 0;
  align-items: center;
}
.ad-pill {
  font-size: 10px;
  padding: 2px 8px;
  background: var(--soft);
  border-radius: 10px;
  color: var(--muted);
  white-space: nowrap;
}
.ad-cta {
  font-size: 10px;
  padding: 2px 8px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 10px;
  white-space: nowrap;
}
.ad-variants-badge {
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  white-space: nowrap;
}
.ad-domain {
  font-size: 10px;
  color: var(--muted);
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Signal chips ────────────────────────────────────────────────────── */
.signal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.signal-chip {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 500;
  background: var(--soft);
  color: var(--muted);
  white-space: nowrap;
}
.signal-chip.long-runner   { background: #e4f0e4; color: #2e6b3e; }
.signal-chip.new-week      { background: #e8eef8; color: #2c4a7c; }
.signal-chip.scaled        { background: #f5ecd6; color: #7a5520; }
.signal-chip.multi-plat    { background: var(--soft); color: var(--muted); }
:root[data-theme=dark] .signal-chip.long-runner { background: #1a3328; color: #80c89a; }
:root[data-theme=dark] .signal-chip.new-week    { background: #1a2640; color: #88aae8; }
:root[data-theme=dark] .signal-chip.scaled      { background: #342410; color: #d4a060; }

/* ── Show more ───────────────────────────────────────────────────────── */
.show-more-wrap { text-align: center; padding: 28px 0 48px; }
.show-more-btn {
  min-height: 44px;
  padding: 10px 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
}
.show-more-btn:hover { border-color: var(--accent); }
.show-more-remaining { color: var(--muted); font-size: 12px; margin-left: 8px; }

/* ── Ad detail dialog ────────────────────────────────────────────────── */
.ad-dialog-creative {
  aspect-ratio: 1 / 1;
  background: var(--soft);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}
.ad-dialog-creative img {
  object-fit: contain;
  width: 100%;
  height: 100%;
  display: block;
}
.ad-dialog-creative .image-missing { aspect-ratio: 1 / 1; }
.ad-dialog-brand {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 6px;
}
.ad-dialog-running {
  font-size: 18px;
  font-family: var(--serif);
  font-weight: 400;
  margin-bottom: 10px;
}
.ad-dialog-running.long-run { color: var(--accent); }
.ad-dialog-body { font-size: 13px; color: var(--muted); margin-bottom: 16px; line-height: 1.6; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .ads-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .ads-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand-table-wrap { display: none; }
  .brand-mobile-cards { display: block; }
}
@media (max-width: 760px) {
  .ads-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding-bottom: 13px;
  }
  .ads-toolbar .sort-field {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    margin: 0;
    gap: 8px;
  }
  .ads-toolbar .sort-field > span { font-size: 10px; text-transform: none; letter-spacing: 0; }
  .ads-toolbar .sort-field select {
    border: 0;
    min-height: 28px;
    padding: 3px 20px 3px 5px;
    width: auto;
    background: transparent;
    font-size: 11px;
  }
  .ads-meta-bar { flex-direction: column; align-items: flex-start; gap: 4px; min-height: auto; }
  .ads-section { margin-top: 28px; }
}
@media (max-width: 480px) {
  .ads-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px; }
  .ad-caption { padding: 10px 10px 12px; }
  .ad-title { font-size: 11px; }
}
@media (max-width: 360px) {
  .ads-grid { grid-template-columns: 1fr; }
}
