/* Backrooms UI skin for the persona chat, Simulator console, and town radio.
   Loaded after style.css so the existing DOM and application contracts stay intact. */

:root {
  --br-ui-dark: #151812;
  --br-ui-panel: #242820;
  --br-ui-raised: #30352a;
  --br-ui-line: rgba(201, 207, 177, 0.3);
  --br-ui-ink: #d8dec5;
  --br-ui-muted: #969d86;
  --br-ui-green: #afc48c;
  --br-ui-alert: #d8a18f;
}

body.chat-modal-open,
body.terminal-modal-open {
  overflow: hidden;
}

.payphone-call {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  display: grid;
  width: min(420px, calc(100vw - 40px));
  gap: 8px;
  padding: 15px;
  border: 1px solid #6d735f;
  border-left: 4px solid var(--br-ui-green);
  border-radius: 2px;
  color: var(--br-ui-ink);
  background: #20241d;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.62), inset 0 0 0 2px #171a15;
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.payphone-call[hidden] {
  display: none;
}

.payphone-call__eyebrow {
  margin: 0;
  color: var(--br-ui-muted);
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.13em;
}

.payphone-call h2 {
  margin: 0;
  color: #e3ebcd;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.04em;
}

.payphone-call__status {
  min-height: 2.7em;
  margin: 0;
  color: var(--br-ui-ink);
  font-size: 0.78rem;
  line-height: 1.45;
}

.payphone-call__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.payphone-call__button {
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid var(--br-ui-line);
  border-radius: 2px;
  color: var(--br-ui-ink);
  background: #30352a;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.04em;
}

.payphone-call__button--primary {
  border-color: #879572;
  color: #edf5d8;
  background: #3a4332;
}

.payphone-call__button--hangup {
  color: #f0d4cb;
  background: #3b2e29;
}

.payphone-call__button:hover:not(:disabled) {
  border-color: #b7c69e;
  background: #444c3d;
}

.payphone-call__button--hangup:hover:not(:disabled) {
  border-color: var(--br-ui-alert);
  background: #50372f;
}

.payphone-call__button:focus-visible {
  outline: 2px solid var(--br-ui-green);
  outline-offset: 2px;
}

.payphone-call__button:disabled {
  cursor: wait;
  opacity: 0.66;
}

.chat {
  top: 50%;
  right: auto;
  bottom: auto;
  left: 50%;
  z-index: 40;
  grid-template-columns: minmax(170px, 0.32fr) minmax(380px, 1fr);
  grid-template-rows: minmax(0, 1fr) auto auto;
  width: min(900px, calc(100vw - 40px));
  height: min(650px, calc(100dvh - 40px));
  max-height: none;
  overflow: hidden;
  border: 1px solid #666b59;
  border-radius: 3px;
  background: #20241d;
  box-shadow: 0 0 0 100vmax rgba(11, 12, 9, 0.78), 0 25px 75px rgba(0, 0, 0, 0.7), inset 0 0 0 3px #171a15;
  color: var(--br-ui-ink);
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  transform: translate(-50%, -50%);
}

.chat.is-open {
  display: grid;
}

.chat-head {
  position: relative;
  grid-row: 1 / 4;
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 18px;
  border-right: 1px solid var(--br-ui-line);
  border-bottom: 0;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.015) 0 1px, transparent 1px 4px),
    #1c2019;
}

.chat-head::before {
  display: block;
  color: var(--br-ui-muted);
  content: "ASSISTANCE UNIT 95";
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  line-height: 1.3;
}

.chat-avatar {
  order: 1;
  width: 100%;
  height: min(280px, 40vh);
  margin: 2px 0 5px;
  padding: 16px;
  border: 8px solid #393d34;
  border-radius: 9% / 6%;
  background:
    linear-gradient(rgba(165, 188, 134, 0.055) 50%, transparent 50%) 0 0 / 100% 4px,
    radial-gradient(circle at 50% 45%, #657257 0, #30392c 55%, #11150f 100%);
  box-shadow: inset 0 0 32px #090b08, 0 0 0 1px #0d0f0c;
  object-fit: contain;
  filter: grayscale(0.8) sepia(0.22) hue-rotate(40deg) saturate(0.58) brightness(0.9);
}

.chat-title {
  order: 2;
}

.chat-title::before {
  display: block;
  margin-bottom: 5px;
  color: var(--br-ui-muted);
  content: "HELP TERMINAL / ACTIVE";
  font-size: 0.62rem;
  letter-spacing: 0.1em;
}

.chat-title h2 {
  color: #e3ebcd;
  font-family: inherit;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
}

.chat-title p {
  margin-top: 5px;
  color: var(--br-ui-muted);
  font-size: 0.7rem;
  line-height: 1.45;
}

.chat-icon,
.chat-send {
  border: 1px solid var(--br-ui-line);
  border-radius: 2px;
  color: var(--br-ui-ink);
  background: #292e25;
  font-family: inherit;
}

.chat-head .chat-icon {
  order: 3;
  width: 100%;
  height: 36px;
  border-radius: 2px;
}

.chat-head #chatNew::after {
  margin-left: 7px;
  content: "NEW SESSION";
  font-size: 0.62rem;
  letter-spacing: 0.07em;
  vertical-align: 2px;
}

