/* q2web runtime UI styles
 * =======================
 * Allt UX-styling för lobbyn, topbaren och modalerna. Tidigare
 * inject:ades det här via injectStyles() i q2web-runtime.js — flyttat
 * till en egen fil så browsern kan cache:a det separat och diffar mot
 * runtime.js inte längre fylls med CSS-text.
 */

/* ── Login picker ─────────────────────────────────────────────── */
/* Form i mitten + recent-players-panel till höger.
 * Form:en behåller sin centrerade column-layout via column-flex inuti;
 * row-flex i wrappern lägger panelen vid sidan. align-items: flex-start
 * så panelen följer toppen av form:en, inte centreras vertikalt. */
#qweb-lobby-row {
  display: flex; flex-direction: row;
  align-items: flex-start; justify-content: center;
  gap: 32px; width: 100%;
}
#qweb-form {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; margin-top: 32px;
}
#qweb-recent-players {
  margin-top: 32px;
  width: 200px; min-width: 200px;
  border: 1px solid var(--border); background: #131313;
  padding: 14px 14px 12px;
  align-self: stretch; max-height: 360px;
  display: flex; flex-direction: column;
}
.qweb-recent-players-title {
  color: var(--dim); font-size: 10px;
  letter-spacing: 0.22em; text-transform: uppercase;
  padding-bottom: 10px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.qweb-recent-players-list {
  list-style: none; padding: 0; margin: 0;
  overflow-y: auto; flex: 1;
}
.qweb-recent-row {
  display: flex; flex-direction: column;
  padding: 6px 0;
  border-bottom: 1px dashed #1f1f1f;
}
.qweb-recent-row:last-child { border-bottom: 0; }
.qweb-recent-name {
  color: var(--fg); font-size: 13px;
  letter-spacing: 0.02em;
}
.qweb-recent-meta {
  display: flex; justify-content: space-between;
  margin-top: 2px;
}
.qweb-recent-source {
  color: var(--accent); font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase;
}
.qweb-recent-time {
  color: var(--dim); font-size: 10px;
}
.qweb-recent-empty {
  color: var(--dim); font-size: 11px; padding: 6px 0;
  font-style: italic;
}
/* Mobil/smal viewport: göm panelen helt — formen behöver hela bredden */
@media (max-width: 760px) {
  #qweb-recent-players { display: none; }
  #qweb-lobby-row { flex-direction: column; align-items: center; }
}
.qweb-label {
  color: var(--dim); font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase;
}
#qweb-name, #qweb-custom {
  background: #1c1c1c; border: 1px solid var(--border); color: var(--fg);
  padding: 10px 14px; font: inherit; outline: none; width: 312px;
  letter-spacing: 0.04em; text-align: center;
}
#qweb-name:focus, #qweb-custom:focus { border-color: var(--accent); }
#qweb-name.qweb-invalid { border-color: #c33; animation: qweb-shake 0.2s; }
@keyframes qweb-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.qweb-buttons {
  display: flex; flex-direction: column; gap: 6px; margin-top: 16px;
}
.qweb-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--fg); padding: 10px 24px; font: inherit; cursor: pointer;
  width: 312px; letter-spacing: 0.12em; font-weight: 600;
  opacity: 0.85;
  transition: opacity 0.15s, background 0.1s, border-color 0.1s,
              color 0.1s, box-shadow 0.15s, filter 0.1s;
  display: flex; justify-content: space-between; align-items: center;
}
.qweb-btn:hover, .qweb-btn:focus-visible {
  background: #1f1f1f; border-color: #555; opacity: 1;
}
.qweb-btn:active { background: #2a2a2a; }
.qweb-btn.qweb-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.qweb-btn.qweb-primary:hover {
  filter: brightness(1.12); background: var(--accent);
}
.qweb-btn.qweb-secondary { color: var(--dim); border-color: #2a2a2a; }
.qweb-btn.qweb-secondary:hover { color: var(--fg); }

/* Live state: spelare inne → full opacity + grön outline-glow.
   Offline → dimmad + not-allowed-cursor (men inte disabled, user
   kan ändå klicka för att starta första anslutningen). */
.qweb-btn:has(.qweb-btn-count.active) {
  opacity: 1;
  box-shadow: 0 0 0 1px rgba(127, 220, 127, 0.30),
              0 0 14px rgba(127, 220, 127, 0.14);
}
.qweb-btn:has(.qweb-btn-count.offline) { opacity: 0.5; }
.qweb-btn:has(.qweb-btn-count.offline):hover { opacity: 1; }

/* Hover-tooltip: ligger till höger om knappen, bygger på data-
   tooltip-attributet som startLobbyPoll() uppdaterar varje 5:e
   sekund. Pekar tillbaka mot knappen via en pseudo-pil. */
.qweb-btn[data-tooltip] { position: relative; }
.qweb-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 14px); top: 50%;
  transform: translateY(-50%) translateX(-6px);
  background: #1a1a1a;
  border: 1px solid #3a3a3a;
  padding: 9px 13px;
  white-space: pre-line;
  font-size: 11px; font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--fg);
  line-height: 1.5;
  text-transform: none;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 50;
  min-width: 220px; max-width: 280px;
}
.qweb-btn[data-tooltip]::before {
  content: ''; position: absolute;
  left: calc(100% + 8px); top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: #3a3a3a;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 51;
}
.qweb-btn[data-tooltip]:hover::after,
.qweb-btn[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
.qweb-btn[data-tooltip]:hover::before,
.qweb-btn[data-tooltip]:focus-visible::before {
  opacity: 1;
}

/* tabular-nums så siffror inte hoppar mellan poll-tickar, min-width
   så "offline"/"5/16"/"…" ger samma knapp-bredd. */
.qweb-btn-count {
  font-size: 11px; opacity: 0.7;
  font-weight: 400; letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  min-width: 50px; text-align: right;
  transition: opacity 0.15s, color 0.15s;
}
.qweb-btn-count.active { opacity: 1; color: #7fdc7f; }
.qweb-btn-count.offline { color: #777; font-style: italic; }
.qweb-primary .qweb-btn-count { color: #fff; }
.qweb-primary .qweb-btn-count.active { color: #fff; font-weight: 600; }

/* Player-roster: lista av spelare-namn som spelar just nu, renderas
   under knappen vid poll-tick (renderRoster). Helt dold när tom. */
.qweb-btn-roster {
  width: 312px;
  margin: 4px 0 -2px;
  padding: 0 4px;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: #7fdc7f;
  text-align: center;
  line-height: 1.4;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.25s ease, max-height 0.25s ease;
  word-break: break-word;
}
.qweb-btn-roster.visible {
  opacity: 0.85;
  max-height: 60px;
}

/* Fullscreen-hint som visas över canvas:en när game laddat men user
   inte är i fullscreen ännu. Subtil pill ovanför mitten av canvas:en —
   klickbar (samma effekt som F11). Stilas mot stage:n så den visas
   ovanför svart canvas-bakgrund. */
#qweb-fs-hint {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid #3a3a3a;
  padding: 16px 28px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg);
  cursor: pointer;
  user-select: none;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.3s ease, background 0.15s, border-color 0.15s;
}
#qweb-fs-hint.show {
  opacity: 1;
  pointer-events: auto;
}
#qweb-fs-hint:hover {
  background: rgba(40, 40, 40, 0.95);
  border-color: var(--accent);
}
#qweb-fs-hint kbd {
  background: #2a2a2a; border: 1px solid #4a4a4a;
  padding: 2px 8px; border-radius: 2px;
  color: var(--accent);
  font: inherit;
  margin: 0 4px;
}

