/* ============================================================
   Кузня — Документация
   Shared stylesheet for all pages
   Palette: industrial forge — dark, heat accents
   ============================================================ */

/* --- Google Fonts ----------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- CSS Variables ---------------------------------------- */
:root {
  --base:        #0e1013;
  --panel:       #14161b;
  --hairline:    #252a33;
  --orange:      #e8823a;
  --yellow:      #f2c14e;
  --green:       #4fbf7b;
  --red:         #e0524a;
  --steel:       #7a8290;
  --text-1:      #e6e9ef;
  --text-2:      #b9c1cd;
  --text-3:      #8b95a5;
  --sidebar-w:   260px;
  --content-max: 70ch;
  --radius:      6px;
  --radius-lg:   12px;
  --mono:        'JetBrains Mono', 'Fira Code', monospace;
  --sans:        'Inter', system-ui, sans-serif;
}

/* --- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--base);
  color: var(--text-1);
  line-height: 1.7;
  min-height: 100vh;
}

/* --- Layout ------------------------------------------------ */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar --------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--hairline);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.2;
}

.sidebar-subtitle {
  font-size: 0.7rem;
  color: var(--steel);
  font-family: var(--mono);
  font-weight: 400;
}

/* Nav sections */
.sidebar-nav {
  flex: 1;
  padding: 12px 0 16px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--steel);
  padding: 12px 20px 4px;
}

.nav-link {
  display: block;
  padding: 6px 20px;
  font-size: 0.875rem;
  color: var(--text-2);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  line-height: 1.4;
}

.nav-link:hover {
  color: var(--text-1);
  background: rgba(232,130,58,0.06);
}

.nav-link.active {
  color: var(--orange);
  border-left-color: var(--orange);
  background: rgba(232,130,58,0.08);
  font-weight: 500;
}

/* Anchor sub-links */
.nav-anchor {
  display: block;
  padding: 4px 20px 4px 32px;
  font-size: 0.78rem;
  color: var(--text-3);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  line-height: 1.4;
}

.nav-anchor:hover {
  color: var(--text-2);
}

.nav-anchor.active {
  color: var(--yellow);
  border-left-color: var(--yellow);
}

/* Search in sidebar */
.sidebar-search {
  padding: 12px 16px;
  border-top: 1px solid var(--hairline);
  flex-shrink: 0;
}

.search-wrap {
  position: relative;
}

.search-input {
  width: 100%;
  background: var(--base);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 7px 12px 7px 32px;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--text-1);
  outline: none;
  transition: border-color 0.15s;
}

.search-input::placeholder { color: var(--text-3); }
.search-input:focus { border-color: var(--orange); }

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--steel);
  pointer-events: none;
  font-size: 0.85rem;
}

.search-results {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  max-height: 300px;
  overflow-y: auto;
  display: none;
  z-index: 200;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.4);
}

.search-results.open { display: block; }

.search-result-item {
  display: block;
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--text-2);
  text-decoration: none;
  border-bottom: 1px solid var(--hairline);
  transition: background 0.1s, color 0.1s;
}

.search-result-item:last-child { border-bottom: none; }

.search-result-item:hover {
  background: rgba(232,130,58,0.1);
  color: var(--text-1);
}

.search-result-title {
  font-weight: 600;
  color: var(--orange);
  font-size: 0.75rem;
  margin-bottom: 2px;
}

.search-result-excerpt {
  color: var(--text-3);
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-no-results {
  padding: 12px;
  font-size: 0.8rem;
  color: var(--steel);
  text-align: center;
}

/* ---- Hamburger ------------------------------------------- */
.hamburger {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 200;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: pointer;
  color: var(--text-1);
  font-size: 1.1rem;
  line-height: 1;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ---- Main content ---------------------------------------- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}

.content-inner {
  max-width: calc(var(--content-max) + 80px);
  padding: 48px 40px 80px;
  margin: 0 auto;
}

/* ---- Typography ------------------------------------------ */
h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.25;
  margin-bottom: 0.5em;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-1);
  margin-top: 2.5em;
  margin-bottom: 0.6em;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--hairline);
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-1);
  margin-top: 1.8em;
  margin-bottom: 0.5em;
}

h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-2);
  margin-top: 1.4em;
  margin-bottom: 0.4em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

p { margin-bottom: 1em; color: var(--text-2); }
p:last-child { margin-bottom: 0; }

strong { color: var(--text-1); font-weight: 600; }
em { color: var(--text-2); font-style: italic; }

