/* ─────────────────────────────────────────────────────────────
   Hello Radio — component styles
   Structure mirrors the Meta Ad Library; skin comes from tokens.
   One job: layout + component appearance. Tokens live in tokens.css.
   ───────────────────────────────────────────────────────────── */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: var(--prim-white); }

/* ── Animated link underline (sweep in left→right, collapse right) ── */
.nav-underline {
  position: relative; text-decoration: none; color: inherit;
}
.nav-underline::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1.5px;
  background: currentColor; transform: scaleX(0); transform-origin: right;
  transition: transform var(--dur-base) var(--ease-out);
}
.nav-underline:hover::after { transform: scaleX(1); transform-origin: left; }

/* ── App bar: brand + scoped search + filters + nav, sticky ── */
.appbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface);
  display: flex; align-items: center; gap: 8px;
  padding: 0 20px; height: 52px;
  box-shadow: 0 1px 0 var(--divider);
  transition: box-shadow var(--dur-base) var(--ease-out);
}
.appbar.scrolled { box-shadow: 0 1px 0 var(--divider), 0 4px 16px rgba(0,0,0,0.08); }
.appbar nav { margin-left: auto; display: flex; gap: 26px; font-size: var(--text-md); }
.appbar nav a.current { font-weight: 600; color: var(--accent); }

/* Scoped search: the brand lives inside the field as a token;
   typing filters within that brand (one control, two jobs merged) */
.scope-search {
  display: flex; align-items: center; gap: 6px;
  width: 340px; padding: 5px 8px;
  background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  position: relative; /* anchors the brand-picker dropdown */
}
.brand-token { cursor: pointer; }
.brand-pop { width: 300px; padding: 10px; }
.toolpop.brand-mega {
  width: min(720px, calc(100vw - 48px));
  padding: 16px;
  max-height: min(70vh, 640px);
  overflow-y: auto; scrollbar-width: thin;
}
.mega-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 2px 14px;
  align-items: start;
}
.mega-group { min-width: 0; }
.mega-group-h {
  font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary);
  margin: 10px 10px 4px;
}
.mega-empty { padding: 14px 10px; font-size: var(--text-md); color: var(--text-secondary); }
.brand-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: none; border-radius: 8px;
  background: none; cursor: pointer; text-align: left;
  font-family: var(--font-body); color: var(--text);
  transition: background var(--dur-fast) var(--ease-out);
}
.brand-row:hover { background: var(--control-bg); }
.brand-row.checked { background: var(--focus-ring-soft); }
.brand-row-av {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--avatar-bg); color: var(--prim-white);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; overflow: hidden;
}
.brand-row-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-row-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.brand-row-txt .nm { font-size: var(--text-lg); font-weight: 600; }
.brand-row-txt .ct { font-size: var(--text-sm); color: var(--text-secondary); }
.brand-row-tick { display: inline-flex; color: var(--accent); }
.scope-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring-soft); }
.scope-search input {
  border: none; outline: none; background: transparent; min-width: 0; flex: 1;
  font-family: var(--font-body); font-size: var(--text-sm); color: var(--text);
}
.brand-token {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--control-bg); border-radius: 999px;
  padding: 2px 8px 2px 3px; font-size: var(--text-sm); font-weight: 600;
  white-space: nowrap; flex-shrink: 0;
}
.brand-token img { width: 18px; height: 18px; border-radius: 50%; display: block; }
.brand-token .clear { cursor: pointer; opacity: .5; font-weight: 400; padding: 0 2px; }
.brand-token .clear:hover { opacity: .9; }

.brand { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.brand .dot {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: var(--prim-white);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--control-bg); border: none; border-radius: var(--radius-sm);
  padding: 8px 14px; font-family: var(--font-body); font-size: var(--text-lg);
  color: var(--text); cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-spring);
}
.pill:hover { background: var(--control-bg-hover); }
.pill:active { transform: scale(0.97); }
/* ── Theme toggle ── */
.theme-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--control-bg); color: var(--text-secondary);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; margin-left: auto; flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-spring);
}
.theme-btn:hover { background: var(--control-bg-hover); color: var(--text); }
.theme-btn:active { transform: scale(0.9); }
.appbar nav { margin-left: 0; }

