/* Homebrew biome: the channel strip, bubbles, boot text, the static, the warning, the screen tear and the four auras. See js/ui/homebrew.js. */

/* the strip along the bottom; the HUD moves up to make room */
#hbstrip { position: fixed; left: 0; right: 0; bottom: 0; height: 38px; z-index: 9; display: none; align-items: center; justify-content: space-between; padding: 0 22px; background: #020306; border-top: 1px solid #0c1a33; color: #e8f1ff; pointer-events: none; }
body.hb-on #hbstrip { display: flex; }
body.hb-on #hud { bottom: 38px; }
#hbstrip .nm { font: 500 15px/1 var(--head, sans-serif); letter-spacing: .01em; }
#hbstrip .nm span { opacity: .7; margin-right: 4px; }
#hbstrip .nm b { font-weight: 800; font-size: 19px; }
#hbstrip svg { width: 22px; height: 18px; fill: none; stroke: #e8f1ff; stroke-width: 2; stroke-linecap: round; opacity: .85; }

/* the layer behind the HUD: bubbles and boot text */
#hbfx { position: fixed; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; opacity: 0; transition: opacity 1.6s; }
#hbfx.on { opacity: 1; }
#hbfx .bub { position: absolute; bottom: -60px; width: var(--s); height: var(--s); background: var(--bub) center / contain no-repeat; image-rendering: pixelated; opacity: .6; animation: hbrise var(--t) linear infinite; animation-delay: var(--d); }
@keyframes hbrise { from { transform: translate(0, 0); } 50% { transform: translate(var(--w), -55vh); } to { transform: translate(0, -115vh); } }
#hbfx .boot { position: absolute; left: 16px; bottom: 0; font: 11px/1.5 ui-monospace, Menlo, Consolas, monospace; color: #7fb4ff; opacity: .16; white-space: pre; animation: hbscroll 46s linear infinite; }
@keyframes hbscroll { from { transform: translateY(0); } to { transform: translateY(-50%); } }
body.hb-calm #hbfx .bub, body.hb-calm #hbfx .boot { display: none; }

