/* Lootcamp base: reset, typography, shared controls. Component layout lives in each component's .razor.css. */

*, *::before, *::after { box-sizing: border-box; }

/* Voice tab strip shown (docs/MULTI-VOICE.md §5.1): the stage layer starts under it. Without :has() shell.js sets the same value. */
:root:has(.voice-tabs) { --voice-tabs-h: 40px; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg-chat);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
}

#app { height: 100%; }

/* Desktop window with its own title bar (docs/NOTIFICATIONS.md §5.7): #app starts under the bar, and contain: layout makes it
   the containing block of every position: fixed descendant, so modals, popovers, toasts, the voice stage layer, scrims and
   drawers land under the bar without per-overlay offsets. Web and native frames: no attribute, nothing changes. */
html[data-frame='custom'] #app {
  position: fixed;
  inset: var(--titlebar-h) 0 0 0;
  height: auto;
  contain: layout;
}

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { font-weight: 680; letter-spacing: var(--tracking-tight); line-height: var(--lh-tight); }

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
img { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }

::selection { background: var(--accent-soft); }

/* Keyboard focus: visible everywhere, never on mouse click. */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus-color); outline-offset: 2px; border-radius: var(--r-xs); }

/* Scrollbars: thin, tinted. */
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* Icons (lucide sprite symbols inherit these). */
.icon {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}

.spin { animation: md-spin 0.9s linear infinite; }
@keyframes md-spin { to { transform: rotate(360deg); } }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 16px;
  border-radius: var(--r-md);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1), box-shadow var(--dur-1), transform var(--dur-1);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: var(--fs-sm); }
.btn-block { width: 100%; }

.btn-primary { background: var(--accent); color: var(--text-on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary { background: var(--bg-input); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-active); }

.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--bg-hover); }

.btn-danger { background: var(--danger-bg); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }

.btn-danger-ghost { color: var(--danger-text); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  color: var(--text-muted);
  transition: background-color var(--dur-1), color var(--dur-1);
}
.icon-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.icon-btn[aria-pressed='true'] { color: var(--danger-text); }
.icon-btn.active { color: var(--text); background: var(--bg-active); }

.link-btn { color: var(--accent-text); font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

/* ── Forms ── */
.field { display: grid; gap: 6px; }
.field + .field { margin-top: 16px; }
.label { font-size: var(--fs-sm); font-weight: 620; color: var(--text-muted); }
.label .req { color: var(--danger-text); margin-left: 2px; }
.hint { font-size: var(--fs-xs); color: var(--text-faint); }

.input, .textarea, .select {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: var(--fs-base);
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--border-strong); }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible {
  outline: none;
  border-color: var(--focus-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus-color) 25%, transparent);
}
.textarea { resize: vertical; min-height: 80px; line-height: var(--lh-base); }
.input.invalid, .textarea.invalid, .select.invalid,
.input.modified.invalid { border-color: var(--danger); }
.select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }

.validation-message, .field-error { color: var(--danger-text); font-size: var(--fs-sm); }
.validation-errors { margin: 0 0 12px; padding: 0; list-style: none; color: var(--danger-text); font-size: var(--fs-sm); }

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }

.color-input { width: 44px; height: 40px; padding: 2px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--bg-input); cursor: pointer; }

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  background: var(--danger-soft);
  color: var(--danger-text);
}
.alert.info { background: var(--accent-soft); color: var(--text); }
.alert.success { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--text); }

