/* ============================================================
   Baybay Docs — prototype stylesheet
   Palette (locked):
     bg        #FFFFFF
     panel     #F6F8F7
     text      #1E2523
     muted     #5C6B66
     accent    #0B6B4F
     tint      #E3F1EB
     code bg   #10201B
   Type: IBM Plex Sans (body/UI), IBM Plex Mono (code, wordmark)
   ============================================================ */

:root {
  --bg: #FFFFFF;
  --panel: #F6F8F7;
  --text: #1E2523;
  --muted: #5C6B66;
  --accent: #0B6B4F;
  --tint: #E3F1EB;
  --code-bg: #10201B;
  --border: #E1E7E4;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --header-h: 3.5rem;
  --sidebar-w: 16.5rem;
  --toc-w: 13rem;
  --radius: 6px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

code, kbd, pre, samp { font-family: var(--mono); }

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.wordmark {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
}
.wordmark:hover { text-decoration: none; }
.wordmark .cursor-block {
  color: var(--accent);
  font-weight: 400;
}
.wordmark .version {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: 0.5rem;
  align-self: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}

.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0.5rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

.header-spacer { flex: 1; }

.search-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 0 0 auto;
  max-width: 14rem;
  padding: 0.45rem 0.6rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
}
.search-button:hover { border-color: var(--accent); }
.search-button .search-label { display: none; }
.search-button .kbd-hint {
  display: none;
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
}

.header-links {
  display: none;
  gap: 1rem;
  font-size: 0.85rem;
}
.header-links a { color: var(--muted); }
.header-links a:hover { color: var(--accent); }

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

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: 80rem;
  margin: 0 auto;
}

.layout.with-toc {
  grid-template-columns: minmax(0, 1fr);
}

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

.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  z-index: 90;
  width: min(18rem, 84vw);
  height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  padding: 1.5rem 1rem 2rem 1.25rem;
  border-right: 1px solid var(--border);
  background: var(--bg);
  box-shadow: 0 12px 40px rgba(30, 37, 35, 0.2);
  transform: translateX(-105%);
  visibility: hidden;
}
@media (prefers-reduced-motion: no-preference) {
  .sidebar { transition: transform 0.22s ease, visibility 0.22s; }
}
body.nav-open .sidebar {
  transform: translateX(0);
  visibility: visible;
}
body.nav-open { overflow: hidden; }

.sidebar h2 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin: 1.5rem 0 0.4rem;
}
.sidebar h2:first-child { margin-top: 0; }

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

.sidebar a {
  display: block;
  padding: 0.3rem 0.6rem;
  font-size: 0.875rem;
  color: var(--text);
  border-radius: var(--radius);
  border-left: 2px solid transparent;
}
.sidebar a:hover {
  background: var(--panel);
  text-decoration: none;
}
.sidebar a[aria-current="page"] {
  background: var(--tint);
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
}

.sidebar-backdrop { display: none; }
body.nav-open .sidebar-backdrop {
  display: block;
  position: fixed;
  inset: var(--header-h) 0 0 0;
  z-index: 80;
  background: rgba(30, 37, 35, 0.35);
  border: 0;
  padding: 0;
  width: 100%;
}

/* ---------- Main content ---------- */

.content {
  min-width: 0;
  padding: 1.5rem 1.25rem 3rem;
}

.breadcrumb {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 1rem;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }

