@import "tailwindcss";

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

/* ---------------------------------- */
/* Theme Variables                    */
/* ---------------------------------- */

:root {
  --radius: 0.625rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-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);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --chart-1: oklch(0.646 0.222 41.116);
  --chart-2: oklch(0.6 0.118 184.704);
  --chart-3: oklch(0.398 0.07 227.392);
  --chart-4: oklch(0.828 0.189 84.429);
  --chart-5: oklch(0.769 0.188 70.08);
  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-primary: oklch(0.205 0 0);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.97 0 0);
  --sidebar-accent-foreground: oklch(0.205 0 0);
  --sidebar-border: oklch(0.922 0 0);
  --sidebar-ring: oklch(0.708 0 0);
  --font-sans: Inter, sans-serif;
  --font-serif: Source Serif 4, serif;
  --font-mono: JetBrains Mono, monospace;
  --radius: 0.375rem;
  --shadow-2xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
  --shadow-xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
  --shadow-sm: 0 1px 3px 0px hsl(0 0% 0% / 0.1),
    0 1px 2px -1px hsl(0 0% 0% / 0.1);
  --shadow: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1);
  --shadow-md: 0 1px 3px 0px hsl(0 0% 0% / 0.1),
    0 2px 4px -1px hsl(0 0% 0% / 0.1);
  --shadow-lg: 0 1px 3px 0px hsl(0 0% 0% / 0.1),
    0 4px 6px -1px hsl(0 0% 0% / 0.1);
  --shadow-xl: 0 1px 3px 0px hsl(0 0% 0% / 0.1),
    0 8px 10px -1px hsl(0 0% 0% / 0.1);
  --shadow-2xl: 0 1px 3px 0px hsl(0 0% 0% / 0.25);
  --duration-accordion: 0.2s;
}

.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);
  --popover: oklch(0.269 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 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.371 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  --chart-1: oklch(0.488 0.243 264.376);
  --chart-2: oklch(0.696 0.17 162.48);
  --chart-3: oklch(0.769 0.188 70.08);
  --chart-4: oklch(0.627 0.265 303.9);
  --chart-5: oklch(0.645 0.246 16.439);
  --sidebar: oklch(0.205 0 0);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.488 0.243 264.376);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.269 0 0);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(1 0 0 / 10%);
  --sidebar-ring: oklch(0.439 0 0);
}

/* ---------------------------------- */
/* Theme Configuration                */
/* ---------------------------------- */

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-card: var(--card);
  --color-card-foreground: var(--card-foreground);
  --color-popover: var(--popover);
  --color-popover-foreground: var(--popover-foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-destructive: var(--destructive);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);
  --color-chart-1: var(--chart-1);
  --color-chart-2: var(--chart-2);
  --color-chart-3: var(--chart-3);
  --color-chart-4: var(--chart-4);
  --color-chart-5: var(--chart-5);
  --color-sidebar: var(--sidebar);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-ring: var(--sidebar-ring);

  --font-sans: var(--font-sans);
  --font-mono: var(--font-mono);
  --font-serif: var(--font-serif);

  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);

  --shadow-2xs: var(--shadow-2xs);
  --shadow-xs: var(--shadow-xs);
  --shadow-sm: var(--shadow-sm);
  --shadow: var(--shadow);
  --shadow-md: var(--shadow-md);
  --shadow-lg: var(--shadow-lg);
  --shadow-xl: var(--shadow-xl);
  --shadow-2xl: var(--shadow-2xl);

  --animate-marquee: marquee var(--duration) infinite linear;
  --animate-marquee-vertical: marquee-vertical var(--duration) linear infinite;
  --animate-accordion-down: accordion-down 0.2s ease-out;
  --animate-accordion-up: accordion-up 0.2s ease-out;

  @keyframes accordion-down {
    from {
      height: 0;
    }
    to {
      height: var(--radix-accordion-content-height);
    }
  }

  @keyframes accordion-up {
    from {
      height: var(--radix-accordion-content-height);
    }
    to {
      height: 0;
    }
  }

  @keyframes marquee {
    from {
      transform: translateX(0);
    }
    to {
      transform: translateX(calc(-100% - var(--gap)));
    }
  }
  @keyframes marquee-vertical {
    from {
      transform: translateY(0);
    }
    to {
      transform: translateY(calc(-100% - var(--gap)));
    }
  }
}

/* ---------------------------------- */
/* Base Styles                        */
/* ---------------------------------- */

@layer base {
  * {
    @apply border-border;
  }
  html {
    @apply scroll-smooth;
  }
  body {
    @apply bg-background text-foreground overscroll-none;
    font-synthesis-weight: none;
    text-rendering: optimizeLegibility;
  }

  @supports (font: -apple-system-body) and (-webkit-appearance: none) {
    [data-wrapper] {
      @apply min-[1800px]:border-t;
    }
  }
}

/* ---------------------------------- */
/* MDX & Code Styles                  */
/* ---------------------------------- */

/* Code Blocks */
[data-rehype-pretty-code-figure],
pre[class*="language-"] {
  @apply relative text-foreground font-mono;
  overflow: hidden;
  background-color: hsl(var(--card));
  border-radius: 0.5rem;
  border: 1px solid hsl(var(--border));
}

[data-rehype-pretty-code-figure] pre,
pre[class*="language-"] {
  @apply overflow-x-auto py-4 text-[13px] leading-[1.45] font-normal;
  background-color: transparent !important;
}