/* ── Toolbar popovers (country / category / sort) ── */
.toolwrap { position: relative; display: inline-flex; }
.toolbar-i { color: var(--text-secondary); align-self: center; cursor: default; }
.toolpop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 150;
  width: 320px; padding: 16px;
  background: var(--surface); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18), 0 0 1px rgba(0, 0, 0, 0.1);
  opacity: 0; transform: translateY(-4px) scale(0.98);
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-spring);
}
.toolpop.show { opacity: 1; transform: none; pointer-events: auto; }
.toolpop.pop-compact { width: 260px; padding: 8px; }
.pop-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }
.pop-search { margin-bottom: 12px; }
.pop-section { font-size: var(--text-md); font-weight: 600; margin: 4px 0 4px 10px; }
.pop-divider { height: 1px; background: var(--divider); margin: 10px 0; }
.pop-list { max-height: 300px; overflow-y: auto; scrollbar-width: thin; }

.radio-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: none; border-radius: 8px;
  background: none; cursor: pointer; text-align: left;
  font-family: var(--font-body); font-size: var(--text-lg); color: var(--text);
  transition: background var(--dur-fast) var(--ease-out);
}
.radio-row:hover { background: var(--control-bg); }
.radio-row.checked { background: var(--focus-ring-soft); }
.radio {
  width: 20px; height: 20px; border-radius: 50%; box-sizing: border-box;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  flex-shrink: 0; transition: border var(--dur-fast) var(--ease-out);
}
.radio-row.checked .radio { border: 6px solid var(--accent); }
.radio-row .ric { display: inline-flex; color: var(--text); flex-shrink: 0; }

/* drawn triangle — the ▾ glyph renders too small at any font size */
.caret::after {
  content: ""; width: 0; height: 0;
  border-left: 4.5px solid transparent; border-right: 4.5px solid transparent;
  border-top: 5.5px solid currentColor; opacity: .6; margin-top: 2px;
}
/* ── Page header ── */
.pagehead { background: var(--surface); padding: 24px 32px 0; }
.pagehead .id { display: flex; align-items: center; gap: 16px; }
.avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--avatar-bg); color: var(--prim-white);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700;
}
.avatar img, .advertiser .av img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;
}
.pagehead h1 { font-family: var(--font-display); font-size: var(--text-display); font-weight: 700; letter-spacing: -0.3px; }
.tabs { display: flex; gap: 30px; margin-top: 22px; }
.tabs a {
  color: var(--text-secondary); font-size: var(--text-md); padding: 11px 2px;
  text-decoration: none; transition: color var(--dur-fast) var(--ease-out);
}
.tabs a.current { color: var(--accent); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.tabs a:hover { color: var(--text); }
.results-row { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 14px; }
.results { font-size: var(--text-lg); font-weight: 600; font-variant-numeric: tabular-nums; }

.chip {
  background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow-chip);
  padding: 8px 12px; font-size: var(--text-sm); display: inline-flex; gap: 6px; align-items: center;
}
.chip b { font-weight: 600; }
.chip .x { cursor: pointer; opacity: .5; padding: 0 2px; }

/* ── Grid ── */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px; padding: 20px 32px 56px;
}

/* ── Campaign card: stacked-deck wrapper + thumbstrip + group header ── */
/* align-self: start — the grid stretches items to row height, which would
   drag the deck layers below the real card as an empty phantom.
   padding-top reserves the peek space INSIDE the cell so the deck never
   juts into the row gap and reads as a stray sliver under the card above. */
.card-stack { position: relative; z-index: 0; align-self: start; padding-top: 9px; }
.card-stack::before, .card-stack::after {
  content: ""; position: absolute; left: 0; right: 0; top: 9px; bottom: 0;
  background: var(--surface); border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.card-stack::before { transform: translateY(-5px) scaleX(0.95); z-index: -1; }
.card-stack::after { transform: translateY(-9px) scaleX(0.90); z-index: -2; }
.card-stack .card { cursor: pointer; }

.thumbstrip { display: flex; align-items: center; margin-top: 10px; }
.thumbstrip img, .thumbstrip .more {
  width: 28px; height: 28px; border-radius: 6px; object-fit: cover;
  border: 2px solid var(--surface); margin-left: -8px;
}
.thumbstrip img:first-child { margin-left: 0; }
.thumbstrip .more {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--control-bg); font-size: 10px; font-weight: 600;
  color: var(--text-secondary);
}

