/*
 * Confidesk User Guide — styling.
 *
 * The whole look is driven by the CSS variables in :root below. They mirror
 * the marketing placeholder's palette today; to restyle the guide (or match a
 * future marketing site) change these values only — the rest of the file is
 * layout and rarely needs touching.
 */

:root {
  color-scheme: light dark;

  /* ---- Shared look — mirrors the app design tokens (M18 crimson) ---- */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fg: #14181f;
  --fg-muted: #5b6573;
  --bg: #ffffff;
  --bg-elevated: #f6f7f9;
  --border: #e5e7eb;
  --accent: #c5202e;
  --accent-hover: #a01824;
  --accent-soft: #fdecee;

  /* ---- Metrics ---- */
  --content-max: 46rem;
  --sidebar-w: 17rem;
  --radius: 0.375rem;
  --line: 1.65;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #f0f0f0;
    --fg-muted: #a6adba;
    --bg: #14181f;
    --bg-elevated: #1d232c;
    --border: #2a2f38;
    --accent: #f0808b;
    --accent-hover: #f5a0a8;
    --accent-soft: #2a1a1d;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  line-height: var(--line);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---- Top bar: the two links ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  margin-right: auto;
}

.topbar .brand-logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
  display: block;
}

.topbar .brand-name {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.topbar a.button {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--fg);
  background: var(--bg);
}

.topbar a.button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.topbar a.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.topbar a.button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}

/* ---- Layout: sidebar + content ---- */
.layout {
  display: flex;
  align-items: flex-start;
  max-width: calc(var(--content-max) + var(--sidebar-w) + 4rem);
  margin: 0 auto;
  padding: 0 1.25rem;
}

#toc {
  position: sticky;
  top: 4rem;
  flex: 0 0 var(--sidebar-w);
  align-self: flex-start;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  /* Reserve the scrollbar's space so the list never shifts as it appears, and
     keep the bar itself subtle — hidden until you hover the menu — so a long
     guide doesn't show a chunky default scrollbar between the menu and text. */
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  padding: 1.5rem 0.5rem 1.5rem 0;
}

#toc:hover {
  scrollbar-color: var(--border) transparent;
}

#toc::-webkit-scrollbar {
  width: 8px;
}

#toc::-webkit-scrollbar-track {
  background: transparent;
}

#toc::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 4px;
}

#toc:hover::-webkit-scrollbar-thumb {
  background: var(--border);
}

#toc .toc-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin: 0 0 0.5rem 0.5rem;
}

#toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#toc a {
  display: block;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

#toc a:hover {
  color: var(--fg);
  background: var(--bg-elevated);
}

#toc a.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

#toc a.sub {
  padding-left: 1.25rem;
  font-size: 0.85rem;
}

/* ---- Content ---- */
#content {
  flex: 1 1 auto;
  min-width: 0;
  max-width: var(--content-max);
  padding: 1.5rem 0 4rem;
}

#content h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin: 0 0 1rem;
}

#content h2 {
  font-size: 1.4rem;
  margin: 2.5rem 0 0.75rem;
  padding-top: 0.5rem;
  scroll-margin-top: 4.5rem;
}

#content h3 {
  font-size: 1.1rem;
  margin: 1.75rem 0 0.5rem;
  scroll-margin-top: 4.5rem;
}

#content p,
#content li {
  color: var(--fg);
}

#content a {
  color: var(--accent);
}

#content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

#content blockquote {
  margin: 1.25rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--fg);
}

#content blockquote p {
  margin: 0.25rem 0;
}

#content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

#content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.25rem 0;
  font-size: 0.95rem;
}

#content th,
#content td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.7rem;
  text-align: left;
}

#content th {
  background: var(--bg-elevated);
}

.loading {
  color: var(--fg-muted);
  padding: 2rem 0;
}

/* ---- Narrow screens: sidebar moves above content ---- */
@media (max-width: 820px) {
  .layout {
    flex-direction: column;
  }

  #toc {
    position: static;
    flex-basis: auto;
    width: 100%;
    max-height: none;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
  }

  #content {
    max-width: none;
  }
}
