/* Mobile Optimization - Enhanced Touch Experience */

/* Mobile-First Navigation Enhancements */
@media screen and (max-width: 768px) {
  /* Enhanced Touch Targets */
  .md-nav__link {
    min-height: 44px; /* iOS touch target minimum */
    padding: 0.75rem 1rem;
  }
  
  /* Larger touch targets for interactive elements */
  .copy-button, .download-button, .run-button {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
  }
  
  /* Enhanced Topic Cards for Mobile */
  .topic-card {
    margin: 0.5rem 0;
    padding: 1rem;
  }
  
  .topic-card-header {
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }
  
  .topic-card-icon {
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
  }
  
  .topic-card-footer {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  
  .topic-card-action {
    text-align: center;
    padding: 0.75rem;
    font-size: 1rem;
  }
  
  /* Enhanced Lab Exercises for Mobile */
  .lab-exercise {
    margin: 1rem 0;
    padding: 1rem;
  }
  
  .lab-exercise-header {
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }
  
  .lab-exercise-icon {
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
  }
  
  .lab-step {
    padding-left: 0;
    margin-bottom: 2rem;
  }
  
  .lab-step::before {
    position: relative;
    top: auto;
    left: auto;
    margin-bottom: 0.5rem;
  }
  
  /* Enhanced Code Blocks for Mobile */
  .code-block-wrapper {
    margin: 1rem 0;
    border-radius: 0.75rem;
  }
  
  .code-block-header {
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
  }
  
  .code-block-actions {
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .code-block-content {
    padding: 0.75rem;
    font-size: 0.8rem;
  }
  
  /* Enhanced Logic-First Annotations for Mobile */
  .logic-first {
    margin: 1rem 0;
    padding: 1rem;
  }
  
  .logic-first h4 {
    font-size: 1rem;
  }
  
  .logic-first p {
    font-size: 0.9rem;
  }
  
  /* Enhanced Workflow Navigation for Mobile */
  .workflow-nav {
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
  }
  
  .workflow-nav-item {
    padding: 1rem;
    text-align: center;
    min-height: 44px;
  }
  
  /* Enhanced Content Tags for Mobile */
  .content-tag {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    margin: 0.25rem;
  }
  
  /* Enhanced Progress Indicators for Mobile */
  .progress-bar {
    height: 8px;
    border-radius: 4px;
  }
  
  .progress-fill {
    height: 8px;
    border-radius: 4px;
  }
}

/* Touch-Friendly Enhancements */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .topic-card:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }
  
  .copy-button:hover,
  .download-button:hover,
  .run-button:hover {
    transform: none;
  }
  
  .starter-file-item:hover {
    transform: none;
  }
  
  /* Add active states for touch */
  .topic-card:active {
    transform: scale(0.98);
  }
  
  .copy-button:active,
  .download-button:active,
  .run-button:active {
    transform: scale(0.95);
  }
}

/* Swipe Gestures for Mobile */
@media screen and (max-width: 768px) {
  /* Swipeable topic cards */
  .topic-cards-grid {
    scroll-snap-type: x mandatory;
    scroll-snap-points-x: repeat(100%);
    scroll-snap-stop: always;
    overflow-x: auto;
    scroll-snap-align: start;
    -webkit-overflow-scrolling: touch;
  }
  
  .topic-cards-grid .topic-card {
    scroll-snap-align: start;
    flex: 0 0 85%;
    max-width: 300px;
  }
  
  /* Hide scrollbar but keep functionality */
  .topic-cards-grid::-webkit-scrollbar {
    display: none;
  }
  
  .topic-cards-grid {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  
  /* Swipe indicators */
  .topic-cards-grid::after {
    content: '← Swipe →';
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: var(--md-default-fg-color--light);
    pointer-events: none;
  }
}

/* Mobile-Specific Success Messages */
@media screen and (max-width: 768px) {
  .success-message {
    left: 10px;
    right: 10px;
    top: 10px;
    padding: 0.75rem;
    font-size: 0.9rem;
  }
}

/* Enhanced Mobile Typography */
@media screen and (max-width: 768px) {
  .md-typeset h1 {
    font-size: 1.8rem;
  }
  
  .md-typeset h2 {
    font-size: 1.5rem;
  }
  
  .md-typeset h3 {
    font-size: 1.3rem;
  }
  
  .md-typeset p {
    font-size: 0.95rem;
    line-height: 1.6;
  }
  
  .md-typeset li {
    font-size: 0.95rem;
  }
}

/* Mobile Optimized Tables */
@media screen and (max-width: 768px) {
  .md-typeset table {
    font-size: 0.8rem;
  }
  
  .md-typeset th,
  .md-typeset td {
    padding: 0.5rem 0.25rem;
  }
  
  /* Make tables horizontally scrollable on mobile */
  .md-typeset table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* Mobile-Friendly Forms */
@media screen and (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 44px;
    padding: 0.75rem;
  }
}

/* Enhanced Mobile Navigation */
@media screen and (max-width: 768px) {
  .md-nav--primary .md-nav__item {
    margin: 0.25rem 0;
  }
  
  .md-nav--primary .md-nav__link {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
  }
  
  /* Larger touch targets for sidebar */
  .md-nav--secondary .md-nav__link {
    padding: 0.5rem 0.75rem;
    min-height: 44px;
  }
}

/* Mobile Performance Optimizations */
@media screen and (max-width: 768px) {
  /* Reduce animations on mobile for better performance */
  .topic-card {
    animation: none;
  }
  
  /* Optimize images for mobile */
  img {
    max-width: 100%;
    height: auto;
  }
  
  /* Reduce box shadows for better performance */
  .code-block-wrapper,
  .lab-exercise,
  .logic-first {
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  }
}

/* Dark Mode Mobile Optimizations */
@media screen and (max-width: 768px) {
  [data-md-color-scheme="slate"] .success-message {
    background: #2e7d32;
  }
  
  [data-md-color-scheme="slate"] .copy-button.copied {
    background: #2e7d32;
  }
  
  [data-md-color-scheme="slate"] .topic-card {
    background: var(--md-default-bg-color);
  }
}

/* Landscape Mobile Optimizations */
@media screen and (max-width: 768px) and (orientation: landscape) {
  .lab-exercise-header {
    flex-direction: row;
    text-align: left;
  }
  
  .workflow-nav {
    flex-direction: row;
  }
  
  .topic-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .topic-cards-grid .topic-card {
    flex: 1;
  }
}

/* Very Small Screens (iPhone SE, etc.) */
@media screen and (max-width: 375px) {
  .topic-card-icon {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }
  
  .lab-exercise-icon {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }
  
  .code-block-actions {
    flex-direction: column;
  }
  
  .copy-button,
  .download-button {
    width: 100%;
  }
}
