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

/* Import KaTeX styles for math formula rendering */
@import 'katex/dist/katex.min.css';

@layer base { 
  html {
    font-family: 'Open Sans', system-ui, sans-serif;
    scroll-padding-top: 100px; /* Adjust based on header height */
  }

  :lang(en) h1, :lang(en) h2, :lang(en) h3, :lang(en) h4, :lang(en) h5, :lang(en) h6 {
    font-family: 'Open Sans', sans-serif;
  }

  :lang(zh) h1, :lang(zh) h2, :lang(zh) h3, :lang(zh) h4, :lang(zh) h5, :lang(zh) h6 {
    font-family: 'Open Sans', sans-serif;
  }
}

/* Mouse glow effect */
.mouse-glow {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 0;
}

.mouse-glow::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle at center, rgba(0, 136, 255, 0.15), transparent 50%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.2s, height 0.2s;
}

@media (hover: none) {
  .mouse-glow {
    display: none;
  }
}

/* Hero Section Scroll */
.hero-container {
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  scroll-snap-type: y mandatory;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.hero-section {
  scroll-snap-align: start;
  scroll-snap-stop: always;
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for mobile */
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: 5rem;
  position: relative;
  overflow: hidden;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.hero-container::-webkit-scrollbar {
  display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.hero-container {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .hero-section {
    padding-top: 4rem;
    padding-bottom: 2rem;
  }
}

/* Scroll Down Button Animation */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

.scroll-down-button {
  animation: bounce 2s infinite;
  bottom: 0;
  z-index: 10;
}

/* Partner Logo Animation */
@keyframes scroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

.animate-scroll {
  animation: scroll 30s linear infinite;
}

.animate-scroll:hover {
  animation-play-state: paused;
}

/* Loading Animation */
@keyframes typing {
  0% { transform: translateY(0px); }
  28% { transform: translateY(-7px); }
  44% { transform: translateY(0px); }
}

.loading-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(8px);
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #0088FF;
  animation: typing 1.4s infinite;
}

.loading-dots span:nth-child(1) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.4s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.6s;
}

/* 3D Card Flip Animation */
.card-container {
  perspective: 1000px;
}

.card {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s;
}

.card.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.card-back {
  transform: rotateY(180deg);
}

/* Add scroll margin for heading elements */
h1, h2, h3, h4, h5, h6 {
  scroll-margin-top: 100px;
}

/* Improve scrolling behavior for glossary content */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 120px; /* Match the header height */
}

/* Markdown content styling */
.glossary-content {
  color-scheme: light !important;
  background-color: white !important;
  color: #333 !important;
}

.glossary-content .prose h1 {
  color: #0088FF;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 1.5rem;
  font-size: 2.25rem;
  line-height: 2.5rem;
}

.glossary-content .prose h2 {
  color: #333;
  font-weight: 600;
  margin-top: 1.75rem;
  margin-bottom: 1rem;
  font-size: 1.75rem;
  line-height: 2rem;
  border-bottom: 1px solid #eaeaea;
  padding-bottom: 0.5rem;
}

.glossary-content .prose h3 {
  color: #444;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.5rem;
  line-height: 1.75rem;
}

.glossary-content .prose p {
  margin-bottom: 1.25rem;
  line-height: 1.7;
}

.glossary-content .prose ul {
  margin-top: 1rem;
  margin-bottom: 1rem;
  padding-left: 1.5rem;
  list-style-type: disc;
  list-style-position: outside;
}

.glossary-content .prose li {
  margin-bottom: 0.5rem;
}

.glossary-content .prose strong {
  font-weight: 600;
}

.glossary-content .prose a {
  color: #0088FF;
  text-decoration: none;
  transition: color 0.2s;
}

.glossary-content .prose a:hover {
  text-decoration: underline;
}

.glossary-content .prose blockquote {
  border-left: 4px solid #0088FF;
  padding-left: 1rem;
  font-style: italic;
  color: #555;
  margin: 1.5rem 0;
}

.glossary-content .prose code {
  background-color: #f5f5f5;
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
  color: #0088FF;
}

.glossary-content .prose pre {
  background-color: #f8f9fa;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid #eaeaea;
}

.glossary-content .prose pre code {
  background-color: transparent;
  padding: 0;
  color: #333;
}

/* Add scroll margin for heading elements */
h1, h2, h3, h4, h5, h6 {
  scroll-margin-top: 120px;
}

/* Force light mode for markdown content */
.glossary-content .wmde-markdown {
  color-scheme: light;
  background-color: white;
  color: #333;
}

/* Fix for Markdown unordered lists */
.wmde-markdown ul {
  list-style-type: disc !important;
  list-style-position: outside !important;
  padding-left: 2rem !important;
}