/* warserver content browser — shared styles */
:root {
  --bg: #0f1117;
  --bg-2: #161922;
  --bg-3: #1c2030;
  --line: #262b3a;
  --text: #d8dde8;
  --muted: #8a93a8;
  --accent: #6aa6ff;
  --accent-2: #ff8a4c;
  --warn: #ffc857;
  --good: #57d68d;
  --danger: #ff6b6b;
}
* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--text); }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font: 12.5px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* Top bar */
#topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 18px; padding: 10px 16px;
}
#topbar .brand {
  font-weight: 700; letter-spacing: .02em; color: #fff;
}
#topbar .brand .dim { color: var(--muted); font-weight: 500; }
#topbar nav { display: flex; gap: 14px; flex-wrap: wrap; }
#topbar nav a {
  color: var(--text); opacity: .8; padding: 4px 8px; border-radius: 6px;
}
#topbar nav a:hover { background: var(--bg-3); opacity: 1; text-decoration: none; }
#topbar nav a.active { background: var(--bg-3); color: #fff; opacity: 1; }
#topbar .search {
  margin-left: auto; position: relative;
}
#topbar .search input {
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; min-width: 240px; font: inherit;
}
#topbar .search input:focus { outline: 1px solid var(--accent); }
/* Кнопка-гамбургер: видна только на узком экране (правила в блоке @media ниже). */
#topbar .menu-btn {
  display: none; background: var(--bg-3); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; font: inherit; cursor: pointer; line-height: 1;
}
#search-results {
  position: absolute; top: 100%; right: 0; margin-top: 4px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 6px; max-height: 60vh; overflow: auto;
  min-width: 360px; box-shadow: 0 8px 24px #0008;
}
#search-results .row {
  padding: 6px 10px; cursor: pointer; border-bottom: 1px solid var(--line);
}
#search-results .row:last-child { border-bottom: 0; }
#search-results .row:hover { background: var(--bg-3); }
#search-results .row .file { color: var(--muted); font-size: 12px; }