a { color: var(--orange); text-decoration: none; transition: color 0.15s; }
a:hover { color: #f0a060; text-decoration: underline; }

ul, ol {
  margin-bottom: 1em;
  padding-left: 1.5em;
  color: var(--text-2);
}
li { margin-bottom: 0.3em; }
li:last-child { margin-bottom: 0; }

/* Anchor headings */
.heading-anchor {
  display: flex;
  align-items: center;
  gap: 8px;
}

.heading-anchor .anchor-link {
  color: var(--steel);
  opacity: 0;
  font-size: 0.8em;
  text-decoration: none;
  transition: opacity 0.15s, color 0.15s;
}

.heading-anchor:hover .anchor-link,
h2:hover .anchor-link,
h3:hover .anchor-link {
  opacity: 1;
}

.heading-anchor .anchor-link:hover { color: var(--orange); }

/* ---- Page header ----------------------------------------- */
.page-header {
  margin-bottom: 2.5em;
  padding-bottom: 1.5em;
  border-bottom: 1px solid var(--hairline);
}

.page-header h1 { margin-bottom: 0.3em; }

.page-lead {
  font-size: 1.05rem;
  color: var(--text-2);
  line-height: 1.65;
  margin-bottom: 0;
}

/* ---- Callout boxes --------------------------------------- */
.callout {
  border-left: 3px solid;
  padding: 12px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.5em 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.callout-title {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.callout.warn {
  border-color: var(--red);
  background: rgba(224,82,74,0.08);
}
.callout.warn .callout-title { color: var(--red); }
.callout.warn { color: var(--text-2); }

.callout.tip {
  border-color: var(--yellow);
  background: rgba(242,193,78,0.07);
}
.callout.tip .callout-title { color: var(--yellow); }
.callout.tip { color: var(--text-2); }

.callout.info {
  border-color: var(--orange);
  background: rgba(232,130,58,0.07);
}
.callout.info .callout-title { color: var(--orange); }
.callout.info { color: var(--text-2); }

.callout.success {
  border-color: var(--green);
  background: rgba(79,191,123,0.07);
}
.callout.success .callout-title { color: var(--green); }
.callout.success { color: var(--text-2); }

/* ---- Code blocks ----------------------------------------- */
.code-wrap {
  position: relative;
  margin: 1.5em 0;
}

.code-label {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--hairline);
  color: var(--steel);
  font-family: var(--mono);
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: var(--radius) 0 var(--radius) 0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  z-index: 1;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--hairline);
  border: none;
  color: var(--steel);
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  z-index: 1;
  letter-spacing: 0.03em;
}

.copy-btn:hover { background: var(--orange); color: #fff; }
.copy-btn.copied { background: var(--green); color: #fff; }

pre {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 40px 20px 20px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.845rem;
  line-height: 1.65;
  color: var(--text-2);
  tab-size: 4;
}

pre code {
  font-family: inherit;
  font-size: inherit;
  background: none;
  padding: 0;
  color: inherit;
}

code {
  font-family: var(--mono);
  font-size: 0.865em;
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--text-1);
}

/* Syntax highlighting — hand-rolled */
.tok-kw   { color: #c792ea; }  /* keyword — purple */
.tok-str  { color: #c3e88d; }  /* string — green */
.tok-num  { color: var(--yellow); }  /* number — yellow */
.tok-cm   { color: var(--steel); font-style: italic; }  /* comment — steel */
.tok-fn   { color: #82aaff; }  /* function — blue */
.tok-key  { color: var(--orange); }  /* JSON key — orange */
.tok-bool { color: #f78c6c; }  /* boolean — peach */
.tok-op   { color: var(--text-3); }  /* operator */
.tok-cls  { color: var(--yellow); font-weight: 500; }  /* class */
.tok-dec  { color: #f78c6c; }  /* decorator */

/* ---- Tables ---------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  margin: 1.5em 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

thead {
  background: var(--panel);
}

th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-3);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}

td {
  padding: 9px 14px;
  color: var(--text-2);
  border-bottom: 1px solid rgba(37,42,51,0.7);
  vertical-align: top;
  line-height: 1.5;
}

tr:last-child td { border-bottom: none; }

tbody tr:hover { background: rgba(255,255,255,0.02); }

td code { font-size: 0.82em; }
td:first-child code { color: var(--orange); }

/* ---- Step cards ------------------------------------------ */
.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 1.5em 0;
}

.step {
  display: flex;
  gap: 16px;
  margin-bottom: 1.5em;
  counter-increment: step;
}

.step-num {
  width: 28px;
  height: 28px;
  background: var(--orange);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  font-family: var(--mono);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-body { flex: 1; min-width: 0; }
.step-body h4 { margin-top: 0; color: var(--text-1); font-size: 0.9rem; }
.step-body p { margin-bottom: 0.5em; }

/* ---- Prev/Next nav --------------------------------------- */
.page-nav {
  display: flex;
  gap: 12px;
  margin-top: 4em;
  padding-top: 2em;
  border-top: 1px solid var(--hairline);
}

.page-nav-item {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.page-nav-item:hover {
  border-color: var(--orange);
  background: rgba(232,130,58,0.05);
  text-decoration: none;
}

.page-nav-item.prev { text-align: left; }
.page-nav-item.next { text-align: right; }

.page-nav-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--steel);
  font-weight: 600;
  margin-bottom: 4px;
}

.page-nav-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-1);
}

.page-nav-arrow {
  color: var(--orange);
}

/* ---- Badges ---------------------------------------------- */
.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 3px;
  font-weight: 500;
}
.badge-orange { background: rgba(232,130,58,0.2); color: var(--orange); }
.badge-green  { background: rgba(79,191,123,0.15); color: var(--green); }
.badge-red    { background: rgba(224,82,74,0.15); color: var(--red); }
.badge-yellow { background: rgba(242,193,78,0.15); color: var(--yellow); }
.badge-steel  { background: rgba(122,130,144,0.15); color: var(--steel); }

/* ---- Feature grid ---------------------------------------- */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin: 1.5em 0;
}

.feature-card {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: border-color 0.15s;
}

.feature-card:hover { border-color: var(--orange); }

.feature-icon {
  font-size: 1.5rem;
  margin-bottom: 10px;
}

.feature-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 4px;
}

.feature-desc {
  font-size: 0.82rem;
  color: var(--text-3);
  line-height: 1.5;
  margin: 0;
}

/* ---- Inline definitions ---------------------------------- */
dl { margin: 1em 0; }
dt { font-weight: 600; color: var(--orange); font-family: var(--mono); font-size: 0.85em; margin-top: 1em; }
dd { margin-left: 1.5em; color: var(--text-2); font-size: 0.9em; }

/* ---- Horizontal rule ------------------------------------- */
hr { border: none; border-top: 1px solid var(--hairline); margin: 2em 0; }

/* ---- Responsive ------------------------------------------ */
@media (max-width: 900px) {
  .hamburger { display: block; }

  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }

  .sidebar-overlay.open { display: block; }

  .main-content { margin-left: 0; }

  .content-inner {
    padding: 56px 20px 60px;
  }

  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.2rem; }

  .page-nav { flex-direction: column; }

  .feature-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .content-inner { padding: 52px 16px 48px; }
  pre { font-size: 0.78rem; }
  th, td { padding: 8px 10px; }
}

