@import 'tailwindcss';
@import 'tw-animate-css';

@custom-variant dark (&:is(.dark *));

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-border: var(--border);
  --color-card: var(--card);
  --color-card-foreground: var(--card-foreground);
  --color-accent: var(--accent);
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
}

:root {
  --radius: 0.375rem;

  /* Core palette */
  --background:      #050508;
  --background-alt:  #09090e;
  --foreground:      #d4d4d8;
  --foreground-hi:   #f4f4f5;
  --card:            #0d0d14;
  --card-foreground: #d4d4d8;

  /* Accents */
  --primary:            #00ff88;       /* fluorescent green */
  --primary-dim:        rgba(0,255,136,0.12);
  --primary-glow:       rgba(0,255,136,0.20);
  --primary-foreground: #050508;
  --secondary:          #00d4ff;       /* fluorescent cyan */
  --secondary-dim:      rgba(0,212,255,0.10);

  /* Muted / UI */
  --muted:            #111118;
  --muted-foreground: #71717a;
  --border:           rgba(255,255,255,0.07);
  --border-strong:    rgba(255,255,255,0.12);
  --accent:           #00ff88;
  --accent-dim:       rgba(0,255,136,0.10);

  /* Layout */
  --sidebar-width:    264px;
  --toc-width:        216px;
  --content-max-width: 780px;
  --header-height:    56px;

  /* Typography */
  --font-display: var(--font-mono-display), 'IBM Plex Mono', ui-monospace, monospace;
  --font-body:    var(--font-sans), 'IBM Plex Sans', ui-sans-serif, sans-serif;
  --font-code:    var(--font-code), 'JetBrains Mono', 'Cascadia Code', ui-monospace, monospace;
}

@layer base {
  * {
    box-sizing: border-box;
  }

  html {
    scroll-behavior: smooth;
  }

  body {
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

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

  /* Subtle scrollbar */
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
  }
  ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }
}

/* ─── Prose / markdown content ─────────────────────────────────────────── */

.prose {
  color: var(--foreground);
  max-width: var(--content-max-width);
  font-family: var(--font-body);
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5 {
  font-family: var(--font-display);
  color: var(--foreground-hi);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.prose h1 {
  font-size: 1.875rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 1.25rem;
  line-height: 1.15;
  color: var(--foreground-hi);
}

.prose h2 {
  font-size: 1.35rem;
  margin-top: 2.5rem;
  margin-bottom: 0.875rem;
  line-height: 1.25;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.prose h2::before {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 3rem;
  height: 1px;
  background: var(--primary);
  opacity: 0.7;
}

.prose h3 {
  font-size: 1.1rem;
  margin-top: 2rem;
  margin-bottom: 0.625rem;
  line-height: 1.3;
  color: var(--foreground-hi);
}

.prose h4 {
  font-size: 0.95rem;
  margin-top: 1.5rem;
  margin-bottom: 0.4rem;
  color: var(--foreground-hi);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.prose p {
  margin-top: 0;
  margin-bottom: 1.125rem;
  line-height: 1.8;
  color: var(--foreground);
}

.prose a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px solid rgba(0,255,136,0.3);
  transition: border-color 0.15s, color 0.15s;
}

.prose a:hover {
  color: var(--foreground-hi);
  border-bottom-color: var(--primary);
}

.prose ul,
.prose ol {
  margin-top: 0;
  margin-bottom: 1.125rem;
  padding-left: 1.5rem;
}

.prose li {
  margin-bottom: 0.4rem;
  line-height: 1.75;
  color: var(--foreground);
}

.prose ul li::marker { color: var(--primary); }

/* Inline code */
.prose code {
  font-family: var(--font-code);
  font-size: 0.84em;
  background: var(--muted);
  color: var(--primary);
  padding: 0.15em 0.45em;
  border-radius: 0.25rem;
  border: 1px solid var(--border-strong);
}

.prose pre {
  margin-top: 0;
  margin-bottom: 1.5rem;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--border-strong);
}

.prose pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border: none;
  font-size: 0.875rem;
}

.prose blockquote {
  border-left: 3px solid var(--primary);
  padding: 0.5rem 1rem;
  margin: 1.5rem 0;
  background: var(--primary-dim);
  border-radius: 0 0.375rem 0.375rem 0;
  color: var(--foreground);
  font-style: normal;
}

.prose blockquote p { margin: 0; opacity: 0.9; }

/* Tables */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  font-family: var(--font-body);
}

.prose th {
  background: var(--muted);
  border: 1px solid var(--border-strong);
  padding: 0.5rem 0.875rem;
  text-align: left;
  font-weight: 600;
  color: var(--foreground-hi);
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.prose td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.875rem;
  color: var(--foreground);
}

.prose tr:hover td { background: rgba(0,255,136,0.025); }

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

/* Anchor links on headings */
.prose .anchor {
  color: inherit;
  text-decoration: none;
}

.prose .anchor:hover::after {
  content: ' #';
  color: var(--primary);
  opacity: 0.6;
  font-weight: 400;
}

/* ─── Shiki / rehype-pretty-code ────────────────────────────────────────── */

[data-rehype-pretty-code-figure] {
  position: relative;
  margin-bottom: 1.5rem;
}

[data-rehype-pretty-code-figure] pre {
  overflow-x: auto;
  padding: 1.125rem 1.375rem;
  background: #020207 !important;
  border: 1px solid var(--border-strong);
  border-top: none;
  border-radius: 0 0 0.5rem 0.5rem;
  margin: 0;
  font-family: var(--font-code);
  font-size: 0.85rem;
  line-height: 1.65;
}

/* Code block without title: show top border with gradient */
[data-rehype-pretty-code-figure]:not(:has([data-rehype-pretty-code-title])) pre {
  border-top: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  position: relative;
}

[data-rehype-pretty-code-figure]:not(:has([data-rehype-pretty-code-title])) pre::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 60%, transparent 100%);
  opacity: 0.5;
  border-radius: 0.5rem 0.5rem 0 0;
}

[data-rehype-pretty-code-figure] [data-line] {
  padding: 0 0.25rem;
}

[data-rehype-pretty-code-title] {
  background: #0d0d18;
  border: 1px solid var(--border-strong);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  border-radius: 0.5rem 0.5rem 0 0;
  padding: 0.45rem 1.25rem;
  font-size: 0.75rem;
  font-family: var(--font-code);
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

[data-rehype-pretty-code-title]::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 60%, transparent 100%);
  opacity: 0.5;
}

/* ─── Header top gradient line ──────────────────────────────────────────── */

.docs-header-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--primary) 30%,
    var(--secondary) 70%,
    transparent 100%
  );
  opacity: 0.6;
}

/* ─── Nav link hover ─────────────────────────────────────────────────────── */

.nav-link {
  position: relative;
  transition: color 0.15s !important;
}

.nav-link:hover {
  color: var(--foreground-hi) !important;
  background: transparent !important;
}

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

.sidebar-item-active {
  color: var(--primary) !important;
  background: var(--primary-dim) !important;
  border-left: 2px solid var(--primary) !important;
}

.sidebar-item-link {
  transition: color 0.15s, background 0.15s;
}

.sidebar-item-link:hover {
  color: var(--foreground-hi) !important;
  background: rgba(255,255,255,0.04) !important;
}

/* ─── Pagefind search ────────────────────────────────────────────────────── */

.pagefind-ui {
  --pagefind-ui-background: var(--card);
  --pagefind-ui-border: var(--border-strong);
  --pagefind-ui-text: var(--foreground);
  --pagefind-ui-primary: var(--primary);
}
