/* Mobile-specific styles for KPMWiki */
/* Mobile viewport handling */
@-ms-viewport {
  width: device-width;
}

@viewport {
  width: device-width;
}

/* Additional mobile reset */
html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Better touch interaction */
a, button, [role="button"] {
  touch-action: manipulation;
}

/* Remove tap highlight color on links */
a {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background-color: #343a40;
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  text-align: center;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: transform 0.3s ease;
}

.sidebar-toggle:hover {
  transform: scale(1.1);
}

.sidebar-toggle:active {
  transform: scale(0.95);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 900;
}

.search-container {
  position: relative;
}

/* Base mobile styles for all screens <= 768px */
@media (max-width: 768px) {
  /* General mobile adjustments */
  body {
    font-size: 16px;
  }
  
  /* Header adjustments */
  .header {
    padding: 0.5rem;
  }
  
  .header-title a {
    font-size: 1.2rem;
  }
  
  .search-input {
    width: 130px;
    font-size: 14px;
    padding: 0.4rem 0.8rem;
  }
  
  .search-input:focus {
    width: 140px;
  }
  
  /* Show the toggle button */
  .sidebar-toggle {
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  /* Content area adjustments */
  .content {
    padding: 15px;
    padding-left: 15px;
    width: 100%;
  }
  
  .page-title h1 {
    font-size: 1.5rem;
  }
  
  /* Table of contents adjustments */
  .article-container {
    flex-direction: column;
  }
  
  .table-of-contents {
    position: static;
    width: 100%;
    margin-bottom: 20px;
    max-height: none;
  }
  
  /* Improve code blocks on mobile */
  .article-content pre {
    padding: 0.75rem;
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-break: break-word;
  }
  
  /* Improve tables on mobile */
  .article-content table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  
  /* Improve search results display */
  .result-item {
    padding: 0.75rem;
  }
  
  .result-context {
    max-height: 150px;
    overflow-y: auto;
  }
  
  /* Directory listing adjustments */
  .files-grid, .folders-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
  }
}

/* Styles for extra small screens */
@media (max-width: 480px) {
  /* Header layout for very small screens */
  .header {
    flex-wrap: wrap;
    height: auto;
    padding-bottom: 10px;
  }
  
  .header-title {
    margin-bottom: 8px;
    width: 100%;
    text-align: center;
  }
  
  .search-container {
    width: 100%;
    justify-content: center;
    margin-top: 5px;
  }
  
  .search-input {
    width: calc(100% - 40px);
  }
  
  .search-input:focus {
    width: calc(100% - 40px);
  }
  
  .container {
    margin-top: 90px;
  }
  
  /* Smaller grid items for very small screens */
  .files-grid, .folders-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
  
  /* Adjust font sizes for better readability on small screens */
  .article-content h2 {
    font-size: 1.5rem;
  }
  
  .article-content h3 {
    font-size: 1.3rem;
  }
  
  .article-content h4 {
    font-size: 1.1rem;
  }
  
  /* Reduce padding for better space utilization */
  .content {
    padding: 10px;
  }
  
  /* Better image handling */
  .article-content img {
    max-width: 100%;
    height: auto;
    margin: 0.5rem 0;
  }
}