.group-header {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: var(--radius-md);
  box-shadow: var(--shadow-card); padding: 10px 14px;
}
.group-header .back { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.group-header .back:hover { color: var(--accent); }
.group-header .hedge { color: var(--text-secondary); font-size: var(--text-xs); margin-left: auto; }

/* ── Ad card ── */
.card {
  background: var(--surface); border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; overflow: hidden;
  transition: transform var(--dur-base) var(--ease-spring), box-shadow var(--dur-base) var(--ease-out);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); }

/* blur-fade entrance (Animation-Workflow: blur-fade) */
.card.enter { opacity: 0; filter: blur(8px); transform: translateY(10px); }
.card.entered {
  opacity: 1; filter: blur(0); transform: translateY(0);
  transition: opacity var(--dur-enter) var(--ease-out), filter var(--dur-enter) var(--ease-out),
              transform var(--dur-enter) var(--ease-spring),
              box-shadow var(--dur-base) var(--ease-out);
}
@media (prefers-reduced-motion: reduce) {
  .card.enter { opacity: 1; filter: none; transform: none; }
  .card, .pill, .nav-underline::after { transition: none !important; }
}

.card-meta { padding: 14px 14px 0; }
.statusrow { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
/* Measured off the real Ad Library: #ebf2e6 capsule, 999px radius,
   18px tall, 12px icon + 4px gap, green 700 text */
.status {
  display: inline-flex; align-items: center; gap: 4px;
  height: 18px; padding: 0 8px; border-radius: 999px;
  background: var(--status-pill-bg);
  font-size: var(--text-sm); font-weight: 400; color: var(--active); /* Edward: non-bold */
}
.status .tick { width: 12px; height: 12px; display: inline-flex; }
.status .tick svg { width: 12px; height: 12px; fill: var(--active); }
.status.ended { background: var(--status-pill-ended-bg); color: var(--text-secondary); }
.status.ended .tick svg { fill: var(--text-secondary); }
.platicons { display: inline-flex; gap: 4px; align-items: center; margin-left: 8px; vertical-align: middle; color: var(--platform-icon); }
.platicons svg { width: 12px; height: 12px; display: block; }
.dots { color: var(--text-secondary); cursor: pointer; letter-spacing: 1px; font-weight: 700; }

/* ── Ellipsis menu (cards + modal) ── */
.admenu { position: relative; display: inline-flex; }
.dots-btn {
  border: none; background: transparent; color: var(--text-secondary);
  font-size: 16px; font-weight: 700; letter-spacing: 1px; line-height: 1;
  padding: 6px 10px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--dur-fast), transform var(--dur-fast) var(--ease-spring);
}
.dots-btn:hover { background: var(--control-bg); color: var(--text); }
.dots-btn:active { transform: scale(0.94); }
.admenu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  min-width: 260px; padding: 6px;
  background: var(--surface); border-radius: var(--radius-md);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.16), 0 0 1px rgba(0, 0, 0, 0.2);
  opacity: 0; transform: scale(0.96) translateY(-4px); pointer-events: none;
  transform-origin: top right;
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-spring);
}
.admenu-pop.show { opacity: 1; transform: none; pointer-events: auto; }
.admenu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: none; background: transparent; border-radius: var(--radius-sm);
  padding: 10px 12px; cursor: pointer; color: var(--text); font-family: var(--font-body);
  transition: background var(--dur-fast);
}
.admenu-item:hover { background: var(--control-bg); }
.admenu-item svg { flex-shrink: 0; color: var(--text); }
.admenu-item .txt { display: flex; flex-direction: column; gap: 1px; }
.admenu-item .t { font-size: 14px; font-weight: 600; }
.admenu-item .d { font-size: 12px; color: var(--text-secondary); }
/* Meta's info-circle sprite (Edward-supplied), tinted via currentColor */
.sprite-i {
  display: inline-block; width: 12px; height: 12px;
  background: currentColor; vertical-align: -2px;
  -webkit-mask-image: url("https://static.xx.fbcdn.net/rsrc.php/yt/r/DSEb3Js9JBF.webp");
  mask-image: url("https://static.xx.fbcdn.net/rsrc.php/yt/r/DSEb3Js9JBF.webp");
  -webkit-mask-size: 29px 2424px; mask-size: 29px 2424px;
  -webkit-mask-position: 0 -2307px; mask-position: 0 -2307px;
}
.metaline { margin-bottom: 6px; color: var(--text); font-family: var(--font-mono); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
/* note lines wear the same font as the Library ID line (Edward) */
.metaline.note { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary); }