.chat-head #chatClose {
  order: 4;
}

.chat-head #chatClose::after {
  margin-left: 7px;
  content: "CLOSE TERMINAL";
  font-size: 0.62rem;
  letter-spacing: 0.07em;
  vertical-align: 2px;
}

.chat-icon:hover,
.chat-send:hover {
  border-color: #9da987;
  background: #3a4233;
}

.chat-icon:focus-visible,
.chat-send:focus-visible,
.chat-suggestion:focus-visible,
.chat-input:focus-visible,
.terminal-action:focus-visible,
.terminal-input:focus-visible {
  outline: 2px solid var(--br-ui-green);
  outline-offset: 2px;
}

.chat-messages {
  grid-column: 2;
  grid-row: 1;
  min-height: 0;
  padding: 18px;
  gap: 11px;
  scrollbar-color: #6f785f #1a1e18;
}

.chat-message {
  max-width: min(88%, 60ch);
  padding: 10px 12px;
  border: 1px solid var(--br-ui-line);
  border-radius: 2px;
  color: var(--br-ui-ink);
  background: #292e25;
  font-size: 0.88rem;
  line-height: 1.55;
}

.chat-message::before {
  display: block;
  margin-bottom: 5px;
  color: var(--br-ui-muted);
  font-size: 0.61rem;
  letter-spacing: 0.1em;
}

.chat-message.assistant {
  border: 1px solid var(--br-ui-line);
  border-left: 3px solid #71805e;
  border-radius: 2px;
  color: var(--br-ui-ink);
  background: #292e25;
}

.chat-message.assistant::before {
  content: "ASSISTANCE UNIT";
}

.chat[data-persona="cloppy"] .chat-message.assistant::before { content: "CLOPPY"; }
.chat[data-persona="clippo"] .chat-message.assistant::before { content: "CLIPPO"; }
.chat[data-persona="clampy"] .chat-message.assistant::before { content: "CLAMPY"; }

.chat-message.user {
  border-radius: 2px;
  border-right: 3px solid #a8b890;
  color: #182014;
  background: #a9b993;
}

.chat-message.user::before {
  color: #4d5942;
  content: "VISITOR";
}

.chat-message.error {
  border: 1px solid #8b5b50;
  border-radius: 2px;
  color: #f1c2b6;
  background: #382725;
}

.chat-message.error::before {
  color: var(--br-ui-alert);
  content: "CONNECTION ERROR";
}

.chat-suggestions {
  grid-column: 2;
  grid-row: 2;
  gap: 7px;
  padding: 0 18px 14px;
}

.chat-suggestion {
  padding: 7px 9px;
  border: 1px solid var(--br-ui-line);
  border-radius: 2px;
  color: #cad6b5;
  background: #252b21;
  font-family: inherit;
  font-size: 0.72rem;
  text-align: left;
}

.chat-suggestion:hover {
  border-color: #9da987;
  background: #3a4233;
}

.chat-compose {
  grid-column: 2;
  grid-row: 3;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--br-ui-line);
  background: #1b1f19;
}

.chat-compose::before {
  align-self: center;
  color: var(--br-ui-green);
  content: ">";
  font-weight: 700;
}

.chat-input {
  min-height: 44px;
  max-height: 120px;
  border: 1px solid #59604f;
  border-radius: 2px;
  color: #e3ebcd;
  background: #11140f;
  font-family: inherit;
  font-size: 0.88rem;
}

.chat-input:focus {
  border-color: var(--br-ui-green);
  box-shadow: 0 0 0 2px rgba(175, 196, 140, 0.15);
}

.chat-input::placeholder {
  color: #777f6b;
}

.chat-send {
  width: 58px;
  border-radius: 2px;
  color: #172012;
  background: var(--br-ui-green);
}

.chat.is-pending .chat-avatar {
  box-shadow: inset 0 0 32px #090b08, 0 0 0 1px #0d0f0c, 0 0 15px rgba(175, 196, 140, 0.2);
}