/* Pref-rad i lobbyn (invert mouse + key bindings link på samma rad) */
.qweb-prefs-row {
  display: flex; align-items: center; justify-content: space-between;
  width: 312px;
  margin-top: 6px;
  padding: 0 4px;
}

/* Native-checkbox style i lobbyn (invert mouse etc.). Tic-box +
   text på sidan, knyts till input via <label for="..."> så hela raden
   är klickbar. */
.qweb-checkbox {
  display: flex; align-items: center; gap: 9px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}
.qweb-checkbox:hover { color: var(--fg); }
.qweb-checkbox input[type="checkbox"] {
  width: 14px; height: 14px;
  margin: 0; flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Inline link-button (text-länk-stil) */
.qweb-link-btn {
  background: transparent; border: none;
  color: var(--accent);
  font: inherit; font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
  border-bottom: 1px dotted var(--accent);
  transition: color 0.15s, border-color 0.15s;
}
.qweb-link-btn:hover {
  color: #fff;
  border-bottom-color: #fff;
}

/* Lobby pref-toggles (notify, invert mouse, ...). Delar en CSS-klass
   för enhetlig look; specifika tillstånd som disabled hanteras av
   den enskilda toggle:n. */
.qweb-pref-toggle {
  margin-top: 8px;
  background: transparent; border: 1px solid var(--border);
  color: var(--dim);
  padding: 7px 12px; width: 312px;
  font: inherit; font-size: 11px; letter-spacing: 0.04em;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px; justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.qweb-pref-toggle:hover:not(:disabled) {
  color: var(--fg); border-color: #444; background: #1a1a1a;
}
.qweb-pref-toggle.on {
  color: #a3eaa3; border-color: rgba(127, 220, 127, 0.45);
  background: rgba(127, 220, 127, 0.06);
}
.qweb-pref-toggle.on:hover {
  background: rgba(127, 220, 127, 0.12);
}
.qweb-pref-toggle:disabled {
  opacity: 0.5; cursor: not-allowed;
}
.qweb-pref-icon { font-size: 13px; }
/* Första toggle:n får större margin från knapparna ovanför */
.qweb-pref-toggle:first-of-type { margin-top: 14px; }

#qweb-advanced-toggle {
  margin-top: 18px; color: var(--dim); font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase; cursor: pointer;
  user-select: none;
}
#qweb-advanced-toggle::after { content: ' ▾'; }
#qweb-advanced-toggle.open::after { content: ' ▴'; }
#qweb-advanced-toggle:hover { color: var(--fg); }
#qweb-advanced {
  display: none; flex-direction: column; align-items: center;
  gap: 6px; margin-top: 14px;
}
#qweb-advanced.open { display: flex; }
#qweb-recent { width: 312px; margin-top: 4px; }
#qweb-recent:empty { display: none; }
.qweb-recent-label {
  color: var(--dim); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; margin: 12px 0 6px; text-align: left;
}
.qweb-recent-list { display: flex; flex-direction: column; gap: 3px; }
.qweb-recent-row { display: flex; gap: 0; }
.qweb-recent-join {
  flex: 1; background: transparent; border: 1px solid #2a2a2a;
  color: var(--fg); padding: 7px 14px; font: inherit; cursor: pointer;
  text-align: left; letter-spacing: 0.04em; font-size: 12px;
  transition: background 0.1s, border-color 0.1s;
}
.qweb-recent-join:hover { background: #1a1a1a; border-color: #444; }
.qweb-recent-del {
  background: transparent; border: 1px solid #2a2a2a; border-left: none;
  color: var(--dim); padding: 7px 12px; font: inherit; cursor: pointer;
  font-size: 14px; line-height: 1;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}
.qweb-recent-del:hover {
  color: var(--accent); background: #1a1a1a; border-color: #553a3a;
}
.qweb-hint {
  margin-top: 12px; max-width: 312px; text-align: center;
  color: var(--dim); font-size: 11px; line-height: 1.5;
}
.qweb-hint a {
  color: var(--accent); text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}
.qweb-hint a:hover { color: #fff; border-bottom-color: #fff; }

/* ── Topbar mode-info ─────────────────────────────────────────── */
#qweb-mode-info {
  display: flex; align-items: center; gap: 8px;
  margin-left: 16px; font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase;
}
.qweb-mode-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}
.qweb-mode-dot[data-mode="battle"] { background: var(--accent); }
.qweb-mode-dot[data-mode="baseq2"] { background: #7fdc7f; }
.qweb-mode-dot[data-mode="local"]  { background: #888; }
.qweb-mode-label { color: var(--fg); font-weight: 600; }
.qweb-mode-host  { color: var(--dim); font-size: 10px; }

#btn-leave {
  background: transparent; border: 1px solid #553a3a;
  color: #c84a2c !important;
}
#btn-leave:hover {
  background: rgba(200, 74, 44, 0.1); border-color: var(--accent);
}
/* #btn-help ärver topbar button-stil (CONSOLE/FULLSCREEN-look) */

