/* Wiki Responsive Enhancements
 * This file adds comprehensive mobile styling for all wiki components
 * especially focusing on shortcode-generated content.
 */

/* Global responsive improvements */
html {
  box-sizing: border-box;
}

*, *:before, *:after {
  box-sizing: inherit;
}

img {
  max-width: 100%;
  height: auto;
}

/* Large screens (tablets, small laptops) */
@media (max-width: 1200px) {
  /* Keep the flex layout but adjust sidebar width */
  .wiki-sidebar {
    width: 240px;
  }
  
  /* Improve article container */
  .article-container {
    padding: var(--space-lg);
    padding-bottom: calc(var(--space-lg) + 50px);
  }
  
  /* Ensure all grids adapt properly */
  .wiki-grid-2, 
  .wiki-grid-3, 
  .welcome-grid-2, 
  .welcome-grid-3, 
  .welcome-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Medium screens (tablets, large phones) */
@media (max-width: 768px) {
  /* ===== ESSENTIAL LAYOUT FIXES ===== */
  
  /* Switch to vertical layout on mobile */
  .wiki-container {
    flex-direction: column;
    height: auto;
  }
  
  .wiki-sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--light-gray);
    padding: var(--space-md);
  }
  
  .wiki-main-content {
    height: auto;
    min-height: calc(100vh - 200px);
  }
  
  /* Article layout improvements */
  .article-container {
    padding: var(--space-md);
    min-height: auto;
    padding-bottom: calc(var(--space-md) + 50px);
  }
  
  .article-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .article-title {
    font-size: 1.5rem;
    margin-bottom: var(--space-sm);
  }
  
  .article-tools {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-sm);
    width: 100%;
  }
  
  .article-breadcrumbs {
    flex-wrap: wrap;
  }
  
  /* ===== SHORTCODE COMPONENT FIXES ===== */
  
  /* Fix grid layouts to single column */
  .wiki-grid-2,
  .wiki-grid-3,
  .welcome-grid,
  .welcome-grid-2,
  .welcome-grid-3,
  .welcome-grid-4,
  .category-grid,
  .categories-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem;
    margin: 0.5rem 0;
  }
  
  /* Grid item positioning fixes */
  .welcome-grid .grid-item,
  .welcome-grid .welcome-section,
  [class*="grid-position"],
  [class*="grid-area"],
  [class*="grid-row"],
  [class*="grid-span"] {
    grid-column: 1 !important;
    grid-row: auto !important;
    margin-bottom: var(--space-md);
  }
  
  /* Fix welcome sections */
  .article-content .welcome-container .welcome-section,
  .grid-item {
    min-height: auto;
    height: auto;
    padding: var(--space-md);
    overflow: visible; /* Allow content to display fully */
  }
  
  /* Handle text overflow more gracefully for shortcode content */
  .welcome-section > p:not(.article-card p):not(.category-nav-description) {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 6; /* Reduce to 6 lines for tighter mobile layout */
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
  }
  
  /* Don't truncate content inside cards or complex shortcode structures */
  .article-card p,
  .category-nav-description,
  .category-description,
  .feature-box p,
  .quote-panel p {
    display: block !important;
    -webkit-line-clamp: none !important;
    overflow: visible !important;
  }
  
  /* Mobile-first height constraints for shortcode sections */
  .article-content .welcome-container .welcome-section {
    max-height: none; /* Remove rigid height constraints */
    min-height: auto;
    height: auto;
  }
  
  /* Content overflow handling for mobile */
  .article-content .welcome-container .welcome-section:first-of-type {
    /* About section - allow natural height but cap if needed */
    max-height: none;
  }
  
  .welcome-section:nth-of-type(2) {
    /* Recent Articles section - needs more space for cards */
    max-height: 400px !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .welcome-section:nth-of-type(3) {
    /* Key Topics section - accommodate lists better */
    max-height: 350px !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .welcome-section:nth-of-type(4) {
    /* Contribute section - compact but scrollable */
    max-height: 300px !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Hero section improvements */
  .welcome-hero,
  .category-hero {
    padding: var(--space-lg) var(--space-md);
    margin-bottom: var(--space-md);
  }
  
  .welcome-hero h1,
  .category-hero-title {
    font-size: 1.5rem;
    margin-bottom: var(--space-sm);
  }
  
  .welcome-subtitle,
  .category-hero-description {
    font-size: 0.9rem;
    max-width: 100%;
  }
  
  /* Button improvements for mobile */
  .welcome-buttons {
    flex-direction: column;
    gap: var(--space-sm);
    width: 100%;
  }
  
  .welcome-button,
  .wiki-button {
    width: 100%;
    text-align: center;
    margin-bottom: var(--space-xs);
  }
  
  /* Card layout improvements for shortcode components */
  .article-list,
  .category-grid,
  .category-navigation-grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-sm) !important;
    margin: var(--space-md) 0 !important;
  }
  
  .article-card,
  .category-card,
  .category-item,
  .category-nav-item {
    padding: var(--space-sm) !important;
    margin-bottom: var(--space-sm) !important;
  }
  
  /* Compact article cards for mobile */
  .article-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
  }
  
  .article-card h3 {
    font-size: 1rem !important;
    line-height: 1.3 !important;
    margin: 0 !important;
  }
  
  .article-meta {
    font-size: 0.8rem !important;
    color: var(--medium-gray) !important;
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
  }
  
  /* Feature box, Concept box and Quote panel improvements */
  .feature-box,
  .concept-box,
  .quote-panel {
    padding: var(--space-md);
    margin: var(--space-md) 0;
  }
  
  /* Table improvements */
  .article-content table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Table of Contents improvements */
  .toc {
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
  }
  
  /* Category portal improvements */
  .category-image {
    height: 120px;
  }
  
  /* Make images responsive and avoid overflow */
  .article-content img,
  .welcome-wiki-content img,
  .category-image img {
    max-width: 100% !important;
    height: auto !important;
  }
  
  /* Fix image alignment on mobile */
  .img-left,
  .img-right,
  .img-center,
  .wiki-figure {
    float: none !important;
    margin: var(--space-md) auto !important;
    max-width: 100% !important;
    display: block;
  }
  
  /* Reduce spacing between welcome-section containers on mobile */
  .article-content .welcome-container .welcome-section {
    margin-bottom: 0.75rem;
  }
}


