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

/* Import AOS styles */
@import "aos/dist/aos.css";

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

.font-syne {
  font-family: "Syne", sans-serif;
  font-display: swap; /* Improve font loading performance */
}

.font-outfit {
  font-family: "Outfit", sans-serif;
  font-display: swap; /* Improve font loading performance */
}

@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);
}

:root {
  --radius: 0.65rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.141 0.005 285.823);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.141 0.005 285.823);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.141 0.005 285.823);
  --primary: oklch(0.705 0.213 47.604);
  --primary-foreground: oklch(0.98 0.016 73.684);
  --secondary: oklch(0.967 0.001 286.375);
  --secondary-foreground: oklch(0.21 0.006 285.885);
  --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);
  --accent-foreground: oklch(0.21 0.006 285.885);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.92 0.004 286.32);
  --input: oklch(0.92 0.004 286.32);
  --ring: oklch(0.705 0.213 47.604);
  --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.141 0.005 285.823);
  --sidebar-primary: oklch(0.705 0.213 47.604);
  --sidebar-primary-foreground: oklch(0.98 0.016 73.684);
  --sidebar-accent: oklch(0.967 0.001 286.375);
  --sidebar-accent-foreground: oklch(0.21 0.006 285.885);
  --sidebar-border: oklch(0.92 0.004 286.32);
  --sidebar-ring: oklch(0.705 0.213 47.604);
  --font-sans: "Syne", sans-serif;

  color-scheme: light;
  scroll-behavior: smooth;
}

.dark {
  --background: oklch(0.141 0.005 285.823);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.21 0.006 285.885);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.21 0.006 285.885);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.646 0.222 41.116);
  --primary-foreground: oklch(0.98 0.016 73.684);
  --secondary: oklch(0.274 0.006 286.033);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.274 0.006 286.033);
  --muted-foreground: oklch(0.705 0.015 286.067);
  --accent: oklch(0.274 0.006 286.033);
  --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.646 0.222 41.116);
  --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.21 0.006 285.885);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.646 0.222 41.116);
  --sidebar-primary-foreground: oklch(0.98 0.016 73.684);
  --sidebar-accent: oklch(0.274 0.006 286.033);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(1 0 0 / 10%);
  --sidebar-ring: oklch(0.646 0.222 41.116);

  color-scheme: dark;
}

@layer utilities {
  .bg-background {
    background-color: var(--color-background);
  }
  .text-foreground {
    color: var(--color-foreground);
  }
  .border-border {
    border-color: var(--color-border);
  }
  .outline-ring {
    outline-color: var(--color-ring);
  }
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }

  html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;

    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
  }

  body {
    @apply bg-background text-foreground;

    scrollbar-gutter: stable;

    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    overflow-x: hidden;
  }

  img,
  video {
    height: auto;
    max-width: 100%;
  }

  :focus-visible {
    outline: 2px solid var(--color-ring);
    outline-offset: 2px;
  }

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

.code-block {
  background-color: var(--code-bg) !important;
  color: var(--code-fg) !important;
  border: 1px solid var(--code-border);
  overflow: hidden;
  contain: layout style paint;
}

.code-block .token.comment,
.code-block .token.prolog,
.code-block .token.doctype,
.code-block .token.cdata {
  opacity: 0.7;
}

.code-block .token.punctuation {
  opacity: 0.8;
}

@media (max-width: 640px) {
  .code-block {
    border-radius: 0.5rem;
    font-size: 0.75rem;
  }

  .code-block pre {
    padding: 0.75rem !important;
    font-size: 0.75rem !important;
    line-height: 1.25rem !important;
  }

  [data-radix-dialog-content] {
    max-width: calc(100vw - 2rem) !important;
    max-height: calc(100vh - 2rem) !important;
  }

  button,
  [role="button"],
  input[type="submit"],
  input[type="button"] {
    min-height: 44px;
    min-width: 44px;
  }
}

.share-url-input {
  word-break: break-all;
  overflow-wrap: break-word;
  font-family:
    ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo,
    monospace;
}

.dialog-content {
  display: flex;
  flex-direction: column;
  max-height: 95vh;
  overflow: hidden;
}

.dialog-content .flex-1 {
  min-height: 0;
  overflow-y: auto;
}

.snippet-description {
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  max-width: 100%;
}

