﻿/* —— Font ——————————————————————————————————————————————————————— */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,700;1,400&display=swap');

/* —— Reset —————————————————————————————————————————————————————— */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #EDEAE2;
  --surface: #F5F2EA;
  --ink:     #0D0D0D;
  --muted:   #888880;
  --rule:    #0D0D0D;
  --red:     #CC2800;
  --mono:    'IBM Plex Mono', 'Courier New', monospace;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--mono);
  background: #F0EDE5;
  color: var(--ink);
  line-height: 1.55;
  font-size: 13px;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0);    }
}
@keyframes slideIn {
  from { transform: translateY(14px); }
  to   { transform: translateY(0);    }
}

@keyframes panelExpand {
  from { opacity: 0; transform: translate(-50%, -50%) scaleX(0.12); }
  to   { opacity: 1; transform: translate(-50%, -50%) scaleX(1);    }
}
@keyframes contentIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes panelCollapse {
  from { opacity: 1; transform: translate(-50%, -50%) scaleX(1);    }
  to   { opacity: 0; transform: translate(-50%, -50%) scaleX(0.12); }
}
.graph-ui--exit {
  animation: panelCollapse 0.28s cubic-bezier(0.4, 0, 1, 1) both !important;
}

/* —— Graph (full-screen) ———————————————————————————————— */
#graph-view {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.graph-empty {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.25);
  font-family: var(--mono);
  letter-spacing: 0.08em;
}

/* —— Centered glass search ——————————————————————————————— */
.graph-ui {
  position: fixed;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  width: min(480px, 90vw);
  pointer-events: none;
  animation: panelExpand 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 0.12s;
}

/* Content fades in after the panel finishes expanding (0.12s + 0.55s = 0.67s) */
.graph-ui .glass-search-row {
  animation: contentIn 0.22s ease both;
  animation-delay: 0.67s;
}

.glass-panel {
  pointer-events: all;
  padding: 12px 18px;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 3px;
  box-shadow: 0 2px 18px rgba(0, 0, 0, 0.10);
}

.glass-search-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.glass-search-row svg {
  color: var(--muted);
  flex-shrink: 0;
}

.glass-search-row input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  min-width: 0;
}

.glass-search-row input::placeholder {
  color: var(--muted);
  letter-spacing: 0.1em;
}

.glass-count {
  font-size: 0.65rem;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
  letter-spacing: 0.06em;
}

/* Active filter pill — hidden until .has-filter added to .glass-panel */
.glass-active-filter {
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(0,0,0,0.10);
}

.glass-panel.has-filter .glass-active-filter { display: flex; }

#glass-filter-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: #ffffff;
  background: #0033FF;
  border: 1px solid #0033FF;
  padding: 2px 8px;
  flex: 1;
}

#glass-filter-clear {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.1s;
}

#glass-filter-clear:hover { color: var(--ink); }

/* —— Search dropdown ——————————————————————————————————————— */
.search-dropdown {
  pointer-events: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 3px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.search-dropdown.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.sd-section { padding: 12px 16px 10px; }
.sd-section + .sd-section { border-top: 1px solid rgba(0,0,0,0.08); }

.sd-header {
  font-family: var(--mono);
  font-size: 0.57rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 8px;
}

.sd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.sd-chip {
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.08s, color 0.08s;
  white-space: nowrap;
  opacity: 0.55;
}

.sd-chip:hover {
  opacity: 1;
}

.sd-chip.active {
  background: #0033FF;
  color: #ffffff;
  opacity: 1;
}

/* —— Floating toggle button ————————————————————————————— */
.float-toggle {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 30;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  padding: 9px 10px;
  border-radius: 3px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.float-toggle.mode-graph {
  background: rgba(13, 13, 13, 0.82);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-top-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.06);
  color: rgba(255, 255, 255, 0.55);
}

.float-toggle.mode-graph:hover {
  background: rgba(13, 13, 13, 0.95);
  color: rgba(255, 255, 255, 0.9);
}

.float-toggle.mode-list {
  background: var(--bg);
  border: 2px solid var(--rule);
  color: var(--ink);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.float-toggle.mode-list:hover { background: var(--ink); color: var(--bg); }

/* —— List view overlay ——————————————————————————————— */
#list-view {
  position: fixed;
  inset: 0;
  z-index: 15;
  background: var(--bg);
  overflow-y: auto;
}
#list-view.entering {
  animation: slideIn 0.45s cubic-bezier(0.0, 0, 0.2, 1) both;
}

.list-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 80px 28px 80px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid var(--rule);
  padding: 0 14px;
  height: 42px;
  background: var(--surface);
  margin-bottom: -2px;
}

.search-bar svg { color: var(--muted); flex-shrink: 0; }

.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font-size: 0.78rem;
  font-family: var(--mono);
  letter-spacing: 0.04em;
}

.search-bar input::placeholder { color: var(--muted); }

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  border: 2px solid var(--rule);
  border-top: none;
  background: var(--bg);
}

.tag-filters:empty { display: none; }

.tag-chip {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: transparent;
  border: 1px solid #b8b4aa;
  padding: 3px 8px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.08s, color 0.08s, border-color 0.08s;
}

