/*
 * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 * SPDX-License-Identifier: Apache-2.0
 */
/* ==========================================================================
   Grana page: synchronized players
   Policy rollouts (dark band) · reward predictions
   ========================================================================== */

/* --------------------------------------------------------------------------
   Shared transport row
   -------------------------------------------------------------------------- */
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.6rem; }
.transport .btn { min-height: 2.5rem; }
/* Seek bars: thin track filled up to the playhead (--fill is kept in sync by
   the site script), round thumb in the accent colour. */
.transport input[type="range"] {
  --fill: 0%;
  --track: rgba(0, 0, 0, 0.16);
  --track-fill: var(--accent-ink);
  --thumb: var(--accent-ink);
  --thumb-ring: #fff;
  -webkit-appearance: none; appearance: none;
  flex: 1 1 10rem; min-width: 6rem;
  height: 2.5rem; margin: 0;
  background: transparent;
  cursor: pointer;
}
.transport input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 999px;
  background: linear-gradient(to right, var(--track-fill) 0 var(--fill), var(--track) var(--fill) 100%);
}
.transport input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; margin-top: -5px;
  border-radius: 50%;
  background: var(--thumb);
  border: 2px solid var(--thumb-ring);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.2);
}
.transport input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; background: var(--track); }
.transport input[type="range"]::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--track-fill); }
.transport input[type="range"]::-moz-range-thumb {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--thumb);
  border: 2px solid var(--thumb-ring);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
}
.transport input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.12); }
.transport-time {
  font: 500 0.82rem/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  white-space: nowrap;
}
.transport select {
  min-height: 2.5rem;
  padding: 0 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-btn);
  background: var(--surface);
  color: var(--text);
  font: 500 0.84rem/1 var(--font-mono);
  cursor: pointer;
}
.transport select:focus-visible, .transport input:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.transport-chip {
  padding: 0.28rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font: 500 0.74rem/1.2 var(--font-mono);
  color: var(--muted);
  white-space: nowrap;
}
.btn--play { min-width: 5.2rem; }
.btn--play::before {
  content: ""; width: 0; height: 0;
  border-style: solid; border-width: 0.32em 0 0.32em 0.55em;
  border-color: transparent transparent transparent currentColor;
}
.btn--play[data-state="playing"]::before {
  width: 0.5em; height: 0.66em;
  border-width: 0 0.16em; border-color: transparent currentColor;
}
.btn--ghost.btn--sm { color: var(--text); }

/* --------------------------------------------------------------------------
   Policy player (on the dark band)
   -------------------------------------------------------------------------- */
.policy-band { margin-top: 0; }
#policy-player { container-type: inline-size; }
.policy-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "tabs" "panel" "context";
  gap: 1.1rem;
}
.policy-active-panel { grid-area: panel; min-width: 0; }
.policy-tabs { grid-area: tabs; min-width: 0; }
.policy-task-context { grid-area: context; min-width: 0; }
@container (min-width: 900px) {
  .policy-card {
    grid-template-columns: minmax(0, 1.72fr) minmax(15.5rem, 1fr);
    grid-template-areas: "panel tabs" "panel context";
    grid-template-rows: auto 1fr;
    column-gap: 2rem; row-gap: 1.1rem;
  }
}
.policy-active-panel:focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 6px; border-radius: var(--r-md); }

.policy-task-identity {
  position: relative;
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 0.2rem 1rem;
  margin-bottom: 0.7rem;
}
.policy-task-anchor { position: absolute; top: 0; left: 0; width: 1px; height: 1px; scroll-margin-top: 1rem; }
.policy-task-identity h3 { margin: 0; font-size: var(--fs-h4); color: var(--text); }
.policy-task-identity h3 .policy-task-count { margin-left: 0.4rem; font: 400 0.84rem/1 var(--font-sans); color: var(--muted); }
.policy-task-meta { font: 500 0.74rem/1.4 var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }

