/* Work Docs — shadcn/ui design language, tokens mirrored from the product. */

:root {
  color-scheme: light;
  --background: oklch(1 0 0);
  --foreground: oklch(0.141 0.005 285.823);
  --card: oklch(1 0 0);
  --primary: oklch(0.21 0.006 285.885);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.967 0.001 286.375);
  --muted: oklch(0.967 0.001 286.375);
  --muted-foreground: oklch(0.552 0.016 285.938);
  --accent: oklch(0.967 0.001 286.375);
  --border: oklch(0.92 0.004 286.32);
  --ring: oklch(0.705 0.015 286.067);
  --sidebar: oklch(0.985 0 0);
  --brand: oklch(0.141 0.005 285.823);
  --radius: 0.625rem;
  --code-bg: oklch(0.967 0.001 286.375);
}

.dark {
  color-scheme: dark;
  --background: oklch(0.141 0.005 285.823);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.21 0.006 285.885);
  --primary: oklch(0.75 0.129 276.1);
  --primary-foreground: oklch(0.21 0.05 276.1);
  --secondary: oklch(0.274 0.006 286.033);
  --muted: oklch(0.274 0.006 286.033);
  --muted-foreground: oklch(0.705 0.015 286.067);
  --accent: oklch(0.32 0.08 276.1);
  --border: oklch(1 0 0 / 10%);
  --ring: oklch(0.6 0.2 276.1);
  --sidebar: oklch(0.2 0.035 276.1);
  --brand: oklch(0.75 0.129 276.1);
  --code-bg: oklch(0.21 0.006 285.885);
}

* { box-sizing: border-box; }

::selection { background: var(--primary); color: var(--primary-foreground); }

* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in oklab, var(--muted-foreground) 35%, transparent) transparent;
}

/* scroll-padding-top clears the sticky header, so a jumped-to heading
   lands below it rather than under it. */
html {
  scroll-padding-top: 5rem;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 1rem; height: 1rem; }

/* --- Top bar ------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 3.5rem;
  padding: 0 1.25rem;
  background: color-mix(in oklab, var(--background) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
}

.wordmark-badge {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: calc(var(--radius) - 2px);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.8125rem;
  font-weight: 700;
}

.wordmark-docs { color: var(--muted-foreground); font-weight: 400; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.search-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 2rem;
  padding: 0 0.625rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  min-width: 13rem;
}

.search-button:hover { background: var(--accent); }
.search-button kbd {
  margin-left: auto;
  padding: 0 0.375rem;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  background: var(--muted);
  font-family: inherit;
  font-size: 0.6875rem;
}

.mode-button, .menu-button {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground);
}
.mode-button:hover, .menu-button:hover { background: var(--accent); color: var(--foreground); }
.icon-moon { display: none; }
.dark .icon-moon { display: block; }
.dark .icon-sun { display: none; }
.menu-button { display: none; }

.app-link {
  display: flex;
  align-items: center;
  height: 2rem;
  padding: 0 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

/* --- Shell --------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr) 13rem;
  gap: 2.5rem;
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.sidebar {
  position: sticky;
  top: 3.5rem;
  height: calc(100vh - 3.5rem);
  overflow-y: auto;
  padding: 1.5rem 0.75rem 2rem 0;
  border-right: 1px solid var(--border);
}

.nav-section + .nav-section { margin-top: 1.25rem; }

.nav-heading {
  padding: 0 0.625rem;
  margin-bottom: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.nav-link {
  display: block;
  padding: 0.3125rem 0.625rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  text-decoration: none;
}

.nav-link:hover { background: var(--accent); color: var(--foreground); }
.nav-link.active { background: var(--accent); color: var(--brand); font-weight: 500; }

.content { padding: 2.5rem 0 4rem; min-width: 0; }

.toc {
  position: sticky;
  top: 3.5rem;
  height: calc(100vh - 3.5rem);
  overflow-y: auto;
  padding: 2.5rem 0 2rem;
  font-size: 0.8125rem;
}

.toc-heading { font-weight: 600; margin-bottom: 0.5rem; font-size: 0.75rem; }

.toc-link {
  display: block;
  padding: 0.1875rem 0;
  color: var(--muted-foreground);
  text-decoration: none;
}
.toc-link:hover { color: var(--foreground); }

.page-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
.page-footer a {
  color: var(--muted-foreground);
  text-decoration: none;
}

.page-footer a:hover {
  color: var(--foreground);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* --- Prose --------------------------------------------------------------- */

