/**
 * Lattice — Mobile Stylesheet
 *
 * Loaded only on screens <= 768px via media query in HTML.
 * These rules override desktop styles for touch devices.
 *
 * IMPORTANT: Desktop styles are NOT modified. All changes here.
 */

/* ============================================
   GLOBAL MOBILE ADJUSTMENTS
   ============================================ */

html {
  font-size: 14px; /* Slightly larger base for readability */
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  /* Override desktop overflow restrictions */
  overflow: visible !important;
  height: auto !important;
}

body {
  overflow-x: hidden;
  overflow-y: auto !important;
  height: auto !important;
  min-height: 100vh;
  /* Ensure body can scroll */
  position: relative !important;
  display: block !important;
}

/* Reduce heavy backgrounds on mobile for performance */
#bg {
  opacity: 0.5;
}

.hero-background {
  display: none; /* Hide blurred hero image on mobile - saves memory */
}

/* ============================================
   INDEX.HTML - LANDING PAGE
   ============================================ */

/* Fix hero wrapper blocking scroll */
.hero-wrapper {
  overflow: visible !important;
  flex: none !important;
  min-height: auto !important;
  height: auto !important;
}

/* Stack header into single column */
.header-section {
  display: flex !important;
  flex-direction: column;
  gap: 24px;
  padding: 20px;
}

.column {
  width: 100%;
}

/* Make title more prominent */
.header-section h1 {
  font-size: 24px;
  margin-bottom: 8px;
}

/* Hide less critical columns on small screens */
.column:nth-child(5) {
  /* Audio samples - keep but simplify */
}

/* Audio dropdown - make touch-friendly */
.audio-dropdown-wrapper {
  padding: 8px 0;
}

.dropdown-menu {
  position: fixed !important;
  top: auto !important;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  border-radius: 8px 8px 0 0;
  padding: 16px;
  max-height: 50vh;
  overflow-y: auto;
}

.dropdown-menu.open {
  transform: translateY(0) !important;
}

.audio-track {
  padding: 12px 8px;
  min-height: 44px; /* iOS touch target */
  display: flex;
  align-items: center;
}

/* Carousel - simplify for mobile */
.carousel-section {
  padding: 20px 0 40px 0;
}

.carousel-slide {
  width: 85vw !important;
  max-width: 360px;
}

.carousel-slide img {
  border-radius: 4px;
}

/* Hide noise overlay on mobile - performance */
.slide-noise {
  display: none !important;
}

/* Indicators - larger touch targets */
.indicator {
  width: 12px;
  height: 12px;
  margin: 0 6px;
}

/* Lightbox - full screen on mobile */
#lightbox {
  padding: 0;
}

#lightbox img {
  max-width: 100%;
  max-height: 100vh;
  object-fit: contain;
}

/* Footer - stack on mobile */
.footer {
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  text-align: center;
  position: relative;
  z-index: 10; /* Keep above particle background */
}

.footer-left,
.footer-right {
  width: 100%;
}

/* ============================================
   DOCS.HTML - USER GUIDE
   ============================================ */

/* Single column layout */
.docs-layout {
  display: block !important;
  padding: 16px;
  max-width: 100%;
}

/* Sidebar - convert to horizontal nav at top */
.sidebar {
  position: relative !important;
  top: 0;
  width: 100%;
  max-height: none;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border, #1a1a1a);
}

.sidebar-header {
  margin-bottom: 12px;
}

.sidebar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sidebar-nav a {
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 2px;
  font-size: 11px;
  white-space: nowrap;
}

/* Hide TOC sidebar on mobile */
.toc {
  display: none !important;
}

/* Content area */
.content {
  width: 100%;
  max-width: 100%;
}

.content h2 {
  font-size: 16px;
  margin-top: 32px;
}

.content h3 {
  font-size: 14px;
}

/* ASCII diagram - allow horizontal scroll */
.ascii-diagram {
  overflow-x: auto;
  justify-content: flex-start;
  margin: 16px -16px;
  padding: 0 16px;
}

.ascii-diagram canvas {
  flex-shrink: 0;
}

/* Cards - full width */
.card {
  margin: 16px 0;
}

/* Tables - horizontal scroll */
.param-table {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

/* Code blocks - horizontal scroll */
.content pre {
  overflow-x: auto;
  margin: 12px -16px;
  padding: 12px 16px;
  border-radius: 0;
}

/* ============================================
   DOWNLOAD.HTML
   ============================================ */

.container {
  padding: 20px;
}

.download-section {
  margin: 24px 0;
}

.download-item {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 16px 0;
}

.download-link {
  width: 100%;
  text-align: center;
  padding: 12px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   TOUCH INTERACTIONS
   ============================================ */

/* Disable hover effects that cause sticky states on touch */
@media (hover: none) {
  a:hover,
  button:hover,
  .audio-track:hover,
  .indicator:hover {
    /* Remove hover styles - they stick on touch devices */
  }

  /* Use :active instead for touch feedback */
  a:active,
  button:active,
  .audio-track:active {
    opacity: 0.7;
  }
}

/* Ensure tap targets are at least 44px (iOS guideline) */
a, button, .audio-track, .indicator, .download-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Reduce animations on mobile */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Disable WebGL effects on mobile - they drain battery */
.slide-noise {
  display: none !important;
}

/* Simpler transitions */
.carousel-track {
  transition-duration: 0.3s !important;
}