/* ── Tooltip (Meta Ad Library pattern): dark capsule above the target,
   Library-ID-size type. Attach with data-tip; add .tip-wide for the
   wrapping multi-line variant (the multiple-versions explainer). ── */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 7px); left: 50%;
  background: rgba(0, 0, 0, 0.8); color: var(--prim-white);
  font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.4;
  padding: 6px 10px; border-radius: 6px; white-space: nowrap;
  opacity: 0; transform: translateX(-50%) translateY(3px) scale(0.97);
  pointer-events: none; z-index: 60;
  transition: opacity var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-spring);
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
.tip-wide::after { white-space: normal; width: 230px; text-align: left; }
.details-btn {
  margin: 10px 14px 14px; padding: 9px 16px; text-align: center;
  background: var(--control-bg); border: none; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: var(--text-sm); color: var(--text); cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-spring);
}
.details-btn:hover { background: var(--control-bg-hover); }
.details-btn:active { transform: scale(0.98); }
.card-divider { height: 1px; background: var(--divider); }

.preview { padding: 14px; display: flex; flex-direction: column; flex: 1; }
.advertiser { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.advertiser .av {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--avatar-bg); color: var(--prim-white);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
.advertiser .nm { font-weight: 600; font-size: var(--text-md); }
.advertiser .sp { color: var(--text-secondary); font-size: var(--text-xs); }
.copy { margin-bottom: 10px; line-height: 1.45; text-wrap: pretty; }
.creative {
  aspect-ratio: 1 / 1; border-radius: var(--radius-sm);
  background: linear-gradient(160deg, var(--placeholder-1), var(--placeholder-2));
  display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary); font-size: var(--text-sm);
  flex-direction: column; gap: 6px; text-align: center; padding: 12px;
}
.creative.has-asset {
  aspect-ratio: auto; padding: 0; background: none; position: relative;
}
.creative.has-asset img, .creative.has-asset video { width: 100%; display: block; border-radius: var(--radius-sm); }
.creative .play {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: var(--prim-white);
  display: flex; align-items: center; justify-content: center; font-size: 14px; padding-left: 3px;
}
.creative.has-asset .play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
}
/* full-bleed click-catcher over a video poster — click anywhere plays */
.vidstart { position: absolute; inset: 0; cursor: pointer; z-index: 1; }
.ctabar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--page-bg); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-top: 10px;
}
.ctabar .info { min-width: 0; }
.ctabar .domain { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .3px; }
.ctabar .headline { font-size: var(--text-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctabar .sub { font-size: var(--text-xs); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cta-btn {
  background: var(--control-bg); color: var(--text);
  border: none; border-radius: var(--radius-sm); padding: 8px 14px;
  font-family: var(--font-body); font-size: var(--text-sm); font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-spring);
}
.cta-btn:hover { background: var(--control-bg-hover); }
.cta-btn:active { transform: scale(0.97); }

footer {
  padding: 24px 32px; color: var(--text-tertiary); font-size: var(--text-xs);
  background: var(--surface); box-shadow: 0 -1px 0 var(--divider);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.foot-links { display: flex; gap: 20px; flex-wrap: wrap; }
.foot-links a {
  color: var(--text-secondary); text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px; background-position: 0 100%; background-repeat: no-repeat;
  transition: background-size var(--dur-base) var(--ease-out);
}
.foot-links a:hover { background-size: 100% 1px; }

/* wide vector logos letterbox inside round avatars instead of cropping */
.brand-row-av img[src$=".svg"], .av img[src$=".svg"], #brand-token img[src$=".svg"] {
  object-fit: contain; background: #fff; padding: 2px; box-sizing: border-box;
}

/* RULE (Edward): every interactive control shows the finger */
button, [role="button"], .pill, select { cursor: pointer; }
