/*
 * SPDX-FileCopyrightText: Copyright The Zephyr Project Contributors
 * SPDX-License-Identifier: Apache-2.0
 *
 * POSIX Option Group badges. Donut style mirrors scripts/ci/coverageui.py.
 */

:root {
  --pn-green: #198754;
  --pn-yellow: #cc9a06;
  --pn-red: #dc3545;
  --pn-unknown: #868e96;
  /* translucent: legible on light and dark themes alike */
  --pn-ring-bg: rgba(128, 140, 160, 0.28);
  /* punch-out follows the live theme background */
  --pn-ring-center: var(--content-wrap-background-color, #fcfcfc);
}

/* Badge strips are invisible tables: fixed-size cells in a fixed slot
   order, with empty placeholder cells, so badges align in columns. */
.pn-badges {
  display: inline-flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0.6em 0 1.2em;
}

.pn-badges > .pn-cell {
  display: flex;
  width: 56px;
  justify-content: center;
  align-items: flex-start;
}

.pn-cell.pn-empty {
  visibility: hidden;
}

.pn-badge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 52px;
}

.pn-badge {
  transition: transform 0.15s ease;
  cursor: default;
}

.pn-badge:hover {
  transform: scale(1.15);
}

@media (prefers-reduced-motion: reduce) {
  .pn-badge {
    transition: none;
  }
  .pn-badge:hover {
    transform: none;
  }
}

/* percentage donut (conic-gradient set inline per badge) */
.pn-ring {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  position: relative;
  background: var(--pn-ring-bg);
}

.pn-ring::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 999px;
  background: var(--pn-ring-center);
}

.pn-ring > span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 2;
  font-weight: 700;
  font-size: 0.73rem;
}

.pn-ring-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  opacity: 0.7;
}

/* pass/fail status circle */
.pn-status {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--pn-ring-bg);
  position: relative;
  font-size: 1.35rem;
  line-height: 1;
}

.pn-status .pn-glyph-text {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.pn-status.pn-pass {
  box-shadow: inset 0 0 0 2px var(--pn-green);
}

.pn-status.pn-fail {
  box-shadow: inset 0 0 0 2px var(--pn-red);
}

/* round ISO C badge with no test data yet */
.pn-status.pn-none {
  box-shadow: inset 0 0 0 2px var(--pn-unknown);
}

.pn-status .pn-mark {
  position: absolute;
  right: -3px;
  bottom: -3px;
  font-size: 0.85rem;
  font-weight: 900;
  line-height: 1;
}

.pn-pass .pn-mark {
  color: var(--pn-green);
}

.pn-fail .pn-mark {
  color: var(--pn-red);
}

/* per-function badge strips: their own table column, fixed-slot cells */
td.pn-badges-col,
th.pn-badges-col {
  white-space: nowrap;
  vertical-align: middle;
}

/* the option_groups index toctree, re-rendered as a table by JS */
.pn-index-table td {
  vertical-align: middle;
}

.pn-func-badges {
  display: inline-flex;
  gap: 4px;
  vertical-align: middle;
  align-items: center;
}

.pn-func-badges .pn-cell {
  display: inline-flex;
  width: 38px;
  height: 34px;
  align-items: center;
  justify-content: center;
}

.pn-func-badges .pn-cell.pn-wide {
  width: 68px;
}

.pn-func-badges .pn-ring {
  width: 30px;
  height: 30px;
}

.pn-func-badges .pn-ring::after {
  inset: 4px;
}

.pn-func-badges .pn-ring > span {
  font-size: 0.58rem;
}

.pn-func-badges .pn-ring-label {
  display: none;
}

.pn-func-badges .pn-status {
  width: 30px;
  height: 30px;
  font-size: 0.95rem;
}

.pn-func-badges .pn-status .pn-glyph-text {
  font-size: 0.62rem;
}

.pn-func-badges .pn-status .pn-mark {
  font-size: 0.7rem;
  right: -2px;
  bottom: -2px;
}

/* text pills (ISO C, ENOSYS) next to :c:func: references */
.pn-pill {
  display: inline-block;
  padding: 0 0.35em;
  border-radius: 0.5em;
  font-size: 0.68em;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.pn-pill.pn-isoc {
  border: 1px solid var(--pn-green);
  color: var(--pn-green);
}

.pn-pill.pn-enosys {
  border: 1px solid var(--pn-red);
  color: var(--pn-red);
}

/* coverage donuts link to Codecov; keep them looking like badges */
a.pn-badge-link,
a.pn-badge-link:hover,
a.pn-badge-link:visited {
  /* inline-flex so span-based donut rings keep their box size inside the link */
  display: inline-flex;
  text-decoration: none;
  border-bottom: none;
}

a.pn-badge-link .pn-ring {
  cursor: pointer;
}
