/* Custom styles for Bestatic Tailwind Documentation Theme */

/* Custom xs breakpoint for very small screens (360px+) */
@media (min-width: 360px) {
  .xs\:px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .xs\:space-x-3> :not([hidden])~ :not([hidden]) {
    margin-left: 0.75rem;
  }

  .xs\:space-x-2> :not([hidden])~ :not([hidden]) {
    margin-left: 0.5rem;
  }

  .xs\:p-2 {
    padding: 0.5rem;
  }

  .xs\:w-6 {
    width: 1.5rem;
  }

  .xs\:h-6 {
    height: 1.5rem;
  }

  .xs\:w-5 {
    width: 1.25rem;
  }

  .xs\:h-5 {
    height: 1.25rem;
  }

  .xs\:h-8 {
    height: 2rem;
  }
}

/* Base font for everything except code */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Responsive body padding to match navbar height */
/* At very small screens (<640px/sm), navbar has py-2 (0.5rem × 2) + logo h-7 (1.75rem) ≈ 2.75rem */
/* At sm+ screens, navbar has py-3 (0.75rem × 2) + logo h-8 (2rem) ≈ 3.5rem */
/* Default pt-16 (4rem) works for md+ screens */
@media (max-width: 639px) {

  body.pt-16,
  body[class*="pt-16"] {
    padding-top: 3rem !important;
    /* Match smaller navbar height */
  }

  /* Also fix sidebar top position for docs pages */
  #sidebar,
  #toc-sidebar {
    top: 3rem !important;
  }

  /* Fix scroll position for anchor links at small viewports */
  /* Much smaller values to fix scroll going too far down */
  html {
    scroll-padding-top: 1.5rem !important;
  }

  /* Apply to ALL headings with IDs (TOC anchor targets), not just .prose */
  h1[id],
  h2[id],
  h3[id],
  h4[id],
  h5[id],
  h6[id],
  .prose h1,
  .prose h2,
  .prose h3,
  .prose h4,
  .prose h5,
  .prose h6 {
    scroll-margin-top: 1.5rem !important;
  }
}

/* Scrollbar styling for sidebars */
#sidebar::-webkit-scrollbar,
#toc-sidebar::-webkit-scrollbar {
  width: 8px;
}

#sidebar::-webkit-scrollbar-track,
#toc-sidebar::-webkit-scrollbar-track {
  background: #e2e8f0;
}

.dark #sidebar::-webkit-scrollbar-track,
.dark #toc-sidebar::-webkit-scrollbar-track {
  background: #1e3252;
}

#sidebar::-webkit-scrollbar-thumb,
#toc-sidebar::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
}

#sidebar::-webkit-scrollbar-thumb:hover,
#toc-sidebar::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.dark #sidebar::-webkit-scrollbar-thumb,
.dark #toc-sidebar::-webkit-scrollbar-thumb {
  background: #475569;
}

.dark #sidebar::-webkit-scrollbar-thumb:hover,
.dark #toc-sidebar::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Mark/Highlight tag styling - Bootstrap/Modular theme inspired */
mark {
  background-color: #fff5d6;
  color: #281f04;
  padding: 0.2rem 0.4rem;
  border-radius: 0.1rem;
}

.dark mark {
  background-color: #9a927899;
  color: #cad5e0;
}

/* Code fonts - applying to all code-related elements */
code,
pre,
kbd,
samp,
.codehilite,
.codehilite *,
.codehilitetable,
.codehilitetable *,
.linenos,
.linenos * {
  font-family: 'Fira Code', 'JetBrains Mono', 'Source Code Pro', Consolas, Monaco, 'Courier New', monospace !important;
}


/* Focus visible for accessibility */
*:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Prevent layout shift from scrollbar */
html {
  overflow-y: scroll;
}

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }

  .print-full-width {
    max-width: 100% !important;
  }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Prose content improvements */
.prose {
  color: inherit;
}

/* Paragraph spacing */
.prose p {
  margin-bottom: 1.25em;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  font-weight: 700;
  line-height: 1.25;
  margin-top: 2rem;
  margin-bottom: 1rem;
  scroll-margin-top: 5rem;
}

.prose h1 {
  font-size: 2.25rem;
  line-height: 2.5rem;
  margin-top: 0;
  color: #0d9488;
  /* teal-600 */
}

