/* ============================================================
   CATBACK eggs — interaction & surprise layer styles.
   Owns: #atm-hotspots children, #receipt-layer, #cat-walk-layer,
   #maintenance-screen, #cursor-fx. Colors/fonts: tokens.css only.
   ============================================================ */

/* ---- ATM hotspot layer ------------------------------------ */
.atm-hotspots {
  position: absolute;
  inset: 0;
  z-index: 8;                 /* top of the atm-wrap stack per contract */
  pointer-events: none;       /* layer never blocks touch scrolling */
}

.hs-btn {
  position: absolute;
  pointer-events: auto;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
/* invisible hit-area expansion so every target is >= 40px */
.hs-btn::after {
  content: '';
  position: absolute;
  top: calc(-1 * var(--hy, 0px));
  bottom: calc(-1 * var(--hy, 0px));
  left: calc(-1 * var(--hx, 0px));
  right: calc(-1 * var(--hx, 0px));
}
.hs-btn:hover { box-shadow: inset 0 0 0 2px var(--glow-soft); }

/* dual-tone focus ring: dark inner + bright outer stays >=3:1 over any art */
.hs-btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 0;
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--terminal);
}
/* the armed pulse animates box-shadow, and animation declarations beat the
   normal cascade — without this override the focused, armed OK button
   (the receipt-print gate) would lose its ring */
.hs-ok.armed:focus-visible {
  animation: none;
  box-shadow: inset 0 0 0 2px var(--terminal), 0 0 0 2px var(--ink), 0 0 0 4px var(--terminal);
}

.hs-ok.armed {
  box-shadow: inset 0 0 0 2px var(--terminal), 0 0 12px var(--glow-terminal);
  animation: eggs-armed 900ms steps(2, end) infinite;
}
@keyframes eggs-armed {
  50% { box-shadow: inset 0 0 0 2px var(--terminal-dim), 0 0 4px var(--glow-soft); }
}

/* bright pixel flash when a key is pressed */
.key-flash {
  position: absolute;
  pointer-events: none;
  background: var(--terminal);
  mix-blend-mode: screen;
  animation: key-flash 220ms steps(3, end) forwards;
}
@keyframes key-flash {
  from { opacity: 0.9; }
  to   { opacity: 0; }
}

/* eye-blink covers (color sampled from the art at runtime) */
.eye-blink {
  position: absolute;
  pointer-events: none;
  z-index: 3;
}

/* MEOW! speech bubble */
.meow-bubble {
  position: absolute;
  pointer-events: none;
  z-index: 4;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 9px;
  padding: 7px 9px;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  box-shadow:
    0 var(--px) 0 0 var(--forest-2),
    0 calc(-1 * var(--px)) 0 0 var(--forest-2),
    var(--px) 0 0 0 var(--forest-2),
    calc(-1 * var(--px)) 0 0 0 var(--forest-2);
  animation: toast-pop 180ms var(--ease-snap);
}
.meow-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 6px;
  height: 6px;
  margin-left: -3px;
  background: var(--cream);
}

/* small pixel toast (GOLD RUSH!) anchored near the slot */
.egg-toast {
  position: absolute;
  pointer-events: none;
  z-index: 4;
  background: var(--ink-2);
  border: var(--px) solid var(--gold);
  color: var(--gold);
  font-family: var(--font-pixel);
  font-size: 9px;
  padding: 8px 10px;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  box-shadow: 0 0 14px var(--glow-soft);
  animation: toast-pop 220ms var(--ease-snap);
}
@keyframes toast-pop {
  from { transform: translate(-50%, -100%) scale(0); }
  to   { transform: translate(-50%, -100%) scale(1); }
}

/* screen tooltip (wrong code / cancel decline) */
.egg-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--ink-2);
  border: var(--px) solid var(--terminal-dim);
  color: var(--terminal);
  font-family: var(--font-term);
  font-size: 19px;
  line-height: 1.2;
  padding: 8px 12px;
  animation: tip-in 140ms steps(2, end);
}
.egg-tooltip.judge { border-color: var(--alert); }
.egg-tooltip.shake { animation: tip-shake 340ms steps(6, end) 2; }
@keyframes tip-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes tip-shake {
  0%   { transform: translateX(0); }
  25%  { transform: translateX(-3px); }
  50%  { transform: translateX(3px); }
  75%  { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

/* card peeking out of the card slot */
.card-peek-mask {
  position: absolute;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}
.card-peek {
  position: absolute;
  left: 12%;
  bottom: 0;
  width: 76%;
  height: 58%;
  background: var(--atm-green);
  border: var(--px) solid var(--forest-2);
  transform: translateY(102%);
  animation: card-peek 600ms var(--ease-mech) forwards;
}
.card-peek::after {           /* tiny gold chip */
  content: '';
  position: absolute;
  left: 5px;
  top: 4px;
  width: 9px;
  height: 7px;
  background: var(--gold);
}
@keyframes card-peek {
  0%   { transform: translateY(102%); }
  40%  { transform: translateY(10%); }
  62%  { transform: translateY(10%); }
  100% { transform: translateY(102%); }
}

/* ---- receipt layer ----------------------------------------- */
#receipt-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 55;
}
.receipt-mask {
  position: absolute;
  overflow: hidden;
  pointer-events: none;
}
.receipt {
  pointer-events: auto;
  width: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-term);
  font-size: 17px;
  line-height: 1.35;
  padding: 12px 14px;
  border: var(--px) solid var(--forest-2);
  border-top: 0;
  border-bottom-style: dashed;
  transform: translateY(-102%);
}
.receipt.in  { animation: rc-print 800ms steps(9, end) forwards; }
.receipt.rip { animation: rc-rip 420ms var(--ease-mech) forwards; }
@keyframes rc-print {
  to { transform: translateY(0); }
}
@keyframes rc-rip {
  30%  { transform: translateY(6px) rotate(-2deg); opacity: 1; }
  100% { transform: translateY(70px) rotate(7deg); opacity: 0; }
}
.rc-title {
  font-family: var(--font-pixel);
  font-size: 9px;
  text-align: center;
  margin: 2px 0 8px;
}
.rc-hr {
  border: 0;
  border-top: var(--px) dashed var(--charcoal);
  margin: 8px 0;
}
.rc-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.rc-row span:last-child { text-align: right; word-break: break-all; }
.rc-simwrap { text-align: center; margin: 6px 0 0; }
.rc-sim {
  display: inline-block;
  background: var(--amber);
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 7px;
  padding: 4px 6px;
}
.rc-heart { text-align: center; margin: 8px 0 0; }
.rc-red { color: var(--alert); }
.rc-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}
.rc-btn {
  min-height: 40px;
  min-width: 72px;
  font-family: var(--font-pixel);
  font-size: 9px;
  background: var(--forest);
  color: var(--terminal);
  border: var(--px) solid var(--forest-2);
  padding: 8px 10px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform var(--dur-fast) var(--ease-snap);
}
.rc-btn:hover { background: var(--forest-2); transform: translateY(-1px); }
.rc-btn:active { transform: translateY(1px); }

