/*
 * Guides — the shared stylesheet for every page under /guides.
 *
 * Tokens mirror packages/ui/src/theme.ts (slate surfaces, one indigo accent, the same
 * radii) so the guides read as part of the app rather than a separate site. Light and
 * dark follow the reader's system setting.
 */
:root {
  color-scheme: light dark;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --primary-soft-2: #e0e7ff;
  --danger: #e11d48;
  --success: #059669;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --success-soft: #ecfdf5;
  --code-bg: #f1f5f9;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --rail: 272px;
  --toc: 220px;
  --header: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --text: #f8fafc;
    --muted: #94a3b8;
    --border: #1f2937;
    --primary: #818cf8;
    --primary-soft: #1e1b4b;
    --primary-soft-2: #312e81;
    --warning-soft: #2a1f0a;
    --success-soft: #062a1f;
    --code-bg: #1f2937;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header) + 16px); }
body {
  margin: 0;
  font: 16px/1.65 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
}
pre {
  background: var(--code-bg);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  overflow-x: auto;
}
pre code { background: none; padding: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
img { max-width: 100%; }

/* ---- Header ---------------------------------------------------------------------- */
.g-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.g-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}
.g-brand:hover { text-decoration: none; }
.g-brand-mark {
  /* The app's own G mark (the sign-in screen and splash icon), not a lettered stand-in. */
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: block;
  object-fit: cover;
  flex: none;
}
.g-brand-sub { color: var(--muted); font-weight: 500; }
.g-header-spacer { flex: 1; }
.g-header-link {
  color: var(--muted);
  font-size: 14px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}
.g-header-link:hover { color: var(--text); background: var(--code-bg); text-decoration: none; }
.g-menu-btn {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.g-search {
  position: relative;
  width: 260px;
}
.g-search input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  padding: 0 10px 0 32px;
  font: inherit;
  font-size: 14px;
}
.g-search input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.g-search svg {
  position: absolute;
  left: 10px;
  top: 10px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.g-search-results {
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  max-height: 60vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  display: none;
}
.g-search-results.open { display: block; }
.g-search-results a {
  display: block;
  padding: 8px 12px;
  color: var(--text);
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.g-search-results a:last-child { border-bottom: 0; }
.g-search-results a:hover, .g-search-results a.active { background: var(--primary-soft); text-decoration: none; }
.g-search-results small { display: block; color: var(--muted); font-size: 12px; }
.g-search-results .g-empty { padding: 12px; color: var(--muted); font-size: 14px; }

/* ---- Layout ----------------------------------------------------------------------- */
.g-app {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr) var(--toc);
  max-width: 1440px;
  margin: 0 auto;
}
.g-rail {
  position: sticky;
  top: var(--header);
  height: calc(100vh - var(--header));
  overflow-y: auto;
  padding: 20px 12px 40px 16px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.g-main { min-width: 0; padding: 32px 48px 80px; }
.g-toc {
  position: sticky;
  top: var(--header);
  height: calc(100vh - var(--header));
  overflow-y: auto;
  padding: 32px 16px 40px 8px;
  font-size: 13px;
}
.g-toc h4 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.g-toc a {
  display: block;
  color: var(--muted);
  padding: 4px 0 4px 10px;
  border-left: 2px solid var(--border);
  line-height: 1.4;
}
.g-toc a:hover { color: var(--text); text-decoration: none; }
.g-toc a.active { color: var(--primary); border-left-color: var(--primary); }

/* ---- Rail navigation --------------------------------------------------------------- */
.g-nav-section { margin-bottom: 18px; }
.g-nav-title {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 8px;
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-sm);
}
.g-nav-title:hover { background: var(--code-bg); }
.g-nav-title svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.g-nav-title .g-chev { margin-left: auto; transition: transform 0.15s; }
.g-nav-section.collapsed .g-chev { transform: rotate(-90deg); }
.g-nav-section.collapsed .g-nav-pages { display: none; }
.g-nav-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 1px 7px;
}
.g-nav-pages { list-style: none; margin: 2px 0 0; padding: 0 0 0 4px; }
.g-nav-pages a {
  display: block;
  color: var(--muted);
  font-size: 14px;
  padding: 5px 8px 5px 20px;
  border-left: 2px solid var(--border);
  margin-left: 12px;
  line-height: 1.4;
}
.g-nav-pages a:hover { color: var(--text); text-decoration: none; background: var(--code-bg); }
.g-nav-pages a.active {
  color: var(--primary);
  border-left-color: var(--primary);
  background: var(--primary-soft);
  font-weight: 500;
}

/* ---- Article ----------------------------------------------------------------------- */
.g-crumbs { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.g-crumbs a { color: var(--muted); }
.g-crumbs span { margin: 0 6px; }
.g-article { max-width: 760px; }
.g-article h1 { font-size: 34px; line-height: 1.2; margin: 0 0 8px; letter-spacing: -0.01em; }
.g-lead { font-size: 18px; color: var(--muted); margin: 0 0 28px; }
.g-article h2 {
  font-size: 22px;
  margin: 44px 0 12px;
  padding-top: 8px;
  letter-spacing: -0.005em;
}
.g-article h2 a.g-anchor, .g-article h3 a.g-anchor {
  color: var(--border);
  margin-left: 6px;
  font-weight: 400;
  opacity: 0;
}
.g-article h2:hover a.g-anchor, .g-article h3:hover a.g-anchor { opacity: 1; }
.g-article h3 { font-size: 17px; margin: 28px 0 8px; }
.g-article h4 { font-size: 15px; margin: 20px 0 6px; }
.g-article p, .g-article ul, .g-article ol { margin: 0 0 14px; }
.g-article li { margin: 4px 0; }
.g-article ul, .g-article ol { padding-left: 24px; }
.g-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 20px;
  font-size: 14.5px;
  display: block;
  overflow-x: auto;
}
.g-article th, .g-article td {
  text-align: left;
  vertical-align: top;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.g-article th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.g-article tr:last-child td { border-bottom: 0; }
.g-article thead th { border-bottom: 2px solid var(--border); }

/* Menu paths and on-screen labels */
.g-path {
  font-size: 0.92em;
  color: var(--text);
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  padding: 1px 7px;
  white-space: nowrap;
}
.g-ui {
  font-weight: 600;
}

/* Callouts */
.g-callout {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin: 18px 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 15px;
}
.g-callout > :first-child { margin-top: 0; }
.g-callout > :last-child { margin-bottom: 0; }
.g-callout h4 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.g-perm { border-left-color: var(--primary); }
.g-perm h4 { color: var(--primary); }
.g-perm ul { margin: 0; padding-left: 20px; }
.g-perm code { background: var(--primary-soft); }
.g-cross { border-left-color: var(--success); }
.g-cross h4 { color: var(--success); }
.g-note { border-left-color: var(--muted); }
.g-warn { border-left-color: var(--warning); background: var(--warning-soft); }
.g-warn h4 { color: var(--warning); }

/* Definition list for settings */
.g-fields dt { font-weight: 600; margin-top: 12px; }
.g-fields dd { margin: 2px 0 0; color: var(--text); }
.g-fields dd .g-meta { color: var(--muted); font-size: 14px; }

/* Cards on the landing page */
.g-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 20px 0 32px; }
.g-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.g-card:hover { border-color: var(--primary); text-decoration: none; }
.g-card h3 { margin: 0 0 4px; font-size: 16px; color: var(--primary); }
.g-card p { margin: 0; color: var(--muted); font-size: 14px; }
.g-card ul { margin: 8px 0 0; padding-left: 0; list-style: none; font-size: 14px; }
.g-card ul li { margin: 2px 0; }

/* Previous / next */
.g-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 56px 0 0;
  max-width: 760px;
}
.g-pager a {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text);
  background: var(--surface);
}
.g-pager a:hover { border-color: var(--primary); text-decoration: none; }
.g-pager a small { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.g-pager a.next { text-align: right; }
.g-footer {
  max-width: 760px;
  margin: 40px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

/* ---- Responsive ------------------------------------------------------------------ */
@media (max-width: 1279px) {
  .g-app { grid-template-columns: var(--rail) minmax(0, 1fr); }
  .g-toc { display: none; }
}
@media (max-width: 899px) {
  .g-app { grid-template-columns: minmax(0, 1fr); }
  .g-menu-btn { display: inline-flex; }
  .g-search { width: 100%; max-width: 320px; }
  .g-brand-sub { display: none; }
  .g-rail {
    position: fixed;
    top: var(--header);
    left: 0;
    bottom: 0;
    width: min(320px, 85vw);
    height: auto;
    transform: translateX(-100%);
    transition: transform 0.18s ease-out;
    z-index: 25;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  }
  body.nav-open .g-rail { transform: translateX(0); }
  .g-scrim {
    display: none;
    position: fixed;
    inset: var(--header) 0 0 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 20;
  }
  body.nav-open .g-scrim { display: block; }
  .g-main { padding: 24px 16px 64px; }
  .g-article h1 { font-size: 28px; }
  .g-pager { grid-template-columns: 1fr; }
}
@media (max-width: 599px) {
  .g-header-link { display: none; }
  .g-search { width: 100%; }
}
@media print {
  .g-header, .g-rail, .g-toc, .g-pager, .g-menu-btn, .g-scrim { display: none !important; }
  .g-app { display: block; }
  .g-main { padding: 0; }
}
