/* KEIZAC TECH — documentation portal (/docs).
   VS Code Docs-style layout: sticky top bar + left category sidebar + content.
   Reuses the token system from styles.css, so it follows light/dark themes
   automatically (body[data-theme] drives --bg, --panel, --text, etc.). */

:root {
  --docs-side-w: 292px;
  --docs-top-h: 62px;
  --docs-max: 1320px;
}

body.docs {
  min-height: 100vh;
}

/* ---------------- Top bar ---------------- */
.docs-top {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--docs-top-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
}
.docs-top__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}
.docs-top__brand em { color: var(--blue-bright); font-style: normal; }
.docs-top__brand img { display: block; }
.docs-top__tag {
  margin-left: 2px;
  padding: 3px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.docs-top__search {
  flex: 1;
  max-width: 460px;
  margin-left: auto;
  position: relative;
}
.docs-top__search svg {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  stroke: var(--muted-2);
  fill: none; stroke-width: 2;
  pointer-events: none;
}
.docs-top__search input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
  outline: none;
  transition: border-color .15s;
}
.docs-top__search input:focus { border-color: var(--blue-bright); }
.docs-top__search input::placeholder { color: var(--muted-2); }

.docs-top__actions { display: flex; align-items: center; gap: 10px; }
.docs-top__link {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.docs-top__link:hover { color: var(--text); }

.docs-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.docs-icon-btn:hover { color: var(--text); border-color: var(--blue-bright); }
.docs-icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

.docs-burger { display: none; }

/* ---------------- Shell ---------------- */
.docs-shell {
  display: grid;
  grid-template-columns: var(--docs-side-w) minmax(0, 1fr);
  gap: 0;
  max-width: var(--docs-max);
  margin: 0 auto;
}

/* ---------------- Sidebar ---------------- */
.docs-side {
  position: sticky;
  top: var(--docs-top-h);
  align-self: start;
  height: calc(100vh - var(--docs-top-h));
  overflow-y: auto;
  padding: 26px 14px 60px 20px;
  border-right: 1px solid var(--line);
}
.docs-side__group { margin-bottom: 22px; }
.docs-side__label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin: 0 0 8px 10px;
}
.docs-side a {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius-xs);
  font-size: 14px;
  color: var(--muted);
  line-height: 1.35;
  border-left: 2px solid transparent;
}
.docs-side a:hover { color: var(--text); background: var(--blue-ghost); }
.docs-side a.is-active {
  color: var(--text);
  font-weight: 600;
  background: var(--blue-ghost);
  border-left-color: var(--blue-bright);
}
.docs-side__empty {
  display: none;
  margin: 8px 10px;
  font-size: 13.5px;
  color: var(--muted-2);
}
.docs-side.is-searching .docs-side__group:not(.has-match) { display: none; }
.docs-side.is-searching a.no-match { display: none; }

/* ---------------- Main content ---------------- */
.docs-main {
  min-width: 0;
  padding: 44px clamp(20px, 4vw, 64px) 120px;
}
.docs-main__inner { max-width: 820px; }

.docs-hero { margin-bottom: 46px; }
.docs-hero .overline {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blue-bright);
  margin-bottom: 14px;
}
.docs-hero h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(30px, 4.4vw, 44px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 16px;
}
.docs-hero p {
  font-size: clamp(16px, 1.9vw, 18px);
  color: var(--muted);
  max-width: 62ch;
  line-height: 1.6;
}

/* Quick cards */
.docs-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin: 34px 0 8px;
}
.docs-card {
  display: block;
  padding: 18px 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-card);
  transition: transform .15s, border-color .15s;
}
.docs-card:hover { transform: translateY(-3px); border-color: var(--blue-bright); }
.docs-card h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  margin: 0 0 6px;
}
.docs-card p { font-size: 13.5px; color: var(--muted); line-height: 1.5; margin: 0; }

/* Single-topic article (one page per topic) */
.docs-crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-2);
}
.docs-crumbs a { color: var(--blue-bright); }
.docs-crumbs a:hover { text-decoration: underline; }
.docs-crumbs span[aria-hidden] { color: var(--muted-2); }
.docs-article__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 22px;
}
.docs-article__body { font-size: 15.5px; }

