@import "tailwindcss";
@import "tw-animate-css";
@import "shadcn/tailwind.css";
@import "@fontsource-variable/ibm-plex-sans";

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

@theme inline {
    --font-heading: var(--font-sans);
    --font-sans: 'IBM Plex Sans Variable', sans-serif;
    --color-sidebar-ring: var(--sidebar-ring);
    --color-sidebar-border: var(--sidebar-border);
    --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
    --color-sidebar-accent: var(--sidebar-accent);
    --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
    --color-sidebar-primary: var(--sidebar-primary);
    --color-sidebar-foreground: var(--sidebar-foreground);
    --color-sidebar: var(--sidebar);
    --color-chart-5: var(--chart-5);
    --color-chart-4: var(--chart-4);
    --color-chart-3: var(--chart-3);
    --color-chart-2: var(--chart-2);
    --color-chart-1: var(--chart-1);
    --color-ring: var(--ring);
    --color-input: var(--input);
    --color-border: var(--border);
    --color-destructive: var(--destructive);
    --color-accent-foreground: var(--accent-foreground);
    --color-accent: var(--accent);
    --color-muted-foreground: var(--muted-foreground);
    --color-muted: var(--muted);
    --color-secondary-foreground: var(--secondary-foreground);
    --color-secondary: var(--secondary);
    --color-primary-foreground: var(--primary-foreground);
    --color-primary: var(--primary);
    --color-popover-foreground: var(--popover-foreground);
    --color-popover: var(--popover);
    --color-card-foreground: var(--card-foreground);
    --color-card: var(--card);
    --color-foreground: var(--foreground);
    --color-background: var(--background);
    --radius-sm: calc(var(--radius) * 0.6);
    --radius-md: calc(var(--radius) * 0.8);
    --radius-lg: var(--radius);
    --radius-xl: calc(var(--radius) * 1.4);
    --radius-2xl: calc(var(--radius) * 1.8);
    --radius-3xl: calc(var(--radius) * 2.2);
    --radius-4xl: calc(var(--radius) * 2.6);
}

:root {
    --background: oklch(0.974 0.026 90.1);
    --foreground: oklch(0.30 0.02 150);
    --card: oklch(0.952 0.031 98.9);
    --card-foreground: oklch(0.30 0.02 150);
    --popover: oklch(0.952 0.031 98.9);
    --popover-foreground: oklch(0.30 0.02 150);
    --primary: oklch(0.45 0.12 145);
    --primary-foreground: oklch(0.97 0.02 90);
    --secondary: oklch(0.937 0.031 98.9);
    --secondary-foreground: oklch(0.30 0.02 150);
    --muted: oklch(0.937 0.031 98.9);
    --muted-foreground: oklch(0.55 0.02 150);
    --accent: oklch(0.937 0.031 98.9);
    --accent-foreground: oklch(0.30 0.02 150);
    --destructive: oklch(0.709 0.128 19.6);
    --border: oklch(0.892 0.028 98.1);
    --input: oklch(0.892 0.028 98.1);
    --ring: oklch(0.45 0.12 145);
    --chart-1: oklch(0.45 0.12 145);
    --chart-2: oklch(0.749 0.063 185.5);
    --chart-3: oklch(0.750 0.082 349.2);
    --chart-4: oklch(0.709 0.128 19.6);
    --chart-5: oklch(0.30 0.02 150);
    --radius: 0.625rem;
    --sidebar: oklch(0.952 0.031 98.9);
    --sidebar-foreground: oklch(0.30 0.02 150);
    --sidebar-primary: oklch(0.45 0.12 145);
    --sidebar-primary-foreground: oklch(0.97 0.02 90);
    --sidebar-accent: oklch(0.937 0.031 98.9);
    --sidebar-accent-foreground: oklch(0.30 0.02 150);
    --sidebar-border: oklch(0.892 0.028 98.1);
    --sidebar-ring: oklch(0.45 0.12 145);
}

