/* ============================================================
   ui.css — Person Sections Analyzer (player page layout)
   Tokens come from tokens.css (single source of design truth)
   ============================================================ */

/* ---------- shell: top bar + progress fixed, workspace fills the rest of
   the viewport — the page itself never scrolls (the sidebar does) ---------- */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------- top bar ---------- */
.top {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-2) var(--s-4);
  min-height: 58px;
  flex: 0 0 auto;
  flex-wrap: wrap;            /* actions drop to a second row instead of being clipped */
  background: color-mix(in srgb, var(--neutral-950) 35%, var(--surface));
  border-bottom: 1px solid var(--border);
}

#prog { flex: 0 0 auto; }

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-shrink: 0;
}
.brand .logo {
  width: 12px; height: 12px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--primary-400), var(--info-400));
  box-shadow: 0 0 8px color-mix(in srgb, var(--primary-400) 60%, transparent);
}
.brand b { font-size: var(--fs-lg); font-weight: 650; letter-spacing: .1px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  min-width: 0;
}

.field {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.field > .lab { white-space: nowrap; }

.actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

select, input[type="file"] {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  font: inherit;
  font-size: var(--fs-sm);
  min-height: 34px;
}
select#vidSel { min-width: 200px; max-width: 300px; }
input[type="range"] { accent-color: var(--accent); width: 90px; }
input[type="file"] { max-width: 230px; font-size: var(--fs-xs); }
input[type="file"]::file-selector-button {
  background: var(--accent-strong); color: var(--on-accent);
  border: 1px solid var(--accent-strong); border-radius: var(--r-sm);
  padding: 4px 10px; margin-right: 8px; font: inherit; font-size: var(--fs-xs);
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--accent); }

/* ---------- global job progress ---------- */
#prog { height: 4px; background: var(--surface-2); position: relative; }
#prog > i {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, var(--primary-500), var(--success-500));
  transition: width .3s;
}

/* ---------- two-pane workspace ---------- */
.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  flex: 1 1 auto;
  min-height: 0;
}

.left {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: #000;
}

.player {
  flex: 1;
  display: flex;
  align-items: center;
  min-height: 0;
}
video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

.controls {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  padding: var(--s-2) var(--s-3);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.controls .group {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  flex-wrap: wrap;
}

/* ---------- timeline strip ---------- */
#tl {
  position: relative;
  height: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin: var(--s-2) var(--s-3) 0;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
}
#tl .seg {
  position: absolute;
  inset: 0 auto 0 0;
  background: color-mix(in srgb, var(--success-500) 80%, transparent);
  border-radius: 2px;
  min-width: 2px;
}
#tl .out-seg {
  position: absolute;
  inset: 0 auto 0 0;
  background: color-mix(in srgb, var(--danger-500) 18%, transparent);
  min-width: 2px;
}
#tl .played {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 0%;
  background: color-mix(in srgb, var(--primary-400) 28%, transparent);
  pointer-events: none;
}

.meta {
  font-family: var(--mono);
  font-size: var(--fs-sm);
  color: var(--text-faint);
  padding: var(--s-2) var(--s-3);
  min-height: 30px;
  overflow-wrap: anywhere;
}
#recTag { color: var(--text-muted); margin-right: var(--s-4); }

/* ---------- right sidebar (sections) ---------- */
.right {
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.right h3 {
  margin: 0;
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--neutral-950) 30%, var(--surface));
  flex-shrink: 0;
}
#list {
  overflow-y: auto;
  padding: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  flex: 1;
  min-height: 0;
}

/* people-visible cards get a success edge; no-people spans are dimmed + dashed */
.card.section { border-left: 3px solid var(--success-600); }
.card.out {
  opacity: .7;
  border-style: dashed;
  border-left: 3px solid color-mix(in srgb, var(--danger-500) 55%, transparent);
}
.card .mark { width: 7px; height: 7px; border-radius: 2px; display: inline-block; margin-right: 4px; }
.card .mark.in  { background: var(--success-500); }
.card .mark.out { background: color-mix(in srgb, var(--danger-400) 65%, transparent); }

/* the card covering the playhead — accent ring + tint, not color-only:
   the ▶ pill names the state explicitly */
.card.active {
  position: relative;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--primary-600) 14%, var(--surface));
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-1);
}
.card.active::before {
  content: "▶ playing";
  position: absolute;
  top: calc(-1 * (var(--s-2) + 3px));
  right: var(--s-3);
  z-index: 1;
  padding: 1px 8px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: var(--fs-xs);
  font-weight: 650;
  letter-spacing: .04em;
  color: var(--on-accent);
  background: var(--accent-strong);
  box-shadow: var(--shadow-1);
}
.card.out.active { opacity: 1; }

#pct { font-weight: 600; font-size: var(--fs-md); font-family: var(--mono); color: var(--success-400); }
#time { min-width: 150px; justify-content: center; }
#status { font-family: var(--font); }

/* ---------- responsive ---------- */
/* ---------- responsive: stacked layout scrolls the page again ---------- */
@media (max-width: 1100px) {
  body { height: auto; overflow: auto; }
  .main { grid-template-columns: 1fr; flex: none; }
  .player { min-height: 52vh; }
  video { max-height: 60vh; width: 100%; }
  .right {
    border-left: 0;
    border-top: 1px solid var(--border);
  }
  #list { max-height: 46vh; }
}

@media (max-width: 720px) {
  .top { flex-wrap: wrap; align-items: stretch; gap: var(--s-2); padding: var(--s-2) var(--s-3); }
  .toolbar { width: 100%; }
  .field { flex: 1 1 auto; }
  select#vidSel { width: 100%; max-width: none; flex: 1 1 160px; }
  input[type="file"] { max-width: none; flex: 1 1 160px; }
  input[type="range"] { width: 100%; }
  .actions { width: 100%; }
  .actions .btn { flex: 1 1 30%; min-height: 40px; }

  .player { min-height: 42vh; }
  .controls { gap: var(--s-1); padding: var(--s-2); }
  .controls .group { width: 100%; }
  .controls .btn { flex: 1 1 28%; min-height: 40px; padding: 6px 8px; }
  #time { order: 5; }
  #tl { height: 20px; }
  .right h3 { padding: var(--s-2) var(--s-3); }
}
