/* RustSetup Docs — modern theme (dark-first, GitHub/Vercel docs inspired) */

:root {
  --bg: #0d1117;
  --bg-elevated: #161b22;
  --bg-inset: #010409;
  --border: #30363d;
  --border-muted: #21262d;
  --text: #e6edf3;
  --text-muted: #9198a1;
  --text-faint: #6e7681;
  --accent: #e8935a;
  --accent-strong: #f2a86e;
  --accent-contrast: #1a1206;
  --link: #6cb6ff;
  --info-bg: rgba(56, 139, 253, 0.1);
  --info-border: #388bfd;
  --info-text: #79c0ff;
  --danger-bg: rgba(248, 81, 73, 0.1);
  --danger-border: #f85149;
  --danger-text: #ff7b72;
  --warning-bg: rgba(210, 153, 34, 0.1);
  --warning-border: #d29922;
  --warning-text: #e3b341;
  --success-bg: rgba(63, 185, 80, 0.1);
  --success-border: #3fb950;
  --success-text: #56d364;
  --code-bg: #0d1117;
  --shadow: 0 8px 24px rgba(1, 4, 9, 0.6);
  --radius: 8px;
  --header-h: 60px;
  --sidebar-w: 280px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-elevated: #f6f8fa;
  --bg-inset: #eef1f4;
  --border: #d0d7de;
  --border-muted: #e4e8ec;
  --text: #1f2328;
  --text-muted: #57606a;
  --text-faint: #6e7781;
  --accent: #c8672c;
  --accent-strong: #a8551f;
  --accent-contrast: #ffffff;
  --link: #0969da;
  --info-bg: #ddf4ff;
  --info-border: #54aeff;
  --info-text: #0969da;
  --danger-bg: #ffebe9;
  --danger-border: #ff8182;
  --danger-text: #cf222e;
  --warning-bg: #fff8c5;
  --warning-border: #d4a72c;
  --warning-text: #9a6700;
  --success-bg: #dafbe1;
  --success-border: #4ac26b;
  --success-text: #1a7f37;
  --code-bg: #f6f8fa;
  --shadow: 0 8px 24px rgba(140, 149, 159, 0.2);
  color-scheme: light;
}

* { box-sizing: border-box; }

.visually-hidden {
  position: absolute;
  left: -9999px;
  top: auto;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 6px;
}
.visually-hidden:focus { left: 12px; top: 12px; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.15s ease, color 0.15s ease;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

hr { border: none; border-top: 1px solid var(--border-muted); margin: 0; }

::selection { background: var(--accent); color: var(--accent-contrast); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-muted);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand svg { flex: none; color: var(--accent); }

.brand-sep { color: var(--text-faint); }
.brand-product { color: var(--text-muted); font-weight: 500; }

.version-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.header-spacer { flex: 1; }

.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-elevated); border-color: var(--border); color: var(--text); }

.header-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.header-link:hover { color: var(--text); border-color: var(--text-faint); text-decoration: none; background: var(--bg-elevated); }

.sidebar-toggle { display: none; }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  max-width: 1400px;
  margin: 0 auto;
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 24px 16px 40px;
  border-right: 1px solid var(--border-muted);
}

.sidebar-group { margin-bottom: 4px; }

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 8px 10px;
}

.sidebar nav ul { list-style: none; margin: 0; padding: 0; }

.sidebar nav a {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-muted);
  border-left: 2px solid transparent;
}

.sidebar nav > ul > li > a { font-weight: 600; color: var(--text); }

.sidebar nav ul ul { margin-top: 2px; margin-bottom: 10px; }
.sidebar nav ul ul a { padding-left: 20px; font-weight: 400; }

.sidebar nav a:hover { background: var(--bg-elevated); text-decoration: none; color: var(--text); }

.sidebar nav a.active {
  color: var(--accent-strong);
  background: var(--bg-elevated);
  border-left-color: var(--accent);
}

.sidebar-backdrop { display: none; }

/* ---------- Content ---------- */

.content {
  min-width: 0;
  padding: 40px clamp(20px, 4vw, 56px) 100px;
  max-width: 880px;
}

.content h1 {
  font-size: 32px;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.content h2 {
  font-size: 22px;
  margin: 0 0 16px;
  padding-top: 4px;
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.content h5 {
  font-size: 15px;
  font-weight: 700;
  margin: 20px 0 8px;
}

.lead { font-size: 17px; color: var(--text-muted); margin: 0 0 20px; }

.content p { margin: 0 0 14px; }
.content ol, .content ul { margin: 0 0 16px; padding-left: 22px; }
.content li { margin-bottom: 8px; }
.content li ul, .content li ol { margin-top: 8px; }

.divider { margin: 40px 0; }

section { margin-bottom: 8px; }

.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  margin: 20px 0 24px;
  padding: 16px 0;
  border-top: 1px solid var(--border-muted);
  border-bottom: 1px solid var(--border-muted);
}
.meta-grid dl { margin: 0; }
.meta-grid dt { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.meta-grid dd { margin: 0; font-size: 14px; font-weight: 500; }

/* ---------- Inline code / pre ---------- */

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.87em;
  background: var(--bg-elevated);
  border: 1px solid var(--border-muted);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--accent-strong);
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 44px 16px 16px;
  overflow-x: auto;
  position: relative;
  margin: 0 0 16px;
}
pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.1s ease;
}
pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--text); border-color: var(--text-faint); }
.copy-btn.copied { color: var(--success-text); border-color: var(--success-border); opacity: 1; }

/* ---------- Callouts ---------- */

.callout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid;
  font-size: 14.5px;
  margin: 0 0 16px;
}
.callout svg { flex: none; margin-top: 2px; }
.callout a { font-weight: 600; }

.callout--info { background: var(--info-bg); border-color: var(--info-border); color: var(--text); }
.callout--info svg { color: var(--info-text); }
.callout--danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--text); }
.callout--danger svg { color: var(--danger-text); }
.callout--warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--text); }
.callout--warning svg { color: var(--warning-text); }
.callout--success { background: var(--success-bg); border-color: var(--success-border); color: var(--text); }
.callout--success svg { color: var(--success-text); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; margin: 0 0 20px; border: 1px solid var(--border); border-radius: var(--radius); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  background: var(--bg-elevated);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-muted); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-elevated); }
table p { margin: 0 0 6px; }
table p:last-child { margin-bottom: 0; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--bg-elevated);
}
.btn:hover { border-color: var(--text-faint); text-decoration: none; }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border-muted);
  padding: 24px clamp(20px, 4vw, 56px);
  color: var(--text-faint);
  font-size: 13px;
  max-width: 880px;
}

/* ---------- Back to top ---------- */

#back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 40;
}
#back-to-top.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
#back-to-top:hover { color: var(--text); border-color: var(--text-faint); }

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }

  .sidebar-toggle { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    width: 300px;
    max-width: 84vw;
    height: calc(100vh - var(--header-h));
    background: var(--bg);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 60;
  }
  .sidebar.is-open { transform: translateX(0); }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(1, 4, 9, 0.5);
    z-index: 55;
  }
  .sidebar-backdrop.is-open { display: block; }

  .content { padding-left: 20px; padding-right: 20px; }
  .header-link span { display: none; }
}

@media (max-width: 560px) {
  .content h1 { font-size: 26px; }
  .meta-grid { gap: 20px; }
}