/* ── Help modal ───────────────────────────────────────────────── */
#qweb-help-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  display: flex; align-items: center; justify-content: center;
}
.qweb-help-content {
  background: var(--panel); border: 1px solid var(--border);
  padding: 28px 36px;
  min-width: 360px;
  width: min(95vw, 1100px);
  max-height: 90vh; overflow-y: auto;
}
.qweb-help-content h2 {
  margin: 0 0 22px; font-size: 16px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent);
}
.qweb-help-subtitle {
  color: var(--dim); font-weight: 400;
  letter-spacing: 0.08em; text-transform: none;
  font-size: 12px; margin-left: 6px;
}
.qweb-help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px 28px;
}
.qweb-help-section { min-width: 0; }
.qweb-help-section h3 {
  margin: 0 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #2a2a2a;
  font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent); font-weight: 600;
}
.qweb-help-content table {
  border-collapse: collapse; width: 100%; font-size: 12px;
}
.qweb-help-content th, .qweb-help-content td {
  padding: 5px 8px; text-align: left;
}
.qweb-help-content th {
  color: var(--dim); font-weight: 400;
  text-transform: uppercase; letter-spacing: 0.08em; font-size: 10px;
}
.qweb-help-content td { color: var(--fg); font-family: inherit; }
.qweb-help-content tr:nth-child(odd) td,
.qweb-help-content tr:nth-child(odd) th { background: #1a1a1a; }
.qweb-help-foot {
  margin: 16px 0 4px; font-size: 11px; line-height: 1.5;
  color: var(--dim); letter-spacing: 0.02em;
}
.qweb-help-foot code {
  background: #1c1c1c; padding: 1px 5px; border-radius: 2px;
  color: var(--fg); font-size: 11px;
}
.qweb-help-close {
  margin-top: 18px; width: 100%;
  background: transparent; border: 1px solid var(--border);
  color: var(--fg); padding: 8px; font: inherit; cursor: pointer;
  letter-spacing: 0.12em; font-weight: 600;
}
.qweb-help-close:hover { background: #1f1f1f; border-color: #555; }

/* ── Config editor modal ──────────────────────────────────────── */
#qweb-cfg-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  display: flex; align-items: center; justify-content: center;
}
.qweb-cfg-content {
  background: var(--panel); border: 1px solid var(--border);
  padding: 22px 26px; min-width: 560px; max-width: 720px;
  display: flex; flex-direction: column; gap: 12px;
}
.qweb-cfg-content h2 {
  margin: 0; font-size: 14px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent);
}
#qweb-cfg-select {
  background: #1c1c1c; color: var(--fg); border: 1px solid var(--border);
  padding: 8px 10px; font: inherit; outline: none;
}
#qweb-cfg-textarea {
  background: #0a0a0a; color: var(--fg); border: 1px solid var(--border);
  padding: 10px 12px; font: 12px ui-monospace, Menlo, Consolas, monospace;
  outline: none; min-height: 360px; max-height: 60vh; resize: vertical;
  white-space: pre; tab-size: 4;
}
#qweb-cfg-textarea:focus { border-color: var(--accent); }
#qweb-cfg-textarea[readonly] { color: var(--dim); background: #050505; }
.qweb-cfg-status {
  font-size: 11px; color: var(--dim); letter-spacing: 0.04em;
  min-height: 1.2em;
}
.qweb-cfg-buttons { display: flex; gap: 8px; justify-content: flex-end; }
.qweb-cfg-buttons button {
  background: transparent; border: 1px solid var(--border);
  color: var(--fg); padding: 8px 18px; font: inherit; cursor: pointer;
  letter-spacing: 0.1em; font-weight: 600;
}
.qweb-cfg-buttons button:hover { background: #1f1f1f; border-color: #555; }
.qweb-cfg-buttons button:disabled {
  opacity: 0.4; cursor: not-allowed;
}
.qweb-cfg-save-reload {
  background: var(--accent) !important;
  border-color: var(--accent) !important; color: #fff !important;
}
.qweb-cfg-save-reload:hover:not(:disabled) {
  filter: brightness(1.12);
}
#btn-config { font-weight: 600; }
