@import './tailwind.css';

/* Apple-style documentation prose styling */
.prose {
  @apply text-gray-900 dark:text-gray-100;
  max-width: none;
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
    system-ui, sans-serif;
  font-feature-settings:
    'kern' 1,
    'liga' 1,
    'calt' 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 移动端优化 */
@media (max-width: 768px) {
  .prose {
    font-size: 0.9rem;
    line-height: 1.65;
  }
}

.prose h1 {
  @apply text-gray-900 dark:text-gray-100;
  font-weight: 700;
  font-size: 2.5rem;
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin-bottom: 1.5rem;
  margin-top: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
}

/* 移动端标题优化 */
@media (max-width: 768px) {
  .prose h1 {
    font-size: 1.875rem;
    margin-bottom: 1rem;
  }
}

.prose h2 {
  @apply text-gray-900 dark:text-gray-100;
  font-weight: 600;
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-top: 3rem;
  margin-bottom: 1.25rem;
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
}

/* 移动端H2标题优化 */
@media (max-width: 768px) {
  .prose h2 {
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
  }
}

.prose h3 {
  @apply text-gray-900 dark:text-gray-100;
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
}

/* 移动端H3标题优化 */
@media (max-width: 768px) {
  .prose h3 {
    font-size: 1.25rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
  }
}

.prose h4 {
  @apply text-gray-900 dark:text-gray-100;
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
}

.prose h5 {
  @apply text-gray-900 dark:text-gray-100;
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.4;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
}

.prose h6 {
  @apply text-gray-900 dark:text-gray-100;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.5;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
}

.prose p {
  @apply text-text;
  margin-bottom: 1.25rem;
  line-height: 1.6;
  font-size: 1rem;
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  text-wrap: pretty;
}

.prose strong {
  @apply text-gray-900 dark:text-gray-100;
  font-weight: 600;
}

.prose em {
  font-style: italic;
  @apply text-gray-900 dark:text-gray-100;
}

.prose code {
  @apply text-text-secondary;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  font-size: 0.9em;
  font-family:
    'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New',
    monospace;
  font-weight: 500;
}

&:where([data-theme='dark'], [data-theme='dark'] *) {
  .shiki,
  .shiki span {
    color: var(--shiki-dark) !important;
    background-color: var(--shiki-dark-bg) !important;
    /* Optional, if you also want font styles */
    font-style: var(--shiki-dark-font-style) !important;
    font-weight: var(--shiki-dark-font-weight) !important;
    text-decoration: var(--shiki-dark-text-decoration) !important;
  }
}

.prose pre {
  @apply text-text border-border border-solid border-[1px];
  padding: 1.25rem;
  border-radius: 12px;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-family:
    'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New',
    monospace;
  font-size: 0.875rem;
  line-height: 1.5;
}

.prose pre code {
  background-color: transparent;
  padding: 0;
  border: none;
  border-radius: 0;
  font-weight: 400;
}

.prose ul,
.prose ol {
  @apply text-gray-900 dark:text-gray-100;
  margin: 1.25rem 0;
  padding-left: 1.75rem;
}

.prose ul {
  list-style-type: none;
}

.prose ul > li {
  position: relative;
}

.prose ul > li::before {
  content: '•';
  @apply text-gray-500 dark:text-gray-400;
  font-weight: bold;
  position: absolute;
  left: -1.25rem;
  top: 0;
}

.prose ol {
  list-style-type: decimal;
}

.prose ol > li::marker {
  @apply text-gray-500 dark:text-gray-400;
  font-weight: 500;
}

.prose li {
  margin: 0.75rem 0;
  line-height: 1.6;
}

.prose li > p {
  margin-bottom: 0.5rem;
}

.prose blockquote {
  @apply border-l-4 border-blue-600 bg-blue-50 dark:bg-blue-900/20;
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
  border-radius: 8px;
  position: relative;
}

.prose blockquote p {
  @apply text-gray-900 dark:text-gray-100;
  font-style: italic;
  margin-bottom: 0;
  font-size: 1.1em;
  line-height: 1.7;
}

.prose blockquote::before {
  content: '"';
  @apply text-gray-400 dark:text-gray-500;
  font-size: 3rem;
  font-weight: bold;
  position: absolute;
  top: -0.5rem;
  left: 1rem;
  opacity: 0.3;
}

.prose a {
  @apply text-link;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  border-radius: 4px;
  padding: 0 2px;
}

.prose a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.prose a:active {
  transform: scale(0.98);
}

/* Table styling */
.prose table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  @apply border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800;
  border-radius: 8px;
  overflow: hidden;
  margin: 1.5rem 0;
}

.prose th {
  @apply bg-gray-100 dark:bg-gray-700 text-gray-900 dark:text-gray-100 border-b border-gray-200 dark:border-gray-600;
  font-weight: 600;
  padding: 0.75rem 1rem;
  text-align: left;
}

.prose td {
  padding: 0.75rem 1rem;
  @apply border-b border-gray-100 dark:border-gray-700 text-gray-900 dark:text-gray-100;
}

.prose tr:last-child td {
  border-bottom: none;
}

/* Horizontal rule */
.prose hr {
  border: none;
  @apply border-t border-gray-200 dark:border-gray-700;
  margin: 3rem 0;
}

/* Image styling */
.prose img {
  margin: 1.5rem 0;
}

/* Badge/Tag styling */
.prose .badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  @apply bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-gray-100 border border-gray-200 dark:border-gray-700;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Focus and accessibility */
.prose *:focus {
  @apply outline-2 outline-blue-600 dark:outline-blue-400;
  outline-offset: 2px;
}

.mermaid-diagram {
  @apply mx-auto my-8 flex items-center justify-center;
}
.mermaid-diagram img {
  @apply max-h-[300px] lg:max-h-[400px] w-auto max-w-full;
  min-height: 0;
}
.mermaid-dark {
  display: none;
}
@media (prefers-color-scheme: dark) {
  .mermaid-light {
    display: none;
  }

  .mermaid-dark {
    display: block;
  }
}
