/* Policy Results section */
#policy {
  --ours: var(--accent);
  --line: #e6e6e6;
}

#policy button {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
}

/* the theme greys out <b>; key phrases in the intro should stand out instead */
#policy > p b { color: black; font-weight: 700; }

/* ---- Training setup: pretrain on robot data, post-train with a few human demos, deploy in human-only scenes ---- */
#policy .pr-setup {
  display: flex;
  align-items: stretch;
  gap: 0.6em;
  margin: 1.25em 0 0.5em;
}

#policy .pr-step {
  flex: 1;
  padding: 0.6em 0.9em;
  border: solid 1px var(--line);
  border-radius: 8px;
  font-size: 0.8em;
  line-height: 1.45em;
  color: #555;
}

#policy .pr-step span {
  display: block;
  margin-bottom: 0.15em;
  font-weight: bold;
  color: black;
}

/* the post-training step is the contribution: accent it */
#policy .pr-step:nth-child(3) { border-color: var(--ours); background: color-mix(in srgb, var(--ours) 6%, #fff); }
#policy .pr-step:nth-child(3) span { color: var(--ours); }

#policy .pr-arrow {
  display: flex;
  align-items: center;
  color: #aaa;
}

@media screen and (max-width: 736px) {
  #policy .pr-setup { flex-direction: column; }
  #policy .pr-arrow { justify-content: center; transform: rotate(90deg); }
}

/* ---- Charts ---- */
#policy .pr-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2em;
  margin: 1.5em 0 0.5em;
}

#policy .pr-chart h4 {
  margin: 0 0 0.15em;
  font-size: 1em;
  line-height: 1.4em;
  color: black;
}

#policy .pr-metric {
  margin: 0 0 0.75em;
  font-size: 0.75em;
  line-height: 1.4em;
  color: #888;
}

#policy .pr-row {
  display: grid;
  grid-template-columns: 9.5em minmax(0, 1fr);
  column-gap: 0.75em;
  align-items: center;
  margin-bottom: 0.4em;
}

#policy .pr-name {
  font-size: 0.8em;
  line-height: 1.3em;
  color: #555;
  text-align: right;
}

#policy .pr-row.ours .pr-name { color: black; font-weight: bold; }
#policy .pr-row.key .pr-name { color: #333; }

#policy .pr-track {
  position: relative;
  height: 1.5em;
  border-radius: 3px;
  background: #f6f6f6;
}

#policy .pr-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 3px;
  background: #c9c9c9;
  transition: width 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}

#policy .pr-row.ours .pr-bar { background: var(--ours); }
#policy .pr-row.key .pr-bar { background: #9aa9c9; }

#policy .pr-val {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 0.4em;
  font-size: 0.75em;
  line-height: 1;
  color: #333;
  white-space: nowrap;
  transition: left 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}

#policy .pr-row.ours .pr-val { font-weight: bold; color: black; }

/* gain annotation: OURS vs OURS w/o alignment */
#policy .pr-gain {
  margin: 0.5em 0 0 10.3em;
  font-size: 0.7em;
  line-height: 1.4em;
  color: #555;
}

#policy .pr-gain b { color: var(--ours); }

/* ---- Rollouts ---- */
#policy .pr-bar-ctrl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75em 1.5em;
  margin: 2em 0 1em;
}

#policy .pr-seg {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 3px;
  padding: 3px;
  border: solid 1px var(--line);
  border-radius: 8px;
}

#policy .pr-seg button {
  white-space: nowrap;
  padding: 0.3em 1em;
  border-radius: 5px;
  font-size: 0.8em;
  line-height: 1.6em;
  color: #787878;
}

#policy .pr-seg button:hover { color: #333; }
#policy .pr-seg button.on { background: var(--accent); color: #fff; }
#policy .pr-seg.small button { padding: 0.2em 0.75em; font-size: 0.7em; }
#policy .pr-seg.small button.on { background: #333; }

#policy .pr-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  gap: 0.9em 0.75em;
}

@media screen and (max-width: 736px) {
  #policy .pr-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

#policy .pr-fail { margin-top: 1.75em; }
#policy .pr-fail[hidden] { display: none; }

#policy .pr-fail h4 {
  margin: 0 0 0.6em;
  font-size: 1em;
  line-height: 1.4em;
  color: black;
}

#policy .pr-fail-note {
  font-size: 0.85em;
  font-weight: 700;
  line-height: 1.4em;
  color: #c62f24;
}

/* Red border over a baseline video from its failure time until it loops */
#policy .pr-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border: 4px solid #d0453b;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

#policy .pr-frame.failing::before { opacity: 1; }

#policy .pr-cell { display: flex; flex-direction: column; gap: 0.35em; min-width: 0; }

#policy .pr-cell-name {
  font-size: 0.88em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4em;
  color: #333;
}

#policy .pr-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 6px;
  background: #f4f4f4;
}

/* Hover enlarges a rollout in place; edge columns grow inward so they stay on the page */
@media (hover: hover) {
  #policy .pr-frame {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
  }

  #policy .pr-cell:hover .pr-frame {
    z-index: 10;
    transform: scale(2);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  }

  #policy .pr-cell.first .pr-frame { transform-origin: left center; }
  #policy .pr-cell.last .pr-frame { transform-origin: right center; }
}

@media screen and (hover: hover) and (max-width: 736px) {
  #policy .pr-cell.last:nth-child(odd) .pr-frame,
  #policy .pr-cell:nth-child(odd) .pr-frame { transform-origin: left center; }
  #policy .pr-cell.first:nth-child(even) .pr-frame,
  #policy .pr-cell:nth-child(even) .pr-frame { transform-origin: right center; }
}

#policy .pr-frame video { display: block; width: 100%; height: 100%; object-fit: cover; }

#policy .pr-frame.missing { background: repeating-linear-gradient(135deg, #f4f4f4 0 10px, #ececec 10px 20px); }
#policy .pr-frame.missing video { visibility: hidden; }

#policy .pr-frame.missing::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
  font-size: 11px;
  color: #999;
}

/* Seek bar: a thin track on the bottom edge with a taller invisible hit area */
#policy .pr-seek {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  height: 10px;
  cursor: pointer;
  touch-action: none;
}

#policy .pr-seek::before,
#policy .pr-seek-fill {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
}

#policy .pr-seek::before { right: 0; background: rgba(255, 255, 255, 0.35); }
#policy .pr-seek-fill { width: 0; background: var(--ours); }
#policy .pr-seek:hover::before, #policy .pr-seek:hover .pr-seek-fill { height: 5px; }
#policy .pr-frame.missing .pr-seek { display: none; }

#policy .pr-speed {
  position: absolute;
  z-index: 2;
  top: 6px;
  right: 6px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-family: monospace;
  font-size: 13px;
  line-height: 18px;
}