article h1 {
  font-size: 1.6rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

.lede {
  font-size: 1.1rem;
  color: var(--muted);
  margin: 0 0 2rem;
  max-width: 44rem;
}

article h2 {
  font-size: 1.4rem;
  letter-spacing: -0.015em;
  margin: 2.5rem 0 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
article h3 {
  font-size: 1.1rem;
  margin: 1.75rem 0 0.5rem;
}

article p, article li { max-width: 44rem; }

article code:not(pre code) {
  font-size: 0.86em;
  background: var(--tint);
  color: var(--accent);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

kbd {
  font-size: 0.8em;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.1em 0.45em;
}

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

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

.callout {
  display: flex;
  gap: 0.7rem;
  max-width: 44rem;
  margin: 1.25rem 0;
  padding: 0.85rem 1rem;
  background: var(--tint);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.92rem;
}
.callout p { margin: 0; }
.callout .callout-label {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

/* ---------- Code blocks ---------- */

.code-block {
  position: relative;
  max-width: 46rem;
  margin: 1.25rem 0;
  background: var(--code-bg);
  border-radius: 8px;
  overflow: hidden;
}

.code-block .code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
.code-block .lang {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7FA89A;
}

.copy-btn {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: #C9D7D1;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 0.15rem 0.6rem;
  cursor: pointer;
}
.copy-btn:hover { background: rgba(255, 255, 255, 0.14); }
.copy-btn.copied { color: #7EE2B8; border-color: #7EE2B8; }
.copy-btn:focus-visible { outline-color: #7EE2B8; }

.code-block pre {
  margin: 0;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.6;
  color: #DCE8E2;
}
.code-block code { display: block; min-width: max-content; }

/* muted output lines / comments inside code */
.code-block .dim { color: #7C8F88; }
.code-block .ok { color: #7EE2B8; }
.code-block .cmd { color: #FFFFFF; font-weight: 500; }
.code-block .prompt { color: #58C99B; user-select: none; }

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

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  margin: 1.25rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
}
th, td {
  text-align: left;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:last-child td { border-bottom: 0; }
th {
  background: var(--panel);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
}
td code { white-space: nowrap; }

/* ---------- Right TOC ---------- */

.toc {
  display: none;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 2.25rem 1rem 2rem 0.5rem;
  font-size: 0.8rem;
}
.toc-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin: 0 0 0.6rem;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: block;
  padding: 0.22rem 0 0.22rem 0.75rem;
  color: var(--muted);
  border-left: 2px solid var(--border);
}
.toc li.toc-h3 a { padding-left: 1.6rem; }
.toc a:hover { color: var(--accent); text-decoration: none; }
.toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* ---------- Prev / Next ---------- */

.pagination {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 3.5rem;
  max-width: 46rem;
}
.pagination a {
  flex: 1;
  display: block;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.pagination a:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.pagination .dir {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.pagination .page-name {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
}
.pagination .next { text-align: left; margin-left: 0; }

/* ---------- Landing page ---------- */

.hero {
  padding: 1.5rem 0 2.5rem;
  max-width: 46rem;
}
.hero h1 {
  font-size: 1.9rem;
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin: 0 0 0.75rem;
}
.hero h1 .accent { color: var(--accent); }
.hero .lede { margin-bottom: 2rem; }

.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}
.btn {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #095a43; text-decoration: none; }
.btn-secondary { color: var(--accent); background: var(--bg); }
.btn-secondary:hover { background: var(--tint); text-decoration: none; }

/* Terminal hero */

.terminal {
  max-width: 46rem;
  background: var(--code-bg);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 32px -12px rgba(16, 32, 27, 0.45);
}
.terminal-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
.terminal-bar .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}
.terminal-bar .term-title {
  margin-left: 0.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: #7C8F88;
}
.terminal-body {
  padding: 1rem 1.1rem 1.2rem;
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.7;
  color: #DCE8E2;
  min-height: 9.5rem;
  overflow-x: auto;
}
.terminal-body .line { display: block; white-space: pre; }

.caret {
  display: inline-block;
  width: 0.55em;
  height: 1.1em;
  vertical-align: text-bottom;
  background: #58C99B;
}
@media (prefers-reduced-motion: no-preference) {
  .caret { animation: blink 1.06s steps(1) infinite; }
}
@keyframes blink { 50% { opacity: 0; } }

/* Quick-start cards + feature grid */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}
.card {
  display: block;
  padding: 1.1rem 1.2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
a.card:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.card .card-step {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent);
  display: block;
  margin-bottom: 0.35rem;
}
.card h3 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
}
.card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
a.card .card-cta {
  display: inline-block;
  margin-top: 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}
.feature {
  background: var(--bg);
  padding: 1.2rem 1.25rem;
}
.feature .feature-key {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
  display: block;
  margin-bottom: 0.4rem;
}
.feature h3 { margin: 0 0 0.3rem; font-size: 0.98rem; }
.feature p { margin: 0; font-size: 0.85rem; color: var(--muted); }

.landing-section { margin-top: 3.5rem; }
.landing-section > h2 {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}
.landing-section > .section-sub {
  color: var(--muted);
  margin-top: -0.35rem;
  font-size: 0.95rem;
}

/* ---------- Search modal ---------- */

.search-dialog {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  width: min(34rem, calc(100vw - 2rem));
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 24px 60px -16px rgba(30, 37, 35, 0.35);
}
.search-dialog::backdrop {
  background: rgba(30, 37, 35, 0.4);
  backdrop-filter: blur(2px);
}
.search-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  margin: 0;
}
.search-form input {
  flex: 1;
  border: 0;
  font: inherit;
  font-size: 1rem;
  background: transparent;
  color: var(--text);
}
.search-form input:focus { outline: none; }
.search-form .esc-hint {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
}
.search-results {
  list-style: none;
  margin: 0;
  padding: 0.4rem;
  max-height: 19rem;
  overflow-y: auto;
}
.search-results a {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text);
}
.search-results a:hover,
.search-results a:focus-visible {
  background: var(--tint);
  text-decoration: none;
}
.search-results .result-title {
  font-weight: 600;
  font-size: 0.9rem;
}
.search-results .result-page {
  font-size: 0.75rem;
  color: var(--muted);
}
.search-results mark {
  background: transparent;
  color: var(--accent);
  font-weight: 700;
}
.search-empty {
  padding: 1rem 0.9rem 1.2rem;
  font-size: 0.85rem;
  color: var(--muted);
}

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

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.site-footer .footer-inner {
  max-width: 80rem;
  margin: 0 auto;
  padding: 1.25rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
}
.site-footer a { color: var(--accent); }

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

@media (min-width: 481px) {
  .search-button .search-label { display: inline; }
  .search-button { flex: 1; padding: 0.4rem 0.65rem; }
  .pagination { flex-direction: row; }
  .pagination .next { text-align: right; margin-left: auto; }
  article h1 { font-size: 2rem; }
}

@media (min-width: 821px) {
  .layout, .layout.with-toc { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }

  .nav-toggle { display: none; }

  .sidebar {
    position: sticky;
    left: auto;
    z-index: auto;
    width: auto;
    height: calc(100vh - var(--header-h));
    box-shadow: none;
    transform: none;
    visibility: visible;
    transition: none;
  }
  body.nav-open .sidebar {
    transform: none;
    visibility: visible;
  }
  body.nav-open .sidebar-backdrop { display: none; }
  body.nav-open { overflow: visible; }

  .content { padding: 2.25rem 2.5rem 4rem; }
  .hero { padding-top: 3.5rem; }
  .hero h1 { font-size: 2.5rem; }
  .search-button { min-width: 13rem; flex: 0 1 auto; max-width: none; }
  .search-button .kbd-hint { display: inline; }
  .header-links { display: flex; }
  .site-footer .footer-inner { padding: 1.4rem 2.5rem; }
}

@media (min-width: 1081px) {
  .layout.with-toc { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w); }
  .toc { display: block; }
}
