/* ============================================================================
   CHAT-NWAR overlay — style.css
   Design system: "noir sur blanc, retro-tech, sobre, simple".
   STRICTLY black & white. Sharp corners. 2px black borders. Geist Pixel font.
   One allowed effect: a HARD pixel shadow (3px 3px 0 #0a0a0a), used sparingly
   and driven by --hype so the overlay still reacts to sound — but stays sober.

   OBS Browser Source: the page itself stays fully TRANSPARENT. Only the little
   white message boxes + the thin meter/pill paint over the game.
   ========================================================================== */

/* ---- Font ----------------------------------------------------------------- */
@font-face {
  font-family: 'Geist Pixel';
  src: url('geistpixel.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

/* ---- Theme tokens --------------------------------------------------------- */
:root {
  /* Live values (JS overrides these). */
  --hype: 0;                 /* 0..1 audio hype level, smoothed in JS          */
  --width: 420px;            /* column width (?width=)                         */
  --pad: 26px;               /* breathing room from the screen edge           */
  --aura-x: 82%;             /* kept for JS compatibility (aura is inert now)  */

  /* Message enter animation — JS tightens these as hype rises. */
  --msg-dur: 340ms;          /* slide/fade duration                           */
  --msg-rise: 11px;          /* how far a new line rises into place           */
  --row-gap: 8px;            /* vertical gap between rows                      */

  /* Monochrome palette. */
  --ink:  #0a0a0a;           /* text, borders, icons                          */
  --soft: #5a5a5a;           /* secondary labels / separators                 */
  --white:#ffffff;           /* box fills                                     */

  --font: 'Geist Pixel', 'Courier New', monospace;

  color-scheme: light;
}

/* ---- Page: transparent, no scroll, no selection --------------------------- */
html, body {
  margin: 0;
  height: 100%;
  background: transparent !important;   /* critical for OBS transparency      */
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  cursor: default;
  user-select: none;
}

/* ---- Overlay frame: pins the column to a bottom corner -------------------- */
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  padding: var(--pad);
  box-sizing: border-box;
  pointer-events: none;               /* never intercept clicks in OBS         */
  flex-direction: column;
  align-items: flex-end;              /* right side by default (align=right)   */
}
#overlay[data-align="left"]  { align-items: flex-start; }
#overlay[data-align="right"] { align-items: flex-end; }

/* ---- Shake wrapper: carries the high-hype screen-shake -------------------- */
#shake {
  position: relative;
  width: var(--width);
  max-width: calc(100vw - var(--pad) * 2);
  max-height: calc(100vh - var(--pad) * 2);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;          /* stack sits at the bottom             */
  will-change: transform;
  transform: translateZ(0);
}

/* ---- Aura: retired. Kept in the DOM for compatibility, paints nothing.
   (The design forbids glow/blur — hype reactivity now lives on the boxes.) -- */
#aura { display: none; }

/* ============================================================================
   CHAT COLUMN
   ========================================================================== */
#chat {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;          /* newest (last child) hugs the bottom   */
  gap: var(--row-gap);
  min-height: 0;
  overflow: hidden;                   /* clip old rows scrolling off the top   */
  padding: 4px 6px 12px;              /* room for the pixel shadow             */
  /* Soft top fade so retired messages dissolve instead of hard-cutting. */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 64px);
          mask-image: linear-gradient(to bottom, transparent 0, #000 64px);
}
#overlay[data-align="left"] #chat { align-items: flex-start; }

/* ---- A single message row: a white box, sharp corners, 2px black border --- */
.msg {
  position: relative;
  align-self: stretch;
  max-width: 100%;
  box-sizing: border-box;
  padding: 7px 11px 8px;
  border: 2px solid var(--ink);
  border-radius: 0;                   /* SHARP corners                         */
  background: var(--white);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  /* Constant hard pixel shadow for a sober retro depth. */
  box-shadow: 2px 2px 0 var(--ink);
  /* Slide + fade in. */
  animation: msgIn var(--msg-dur) cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(var(--msg-rise)); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Row inner pieces (all inline so the line wraps like a paragraph) ----- */
.msg-badges { display: inline; margin-right: 3px; white-space: nowrap; }

/* Username: bold black. Overrides the inline per-user colour from app.js. */
.msg-user {
  font-weight: 700;
  color: var(--ink) !important;
}
.msg-colon { color: var(--soft); margin: 0 6px 0 1px; font-weight: 700; }
.msg-body  { color: var(--ink); }

/* ---- Badges: tiny black bracketed labels, e.g. [SUB] ---------------------- */
.badge {
  display: inline;
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--ink);
  margin-right: 3px;
  white-space: nowrap;
}
.badge::before { content: "["; }
.badge::after  { content: "]"; }

/* ---- Emotes: small INVERTED chips (black box, white text) ----------------- */
.pill {
  display: inline-block;
  padding: 0 5px;
  margin: 0 1px;
  background: var(--ink);
  color: var(--white);
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  line-height: 1.55;
  vertical-align: 1px;
  border-radius: 0;
}

/* Emoji-style emote fallback (no longer emitted, kept harmless & monochrome). */
.emote { font-style: normal; filter: grayscale(1); }

/* 7TV image emotes — animated, full-colour, sized to sit on the text baseline. */
.emote-img {
  display: inline-block;
  height: 1.9em;
  width: auto;
  max-width: 3.4em;
  margin: -0.35em 1px;      /* let tall emotes overlap padding without growing the row much */
  vertical-align: middle;
  object-fit: contain;
  image-rendering: auto;    /* colour bitmaps: keep smooth, not pixelated */
}

/* ============================================================================
   SYSTEM LINE — a small black-bordered pill, centered, auto-fading.
   ========================================================================== */
#system {
  align-self: center;
  max-width: 92%;
  margin-top: 10px;
  padding: 5px 12px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--white);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: center;
  box-shadow: 3px 3px 0 var(--ink);   /* hard pixel shadow, used sparingly     */
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 260ms ease, transform 260ms ease;
  pointer-events: none;
}
#system.show { opacity: 1; transform: translateY(0); }

/* ============================================================================
   CONNECTION PILL — invisible unless the socket is down.
   ========================================================================== */
#conn-pill {
  position: fixed;
  top: 12px;
  right: 12px;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--white);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  box-shadow: 3px 3px 0 var(--ink);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none;
}
#conn-pill[data-state="down"] {
  opacity: 1;
  transform: translateY(0);
}
#conn-pill[data-state="down"]::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  vertical-align: 0;
  background: var(--ink);             /* small black square, blinks            */
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---- Respect reduced-motion: calm the moving parts ------------------------ */
@media (prefers-reduced-motion: reduce) {
  #conn-pill[data-state="down"]::before { animation: none; }
  .msg { animation-duration: 160ms; }
}