.dark .prose h1 {
  color: #5eead4;
  /* teal-300 */
}

.prose h2 {
  font-size: 1.875rem;
  line-height: 2.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
  color: #0891b2;
  /* cyan-600 */
}

.dark .prose h2 {
  border-bottom-color: #374151;
  color: #67e8f9;
  /* cyan-300 */
}

.prose h3 {
  font-size: 1.5rem;
  line-height: 2rem;
  color: #2563eb;
  /* blue-600 */
}

.dark .prose h3 {
  color: #93c5fd;
  /* blue-300 */
}

.prose h4 {
  font-size: 1.25rem;
  line-height: 1.75rem;
  color: #4f46e5;
  /* indigo-600 */
}

.dark .prose h4 {
  color: #a5b4fc;
  /* indigo-300 */
}

.prose h5 {
  font-size: 1.125rem;
  line-height: 1.75rem;
  color: #9333ea;
  /* purple-600 */
}

.dark .prose h5 {
  color: #d8b4fe;
  /* purple-300 */
}

.prose h6 {
  font-size: 1rem;
  line-height: 1.5rem;
  color: #e11d48;
  /* rose-600 */
}

.dark .prose h6 {
  color: #fda4af;
  /* rose-300 */
}

/* Lists in prose */
.prose ol {
  list-style-type: decimal;
  padding-left: 1.625em;
  margin-top: 1.25em;
  margin-bottom: 1.25em;
}

.prose ol li {
  padding-left: 0.375em;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

.prose ul {
  list-style-type: disc;
  padding-left: 1.625em;
  margin-top: 1.25em;
  margin-bottom: 1.25em;
}

.prose ul li {
  padding-left: 0.375em;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

.prose ol>li::marker,
.prose ul>li::marker {
  color: #6b7280;
}

.dark .prose ol>li::marker,
.dark .prose ul>li::marker {
  color: #9ca3af;
}

/* Add scroll padding for anchor links */
html {
  scroll-padding-top: 5rem;
}

.prose a {
  color: #16a34a;
  text-decoration: underline;
  text-decoration-color: rgba(22, 163, 74, 0.3);
  text-underline-offset: 2px;
  transition: all 0.2s;
}

.prose a:hover {
  color: #c026d3;
  text-decoration-color: rgba(192, 38, 211, 1);
}

.dark .prose a {
  color: #4ade80;
  text-decoration-color: rgba(74, 222, 128, 0.3);
}

.dark .prose a:hover {
  color: #e879f9;
  text-decoration-color: rgba(232, 121, 249, 1);
}

/* Inline code (not in code blocks) */
.prose :not(pre)>code {
  background-color: #4c5a71;
  color: #f1f5f9;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
  font-family: 'Fira Code', 'JetBrains Mono', 'Source Code Pro', Consolas, Monaco, 'Courier New', monospace !important;
}

.dark .prose :not(pre)>code {
  background-color: #cdd3d9;
  color: #1e293b;
}

/* Keyboard key styling */
kbd,
.prose kbd {
  background-color: #f3f4f6;
  border: 1px solid #d1d5db;
  border-bottom-width: 2px;
  border-radius: 0.375rem;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  color: #374151;
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875em;
  font-weight: 600;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  vertical-align: baseline;
  white-space: nowrap;
}

.dark kbd,
.dark .prose kbd {
  background-color: #374151;
  border-color: #4b5563;
  color: #e5e7eb;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
}

/* Code block spacing - with higher specificity to override prose defaults */
.prose .codehilite,
.prose .codehilitetable,
.codehilite,
.codehilitetable {
  margin-top: 1.5rem !important;
  /* margin-bottom: 1.5rem !important; */
}

/* Ensure div containing codehilite also has proper spacing */
.prose div.codehilite,
.prose div.codehilitetable {
  margin-top: 1.5rem !important;
  margin-bottom: 1.5rem !important;
}

/* Table styling */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 2rem;
  margin-bottom: 2rem;
  font-size: 0.875rem;
  line-height: 1.5;
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.prose thead {
  background-color: #f9fafb;
  border-bottom: 2px solid #e5e7eb;
}

.dark .prose thead {
  background-color: #1f2937;
  border-bottom-color: #374151;
}

.prose th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: #111827;
  border-right: 1px solid #e5e7eb;
}

.prose th:last-child {
  border-right: none;
}

.dark .prose th {
  color: #f9fafb;
  border-right-color: #374151;
}

.prose td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
  color: #374151;
}

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

