/*
 * View styles — bug capsules.
 * Scoped under .v-capsules. Shared primitives come from /ui/components.css.
 *
 * The capsule list is a radio group. Each capsule-specific value in the detail
 * panel is wrapped in .cs-var[data-cap="n"]; :has() shows the wrapper whose
 * capsule is checked, so selection works without any script.
 */

.v-capsules .view-main {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

/* --------------------------------------------------------------- header */

.v-capsules .page-header {
  margin-bottom: 0;
}

.v-capsules .page-header__main {
  flex-basis: 480px;
}

.v-capsules .page-header__meta {
  margin-bottom: 6px;
}

.v-capsules .page-header__sub {
  max-width: 720px;
  color: var(--text-1);
  line-height: 1.55;
}

/* --------------------------------------------------------------- badges */

.v-capsules .cs-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  align-self: flex-start;
  padding: 3px var(--sp-2);
  border-radius: var(--r-1);
  font-family: var(--font-mono);
  font-size: var(--fz-2xs);
  line-height: 1.4;
  white-space: nowrap;
}

.v-capsules .cs-badge--lg {
  padding: var(--sp-1) var(--sp-2);
}

.v-capsules .cs-badge--sand {
  background: var(--sand-soft);
  color: var(--sand-ink);
}

.v-capsules .cs-badge--ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.v-capsules .cs-badge--info {
  background: var(--signal-soft);
  color: var(--signal-hover);
}

.v-capsules .cs-badge--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.v-capsules .cs-badge--bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.v-capsules .cs-badge--ink {
  background: var(--ink-0);
  color: var(--bone-0);
}

/* -------------------------------------------------------------- warning */

.v-capsules .cs-warning {
  padding: 14px var(--sp-4);
  border: 1px solid #ecdcb8;
  border-radius: var(--r-2);
  background: #fbf6ec;
  box-shadow: inset 3px 0 0 var(--warn);
}

.v-capsules .cs-warning__title {
  color: var(--text-0);
  font-size: var(--fz-sm);
  font-weight: var(--fw-semibold);
}

.v-capsules .cs-warning__text {
  margin-top: 3px;
  color: var(--text-1);
  font-size: var(--fz-sm);
  line-height: 1.5;
}

/* --------------------------------------------------------- panel chrome */

.v-capsules .cs-panel {
  min-width: 0;
  border: 1px solid var(--line-0);
  border-radius: var(--r-2);
  background: var(--paper-1);
}

.v-capsules .cs-panel__head {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line-0);
}

.v-capsules .cs-panel__title {
  font-size: 0.9375rem;
  font-weight: var(--fw-semibold);
}

.v-capsules .cs-panel__meta {
  margin-top: 2px;
  color: var(--text-2);
  font-size: var(--fz-xs);
}

.v-capsules .cs-mono {
  font-family: var(--font-mono);
  font-size: var(--fz-xs);
}

.v-capsules .cs-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- layout */

.v-capsules .cs-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--sp-6);
}

.v-capsules .cs-list-card {
  flex: 1 1 280px;
}

.v-capsules .cs-detail {
  flex: 3 1 520px;
}

/* ----------------------------------------------------------------- list */

.v-capsules .cs-list {
  min-width: 0;
  margin: 0;
  padding: var(--sp-2);
  border: 0;
}