/* ── Badges (unread / mention counters, live tag) ── */
.badge-count {
  display: inline-grid;
  place-items: center;
  flex: none;
  min-width: var(--badge-min-w);
  height: var(--badge-h);
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--badge-bg);
  color: var(--badge-fg);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.badge-dot {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text);
}
.live-badge {
  display: inline-block;
  flex: none;
  padding: 1px 5px;
  border-radius: var(--r-xs);
  background: var(--live-bg);
  color: var(--live-fg);
  font-size: 10px;
  font-weight: 760;
  line-height: 1.3;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Lock mark in the corner of a channel icon (private channel): stack the hash and a small lock. */
.icon-lock {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
}
.icon-lock .lock-mark {
  position: absolute;
  right: -4px;
  bottom: -3px;
  width: var(--lock-size);
  height: var(--lock-size);
  padding: 1px;
  border-radius: 50%;
  background: var(--ring, var(--bg-sidebar)); /* the row surface: sidebar, or chat on the selected tab */
  stroke-width: 2.5;
}

/* Thread indent: anything that lists threads under a channel (sidebar rows, panels) aligns to the same column. */
.thread-indent { padding-left: var(--thread-indent); }

/* ── Video tiles (voice stage: camera / screen-share grid) ── */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-min), 1fr));
  gap: var(--tile-gap);
  align-content: center;
}
.video-tile {
  position: relative;
  aspect-ratio: var(--tile-ratio);
  overflow: hidden;
  border-radius: var(--tile-radius);
  background: var(--tile-bg);
  color: var(--tile-fg);
  box-shadow: inset 0 0 0 1px var(--tile-border);
  transition: box-shadow var(--dur-1);
}
.video-tile.speaking { box-shadow: inset 0 0 0 2px var(--tile-speaking); }
.video-tile.focused { grid-column: 1 / -1; }
.video-tile > video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.video-tile .tile-label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 16px);
  padding: 3px 8px;
  border-radius: var(--r-sm);
  background: rgba(6, 12, 13, 0.6);
  color: #eef3f1;
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 767px) {
  .video-grid { grid-template-columns: repeat(2, 1fr); align-content: start; }
  .video-tile.focused { grid-column: 1 / -1; }
}

/* ── Skeletons ── */
.skeleton {
  display: block;
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--skeleton-a) 0%, var(--skeleton-b) 40%, var(--skeleton-a) 80%);
  background-size: 300% 100%;
  animation: md-shimmer 1.4s ease-in-out infinite;
}
.skeleton.circle { border-radius: 50%; }
@keyframes md-shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }

/* ── Tooltip layer (positioned by js/app.js) ── */
.md-tooltip {
  position: fixed;
  z-index: var(--z-tooltip);
  max-width: 260px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: #0a1012;
  color: #eef3f1;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.3;
  pointer-events: none;
  box-shadow: var(--shadow-float);
  opacity: 0;
  transform: scale(0.96);
  transition: opacity var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.md-tooltip.visible { opacity: 1; transform: none; }

/* Message flash when jumping to a replied message (js/app.js adds the class). */
.md-flash { animation: md-flash 1.6s var(--ease-out); }
@keyframes md-flash { 0%, 30% { background: var(--accent-soft); } 100% { background: transparent; } }

/* ── Boot screen (index.html, before Blazor starts) and splash ── */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg-rail);
  color: var(--text-muted);
}
.boot-inner { display: grid; justify-items: center; gap: 18px; }
.boot-mark { width: 64px; height: 64px; animation: md-breathe 1.8s ease-in-out infinite; }
.boot-text { font-size: var(--fs-sm); letter-spacing: 0.01em; }
.boot-bar { width: 140px; height: 3px; border-radius: 3px; background: var(--skeleton-a); overflow: hidden; }
.boot-bar::after {
  content: '';
  display: block;
  height: 100%;
  width: calc(var(--blazor-load-percentage, 30%) * 1);
  background: var(--accent);
  border-radius: 3px;
  transition: width var(--dur-2) var(--ease-out);
}
@keyframes md-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(0.92); } }

/* ── Desktop window title bar (WindowTitleBar and its static copy in the desktop index.html; docs/NOTIFICATIONS.md §5.5) ──
   Every rule is bound to html[data-frame=custom]: on macOS/Linux, with --native-frame and on the web the static copy never shows,
   not even before Blazor starts. #lootcamp-titlebar comes after #app in the DOM, so Tab reaches the window buttons last. */
html:not([data-frame='custom']) #lootcamp-titlebar,
html:not([data-frame='custom']) .titlebar { display: none; }

html[data-frame='custom'] .titlebar {
  position: fixed;
  top: 0;
  inset-inline: 0;
  z-index: var(--z-titlebar);
  display: flex;
  align-items: center;
  height: var(--titlebar-h);
  background: var(--titlebar-bg);
  color: var(--titlebar-fg);
  font-size: var(--fs-sm);
  line-height: 1;
  -webkit-app-region: drag;
  app-region: drag;
  user-select: none;
}
/* Full screen: out of the layout together with its native drag region (§5.9), or it would swallow clicks on the video. */
html[data-frame='custom'][data-fullscreen] .titlebar { display: none; }