.dark .prose td {
  border-bottom-color: #374151;
  border-right-color: #374151;
  color: #d1d5db;
}

.prose tbody tr {
  background-color: #ffffff;
}

.prose tbody tr:nth-child(even) {
  background-color: #f9fafb;
}

.dark .prose tbody tr {
  background-color: #111827;
}

.dark .prose tbody tr:nth-child(even) {
  background-color: #1f2937;
}

.prose tbody tr:hover {
  background-color: #f3f4f6;
}

.dark .prose tbody tr:hover {
  background-color: #374151;
}

/* Table wrapper for responsive scrolling */
.prose>table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

/* Image responsiveness */
.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
}

/* Sidebar transitions */
.sidebar-transition {
  transition: transform 0.3s ease-in-out;
}

/* Backdrop */
.backdrop {
  transition: opacity 0.3s ease-in-out;
}

/* Touch target size for mobile - excluding nav icons */
@media (min-width: 300px) and (max-width: 640px) {

  button:not(#search-toggle):not(#theme-toggle):not(#mobile-menu-toggle):not(#sidebar-toggle),
  a:not(#search-toggle):not(#theme-toggle):not(#mobile-menu-toggle):not(#sidebar-toggle) {
    min-height: 44px;
    min-width: 44px;
  }

  /* Nav icon buttons on small screens */
  #search-toggle,
  #theme-toggle,
  #mobile-menu-toggle,
  #sidebar-toggle {
    min-width: 28px !important;
    min-height: 28px !important;
    width: 28px;
    height: 28px;
    padding: 4px !important;
  }

  #search-toggle svg,
  #theme-toggle svg,
  #mobile-menu-toggle svg,
  #sidebar-toggle svg {
    width: 20px;
    height: 20px;
  }
}

/* Ripple effect for touch devices */
.ripple {
  position: absolute;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.6);
  transform: scale(0);
  animation: ripple-animation 0.6s ease-out;
  pointer-events: none;
}

@keyframes ripple-animation {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Better button positioning for ripple */
button,
.btn {
  position: relative;
  overflow: hidden;
}

/* Line clamp utilities */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Smooth height transitions */
.transition-height {
  transition: height 0.3s ease-in-out;
}

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.dark ::-webkit-scrollbar-track {
  background: #1e293b;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 6px;
}

.dark ::-webkit-scrollbar-thumb {
  background: #475569;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* TOC Sidebar specific scrollbar (thinner) */
#toc-sidebar::-webkit-scrollbar {
  width: 6px;
}

#toc-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#toc-sidebar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.dark #toc-sidebar::-webkit-scrollbar-thumb {
  background: #374151;
}

#toc-sidebar::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.dark #toc-sidebar::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

/* Improve tap highlight color */
* {
  -webkit-tap-highlight-color: rgba(37, 99, 235, 0.1);
}

/* Better text rendering */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Viewport height variable for mobile browsers */
:root {
  --vh: 1vh;
}

/* Responsive video embeds */
.prose iframe,
.prose video {
  max-width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

/* Mobile menu transitions - using custom class to avoid Tailwind conflicts */
#mobile-menu {
  overflow: hidden;
  transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out, margin 0.3s ease-in-out, padding 0.3s ease-in-out;
}

#mobile-menu.menu-closed {
  max-height: 0;
  opacity: 0;
  margin: 0 !important;
  padding: 0 !important;
}

#mobile-menu:not(.menu-closed) {
  max-height: 500px;
  opacity: 1;
}

/* ===================================================================
   Figure and Image Styling
   =================================================================== */

figure {
  margin: 1.5rem 0;
  padding: 0.75rem;
  border: 2px solid #3b82f6;
  border-radius: 0.5rem;
  background-color: #f9fafb;
  display: inline-block;
  max-width: 100%;
}

.dark figure {
  background-color: #1f2937;
  border-color: #60a5fa;
}

figure figcaption {
  margin-top: 0.75rem;
  text-align: center;
  font-size: 0.875rem;
  color: #6b7280;
  font-style: italic;
}

.dark figure figcaption {
  color: #9ca3af;
}

figure img {
  object-fit: contain;
  margin: auto;
  max-width: 100%;
  height: auto;
  border-radius: 0.375rem;
}

