@import "./fonts.css";
@import "tailwindcss";
@import "easymde/dist/easymde.min.css";

@import "tw-animate-css";

:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: #0047bb;
  --primary-600: #002d7a;
  --primary-foreground: oklch(0.985 0 0);
  --branding-secondary: #896ad6;
  --secondary: oklch(0.97 0 0);
  --secondary-hover: #f3f4f6;
  --secondary-foreground: #4b5563;
  --muted: oklch(0.97 0 0);
  --muted-foreground: #46484d;
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.577 0.245 27.325);
  --border: #d1d5db;
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --chart-1: oklch(0.646 0.222 41.116);
  --chart-2: oklch(0.6 0.118 184.704);
  --chart-3: oklch(0.398 0.07 227.392);
  --chart-4: oklch(0.828 0.189 84.429);
  --chart-5: oklch(0.769 0.188 70.08);
  --radius: 0.625rem;
  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-primary: oklch(0.205 0 0);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.97 0 0);
  --sidebar-accent-foreground: oklch(0.205 0 0);
  --sidebar-border: oklch(0.922 0 0);
  --sidebar-ring: oklch(0.708 0 0);

  /* ruby_ui specific */
  --warning: hsl(38 92% 50%);
  --warning-foreground: hsl(0 0% 100%);
  --success: hsl(87 100% 37%);
  --success-foreground: hsl(0 0% 100%);
}

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-card: var(--card);
  --color-card-foreground: var(--card-foreground);
  --color-popover: var(--popover);
  --color-popover-foreground: var(--popover-foreground);
  --color-primary: var(--primary);
  --color-primary-600: var(--primary-600);
  --color-primary-foreground: var(--primary-foreground);
  --color-branding-secondary: var(--branding-secondary);
  --color-secondary: var(--secondary);
  --color-secondary-hover: var(--secondary-hover);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-destructive: var(--destructive);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);
  --color-chart-1: var(--chart-1);
  --color-chart-2: var(--chart-2);
  --color-chart-3: var(--chart-3);
  --color-chart-4: var(--chart-4);
  --color-chart-5: var(--chart-5);
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --color-sidebar: var(--sidebar);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-ring: var(--sidebar-ring);

  /* ruby_ui specific */
  --color-warning: var(--warning);
  --color-warning-foreground: var(--warning-foreground);
  --color-success: var(--success);
  --color-success-foreground: var(--success-foreground);

  /* Custom font families */
  --font-family-mulish: "Mulish", sans-serif;
  --font-family-instrument: "Instrument Sans", sans-serif;
}

/* Container settings */
@utility container {
  margin-inline: auto;
  padding-inline: 2rem;
  max-width: 1400px;
}

/* Custom font utilities */
@utility font-mulish {
  font-family: var(--font-family-mulish);
  font-optical-sizing: auto;
  font-style: normal;
}

@utility font-instrument {
  font-family: var(--font-family-instrument);
  font-optical-sizing: auto;
  font-style: normal;
  font-variation-settings: "wdth" 100;
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }
  body {
    @apply bg-background text-foreground;
    @apply mx-4 sm:mx-8 md:mx-16 lg:mx-24 xl:mx-[9rem];
  }
}

