/* Prebid test bench styles
   Two voices: the bench chrome (IBM Plex Sans) and the sample publisher page
   (IBM Plex Serif). Ad slots are drawn like drafting sheets: blueprint-blue
   dashed frames with their dimensions written on them. */

:root {
  --paper: #e9edf2;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --ink: #18212d;
  --muted: #5a6575;
  --rule: #c8d0db;
  --drafting: #2457c5;
  --drafting-soft: rgba(36, 87, 197, 0.08);
  --good: #217a52;
  --warn: #9a6410;
  --bad: #b5372a;
  --won: #5b3fc4;
  --focus: #2457c5;
  --code-bg: #f1f3f7;
  --on-drafting: #ffffff;

  --sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --panel-w: 480px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141a22;
    --surface: #1b232e;
    --surface-2: #212b37;
    --ink: #e3e8ef;
    --muted: #9aa6b6;
    --rule: #334051;
    --drafting: #7ea3f2;
    --drafting-soft: rgba(126, 163, 242, 0.08);
    --good: #5cc493;
    --warn: #e0a84a;
    --bad: #f0806f;
    --won: #a993f5;
    --focus: #7ea3f2;
    --code-bg: #121820;
    --on-drafting: #0b1a38;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--code-bg); padding: 0.1em 0.3em; border-radius: 3px; }

/* ---------- Bench bar ---------- */
.bench-bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.bench-id h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.bench-id p { margin: 0; font-size: 13px; color: var(--muted); }
.bench-id strong { color: var(--drafting); font-weight: 600; }
.bench-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; }
.control { display: flex; flex-direction: column; gap: 3px; }
.control-label { font-size: 12px; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.seg button {
  font: 500 13px/1 var(--sans); color: var(--ink); background: var(--surface);
  border: 0; padding: 8px 12px; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-pressed="true"] { background: var(--drafting); color: var(--on-drafting); }
select {
  font: 13px/1 var(--sans); color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 6px; padding: 7px 8px; min-height: 32px;
}
.btn {
  font: 500 13px/1 var(--sans); color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 6px; padding: 8px 12px; cursor: pointer;
}
.btn:hover { border-color: var(--drafting); }
.btn-primary { background: var(--drafting); border-color: var(--drafting); color: var(--on-drafting); }
.btn-small { padding: 5px 8px; font-size: 12px; }
.panel-toggle[aria-expanded="true"] { border-color: var(--drafting); color: var(--drafting); }

/* ---------- Layout ---------- */
.bench-main { display: grid; grid-template-columns: minmax(0, 1fr); }
body.panel-open .bench-main { grid-template-columns: minmax(0, 1fr) var(--panel-w); }
.panel { display: none; }
body.panel-open .panel { display: flex; }

/* ---------- Sample publisher page ---------- */
.pub { padding: 28px 24px 0; min-width: 0; }
.pub-grid {
  display: grid; grid-template-columns: minmax(0, 640px) 300px; gap: 40px;
  justify-content: center; align-items: start;
  max-width: 1000px; margin: 0 auto;
}
.story { font-family: var(--serif); font-size: 18px; line-height: 1.65; }
.story h2 { font-family: var(--serif); font-weight: 600; font-size: 34px; line-height: 1.15; letter-spacing: -0.015em; margin: 0 0 12px; }
.story-dek { font-style: italic; color: var(--muted); margin: 0 0 28px; }
.story p { margin: 0 0 1.1em; max-width: 66ch; }

.rail { display: flex; flex-direction: column; gap: 28px; }
.howto { font-size: 14px; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 14px; }
.howto h3 { font-size: 14px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.howto p { margin: 0 0 8px; }

/* A placement can hold several slots: they wrap in a row, or stack in the
   sidebar and bottom areas. */
.placement { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 32px 28px; }
.placement-top { margin: 0 auto 32px; max-width: 1000px; }
.placement-inline { margin: 28px 0; }
.placement-sidebar, .placement-bottom { flex-direction: column; flex-wrap: nowrap; align-items: center; }
.placement-bottom { margin: 40px auto 0; max-width: 1000px; padding-top: 32px; border-top: 1px solid var(--rule); }
.pub { padding-bottom: 40px; }
.placement-sticky {
  position: sticky; bottom: 0; z-index: 10;
  margin: 32px -24px 0; padding: 8px 0 10px;
  background: var(--surface); border-top: 1px solid var(--rule);
}

/* ---------- Slots: the drafting sheet ---------- */
.slot { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; width: var(--slot-w, 300px); max-width: 100%; }
.slot-cap {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  width: 100%;
  font-size: 12px; color: var(--drafting);
  font-variant-numeric: tabular-nums;
}
.slot-name { font-weight: 600; }
.slot-frame {
  position: relative;
  width: 100%; min-height: var(--slot-h);
  display: flex; align-items: center; justify-content: center; justify-content: safe center;
  background:
    linear-gradient(var(--drafting-soft), var(--drafting-soft)),
    repeating-linear-gradient(0deg, transparent 0 19px, var(--drafting-soft) 19px 20px),
    repeating-linear-gradient(90deg, transparent 0 19px, var(--drafting-soft) 19px 20px);
  outline: 1px dashed var(--drafting);
  outline-offset: 3px;
}
/* corner registration ticks */
.slot-frame::before, .slot-frame::after {
  content: ""; position: absolute; width: 10px; height: 10px; pointer-events: none;
  border: 0 solid var(--drafting);
}
.slot-frame::before { top: -8px; left: -8px; border-top-width: 1px; border-left-width: 1px; }
.slot-frame::after { bottom: -8px; right: -8px; border-bottom-width: 1px; border-right-width: 1px; }
.slot-ad { display: flex; align-items: center; justify-content: center; justify-content: safe center; max-width: 100%; overflow-x: auto; }
.slot-ad iframe { max-width: none; }
/* Bench video player (lib/vast-player.js) */
.vast-player { position: relative; max-width: 100%; background: #0b0f14; color: #e3e8ef; overflow: hidden; }
.vast-player video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.vast-tag {
  position: absolute; top: 8px; left: 8px; pointer-events: none;
  font-size: 12px; line-height: 1; padding: 4px 6px; border-radius: 3px;
  background: rgba(0, 0, 0, 0.65); color: #fff;
}
.vast-msg {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 12px; text-align: center; font-size: 13px; overflow-wrap: anywhere;
}
.slot-status {
  margin: 4px 0 0; font-size: 13px; text-align: center; max-width: 60ch;
  padding-left: 14px; position: relative;
}
.slot-status::before {
  content: ""; position: absolute; left: 0; top: 0.45em; width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
}
.slot-status[data-state="filled"]::before { background: var(--good); }
.slot-status[data-state="empty"]::before { background: var(--warn); }
.slot-status[data-state="error"]::before { background: var(--bad); }
.slot-status[data-state="waiting"]::before { animation: pulse 1s ease-in-out infinite alternate; }
.slot-code { margin: 0; font-size: 12px; color: var(--muted); }
@keyframes pulse { from { opacity: 0.25; } to { opacity: 1; } }

/* ---------- Debug panel ---------- */
.panel {
  position: sticky; top: var(--bar-h, 57px); height: calc(100vh - var(--bar-h, 57px));
  flex-direction: column; min-width: 0;
  background: var(--surface); border-left: 1px solid var(--rule);
  font-size: 13px;
}
.tbp-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 8px; }
.tbp-title { margin: 0; font-size: 15px; font-weight: 600; }
.tbp-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.tbp-notices { padding: 0 14px; }
.notice { margin: 0 0 8px; padding: 7px 10px; border-radius: 6px; border-left: 3px solid var(--muted); background: var(--surface-2); }
.notice-info { border-left-color: var(--drafting); }
.notice-warn { border-left-color: var(--warn); }
.notice-error { border-left-color: var(--bad); }
.tbp-tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--rule); overflow-x: auto; }
.tbp-tab {
  font: 500 13px/1 var(--sans); color: var(--muted); background: none; border: 0;
  padding: 10px 8px 9px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tbp-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--drafting); }