.dark {
    --background: oklch(0.324 0.015 240.4);
    --foreground: oklch(0.830 0.041 86.1);
    --card: oklch(0.360 0.017 227.1);
    --card-foreground: oklch(0.830 0.041 86.1);
    --popover: oklch(0.360 0.017 227.1);
    --popover-foreground: oklch(0.830 0.041 86.1);
    --primary: oklch(0.773 0.091 125.8);
    --primary-foreground: oklch(0.324 0.015 240.4);
    --secondary: oklch(0.386 0.019 229.5);
    --secondary-foreground: oklch(0.830 0.041 86.1);
    --muted: oklch(0.386 0.019 229.5);
    --muted-foreground: oklch(0.723 0.019 153.4);
    --accent: oklch(0.386 0.019 229.5);
    --accent-foreground: oklch(0.830 0.041 86.1);
    --destructive: oklch(0.709 0.128 19.6);
    --border: oklch(0.515 0.021 232.9);
    --input: oklch(0.515 0.021 232.9);
    --ring: oklch(0.773 0.091 125.8);
    --chart-1: oklch(0.773 0.091 125.8);
    --chart-2: oklch(0.749 0.063 185.5);
    --chart-3: oklch(0.750 0.082 349.2);
    --chart-4: oklch(0.709 0.128 19.6);
    --chart-5: oklch(0.647 0.020 155.6);
    --sidebar: oklch(0.360 0.017 227.1);
    --sidebar-foreground: oklch(0.830 0.041 86.1);
    --sidebar-primary: oklch(0.773 0.091 125.8);
    --sidebar-primary-foreground: oklch(0.324 0.015 240.4);
    --sidebar-accent: oklch(0.416 0.023 157.1);
    --sidebar-accent-foreground: oklch(0.830 0.041 86.1);
    --sidebar-border: oklch(0.515 0.021 232.9);
    --sidebar-ring: oklch(0.773 0.091 125.8);
}

@layer base {
  * {
    @apply border-border outline-ring/50;
    }
  body {
    @apply bg-background text-foreground;
    }
  html {
    @apply font-sans;
    scroll-behavior: smooth;
    }
}

.prose h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  color: var(--foreground);
}

.prose h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--primary);
}

.prose p {
  margin-bottom: 1rem;
  line-height: 1.75;
  color: var(--muted-foreground);
}

.prose ul {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
  list-style-type: disc;
}

.prose ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
  list-style-type: decimal;
}

.prose li {
  margin-bottom: 0.375rem;
  line-height: 1.65;
  color: var(--muted-foreground);
}

.prose code {
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  background-color: var(--muted);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  color: var(--foreground);
}

.prose pre {
  position: relative;
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  overflow-y: visible;
  margin-bottom: 1.25rem;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.7;
  background-color: var(--card) !important;
  color: var(--card-foreground);
}

.prose .astro-code {
  position: relative !important;
  background-color: var(--card) !important;
  color: var(--card-foreground) !important;
}

.prose pre code {
  background: none !important;
  border: none;
  padding: 0;
  color: var(--card-foreground);
}

.prose pre .copy-code {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 10;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  color: var(--muted-foreground);
  background: var(--background);
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
  cursor: pointer;
  pointer-events: auto;
}

.prose pre:hover .copy-code {
  opacity: 1;
}

.prose .astro-code .copy-code {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 10;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  color: var(--muted-foreground);
  background: var(--background);
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
  cursor: pointer;
  pointer-events: auto;
}

.prose .astro-code:hover .copy-code {
  opacity: 1;
}

.prose .astro-code .copy-code:hover {
  color: var(--primary);
}

.prose pre .copy-code:hover {
  color: var(--primary);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.prose th {
  background-color: var(--card);
  padding: 0.625rem 0.875rem;
  text-align: left;
  font-weight: 600;
  color: var(--foreground);
  border-bottom: 1px solid var(--border);
}

.prose td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border);
}

.prose td code {
  background-color: var(--muted);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.85rem;
}

.prose tr:nth-child(even) {
  background-color: var(--card);
}

.prose a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prose a:hover {
  opacity: 0.8;
}

.prose strong {
  color: var(--foreground);
  font-weight: 600;
}

.prose hr {
  border-color: var(--border);
  margin: 2rem 0;
}

.prose blockquote {
  border-left: 2px solid var(--muted-foreground);
  padding-left: 1rem;
  color: var(--muted-foreground);
  font-style: italic;
  margin-bottom: 1rem;
}

.dark .astro-code {
  background-color: var(--card) !important;
}

.dark .astro-code code span {
  color: var(--shiki-dark) !important;
  background-color: var(--shiki-dark-bg) !important;
  font-style: var(--shiki-dark-font-style) !important;
  font-weight: var(--shiki-dark-font-weight) !important;
  text-decoration: var(--shiki-dark-text-decoration) !important;
}

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

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

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

::-webkit-scrollbar-thumb:hover {
  background: var(--muted-foreground);
}

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

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