/* In-raid panels (js/client/ui/machine.js): FLAKOMAT, till, vendor, NPC.
   Desktop: a card at the bottom centre. Phones: a bottom sheet. Uses the style.css tokens and .btn. */

.efb-panels {
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  pointer-events: none;
  font-family: var(--font-body, 'Barlow Condensed', 'Arial Narrow', sans-serif);
  color: var(--text, #eee);
}
#ui > .efb-panels, .efb-panels { pointer-events: none; }   /* style.css gives #ui > * pointer events */
.efb-panels.on { display: block; }

.pn-card {
  position: absolute;
  left: 50%;
  bottom: calc(var(--sb) + 22px);
  translate: -50% 0;
  width: min(580px, calc(100vw - 32px));
  max-height: min(74vh, 640px);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  background: var(--panel-bg, rgba(19, 22, 25, 0.94));
  border: 1px solid var(--line-2, rgba(255, 255, 255, 0.16));
  border-top: 4px solid var(--bkv, #ffd200);
  border-radius: calc(var(--r, 7px) + 3px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), var(--sticker, 0 3px 0 rgba(0, 0, 0, 0.55));
  animation: pn-in 0.18s ease-out;
  overflow: hidden;
  touch-action: manipulation;
}
@keyframes pn-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.pn-card.pn-shake { animation: pn-shake 0.32s ease-out; }
@keyframes pn-shake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } }
.pn-card.pn-machine { border-top-color: var(--good, #71d36b); }
.pn-card.pn-npc { border-top-color: var(--warn, #ffb03a); }

/* ---------- head */
.pn-head {
  position: relative;
  padding: 12px 58px 8px 16px;
  border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.09));
}
.pn-title {
  margin: 0;
  font-family: var(--font-head, 'Anton', Impact, sans-serif);
  font-weight: 400;
  font-size: 1.6rem;
  line-height: 1.05;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pn-sub { margin-top: 2px; font-size: 0.98rem; color: var(--text-dim, #aab); }
.pn-sub.quote { font-style: italic; color: var(--text, #eee); }
.pn-x { position: absolute; top: 8px; right: 8px; }

/* ---------- body */
.pn-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pn-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--line, rgba(255, 255, 255, 0.09));
  background: rgba(0, 0, 0, 0.18);
}
.pn-foot:empty { display: none; }
.pn-hint {
  padding: 0 16px 6px;
  text-align: right;
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.78rem;
  color: var(--text-dim, #889);
  letter-spacing: 0.04em;
  pointer-events: none;
}
body.efb-touch .pn-hint, body.efb-pad .pn-hint { display: none; }

/* buttons: label + small sub line, hotkey chip */
.pn-act { position: relative; flex-direction: column; gap: 1px; line-height: 1; }
.pn-foot .pn-act { flex: 1 1 110px; }
.pn-foot .pn-act.big { flex: 2 1 180px; }
.pn-lbl { display: block; }
.pn-bsub {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  opacity: 0.8;
}
.pn-bsub:empty { display: none; }
.pn-kbd {
  position: absolute;
  top: 3px;
  left: 4px;
  min-width: 15px;
  padding: 0 3px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.35);
  color: inherit;
  font-family: var(--font-mono, monospace);
  font-size: 0.68rem;
  line-height: 15px;
  opacity: 0.75;
}
body.efb-touch .pn-kbd, body.efb-pad .pn-kbd { display: none; }
.pn-act.hot:not(:disabled) { animation: pn-hot 1.2s ease-in-out infinite; --b-bg: var(--warn, #ffb03a); --b-fg: var(--bkv-ink, #17150f); }
@keyframes pn-hot { 50% { box-shadow: 0 3px 0 var(--b-edge), 0 0 0 5px rgba(255, 176, 58, 0.3); } }
.pn-act.armed { --b-bg: var(--bad, #ff5b4d); animation: pn-hot 0.6s ease-in-out infinite; }

/* ---------- FLAKOMAT screen */
.pn-screen {
  position: relative;
  padding: 10px 12px 12px;
  border-radius: 6px;
  background: linear-gradient(180deg, #0c2a1c, #071a12);
  border: 3px solid #2b3036;
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06);
  color: #8dff9a;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  text-shadow: 0 0 6px rgba(120, 255, 140, 0.45);
  overflow: hidden;
}
.pn-screen::after {                         /* scanlines */
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
}
.pn-screen.st-full, .pn-screen.st-err { background: linear-gradient(180deg, #3a0d0b, #1e0605); color: #ff8f80; text-shadow: 0 0 6px rgba(255, 90, 70, 0.5); }
.pn-screen.st-off { background: linear-gradient(180deg, #23262a, #15171a); color: #9aa0a8; text-shadow: none; }
.pn-scr-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pn-scr-st { font-size: 1.35rem; font-weight: 800; letter-spacing: 0.1em; }
.st-full .pn-scr-st, .st-err .pn-scr-st { animation: pn-blink 1s steps(2, start) infinite; }
@keyframes pn-blink { to { visibility: hidden; } }
.pn-scr-fill { display: flex; align-items: center; gap: 6px; font-size: 0.72rem; opacity: 0.85; white-space: nowrap; }
.pn-fbar { width: 70px; height: 7px; border: 1px solid currentColor; border-radius: 2px; overflow: hidden; }
.pn-fbar i { display: block; height: 100%; width: 0; background: currentColor; transition: width 0.4s; }
.pn-scr-fill.hi { color: var(--warn, #ffb03a); }
.pn-scr-msg { margin-top: 4px; min-height: 1.3em; font-size: 0.86rem; }
.pn-scr-q { margin-top: 2px; font-size: 0.8rem; opacity: 0.8; }
.pn-scr-q.wait { color: var(--warn, #ffb03a); opacity: 1; }
.pn-counts { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; margin-top: 10px; }
.pn-cnt { display: flex; flex-direction: column; padding: 4px 8px; border: 1px solid rgba(141, 255, 154, 0.25); border-radius: 4px; }
.pn-cnt b { font-size: 1.45rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pn-cnt span { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.75; }
.pn-cnt.rej b { color: #ffb0a6; }
.pn-cnt.sum b { color: #fff6b0; }
.pn-cnt b.bump { animation: pn-bump 0.3s ease-out; }
@keyframes pn-bump { 40% { transform: scale(1.25); } }
.pn-scr-note { margin-top: 6px; font-size: 0.72rem; opacity: 0.8; }
.pn-scr-note.bad { color: #ffb0a6; opacity: 1; }

/* feed slot and the flying bottle */
.pn-slot {
  position: absolute;
  right: 12px;
  bottom: 40px;
  width: 44px;
  height: 44px;
  pointer-events: none;
}
.pn-slot-mouth {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 0;
  height: 8px;
  border-radius: 50%;
  background: #000;
  box-shadow: 0 0 0 2px rgba(141, 255, 154, 0.35);
}
.pn-fly {
  position: absolute;
  left: 50%;
  bottom: 2px;
  font-size: 26px;
  text-shadow: none;
  translate: -50% 0;
  animation: pn-fly 0.72s ease-in forwards;
}
@keyframes pn-fly {
  0% { transform: translate(-60px, -46px) rotate(-30deg); opacity: 0; }
  25% { opacity: 1; }
  60% { transform: translate(0, -18px) rotate(0); opacity: 1; }
  100% { transform: translate(0, 18px) scaleY(0.4); opacity: 0; }
}

/* the receipt the machine prints, in flow below the screen */
.pn-paper {
  display: none;
  align-self: center;
  width: min(240px, 80%);
  padding: 8px 12px 10px;
  margin-top: -4px;
  background: var(--paper, #f4f1e8);
  color: var(--paper-ink, #26221d);
  text-shadow: none;
  font-size: 0.8rem;
  text-align: center;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.pn-paper b, .pn-paper span, .pn-paper i { display: block; }
.pn-paper b { letter-spacing: 0.2em; }
.pn-paper span { font-size: 1.05rem; font-weight: 800; }
.pn-paper i { font-style: normal; letter-spacing: -1px; opacity: 0.7; }
.pn-paper.out { display: block; animation: pn-print 2.6s ease-out forwards; }
@keyframes pn-print {
  0% { clip-path: inset(0 0 100% 0); opacity: 1; }
  25% { clip-path: inset(0 0 0 0); opacity: 1; }
  80% { clip-path: inset(0 0 0 0); opacity: 1; transform: none; }
  100% { clip-path: inset(0 0 0 0); opacity: 0; transform: translateY(10px) rotate(3deg); }
}

/* reject log */
.pn-log { display: none; }
.pn-log.on { display: block; }
.pn-log-h { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim, #aab); margin-bottom: 4px; }
.pn-log-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.pn-log-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 8px;
  border-left: 3px solid var(--bad, #ff5b4d);
  background: rgba(255, 91, 77, 0.08);
  font-size: 0.92rem;
  animation: pn-in 0.2s ease-out;
}
.pn-log-list li span { color: #ffb0a6; text-align: right; }
.pn-log-list li:first-child { background: rgba(255, 91, 77, 0.18); }

.pn-warn { display: none; flex: 1 1 100%; font-size: 0.85rem; color: #ffb0a6; }
.pn-warn.on { display: block; }

/* ---------- lists (till) */
.pn-refuse {
  padding: 8px 10px;
  border-radius: var(--r, 7px);
  background: rgba(255, 91, 77, 0.14);
  border: 1px solid rgba(255, 91, 77, 0.4);
  color: #ffc4bb;
  font-weight: 700;
}
.pn-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pn-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 5px;
  background: var(--paper, #f4f1e8);
  color: var(--paper-ink, #26221d);
  font-size: 1rem;
}
.pn-list li.bad { opacity: 0.7; }
.pn-list li.bad .pn-val { color: var(--bad-deep, #b0261b); font-weight: 600; }
.pn-list li.pn-empty { background: transparent; color: var(--text-dim, #aab); padding-left: 0; }
.pn-ico { font-size: 1.15rem; }
.pn-name { flex: 1; }
.pn-val { font-variant-numeric: tabular-nums; }
.pn-total { font-family: var(--font-head, 'Anton', sans-serif); font-size: 1.3rem; letter-spacing: 0.03em; text-align: right; }
.pn-total:empty { display: none; }
.pn-total.bad { font-family: inherit; font-size: 1rem; color: #ffb0a6; }

/* ---------- shop (vendor) and NPC options */
.pn-shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.pn-opts { display: flex; flex-direction: column; gap: 8px; }
.pn-item, .pn-opts .pn-act {
  justify-content: flex-start;
  align-items: flex-start;
  text-align: left;
  padding: 8px 10px 8px 48px;
  min-height: 52px;
  text-transform: none;
}
.pn-opts .pn-act { padding-left: 30px; }
.pn-item .pn-lbl, .pn-opts .pn-lbl { font-size: 1.02rem; }
.pn-glyph {
  position: absolute;
  left: 8px;
  top: 50%;
  translate: 0 -50%;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 18px;
}
.pn-shop .pn-kbd { left: auto; right: 4px; }
.pn-item.short .pn-bsub { color: #ffb0a6; opacity: 1; }
.pn-wallet { font-size: 0.92rem; color: var(--text-dim, #aab); }
.pn-wallet:empty { display: none; }

/* ---------- phones: a bottom sheet */
@media (max-width: 760px), (pointer: coarse) and (max-height: 540px) {
  .pn-card {
    left: 0;
    right: 0;
    bottom: 0;
    translate: none;
    width: auto;
    max-height: 66vh;
    border-radius: 14px 14px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding-left: var(--sl);
    padding-right: var(--sr);
    animation-name: pn-sheet;
  }
  @keyframes pn-sheet { from { transform: translateY(100%); } to { transform: none; } }
  .pn-card::before {                     /* grab handle */
    content: '';
    position: absolute;
    left: 50%;
    top: 6px;
    width: 40px;
    height: 4px;
    margin-left: -20px;
    border-radius: 2px;
    background: var(--line-2, rgba(255, 255, 255, 0.16));
  }
  .pn-head { padding-top: 14px; }
  .pn-title { font-size: 1.35rem; }
  .pn-foot { padding-bottom: calc(10px + var(--sb)); }
  .pn-foot .pn-act { flex: 1 1 calc(50% - 8px); }
  .pn-foot .pn-act.big { flex: 1 1 100%; }
  .pn-shop { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 380px) {
  .pn-shop { grid-template-columns: 1fr; }
  .pn-counts { grid-template-columns: 1fr 1fr; }
  .pn-cnt.sum { grid-column: 1 / -1; }
  .pn-body { padding: 10px 12px; }
}
/* short landscape phones: a side sheet on the right, the map stays visible on the left */
@media (orientation: landscape) and (max-height: 540px) {
  .pn-card {
    left: auto;
    right: 0;
    translate: none;
    animation-name: pn-sheet;
    top: 0;
    bottom: 0;
    width: min(440px, 58vw);
    max-height: none;
    border-radius: 14px 0 0 14px;
    border-top-width: 4px;
    padding-right: var(--sr);
    padding-left: 0;
  }
  .pn-card::before { display: none; }
  .pn-hint { display: none; }
  @keyframes pn-sheet { from { transform: translateX(100%); } to { transform: none; } }
  .pn-body { gap: 8px; padding: 8px 12px; }
  .pn-head { padding: 8px 56px 6px 12px; }
  .pn-foot { padding: 8px 12px calc(8px + var(--sb)); }
  .pn-foot .pn-act { flex: 1 1 calc(50% - 8px); min-height: 44px; }
  .pn-foot .pn-act.big { flex: 1 1 calc(50% - 8px); min-height: 44px; font-size: 1rem; }
  .pn-counts { margin-top: 6px; }
  .pn-shop { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .pn-card, .pn-card.pn-shake, .pn-fly, .pn-act.hot, .pn-act.armed, .st-full .pn-scr-st, .st-err .pn-scr-st { animation: none; }
}