/* ---- maintenance mode (CRT overlay) ------------------------- */
.maintenance-screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.maintenance-screen[hidden] { display: none; }
.maintenance-screen::before {          /* scanlines over everything */
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0 2px, var(--scanline) 2px 4px);
  pointer-events: none;
  z-index: 2;
}
.mx-frame {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--ink);
  border: var(--px) solid var(--terminal-dim);
  box-shadow: 0 0 0 var(--px) var(--ink), 0 0 26px var(--glow-soft);
  padding: 20px 22px;
  color: var(--terminal);
  font-family: var(--font-term);
  font-size: 20px;
}
.mx-title {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--terminal);
  letter-spacing: 2px;
  margin: 0 44px 14px 0;
  text-shadow: 0 0 10px var(--glow-terminal);
}
.mx-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  background: var(--ink-3);
  border: var(--px) solid var(--forest-2);
  color: var(--alert);
  font-family: var(--font-pixel);
  font-size: 12px;
  cursor: pointer;
  touch-action: manipulation;
}
.mx-close:hover { border-color: var(--alert); }
.mx-ascii {
  margin: 0 0 12px;
  color: var(--terminal-dim);
  font-family: var(--font-term);
  font-size: 17px;
  line-height: 1.05;
  white-space: pre;
  overflow-x: auto;
}
.mx-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--forest-2);
}
.mx-k { color: var(--terminal-soft); }
.mx-v { color: var(--terminal); text-align: right; }
.mx-v:empty::after { content: '▌'; animation: mx-blink 900ms steps(2, end) infinite; }
.mx-footer {
  margin: 14px 0 0;
  text-align: center;
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--terminal-dim);
}
@keyframes mx-blink { 50% { opacity: 0; } }

/* ---- cursor pixels ------------------------------------------ */
#cursor-fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 78;
}
.cfx {
  position: fixed;
  background: var(--terminal);
  animation: cfx-fade 460ms steps(5, end) forwards;
}
@keyframes cfx-fade {
  from { opacity: 0.95; }
  to   { opacity: 0; }
}

/* ---- walking cat --------------------------------------------- */
#cat-walk-layer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  pointer-events: none;
  z-index: 58;
}
.cat-walker {
  position: absolute;
  bottom: 0;
  left: 0;
  pointer-events: auto;
  background: transparent;
  border: 0;
  margin: 0;
  padding: 8px 8px 6px;         /* pads the hit area to >= 40px */
  cursor: pointer;
  will-change: transform;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.cat-walker .cat-body { display: block; }
.cat-walker.flip .cat-body { transform: scaleX(-1); }
.cat-walker canvas { display: block; image-rendering: pixelated; }
/* needs the .cat-walker prefix to outrank `.cat-walker canvas` above —
   without it both walk frames render stacked and the cat doubles in height */
.cat-walker .cat-frame-b { display: none; }
.cat-walker.step .cat-frame-a { display: none; }
.cat-walker.step .cat-frame-b { display: block; }

.cat-heart {
  position: fixed;
  pointer-events: none;
  z-index: 59;
  image-rendering: pixelated;
  animation: heart-pop 900ms var(--ease-snap) forwards;
}
@keyframes heart-pop {
  0%   { transform: translate(-50%, 0) scale(0); opacity: 1; }
  60%  { transform: translate(-50%, -26px) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -40px) scale(1); opacity: 0; }
}

.mini-note {
  position: fixed;
  bottom: 4px;
  pointer-events: auto;
  background: transparent;
  border: 0;
  padding: 6px;
  cursor: pointer;
  z-index: 59;
  touch-action: manipulation;
  animation: note-drop 500ms var(--ease-snap);
}
.mini-note img { width: 30px; display: block; image-rendering: pixelated; }
.mini-note.pop  { animation: note-collect 300ms var(--ease-snap) forwards; }
.mini-note.fade { opacity: 0; transition: opacity 600ms var(--ease-mech); }
@keyframes note-drop {
  from { transform: translateY(-46px); }
  to   { transform: translateY(0); }
}
@keyframes note-collect {
  to { transform: translateY(-14px) scale(1.5); opacity: 0; }
}
