/* Pixel accents for the work pages (js/pixel-accents.js), only under
   <body class="px-accents">. Cards and primary buttons take the pixel kit's
   stepped edges; forms, inputs and tables keep their look.

   Cards draw the frame on ::before (the stepped border) and ::after (the
   stepped surface) instead of clipping the card: a clip on a bordered box
   leaves holes at the corners and would cut anything that pokes out.
   Requires tokens.css (and pixel.css for the shared .px-* classes). */

body.px-accents {
  --pxa-step-9: polygon(
    0 9px, 3px 9px, 3px 6px, 6px 6px, 6px 3px, 9px 3px, 9px 0,
    calc(100% - 9px) 0, calc(100% - 9px) 3px, calc(100% - 6px) 3px, calc(100% - 6px) 6px,
    calc(100% - 3px) 6px, calc(100% - 3px) 9px, 100% 9px,
    100% calc(100% - 9px), calc(100% - 3px) calc(100% - 9px), calc(100% - 3px) calc(100% - 6px),
    calc(100% - 6px) calc(100% - 6px), calc(100% - 6px) calc(100% - 3px), calc(100% - 9px) calc(100% - 3px),
    calc(100% - 9px) 100%, 9px 100%, 9px calc(100% - 3px), 6px calc(100% - 3px),
    6px calc(100% - 6px), 3px calc(100% - 6px), 3px calc(100% - 9px), 0 calc(100% - 9px)
  );
  --pxa-step-6: polygon(
    0 6px, 3px 6px, 3px 3px, 6px 3px, 6px 0, calc(100% - 6px) 0, calc(100% - 6px) 3px,
    calc(100% - 3px) 3px, calc(100% - 3px) 6px, 100% 6px, 100% calc(100% - 6px),
    calc(100% - 3px) calc(100% - 6px), calc(100% - 3px) calc(100% - 3px), calc(100% - 6px) calc(100% - 3px),
    calc(100% - 6px) 100%, 6px 100%, 6px calc(100% - 3px), 3px calc(100% - 3px), 3px calc(100% - 6px), 0 calc(100% - 6px)
  );
  --pxa-step-4: polygon(
    0 4px, 4px 4px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px)
  );
}

/* --- Cards --------------------------------------------------------------- */

body.px-accents .card,
body.px-accents .ui-card {
  position: relative;
  isolation: isolate;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

body.px-accents .card:hover,
body.px-accents .ui-card:hover {
  background: none;
  box-shadow: none;
}

body.px-accents .card::before,
body.px-accents .ui-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  padding: 0;
  border-radius: 0;
  background: var(--line-strong);
  -webkit-mask: none;
  mask: none;
  opacity: 1;
  clip-path: var(--pxa-step-9);
  pointer-events: none;
}

body.px-accents .card::after,
body.px-accents .ui-card::after {
  content: "";
  position: absolute;
  /* 3px, so the surface's 6px steps sit inside the border's 9px steps and
     the border reads as one line, not dashes. */
  inset: 3px;
  z-index: -1;
  background: var(--surface);
  clip-path: var(--pxa-step-6);
  pointer-events: none;
}

body.px-accents .card:hover::after {
  background: var(--surface-2);
}

/* Kas' dialogs keep a big shadow on hover with !important; the steps would
   show it as a square. */
body.px-accents .debt-modal .card:hover {
  box-shadow: none !important;
}

/* --- Primary buttons ----------------------------------------------------- */

body.px-accents .ui-btn--primary,
body.px-accents button[type="submit"],
body.px-accents [data-px-primary] {
  border-radius: 0;
  clip-path: var(--pxa-step-4);
}

/* An outer focus ring would be cut by the steps: inset, in the button's own
   ink so it reads on the brand fill. */
body.px-accents .ui-btn--primary:focus-visible,
body.px-accents button[type="submit"]:focus-visible,
body.px-accents [data-px-primary]:focus-visible {
  outline: none;
  /* The button's own text colour: pages pick it to read on the fill, so the
     ring does too, whatever the fill (brand, ok, a page's gradient). */
  box-shadow: inset 0 0 0 3px currentColor;
}

/* --- Empty states and bursts --------------------------------------------- */

/* Pages dim their old empty-line wrappers; the empty state already uses the
   muted ink, so dimming it again drops the text below AA. */
body.px-accents :is(.empty, .debt-empty, .roster-empty, .cal__empty):has(.px-empty) {
  opacity: 1;
  padding: 0;
}

.px-empty {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-3);
  text-align: center;
}

.px-empty__sprite {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

.px-empty__text {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.px-burst {
  position: fixed;
  z-index: var(--z-toast);
  width: 135px;
  height: 225px;
  transform: translate(-50%, -40%);
  image-rendering: pixelated;
  pointer-events: none;
}