/* ---- Scrollbar ------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--steel); }

/* ---- Version tag ----------------------------------------- */
.version-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  padding: 4px 12px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--steel);
  margin-bottom: 1em;
}

.version-tag .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
  flex-shrink: 0;
}

/* ---- TOC badge on h2 ------------------------------------- */
h2 .anchor-id { scroll-margin-top: 24px; }
h3 .anchor-id { scroll-margin-top: 24px; }
[id] { scroll-margin-top: 24px; }

/* ---- Download button ------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--orange);
  color: #fff;
}
.btn-primary:hover {
  background: #f0954a;
  color: #fff;
  text-decoration: none;
}

.btn-secondary {
  background: var(--panel);
  border: 1px solid var(--hairline);
  color: var(--text-1);
}
.btn-secondary:hover {
  border-color: var(--orange);
  color: var(--orange);
  text-decoration: none;
}

/* ---- Two-col layout -------------------------------------- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 1em 0;
}
@media (max-width: 600px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ---- Comparison / side-by-side --------------------------- */
.compare-box {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.compare-box .compare-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--steel);
  margin-bottom: 8px;
}

/* ---- Inline key combo ------------------------------------ */
kbd {
  font-family: var(--mono);
  font-size: 0.8em;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text-2);
}

/* ---- Schema table specifics ------------------------------ */
.schema-path {
  font-family: var(--mono);
  font-size: 0.82em;
  color: var(--orange);
  white-space: nowrap;
}

.schema-type {
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--yellow);
}

.schema-default {
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--green);
}

/* ---- Animated gradient title on index -------------------- */
.hero-title {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--orange) 0%, var(--yellow) 60%, var(--orange) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.4em;
}

@media (max-width: 600px) {
  .hero-title { font-size: 2rem; }
}

/* Loss chart diagram */
.loss-chart-demo {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 1.5em 0;
}

.loss-chart-demo svg {
  width: 100%;
  height: auto;
}
