/* docs.css: shared look for the /docs pages. Builds on the brand tokens in
   /web/shared/style.css; everything here is documentation-specific layout. */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans, "Inter", system-ui, sans-serif);
  background: var(--color-bg-app, #F7F9FB);
  color: var(--text-primary, #1E2933);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Top navigation (matches the admin pages) ─────────────────────────── */
nav {
  height: 64px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--divider, #E8EDF2);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
nav .logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
nav .logo img { height: 32px; width: auto; display: block; }
nav .logo span {
  color: var(--color-accent, #0E93D5);
  font-weight: 600;
  font-size: 15px;
}
nav a {
  color: var(--text-primary, #1E2933);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
nav a:hover, nav a.active { color: var(--color-accent, #0E93D5); }
/* Version chip next to the Docs label; pushes the page links to the right. */
nav .ver {
  margin-right: auto;
  margin-left: 2px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary, #5F6B76);
  background: var(--color-bg-panel, #EAF4F8);
  border: 1px solid var(--border, #D8E1E8);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}
@media (max-width: 700px) { nav .ver { display: none; } }

/* Narrow screens: let the top nav wrap instead of overflowing. */
@media (max-width: 760px) {
  nav {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding: 10px 16px;
    gap: 8px 18px;
  }
}

/* ── Two-column layout: sticky section nav + content ─────────────────── */
.layout {
  display: flex;
  gap: 40px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}
.sidenav {
  width: 230px;
  flex-shrink: 0;
  position: sticky;
  top: 64px;
  align-self: flex-start;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 28px 0 48px;
}
.sidenav .group {
  font-size: .7em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted, #8B98A5);
  margin: 22px 0 6px 12px;
}
.sidenav .group:first-child { margin-top: 6px; }
.sidenav a {
  display: block;
  padding: 4px 12px;
  font-size: .86em;
  color: var(--text-secondary, #5F6B76);
  text-decoration: none;
  border-left: 2px solid var(--divider, #E8EDF2);
  transition: color .1s, border-color .1s;
}
.sidenav a:hover { color: var(--color-accent, #0E93D5); }
.sidenav a.active {
  color: var(--color-primary, #123E63);
  border-left-color: var(--color-accent, #0E93D5);
  background: var(--color-bg-panel, #EAF4F8);
  font-weight: 600;
}
/* On small screens the sidenav becomes a wrapping pill TOC above the content
   instead of disappearing. */
@media (max-width: 900px) {
  .layout { display: block; padding: 0 16px; }
  .sidenav {
    position: static;
    width: auto;
    max-height: none;
    overflow: visible;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 16px 0 0;
  }
  .sidenav .group { display: none; }
  .sidenav a {
    border: 1px solid var(--border, #D8E1E8);
    border-left: 1px solid var(--border, #D8E1E8);
    border-radius: 999px;
    background: var(--white, #fff);
    padding: 3px 12px;
    font-size: .8em;
  }
  .sidenav a.active {
    border-color: var(--color-accent, #0E93D5);
    background: var(--color-bg-panel, #EAF4F8);
  }
}

/* ── Page content ─────────────────────────────────────────────────────── */
.page {
  max-width: var(--w-reading, 760px);
  margin: 0 auto;
  padding: var(--space-xl, 32px) var(--space-lg, 24px) var(--space-xxxl, 72px);
}
.layout .page { margin: 0; padding-left: 0; padding-right: 0; flex: 1; min-width: 0; }
.page.wide { max-width: 900px; }

h1 { font-size: 1.7em; color: var(--color-primary, #123E63); margin-bottom: 8px; }
.subtitle { color: var(--text-secondary, #5F6B76); margin-bottom: 32px; }
h2 {
  font-size: 1.3em;
  color: var(--color-primary, #123E63);
  margin: 48px 0 16px;
  padding-top: 20px;
  border-top: 2px solid var(--border, #D8E1E8);
  scroll-margin-top: 84px;
}
h3 {
  font-size: 1.08em;
  color: var(--color-primary, #123E63);
  margin: 28px 0 10px;
  scroll-margin-top: 84px;
}
p, ul, ol { margin-bottom: 12px; }
ul, ol { padding-left: 24px; }
li { margin-bottom: 4px; }
a { color: var(--color-accent, #0E93D5); }

code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .875em;
  background: var(--color-bg-panel, #EAF4F8);
  border-radius: 4px;
  padding: 1px 5px;
}
pre {
  background: #0F2438;
  color: #DCE8F2;
  border-radius: var(--radius-button, 8px);
  padding: 14px 16px;
  overflow-x: auto;
  margin-bottom: 16px;
  font-size: .82em;
  line-height: 1.55;
}
pre code { background: none; padding: 0; color: inherit; font-size: inherit; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: .9em;
  background: var(--white, #fff);
  border: 1px solid var(--border, #D8E1E8);
  border-radius: var(--radius-button, 8px);
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--divider, #E8EDF2);
  vertical-align: top;
}
th {
  background: var(--color-bg-panel, #EAF4F8);
  color: var(--color-primary, #123E63);
  font-weight: 600;
}
tr:last-child td { border-bottom: none; }

/* ── Term tooltips ─────────────────────────────────────────────────────
   Jargon gets a dotted underline; hovering (or tapping/focusing) shows a
   plain-English explanation from the data-tip attribute. */
.term {
  border-bottom: 1px dotted var(--color-accent, #0E93D5);
  cursor: help;
  position: relative;
}
.term:hover::after, .term:focus::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary, #123E63);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 400;
  font-style: normal;
  line-height: 1.45;
  width: max-content;
  max-width: 280px;
  white-space: normal;
  z-index: 50;
  box-shadow: 0 4px 14px rgba(18, 62, 99, .25);
  pointer-events: none;
}
.term:hover::before, .term:focus::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--color-primary, #123E63);
  z-index: 50;
  pointer-events: none;
}

/* ── Callouts ─────────────────────────────────────────────────────────── */
.note, .warn {
  border-left: 4px solid var(--info, #3B82F6);
  background: var(--white, #fff);
  border-radius: 0 var(--radius-button, 8px) var(--radius-button, 8px) 0;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: .92em;
}
.warn { border-left-color: var(--error, #C44747); }
.note strong, .warn strong { display: block; margin-bottom: 2px; }

/* ── Architecture diagram ─────────────────────────────────────────────── */
figure.arch {
  margin: 20px 0 24px;
  background: var(--white, #fff);
  border: 1px solid var(--border, #D8E1E8);
  border-radius: var(--radius-button, 8px);
  padding: 20px 16px 10px;
}
figure.arch figcaption {
  font-size: .8em;
  color: var(--text-muted, #8B98A5);
  text-align: center;
  margin-top: 8px;
}

/* ── Screenshot figures ────────────────────────────────────────────────
   Guides reference images in /web/docs/img/. Until a screenshot is dropped
   in, the figure renders a styled "pending" placeholder instead of a broken
   image (the img onerror handler adds .pending). */
figure.shot { margin: 16px 0 20px; }
figure.shot img {
  max-width: 100%;
  border: 1px solid var(--border, #D8E1E8);
  border-radius: var(--radius-button, 8px);
  box-shadow: 0 2px 8px rgba(18, 62, 99, .08);
}
figure.shot.pending img { display: none; }
figure.shot.pending::before {
  content: "📷  Screenshot pending. Drop the file named in the caption into web/docs/img/";
  display: block;
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted, #8B98A5);
  background: var(--white, #fff);
  border: 1px dashed var(--border, #D8E1E8);
  border-radius: var(--radius-button, 8px);
  font-size: .85em;
}
figure.shot figcaption {
  font-size: .8em;
  color: var(--text-muted, #8B98A5);
  margin-top: 6px;
}

/* ── Hub cards (index page) ───────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin: 32px 0; }
@media (max-width: 760px) { .cards { grid-template-columns: 1fr; } }
a.card {
  display: block;
  background: var(--white, #fff);
  border: 1px solid var(--border, #D8E1E8);
  border-radius: 14px;
  padding: 34px;
  text-decoration: none;
  color: var(--text-primary, #1E2933);
  transition: border-color .15s, box-shadow .15s;
}
a.card:hover {
  border-color: var(--color-accent, #0E93D5);
  box-shadow: 0 4px 14px rgba(18, 62, 99, .10);
}
a.card h2 { border: none; margin: 0 0 12px; padding: 0; font-size: 1.4em; }
a.card p { color: var(--text-secondary, #5F6B76); font-size: 1em; margin: 0; line-height: 1.65; }
a.card .go { display: block; margin-top: 22px; color: var(--color-accent, #0E93D5); font-size: 1em; font-weight: 600; }
@media (max-width: 760px) {
  a.card { padding: 24px; }
  a.card h2 { font-size: 1.25em; }
}

.linklist { list-style: none; padding: 0; }
.linklist li { margin-bottom: 6px; }
.method {
  display: inline-block;
  min-width: 52px;
  text-align: center;
  font-family: ui-monospace, Menlo, monospace;
  font-size: .72em;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 6px;
  color: var(--white, #fff);
  background: var(--color-enterprise-blue, #2F6F9F);
}
.method.get { background: var(--success, #2E8B57); }
.method.post { background: var(--color-enterprise-blue, #2F6F9F); }
.method.put { background: var(--warning, #D89B2B); }
.method.delete { background: var(--error, #C44747); }

/* ── Small screens: wide content scrolls, long tokens wrap ────────────── */
@media (max-width: 760px) {
  .page { padding: 24px 0 56px; }
  h1 { font-size: 1.45em; }
  /* Wide tables (route map, env vars) scroll inside their own box instead
     of stretching the page. */
  table { display: block; overflow-x: auto; }
  /* Long endpoint paths in prose wrap instead of overflowing. */
  p code, li code { overflow-wrap: anywhere; }
  /* The architecture diagram stays readable and scrolls sideways. */
  figure.arch { overflow-x: auto; }
  figure.arch svg { min-width: 640px; }
}