.prose figure {
  margin: 1.5rem 0;
}

/* ===================================================================
   Markdown Custom Blocks / Admonitions
   =================================================================== */

div.admonition {
  padding: 0;
  margin-bottom: 1.5rem;
  border-radius: 0.5rem;
  border: 1px solid;
  overflow: hidden;
}

div.admonition p {
  margin: 0.75rem 1rem;
  padding: 0;
}

div.admonition p a {
  color: inherit;
  text-decoration: underline;
}

div.admonition ul,
div.admonition ol {
  margin: 0.5rem 1rem 0.75rem 2.5rem;
  padding: 0;
}

div.admonition p.admonition-title {
  color: #fff;
  margin: 0;
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

div.admonition p.admonition-title::before {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  background-size: 20px 20px;
  background-repeat: no-repeat;
  flex-shrink: 0;
}

/* Danger / Error */
div.danger,
div.error {
  color: #dc2626;
  background-color: #fef2f2;
  border-color: #dc2626;
}

.dark div.danger,
.dark div.error {
  color: #fca5a5;
  background-color: #1f1d1d;
  border-color: #991b1b;
}

div.danger p.admonition-title,
div.error p.admonition-title {
  background-color: #dc2626;
}

div.danger p.admonition-title::before,
div.error p.admonition-title::before {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="white" d="M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"/></svg>');
}

/* Warning / Caution / Attention */
div.warning,
div.caution,
div.attention {
  color: #d97706;
  background-color: #fffbeb;
  border-color: #d97706;
}

.dark div.warning,
.dark div.caution,
.dark div.attention {
  color: #fcd34d;
  background-color: #1e1a0f;
  border-color: #92400e;
}

div.warning p.admonition-title,
div.caution p.admonition-title,
div.attention p.admonition-title {
  background-color: #d97706;
}

div.warning p.admonition-title::before,
div.caution p.admonition-title::before,
div.attention p.admonition-title::before {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="white" d="M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"/></svg>');
}

/* Note / Important */
div.note,
div.important {
  color: #2563eb;
  background-color: #eff6ff;
  border-color: #2563eb;
}

.dark div.note,
.dark div.important {
  color: #93c5fd;
  background-color: #1e293b;
  border-color: #1e40af;
}

div.note p.admonition-title,
div.important p.admonition-title {
  background-color: #2563eb;
}

div.note p.admonition-title::before,
div.important p.admonition-title::before {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="white" d="M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z"/></svg>');
}

/* Hint / Tip */
div.hint,
div.tip {
  color: #059669;
  background-color: #ecfdf5;
  border-color: #059669;
}

.dark div.hint,
.dark div.tip {
  color: #6ee7b7;
  background-color: #1a2e2a;
  border-color: #065f46;
}

div.hint p.admonition-title,
div.tip p.admonition-title {
  background-color: #059669;
}

div.hint p.admonition-title::before,
div.tip p.admonition-title::before {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 352 512"><path fill="white" d="M176 80c-52.94 0-96 43.06-96 96 0 8.84 7.16 16 16 16s16-7.16 16-16c0-35.3 28.72-64 64-64 8.84 0 16-7.16 16-16s-7.16-16-16-16zM96.06 459.17c0 3.15.93 6.22 2.68 8.84l24.51 36.84c2.97 4.46 7.97 7.14 13.32 7.14h78.85c5.36 0 10.36-2.68 13.32-7.14l24.51-36.84c1.74-2.62 2.67-5.7 2.68-8.84l.05-43.18H96.02l.04 43.18zM176 0C73.72 0 0 82.97 0 176c0 44.37 16.45 84.85 43.56 115.78 16.64 18.99 42.74 58.8 52.42 92.16v.06h48v-.12c-.01-4.77-.72-9.51-2.15-14.07-5.59-17.81-22.82-64.77-62.17-109.67-20.54-23.43-31.52-53.15-31.61-84.14-.2-73.64 59.67-128 127.95-128 70.58 0 128 57.42 128 128 0 30.97-11.24 60.85-31.65 84.14-39.11 44.61-56.42 91.47-62.1 109.46a47.507 47.507 0 0 0-2.22 14.3v.1h48v-.05c9.68-33.37 35.78-73.18 52.42-92.16C335.55 260.85 352 220.37 352 176 352 78.8 273.2 0 176 0z"/></svg>');
}