/* Image swap animation */
@keyframes image-swap {
  0%, 35% { opacity: 1; }
  50%, 85% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes image-swap-alt {
  0%, 35% { opacity: 0; }
  50%, 85% { opacity: 1; }
  100% { opacity: 0; }
}

@utility animate-image-swap {
  animation: image-swap 8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@utility animate-image-swap-alt {
  animation: image-swap-alt 8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* Article body markdown styles — applied to public article page and EasyMDE preview panes */
.article-body,
.editor-preview,
.editor-preview-side {
  line-height: 1.75;
  color: #374151;
}
.article-body h2, .editor-preview h2, .editor-preview-side h2 { font-size: 1.375rem; font-weight: 700; color: #111827; margin-top: 2rem; margin-bottom: 0.75rem; font-family: var(--font-family-mulish); }
.article-body h3, .editor-preview h3, .editor-preview-side h3 { font-size: 1.125rem; font-weight: 600; color: #111827; margin-top: 1.5rem; margin-bottom: 0.5rem; }
.article-body h4, .editor-preview h4, .editor-preview-side h4 { font-size: 1rem; font-weight: 600; color: #111827; margin-top: 1.25rem; margin-bottom: 0.375rem; }
.article-body p, .editor-preview p, .editor-preview-side p { margin-bottom: 1rem; font-size: 1rem; }
.article-body a, .editor-preview a, .editor-preview-side a { color: #0047bb; text-decoration: underline; text-underline-offset: 3px; }
.article-body a:hover, .editor-preview a:hover, .editor-preview-side a:hover { color: #002d7a; }
.article-body img, .editor-preview img, .editor-preview-side img { width: 100%; border-radius: 0.5rem; margin-top: 1.5rem; margin-bottom: 1.5rem; }
.article-body ul, .editor-preview ul, .editor-preview-side ul { list-style-type: disc; padding-left: 1.5rem; margin-bottom: 1rem; }
.article-body ol, .editor-preview ol, .editor-preview-side ol { list-style-type: decimal; padding-left: 1.5rem; margin-bottom: 1rem; }
.article-body li, .editor-preview li, .editor-preview-side li { margin-bottom: 0.375rem; }
.article-body strong, .editor-preview strong, .editor-preview-side strong { font-weight: 600; color: #111827; }
.article-body em, .editor-preview em, .editor-preview-side em { font-style: italic; }
.article-body blockquote, .editor-preview blockquote, .editor-preview-side blockquote { border-left: 3px solid #0047bb; padding-left: 1rem; margin: 1.5rem 0; color: #6b7280; font-style: italic; }
.article-body code, .editor-preview code, .editor-preview-side code { background: #f3f4f6; border-radius: 0.25rem; padding: 0.125rem 0.375rem; font-size: 0.875em; font-family: monospace; }
.article-body pre, .editor-preview pre, .editor-preview-side pre { background: #f3f4f6; border-radius: 0.5rem; padding: 1rem; overflow-x: auto; margin-bottom: 1rem; }
.article-body pre code, .editor-preview pre code, .editor-preview-side pre code { background: none; padding: 0; }
.article-body hr, .editor-preview hr, .editor-preview-side hr { border: none; border-top: 1px solid #e5e7eb; margin: 2rem 0; }

/* Hide scrollbar but keep functionality */
@utility scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* Navbar logo scroll transition */
.logo-container {
  display: inline-grid;
  align-items: center;
}

.logo-container .logo-full,
.logo-container .logo-icon {
  grid-area: 1 / 1;
}

.logo-container .logo-full {
  opacity: 1;
}

.logo-container .logo-icon {
  opacity: 0;
}

/* Scroll down: full → icon (clockwise spin in) */
.logo-container.logo-scrolled .logo-full {
  opacity: 0;
  pointer-events: none;
}

.logo-container.logo-scrolled .logo-icon {
  animation: icon-rotate-in 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Scroll up: icon → full (anticlockwise spin out) */
.logo-container.logo-scroll-out .logo-icon {
  animation: icon-rotate-out 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes icon-rotate-in {
  from {
    opacity: 0;
    transform: rotate(-360deg);
  }
  to {
    opacity: 1;
    transform: rotate(0deg);
  }
}

@keyframes icon-rotate-out {
  from {
    opacity: 1;
    transform: rotate(0deg);
  }
  to {
    opacity: 0;
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .logo-container.logo-scrolled .logo-icon,
  .logo-container.logo-scroll-out .logo-icon {
    animation: none;
  }
}

/* Full-width section that breaks out of body margins */
@utility full-width-section {
  @apply -mx-4 sm:-mx-8 md:-mx-16 lg:-mx-24 xl:-mx-[9rem];
}

/* Content inside full-width sections that respects body margins */
@utility content-width {
  @apply mx-4 sm:mx-8 md:mx-16 lg:mx-24 xl:mx-[9rem];
}
