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

/* ========================= */
/* Root Variables & Theming  */
/* ========================= */
@layer base {
  @font-face {
    font-family: "JudgeMedium";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(./fonts/F37Judge-MediumExtended.woff2) format("woff2");
  }

  @font-face {
    font-family: "JudgeRegular";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(./fonts/F37Judge-Regular.woff2) format("woff2");
  }

  :root {
    --nextra-primary-hue: 228;
    --nextra-primary-saturation: 61%;
    --nextra-primary-lightness: 44%;
    --nextra-bg: 255 255 255;

    --navy: 228 61% 10%;
    --cyan: 212 100% 86%;
    --brand: hsl(var(--navy));

    --background: 0 0% 100%;
    --foreground: 0 0% 3.9%;

    --card: 0 0% 100%;
    --card-foreground: 0 0% 3.9%;

    --popover: 0 0% 100%;
    --popover-foreground: 0 0% 3.9%;

    --primary: 0 0% 9%;
    --primary-foreground: 0 0% 98%;

    --secondary: 0 0% 96.1%;
    --secondary-foreground: 0 0% 9%;

    --muted: 0 0% 96.1%;
    --muted-foreground: 0 0% 45.1%;

    --accent: 0 0% 96.1%;
    --accent-foreground: 0 0% 9%;

    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;

    --border: 0 0% 89.8%;
    --input: 0 0% 89.8%;
    --ring: 0 0% 3.9%;

    /* Chart Colors */
    --chart-1: 221.2 83.2% 53.3%;
    --chart-2: 212 95% 68%;
    --chart-3: 216 92% 60%;
    --chart-4: 210 98% 78%;
    --chart-5: 212 97% 87%;

    --radius: 0.5rem;
  }

  .dark {
    --nextra-primary-hue: 212;
    --nextra-primary-saturation: 100%;
    --nextra-primary-lightness: 60%;
    --nextra-bg: 2 8 29;

    --brand: hsl(var(--cyan));

    --background: 222.2 84% 4.9%;
    --foreground: 210 40% 98%;

    --card: 222.2 84% 4.9%;
    --card-foreground: 210 40% 98%;

    --popover: 222.2 84% 4.9%;
    --popover-foreground: 210 40% 98%;

    --primary: 210 40% 98%;
    --primary-foreground: 222.2 47.4% 11.2%;

    --secondary: 217.2 32.6% 17.5%;
    --secondary-foreground: 210 40% 98%;

    --muted: 217.2 32.6% 17.5%;
    --muted-foreground: 215 20.2% 65.1%;

    --accent: 217.2 32.6% 17.5%;
    --accent-foreground: 210 40% 98%;

    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 210 40% 98%;

    --border: 217.2 32.6% 17.5%;
    --input: 217.2 32.6% 17.5%;
    --ring: 212.7 26.8% 83.9%;

    /* Dark Mode Chart Colors */
    --chart-1: 220 70% 50%;
    --chart-2: 160 60% 45%;
    --chart-3: 30 80% 55%;
    --chart-4: 280 65% 60%;
    --chart-5: 340 75% 55%;
  }
}

/* ========================= */
/* Custom UI Components      */
/* ========================= */
.step-run-card {
  --transition: 0.25s;
  --spark: 3s;
  display: grid;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1000px 0 0 hsl(217.2 32.6% 17.5%) inset;
  transition:
    box-shadow var(--transition),
    background var(--transition),
    transform var(--transition);
}

.step-run-card.active .step-run-backdrop {
  background: var(--background);
}

.step-run-card.active {
  transform: scale(1.05);
}

.step-run-backdrop {
  position: absolute;
  inset: 1px;
  background: var(--background);
  border-radius: 10px;
  transition:
    background var(--transition),
    opacity var(--transition);
}

/* ========================= */
/* Animation Effects         */
/* ========================= */
.spark {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  rotate: 0deg;
  overflow: hidden;
  mask: linear-gradient(white, transparent 50%);
  animation: flip calc(var(--spark) * 2) infinite steps(2, end);
}

