/*
 * Provenance chips (Yambo v3, feature A). Every figure gets a small ring; tapping it opens its evidence.
 * Framework-free and scoped like the rest of the shell. Pair with provenance.js.
 * Colours come from the shell tokens, so it follows the unit accent and dark mode.
 */

.fig {
  white-space: nowrap;
}

.fig data,
.fig output {
  font-variant-numeric: tabular-nums;
}

.chip {
  display: inline-grid;
  place-items: center;
  width: 1.5rem; /* 24px: WCAG 2.2 target size */
  height: 1.5rem;
  margin: 0 0 0 0.05em;
  padding: 0;
  vertical-align: -0.35em;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--yb-soft);
  cursor: pointer;
}

.chip::before {
  content: '';
  width: 0.55rem;
  height: 0.55rem;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--yb-paper), inset 0 0 0 3px currentColor;
}

.chip:hover,
.chip[aria-expanded='true'] {
  color: var(--yb-accent);
}

.chip:focus-visible {
  outline: 2px solid var(--yb-accent);
  outline-offset: 1px;
}

/* The evidence panel: a popover beside the chip on wide screens with a mouse, a bottom sheet on phones. */
.yb-ev {
  width: min(26rem, calc(100vw - 2rem));
  max-height: min(34rem, 80vh);
  margin: 0;
  padding: 1.25rem 1.25rem 1.1rem;
  border: 1px solid var(--yb-ink);
  border-radius: 0;
  background: var(--yb-card, var(--yb-paper));
  color: var(--yb-ink);
  font-family: var(--yb-sans);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.yb-ev::backdrop {
  background: rgb(10 16 22 / 0.28);
}

.yb-ev__top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
}

.yb-ev__value {
  margin: 0 0 0.9rem;
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--yb-serif);
  font-size: 2rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.yb-ev__close {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  margin: -0.4rem -0.4rem 0 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--yb-ink);
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.yb-ev__close:focus-visible,
.yb-ev a:focus-visible {
  outline: 2px solid var(--yb-accent);
  outline-offset: 2px;
}

.yb-ev a {
  color: var(--yb-accent);
}

/* The record: the same fields everywhere, keys in the evidence voice. */
.yb-ev dl {
  display: grid;
  grid-template-columns: 7rem 1fr;
  margin: 0;
  border-top: 1px solid var(--yb-ink);
}

.yb-ev dt,
.yb-ev dd {
  margin: 0;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--yb-grid, var(--yb-rule));
}

.yb-ev dt {
  padding-top: 0.7rem;
  font-family: var(--yb-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--yb-soft);
}

.yb-ev dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.yb-status {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.yb-status--measured {
  color: var(--yb-accent);
}

.yb-status--estimate {
  color: var(--yb-soft);
  border-style: dashed;
}

.yb-status--sample {
  color: var(--yb-soft);
  border-style: dotted;
}

.yb-status--published,
.yb-status--input {
  color: var(--yb-ink);
}

@media (max-width: 47.99em), (pointer: coarse) {
  .yb-ev {
    inset: auto 0 0 0;
    width: 100%;
    max-width: none;
    max-height: 85vh;
    border-width: 1px 0 0;
    border-radius: 0;
    padding: 0.6rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
  }

  .yb-ev::before {
    content: '';
    display: block;
    width: 2.5rem;
    height: 4px;
    margin: 0 auto 0.75rem;
    border-radius: 2px;
    background: var(--yb-rule);
  }
}

@media print {
  .chip {
    display: none;
  }
}

.yb-ev__rules {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  margin: 0.9rem 0 0;
  font-size: 0.875rem;
  font-weight: 600;
}