/* Layout */
main { max-width: 1400px; margin: 0 auto; padding: 18px 16px 48px; }
h1, h2, h3 { color: #fff; }
h1 { font-size: 22px; margin: 8px 0 16px; }
h2 { font-size: 18px; margin: 24px 0 10px; }
h3 { font-size: 15px; margin: 0 0 6px; }

.card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px;
}
.cards-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* Section landing tiles */
.tiles {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.tile {
  display: block; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; color: var(--text);
}
.tile:hover { background: var(--bg-3); text-decoration: none; }
.tile h3 { margin: 0 0 4px; }
.tile p { margin: 0; color: var(--muted); font-size: 13px; }
.tile .count { float: right; color: var(--accent); font-weight: 600; }

/* Generic grid item with thumbnail */
.thumb-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.thumb {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column;
}
.thumb:hover { border-color: var(--accent); }
.thumb .img {
  aspect-ratio: 1 / 1; background: #0a0c12 center/contain no-repeat;
  image-rendering: -webkit-optimize-contrast;
}
.thumb .label {
  padding: 6px 8px; font-size: 12px; line-height: 1.3;
}
.thumb .label .id { color: var(--muted); font-size: 11px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
table th, table td {
  border-bottom: 1px solid var(--line);
  padding: 6px 10px; text-align: left; vertical-align: top;
}
table th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:hover td { background: var(--bg-3); }

/* Tag / pill */
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--bg-3); color: var(--muted);
  font-size: 11px; margin-right: 4px;
}
.tag.warn { background: #3a2c10; color: var(--warn); }
.tag.good { background: #143a25; color: var(--good); }
.tag.bad  { background: #3a1414; color: var(--danger); }

/* Filters bar */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px;
}
.filters input, .filters select {
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 8px; font: inherit;
}
.filters input:focus, .filters select:focus { outline: 1px solid var(--accent); }

/* YAML tree viewer */
.yml-tree {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px;
}
.yml-tree details { margin: 2px 0; }
.yml-tree summary {
  cursor: pointer; list-style: none; padding: 1px 0;
}
.yml-tree summary::-webkit-details-marker { display: none; }
.yml-tree summary::before {
  content: '▸'; display: inline-block; width: 14px;
  color: var(--muted); transform: translateY(-1px);
}
.yml-tree details[open] > summary::before { content: '▾'; }
.yml-tree .key   { color: #c8d3e6; }
.yml-tree .val-s { color: #b7e0a3; }
.yml-tree .val-n { color: #f3c969; }
.yml-tree .val-b { color: #ff97c4; }
.yml-tree .val-z { color: var(--muted); font-style: italic; }
.yml-tree ul { list-style: none; margin: 0; padding-left: 16px; border-left: 1px dashed var(--line); }
.yml-tree li { padding: 1px 0; }

/* Misc */
.muted { color: var(--muted); }
.row-flex { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.row-flex > * { min-width: 0; }

/* Async art loader (lib/art.js).
   Any element that hosts a background-image resolved asynchronously gets a
   loading state via these classes. The spinner is positioned inside the
   element using its existing layout — works for both flex-centered and
   non-flex hosts because of position:relative on the spinner. */
.art-mounting, .art-loading { position: relative; overflow: hidden; }
/* Hide any placeholder/"арт не найден" text inside the host while the image is
   still loading — only show it on the explicit missing/error states. The
   existing per-page rules for .has-art (color: transparent) already cover the
   success case. */
.art-mounting, .art-mounting *,
.art-loading,  .art-loading *  { color: transparent !important; }
.art-spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.12);
  border-top-color: var(--accent);
  animation: art-spin .8s linear infinite;
  pointer-events: none;
  align-self: center; margin: auto;
}
@keyframes art-spin { to { transform: rotate(360deg); } }
.art-loading {
  /* faint shimmer to make it obvious something is loading even before the
     spinner appears (and as a backdrop while it spins) */
  background-color: rgba(255,255,255,.03);
}
.art-loading::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg,
    transparent 30%, rgba(255,255,255,.06) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: art-shimmer 1.4s linear infinite;
  border-radius: inherit;
}
@keyframes art-shimmer { from { background-position: 200% 0 } to { background-position: -200% 0 } }
.art-error { outline: 1px dashed var(--danger); }

.spinner { color: var(--muted); padding: 16px 0; }
.empty { color: var(--muted); padding: 32px 8px; text-align: center; }
.kbd { background: var(--bg-3); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 6px; font-size: 11px; }

video { max-width: 100%; border-radius: 8px; background: #000; }
img.portrait { max-width: 220px; border-radius: 8px; }
.portrait { width: 220px; min-height: 280px; border-radius: 8px; background:#1a1a2a center/contain no-repeat; }
.portrait.has-art { background-size: contain; }
.portrait.empty { display:flex; align-items:center; justify-content:center; color:#666; }
.inline-icon { display:inline-block; width:24px; height:24px; vertical-align:middle; background:#1a1a2a no-repeat center/cover; border-radius:4px; }
.data-table { width:100%; border-collapse:collapse; }
.data-table th, .data-table td { border:1px solid #2a2a3a; padding:4px 8px; text-align:left; }

/* ── Телефон (≤ 820px) ───────────────────────────────────────────────────────
   Шапка складывается: слева логотип, справа кнопка-гамбургер, меню раскрывается
   на всю ширину под ними. Поиск уезжает в раскрытое меню. Таблицы и графики
   прокручиваются вбок сами, чтобы страница не растягивалась. */
@media (max-width: 820px) {
  #topbar {
    flex-wrap: wrap; gap: 10px; padding: 8px 12px;
    align-items: center;
  }
  #topbar .brand { flex: 1 1 auto; font-size: 15px; }
  #topbar .menu-btn { display: block; flex: 0 0 auto; order: 2; }

  /* Меню и поиск — вторая строка, скрыты пока не нажат гамбургер. */
  #topbar nav, #topbar .search {
    order: 3; flex-basis: 100%; margin-left: 0;
  }
  #topbar:not(.open) nav, #topbar:not(.open) .search { display: none; }
  #topbar nav {
    flex-direction: column; gap: 2px;
    max-height: 60vh; overflow-y: auto;
    border-top: 1px solid var(--line); padding-top: 8px;
  }
  #topbar nav a { padding: 10px 8px; border-radius: 8px; }
  #topbar .search input { width: 100%; min-width: 0; }
  #search-results { left: 0; right: 0; min-width: 0; }

  main { padding: 12px 12px 40px; }
  h1 { font-size: 19px; }
  h2 { font-size: 17px; }

  /* Широкие таблицы и полосы фильтров — горизонтальная прокрутка вместо разъезда. */
  table { display: block; overflow-x: auto; white-space: nowrap; }
  .toolbar, .controls { overflow-x: auto; }
  .toolbar select, .toolbar input, .controls select, .controls input { max-width: 46vw; }
  canvas, svg { max-width: 100%; }
  pre, .schema { overflow-x: auto; }
}
