@import "tailwindcss";
@import "tw-animate-css";
@import "shadcn/tailwind.css";

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

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --font-sans: var(--font-sans);
  --font-mono: var(--font-geist-mono);
  --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);
  --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.985 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.96 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.96 0 0);
  --muted-foreground: oklch(0.5 0 0);
  --accent: oklch(0.96 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.58 0.22 27);
  --border: oklch(0.91 0 0);
  --input: oklch(0.91 0 0);
  --ring: oklch(0.708 0 0);
  --radius: 0.75rem;
}

.dark {
  --background: oklch(0.1 0 0);
  --foreground: oklch(0.93 0 0);
  --card: oklch(0.14 0 0);
  --card-foreground: oklch(0.93 0 0);
  --popover: oklch(0.14 0 0);
  --popover-foreground: oklch(0.93 0 0);
  --primary: oklch(0.93 0 0);
  --primary-foreground: oklch(0.1 0 0);
  --secondary: oklch(0.18 0 0);
  --secondary-foreground: oklch(0.93 0 0);
  --muted: oklch(0.18 0 0);
  --muted-foreground: oklch(0.55 0 0);
  --accent: oklch(0.2 0 0);
  --accent-foreground: oklch(0.93 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 8%);
  --input: oklch(1 0 0 / 12%);
  --ring: oklch(0.5 0 0);
}

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

/* Scrollbar styling */
.scrollbar-none {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.scrollbar-none::-webkit-scrollbar {
  display: none;
}

/* Custom thin scrollbar — applied globally so dropdowns, sidebars, code
   editors, and overflow areas all share one calm visual language instead
   of the heavy native macOS / Chromium default. */
* {
  scrollbar-width: thin;
  scrollbar-color: rgb(0 0 0 / 0.18) transparent;
}
.dark * {
  scrollbar-color: rgb(255 255 255 / 0.14) transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background-color: rgb(0 0 0 / 0.16);
  border-radius: 9999px;
  border: 2px solid transparent;
  background-clip: content-box;
  min-height: 24px;
  transition: background-color 0.15s ease;
}
*::-webkit-scrollbar-thumb:hover {
  background-color: rgb(0 0 0 / 0.32);
  background-clip: content-box;
}
.dark *::-webkit-scrollbar-thumb {
  background-color: rgb(255 255 255 / 0.12);
}
.dark *::-webkit-scrollbar-thumb:hover {
  background-color: rgb(255 255 255 / 0.22);
}
*::-webkit-scrollbar-corner {
  background: transparent;
}

/* Grid card entrance animation */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in-up {
  animation: fade-in-up 0.3s ease-out both;
}

/* Carousel progress bar */
@keyframes progress {
  from { width: 0%; }
  to { width: 100%; }
}

.animate-progress {
  animation-fill-mode: forwards;
}

/* Floating icon animation */
@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(2deg); }
}

.animate-float {
  animation: float 4s ease-in-out infinite;
}

/* Fade in animation for carousel slides */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fade-in 0.5s ease-out both;
}

/* Subtle icon preview background (ensures visibility in both themes) */
.icon-preview-bg {
  background: radial-gradient(
    circle at center,
    oklch(0.98 0 0) 0%,
    oklch(0.94 0.003 260) 100%
  );
}

.dark .icon-preview-bg {
  background: radial-gradient(
    circle at center,
    oklch(0.22 0.008 260) 0%,
    oklch(0.16 0.005 260) 100%
  );
}

/* View Transitions: smooth cross-fade between pages */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 150ms;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  mix-blend-mode: normal;
}

/* Keep old page visible while new one fades in (prevents white flash) */
::view-transition-old(root) {
  animation: vt-fade-out 150ms cubic-bezier(0.4, 0, 0.2, 1) both;
  z-index: 1;
}

::view-transition-new(root) {
  animation: vt-fade-in 200ms cubic-bezier(0.4, 0, 0.2, 1) both;
  z-index: 2;
}

@keyframes vt-fade-out {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes vt-fade-in {
  0% { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0ms;
  }
}

/* Global reduced-motion guard: disable all animations/transitions */
@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;
  }
}
