/* Small Fallout touches (assets/js/fallout-touches.js): power armor on a theme switch, a bottle cap when code is
 * copied, VATS brackets on a heading reached from the table of contents. Plus the back-to-top button, restyled as a
 * Vault-Tec elevator button (CSS only). */

/* ---- theme switch: power armor helmet ---- */
.pa-suit {
  position:fixed; inset:0; z-index:1060; display:grid; place-items:center; pointer-events:none;
}
.pa-helmet {
  position:relative; width:min(200px, 46vw); aspect-ratio:1;
  animation:pa-in 1.4s cubic-bezier(.3,1.4,.5,1) both;
}
.pa-helmet img { display:block; width:100%; height:100%; }
/* The glow sits on a wrapper: a filter on the masked element itself would be masked away. */
.pa-glow {
  position:absolute; inset:0;
  filter:drop-shadow(0 0 6px var(--pa-visor)) drop-shadow(0 0 16px var(--pa-visor));
  animation:pa-visor 1.4s linear both;
}
.pa-visor {
  position:absolute; inset:0; background:var(--pa-visor);
  -webkit-mask-size:100% 100%; mask-size:100% 100%; -webkit-mask-repeat:no-repeat; mask-repeat:no-repeat;
}
/* Steam from the filter canisters on both sides of the chin. */
.pa-steam { position:absolute; top:72%; width:0; height:0; }
.pa-steam-l { left:17%; }
.pa-steam-r { left:83%; }
.pa-steam i {
  position:absolute; left:-14px; top:-14px; width:28px; height:28px; border-radius:50%;
  background:radial-gradient(circle, #fffffff2 0 40%, #ffffff00 72%); opacity:0;
  animation:pa-steam .8s ease-out .3s both;
}
:root[data-bs-theme='light'] .pa-steam i { background:radial-gradient(circle, #9fb0b9e6 0 40%, #9fb0b900 72%); } /* white steam vanishes on cream */
.pa-steam i:nth-child(2) { animation-delay:.38s; }
.pa-steam i:nth-child(3) { animation-delay:.46s; }
.pa-steam-l i { --pa-dx:-34px; }
.pa-steam-r i { --pa-dx:34px; }
.pa-steam i:nth-child(2) { --pa-dy:-18px; }
.pa-steam i:nth-child(3) { --pa-dy:12px; }

@keyframes pa-in {
  0% { opacity:0; transform:translateY(-46px) scale(.82); }
  20% { opacity:1; transform:translateY(0) scale(1); }        /* clunk */
  24% { transform:translateY(3px) scale(1.01); }
  28% { transform:translate(-2px,0) rotate(-1deg); }
  32% { transform:translate(2px,0) rotate(.8deg); }
  36%, 76% { transform:none; opacity:1; }
  100% { opacity:0; transform:scale(.94); }
}
@keyframes pa-visor {                                          /* boots up with a flicker */
  0%, 26% { opacity:0; }
  30% { opacity:1; }
  33% { opacity:.25; }
  37%, 76% { opacity:1; }
  100% { opacity:0; }
}
@keyframes pa-steam {
  0% { opacity:0; transform:translate(0,0) scale(.3); }
  25% { opacity:.85; }
  100% { opacity:0; transform:translate(var(--pa-dx), calc(-26px + var(--pa-dy, 0px))) scale(1.7); }
}

/* ---- copying code: a bottle cap flips up ---- */
.cap-fx { position:absolute; z-index:1060; width:0; height:0; pointer-events:none; }
.cap-coin {
  position:absolute; left:-13px; top:-13px; width:26px; height:26px;
  animation:cap-flip .9s cubic-bezier(.2,.7,.3,1) both;
}
.cap-coin svg { display:block; width:100%; height:100%; }
.cap-text {
  position:absolute; right:22px; top:-34px; white-space:nowrap;
  color:var(--lab-accent, var(--link-color)); font:700 11px/1 ui-monospace,Consolas,monospace; letter-spacing:1px;
  animation:cap-text 1.2s ease-out both;
}
.cap-text b { margin-left:4px; padding:1px 4px; border-radius:3px; background:var(--lab-selected, var(--card-hover-bg)); font-weight:700; }
@keyframes cap-flip {
  0% { opacity:0; transform:translate(0,0) rotateY(0) scale(.5); }
  12% { opacity:1; }
  55% { transform:translate(-14px,-58px) rotateY(900deg) scale(1); }
  80% { opacity:1; transform:translate(-20px,-40px) rotateY(1080deg) scale(.95); }
  100% { opacity:0; transform:translate(-22px,-26px) rotateY(1080deg) scale(.9); }
}
@keyframes cap-text {
  0%, 15% { opacity:0; transform:translateY(6px); }
  30%, 75% { opacity:1; transform:none; }
  100% { opacity:0; transform:translateY(-8px); }
}

/* ---- table of contents: VATS brackets lock onto the heading ---- */
.vats-lock {
  --vats: #3cff7a;
  position:absolute; z-index:1040; pointer-events:none; border-radius:2px;
  background:repeating-linear-gradient(0deg, #3cff7a0d 0 2px, transparent 2px 4px);
  animation:vats-lock 1.7s ease-out both;
}
:root[data-bs-theme='light'] .vats-lock { --vats: #12823d; background:repeating-linear-gradient(0deg, #12823d12 0 2px, transparent 2px 4px); }
.vats-lock i { position:absolute; width:14px; height:14px; border:2px solid var(--vats); filter:drop-shadow(0 0 3px var(--vats)); }
.vats-lock i:nth-child(1) { left:0; top:0; border-width:2px 0 0 2px; }
.vats-lock i:nth-child(2) { right:0; top:0; border-width:2px 2px 0 0; }
.vats-lock i:nth-child(3) { left:0; bottom:0; border-width:0 0 2px 2px; }
.vats-lock i:nth-child(4) { right:0; bottom:0; border-width:0 2px 2px 0; }
.vats-pct {
  position:absolute; left:calc(100% + 8px); top:50%; transform:translateY(-50%); padding:2px 6px;
  border:1px solid var(--vats); color:var(--vats); background:var(--main-bg);
  font:700 12px/1.3 ui-monospace,Consolas,monospace; letter-spacing:1px;
  animation:vats-pct 1.7s steps(1) both;
}
@keyframes vats-lock {
  0% { opacity:0; transform:scale(1.25); }
  14% { opacity:1; transform:scale(1); }          /* lock on */
  18% { opacity:.35; }
  22%, 78% { opacity:1; transform:none; }
  100% { opacity:0; }
}
@keyframes vats-pct { 0%, 14% { visibility:hidden; } 15%, 100% { visibility:visible; } }
@media (max-width:767.98px) {
  .vats-pct { left:auto; right:0; top:auto; bottom:calc(100% + 4px); transform:none; }
}

/* The script already skips all three with animations off; this keeps a stray one from showing. */
html.lab-motion-off .pa-suit,
html.lab-motion-off .cap-fx,
html.lab-motion-off .vats-lock { display:none; }
@media print { .pa-suit, .cap-fx, .vats-lock { display:none; } }

/* ---- back to top: a Vault-Tec elevator call button ----
 * Chirpy's #back-to-top restyled: a brass bezel around a dark enamel button with an amber "up" lamp that lights up
 * on hover and sinks in when pressed. */
#back-to-top.btn {
  width:3rem; height:3rem; padding:0; border:2px solid #4a3410; border-radius:50%;
  background:radial-gradient(circle at 34% 28%, #fbe7a1 0, #d9a640 38%, #a8731f 70%, #6e4a12 100%);
  box-shadow:0 3px 0 #3a2a0d, 0 7px 14px #00000047, inset 0 1px 1px #fff6;
  transition:opacity .5s ease-in-out, transform .12s ease-out, box-shadow .12s ease-out;
}
#back-to-top.btn i { display:none; }
#back-to-top.btn::before { /* the enamel button inside the bezel */
  content:''; position:absolute; inset:6px; border-radius:50%;
  background:radial-gradient(circle at 40% 32%, #4a3b26 0, #241a0e 65%, #120c05 100%);
  box-shadow:inset 0 2px 3px #000a, 0 1px 0 #fff4;
}
#back-to-top.btn::after { /* the "up" lamp */
  content:''; position:absolute; left:50%; top:50%; width:14px; height:11px; transform:translate(-50%, -62%);
  clip-path:polygon(50% 0, 100% 100%, 0 100%); background:#ffb238; opacity:.55;
  transition:opacity .15s, filter .15s;
}
#back-to-top.btn:hover { transform:none; }
#back-to-top.btn:hover::after,
#back-to-top.btn:focus-visible::after { opacity:1; filter:drop-shadow(0 0 4px #ffb238) drop-shadow(0 0 8px #ff9a1f); }
#back-to-top.btn:active { transform:translateY(2px); box-shadow:0 1px 0 #3a2a0d, 0 3px 6px #00000047, inset 0 1px 1px #fff6; }
#back-to-top.btn:focus-visible { outline:2px solid var(--lab-accent, var(--link-color)); outline-offset:3px; }