html[data-frame='custom'] .titlebar-logo { flex: none; width: 16px; height: 16px; margin: 0 8px 0 12px; }
html[data-frame='custom'] .titlebar-title { font-weight: 620; letter-spacing: 0.01em; white-space: nowrap; }

html[data-frame='custom'] .titlebar-buttons {
  display: flex;
  align-self: stretch;
  margin-left: auto;
}
html[data-frame='custom'] .titlebar-buttons button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 100%;
  color: inherit;
  border-radius: 0;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}
html[data-frame='custom'] .titlebar-buttons button:hover { background: var(--titlebar-hover); color: var(--text); }
html[data-frame='custom'] .titlebar-buttons button:active { background: var(--titlebar-pressed); }
html[data-frame='custom'] .titlebar-buttons button.close:hover,
html[data-frame='custom'] .titlebar-buttons button.close:active { background: var(--titlebar-close-hover); color: #fff; }
html[data-frame='custom'] .titlebar-buttons button:focus-visible { outline-offset: -2px; border-radius: 0; }
/* 10px window glyphs (sprite symbols win-*) are drawn with a crisp 1px stroke. */
html[data-frame='custom'] .titlebar .icon { stroke-width: 1; stroke-linecap: butt; stroke-linejoin: miter; }

/* Inactive window: dimmed text and glyphs. The component marks the bar, desktop.js marks <html> for the static copy. */
html[data-frame='custom'][data-window-active='false'] .titlebar,
html[data-frame='custom'] .titlebar[data-window-active='false'] { color: var(--titlebar-fg-inactive); }

/* Top line on Windows 10 only (DWM draws no top border there; on Windows 11 it draws the whole frame and a line would double).
   --titlebar-accent is set only when the user turned on colored window borders; an inactive window always gets the neutral line. */
html[data-frame='custom'][data-os='win10'] .titlebar { box-shadow: inset 0 1px 0 var(--titlebar-accent, var(--titlebar-border)); }
html[data-frame='custom'][data-os='win10'][data-window-active='false'] .titlebar,
html[data-frame='custom'][data-os='win10'] .titlebar[data-window-active='false'] { box-shadow: inset 0 1px 0 var(--titlebar-border); }
/* A maximized window has no border at all (native Windows 10 windows draw no top line either). */
html[data-frame='custom'][data-window-maximized='true'] .titlebar,
html[data-frame='custom'] .titlebar[data-window-maximized='true'] { box-shadow: none; }

/* Resize strips for the top edge and corners (the other edges are native borders). They lie above the buttons but take only
   their top 5px there: the right corner covers the top 5px of "Закрыть", the rest of it stays clickable. Hidden when the
   window is maximized, so the top pixel of the buttons is clickable (Fitts: "Закрыть" in the screen corner). */
html[data-frame='custom'] .titlebar-resize {
  position: absolute;
  top: 0;
  z-index: 1;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}
html[data-frame='custom'] .titlebar-resize.top { left: 8px; right: 8px; height: 5px; cursor: ns-resize; }
html[data-frame='custom'] .titlebar-resize.top-left { left: 0; width: 8px; height: 8px; cursor: nwse-resize; }
html[data-frame='custom'] .titlebar-resize.top-right { right: 0; width: 8px; height: 5px; cursor: nesw-resize; }
html[data-frame='custom'][data-window-maximized='true'] .titlebar-resize,
html[data-frame='custom'] .titlebar[data-window-maximized='true'] .titlebar-resize { display: none; }

#blazor-error-ui {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 1000;
  display: none;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--danger-bg);
  color: #fff;
  font-size: var(--fs-md);
  box-shadow: var(--shadow-float);
}
#blazor-error-ui a { color: #fff; text-decoration: underline; margin-left: 8px; }
#blazor-error-ui .dismiss { cursor: pointer; margin-left: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  .skeleton { animation: none; background: var(--skeleton-b); }
  .boot-mark { animation: none; }
}

