/* Nameplates and badges (nameplate.ts). The website loads this same file as
   site/css/nameplate.css (npm run site:looks copies it), so a plate looks the
   same in the game and on the homepage board.

   A plate is built like the object it imitates, in layers:
     .np            the frame. Its border is transparent and the frame gradient
                    paints under it, so the frame is exactly the border box and
                    follows any clip-path the style sets.
     .np::before    the body inside the frame, clipped to the same shape set in
                    by the frame width, so a cut corner or a point gets its
                    outline too instead of being sliced off.
     .np-fx         the style's hardware: rivets, a hole, stripes, teeth.
     .np-shine      a slow sweep of light, on some plates.
     .np::after     the material texture over all of that, blended in overlay.
     name, badge    on top.
   Colors come in through custom properties from data/nameplates.ts; the
   style is one np-d-* class. Nothing here knows a plate by name. */

.np {
  --np-bg: linear-gradient(180deg, #1b222c 0%, #121820 100%);
  --np-edge: #334155;
  --np-ink: #e2e8f0;
  --np-alt: #121010;
  --np-bw: 1px;
  --np-r: 3px;
  --np-frame: linear-gradient(180deg,
    color-mix(in srgb, var(--np-edge), #fff 38%) 0%,
    var(--np-edge) 34%,
    color-mix(in srgb, var(--np-edge), #000 30%) 70%,
    color-mix(in srgb, var(--np-edge), #000 55%) 100%);
  --np-tex: var(--np-tex-grain);
  --np-tex-a: 0.5;
  --np-ink-fx: 0 -1px 0 rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.16), 0 1px 3px rgba(0, 0, 0, 0.55);

  /* Grayscale noise tiles, centered on middle gray so overlay leaves the
     average color alone. Brushed is stretched along x into streaks; cast is
     slow blotches with fine pitting through it. */
  --np-tex-grain: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='128' height='128'><filter id='f' x='0' y='0' width='1' height='1'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='3' stitchTiles='stitch'/><feColorMatrix values='0.33 0.33 0.33 0 0 0.33 0.33 0.33 0 0 0.33 0.33 0.33 0 0 0 0 0 0 1'/><feComponentTransfer><feFuncR type='linear' slope='1.8' intercept='-0.4'/><feFuncG type='linear' slope='1.8' intercept='-0.4'/><feFuncB type='linear' slope='1.8' intercept='-0.4'/></feComponentTransfer></filter><rect width='128' height='128' filter='url(%23f)'/></svg>");
  --np-tex-brushed: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='256' height='64'><filter id='f' x='0' y='0' width='1' height='1'><feTurbulence type='fractalNoise' baseFrequency='0.003 0.7' numOctaves='3' seed='8' stitchTiles='stitch'/><feColorMatrix values='0.33 0.33 0.33 0 0 0.33 0.33 0.33 0 0 0.33 0.33 0.33 0 0 0 0 0 0 1'/><feComponentTransfer><feFuncR type='linear' slope='2.6' intercept='-0.8'/><feFuncG type='linear' slope='2.6' intercept='-0.8'/><feFuncB type='linear' slope='2.6' intercept='-0.8'/></feComponentTransfer></filter><rect width='256' height='64' filter='url(%23f)'/></svg>");
  --np-tex-cast: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='f' x='0' y='0' width='1' height='1'><feTurbulence type='fractalNoise' baseFrequency='0.045' numOctaves='5' seed='21' stitchTiles='stitch'/><feColorMatrix values='0.33 0.33 0.33 0 0 0.33 0.33 0.33 0 0 0.33 0.33 0.33 0 0 0 0 0 0 1'/><feComponentTransfer><feFuncR type='linear' slope='2.4' intercept='-0.7'/><feFuncG type='linear' slope='2.4' intercept='-0.7'/><feFuncB type='linear' slope='2.4' intercept='-0.7'/></feComponentTransfer></filter><rect width='160' height='160' filter='url(%23f)'/></svg>");

  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  max-width: 100%;
  overflow: hidden;
  border: var(--np-bw) solid transparent;
  border-radius: var(--np-r);
  background: var(--np-frame) border-box;
  color: var(--np-ink);
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  vertical-align: middle;
}

.np::before,
.np::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: max(0px, calc(var(--np-r) - var(--np-bw)));
  clip-path: var(--np-clip-in, none);
}

/* The body: a top light and a bottom shade over the plate's own colors, with
   a bevel where it meets the frame and the ends falling off into shadow. */
.np::before {
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 48%, rgba(0, 0, 0, 0.14) 100%),
    var(--np-bg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    inset 0 0 0.7em rgba(0, 0, 0, 0.35);
}

.np::after {
  z-index: 0;
  background: var(--np-tex);
  mix-blend-mode: overlay;
  opacity: var(--np-tex-a);
}

.np > .np-name,
.np > .np-badge {
  position: relative;
  z-index: 1;
}

.np-name {
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: var(--np-ink-fx);
}

.np-sm { font-size: 0.74rem; padding: 0.1em 0.55em 0.1em 0.35em; }
.np-md { font-size: 0.92rem; padding: 0.22em 0.85em 0.22em 0.45em; --np-bw: 1.5px; }
.np-lg { font-size: 1.25rem; padding: 0.32em 1.15em 0.32em 0.55em; --np-bw: 2px; --np-r: 4px; }

/* The default plate stays plain, so a bought one has something to be ahead of. */
.np-default {
  --np-frame: var(--np-edge);
  --np-tex-a: 0.25;
}
.np-default::before { box-shadow: none; }
.np-default .np-name { padding-left: 0.2em; }

.np-fx,
.np-shine {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.np-shine { overflow: hidden; }

.np-shine::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -40%;
  width: 30%;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, 0.18) 50%, transparent 100%);
  transform: skewX(-20deg);
  animation: np-sheen 5.5s ease-in-out infinite;
}

@keyframes np-sheen {
  0%, 70% { left: -40%; }
  100% { left: 120%; }
}

/* ── styles ── */

/* Field plate: brushed metal screwed down at the corners. */
.np-d-rivets {
  --np-tex: var(--np-tex-brushed);
  --np-tex-a: 0.55;
  padding-left: 0.85em;
  padding-right: 1.05em;
}
.np-d-rivets .np-fx {
  --rv: radial-gradient(circle at 40% 36%,
    rgba(255, 255, 255, 0.9) 0 9%,
    var(--np-edge) 20% 34%,
    color-mix(in srgb, var(--np-edge), #000 55%) 44%,
    rgba(0, 0, 0, 0.6) 49%,
    transparent 56%);
  background:
    var(--rv) left 0.08em top 0.08em / 0.5em 0.5em no-repeat,
    var(--rv) right 0.08em top 0.08em / 0.5em 0.5em no-repeat,
    var(--rv) left 0.08em bottom 0.08em / 0.5em 0.5em no-repeat,
    var(--rv) right 0.08em bottom 0.08em / 0.5em 0.5em no-repeat;
}

/* Dog tag: rounded stamped steel with a rolled rim, a punched hole, and the
   name struck in capitals the way a tag machine does it. */
.np-d-tag {
  --np-r: 0.62em;
  --np-tex: var(--np-tex-brushed);
  --np-tex-a: 0.6;
  --np-ink-fx: 0 1px 0 rgba(255, 255, 255, 0.35), 0 -1px 0 rgba(0, 0, 0, 0.45);
  padding-left: 1.5em;
  padding-right: 0.85em;
  font-family: ui-monospace, 'Cascadia Mono', 'Roboto Mono', 'Droid Sans Mono', Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.np-d-tag .np-fx::before {
  content: '';
  position: absolute;
  left: 0.32em;
  top: 50%;
  width: 0.62em;
  height: 0.62em;
  transform: translateY(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #050608 0 44%, rgba(0, 0, 0, 0.75) 50%, rgba(255, 255, 255, 0.5) 58%, transparent 70%);
}
.np-d-tag .np-fx::after {
  content: '';
  position: absolute;
  inset: 0.16em;
  border-radius: max(0px, calc(var(--np-r) - var(--np-bw) - 0.16em));
  box-shadow:
    inset 0 1px 0 rgba(0, 0, 0, 0.4),
    inset 0 -1px 0 rgba(255, 255, 255, 0.28),
    0 1px 0 rgba(255, 255, 255, 0.22),
    0 -1px 0 rgba(0, 0, 0, 0.3);
}

/* Console: a readout behind glass, in a dark bezel. Corner brackets glow in
   the readout's color, the glass has scanlines and one reflection. */
.np-d-brackets {
  --np-frame: linear-gradient(180deg, #3b424b 0%, #1d2127 45%, #0c0e11 100%);
  --np-tex-a: 0.3;
  --np-ink-fx: 0 0 0.4em color-mix(in srgb, var(--np-edge) 70%, transparent), 0 1px 1px #000;
  padding-left: 0.75em;
  padding-right: 1em;
}
.np-d-brackets .np-fx {
  --bk: linear-gradient(var(--np-edge), var(--np-edge));
  background:
    var(--bk) left 0.12em top 0.12em / 0.55em 0.11em no-repeat,
    var(--bk) left 0.12em top 0.12em / 0.11em 0.55em no-repeat,
    var(--bk) right 0.12em top 0.12em / 0.55em 0.11em no-repeat,
    var(--bk) right 0.12em top 0.12em / 0.11em 0.55em no-repeat,
    var(--bk) left 0.12em bottom 0.12em / 0.55em 0.11em no-repeat,
    var(--bk) left 0.12em bottom 0.12em / 0.11em 0.55em no-repeat,
    var(--bk) right 0.12em bottom 0.12em / 0.55em 0.11em no-repeat,
    var(--bk) right 0.12em bottom 0.12em / 0.11em 0.55em no-repeat;
  filter: drop-shadow(0 0 0.15em var(--np-edge));
}
.np-d-brackets .np-fx::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(112deg, transparent 0 58%, rgba(255, 255, 255, 0.08) 58% 72%, transparent 72%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 3px);
}

/* Warning: painted striping at both ends, edged like a sign. */
.np-d-hazard {
  --np-tex-a: 0.6;
  padding-left: 1.05em;
  padding-right: 1.3em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.np-d-hazard .np-fx {
  --hz: repeating-linear-gradient(135deg, var(--np-edge) 0 0.25em, var(--np-alt) 0.25em 0.5em);
  background:
    linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.55)) left 0.55em top 0 / 1px 100% no-repeat,
    linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.55)) right 0.55em top 0 / 1px 100% no-repeat,
    var(--hz) left / 0.55em 100% no-repeat,
    var(--hz) right / 0.55em 100% no-repeat;
}

/* Unit stripe: painted chevrons at the leading end, pointing at the name. */
.np-d-chevrons {
  --np-tex-a: 0.6;
  padding-left: 2.15em;
}
.np-d-chevrons .np-fx::before {
  content: '';
  position: absolute;
  left: 0.4em;
  top: 20%;
  bottom: 20%;
  width: 1.5em;
  background:
    linear-gradient(to top right, transparent 42%, var(--np-edge) 42% 66%, transparent 66%) top left / 0.5em 50% repeat-x,
    linear-gradient(to bottom right, transparent 42%, var(--np-edge) 42% 66%, transparent 66%) bottom left / 0.5em 50% repeat-x;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.6));
}
.np-d-chevrons .np-fx::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.16em;
  height: 0.08em;
  background: linear-gradient(90deg, var(--np-edge) 0%, transparent 85%);
  opacity: 0.55;
}

