@import 'tailwindcss';
@import '../node_modules/highlight.js/styles/monokai.min.css';
@import '../node_modules/katex/dist/katex.min.css';

@theme {
  --color-bg: #040404;
  --color-fg: #e0e0e0;
  --color-fg-dim: #b0b0b0;
  --color-accent: #ef1f1f;
  --color-border: #374151;

  --color-warning: #facc15;
  --color-tip: #22c55e;
  --color-info: #3b82f6;
  --color-quote: #f97316;

  --font-sans: 'Space Grotesk', sans-serif;
}

.hljs {
  @apply bg-transparent;
}

pre code.hljs {
  @apply p-0;
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding-block-end: 0.25rem;
}

.katex-display > .katex > .katex-html > .tag {
  @apply relative ml-8 lg:absolute lg:right-1;
}

* {
  @apply scroll-smooth;
}

body {
  @apply bg-bg text-fg;
}

.prose {
  @apply space-y-4 text-fg-dim;

  ul {
    @apply list-disc;
  }

  ol {
    @apply list-decimal;
  }

  ul,
  ol {
    @apply list-outside;
  }

  li {
    @apply mb-1;
  }
}

.categories::before {
  @apply content-['$'] text-accent;
}

.handle::before {
  @apply content-['@'] text-current;
}

/* ── Mark ────────────────────────────── */

mark {
  @apply bg-accent/20 px-1 py-0.5 rounded text-accent;
}

/* ── Tables ────────────────────────────────────────── */

table {
  @apply border-collapse w-full;
}

th,
td {
  @apply border border-border px-4 py-2;
}

th {
  @apply bg-fg/10;
}

tbody tr:nth-child(even) {
  @apply bg-fg/5;
}

tbody tr:hover {
  @apply bg-fg/10;
}

/* ── Definition lists ─────────────────────────────── */

dl {
  @apply my-4;
}

dt {
  @apply font-semibold text-fg mt-3;
}

dt:first-child {
  @apply mt-0;
}

dd {
  @apply ml-6 pl-3 border-l-2 border-fg/20 text-fg-dim;
}

/* ── Prose (markdown) content ─────────────────────── */

.prose h2 {
  @apply text-2xl md:text-3xl;

  &::before {
    @apply content-['#'] text-accent mr-1;
  }
}

.prose h3 {
  @apply text-xl md:text-2xl;

  &::before {
    @apply content-['##'] text-accent mr-1;
  }
}

.prose h4 {
  @apply text-lg md:text-xl;

  &::before {
    @apply content-['###'] text-accent mr-1;
  }
}

.prose h5 {
  @apply text-base md:text-lg;

  &::before {
    @apply content-['####'] text-accent mr-1;
  }
}

.prose h6 {
  @apply text-sm md:text-base;

  &::before {
    @apply content-['#####'] text-accent mr-1;
  }
}

.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  @apply font-bold mb-2 text-fg;
}

.prose code:not(pre code) {
  @apply text-sm bg-fg/10 px-1 py-0.5 rounded;
}

.prose a {
  @apply text-accent hover:underline focus:underline cursor-pointer;
}

.prose ul:not(.task-list-container) {
  @apply list-disc pl-6;
}

hr {
  @apply text-border;
}

/* Only ol that do not include checkboxes */
.prose ol {
  @apply list-decimal pl-6;
}

/* ── Task lists ────────────────────────────────────── */

.task-list-item {
  @apply list-none ml-0 pl-0;
}

.task-list-item input[type='checkbox'] {
  @apply mr-2 accent-accent w-4 h-4 align-middle cursor-pointer;
}

.task-list-item input[type='checkbox']:checked + label,
.task-list-item input[type='checkbox'][checked] + label {
  @apply text-fg-dim line-through;
}

/* ── Footnotes ─────────────────────────────────────── */

.footnotes {
  @apply text-sm italic text-fg-dim pt-4 mt-4 border-t border-border;
}

.footnotes ol {
  @apply space-y-2;
}

.sr-only {
  @apply sr-only;
}

.note {
  @apply border-l-4 pl-4 py-2 text-fg-dim bg-border/20;

  &.warning {
    @apply border-warning bg-warning/20 text-warning;
  }

  &.tip {
    @apply border-tip bg-tip/20 text-tip;
  }

  &.info {
    @apply border-info bg-info/20 text-info;
  }

  &.quote {
    @apply border-quote bg-quote/20 text-quote;
  }
}

.no-js .js-only {
  @apply hidden;
}

#mermaid-diagram {
  @apply mx-auto;
}
