@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: 210 5% 98%;

  --foreground: 210 6% 12%;

  --border: 210 5% 88%;

  --card: 210 5% 96%;

  --card-foreground: 210 6% 12%;

  --card-border: 210 5% 90%;

  --sidebar: 210 5% 94%;

  --sidebar-foreground: 210 6% 12%;

  --sidebar-border: 210 5% 86%;

  --sidebar-primary: 210 85% 42%;

  --sidebar-primary-foreground: 210 85% 98%;

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

  --sidebar-accent-foreground: 210 6% 18%;

  --sidebar-ring: 210 85% 42%;

  --popover: 210 5% 92%;

  --popover-foreground: 210 6% 12%;

  --popover-border: 210 5% 84%;

  --primary: 210 85% 42%;

  --primary-foreground: 210 85% 98%;

  --secondary: 210 8% 86%;

  --secondary-foreground: 210 6% 12%;

  --muted: 210 10% 90%;

  --muted-foreground: 210 5% 35%;

  --accent: 210 12% 88%;

  --accent-foreground: 210 6% 18%;

  --destructive: 0 84% 45%;

  --destructive-foreground: 0 84% 98%;

  --input: 210 5% 65%;
  --ring: 210 85% 42%;
  --chart-1: 210 85% 42%;
  --chart-2: 195 75% 38%;
  --chart-3: 25 85% 48%;
  --chart-4: 280 70% 45%;
  --chart-5: 145 65% 40%;

  --font-sans: Inter, system-ui, -apple-system, sans-serif;
  --font-serif: Georgia, serif;
  --font-mono: 'Roboto Mono', Menlo, monospace;
  --radius: .5rem; /* 8px */
  --shadow-2xs: 0px 1px 2px 0px hsl(210 10% 10% / 0.04);
  --shadow-xs: 0px 1px 3px 0px hsl(210 10% 10% / 0.06);
  --shadow-sm: 0px 2px 4px -1px hsl(210 10% 10% / 0.06), 0px 1px 2px -1px hsl(210 10% 10% / 0.04);
  --shadow: 0px 4px 6px -2px hsl(210 10% 10% / 0.08), 0px 2px 4px -1px hsl(210 10% 10% / 0.04);
  --shadow-md: 0px 6px 12px -2px hsl(210 10% 10% / 0.10), 0px 3px 6px -2px hsl(210 10% 10% / 0.05);
  --shadow-lg: 0px 10px 20px -4px hsl(210 10% 10% / 0.12), 0px 4px 8px -2px hsl(210 10% 10% / 0.06);
  --shadow-xl: 0px 16px 32px -6px hsl(210 10% 10% / 0.14), 0px 6px 12px -3px hsl(210 10% 10% / 0.08);
  --shadow-2xl: 0px 24px 48px -8px hsl(210 10% 10% / 0.16);
  --tracking-normal: -0.01em;
  --spacing: 0.25rem;

  /* 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);
}

.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: 210 6% 10%;

  --foreground: 210 5% 92%;

  --border: 210 5% 20%;

  --card: 210 6% 13%;

  --card-foreground: 210 5% 92%;

  --card-border: 210 5% 18%;

  --sidebar: 210 6% 16%;

  --sidebar-foreground: 210 5% 92%;

  --sidebar-border: 210 5% 22%;

  --sidebar-primary: 210 80% 48%;

  --sidebar-primary-foreground: 210 80% 98%;

  --sidebar-accent: 210 12% 22%;

  --sidebar-accent-foreground: 210 5% 85%;

  --sidebar-ring: 210 80% 48%;

  --popover: 210 6% 18%;

  --popover-foreground: 210 5% 92%;

  --popover-border: 210 5% 24%;

  --primary: 210 80% 48%;

  --primary-foreground: 210 80% 98%;

  --secondary: 210 8% 24%;

  --secondary-foreground: 210 5% 92%;

  --muted: 210 10% 20%;

  --muted-foreground: 210 5% 65%;

  --accent: 210 12% 22%;

  --accent-foreground: 210 5% 85%;

  --destructive: 0 72% 48%;

  --destructive-foreground: 0 72% 98%;

  --input: 210 5% 45%;
  --ring: 210 80% 48%;
  --chart-1: 210 85% 62%;
  --chart-2: 195 75% 58%;
  --chart-3: 25 85% 68%;
  --chart-4: 280 70% 65%;
  --chart-5: 145 65% 60%;

  --shadow-2xs: 0px 1px 2px 0px hsl(210 10% 0% / 0.20);
  --shadow-xs: 0px 1px 3px 0px hsl(210 10% 0% / 0.30);
  --shadow-sm: 0px 2px 4px -1px hsl(210 10% 0% / 0.30), 0px 1px 2px -1px hsl(210 10% 0% / 0.20);
  --shadow: 0px 4px 6px -2px hsl(210 10% 0% / 0.40), 0px 2px 4px -1px hsl(210 10% 0% / 0.20);
  --shadow-md: 0px 6px 12px -2px hsl(210 10% 0% / 0.50), 0px 3px 6px -2px hsl(210 10% 0% / 0.25);
  --shadow-lg: 0px 10px 20px -4px hsl(210 10% 0% / 0.60), 0px 4px 8px -2px hsl(210 10% 0% / 0.30);
  --shadow-xl: 0px 16px 32px -6px hsl(210 10% 0% / 0.70), 0px 6px 12px -3px hsl(210 10% 0% / 0.40);
  --shadow-2xl: 0px 24px 48px -8px hsl(210 10% 0% / 0.80);

  /* 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);
}

@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 {}

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

  .border.toggle-elevate::before {
    inset: -1px;
  }

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

  .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;
  }
}