@import "tailwindcss";
@import "tw-animate-css";
@import "shadcn/tailwind.css";
@import "@fontsource-variable/jetbrains-mono";

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

@keyframes romanSlideIn {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

@theme inline {
  --font-heading: var(--font-mono);
  --font-sans: 'JetBrains Mono Variable', 'Courier New', monospace;
  --font-mono: 'JetBrains Mono Variable', 'Courier New', monospace;
  --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: 0px;
  --radius-md: 0px;
  --radius-lg: 0px;
  --radius-xl: 0px;
  --radius-2xl: 0px;
  --radius-3xl: 0px;
  --radius-4xl: 0px;
}

/* ── Terracotta Light Theme ── */
:root {
  --background: oklch(0.94 0.02 55);
  --foreground: oklch(0.18 0.03 45);
  --card: oklch(0.91 0.025 55);
  --card-foreground: oklch(0.18 0.03 45);
  --popover: oklch(0.91 0.025 55);
  --popover-foreground: oklch(0.18 0.03 45);
  --primary: oklch(0.55 0.14 45);
  --primary-foreground: oklch(0.95 0.02 55);
  --secondary: oklch(0.86 0.03 55);
  --secondary-foreground: oklch(0.18 0.03 45);
  --muted: oklch(0.86 0.025 55);
  --muted-foreground: oklch(0.45 0.04 45);
  --accent: oklch(0.84 0.035 55);
  --accent-foreground: oklch(0.18 0.03 45);
  --destructive: oklch(0.5 0.2 25);
  --border: oklch(0.6 0.08 45);
  --input: oklch(0.78 0.04 55);
  --ring: oklch(0.55 0.14 45);
  --chart-1: oklch(0.55 0.14 45);
  --chart-2: oklch(0.65 0.1 70);
  --chart-3: oklch(0.5 0.08 30);
  --chart-4: oklch(0.6 0.06 90);
  --chart-5: oklch(0.4 0.04 45);
  --radius: 0px;
  --sidebar: oklch(0.90 0.025 55);
  --sidebar-foreground: oklch(0.18 0.03 45);
  --sidebar-primary: oklch(0.55 0.14 45);
  --sidebar-primary-foreground: oklch(0.95 0.02 55);
  --sidebar-accent: oklch(0.84 0.035 55);
  --sidebar-accent-foreground: oklch(0.18 0.03 45);
  --sidebar-border: oklch(0.6 0.08 45);
  --sidebar-ring: oklch(0.55 0.14 45);
}

/* ── Black-Figure Dark Theme (primary) ──
   Inspired by Greek pottery: black ground, terracotta figures, gold accents
*/
.dark {
  --background: oklch(0.12 0.015 45);
  --foreground: oklch(0.72 0.08 55);
  --card: oklch(0.16 0.02 45);
  --card-foreground: oklch(0.72 0.08 55);
  --popover: oklch(0.16 0.02 45);
  --popover-foreground: oklch(0.72 0.08 55);
  --primary: oklch(0.7 0.13 55);
  --primary-foreground: oklch(0.12 0.015 45);
  --secondary: oklch(0.22 0.025 45);
  --secondary-foreground: oklch(0.7 0.08 55);
  --muted: oklch(0.22 0.02 45);
  --muted-foreground: oklch(0.5 0.05 55);
  --accent: oklch(0.24 0.03 45);
  --accent-foreground: oklch(0.72 0.08 55);
  --destructive: oklch(0.55 0.18 25);
  --border: oklch(0.38 0.06 45);
  --input: oklch(0.26 0.03 45);
  --ring: oklch(0.7 0.13 55);
  --chart-1: oklch(0.7 0.13 55);
  --chart-2: oklch(0.65 0.1 70);
  --chart-3: oklch(0.55 0.08 30);
  --chart-4: oklch(0.6 0.06 90);
  --chart-5: oklch(0.45 0.04 45);
  --sidebar: oklch(0.14 0.018 45);
  --sidebar-foreground: oklch(0.72 0.08 55);
  --sidebar-primary: oklch(0.7 0.13 55);
  --sidebar-primary-foreground: oklch(0.12 0.015 45);
  --sidebar-accent: oklch(0.24 0.03 45);
  --sidebar-accent-foreground: oklch(0.72 0.08 55);
  --sidebar-border: oklch(0.38 0.06 45);
  --sidebar-ring: oklch(0.7 0.13 55);
}

/* ── Azure Theme — blue and white, clean ── */
.theme-azure {
  --background: oklch(0.14 0.02 240);
  --foreground: oklch(0.82 0.04 220);
  --card: oklch(0.17 0.025 240);
  --card-foreground: oklch(0.82 0.04 220);
  --popover: oklch(0.17 0.025 240);
  --popover-foreground: oklch(0.82 0.04 220);
  --primary: oklch(0.72 0.12 230);
  --primary-foreground: oklch(0.14 0.02 240);
  --secondary: oklch(0.22 0.03 240);
  --secondary-foreground: oklch(0.78 0.04 220);
  --muted: oklch(0.22 0.025 240);
  --muted-foreground: oklch(0.55 0.04 230);
  --accent: oklch(0.24 0.035 240);
  --accent-foreground: oklch(0.82 0.04 220);
  --destructive: oklch(0.55 0.18 25);
  --border: oklch(0.38 0.06 230);
  --input: oklch(0.26 0.03 240);
  --ring: oklch(0.72 0.12 230);
  --chart-1: oklch(0.72 0.12 230);
  --chart-2: oklch(0.65 0.1 200);
  --chart-3: oklch(0.55 0.08 260);
  --chart-4: oklch(0.6 0.06 180);
  --chart-5: oklch(0.45 0.04 230);
  --sidebar: oklch(0.16 0.02 240);
  --sidebar-foreground: oklch(0.82 0.04 220);
  --sidebar-primary: oklch(0.72 0.12 230);
  --sidebar-primary-foreground: oklch(0.14 0.02 240);
  --sidebar-accent: oklch(0.24 0.035 240);
  --sidebar-accent-foreground: oklch(0.82 0.04 220);
  --sidebar-border: oklch(0.38 0.06 230);
  --sidebar-ring: oklch(0.72 0.12 230);
}

/* Terminal-style block cursor — outside @layer so it overrides CodeMirror's theme */
.cm-cursor,
.cm-cursor-primary {
  border-left-color: var(--primary) !important;
  border-left-width: 0.5em !important;
}

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

  body {
    @apply bg-background text-foreground;
    font-size: 13px;
    letter-spacing: -0.01em;
  }

  html {
    @apply font-mono;
  }

  /* Theme-aware scrollbars */
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }

  *::-webkit-scrollbar {
    width: 5px;
    height: 5px;
  }

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

  *::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 0;
  }

  *::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
  }

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



  /* Bold console aesthetic */
  button,
  [role="button"],
  [data-slot="button"] {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 11px;
    cursor: pointer;
  }

  .cm-content {
    background: var(--background);
  }

  /* Keyword hover tooltip */
  .cm-tooltip.cm-tooltip-hover {
    background: var(--card) !important;
    border: 2px solid var(--border) !important;
    padding: 8px 10px;
    box-shadow:
      3px 3px 0 0 var(--border),
      5px 3px 0 0 transparent,
      7px 3px 0 0 var(--border),
      4px 4px 0 0 transparent,
      6px 4px 0 0 var(--border);
  }

  /* Ensure all interactive elements have pointer cursor */
  a,
  [role="link"],
  [role="tab"],
  [role="option"],
  [data-slot="popover-trigger"],
  [data-slot="toggle-group-item"],
  [data-slot="alert-dialog-action"],
  [data-slot="alert-dialog-cancel"],
  .cm-tooltip-autocomplete [role="option"] {
    cursor: pointer;
  }

  nav {
    border-bottom-width: 3px;
  }

  /* ── Dithered offset shadow ──
     Simulates a stippled/dot-matrix shadow using multiple box-shadow
     dots at alternating positions. Works even with overflow:auto.
  */

  /* Panels — dithered shadow (dialogs, popovers) */
  [data-slot="alert-dialog-content"],
  [data-slot="popover-content"] {
    border: 2px solid var(--border);
    box-shadow:
      3px 3px 0 0 var(--border),
      5px 3px 0 0 transparent,
      7px 3px 0 0 var(--border),
      4px 4px 0 0 transparent,
      6px 4px 0 0 var(--border),
      3px 5px 0 0 var(--border),
      5px 5px 0 0 transparent,
      7px 5px 0 0 var(--border),
      4px 6px 0 0 var(--border),
      6px 6px 0 0 transparent;
  }

  /* Table container — no own border when inside a bordered parent */
  [data-slot="table-container"] {
    border: none;
    box-shadow: none;
  }

  /* Primary (default) buttons only — dithered shadow */
  button[data-slot="button"][data-variant="default"] {
    border: 2px solid var(--border);
    box-shadow:
      2px 2px 0 0 var(--border),
      4px 2px 0 0 transparent,
      6px 2px 0 0 var(--border),
      3px 3px 0 0 transparent,
      5px 3px 0 0 var(--border),
      2px 4px 0 0 var(--border),
      4px 4px 0 0 transparent,
      6px 4px 0 0 var(--border);
    transition: box-shadow 0.1s, transform 0.1s;
  }

  button[data-slot="button"][data-variant="default"]:active {
    box-shadow: none;
    transform: translate(2px, 2px);
  }

  /* All other buttons — no shadow */
  button[data-slot="button"][data-variant="outline"],
  button[data-slot="button"][data-variant="secondary"],
  button[data-slot="button"][data-variant="ghost"],
  button[data-slot="button"][data-variant="link"],
  button[data-slot="button"][data-variant="destructive"] {
    box-shadow: none !important;
  }

  /* Input fields */
  input[data-slot="input"] {
    border: 2px solid var(--border);
  }

  /* ── Floating Nav Menu ── */

  .nav-menu-root {
    position: relative;
    width: 200px;
    height: 400px;
    will-change: transform;
  }

  .nav-menu-frame {
    position: absolute;
    inset: 0;
    background: var(--primary);
    pointer-events: none;
    mask-size: 100% 100%;
    mask-repeat: no-repeat;
    -webkit-mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat;
  }

  .nav-menu-links {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding-top: 168px;
    border: none;
  }

  .nav-menu-item {
    width: 100%;
    text-align: center;
    padding: 6px 12px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted-foreground);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
  }

  .nav-menu-item:hover {
    color: var(--foreground);
  }

  .nav-menu-item[data-active] {
    color: var(--primary);
    background: var(--primary) / 0.08;
  }

  /* ── Editor Pointer ── */

  .editor-pointer {
    position: fixed;
    z-index: 50;
    pointer-events: none;
    will-change: top;
    transform: translateX(-100%);
    margin-top: -20px;
  }

  .editor-pointer-img {
    width: 200px;
    height: 130px;
    background: var(--primary);
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    opacity: 1;
  }
}