@tailwind base;
@tailwind components;
@tailwind utilities;

/* LIGHT MODE */
:root {
  --button-outline: rgba(0,0,0, .10);
  --badge-outline: rgba(0,0,0, .05);

  /* Automatic computation of border around primary / danger buttons */
  --opaque-button-border-intensity: -8; /* In terms of percentages */

  /* Backgrounds applied on top of other backgrounds when hovered/active */
  --elevate-1: rgba(0,0,0, .03);
  --elevate-2: rgba(0,0,0, .08);

  --background: 0 0% 100%;

  --foreground: 222 14% 12%;

  --border: 220 13% 91%;

  --card: 0 0% 98%;

  --card-foreground: 222 14% 12%;

  --card-border: 220 13% 94%;

  --sidebar: 0 0% 96%;

  --sidebar-foreground: 222 14% 12%;

  --sidebar-border: 220 13% 88%;

  --sidebar-primary: 262 83% 58%;

  --sidebar-primary-foreground: 0 0% 100%;

  --sidebar-accent: 220 10% 88%;

  --sidebar-accent-foreground: 222 14% 12%;

  --sidebar-ring: 262 83% 58%;

  --popover: 0 0% 94%;

  --popover-foreground: 222 14% 12%;

  --popover-border: 220 13% 86%;

  --primary: 262 83% 58%;

  --primary-foreground: 0 0% 100%;

  --secondary: 220 10% 90%;

  --secondary-foreground: 222 14% 12%;

  --muted: 220 8% 92%;

  --muted-foreground: 222 10% 45%;

  --accent: 220 12% 89%;

  --accent-foreground: 222 14% 12%;

  --destructive: 0 72% 51%;

  --destructive-foreground: 0 0% 100%;

  --input: 220 13% 75%;
  --ring: 262 83% 58%;
  --chart-1: 262 83% 45%;
  --chart-2: 200 95% 40%;
  --chart-3: 142 76% 35%;
  --chart-4: 38 92% 40%;
  --chart-5: 280 70% 45%;

  --font-sans: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: Georgia, serif;
  --font-mono: "JetBrains Mono", Menlo, monospace;
  --radius: .75rem;
  --shadow-2xs: 0px 1px 2px 0px hsl(222 14% 8% / 0.05);
  --shadow-xs: 0px 1px 3px 0px hsl(222 14% 8% / 0.08);
  --shadow-sm: 0px 2px 4px -1px hsl(222 14% 8% / 0.06), 0px 1px 2px -1px hsl(222 14% 8% / 0.08);
  --shadow: 0px 4px 6px -1px hsl(222 14% 8% / 0.08), 0px 2px 4px -1px hsl(222 14% 8% / 0.06);
  --shadow-md: 0px 6px 8px -2px hsl(222 14% 8% / 0.10), 0px 2px 4px -1px hsl(222 14% 8% / 0.06);
  --shadow-lg: 0px 10px 15px -3px hsl(222 14% 8% / 0.10), 0px 4px 6px -2px hsl(222 14% 8% / 0.05);
  --shadow-xl: 0px 20px 25px -5px hsl(222 14% 8% / 0.10), 0px 10px 10px -5px hsl(222 14% 8% / 0.04);
  --shadow-2xl: 0px 25px 50px -12px hsl(222 14% 8% / 0.25);
  --tracking-normal: 0em;
  --spacing: 0.25rem;

  --ai-accent: 200 95% 45%;
  --ai-accent-foreground: 0 0% 100%;
  --success: 142 76% 40%;
  --success-foreground: 0 0% 100%;
  --warning: 38 92% 45%;
  --warning-foreground: 0 0% 100%;

  /* Automatically computed borders - intensity can be controlled by the user by the --opaque-button-border-intensity setting */

  /* Fallback for older browsers */
  --sidebar-primary-border: hsl(var(--sidebar-primary));
  --sidebar-primary-border: hsl(from hsl(var(--sidebar-primary)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --sidebar-accent-border: hsl(var(--sidebar-accent));
  --sidebar-accent-border: hsl(from hsl(var(--sidebar-accent)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --primary-border: hsl(var(--primary));
  --primary-border: hsl(from hsl(var(--primary)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --secondary-border: hsl(var(--secondary));
  --secondary-border: hsl(from hsl(var(--secondary)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --muted-border: hsl(var(--muted));
  --muted-border: hsl(from hsl(var(--muted)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --accent-border: hsl(var(--accent));
  --accent-border: hsl(from hsl(var(--accent)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --destructive-border: hsl(var(--destructive));
  --destructive-border: hsl(from hsl(var(--destructive)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --ai-accent-border: hsl(var(--ai-accent));
  --ai-accent-border: hsl(from hsl(var(--ai-accent)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --success-border: hsl(var(--success));
  --success-border: hsl(from hsl(var(--success)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --warning-border: hsl(var(--warning));
  --warning-border: hsl(from hsl(var(--warning)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);
}

.dark {
  --button-outline: rgba(255,255,255, .10);
  --badge-outline: rgba(255,255,255, .05);

  --opaque-button-border-intensity: 9;  /* In terms of percentages */

  /* Backgrounds applied on top of other backgrounds when hovered/active */
  --elevate-1: rgba(255,255,255, .04);
  --elevate-2: rgba(255,255,255, .09);

  --background: 222 47% 11%;

  --foreground: 0 0% 98%;

  --border: 222 30% 25%;

  --card: 222 47% 16%;

  --card-foreground: 0 0% 98%;

  --card-border: 222 30% 25%;

  --sidebar: 222 47% 14%;

  --sidebar-foreground: 0 0% 98%;

  --sidebar-border: 222 30% 20%;

  --sidebar-primary: 262 83% 70%;

  --sidebar-primary-foreground: 0 0% 100%;

  --sidebar-accent: 222 30% 22%;

  --sidebar-accent-foreground: 0 0% 98%;

  --sidebar-ring: 262 83% 70%;

  --popover: 222 47% 16%;

  --popover-foreground: 0 0% 98%;

  --popover-border: 222 30% 25%;

  --primary: 262 83% 70%;

  --primary-foreground: 0 0% 100%;

  --secondary: 222 30% 22%;

  --secondary-foreground: 0 0% 98%;

  --muted: 222 30% 20%;

  --muted-foreground: 0 0% 70%;

  --accent: 222 30% 22%;

  --accent-foreground: 0 0% 98%;

  --destructive: 0 72% 51%;

  --destructive-foreground: 0 0% 100%;

  --input: 222 30% 25%;
  --ring: 262 83% 70%;
  --chart-1: 262 83% 70%;
  --chart-2: 189 94% 60%;
  --chart-3: 142 76% 48%;
  --chart-4: 38 92% 55%;
  --chart-5: 280 70% 65%;

  --ai-accent: 189 94% 60%;
  --ai-accent-foreground: 222 47% 11%;
  --success: 142 76% 48%;
  --success-foreground: 222 47% 11%;
  --warning: 38 92% 55%;
  --warning-foreground: 222 47% 11%;

  --shadow-2xs: 0px 1px 2px 0px hsl(0 0% 0% / 0.20);
  --shadow-xs: 0px 1px 3px 0px hsl(0 0% 0% / 0.25);
  --shadow-sm: 0px 2px 4px -1px hsl(0 0% 0% / 0.20), 0px 1px 2px -1px hsl(0 0% 0% / 0.25);
  --shadow: 0px 4px 6px -1px hsl(0 0% 0% / 0.25), 0px 2px 4px -1px hsl(0 0% 0% / 0.20);
  --shadow-md: 0px 6px 8px -2px hsl(0 0% 0% / 0.30), 0px 2px 4px -1px hsl(0 0% 0% / 0.20);
  --shadow-lg: 0px 10px 15px -3px hsl(0 0% 0% / 0.30), 0px 4px 6px -2px hsl(0 0% 0% / 0.15);
  --shadow-xl: 0px 20px 25px -5px hsl(0 0% 0% / 0.30), 0px 10px 10px -5px hsl(0 0% 0% / 0.10);
  --shadow-2xl: 0px 25px 50px -12px hsl(0 0% 0% / 0.50);

  /* Fallback for older browsers */
  --sidebar-primary-border: hsl(var(--sidebar-primary));
  --sidebar-primary-border: hsl(from hsl(var(--sidebar-primary)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --sidebar-accent-border: hsl(var(--sidebar-accent));
  --sidebar-accent-border: hsl(from hsl(var(--sidebar-accent)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --primary-border: hsl(var(--primary));
  --primary-border: hsl(from hsl(var(--primary)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --secondary-border: hsl(var(--secondary));
  --secondary-border: hsl(from hsl(var(--secondary)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --muted-border: hsl(var(--muted));
  --muted-border: hsl(from hsl(var(--muted)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --accent-border: hsl(var(--accent));
  --accent-border: hsl(from hsl(var(--accent)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --destructive-border: hsl(var(--destructive));
  --destructive-border: hsl(from hsl(var(--destructive)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --ai-accent-border: hsl(var(--ai-accent));
  --ai-accent-border: hsl(from hsl(var(--ai-accent)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --success-border: hsl(var(--success));
  --success-border: hsl(from hsl(var(--success)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);

  /* Fallback for older browsers */
  --warning-border: hsl(var(--warning));
  --warning-border: hsl(from hsl(var(--warning)) h s calc(l + var(--opaque-button-border-intensity)) / alpha);
}

@layer base {
  * {
    @apply border-border;
  }

  body {
    @apply font-sans antialiased bg-background text-foreground;
  }
}

@layer utilities {

  /* Hide ugly search cancel button in Chrome until we can style it properly */
  input[type="search"]::-webkit-search-cancel-button {
    @apply hidden;
  }

  /* Placeholder styling for contentEditable div */
  [contenteditable][data-placeholder]:empty::before {
    content: attr(data-placeholder);
    color: hsl(var(--muted-foreground));
    pointer-events: none;
  }

  /* .no-default-hover-elevate/no-default-active-elevate is an escape hatch so consumers of
   * buttons/badges can remove the automatic brightness adjustment on interactions
   * and program their own. */
  .no-default-hover-elevate {}

  .no-default-active-elevate {}


  /**
   * Toggleable backgrounds go behind the content. Hoverable/active goes on top.
   * This way they can stack/compound. Both will overlap the parent's borders!
   * So borders will be automatically adjusted both on toggle, and hover/active,
   * and they will be compounded.
   */
  .toggle-elevate::before,
  .toggle-elevate-2::before {
    content: "";
    pointer-events: none;
    position: absolute;
    inset: 0px;
    border-radius: inherit;
    z-index: -1;
  }

  .toggle-elevate.toggle-elevated::before {
    background-color: var(--elevate-2);
  }

  /* If there's a 1px border, adjust the inset so that it covers that parent's border */
  .border.toggle-elevate::before {
    inset: -1px;
  }

  /* Does not work on elements with overflow:hidden! */
  .hover-elevate:not(.no-default-hover-elevate),
  .active-elevate:not(.no-default-active-elevate),
  .hover-elevate-2:not(.no-default-hover-elevate),
  .active-elevate-2:not(.no-default-active-elevate) {
    position: relative;
    z-index: 0;
  }

  .hover-elevate:not(.no-default-hover-elevate)::after,
  .active-elevate:not(.no-default-active-elevate)::after,
  .hover-elevate-2:not(.no-default-hover-elevate)::after,
  .active-elevate-2:not(.no-default-active-elevate)::after {
    content: "";
    pointer-events: none;
    position: absolute;
    inset: 0px;
    border-radius: inherit;
    z-index: 999;
  }

  .hover-elevate:hover:not(.no-default-hover-elevate)::after,
  .active-elevate:active:not(.no-default-active-elevate)::after {
    background-color: var(--elevate-1);
  }

  .hover-elevate-2:hover:not(.no-default-hover-elevate)::after,
  .active-elevate-2:active:not(.no-default-active-elevate)::after {
    background-color: var(--elevate-2);
  }

  /* If there's a 1px border, adjust the inset so that it covers that parent's border */
  .border.hover-elevate:not(.no-hover-interaction-elevate)::after,
  .border.active-elevate:not(.no-active-interaction-elevate)::after,
  .border.hover-elevate-2:not(.no-hover-interaction-elevate)::after,
  .border.active-elevate-2:not(.no-active-interaction-elevate)::after,
  .border.hover-elevate:not(.no-hover-interaction-elevate)::after {
    inset: -1px;
  }

  /* Gradient Animations */
  @keyframes gradient-xy {
    0%, 100% {
      background-position: 0% 50%;
    }
    50% {
      background-position: 100% 50%;
    }
  }

  .animate-gradient-xy {
    background-size: 400% 400%;
    animation: gradient-xy 15s ease infinite;
  }

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

  .animate-shimmer {
    background-size: 200% 100%;
    animation: gradient-shimmer 2s linear infinite;
  }
}