/* ── Message markup (rendered by MessageContent / MarkupInlines from the parser AST) ── */
.md-p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.md-quote {
  margin: 2px 0;
  padding: 0 0 0 12px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.md-code {
  padding: 1px 5px;
  border-radius: var(--r-xs);
  background: var(--code-bg);
  box-shadow: inset 0 0 0 1px var(--code-border);
  font-family: var(--font-mono);
  font-size: 0.85em;
}
.md-link { color: var(--accent-text); overflow-wrap: anywhere; }
.md-link:hover { text-decoration: underline; }
.mention {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  padding: 0 3px;
  border-radius: var(--r-xs);
  background: var(--mention-bg);
  color: var(--accent-text);
  font-weight: 600;
  font-size: inherit;
  line-height: inherit;
  vertical-align: baseline;
  transition: background-color var(--dur-1);
}
.mention:hover { background: var(--mention-hover); text-decoration: none; }
.mention .icon { align-self: center; }
.mention.me { background: var(--accent); color: var(--text-on-accent); }
.mention.muted { background: var(--bg-hover); color: var(--text-muted); font-weight: 500; }
/* Role chips (docs/NOTIFICATIONS.md §3.8). A role without a color keeps the standard mention look (.mention / .mention.me).
   --role-text-dark / --role-text-light come from Safe.MentionTextColor: var(--text) where the role color would read below 4.5:1. */
.mention.role { cursor: default; }
.mention.role.colored {
  --role-text: var(--role-text-dark, var(--role-color));
  background: color-mix(in srgb, var(--role-color) 18%, transparent);
  color: var(--role-text);
}
:root[data-theme='light'] .mention.role.colored { --role-text: var(--role-text-light, var(--role-color)); }
.mention.role.colored:hover { background: color-mix(in srgb, var(--role-color) 28%, transparent); }
/* Explicit: .mention.me would otherwise paint the chip in --accent. The role color stays, "it is me" is the outline. */
.mention.role.me { box-shadow: inset 0 0 0 1px var(--accent); }
.mention.role.colored.me,
.mention.role.colored.me:hover { background: color-mix(in srgb, var(--role-color) 35%, transparent); color: var(--role-text); }
/* Not counted (the author could not mention the role): muted, no hover. */
.mention.role.inert,
.mention.role.inert:hover { background: var(--bg-hover); color: var(--text-muted); box-shadow: none; cursor: default; }
/* @all / @online chips. */
.mention.group { cursor: default; }

/* Switch built on a native checkbox (role="switch"): keyboard and screen readers work as usual. */
.switch {
  appearance: none;
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  margin: 0;
  border-radius: var(--r-pill);
  background: var(--border-strong);
  cursor: pointer;
  transition: background-color var(--dur-2) var(--ease-out);
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform var(--dur-2) var(--ease-spring);
}
.switch:checked { background: var(--success); }
.switch:checked::after { transform: translateX(16px); }

/* ── Auth screens ── */
/* Shared by the sign-in, registration and invite screens (rendered inside AuthLayout). */
.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 32px;
  border-radius: var(--r-lg);
  background: var(--bg-raised);
  box-shadow: var(--shadow-float);
  animation: auth-in var(--dur-3) var(--ease-out);
}

.auth-card h1 {
  font-size: var(--fs-2xl);
  font-weight: 760;
  letter-spacing: -0.03em;
}

.auth-card .lead {
  margin: 6px 0 22px;
  color: var(--text-muted);
}

.auth-card .alert { margin-bottom: 16px; }

.auth-form .field + .field { margin-top: 16px; }
.auth-form .submit { margin-top: 24px; min-height: 44px; font-size: var(--fs-base); }

.password { position: relative; }
.password .input { padding-right: 92px; }
.password .reveal {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 8px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.password .reveal:hover { color: var(--text); background: var(--bg-hover); }

.switch-auth {
  margin-top: 18px;
  color: var(--text-muted);
  font-size: var(--fs-md);
}
.switch-auth a { font-weight: 650; }

@keyframes auth-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 480px) {
  .auth-card { padding: 24px 18px; box-shadow: none; }
}