/* Previous / next */
.docs-pn {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 56px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
.docs-pn__link {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  transition: border-color .15s, transform .15s;
}
.docs-pn__link:hover { border-color: var(--blue-bright); transform: translateY(-2px); }
.docs-pn__link span { font-size: 12.5px; font-weight: 600; color: var(--muted-2); }
.docs-pn__link strong { font-family: var(--font-display); font-size: 15px; color: var(--text); font-weight: 700; line-height: 1.3; }
.docs-pn__next { text-align: right; align-items: flex-end; }
.docs-top__tag { text-decoration: none; }
.docs-top__tag:hover { color: var(--text); border-color: var(--blue-bright); }

/* Sections (legacy single-page layout — kept for safety) */
.docs-section { padding-top: 30px; scroll-margin-top: calc(var(--docs-top-h) + 20px); }
.docs-section > h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(24px, 3vw, 30px);
  letter-spacing: -0.015em;
  color: var(--text);
  margin: 0 0 6px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
}
.docs-topic { scroll-margin-top: calc(var(--docs-top-h) + 20px); margin-top: 40px; }
.docs-topic > h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(19px, 2.3vw, 23px);
  color: var(--text);
  margin: 0 0 14px;
}
.docs-main p { font-size: 15.5px; line-height: 1.7; color: var(--muted); margin: 0 0 14px; }
.docs-main p strong { color: var(--text); font-weight: 600; }
.docs-main a.inline { color: var(--blue-bright); font-weight: 600; }
.docs-main a.inline:hover { text-decoration: underline; }

/* Numbered steps */
.docs-steps { counter-reset: step; list-style: none; margin: 0 0 18px; padding: 0; }
.docs-steps > li {
  position: relative;
  padding: 2px 0 18px 46px;
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--muted);
}
.docs-steps > li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0; top: 0;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: var(--radius-full);
  background: var(--blue-ghost);
  color: var(--blue-bright);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
}
.docs-steps > li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 14px; top: 34px; bottom: 6px;
  width: 2px;
  background: var(--line);
}
.docs-steps > li strong { color: var(--text); font-weight: 600; }

/* Callout / note */
.docs-note {
  display: flex;
  gap: 12px;
  padding: 15px 17px;
  margin: 4px 0 22px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--blue-bright);
  border-radius: var(--radius-sm);
  background: var(--blue-ghost);
}
.docs-note svg { flex: none; width: 19px; height: 19px; margin-top: 1px; stroke: var(--blue-bright); fill: none; stroke-width: 2; }
.docs-note p { margin: 0; font-size: 14.5px; color: var(--text); }
.docs-note.is-warn { border-left-color: #E0A21A; }
.docs-note.is-warn svg { stroke: #E0A21A; }

/* Bulleted list */
.docs-list { margin: 0 0 18px; padding-left: 22px; }
.docs-list li { font-size: 15.5px; line-height: 1.7; color: var(--muted); margin-bottom: 8px; }
.docs-list li strong { color: var(--text); font-weight: 600; }

/* Footer */
.docs-foot {
  max-width: 820px;
  margin-top: 70px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--muted-2);
}
.docs-foot a { color: var(--muted); }
.docs-foot a:hover { color: var(--text); }
.docs-foot__links { margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; }

/* Scrim for mobile drawer */
.docs-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0,0,0,.45);
}

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .docs-burger {
    display: inline-flex;
    order: -1;
  }
  .docs-top__search { max-width: none; }
  .docs-top__link { display: none; }
  .docs-shell { grid-template-columns: minmax(0, 1fr); }
  .docs-side {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 58;
    width: 300px;
    height: 100vh;
    padding-top: 22px;
    background: var(--bg);
    border-right: 1px solid var(--line-strong);
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  .docs-side.is-open { transform: translateX(0); }
  .docs-scrim.is-open { display: block; }
  .docs-main { padding: 30px 20px 90px; }
}