/* Simulator: the same old office hardware with a larger, readable phosphor area. */
.terminal {
  z-index: 45;
  background: rgba(11, 12, 9, 0.82);
  backdrop-filter: none;
}

.terminal-crt {
  width: min(1000px, 94vw);
  height: min(760px, 90dvh);
  border: 10px solid #393d34;
  border-radius: 12px;
  background: radial-gradient(130% 120% at 50% 45%, #182017, #090c08);
  color: #b7cd95;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.72), inset 0 0 90px rgba(0, 0, 0, 0.75), 0 0 0 1px #0e100d;
  text-shadow: none;
  animation: none;
}

.terminal-scanlines::before {
  opacity: 0.25;
}

.terminal-head {
  border-bottom-color: var(--br-ui-line);
  background: linear-gradient(180deg, rgba(175, 196, 140, 0.08), transparent);
}

.terminal-light {
  background: #a9bd8b;
  box-shadow: 0 0 8px rgba(175, 196, 140, 0.55);
  animation: none;
}

.terminal-title h2,
.terminal-input,
.terminal-line.user {
  color: #dce8c8;
}

.terminal-title p,
.terminal-line,
.terminal-prompt {
  color: #afc88e;
}

.terminal .chat-icon {
  border-color: var(--br-ui-line);
  color: var(--br-ui-ink);
  background: #292e25;
}

.terminal .chat-icon:hover,
.terminal .chat-send:hover {
  border-color: #9da987;
  background: #3a4233;
}

.terminal-messages {
  scrollbar-color: #71805e transparent;
}

.terminal-messages::-webkit-scrollbar-thumb {
  background: #667255;
}

.terminal-line.error {
  color: #e3a38d;
  text-shadow: none;
}

.terminal-action {
  border: 1px solid #758064;
  border-radius: 2px;
  color: #c8d8ad;
  background: #20291d;
  text-shadow: none;
}

.terminal-action:hover,
.terminal-action:focus,
.terminal-action.is-selected {
  color: #182014;
  background: #afc48c;
  box-shadow: none;
}

.terminal-action:disabled {
  cursor: wait;
  opacity: 0.5;
}

.terminal-compose {
  border-top-color: var(--br-ui-line);
  background: rgba(175, 196, 140, 0.035);
}

.terminal-input {
  caret-color: #afc48c;
}

.terminal-input::placeholder {
  color: rgba(175, 196, 140, 0.45);
}

/* Radio stays available but reads as a battered wall control. */
.music-toggle {
  border: 1px solid #6c715f;
  border-radius: 2px;
  color: #aeb99a;
  background: #292e25;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.38), inset 0 0 0 2px #1a1d17;
}

.music-toggle.is-on {
  color: #dce8c8;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.38), inset 0 0 0 2px #1a1d17;
  animation: none;
}

.music-panel {
  border: 1px solid #666b59;
  border-radius: 2px;
  background: rgba(31, 35, 28, 0.97);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.58);
}

.music-head,
.music-key {
  color: #959d85;
}

.music-row:hover,
.music-row.is-active {
  background: rgba(175, 196, 140, 0.11);
}

.music-row.is-active .music-name {
  color: #dce8c8;
}

@media (max-width: 700px) {
  .payphone-call {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }

  .payphone-call__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .chat {
    top: 9px;
    right: 9px;
    bottom: 9px;
    left: 9px;
    display: none;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 3px;
    transform: none;
  }

  .chat.is-open {
    display: grid;
  }

  .chat-head {
    grid-row: 1;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px 42px;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--br-ui-line);
  }

  .chat-head::before,
  .chat-title::before,
  .chat-title p {
    display: none;
  }

  .chat-avatar {
    order: initial;
    width: 42px;
    height: 42px;
    margin: 0;
    padding: 3px;
    border-width: 3px;
    border-radius: 3px;
  }

  .chat-title {
    order: initial;
  }

  .chat-head .chat-icon {
    order: initial;
    width: 42px;
    height: 42px;
    padding: 0;
  }

  .chat-head #chatNew::after,
  .chat-head #chatClose::after {
    display: none;
  }

  .chat-messages {
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
    padding: 12px;
  }

  .chat-message {
    max-width: 94%;
    font-size: 0.84rem;
  }

  .chat-suggestions {
    grid-column: 1;
    grid-row: 3;
    max-height: 92px;
    overflow-y: auto;
    padding: 0 12px 10px;
  }

  .chat-compose {
    grid-column: 1;
    grid-row: 4;
    padding: 10px;
  }

  .terminal {
    padding: 0;
  }

  .terminal-crt {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat *,
  .terminal *,
  .music *,
  .payphone-call * {
    animation: none !important;
    transition-duration: 0.001ms !important;
  }
}