.policy-grid {
  position: relative;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  overflow: hidden;
  border-radius: var(--r-md);
  background: #000;
  cursor: pointer;
}
.policy-cell { position: relative; aspect-ratio: 4 / 3; background: #000; }
.policy-cell video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.policy-view {
  position: absolute; left: 0.45rem; top: 0.45rem; z-index: 1;
  padding: 0.18rem 0.4rem;
  border-radius: 4px;
  background: rgba(5, 7, 10, 0.62);
  font: 500 0.66rem/1 var(--font-mono);
  letter-spacing: 0.06em;
  color: #fff;
  pointer-events: none;
}
/* Right-column labels sit on the outer edge, clear of the centre play disc */
.policy-cell:nth-child(2n) .policy-view { left: auto; right: 0.45rem; }
.policy-grid::after {
  content: "";
  position: absolute; left: 50%; top: 50%; z-index: 2;
  width: 64px; height: 64px; margin: -32px 0 0 -32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(8, 10, 14, 0.62) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M8 5.5v13a1 1 0 0 0 1.52.85l10.4-6.5a1 1 0 0 0 0-1.7L9.52 4.65A1 1 0 0 0 8 5.5z'/%3E%3C/svg%3E") 54% 50% / 24px no-repeat;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  opacity: 0; transition: opacity 0.2s ease;
  pointer-events: none;
}
.policy-grid.is-paused::after { opacity: 1; }
.policy-grid.is-paused:hover::after { background-color: rgba(8, 10, 14, 0.8); }
.policy-transport { margin-top: 0.75rem; }

.policy-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; align-content: start; }
@container (min-width: 900px) {
  .policy-tabs { grid-template-columns: minmax(0, 1fr); gap: 0.45rem; }
}
.policy-task-tab {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  gap: 0.05rem 0.75rem;
  min-height: 3.6rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  text-align: left; font: inherit;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.policy-task-tab:hover { border-color: rgba(255, 255, 255, 0.36); background: rgba(255, 255, 255, 0.05); }
.policy-task-tab:focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 2px; }
.policy-task-name { grid-column: 1; font-size: 0.95rem; font-weight: 600; line-height: 1.3; }
.policy-task-tab .policy-task-count { grid-column: 1; font-size: 0.78rem; line-height: 1.35; color: var(--muted); }
.policy-task-dur { grid-column: 2; grid-row: 1 / span 2; font: 500 0.74rem/1 var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
/* Selected task: dark glass with the accent inset bar (no light slab) */
.policy-task-tab[aria-selected="true"] {
  background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.34); color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}
.policy-task-tab[aria-selected="true"] .policy-task-count,
.policy-task-tab[aria-selected="true"] .policy-task-dur { color: rgba(255, 255, 255, 0.7); }