.tag-chip:hover { border-color: var(--ink); color: var(--ink); }
.tag-chip.active { background: #0033FF; color: #fff; border-color: #0033FF; }

.file-list {
  display: flex;
  flex-direction: column;
  border: 2px solid var(--rule);
}

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 2;
}

.empty-state code { font-family: var(--mono); background: #dedad2; padding: 1px 5px; }

/* —— List sections ————————————————————————————————————————— */
.list-section { margin-bottom: 0; }

.list-section-header {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
  padding: 18px 16px 8px;
  border-top: 2px solid var(--rule);
}

.list-section:first-child .list-section-header { border-top: none; }

/* —— File item ————————————————————————————————————————————— */
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  border-top: 1px solid rgba(13,13,13,0.12);
  background: var(--surface);
  text-decoration: none;
  color: var(--ink);
  transition: background 0.08s, color 0.08s;
  cursor: pointer;
}

.file-item:hover { background: #0033FF; color: #fff; }

.file-item-name {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.file-item-cat {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.file-item:hover .file-item-cat { color: rgba(255,255,255,0.6); }

.action-btn {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  padding: 3px 9px;
  font-size: 0.68rem;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  cursor: pointer;
  border-radius: 0;
}

/* —— Doc page ——————————————————————————————————————————————— */
body.doc-page {
  overflow-y: auto;
  min-height: 100vh;
  background: var(--bg);
  animation: pageIn 0.45s cubic-bezier(0.0, 0, 0.2, 1) both;
}

.doc-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 52px;
  padding: 0 28px;
  background: var(--bg);
  border-bottom: 2px solid var(--rule);
}

.back-btn {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.back-btn:hover { color: var(--red); }

.doc-title {
  flex: 1;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn, .lang-btn {
  background: transparent;
  border: 2px solid var(--rule);
  color: var(--ink);
  padding: 5px 14px;
  font-size: 0.7rem;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}

.copy-btn:hover, .lang-btn:hover { background: var(--ink); color: var(--bg); }

/* —— Bilingual blocks ——————————————————————————————— */
html[data-lang="ru"] [lang="en"] { display: none; }
html[data-lang="en"] [lang="ru"] { display: none; }

/* —— Doc tags ————————————————————————————————————————————— */
.doc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 2em;
}

.doc-tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0;
}

/* —— Markdown body ——————————————————————————————————————— */
.markdown-body {
  max-width: 680px;
  margin: 0 auto;
  padding: 64px 28px 100px;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.9;
  color: var(--ink);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  font-family: var(--mono);
  font-weight: 700;
  line-height: 1.2;
  margin: 2.2em 0 0.7em;
  letter-spacing: -0.01em;
}

.markdown-body h1 {
  font-size: 2rem;
  margin-top: 0;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--rule);
}

.markdown-body h2 {
  font-size: 1.15rem;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.markdown-body h3 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.08em; }
.markdown-body p { margin: 0.9em 0; }

.markdown-body a { color: var(--red); text-decoration: underline; text-underline-offset: 3px; }
.markdown-body a:hover { color: var(--ink); }

.markdown-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: #dedad2;
  border: 1px solid #b8b4aa;
  padding: 1px 5px;
}

.markdown-body pre {
  background: var(--ink);
  color: #E8E4DC;
  border: 2px solid var(--rule);
  padding: 22px 20px;
  overflow-x: auto;
  margin: 1.6em 0;
  tab-size: 2;
}

.markdown-body pre code {
  background: none; border: none; padding: 0;
  color: inherit; font-size: 0.85rem;
}

.markdown-body blockquote {
  border-left: 4px solid var(--rule);
  margin: 1.6em 0;
  padding: 10px 18px;
  color: var(--muted);
  background: #E5E2DA;
  font-style: italic;
}

.markdown-body ul, .markdown-body ol { padding-left: 1.6em; margin: 0.9em 0; }
.markdown-body li { margin: 0.25em 0; }

.markdown-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 2em 0;
  border: 2px solid var(--rule);
}

.markdown-body table {
  width: 100%; border-collapse: collapse;
  margin: 1.6em 0; font-size: 0.85rem;
}

.markdown-body th, .markdown-body td {
  padding: 9px 12px;
  border: 1px solid var(--rule);
  text-align: left;
}

.markdown-body th {
  background: var(--ink); color: var(--bg);
  font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; font-size: 0.72rem;
}

.markdown-body tr:hover td { background: #E5E2DA; }

.markdown-body img {
  max-width: 100%; display: block;
  border: 2px solid var(--rule); margin: 1.2em 0;
}

.markdown-body hr {
  border: none;
  border-top: 2px solid var(--rule);
  margin: 2.5em 0;
}

/* —— Responsive ————————————————————————————————————————————— */
@media (max-width: 600px) {
  .graph-ui      { top: 38%; }
  .list-wrap     { padding: 72px 16px 60px; }
  .doc-header    { padding: 0 16px; }
  .markdown-body { padding: 36px 16px 60px; }
  .float-toggle  { top: 16px; right: 16px; }
  .file-item-actions { opacity: 1; }
}
