/**
 * System Tabs — case-file index tabs on the screen's right edge.
 * SAVE / CONFIG, always reachable during play. Paper + red stamp
 * edge, vertical text, slide out slightly on hover; slide fully
 * away when a cinematic owns the screen (.sys-tabs-hidden).
 */

#systemTabs {
  position: fixed;
  right: 0;
  top: 16%;
  z-index: 9997; /* under the floating phone (9998) and overlays */
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

#systemTabs.sys-tabs-hidden {
  transform: translateX(110%);
  opacity: 0;
  pointer-events: none;
}

.sys-tab {
  writing-mode: vertical-rl;
  text-orientation: upright;
  background: #EBE6D8;
  color: #5F5449;
  border: 1px solid #8E7F7F;
  border-right: none;
  border-radius: 4px 0 0 4px;
  padding: 10px 5px 12px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.66rem;
  font-weight: bold;
  letter-spacing: 3px;
  cursor: pointer;
  box-shadow:
    -2px 2px 8px rgba(0, 0, 0, 0.35),
    inset 0 0 12px rgba(139, 69, 19, 0.06);
  transform: translateX(4px);
  transition: transform 0.18s ease, background 0.18s ease;
  user-select: none;
  position: relative;
}

.sys-tab:hover {
  transform: translateX(0);
  background: #f2ecdd;
}

/* The red stamp edge — the strip of ink where the tab meets the
   folder, like a classification mark bleeding off the page. */
.sys-tab-stamp {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #8B0000;
  opacity: 0.75;
  border-radius: 4px 0 0 4px;
}

.sys-tab-config .sys-tab-stamp {
  background: #4a7c59;
}

/* ── LEFT SIDE — the mirror: GALLERY + PLAYER ─────────────────── */

#systemTabsLeft {
  position: fixed;
  left: 0;
  top: 16%;
  z-index: 9997;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

#systemTabsLeft.sys-tabs-hidden {
  transform: translateX(-110%);
  opacity: 0;
  pointer-events: none;
}

#systemTabsLeft .sys-tab {
  border: 1px solid #8E7F7F;
  border-left: none;
  border-radius: 0 4px 4px 0;
  box-shadow:
    2px 2px 8px rgba(0, 0, 0, 0.35),
    inset 0 0 12px rgba(139, 69, 19, 0.06);
  /* QA P3-03 — the -4px "tucked in" look pushed the tab past the
     screen edge and clipped the first letter. Flush now; hover
     still nudges outward. */
  transform: translateX(0);
}

#systemTabsLeft .sys-tab:hover {
  transform: translateX(2px);
}

#systemTabsLeft .sys-tab-stamp {
  left: auto;
  right: 0;
  border-radius: 0 4px 4px 0;
}

.sys-tab-gallery .sys-tab-stamp { background: #c4a87a; }
.sys-tab-player  .sys-tab-stamp { background: #d4445e; }

/* ── NOW PLAYING — the drawer speaks PC-Eargasm (Moanolith's own
     player): aged paper + grain, typewriter type, warm brown ink,
     little brown EQ bars. The phone Eargasm is the modern parody;
     the case file pulls out the PAPER player. ── */

#nowPlayingCard {
  --ear-ink: #3A2A1A;
  --ear-mid: #7a6a4a;
  --ear-acc: #5a3a1a;
  position: fixed;
  left: 0;                 /* flush to the edge — the tab's continuation */
  top: 24%;                /* overridden by JS to the tab's exact height */
  z-index: 9996;
  width: 300px;
  background: #d8c8a4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  border: 1.5px solid #9a8a6a;
  border-left: none;
  border-radius: 0 4px 4px 0;
  box-shadow: -2px 6px 20px rgba(0, 0, 0, 0.4);
  font-family: 'Courier New', Courier, monospace;
  animation: npcIn 0.35s ease both;
}

#nowPlayingCard.npc-closing {
  animation: npcOut 0.32s ease both;
}

@keyframes npcIn {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

@keyframes npcOut {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

/* The PLAYER tab rides the drawer: while open it sits attached to
   the card's outer edge, still clickable — it IS the close handle. */
#systemTabsLeft .sys-tab-player.sys-tab-open {
  transform: translateX(300px);
  transition: transform 0.35s ease;
  border-radius: 0 4px 4px 0;
}

#nowPlayingCard .npc-head {
  padding: 8px 12px;
  color: var(--ear-ink);
  background: #c8b890;
  border-bottom: 1.5px solid #9a8a6a;
  font-family: 'Special Elite', 'Courier New', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  border-radius: 0 4px 0 0;
}

