/**
 * BarefootJS Design Tokens
 *
 * Shared CSS variables for all BarefootJS sites (docs, ui, lp).
 * Each site can override these values in its own globals.css.
 *
 * Color values use the OKLCH color space with the neutral theme
 * from site/ui as the canonical defaults.
 */

:root {
  /* ── Typography ──────────────────────────────────────── */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --tracking-tighter: -0.05em;
  --tracking-tight: -0.025em;
  --tracking-normal: 0;
  --tracking-wide: 0.025em;
  --tracking-wider: 0.05em;

  /* ── Spacing scale ───────────────────────────────────── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* ── Border radius ───────────────────────────────────── */
  --radius: 0.625rem;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  /* ── Transitions ─────────────────────────────────────── */
  --duration-fast: 0.15s;
  --duration-normal: 0.25s;

  /* ── Layout ──────────────────────────────────────────── */
  --header-height: 52px;

  /* ── Colors (OKLCH, neutral theme) ───────────────────── */
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);

  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);

  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);

  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);

  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);

  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);

  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.985 0 0);

  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);

  --gradient-start: oklch(0.65 0.18 145);
  --gradient-end: oklch(0.55 0.15 165);

  /* ── Shadows ─────────────────────────────────────────── */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);
}

.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);

  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);

  --primary: oklch(0.35 0 0);
  --primary-foreground: oklch(0.985 0 0);

  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);

  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);

  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);

  --destructive: oklch(0.704 0.191 22.216);
  --destructive-foreground: oklch(0.985 0 0);

  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);

  --gradient-start: oklch(0.70 0.18 145);
  --gradient-end: oklch(0.60 0.15 165);
}

/* BarefootJS Documentation — globals.css
 *
 * Site-specific styles for the documentation site.
 * Color tokens are provided by tokens.css (concatenated by build.ts).
 */

/* ── Reset & Base ──────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-width: 0;
  border-style: solid;
  border-color: var(--border);
}

:root {
  --sidebar-width: 14rem;    /* 224px — matches UI site (w-56) */
  --content-max-width: 1000px; /* matches UI site (max-w-[1000px]) */
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--foreground);
}

button {
  border-width: 0;
  border-style: solid;
  background-color: transparent;
  color: inherit;
  font: inherit;
}

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

/* ── Theme transition ──────────────────────────────────────── */

html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color var(--duration-fast) ease,
              color var(--duration-fast) ease,
              border-color var(--duration-fast) ease !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Sidebar ───────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 3.5rem; /* top-14 — matches UI site */
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  overflow-y: auto;
  padding: 16px 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  z-index: 90;
}

/* ── Sidebar Overlay (mobile) ──────────────────────────────── */

.sidebar-overlay {
  display: none;
}

/* ── Markdown Toggle Button ────────────────────────────────── */

.md-toggle-btn {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: color 0.15s;
  margin-right: auto;
}

.md-toggle-btn:hover {
  color: var(--foreground);
}

/* ── Document Title Bar ───────────────────────────────────── */

.doc-title-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 8px;
}

.doc-title {
  font-size: 1.875rem; /* text-3xl — matches UI site */
  font-weight: 700;
  line-height: 2.25rem;
  letter-spacing: -0.05em; /* tracking-tighter — matches UI site */
}

/* ── Main Content ──────────────────────────────────────────── */

.main-content {
  margin-left: var(--sidebar-width);
  padding: 5rem 1.5rem 3rem;
  min-height: 100vh;
}

.doc-content-wrapper {
  display: flex;
  gap: 4rem;  /* gap-16 — matches UI site */
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 1.75rem 1rem 0; /* top: compensate for * {margin:0} reset removing h1 default margin */
}

.doc-main-column {
  flex: 1;
  min-width: 0;
}

/* ── Typography ────────────────────────────────────────────── */

.doc-article h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  line-height: 1.25;
}

.doc-article h2 {
  position: relative;
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  line-height: 1.3;
  scroll-margin-top: 5rem;
}

.doc-article h3 {
  position: relative;
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 10px;
  line-height: 1.35;
  scroll-margin-top: 5rem;
}

.doc-article h4 {
  position: relative;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 20px;
  margin-bottom: 8px;
}

/* ── Heading Anchor Links ─────────────────────────────────── */

.doc-article .heading-anchor {
  position: absolute;
  left: -1.25rem;
  color: var(--muted-foreground);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.doc-article h2:hover > .heading-anchor,
.doc-article h3:hover > .heading-anchor,
.doc-article h4:hover > .heading-anchor,
.heading-anchor:focus {
  opacity: 1;
}

.doc-article p {
  margin-bottom: 16px;
}

.doc-article a {
  color: var(--primary);
  text-decoration: none;
}

.doc-article a:hover {
  text-decoration: underline;
}

.doc-article a.heading-anchor:hover {
  text-decoration: none;
}

.doc-article strong {
  font-weight: 600;
}

.doc-article ul,
.doc-article ol {
  margin-bottom: 16px;
  padding-left: 2em;
}

.doc-article li {
  margin-bottom: 4px;
}

.doc-article li > ul,
.doc-article li > ol {
  margin-top: 4px;
  margin-bottom: 4px;
}

.doc-article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

.doc-article blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--primary);
  background: var(--muted);
  border-radius: 0 6px 6px 0;
  color: var(--muted-foreground);
}

.doc-article blockquote p:last-child {
  margin-bottom: 0;
}

.doc-article img {
  max-width: 100%;
  border-radius: 6px;
}

.doc-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.doc-article th,
.doc-article td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.doc-article th {
  background: var(--muted);
  font-weight: 600;
}

/* ── Code ──────────────────────────────────────────────────── */

.doc-article code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
}

.doc-article pre {
  margin: 16px 0;
  border-radius: 8px;
  overflow-x: auto;
}

.doc-article pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
  line-height: 1.6;
}

/* Shiki dual theme support */
.doc-article .shiki {
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid var(--border);
}

:root span[style*="--shiki-light"] {
  color: var(--shiki-light);
}

.dark span[style*="--shiki-dark"] {
  color: var(--shiki-dark);
}

html.dark .shiki,
html.dark .shiki span {
  color: var(--shiki-dark) !important;
  background-color: var(--shiki-dark-bg) !important;
}

/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    background: var(--background);
    z-index: 200;
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
  }

  .sidebar-overlay.overlay-visible {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 150;
  }

  .mobile-menu-toggle {
    display: inline-flex;
  }

  .main-content {
    margin-left: 0;
    padding: 5rem 0.3rem 3rem; /* matches UI site mobile spacing */
  }

}