.snippet-title {
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

[data-scrollspy-link].scrollspy-active {
  @apply text-blue-500 font-medium;
}

[data-aos="zoom-y-out"] {
  transform: scaleX(1.03);
  opacity: 0;
  transition-property: transform, opacity;
}

.btn,
.btn-sm {
  @apply text-sm font-medium inline-flex items-center justify-center rounded-lg whitespace-nowrap transition-all;
}

.btn {
  @apply px-4 py-[11px] shadow-lg;
}

.btn-sm {
  @apply px-3 py-[5px] shadow-sm;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
}

::selection {
  @apply bg-primary text-white;
}

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

::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 5px;
  transition: background-color 0.2s ease;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  -ms-border-radius: 5px;
  -o-border-radius: 5px;
}

::-webkit-scrollbar-track {
  background-color: transparent;
  transition: background-color 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

::-webkit-scrollbar-thumb:active {
  background-color: var(--color-primary);
}

.shiki-code-block {
  @apply w-full;
  font-family:
    "Fira Code", "Monaco", "Cascadia Code", "Roboto Mono", "Consolas", "Menlo",
    "Ubuntu Mono", monospace;
  overflow: auto;
  contain: layout style;
}

.shiki-code-block pre {
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  overflow: auto;
  font-size: 14px;
  line-height: 1.6;
  tab-size: 2;
}

.shiki-code-block code {
  display: block;
  line-height: inherit;
  font-family: inherit;
  font-size: inherit;
}

.shiki-fallback {
  font-family:
    "Fira Code", "Monaco", "Cascadia Code", "Roboto Mono", "Consolas", "Menlo",
    "Ubuntu Mono", monospace;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.shiki-code-block::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.shiki-code-block::-webkit-scrollbar-track {
  background: hsl(var(--muted) / 0.2);
  border-radius: 4px;
}

.shiki-code-block::-webkit-scrollbar-thumb {
  background: hsl(var(--muted-foreground) / 0.3);
  border-radius: 4px;
}

.shiki-code-block::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground) / 0.5);
}

.shiki-code-block::-webkit-scrollbar-corner {
  background: transparent;
}

@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    transparent,
    hsl(var(--muted-foreground) / 0.1),
    transparent
  );
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
  will-change: background-position;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.animate-spin,
.animate-pulse,
.animate-bounce {
  will-change: transform;
}

p,
li,
blockquote {
  text-wrap: pretty;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
}

@media (hover: hover) {
  button:hover,
  [role="button"]:hover,
  a:hover {
    transition: all 0.2s ease-in-out;
  }
}

@media print {
  .no-print {
    display: none !important;
  }

  * {
    background: transparent !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  pre,
  blockquote {
    border: 1px solid #999;
    page-break-inside: avoid;
  }

  thead {
    display: table-header-group;
  }

  tr,
  img {
    page-break-inside: avoid;
  }

  img {
    max-width: 100% !important;
  }

  p,
  h2,
  h3 {
    orphans: 3;
    widows: 3;
  }

  h2,
  h3 {
    page-break-after: avoid;
  }
}

.shiki-code-block {
  contain: layout style paint;
  will-change: auto;
  isolation: isolate;
}

.shiki-code-block pre {
  contain: layout style;
  transform: translateZ(0);
}

.code-block-loading {
  background: linear-gradient(
    90deg,
    var(--muted) 25%,
    hsl(var(--muted-foreground) / 0.1) 50%,
    var(--muted) 75%
  );
  background-size: 200% 100%;
  animation: code-shimmer 1.5s ease-in-out infinite;
}

@keyframes code-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.shiki-code-block [data-line] {
  contain: layout;
  line-height: 1.5;
}

.shiki-fallback {
  font-family:
    "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New",
    monospace;
  line-height: 1.6;
  border-radius: 0.5rem;
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--muted)) !important;
  color: hsl(var(--foreground)) !important;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    transition:
      background-color 0.15s ease,
      color 0.15s ease;
  }

  .shiki-highlighted {
    transition:
      background-color 0.15s ease,
      color 0.15s ease;
  }
}

html[data-theme] {
  visibility: visible;
}

.shiki span {
  contain: layout style;
}

.shiki-code-block pre code {
  white-space: pre;
  word-wrap: normal;
  overflow-wrap: normal;
}