/* Enamel: glossy color poured between two polished caps. */
.np-d-ends {
  --np-tex-a: 0.25;
  padding-left: 0.85em;
  padding-right: 1.05em;
}
.np-d-ends .np-fx {
  --cap: linear-gradient(90deg,
    color-mix(in srgb, var(--np-edge), #000 45%) 0%,
    var(--np-edge) 35%,
    color-mix(in srgb, var(--np-edge), #fff 45%) 55%,
    color-mix(in srgb, var(--np-edge), #000 35%) 100%);
  background:
    var(--cap) left / 0.3em 100% no-repeat,
    var(--cap) right / 0.3em 100% no-repeat;
}
.np-d-ends .np-fx::before {
  content: '';
  position: absolute;
  left: 0.3em;
  right: 0.3em;
  top: 0;
  height: 48%;
  border-radius: 0 0 50% 50% / 0 0 30% 30%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.26) 0%, rgba(255, 255, 255, 0.04) 100%);
}

/* Plaque: cast metal with cut corners, an engraved line following them, and
   the name in engraved serif capitals. The body is cut by the same corner,
   shortened by the frame width, so the frame runs all the way around. */
.np-d-notch {
  --cut: 0.45em;
  --cut-in: calc(var(--cut) - var(--np-bw) * 0.414);
  --np-r: 0px;
  --np-tex: var(--np-tex-cast);
  --np-tex-a: 0.6;
  clip-path: polygon(var(--cut) 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% calc(100% - var(--cut)),
    calc(100% - var(--cut)) 100%, var(--cut) 100%, 0 calc(100% - var(--cut)), 0 var(--cut));
  --np-clip-in: polygon(var(--cut-in) 0, calc(100% - var(--cut-in)) 0, 100% var(--cut-in), 100% calc(100% - var(--cut-in)),
    calc(100% - var(--cut-in)) 100%, var(--cut-in) 100%, 0 calc(100% - var(--cut-in)), 0 var(--cut-in));
  padding-left: 0.85em;
  padding-right: 1.05em;
  font-family: Georgia, 'Noto Serif', 'Droid Serif', 'Times New Roman', serif;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.np-d-notch .np-fx::before {
  /* A one-pixel ring in the shape of the plate: the outer outline, then the
     inner one, filled even-odd so only the line between them paints. */
  --i: 0.2em;
  --a: calc(var(--cut-in) - var(--i) * 0.414);
  --b: calc(var(--a) - 0.414px);
  content: '';
  position: absolute;
  inset: var(--i);
  background: color-mix(in srgb, var(--np-edge) 60%, transparent);
  clip-path: polygon(evenodd,
    var(--a) 0, calc(100% - var(--a)) 0, 100% var(--a), 100% calc(100% - var(--a)),
    calc(100% - var(--a)) 100%, var(--a) 100%, 0 calc(100% - var(--a)), 0 var(--a), var(--a) 0,
    calc(var(--b) + 1px) 1px, calc(100% - var(--b) - 1px) 1px, calc(100% - 1px) calc(var(--b) + 1px),
    calc(100% - 1px) calc(100% - var(--b) - 1px), calc(100% - var(--b) - 1px) calc(100% - 1px),
    calc(var(--b) + 1px) calc(100% - 1px), 1px calc(100% - var(--b) - 1px), 1px calc(var(--b) + 1px),
    calc(var(--b) + 1px) 1px);
}

/* Thornwire: wrought iron with teeth along the top and bottom. */
.np-d-thorns {
  --np-tex: var(--np-tex-cast);
  --np-tex-a: 0.7;
  padding-top: 0.32em;
  padding-bottom: 0.32em;
}
.np-d-thorns .np-fx::before,
.np-d-thorns .np-fx::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 0.3em;
  background:
    linear-gradient(135deg, var(--np-edge) 34%, transparent 34%) left top / 0.55em 100% repeat-x,
    linear-gradient(225deg, var(--np-edge) 34%, transparent 34%) left top / 0.55em 100% repeat-x;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.7));
}
.np-d-thorns .np-fx::before { top: 0; }
.np-d-thorns .np-fx::after { bottom: 0; transform: scaleY(-1); }