[data-rehype-pretty-code-figure] code,
code[class*="language-"] {
  @apply grid min-w-full break-words rounded-none border-0 bg-transparent p-0;
  counter-reset: line;
  box-decoration-break: clone;
}

[data-rehype-pretty-code-figure] [data-line],
pre[data-line-numbers="true"] [data-line] {
  @apply px-4 min-h-[1.45rem] py-0.5 w-full inline-block border-l-2 border-l-transparent;
}

[data-rehype-pretty-code-figure] [data-line-numbers] [data-line],
pre[data-line-numbers="true"] [data-line] {
  @apply px-2;
}

[data-rehype-pretty-code-figure] [data-line-numbers] > [data-line]::before,
pre[data-line-numbers="true"] [data-line]::before {
  @apply text-muted-foreground/40 text-xs font-mono;
  counter-increment: line;
  content: counter(line);
  display: inline-block;
  width: 1.8rem;
  margin-right: 1.4rem;
  text-align: right;
}

[data-rehype-pretty-code-figure] .line--highlighted,
pre[class*="language-"] .line--highlighted {
  @apply bg-muted/50 border-l-2 border-l-primary;
}

/* Syntax Highlighting */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata,
.hljs-comment {
  @apply text-muted-foreground;
}

.token.function,
.hljs-function {
  @apply text-blue-500 dark:text-blue-400;
}

.token.keyword,
.hljs-keyword {
  @apply text-purple-500 dark:text-purple-400;
}

.token.string,
.hljs-string {
  @apply text-green-500 dark:text-green-400;
}

.token.number,
.hljs-number {
  @apply text-orange-500 dark:text-orange-400;
}

.token.boolean,
.hljs-boolean {
  @apply text-red-500 dark:text-red-400;
}

.token.property,
.hljs-property {
  @apply text-blue-500 dark:text-blue-400;
}

.token.class-name,
.hljs-class,
.hljs-title {
  @apply text-yellow-500 dark:text-yellow-400;
}

.token.constant,
.hljs-constant {
  @apply text-purple-500 dark:text-purple-400;
}

.token.symbol,
.hljs-symbol {
  @apply text-pink-500 dark:text-pink-400;
}

.token.operator,
.hljs-operator {
  @apply text-muted-foreground;
}

.token.punctuation,
.hljs-punctuation {
  @apply text-muted-foreground;
}

/* Additional common syntax elements */
.hljs-tag,
.token.tag {
  @apply text-purple-500 dark:text-purple-400;
}

.hljs-attr,
.token.attr-name {
  @apply text-blue-500 dark:text-blue-400;
}

.hljs-built_in,
.token.builtin {
  @apply text-yellow-500 dark:text-yellow-400;
}

.hljs-type,
.token.type {
  @apply text-purple-500 dark:text-purple-400;
}

.hljs-variable,
.token.variable {
  @apply text-foreground;
}

[data-rehype-pretty-code-title] {
  @apply mt-2 pt-6 px-4 text-sm font-medium text-foreground;
}

[data-rehype-pretty-code-title] + pre {
  @apply mt-2;
}

/* Light/Dark Mode Code Theme Display */
.light [data-theme="light"] {
  display: block;
}

.light [data-theme="dark"] {
  display: none;
}

.dark [data-theme="light"] {
  display: none;
}

.dark [data-theme="dark"] {
  display: block;
}

/* Steps */
.mdx > .steps:first-child > h3:first-child {
  @apply mt-0;
}

.steps > h3 {
  @apply mt-8 mb-4 text-base font-semibold;
}

/* ---------------------------------- */
/* Custom Utilities                   */
/* ---------------------------------- */

.step:before {
  @apply absolute size-9 bg-muted rounded-full font-mono font-medium text-center text-base inline-flex items-center justify-center -indent-px border-4 border-background;
  @apply ml-[-50px] mt-[-4px];
  content: counter(step);
}

.chunk-container::after {
  content: "";
  @apply absolute -inset-4 shadow-xl rounded-xl border;
}

.no-scrollbar::-webkit-scrollbar {
  display: none; /* Chrome, Safari and Opera */
}

/* ---------------------------------- */
/* Scrollbar Styles                   */
/* ---------------------------------- */

::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: hsl(var(--border));
  border-radius: 5px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--border)) transparent;
}

/* ---------------------------------- */
/* Media Queries                      */
/* ---------------------------------- */

@media (max-width: 640px) {
  .container {
    @apply px-4;
  }
}

/* ---------------------------------- */
/* Lab Background Effect              */
/* ---------------------------------- */

.lab-bg {
  --mask-offset: 100px;
  -webkit-mask: linear-gradient(
      to bottom,
      transparent,
      #fff var(--mask-offset) calc(100% - var(--mask-offset)),
      transparent
    ),
    linear-gradient(
      to right,
      transparent,
      #fff var(--mask-offset) calc(100% - var(--mask-offset)),
      transparent
    );
  mask: linear-gradient(
      to bottom,
      transparent,
      #fff var(--mask-offset) calc(100% - var(--mask-offset)),
      transparent
    ),
    linear-gradient(
      to right,
      transparent,
      #fff var(--mask-offset) calc(100% - var(--mask-offset)),
      transparent
    );
  -webkit-mask-composite: source-in, xor;
  mask-composite: intersect;
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }
  body {
    @apply bg-background text-foreground;
  }
}