.prose h1 {
  margin: 0 0 0.75rem;
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.prose h1 + p {
  margin-top: 0;
  font-size: 1.0625rem;
  color: var(--muted-foreground);
}

.prose h2 {
  margin: 2.5rem 0 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.prose h3 { margin: 1.75rem 0 0.5rem; font-size: 1rem; font-weight: 600; }

.prose p { margin: 0.75rem 0; }
.prose ul, .prose ol { margin: 0.75rem 0; padding-left: 1.375rem; }
.prose li { margin: 0.3125rem 0; }
.prose li::marker { color: var(--muted-foreground); }

.prose a { color: var(--brand); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in oklab, var(--brand) 40%, transparent); }
.prose a:hover { text-decoration-color: var(--brand); }

.prose code {
  padding: 0.125rem 0.375rem;
  border-radius: 0.375rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125em;
}

.prose pre {
  margin: 1rem 0;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--code-bg);
  overflow-x: auto;
  line-height: 1.55;
}

.prose pre code { padding: 0; border: 0; background: none; font-size: 0.8125rem; }

.prose blockquote {
  margin: 1rem 0;
  padding: 0.625rem 1rem;
  border-left: 3px solid var(--brand);
  border-radius: 0 calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0;
  background: var(--muted);
  color: var(--foreground);
}
.prose blockquote p { margin: 0.25rem 0; }

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

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

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.prose th {
  padding: 0.5rem 0.875rem;
  text-align: left;
  font-weight: 500;
  color: var(--muted-foreground);
  background: var(--muted);
  white-space: nowrap;
}

.prose td {
  padding: 0.5rem 0.875rem;
  border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.prose kbd {
  display: inline-block;
  min-width: 1.55em;
  padding: 0.15em 0.4em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 0.375rem;
  background: var(--muted);
  color: var(--foreground);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8em;
  line-height: 1.4;
  text-align: center;
  vertical-align: baseline;
}

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

.search-overlay[hidden] { display: none; }

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  padding-top: 10vh;
  background: oklch(0 0 0 / 40%);
  backdrop-filter: blur(2px);
}

.search-panel {
  width: min(34rem, calc(100vw - 2rem));
  height: fit-content;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 16px 48px oklch(0 0 0 / 25%);
  animation: menu-in 0.12s ease-out;
}

@keyframes menu-in { from { opacity: 0; scale: 0.98; } }

.search-input {
  padding: 0.875rem 1rem;
  border: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: transparent;
  color: var(--foreground);
  font: inherit;
  outline: none;
}

/* The divider belongs to the results, not the input: with no query the
   list is empty and collapses, taking the rule with it, so the panel is
   a plain search field rather than a field over a blank strip. */
.search-results {
  overflow-y: auto;
  padding: 0.375rem;
  border-top: 1px solid var(--border);
}

.search-results:empty { display: none; }

.search-result {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  text-decoration: none;
}
.search-result:hover, .search-result.selected { background: var(--accent); }
.search-result-title { font-size: 0.875rem; font-weight: 500; }
.search-result-context { font-size: 0.75rem; color: var(--muted-foreground); }
.search-empty { padding: 1rem 0.75rem; font-size: 0.875rem; color: var(--muted-foreground); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .search-panel { animation: none; }
}

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

@media (max-width: 72rem) {
  .shell { grid-template-columns: 15rem minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 52rem) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .menu-button { display: grid; }
  .search-button { min-width: 0; }
  .search-button span { display: none; }
  .search-button kbd { display: none; }
  .app-link { display: none; }
  .sidebar {
    position: fixed;
    top: 3.5rem;
    left: 0;
    z-index: 30;
    width: 16rem;
    padding: 1.25rem 0.75rem 2rem 1rem;
    background: var(--background);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.15s ease-out;
  }
  .sidebar.open { transform: none; }
}
