/* ============================================
   MOBILE ENHANCEMENTS - Site-Wide
   Touch-friendly, optimized for mobile devices
   ============================================ */

/* Prevent horizontal overflow on mobile */
html, body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

body {
  position: relative;
}

/* Mobile-First Base */
* {
  -webkit-tap-highlight-color: rgba(42, 122, 226, 0.1);
}

/* Improve Touch Targets */
a, button {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Text Links Exception */
.post-card-title a,
.category-badge,
.post-tag,
.post-link,
p a,
.post-excerpt,
.pagination-pages a,
.pagination-pages span,
figure a {
  min-height: unset;
  min-width: unset;
  display: inline;
}

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

/* Prevent Zoom on Input Focus (iOS) */
@media screen and (max-width: 600px) {
  input[type="text"],
  input[type="search"],
  textarea {
    font-size: 16px !important;
  }
}

/* Mobile Typography Adjustments */
@media (max-width: 600px) {
  body {
    font-size: 15px;
    line-height: 1.6;
  }

  h1 {
    font-size: 28px;
    line-height: 1.2;
  }

  h2 {
    font-size: 22px;
    line-height: 1.3;
  }

  h3 {
    font-size: 18px;
    line-height: 1.4;
  }

  p {
    margin-bottom: 16px;
  }
}

/* Mobile Spacing */
@media (max-width: 600px) {
  .wrapper {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .page-content {
    padding-top: 24px;
    padding-bottom: 32px;
  }
}

/* Mobile Navigation Improvements */
@media (max-width: 900px) {
  .site-header {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  }

  .site-title {
    font-size: 20px;
  }
}

/* Mobile Footer */
@media (max-width: 600px) {
  .site-footer {
    padding: 24px 0;
  }

  .footer-col-wrapper {
    gap: 16px;
  }

  .social-media-list {
    gap: 8px;
    justify-content: flex-start;
  }

  .social-media-list a {
    width: 40px;
    height: 40px;
  }
}

/* Mobile Pagination */
@media (max-width: 600px) {
  .pagination {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 14px;
  }

  .pagination-pages {
    margin-top: 16px;
  }

  .pagination-pages a,
  .pagination-pages span {
    min-width: 36px;
    height: 36px;
    font-size: 14px;
  }
}

/* Mobile Forms */
@media (max-width: 600px) {
  input[type="text"],
  input[type="email"],
  input[type="search"],
  textarea {
    padding: 12px 14px;
    border-radius: 8px;
  }

  button,
  .button {
    padding: 12px 20px;
    font-size: 15px;
    border-radius: 8px;
  }
}

/* Smooth Scrolling (All Devices) */
html {
  scroll-behavior: smooth;
}

/* Reduce 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;
    scroll-behavior: auto !important;
  }
}

/* Better Image Loading */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Gallery images OVERRIDE - must maintain their grid dimensions */
.gallery img,
.gallery figure img,
.post-content .gallery img,
.page-content .gallery img {
  max-width: none !important;
  height: 100% !important;
  width: 100% !important;
  display: block !important;
  object-fit: cover !important;
}

/* Prevent Layout Shift */
.post-card-image {
  background: #f5f5f5;
}

/* Mobile Table Handling */
@media (max-width: 600px) {
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Mobile Code Blocks */
@media (max-width: 600px) {
  pre,
  code {
    font-size: 13px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Focus Visible (Keyboard Navigation) */
*:focus-visible {
  outline: 2px solid #2a7ae2;
  outline-offset: 2px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  /* Prepare for future dark mode */
  :root {
    --tap-highlight: rgba(100, 150, 255, 0.2);
  }
}

/* Landscape Mobile Adjustments */
@media (max-width: 900px) and (orientation: landscape) {
  .wrapper {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .post-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-left: 0;
    margin-right: 0;
  }

  .post-card.featured {
    grid-column: span 2;
  }
}

/* Tablet Portrait */
@media (min-width: 601px) and (max-width: 900px) and (orientation: portrait) {
  .post-grid {
    gap: 24px;
    margin-left: 0;
    margin-right: 0;
  }

  .wrapper {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
}

/* Very Small Devices */
@media (max-width: 375px) {
  .page-heading {
    font-size: 24px;
  }

  .post-card-content {
    padding: 16px;
  }

  .category-badge {
    font-size: 10px;
    padding: 3px 10px;
  }

  .post-card-title {
    font-size: 16px;
  }

  .post-card-excerpt {
    font-size: 13px;
  }
}

/* Safe Area Insets (iPhone X+) */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
}