@keyframes flip {
  to {
    rotate: 360deg;
  }
}

@keyframes rotate {
  to {
    transform: rotate(90deg);
  }
}

/* ========================= */
/* Nextra Cards Overrides    */
/* ========================= */
.nextra-cards {
  display: grid;
  gap: 0.875rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  grid-template-columns: repeat(var(--rows, 3), minmax(0, 1fr));
  align-items: stretch;
}

@media (max-width: 768px) {
  .nextra-cards {
    grid-template-columns: 1fr;
  }
}

/* Card: minimal doc-style link block. Title on top (column-reverse), then description. */
.nextra-card {
  display: flex;
  flex-direction: column-reverse;
  align-items: stretch;
  justify-content: flex-start;
  min-height: 100%;
  gap: 0.375rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius, 0.5rem);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  font-size: 0.875rem;
  line-height: 1.5;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    color 0.15s ease;
}

/* Description/content area grows to fill space for equal-height cards */
.nextra-card > *:not(span) {
  flex: 1 1 auto;
  min-height: 0;
  overflow-wrap: break-word;
}

.nextra-card:hover {
  border-color: hsl(var(--ring));
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

/* Title row: icon + label. Override Nextra’s padding so card padding controls spacing. */
.nextra-card > span {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  color: hsl(var(--foreground));
}

.nextra-card:hover > span {
  color: hsl(var(--foreground));
}

/* Optional arrow after title on hover */
.nextra-card > span::after {
  content: "→";
  margin-left: 0.25rem;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.nextra-card:hover > span::after {
  opacity: 0.7;
  transform: translateX(2px);
}

/* Allow natural wrapping instead of truncation for better readability */
.nextra-card ._truncate {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  word-wrap: break-word;
}

/* ========================= */
/* Dark Mode Fixes (Nextra)  */
/* ========================= */

html
  :is(
    kbd,
    ._border-gray-200,
    .dark\:_border-neutral-800,
    .nx-border,
    .nextra-sidebar-footer,
    .nextra-toc-footer,
    .nextra-code-block pre,
    .nextra-code pre,

  ) {
  @apply border-[color:hsl(var(--border))] dark:border-[color:hsl(var(--border))];
  @apply ring-[color:hsl(var(--border))] dark:ring-[color:hsl(var(--border))];
}

/* ========================= */
/* Code Block Styling        */
/* ========================= */
.shiki {
  padding: 15px !important;
  border-radius: 10px !important;
  background-color: #ccc;
  border-radius: 0.375rem; /* rounded-md */
  font-size: 0.875rem;
  border-width: 1px;
  border-style: solid;
}

html.dark .nextra-code-block pre,
html.dark .nextra-code pre,
.dark .shiki {
  background-color: transparent !important;
  border-color: hsl(var(--border)) !important;
}

pre.shiki {
  overflow-x: auto;
}

/* High contrast mode */
.contrast-more .shiki {
  filter: contrast(1.5);
}

/* ========================= */
/* Miscellaneous Fixes       */
/* ========================= */

h1 {
  font-family: "JudgeMedium", sans-serif;
  font-weight: normal !important;
}

h2,
h3 {
  font-family: "JudgeRegular", sans-serif;
  font-weight: normal !important;
  letter-spacing: 0 !important;
}

.nextra-steps h3::before {
  line-height: 25px;
}

.dark .nextra-breadcrumb a,
.dark .nextra-breadcrumb a:visited,
.dark .nextra-breadcrumb a:hover,
.dark .nextra-breadcrumb a:active {
  background: none !important;
  -webkit-text-fill-color: var(--ash-gray) !important;
}

.nextra-nav-container-blur {
  background-color: var(--background) !important;
}

nav:not(.nextra-toc) {
  background-color: var(--background) !important;
}

.dark .nx-sticky,
.dark ._sticky {
  box-shadow: none !important;
}

/* MCP / markdown action links - always under breadcrumbs, left justified */
.page-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  white-space: nowrap;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  justify-content: flex-start;
}
