/* ============================================================
   LANYARD RIG
   ------------------------------------------------------------
   The parts js/lanyard-rig.js draws into a [data-rig] stage:
   the shadows on the wall, the webbing (one svg for the whole
   stage), and the cards. Nothing frames them - the stage paints
   nothing of its own - so each pass reads as an object in front
   of the page, with the page as its wall.

   Layers, bottom up, inside the stage's own stacking context:

     1  .rg-shades    the cards' shadows on the wall
     2  (layout)      things behind the webbing: a hook's plate
     3  .rg-ribbons   the webbing, its shade, the cord
     4  (layout)      things in front of it: a hook's knob, a full stop
     5  .rg-cards     the cards and their clasps

   Sizes come from the script: --bw is the card's width, --s the
   scale of everything else (1 at a 270px card).
   ============================================================ */

[data-rig] {
  position: relative;
  isolation: isolate;
}

.rg-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Not drawn until the script has hung everything at rest. */
[data-rig]:not(.is-rigged) .rg-layer { visibility: hidden; }

.rg-shades,
.rg-cards {
  position: absolute;
  inset: 0;
}

.rg-shades { z-index: 1; }
.rg-cards { z-index: 5; }

.rg-ribbons {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  z-index: 3;
  pointer-events: none;
}

/* ---------- the webbing ---------- */