.policy-task-context {
  display: grid; gap: 0.5rem; align-content: start;
  padding-top: 0.95rem;
  border-top: 1px solid var(--line-strong);
}
.policy-task-context p { margin: 0; font-size: 0.92rem; line-height: 1.6; color: var(--muted); }
.policy-task-context .policy-task-overview { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.policy-task-context .policy-caption { font: 400 var(--fs-small)/1.55 var(--font-sans); color: var(--muted); }

.band-dark .transport-time { color: var(--text); }
.band-dark .transport select { background: var(--dark-panel); border-color: var(--line-strong); color: var(--text); }
.band-dark .transport input[type="range"] { --track: rgba(255, 255, 255, 0.2); --track-fill: var(--accent-dark); --thumb: var(--accent-dark); --thumb-ring: #0b0f14; }
/* Play on the dark band: graphite glass like every other button (the accent
   stays on the seek bar and the selected-task bar) */
.band-dark .btn--play { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.3); color: #fff; }
.band-dark .btn--play:hover { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.45); color: #fff; }
.band-dark .btn--ghost.btn--sm { color: var(--text); }
.band-dark .btn--ghost:hover { border-color: var(--accent-dark); color: var(--accent-dark-ink); }

/* --------------------------------------------------------------------------
   Reward prediction player
   -------------------------------------------------------------------------- */
#prediction-player { container-type: inline-size; min-width: 0; }
.prediction-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5rem; margin: 0 0 1.25rem; }
@container (max-width: 820px) {
  .prediction-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container (max-width: 560px) {
  .prediction-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.prediction-tab {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0.2rem;
  min-height: 4rem; min-width: 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
  text-align: left; font: inherit; font-size: 0.9rem; font-weight: 600; line-height: 1.3;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.prediction-tab:hover { border-color: var(--text); background: rgba(255, 255, 255, 0.5); }
.prediction-tab .prediction-subtask-count { font: 500 0.72rem/1.3 var(--font-mono); color: var(--muted); }
.prediction-tab[aria-selected="true"] { background: var(--text); border-color: var(--text); color: #fff; }
.prediction-tab[aria-selected="true"] .prediction-subtask-count { color: rgba(255, 255, 255, 0.72); }

.prediction-panel { min-width: 0; }
.prediction-panel:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 6px; border-radius: var(--r-md); }
.prediction-heading { display: grid; gap: 0.25rem; max-width: var(--max-prose); margin-bottom: 1rem; }
.prediction-heading h3 { margin: 0; font-size: var(--fs-h4); }
.prediction-event { order: -1; font: 600 0.72rem/1.4 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--q-bad); }
.prediction-description { color: var(--muted); font-size: 0.94rem; line-height: 1.6; }

.prediction-media-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 1rem; align-items: center; }
@container (max-width: 600px) {
  .prediction-media-grid { grid-template-columns: minmax(0, 1fr); }
}
.prediction-camera-wrap { position: relative; min-width: 0; overflow: hidden; border-radius: var(--r-md); background: #000; box-shadow: var(--shadow-frame); }
.prediction-cameras { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: contain; background: #000; cursor: pointer; }
.prediction-camera-wrap::after {
  content: "";
  position: absolute; left: 50%; top: 50%;
  width: 58px; height: 58px; margin: -29px 0 0 -29px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(8, 10, 14, 0.62) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M8 5.5v13a1 1 0 0 0 1.52.85l10.4-6.5a1 1 0 0 0 0-1.7L9.52 4.65A1 1 0 0 0 8 5.5z'/%3E%3C/svg%3E") 54% 50% / 22px no-repeat;
  opacity: 0; transition: opacity 0.2s ease;
  pointer-events: none;
}
.prediction-panel.is-paused .prediction-camera-wrap::after { opacity: 1; }

.prediction-curve-card {
  min-width: 0;
  padding: 0.35rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-frame);
}
/* The future mask lines up only while the curve video is shown uncropped and
   unpadded inside this wrapper (its aspect ratio is set from the plot data). */
.prediction-curve-wrap { position: relative; min-width: 0; overflow: hidden; background: #fff; }
.prediction-curve { display: block; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.prediction-future-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.prediction-future-region { fill: #fff; fill-opacity: var(--prediction-future-opacity, 0.76); }

.prediction-transport { margin-top: 0.9rem; }
.prediction-speed { display: inline-flex; align-items: center; gap: 0.4rem; font: 500 0.74rem/1 var(--font-mono); color: var(--muted); }
.prediction-status { font-size: 0.86rem; line-height: 1.5; color: var(--text-2); }
.prediction-status:not(:empty) { margin-top: 0.45rem; }
.prediction-section-note { max-width: var(--max-prose); margin-top: 0.85rem; font-size: var(--fs-small); line-height: 1.6; color: var(--muted); }

/* --------------------------------------------------------------------------
   Phones
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  /* Row 1: buttons + time; row 2: seek bar + speed. */
  .transport { gap: 0.45rem; }
  .transport input[type="range"] { order: 5; flex: 1 1 8rem; }
  .transport select, .transport .prediction-speed, .transport .transport-chip { order: 6; }
  .transport .transport-time { margin-left: auto; }
  .policy-task-tab { min-height: 3.3rem; padding: 0.5rem 0.7rem; }
  .policy-task-name { font-size: 0.88rem; }
  .policy-task-dur { display: none; }
  .btn--play { min-width: 4.4rem; }
  .prediction-tab { min-height: 3.5rem; padding: 0.5rem 0.65rem; font-size: 0.84rem; }
  .policy-grid::after, .prediction-camera-wrap::after { width: 48px; height: 48px; margin: -24px 0 0 -24px; background-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .policy-grid::after, .prediction-camera-wrap::after, .policy-task-tab, .prediction-tab { transition: none; }
}
