/* ─── shape ──────────────────────────────────────────────────────────────────
 * The slanted corner: `.np-cut` cuts the bottom-right corner off a button, card
 * or code block. `clip-path` clips everything drawn on the element, border and
 * focus ring included, so the parts are layered rather than one box:
 *
 *   ::before   the border colour, clipped to the cut shape
 *   ::after    the fill, inset 1px and clipped to a slightly smaller cut, so what
 *              shows of ::before is a 1px border that follows the diagonal
 *   the element itself is NOT clipped, so its focus outline is a full 2px ring
 *              around the whole box and the cut cannot slice it (3:1, AC-6)
 *
 * Size comes from `--cut`, the run along the bottom edge: 9px on buttons (the
 * default), 6px on small buttons (`np-cut--sm`), 16px on cards and code blocks
 * (`np-cut--lg`). The run up the right edge is `--cut-y`, 1.25 x `--cut`: the
 * brand cuts at a 4 by 5 angle (the image frames and the symbol's chevrons), never
 * 45 degrees. Colours are tokens, overridable per element through `--cut-border`
 * and `--cut-fill`.
 * ─────────────────────────────────────────────────────────────────────────── */

.np-cut {
  --cut: 9px;
  --cut-y: calc(var(--cut) * 1.25);
}

/* :where() keeps these base declarations at zero specificity, so a component's
   own position, border or background wins instead of losing on import order. */
:where(.np-cut) {
  position: relative;
  isolation: isolate;
  border: 0;
  background: transparent;
}

.np-cut--sm {
  --cut: 6px;
}

.np-cut--lg {
  --cut: 16px;
}

.np-cut::before,
.np-cut::after {
  content: "";
  position: absolute;
  z-index: -1;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--cut-y)), calc(100% - var(--cut)) 100%, 0 100%);
}

.np-cut::before {
  inset: 0;
  background: var(--cut-border, var(--c-outline-control));
}

/* A 1px inset moves the diagonal 1px away from the border layer's, so the inner
   cut is shorter than the outer by 0.52px along the bottom and 0.65px up the
   right edge for the two edges to stay parallel. */
.np-cut::after {
  inset: 1px;
  background: var(--cut-fill, var(--c-surface));
  clip-path: polygon(
    0 0,
    100% 0,
    100% calc(100% - var(--cut-y) + 0.65px),
    calc(100% - var(--cut) + 0.52px) 100%,
    0 100%
  );
}

.np-cut:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

@media (forced-colors: active) {
  .np-cut::before {
    background: CanvasText;
  }

  .np-cut::after {
    background: Canvas;
  }

  .np-cut:focus-visible {
    outline-color: Highlight;
  }
}