.rg-band { fill: #14140f; }

/* the weave catches a little light down its middle */
.rg-sheen {
  fill: none;
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: calc(9px * var(--s, 1));
  stroke-linejoin: round;
}

.rg-print {
  fill: #d9ff3d;
  font-family: "sohne-medium", "Inter Tight", sans-serif;
  font-size: calc(9.5px * var(--s, 1));
  letter-spacing: 0.2em;
  text-transform: uppercase;
  dominant-baseline: central;
}


.rg-stitch {
  fill: none;
  stroke: #56564c;
  stroke-width: calc(0.8px * var(--s, 1));
  stroke-dasharray: 2.2 1.6;
}


/* the webbing's shade on the wall, nudged down and right by the script */
/* feathered by a faint stroke wider than the band, rather than a blur */
.rg-band-shade {
  fill: rgba(27, 26, 18, 0.11);
  stroke: rgba(27, 26, 18, 0.05);
  stroke-width: calc(7px * var(--s, 1));
  stroke-linejoin: round;
}

.rg-twist { pointer-events: none; }

/* where the band folds over a bar or the cord */
.rg-cap { fill: #24241e; }

/* the sewn tab the two strands end in */
.rg-tab { fill: #1d1d18; }

.rg-tab-stitch {
  fill: none;
  stroke: #6c6c60;
  stroke-width: calc(0.8px * var(--s, 1));
  stroke-dasharray: 1.8 1.3;
}

/* ---------- the cord ---------- */

.rg-cord {
  fill: none;
  stroke: #14140f;
  stroke-width: 3px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rg-cord-gloss {
  fill: none;
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 1px;
  transform: translateY(-0.7px);
}

.rg-cord-shade {
  fill: none;
  stroke: rgba(20, 20, 15, 0.12);
  stroke-width: 4px;
  transform: translate(4px, 10px);
}

/* ---------- the shadows on the wall ---------- */

/* Three layers: a tight contact line, the key shade, and a wide soft
   fall-off. Each is an image the script paints once (already blurred,
   in the ink warmed a touch, as shade on off-white paper is) and then
   only moves and fades - no filter is redone frame to frame. */
.rg-shade {
  position: absolute;
  left: 0;
  top: 0;
  background: no-repeat 0 0 / 100% 100%;
  transform-origin: 50% 50%;
  pointer-events: none;
  will-change: transform, opacity;
}

/* ---------- the card ---------- */

.rg-card {
  --cut: calc(14px * var(--s, 1));
  --thick: calc(3.2px * var(--s, 1));
  position: absolute;
  left: 0;
  top: 0;
  width: var(--bw, 240px);
  height: calc(var(--bw, 240px) * 1.48);
  transform-origin: 50% 50%;
  pointer-events: auto;
  cursor: grab;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}

.rg-card.is-held { cursor: grabbing; }

.rg-card:focus-visible .rg-face { outline: 2px solid #5c7e12; outline-offset: 4px; }

.rg-flip {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

/* Two printed faces, a card's thickness apart, and the white core showing
   along its two long edges when it turns. */
.rg-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--bw) * 0.13) calc(var(--bw) * 0.074) 0;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  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));
}

.rg-front {
  background: #d9ff3d;
  color: #14140f;
  transform: translateZ(calc(var(--thick) / 2));
}

.rg-back {
  background: #14140f;
  color: #f4f4f2;
  padding-top: calc(var(--bw) * 0.126);
  transform: rotateY(180deg) translateZ(calc(var(--thick) / 2));
}

.rg-edge {
  position: absolute;
  top: var(--cut);
  bottom: var(--cut);
  width: var(--thick);
  background: linear-gradient(90deg, #cfcfc7, #f3f3ee 50%, #c6c6be);
}

.rg-edge--l { left: calc(var(--thick) / -2); transform: rotateY(90deg); }
.rg-edge--r { right: calc(var(--thick) / -2); transform: rotateY(90deg); }

/* The ink pass: the same card, its colours swapped. */
.rg-ink .rg-front { background: #14140f; color: #f4f4f2; }
.rg-ink .rg-front .rg-row { color: #8a8a82; }
.rg-ink .rg-front .rg-band-row { background: #d9ff3d; color: #14140f; }
.rg-ink .rg-front .rg-facts { border-top-color: rgba(244, 244, 242, 0.18); }
.rg-ink .rg-front .rg-facts dt { color: #8a8a82; }
.rg-ink .rg-edge { background: linear-gradient(90deg, #c4c4bc, #ecece6 50%, #bcbcb4); }

/* printed laminate: a soft top-down sheen and a hairline lit edge */
.rg-gloss {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 38%, rgba(0, 0, 0, 0) 72%, rgba(0, 0, 0, 0.06) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.rg-back .rg-gloss,
.rg-ink .rg-front .rg-gloss {
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 40%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

/* The light's streak across the laminate, slid by the script as the card
   turns. Its own layer, so moving it never repaints the face. */
.rg-shine {
  position: absolute;
  inset: -40%;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 42%, rgba(255, 255, 255, 0.32) 50%, transparent 58%);
  mix-blend-mode: soft-light;
  transform: translateX(-55%);
  will-change: transform;
}

/* The punched slot the clasp's hook goes through. */
.rg-slot {
  position: absolute;
  top: calc(7px * var(--s, 1));
  left: 50%;
  width: calc(44px * var(--s, 1));
  height: calc(9px * var(--s, 1));
  transform: translateX(-50%);
  border-radius: 9px;
  background: #e4e4de;
  box-shadow: inset 0 2px 3px rgba(20, 20, 15, 0.5), 0 1px 0 rgba(255, 255, 255, 0.4);
  z-index: 1;
}

.rg-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  font-family: "sohne-medium", "Inter Tight", sans-serif;
  font-size: calc(var(--bw) * 0.037);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #5c7e12;
}

.rg-back .rg-row { color: #8a8a82; }

.rg-photo {
  --pn: calc(var(--bw) * 0.035);
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 0.78;
  margin-top: calc(var(--bw) * 0.04);
  background: #14140f;
  clip-path: polygon(var(--pn) 0, calc(100% - var(--pn)) 0, 100% var(--pn),
    100% calc(100% - var(--pn)), calc(100% - var(--pn)) 100%,
    var(--pn) 100%, 0 calc(100% - var(--pn)), 0 var(--pn));
}

.rg-photo > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 28%;
  filter: grayscale(1) contrast(1.12) brightness(1.04);
  pointer-events: none;
}

.rg-who { width: 100%; margin: calc(var(--bw) * 0.05) 0 0; }

.rg-name {
  margin: 0;
  font-family: "sohne-bold", "Inter Tight", sans-serif;
  font-weight: normal;
  font-size: calc(var(--bw) * 0.15);
  line-height: 0.95;
  letter-spacing: -0.02em;
}

.rg-role {
  margin: calc(var(--bw) * 0.012) 0 0;
  font-family: "Inter Tight", sans-serif;
  font-size: calc(var(--bw) * 0.05);
  font-weight: 500;
}

.rg-facts {
  width: 100%;
  margin: auto 0 calc(var(--bw) * 0.045);
  display: grid;
  grid-template-columns: 1fr 1.25fr 0.8fr;
  gap: calc(var(--bw) * 0.03);
  border-top: 1px solid rgba(20, 20, 15, 0.22);
  padding-top: calc(var(--bw) * 0.03);
}

.rg-facts > div { min-width: 0; }

.rg-facts dt {
  font-family: "sohne-medium", "Inter Tight", sans-serif;
  font-size: calc(var(--bw) * 0.028);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5c7e12;
}

.rg-facts dd {
  margin: calc(var(--bw) * 0.008) 0 0;
  font-family: "sohne-medium", "Inter Tight", sans-serif;
  font-size: calc(var(--bw) * 0.04);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rg-band-row {
  width: calc(100% + var(--bw) * 0.148);
  margin: 0 calc(var(--bw) * -0.074);
  padding: calc(var(--bw) * 0.044) calc(var(--bw) * 0.074) calc(var(--bw) * 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: calc(var(--bw) * 0.06);
  background: #14140f;
  color: #d9ff3d;
  font-family: "sohne-medium", "Inter Tight", sans-serif;
  font-size: calc(var(--bw) * 0.041);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rg-barcode {
  flex: 1;
  height: calc(var(--bw) * 0.07);
  fill: currentColor;
}

.rg-qr {
  width: 76%;
  height: auto;
  margin-top: 16%;
  pointer-events: none;
}

.rg-url {
  margin: auto 0 calc(var(--bw) * 0.08);
  font-family: "sohne-medium", "Inter Tight", sans-serif;
  font-size: calc(var(--bw) * 0.063);
  color: #a3a39a;
}

/* ---------- the clasp ---------- */

.rg-clasp {
  position: absolute;
  left: 50%;
  top: calc(-66px * var(--s, 1));
  width: calc(40px * var(--s, 1));
  height: calc(80px * var(--s, 1));
  transform: translateX(-50%);
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(1.5px 3px 1.5px rgba(20, 20, 15, 0.3));
}