#nowPlayingCard .npc-rows { padding: 6px 10px 10px; }

#nowPlayingCard .npc-row {
  --npc-accent: var(--ear-acc);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 4px;
  border-radius: 2px;
}

#nowPlayingCard .npc-row:hover { background: #cdbd96; }

/* The cover tile — the PC app's album-art grammar: the artist's
   gradient in a thin brown frame, sitting on the paper. */
#nowPlayingCard .npc-cover {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 2px;
  border: 1px solid #9a8a6a;
  background: linear-gradient(135deg, #b8a880 0%, #8a7a5a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: inset 0 0 8px rgba(58, 42, 26, 0.25);
}

#nowPlayingCard .npc-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

#nowPlayingCard .npc-name {
  color: var(--ear-ink);
  font-family: 'Special Elite', 'Courier New', monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#nowPlayingCard .npc-label {
  color: var(--ear-mid);
  font-size: 9.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#nowPlayingCard .npc-empty {
  color: var(--ear-mid);
  font-style: italic;
  font-size: 11px;
  padding: 6px 4px 4px;
}

/* Live indicator — not an EQ, a TAPE REEL: the wire is always
   recording in this town. A small spool with spokes, turning at
   tape speed while the layer sounds. */
#nowPlayingCard .npc-eq {
  position: relative;
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  border: 1.5px solid var(--npc-accent);
  border-radius: 50%;
  animation: npcReel 1.8s linear infinite;
}

#nowPlayingCard .npc-eq::after {
  /* the hub */
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 3px; height: 3px;
  transform: translate(-50%, -50%);
  background: var(--npc-accent);
  border-radius: 50%;
}

#nowPlayingCard .npc-eq i {
  position: absolute;
  background: var(--npc-accent);
}

/* two crossing spokes = four arms */
#nowPlayingCard .npc-eq i:nth-child(1) {
  left: 50%; top: 1px; bottom: 1px; width: 1.5px;
  transform: translateX(-50%);
}
#nowPlayingCard .npc-eq i:nth-child(2) {
  top: 50%; left: 1px; right: 1px; height: 1.5px;
  transform: translateY(-50%);
}
#nowPlayingCard .npc-eq i:nth-child(3) { display: none; }

@keyframes npcReel {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  #nowPlayingCard .npc-eq { animation: none; }
}

/* A tab that isn't unlocked yet simply isn't in the folder. */
.sys-tab.sys-tab-locked {
  display: none;
}

/* ── UNLOCK CEREMONY — a newly earned tab slides out of the edge
     with a slight overshoot and presses itself into the folder,
     announced by the paperclip snap. Direction-aware per side. */
#systemTabs .sys-tab-appear {
  animation: sysTabInR 0.8s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

#systemTabsLeft .sys-tab-appear {
  animation: sysTabInL 0.8s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

@keyframes sysTabInR {
  0%   { transform: translateX(110%); opacity: 0; }
  70%  { transform: translateX(-3px); opacity: 1; }
  100% { transform: translateX(4px); opacity: 1; }
}

@keyframes sysTabInL {
  0%   { transform: translateX(-110%); opacity: 0; }
  70%  { transform: translateX(3px); opacity: 1; }
  100% { transform: translateX(-4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sys-tab-appear { animation: none !important; }
}

/* ── EVIDENCE TALLY — the little red count on the GALLERY tab,
     same family as the mail badge: a red stamp-dot with a number.
     Bumps when the paper clips new evidence in. */
.sys-tab-badge {
  display: none;
  position: absolute;
  top: -7px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  background: #8B0000;
  color: #EBE6D8;
  border: 1px solid #5a0000;
  border-radius: 50%;
  font-size: 9px;
  font-weight: bold;
  line-height: 15px;
  text-align: center;
  letter-spacing: 0;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
}

.sys-tab-badge.sys-tab-badge-on { display: block; }

.sys-tab-badge.sys-tab-badge-bump {
  animation: sysBadgeBump 0.8s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes sysBadgeBump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.7); }
  70%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .sys-tab-badge.sys-tab-badge-bump { animation: none; }
}

/* MENU and BUG — the two tabs under CONFIG (js/system-tabs-menu.js). */
.sys-tab-menu .sys-tab-stamp { background: #3A3238; }
.sys-tab-bug  .sys-tab-stamp { background: #8B0000; }