.tbp-count { margin-left: 5px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tbp-count:empty { display: none; }
.tbp-body { flex: 1; overflow: auto; padding: 10px 14px 24px; }
.tbp-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; }
.tbp-tools input[type="search"] {
  width: 100%; font: 13px var(--sans); color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--rule); border-radius: 6px; padding: 7px 9px;
}
.tbp-body h4 { font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 14px 0; list-style: none; }

.ev-list { list-style: none; margin: 0; padding: 0; }
.ev, .net { border-bottom: 1px solid var(--rule); }
.ev-row {
  display: grid; grid-template-columns: 56px 128px minmax(0, 1fr); gap: 8px; align-items: baseline;
  width: 100%; text-align: left; padding: 6px 2px; cursor: pointer;
  background: none; border: 0; color: inherit; font: inherit;
}
.ev-row:disabled { cursor: default; }
.ev-row:not(:disabled):hover { background: var(--surface-2); }
.ev-t { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.ev-name { font-weight: 500; overflow-wrap: anywhere; }
.ev-sum { overflow-wrap: anywhere; }
.src { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.lvl-good .ev-name { color: var(--good); }
.lvl-warn .ev-name { color: var(--warn); }
.lvl-bad .ev-name, .lvl-error .ev-name { color: var(--bad); }
.lvl-won .ev-name { color: var(--won); }
.net-hl { box-shadow: inset 3px 0 0 var(--drafting); }
.net-hl .ev-row { padding-left: 8px; }
.net-detail { padding: 0 0 10px; }
.net-hl .net-detail { padding-left: 8px; }
.net-detail .url { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; margin: 0 0 6px; }

.dump { position: relative; margin: 2px 0 10px; }
.dump pre {
  margin: 0; max-height: 360px; overflow: auto; padding: 10px; padding-right: 60px;
  background: var(--code-bg); border: 1px solid var(--rule); border-radius: 6px;
  font: 12px/1.45 var(--mono); white-space: pre; tab-size: 2;
}
.dump .btn { position: absolute; top: 6px; right: 6px; }

.table-wrap { overflow-x: auto; }
table.bids { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.bids th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 6px 6px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.bids td { padding: 7px 6px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.bids td.num { text-align: right; white-space: nowrap; }
.bids small { color: var(--muted); }
.status { font-weight: 500; white-space: nowrap; }
.st-bid .status { color: var(--good); }
.st-won .status, .st-rendered .status { color: var(--won); }
.st-no-bid .status { color: var(--warn); }
.st-timeout .status, .st-rejected .status, .st-render-failed .status { color: var(--bad); }
.tag { font-size: 11px; color: var(--drafting); border: 1px solid currentColor; border-radius: 3px; padding: 0 4px; }

.facts { margin: 0; display: grid; gap: 4px; }
.facts div { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Narrow screens ---------- */
@media (max-width: 1180px) {
  body.panel-open .bench-main { grid-template-columns: minmax(0, 1fr); }
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 40;
    height: 58vh; border-left: 0; border-top: 1px solid var(--rule);
    box-shadow: 0 -6px 24px rgba(10, 20, 40, 0.18);
  }
  body.panel-open .pub { padding-bottom: 58vh; }
}
@media (max-width: 1000px) {
  .pub-grid { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; }
}
@media (max-width: 640px) {
  .bench-bar { padding: 10px 12px; position: static; }
  .pub { padding: 20px 14px 0; }
  .placement-sticky { margin: 24px -14px 0; }
  .story { font-size: 17px; }
  .story h2 { font-size: 27px; }
  .ev-row { grid-template-columns: 50px minmax(0, 1fr); }
  .ev-sum { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  .slot-status[data-state="waiting"]::before { animation: none; }
}