/* the CRT flash and the warning */
#hbstatic { position: fixed; inset: 0; z-index: 60; display: none; pointer-events: none; image-rendering: pixelated; }
#hbstatic canvas { width: 100%; height: 100%; display: block; }
#hbstatic::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .35) 0 2px, transparent 2px 4px); }
#hbwarn { position: fixed; left: 0; right: 0; top: 38%; z-index: 61; display: none; text-align: center; pointer-events: none; font: 700 clamp(15px, 2.2vw, 26px)/1.4 ui-monospace, Menlo, Consolas, monospace; color: #ffd400; text-shadow: 0 0 10px rgba(255, 212, 0, .7); }
#hbwarn.on { display: block; animation: hbwarn .16s steps(2) 3; }
@keyframes hbwarn { 50% { opacity: .4; } }
body.hb-black::before { content: ""; position: fixed; inset: 0; z-index: 59; background: #000; }

/* the screen tear on every 50th roll */
body.hb-tear #world, body.hb-tear #hud { animation: hbtear .8s steps(1); }
@keyframes hbtear {
  0% { transform: none; } 8% { transform: translateX(-26px) skewX(3deg); filter: hue-rotate(60deg) saturate(2); } 16% { transform: translateX(34px); filter: none; }
  26% { transform: translateX(-10px) skewX(-2deg); filter: hue-rotate(-50deg); } 38% { transform: translateX(14px); filter: none; } 52% { transform: translateX(-6px); } 70% { transform: none; filter: none; } 100% { transform: none; }
}
#hbtear { position: fixed; inset: 0; z-index: 58; pointer-events: none; }
#hbtear i { position: absolute; left: 0; right: 0; background: rgba(0, 162, 255, .22); animation: hbbar .8s steps(1) forwards; }
@keyframes hbbar { 0% { transform: translateX(0); opacity: 1; } 20% { transform: translateX(var(--x)); } 45% { transform: translateX(calc(var(--x) * -.6)); } 75% { transform: none; opacity: .6; } 100% { opacity: 0; } }
#hbclock { position: fixed; left: 0; right: 0; top: 24%; z-index: 62; text-align: center; pointer-events: none; font: 800 clamp(28px, 5vw, 56px)/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; animation: hbclock 2s steps(20) forwards; }
#hbclock small { display: block; margin-top: 8px; font-size: .32em; letter-spacing: .2em; opacity: .85; }
#hbclock.over { color: #35e0ff; text-shadow: 3px 0 #ff2bd6, -3px 0 #00ff9c; }
#hbclock.under { color: #ff5a4a; text-shadow: 3px 0 #ffd400, -3px 0 #3a1b80; }
@keyframes hbclock { 0% { opacity: 0; transform: translateX(-12px); } 10%, 70% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* Homebrew: a #00A2FF sine wave around the player, pixel bubbles from the feet, a small bob */
#avatar .avfx[data-a=Homebrew] .hbw { left: -14px; top: 12px; width: 50px; height: 12px; overflow: hidden; }
#avatar .avfx[data-a=Homebrew] .hbw svg { width: 90px; height: 12px; display: block; animation: hbwave 1.2s linear infinite; }
#avatar .avfx[data-a=Homebrew] .hbw path { fill: none; stroke: #00a2ff; stroke-width: 1.6; filter: drop-shadow(0 0 2px #00a2ff); }
#avatar .avfx[data-a=Homebrew] .hbw.b { top: 20px; opacity: .55; }
#avatar .avfx[data-a=Homebrew] .hbw.b svg { animation-direction: reverse; animation-duration: 1.7s; }
@keyframes hbwave { to { transform: translateX(-30px); } }
#avatar .avfx[data-a=Homebrew] .pb2 { bottom: 0; width: 3px; height: 3px; background: #6fd0ff; box-shadow: 0 0 0 1px #00a2ff; animation: hbpix 2.2s steps(9) infinite; opacity: 0; }
#avatar .avfx[data-a=Homebrew] .pb2:nth-of-type(3) { left: 2px; animation-delay: -.3s; } #avatar .avfx[data-a=Homebrew] .pb2:nth-of-type(4) { left: 9px; animation-delay: -1.1s; }
#avatar .avfx[data-a=Homebrew] .pb2:nth-of-type(5) { left: 16px; animation-delay: -1.7s; } #avatar .avfx[data-a=Homebrew] .pb2:nth-of-type(6) { left: 5px; animation-delay: -.8s; } #avatar .avfx[data-a=Homebrew] .pb2:nth-of-type(7) { left: 13px; animation-delay: -1.9s; }
@keyframes hbpix { 0% { transform: translateY(0); opacity: 0; } 10% { opacity: 1; } 100% { transform: translateY(-42px); opacity: 0; } }
#avatar:has(.avfx[data-a=Homebrew]) .fig { animation: hbbob 1.8s steps(4) infinite; }
@keyframes hbbob { 50% { translate: 0 -2px; } }

/* Softlock: greyscale, a thin static layer, red pixel crosses circling */
#avatar:has(.avfx[data-a=Softlock]) .fig { filter: grayscale(1) drop-shadow(0 0 calc(var(--gs, 0px) / 2) var(--gc, transparent)); }
#avatar .avfx[data-a=Softlock] .sls { left: -5px; top: -16px; width: 32px; height: 48px; opacity: .3; background: repeating-linear-gradient(0deg, #fff 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, rgba(255, 255, 255, .6) 0 1px, transparent 1px 5px); animation: hbstat .24s steps(3) infinite; }
@keyframes hbstat { 33% { background-position: 0 1px, 2px 0; } 66% { background-position: 0 2px, 4px 0; } }
#avatar .avfx[data-a=Softlock] .slo { left: 11px; top: 4px; width: 0; height: 0; }
#avatar .avfx[data-a=Softlock] .slo i { position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; background: linear-gradient(45deg, transparent 38%, #e53935 38% 62%, transparent 62%), linear-gradient(-45deg, transparent 38%, #e53935 38% 62%, transparent 62%); image-rendering: pixelated; animation: hborbit 3.2s steps(16) infinite; }
#avatar .avfx[data-a=Softlock] .slo i:nth-child(2) { animation-delay: -1.07s; } #avatar .avfx[data-a=Softlock] .slo i:nth-child(3) { animation-delay: -2.13s; }
@keyframes hborbit { from { transform: rotate(0) translateX(24px) scaleY(.6) rotate(0); } to { transform: rotate(360deg) translateX(24px) scaleY(.6) rotate(-360deg); } }

/* Exploit: green digital rain over the player, a ghost trail while moving */
#avatar .avfx[data-a=Exploit] .exr { left: -6px; top: -16px; width: 34px; height: 50px; overflow: hidden; mix-blend-mode: screen; -webkit-mask-image: linear-gradient(transparent, #000 18%, #000 78%, transparent); mask-image: linear-gradient(transparent, #000 18%, #000 78%, transparent); }
#avatar .avfx[data-a=Exploit] .exr span { position: absolute; top: 0; font: 700 7px/8px ui-monospace, Menlo, monospace; color: #39ff14; text-shadow: 0 0 3px #39ff14; writing-mode: vertical-rl; text-orientation: upright; letter-spacing: 1px; white-space: nowrap; animation: hbrain 1s linear infinite; }
#avatar .avfx[data-a=Exploit] .exr span:nth-child(1) { left: 2px; animation-duration: .9s; } #avatar .avfx[data-a=Exploit] .exr span:nth-child(2) { left: 8px; animation-duration: 1.3s; animation-delay: -.4s; }
#avatar .avfx[data-a=Exploit] .exr span:nth-child(3) { left: 14px; animation-duration: 1.05s; animation-delay: -.2s; } #avatar .avfx[data-a=Exploit] .exr span:nth-child(4) { left: 20px; animation-duration: 1.5s; animation-delay: -.9s; } #avatar .avfx[data-a=Exploit] .exr span:nth-child(5) { left: 26px; animation-duration: 1.15s; animation-delay: -.6s; }
@keyframes hbrain { from { transform: translateY(-50%); } to { transform: translateY(0); } }
#avatar.walking:has(.avfx[data-a=Exploit]) .fig { filter: drop-shadow(7px 0 0 rgba(57, 255, 20, .32)) drop-shadow(-7px 0 0 rgba(57, 255, 20, .32)) drop-shadow(0 0 4px #39ff14); }

/* BOOTLEG: a CRT floating behind the head; every 3 seconds it glitches and throws blue light */
#avatar .avfx[data-a=BOOTLEG] { z-index: -1; }
#avatar .avfx[data-a=BOOTLEG] .crt { left: 7px; top: -33px; width: 26px; height: 21px; background: #15161b; border: 2px solid #9aa3b5; border-radius: 4px; box-shadow: inset 0 0 0 2px #07080a, 0 0 6px rgba(0, 162, 255, .5); animation: hbcrt 3s steps(1) infinite; }
#avatar .avfx[data-a=BOOTLEG] .crt::before { content: ""; position: absolute; inset: 1px; border-radius: 2px; background: repeating-linear-gradient(0deg, #3a4150 0 1px, #1c2029 1px 2px); opacity: .55; animation: hbstat .3s steps(3) infinite; }
#avatar .avfx[data-a=BOOTLEG] .crt::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: -6px; height: 3px; background: #6b707c; }
@keyframes hbcrt { 0%, 90%, 100% { transform: none; filter: none; } 92% { transform: translateX(-3px) skewX(8deg); filter: hue-rotate(80deg) brightness(1.8); } 95% { transform: translateX(3px); filter: invert(.3); } }
#avatar .avfx[data-a=BOOTLEG] .blp { left: 20px; top: -23px; width: 3px; height: 3px; background: #7fd4ff; box-shadow: 0 0 5px 2px #29b6f6; opacity: 0; animation: hbshoot 3s linear infinite; }
#avatar .avfx[data-a=BOOTLEG] .blp:nth-of-type(2) { --dx: -26px; --dy: -14px; } #avatar .avfx[data-a=BOOTLEG] .blp:nth-of-type(3) { --dx: 28px; --dy: -12px; }
#avatar .avfx[data-a=BOOTLEG] .blp:nth-of-type(4) { --dx: -12px; --dy: -26px; } #avatar .avfx[data-a=BOOTLEG] .blp:nth-of-type(5) { --dx: 14px; --dy: -28px; } #avatar .avfx[data-a=BOOTLEG] .blp:nth-of-type(6) { --dx: 0px; --dy: -30px; }
@keyframes hbshoot { 0%, 91% { transform: none; opacity: 0; } 92% { opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)); opacity: 0; } }