/* Stencil: a painted iron post. The body is the paint, the frame and the
   chips are the iron under it, and the name is sprayed on through a stencil,
   so it has a soft edge, no bevel, and a bridge across the middle. */
.np-d-stencil {
  --np-tex: var(--np-tex-cast);
  --np-tex-a: 0.7;
  --np-ink-fx: 0 0 0.07em color-mix(in srgb, var(--np-ink) 70%, transparent);
  --np-r: 2px;
  padding-left: 1.05em;
  padding-right: 1.25em;
  font-family: Impact, 'Arial Narrow', 'Roboto Condensed', sans-serif;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
/* The bridge is kept thin: at 8% of the line it took the middle out of B, E
   and R and long names were hard to read. */
.np-d-stencil .np-name {
  -webkit-mask: linear-gradient(180deg, #000 0 51.25%, transparent 51.25% 54.75%, #000 54.75%);
  mask: linear-gradient(180deg, #000 0 51.25%, transparent 51.25% 54.75%, #000 54.75%);
}
.np-d-stencil .np-fx {
  --chip: color-mix(in srgb, var(--np-edge), #000 15%);
  --band: linear-gradient(90deg,
    color-mix(in srgb, var(--np-edge), #000 40%) 0%,
    color-mix(in srgb, var(--np-edge), #fff 22%) 40%,
    var(--np-edge) 60%,
    color-mix(in srgb, var(--np-edge), #000 45%) 100%);
  /* Chips only along the edges, where a line or a boot would catch it. */
  background:
    radial-gradient(ellipse 0.22em 0.09em at 21% 4%, var(--chip) 0 50%, transparent 80%),
    radial-gradient(ellipse 0.1em 0.06em at 25% 7%, var(--chip) 0 50%, transparent 80%),
    radial-gradient(ellipse 0.3em 0.1em at 63% 97%, var(--chip) 0 50%, transparent 80%),
    radial-gradient(ellipse 0.16em 0.08em at 86% 4%, var(--chip) 0 50%, transparent 80%),
    var(--band) left / 0.42em 100% no-repeat,
    var(--band) right / 0.42em 100% no-repeat;
}
.np-d-stencil .np-fx::before {
  /* Rope wear: the paint rubbed thin just inside each band. */
  content: '';
  position: absolute;
  inset: 0 0.42em;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.28), transparent) left / 0.35em 100% no-repeat,
    linear-gradient(270deg, rgba(0, 0, 0, 0.28), transparent) right / 0.35em 100% no-repeat;
}

/* Patch: an embroidered cloth patch. A rolled edge of slanted stitches, a
   running stitch inside it, twill weave on the body, the name sewn in thread
   so it sits proud of the cloth. */
.np-d-patch {
  --np-bw: 0.17em;
  --np-r: 0.45em;
  --np-frame: repeating-linear-gradient(115deg,
    color-mix(in srgb, var(--np-edge), #fff 25%) 0 0.08em,
    color-mix(in srgb, var(--np-edge), #000 40%) 0.08em 0.2em);
  --np-tex: var(--np-tex-grain);
  --np-tex-a: 0.45;
  --np-ink-fx: 0 1px 0 rgba(0, 0, 0, 0.75), 0 -1px 0 rgba(255, 255, 255, 0.12);
  padding-left: 0.85em;
  padding-right: 1.05em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.np-d-patch::before {
  box-shadow: inset 0 0 0.25em rgba(0, 0, 0, 0.55);
}
.np-d-patch .np-fx {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.12) 0 1px, transparent 1px 3px);
}
.np-d-patch .np-fx::after {
  content: '';
  position: absolute;
  inset: 0.2em;
  border: 1px dashed color-mix(in srgb, var(--np-edge) 75%, transparent);
  border-radius: max(0px, calc(var(--np-r) - var(--np-bw) - 0.2em));
}

/* Credential: the staff pass. Engraved guilloche over the body the way a
   banknote is printed, a double rule round the edge, a struck seal with a
   star at the leading end, and the sheen turned to foil. Nothing sold uses
   any of it, so staff read as staff at a glance. */
.np-d-seal {
  --np-r: 2px;
  --np-tex-a: 0.2;
  --np-ink-fx: 0 0 0.4em color-mix(in srgb, var(--np-edge) 50%, transparent), 0 1px 0 #000;
  padding-left: 2em;
  padding-right: 1.15em;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.np-d-seal .np-fx {
  --gl: color-mix(in srgb, var(--np-edge) 13%, transparent);
  background:
    radial-gradient(circle closest-side,
      color-mix(in srgb, var(--np-edge), #000 72%) 0 56%,
      var(--np-edge) 60% 68%,
      color-mix(in srgb, var(--np-edge), #000 55%) 72% 78%,
      color-mix(in srgb, var(--np-edge), #fff 25%) 82% 92%,
      transparent 97%) left 0.3em center / 1.35em 1.35em no-repeat,
    repeating-radial-gradient(circle at 0% 50%, transparent 0 3px, var(--gl) 3px 4px),
    repeating-radial-gradient(circle at 100% 50%, transparent 0 3px, var(--gl) 3px 4px);
}
.np-d-seal .np-fx::before {
  content: '';
  position: absolute;
  left: 0.6em;
  top: 50%;
  width: 0.75em;
  height: 0.75em;
  transform: translateY(-52%);
  background: linear-gradient(160deg, color-mix(in srgb, var(--np-edge), #fff 45%) 0%, var(--np-edge) 45%, color-mix(in srgb, var(--np-edge), #000 35%) 100%);
  clip-path: polygon(50% 0, 61.8% 35.4%, 100% 35.4%, 69.1% 57.3%, 80.9% 92.7%, 50% 70.8%, 19.1% 92.7%, 30.9% 57.3%, 0 35.4%, 38.2% 35.4%);
}
.np-d-seal .np-fx::after {
  content: '';
  position: absolute;
  inset: 0.14em;
  border: 1px solid color-mix(in srgb, var(--np-edge) 55%, transparent);
  border-radius: 1px;
}
.np-d-seal .np-shine::after {
  width: 45%;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 120, 200, 0.2) 25%, rgba(120, 230, 255, 0.24) 50%, rgba(200, 255, 140, 0.2) 75%, transparent 100%);
  mix-blend-mode: color-dodge;
  animation-duration: 4s;
}

/* Viewfinder: a camera's screen in a light bezel. Letterbox bars top and
   bottom, a tick scale along the bottom one, faint scanlines, the name in the
   camera's on-screen type, and the record light blinking at the leading end
   in the second color (`--np-alt`). Combat Camera only. */
.np-d-viewfinder {
  --np-r: 3px;
  --np-tex-a: 0.15;
  --np-ink-fx: 0 0 0.25em rgba(255, 255, 255, 0.25), 0 1px 0 #000;
  padding-top: 0.42em;
  padding-bottom: 0.42em;
  padding-left: 1.45em;
  padding-right: 1.05em;
  font-family: ui-monospace, 'Cascadia Mono', 'Roboto Mono', 'Droid Sans Mono', Consolas, monospace;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.np-d-viewfinder .np-fx {
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.35) 0 1px, transparent 1px 0.5em) left 1.45em bottom 0.05em / calc(100% - 2.5em) 0.1em no-repeat,
    linear-gradient(#000, #000) top / 100% 0.24em no-repeat,
    linear-gradient(#000, #000) bottom / 100% 0.24em no-repeat,
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 3px);
}
.np-d-viewfinder .np-fx::before {
  content: '';
  position: absolute;
  left: 0.5em;
  top: 50%;
  width: 0.5em;
  height: 0.5em;
  transform: translateY(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, color-mix(in srgb, var(--np-alt), #fff 45%) 0 18%, var(--np-alt) 45%, color-mix(in srgb, var(--np-alt), #000 35%) 100%);
  box-shadow: 0 0 0.35em var(--np-alt);
  animation: np-rec 1.2s steps(1, end) infinite;
}

/* Blueprint: an engineer's drawing. White lines on blue drafting paper, a
   fine grid with a heavier line every fourth, a drawn border inset from the
   edge with dimension ticks along the top and bottom, a title block at the
   trailing end, and the name in drafting capitals. Sapper only. */
.np-d-blueprint {
  --np-frame: linear-gradient(color-mix(in srgb, var(--np-edge) 55%, #123566), color-mix(in srgb, var(--np-edge) 55%, #123566));
  --np-r: 1px;
  --np-tex-a: 0.35;
  --np-ink-fx: 0 0 0.2em rgba(200, 225, 255, 0.35);
  padding-left: 0.85em;
  padding-right: 1.85em;
  font-family: 'Arial Narrow', 'Roboto Condensed', 'Segoe UI', sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}
.np-d-blueprint .np-fx {
  --gl: color-mix(in srgb, var(--np-edge) 10%, transparent);
  --gl2: color-mix(in srgb, var(--np-edge) 22%, transparent);
  background:
    repeating-linear-gradient(90deg, var(--gl2) 0 1px, transparent 1px 1.6em),
    repeating-linear-gradient(0deg, var(--gl2) 0 1px, transparent 1px 1.6em),
    repeating-linear-gradient(90deg, var(--gl) 0 1px, transparent 1px 0.4em),
    repeating-linear-gradient(0deg, var(--gl) 0 1px, transparent 1px 0.4em);
}
.np-d-blueprint .np-fx::before {
  /* The drawn border, and its dimension ticks top and bottom. */
  content: '';
  position: absolute;
  inset: 0.18em;
  border: 1px solid color-mix(in srgb, var(--np-edge) 80%, transparent);
  background:
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--np-edge) 70%, transparent) 0 1px, transparent 1px 0.5em) left 0.3em top 0 / calc(100% - 0.6em) 0.18em no-repeat,
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--np-edge) 70%, transparent) 0 1px, transparent 1px 0.5em) left 0.3em bottom 0 / calc(100% - 0.6em) 0.18em no-repeat;
}
.np-d-blueprint .np-fx::after {
  /* The title block: a ruled box at the trailing end with a diagonal through it. */
  content: '';
  position: absolute;
  right: 0.18em;
  top: 0.18em;
  bottom: 0.18em;
  width: 1.2em;
  border-left: 1px solid color-mix(in srgb, var(--np-edge) 80%, transparent);
  background:
    linear-gradient(color-mix(in srgb, var(--np-edge) 80%, transparent), color-mix(in srgb, var(--np-edge) 80%, transparent)) center / 100% 1px no-repeat,
    linear-gradient(to top right, transparent calc(50% - 0.5px), color-mix(in srgb, var(--np-edge) 55%, transparent) 50%, transparent calc(50% + 0.5px)) bottom / 100% 50% no-repeat;
}

@keyframes np-rec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.15; }
}

/* ── badges ── */

.np-badge {
  flex: none;
  display: inline-block;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
}

.np-badge-sm { width: 1.35em; height: 1.35em; }
.np-badge-md { width: 1.6em; height: 1.6em; }
.np-badge-lg { width: 1.9em; height: 1.9em; }

.np-badge-locked {
  filter: grayscale(1) brightness(0.45);
  opacity: 0.55;
}

/* Service: a stripe of chevrons on an enamel shield, the years struck into a
   plate under them, all in the tier's metal. The shapes are SVGs drawn in
   grays and hard-light blended over the metal, so mid gray comes out as the
   metal, white as its highlight and near black as its shadow, and one drawing
   serves every tier. One chevron for the month, two for the first two years,
   three after that. */
.np-service {
  --sv: #c0814a;
  --sv-chev1: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-2 -2 104 44'><g id='c'><path fill='%23a4a4a4' d='M0 0L50 26V40L0 14Z'/><path fill='%236a6a6a' d='M50 26L100 0V14L50 40Z'/><path fill='none' stroke='%23f4f4f4' stroke-width='3' d='M0 1.5L50 27.5L100 1.5'/><path fill='none' stroke='%232e2e2e' stroke-width='2.5' d='M0 12.75L50 38.75L100 12.75'/><path fill='none' stroke='%23111' stroke-width='2' d='M0 0L50 26L100 0V14L50 40L0 14Z'/></g></svg>");
  --sv-chev2: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-2 -2 104 64'><g id='c'><path fill='%23a4a4a4' d='M0 0L50 26V40L0 14Z'/><path fill='%236a6a6a' d='M50 26L100 0V14L50 40Z'/><path fill='none' stroke='%23f4f4f4' stroke-width='3' d='M0 1.5L50 27.5L100 1.5'/><path fill='none' stroke='%232e2e2e' stroke-width='2.5' d='M0 12.75L50 38.75L100 12.75'/><path fill='none' stroke='%23111' stroke-width='2' d='M0 0L50 26L100 0V14L50 40L0 14Z'/></g><use href='%23c' y='20'/></svg>");
  --sv-chev3: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-2 -2 104 84'><g id='c'><path fill='%23a4a4a4' d='M0 0L50 26V40L0 14Z'/><path fill='%236a6a6a' d='M50 26L100 0V14L50 40Z'/><path fill='none' stroke='%23f4f4f4' stroke-width='3' d='M0 1.5L50 27.5L100 1.5'/><path fill='none' stroke='%232e2e2e' stroke-width='2.5' d='M0 12.75L50 38.75L100 12.75'/><path fill='none' stroke='%23111' stroke-width='2' d='M0 0L50 26L100 0V14L50 40L0 14Z'/></g><use href='%23c' y='20'/><use href='%23c' y='40'/></svg>");
  --sv-chev: var(--sv-chev3);
  --sv-rim: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 110'><linearGradient id='g' x1='0' y1='0' x2='1' y2='1'><stop offset='0' stop-color='%23ececec'/><stop offset='.45' stop-color='%23808080'/><stop offset='1' stop-color='%23343434'/></linearGradient><path fill='url(%23g)' stroke='%23111' stroke-width='2' d='M50 2L97 12V62Q97 86 50 108Q3 86 3 62V12Z'/></svg>");
  position: relative;
  isolation: isolate;
  container-type: size;
}

.np-service-t1 { --sv-chev: var(--sv-chev1); }
.np-service-t2 { --sv: #b9c2cc; --sv-chev: var(--sv-chev2); }
.np-service-t3 { --sv: #e9b949; }
.np-service-t4 { --sv: #f1efe6; }
.np-service-t5 { --sv: #8fdcf4; }

/* The shield: a rim in the metal around a dark enamel field. */
.np-service::before {
  content: '';
  position: absolute;
  left: 8%;
  top: 1%;
  width: 84%;
  height: 92.4%;
  z-index: 0;
  background:
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 110'><radialGradient id='e' cx='.4' cy='.25' r='.85'><stop offset='0' stop-color='%2326313f'/><stop offset='1' stop-color='%23080b10'/></radialGradient><path fill='url(%23e)' stroke='%23000' stroke-opacity='.75' stroke-width='1.5' d='M50 10L89 18.5V61Q89 80 50 99Q11 80 11 61V18.5Z'/></svg>") center / 100% 100% no-repeat,
    var(--sv-rim) center / 100% 100% no-repeat,
    linear-gradient(var(--sv), var(--sv));
  background-blend-mode: normal, hard-light, normal;
  -webkit-mask: var(--sv-rim) center / 100% 100% no-repeat;
  mask: var(--sv-rim) center / 100% 100% no-repeat;
}

/* The chevrons' shadow on the enamel. */
.np-service::after {
  content: '';
  position: absolute;
  left: 22%;
  top: 15%;
  width: 56%;
  height: 42%;
  z-index: 1;
  background: rgba(0, 0, 0, 0.6);
  -webkit-mask: var(--sv-chev) center / contain no-repeat;
  mask: var(--sv-chev) center / contain no-repeat;
}

.np-chev {
  position: absolute;
  left: 22%;
  top: 13%;
  width: 56%;
  height: 42%;
  z-index: 2;
  background:
    var(--sv-chev) center / contain no-repeat,
    linear-gradient(180deg, color-mix(in srgb, var(--sv), #fff 18%), var(--sv) 55%, color-mix(in srgb, var(--sv), #000 18%));
  background-blend-mode: hard-light, normal;
  -webkit-mask: var(--sv-chev) center / contain no-repeat;
  mask: var(--sv-chev) center / contain no-repeat;
}

/* The years, struck into a dark plate edged in the metal. Sized off the badge
   (cqw), so the number keeps its share of the badge however big it is drawn;
   the em size is for a browser without container units. */
.np-service b {
  position: absolute;
  left: 50%;
  top: 57%;
  z-index: 3;
  transform: translateX(-50%);
  padding: 0.08em 0.26em 0.05em;
  border-radius: 0.14em;
  font-size: 0.62em;
  font-size: 30cqw;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: color-mix(in srgb, var(--sv), #fff 30%);
  background: linear-gradient(180deg, #05080c, #1b2430);
  box-shadow:
    0 0 0 max(1px, 0.07em) color-mix(in srgb, var(--sv), #000 20%),
    0 0.08em 0.14em rgba(0, 0, 0, 0.8);
  text-shadow: 0 -0.05em 0 #000, 0 0.05em 0 rgba(255, 255, 255, 0.2);
}

@media (prefers-reduced-motion: reduce) {
  .np-shine::after {
    animation: none;
    opacity: 0;
  }
  .np-d-viewfinder .np-fx::before {
    animation: none;
  }
}
