/* Werksausweis: the badge of the KI-Serviceingenieur on a lanyard. Owned by js/site-badge.js.
   The strap, crimp and ring are drawn on a canvas (verlet rope); the card is DOM: a pendulum hanging from the ring,
   turned with rotateY. All sizes inside the card are in em: 1em = card width / 25 (10 px at 250 px).
   Tokens come from [data-look] on body (werklicht.css). Yellow only in his photo field and the AEDIL mark. */

/* fallback size for the slot; site.css sets the real one */
:where(.badge-slot){ position:relative; height:600px }
@media (max-width:900px){ :where(.badge-slot){ height:460px } }
/* the rope canvas and a swinging card may reach past the column: never let that become horizontal page scroll
   (clip, unlike hidden, keeps the sticky column working) */
.s-einstellen{ overflow-x:clip }

.bdg{ position:absolute; inset:0; user-select:none; -webkit-user-select:none; font-family:var(--f-sans); color:var(--ink);
  /* strap and metal, read by the canvas */
  --strap:#2B2E35; --strap-2:#23262C; --strap-weave:rgba(255,255,255,.075); --strap-weave-2:rgba(0,0,0,.22);
  --strap-edge:rgba(0,0,0,.42); --strap-stitch:rgba(255,255,255,.26); --rope-shadow:rgba(var(--sh),.20);
  --metal-1:#FAFBFC; --metal-2:#C9CED5; --metal-3:#8E949C; --metal-4:#E6E9EC; --metal-edge:rgba(13,15,18,.28);
  /* card material: porcelain */
  --b-card:linear-gradient(180deg, #FFFFFF 0%, #FBFBFB 46%, #F3F4F5 100%);
  --b-rim:linear-gradient(180deg, rgba(255,255,255,1), rgba(13,15,18,.10) 60%, rgba(13,15,18,.14));
  --b-shadow:0 1px 1px rgba(var(--sh),.06), 0 3px 8px -3px rgba(var(--sh),.14), 0 34px 60px -26px rgba(var(--sh),.42);
  --b-sheen:rgba(255,255,255,.28); --b-turn:rgba(var(--sh),.28);
  --b-ink:var(--ink); --b-ink2:var(--ink2); --b-muted:var(--muted); --b-line:var(--line); --b-line2:var(--line2); --b-chip:var(--surface2) }
[data-look="nebel"] .bdg{ --strap:#27303C; --strap-2:#202832;
  --b-card:linear-gradient(180deg, #FBFCFD 0%, #F5F7F9 50%, #ECF0F3 100%) }
[data-look="perlmutt"] .bdg{ --strap:#2C2D33; --strap-2:#24252B;
  --b-card:linear-gradient(165deg, #FFFFFF 0%, #FBFBFC 48%, #F3F3F6 100%);
  --b-rim:linear-gradient(160deg, rgba(255,255,255,1), rgba(180,196,230,.42) 55%, rgba(255,214,192,.45)) }
[data-look="nacht"] .bdg{
  --strap:#3A414D; --strap-2:#2E343E; --strap-weave:rgba(255,255,255,.07); --strap-weave-2:rgba(0,0,0,.30);
  --strap-edge:rgba(0,0,0,.55); --strap-stitch:rgba(255,255,255,.22); --rope-shadow:rgba(0,0,0,.55);
  --metal-1:#E4E8EE; --metal-2:#9AA1AC; --metal-3:#5D646F; --metal-4:#BFC5CE; --metal-edge:rgba(0,0,0,.5);
  /* anodised dark card */
  --b-card:linear-gradient(180deg, #1D2028 0%, #16191F 50%, #111318 100%);
  --b-rim:linear-gradient(180deg, rgba(255,255,255,.20), rgba(255,255,255,.05) 50%, rgba(255,255,255,.08));
  --b-shadow:0 1px 0 rgba(255,255,255,.04) inset, 0 3px 8px -3px rgba(0,0,0,.6), 0 36px 64px -24px rgba(0,0,0,.85);
  --b-sheen:rgba(255,255,255,.07); --b-turn:rgba(0,0,0,.45);
  --b-line:rgba(255,255,255,.08); --b-line2:rgba(255,255,255,.15); --b-chip:rgba(255,255,255,.07) }

/* the rope canvas reaches past the slot to the sides and below, and fades in from the top edge */
.bdg-rope{ position:absolute; left:-80px; top:0; width:calc(100% + 160px); height:calc(100% + 80px); display:block; pointer-events:none;
  -webkit-mask-image:linear-gradient(180deg, transparent 0, #000 44px); mask-image:linear-gradient(180deg, transparent 0, #000 44px) }

/* the card: wrapper is the pendulum (pivot = the ring), inner turns in 3D */
.bdg-card{ --cw:250px; --ch:370px; --gap:15px; position:absolute; left:0; top:0; width:var(--cw); height:calc(var(--gap) + var(--ch));
  transform-origin:50% 0; will-change:transform; cursor:grab; touch-action:pan-y; outline:none; -webkit-tap-highlight-color:transparent;
  font-size:calc(var(--cw) / 25) }
.bdg-card.is-drag{ cursor:grabbing }
.bdg-inner{ position:absolute; left:0; right:0; top:var(--gap); height:var(--ch); transform-style:preserve-3d; will-change:transform }
.bdg-face{ position:absolute; inset:0; display:flex; flex-direction:column; padding:1.8em 1.8em 1.7em; overflow:hidden;
  border-radius:1.8em; background:var(--b-card); box-shadow:var(--b-shadow); color:var(--b-ink);
  backface-visibility:hidden; -webkit-backface-visibility:hidden; -webkit-font-smoothing:antialiased }
/* 1 px light rim */
.bdg-face::before{ content:""; position:absolute; inset:0; border-radius:inherit; padding:1px; background:var(--b-rim); pointer-events:none; z-index:3;
  -webkit-mask:linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite:xor; mask-composite:exclude }
/* material: a soft sheen that travels with swing and turn, and a little shade while edge-on */
.bdg-face::after{ content:""; position:absolute; inset:0; pointer-events:none; z-index:2;
  background:linear-gradient(112deg, transparent 36%, var(--b-sheen) 50%, transparent 64%) var(--sheen, 50%) 0 / 280% 100% no-repeat }
.bdg-shade{ position:absolute; inset:0; border-radius:inherit; background:var(--b-turn); opacity:var(--turn, 0); pointer-events:none; z-index:2 }
.bdg-back{ transform:rotateY(180deg) }

/* the metal clip clamps the top edge; the ring runs through its eyelet (a real hole, so the ring on the canvas shows) */
.bdg-clip{ position:absolute; z-index:4; left:50%; top:calc(var(--gap) - 1.25em); width:1.9em; height:2.85em; transform:translateX(-50%);
  border-radius:.62em .62em .4em .4em;
  background:linear-gradient(90deg, var(--metal-4), var(--metal-1) 24%, var(--metal-2) 60%, var(--metal-3) 84%, var(--metal-4));
  -webkit-mask:radial-gradient(circle at 50% .42em, transparent .2em, #000 .25em); mask:radial-gradient(circle at 50% .42em, transparent .2em, #000 .25em);
  filter:drop-shadow(0 1px 1px rgba(var(--sh),.35)) drop-shadow(0 3px 4px rgba(var(--sh),.18)) }
/* seam where it bites the card edge, and the snap rivet */
.bdg-clip::before{ content:""; position:absolute; left:0; right:0; top:1.25em; height:1px; background:rgba(0,0,0,.30); box-shadow:0 1px 0 rgba(255,255,255,.5) }
.bdg-clip::after{ content:""; position:absolute; left:50%; top:1.72em; width:.62em; height:.62em; margin-left:-.31em; border-radius:50%;
  background:radial-gradient(circle at 38% 34%, var(--metal-1), var(--metal-2) 55%, var(--metal-3)); box-shadow:0 0 0 .5px var(--metal-edge) }
/* keyboard focus: a ring around the card that swings with it */
.bdg-focus{ position:absolute; left:-6px; right:-6px; top:calc(var(--gap) - 6px); height:calc(var(--ch) + 12px); border-radius:calc(1.8em + 6px);
  box-shadow:0 0 0 2px var(--ink); opacity:0; pointer-events:none }
.bdg-card:focus-visible .bdg-focus{ opacity:calc(1 - var(--turn, 0) * 1.6) }

/* ---------- front ---------- */
.bf-top{ display:flex; align-items:center; justify-content:space-between; height:2.1em; flex:none }
.bf-logo{ height:1.42em; width:auto; display:block; color:var(--b-ink); --mark:var(--him) }
.bdg .b-chip{ display:inline-flex; align-items:center; height:2.25em; padding:0 .9em; border-radius:999px; background:var(--b-chip); color:var(--b-ink2);
  font:500 .92em/1 var(--f-mono); letter-spacing:.05em; text-transform:uppercase; white-space:nowrap }
/* his photo field: yellow, the drawing grid, crop marks, the AEDIL mark. No face. */
.bf-photo{ position:relative; flex:none; height:13.4em; margin-top:1.5em; border-radius:1em; overflow:hidden; color:var(--on-him);
  background:
    linear-gradient(rgba(20,20,20,.075) 1px, transparent 1px) -1px -1px / 4em 4em,
    linear-gradient(90deg, rgba(20,20,20,.075) 1px, transparent 1px) -1px -1px / 4em 4em,
    radial-gradient(circle at .5px .5px, rgba(20,20,20,.20) .6px, transparent 1px) 0 0 / 1em 1em,
    linear-gradient(158deg, #F6C21F 0%, var(--him) 48%, #ECB103 100%);
  box-shadow:inset 0 0 0 1px rgba(0,0,0,.06), inset 0 1px 0 rgba(255,255,255,.35) }
.bf-photo .crop{ position:absolute; inset:.9em; pointer-events:none; --cm:rgba(20,20,20,.55);
  background:
    linear-gradient(var(--cm), var(--cm)) 0 0 / 1em 1px no-repeat, linear-gradient(var(--cm), var(--cm)) 0 0 / 1px 1em no-repeat,
    linear-gradient(var(--cm), var(--cm)) 100% 0 / 1em 1px no-repeat, linear-gradient(var(--cm), var(--cm)) 100% 0 / 1px 1em no-repeat,
    linear-gradient(var(--cm), var(--cm)) 0 100% / 1em 1px no-repeat, linear-gradient(var(--cm), var(--cm)) 0 100% / 1px 1em no-repeat,
    linear-gradient(var(--cm), var(--cm)) 100% 100% / 1em 1px no-repeat, linear-gradient(var(--cm), var(--cm)) 100% 100% / 1px 1em no-repeat }
.bf-photo .mk{ position:absolute; left:50%; top:50%; width:6.4em; height:auto; transform:translate(-50%, -50%); color:var(--on-him); display:block }
.bf-name{ margin:1.5em 0 0; font:600 1.92em/1.08 var(--f-sans); letter-spacing:-.03em; color:var(--b-ink); white-space:nowrap }
.bf-dept{ margin:.55em 0 0; font:400 1.22em/1.3 var(--f-sans); letter-spacing:-.005em; color:var(--b-ink2) }
.b-rows{ margin:auto 0 0; padding:0; display:grid }
.b-rows > div{ display:flex; align-items:center; justify-content:space-between; gap:1em; height:2.35em; border-top:1px solid var(--b-line) }
.b-rows dt{ font:500 .84em/1 var(--f-mono); letter-spacing:.07em; text-transform:uppercase; color:var(--b-muted) }
.b-rows dd{ margin:0; font:500 1em/1 var(--f-mono); letter-spacing:.01em; color:var(--b-ink); white-space:nowrap; display:flex; align-items:center }

/* the validity value: a dash until issued, then "heute" lands like a stamp */
.b-val .v1{ display:none }
.bdg.is-issued .b-val .v0{ display:none }
.bdg.is-issued .b-val .v1{ display:inline-flex; align-items:center; gap:.45em; transform-origin:60% 50% }
.bdg .v0{ color:var(--b-muted); letter-spacing:.12em }
.bf-valid .v1{ padding:.32em .55em .3em; margin-right:-.55em; border-radius:.35em; box-shadow:inset 0 0 0 1px var(--b-ink); text-transform:uppercase; letter-spacing:.08em; font-size:.92em }
.bdg .ck{ display:inline-block; width:.95em; height:.95em; border-radius:.18em; background:var(--b-ink); position:relative; flex:none }
.bdg .ck::after{ content:""; position:absolute; left:.31em; top:.13em; width:.24em; height:.48em; border:solid var(--bg); border-width:0 1.5px 1.5px 0; transform:rotate(45deg) }
.bdg.is-stamp .b-val .v1{ animation:bdg-stamp 560ms cubic-bezier(.2,0,0,1) both }
@keyframes bdg-stamp{ 0%{ opacity:0; transform:scale(1.7) rotate(-7deg) } 45%{ opacity:1; transform:scale(.94) rotate(1deg) } 72%{ transform:scale(1.02) rotate(0) } 100%{ opacity:1; transform:none } }

/* ---------- back ---------- */
.bb-top{ display:flex; align-items:center; justify-content:space-between; height:2.1em; flex:none }
.bb-mark{ width:2.5em; height:auto; display:block; color:var(--him) }
.bb-main{ margin:2.2em 0 0; display:grid; gap:1.3em }
.bb-main > div{ display:grid; gap:.6em }
.bb-main dt{ font:500 .84em/1 var(--f-mono); letter-spacing:.07em; text-transform:uppercase; color:var(--b-muted) }
.bb-main dd{ margin:0; font:600 1.85em/1.05 var(--f-sans); letter-spacing:-.025em; color:var(--b-ink); display:flex }
.bb-main .v0{ font-weight:400; color:var(--b-muted) }
.bb-own{ margin:auto 0 0; padding-top:1.3em; border-top:1px solid var(--b-line); font:600 3.5em/.98 var(--f-sans); letter-spacing:-.045em; color:var(--b-ink); text-wrap:balance }
.bb-steps{ margin-top:1.9em; display:grid; gap:.85em }
.bb-steps .lbl{ display:flex; justify-content:space-between; font:500 .84em/1 var(--f-mono); letter-spacing:.07em; text-transform:uppercase; color:var(--b-muted) }
.bb-steps .lbl b{ font-weight:500; color:var(--b-ink) }
.bb-steps ol{ list-style:none; margin:0; padding:0; display:grid; grid-template-columns:repeat(5, 1fr); gap:.5em }
.bb-steps li{ display:flex; align-items:center; gap:.45em; font:500 .9em/1 var(--f-mono); color:var(--b-muted); letter-spacing:.02em }
.bb-steps li i{ width:1.15em; height:1.15em; border-radius:.22em; box-shadow:inset 0 0 0 1px var(--b-line2); position:relative; flex:none; transition:background-color var(--t-2) var(--ease), box-shadow var(--t-2) var(--ease) }
.bb-steps li i::after{ content:""; position:absolute; left:.38em; top:.16em; width:.28em; height:.56em; border:solid var(--bg); border-width:0 1.5px 1.5px 0; transform:rotate(45deg) scale(.4); opacity:0;
  transition:opacity var(--t-2) var(--ease), transform var(--t-2) var(--ease) }
.bb-steps li.on{ color:var(--b-ink) }
.bb-steps li.on i{ background:var(--b-ink); box-shadow:none }
.bb-steps li.on i::after{ opacity:1; transform:rotate(45deg) scale(1) }

/* the hint under the card, gone after the first touch */
.bdg-hint{ position:absolute; left:0; right:0; bottom:6px; margin:0; text-align:center; font:500 11px/1.3 var(--f-mono); letter-spacing:.06em; text-transform:uppercase;
  color:var(--muted); transition:opacity var(--t-3) var(--ease); pointer-events:none }
.bdg.is-touched .bdg-hint{ opacity:0 }

@media (prefers-reduced-motion: reduce){
  .bdg.is-stamp .b-val .v1{ animation:none }
  .bdg-focus,.bdg-hint,.bb-steps li i,.bb-steps li i::after{ transition:none }
}