.v-capsules .cs-list__items {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.v-capsules .cs-pick {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.v-capsules .cs-item {
  display: block;
  padding: var(--sp-3);
  border: 1px solid transparent;
  border-radius: var(--r-2);
  background: var(--paper-1);
  color: var(--text-0);
  cursor: pointer;
}

.v-capsules .cs-item:hover {
  background: var(--paper-2);
}

.v-capsules .cs-pick:checked + .cs-item {
  border-color: var(--signal-ink);
  background: #f4f7ff;
}

.v-capsules .cs-pick:focus-visible + .cs-item {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.v-capsules .cs-item__top {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
}

.v-capsules .cs-item__id {
  font-family: var(--font-mono);
  font-size: var(--fz-xs);
  font-weight: var(--fw-semibold);
}

.v-capsules .cs-item__at {
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--fz-2xs);
}

.v-capsules .cs-item__err {
  display: block;
  margin-top: 6px;
  color: var(--bad);
  font-family: var(--font-mono);
  font-size: 0.71875rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.v-capsules .cs-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  color: var(--text-2);
  font-size: var(--fz-2xs);
}

.v-capsules .cs-item__env {
  padding: 1px 5px;
  border: 1px solid var(--line-1);
  border-radius: var(--r-1);
  font-family: var(--font-mono);
}

.v-capsules .cs-item__page {
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------- detail */

.v-capsules .cs-var {
  display: contents;
}

.v-capsules .cs-var[data-cap="2"],
.v-capsules .cs-var[data-cap="3"] {
  display: none;
}

.v-capsules:has(#cs-pick-2:checked) .cs-var[data-cap="1"],
.v-capsules:has(#cs-pick-3:checked) .cs-var[data-cap="1"] {
  display: none;
}

.v-capsules:has(#cs-pick-2:checked) .cs-var[data-cap="2"],
.v-capsules:has(#cs-pick-3:checked) .cs-var[data-cap="3"] {
  display: contents;
}

.v-capsules .cs-detail__head {
  padding: 18px var(--sp-5);
  border-bottom: 1px solid var(--line-0);
}

.v-capsules .cs-detail__top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--sp-3);
}

.v-capsules .cs-detail__meta {
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--fz-2xs);
}

.v-capsules .cs-detail__title {
  margin-top: var(--sp-2);
  font-size: 1.25rem;
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.v-capsules .cs-detail__err {
  margin-top: 6px;
  color: var(--bad);
  font-family: var(--font-mono);
  font-size: var(--fz-xs);
  overflow-wrap: anywhere;
}

.v-capsules .cs-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-3);
  margin: 0;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line-0);
  font-size: var(--fz-sm);
}

.v-capsules .cs-facts dt {
  color: var(--text-2);
  font-size: var(--fz-xs);
}

.v-capsules .cs-facts dd {
  margin: 2px 0 0;
  color: var(--text-0);
}

.v-capsules .cs-block {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line-0);
}

.v-capsules .cs-block--last {
  border-bottom: 0;
}

.v-capsules .cs-block__title {
  font-size: var(--fz-sm);
  font-weight: var(--fw-semibold);
}

.v-capsules .cs-block__text {
  margin-top: var(--sp-1);
  color: var(--text-1);
  font-size: var(--fz-sm);
}

.v-capsules .cs-block__note {
  margin-top: var(--sp-2);
  color: var(--text-2);
  font-size: var(--fz-xs);
}

.v-capsules .cs-redactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--sp-2);
}

.v-capsules .cs-cmd {
  margin: 10px 0 0;
  padding: var(--sp-3) 14px;
  border-radius: var(--r-2);
  background: var(--ink-0);
  color: var(--bone-0);
  font-family: var(--font-mono);
  font-size: var(--fz-xs);
  line-height: 1.7;
  overflow-x: auto;
}

.v-capsules .cs-cmd code {
  color: inherit;
  font: inherit;
}

.v-capsules .cs-cmd__line {
  display: block;
  white-space: pre;
}

.v-capsules .cs-cmd__line::before {
  content: "$ ";
  color: var(--bone-2);
}

.v-capsules .cs-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.v-capsules .cs-actions .btn {
  min-height: 36px;
  padding: 0 14px;
  font-size: var(--fz-sm);
  font-weight: var(--fw-medium);
}

/* --------------------------------------------------------------- events */

.v-capsules .cs-events {
  margin: 0;
  padding: 0;
  list-style: none;
}

.v-capsules .cs-event {
  display: grid;
  grid-template-columns: 80px 84px minmax(0, 1fr);
  align-items: baseline;
  gap: var(--sp-3);
  padding: 11px var(--sp-5);
  border-bottom: 1px solid var(--line-0);
}

.v-capsules .cs-event:last-child {
  border-bottom: 0;
}

.v-capsules .cs-event__t {
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--fz-2xs);
  font-variant-numeric: tabular-nums;
}

.v-capsules .cs-event__k {
  justify-self: start;
  padding: 2px 6px;
  font-size: 0.65625rem;
}

.v-capsules .cs-event__d {
  color: var(--text-0);
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  overflow-wrap: anywhere;
}

/* ----------------------------------------------------------- responsive */

@media (max-width: 720px) {
  .v-capsules .view-main,
  .v-capsules .cs-layout {
    gap: var(--sp-4);
  }

  .v-capsules .cs-panel__head,
  .v-capsules .cs-detail__head,
  .v-capsules .cs-facts,
  .v-capsules .cs-block {
    padding-left: var(--sp-4);
    padding-right: var(--sp-4);
  }

  .v-capsules .cs-event {
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--sp-1) var(--sp-3);
    padding: 10px var(--sp-4);
  }

  .v-capsules .cs-event__d {
    grid-column: 1 / -1;
  }

  .v-capsules .cs-actions .btn {
    flex: 1 1 auto;
    min-height: 44px;
  }
}
