/* Mobile Responsive Improvements for RapidEye Introduction Page */

/* Base mobile styles */
@media screen and (max-width: 768px) {
  /* Improve overall layout for mobile */
  body {
    font-size: 16px;
    line-height: 1.6;
    overflow-x: hidden; /* Prevent horizontal scroll */
  }
  
  /* Ensure all elements stay within viewport */
  * {
    max-width: 100%;
    box-sizing: border-box;
  }
  
  /* Header improvements */
  .header-wrapper {
    padding: 10px 15px;
  }
  
  .header-wrapper .header-title {
    font-size: 18px;
    line-height: 1.4;
  }
  
  .header-title .section-title {
    font-size: 20px;
  }
  
  .header-title .chapter-title {
    font-size: 16px;
  }
  
  /* Navigation improvements */
  .hamburger-button {
    padding: 12px;
    background: none;
    border: none;
    cursor: pointer;
  }
  
  .hamburger-button .material-spec-icon {
    font-size: 28px;
  }
  
  /* Side navigation mobile optimization */
  #side-nav {
    width: 100%;
    max-width: 320px;
  }
  
  #side-nav #logo {
    padding: 20px 15px;
    text-align: center;
  }
  
  #side-nav #logo img {
    height: 60px;
    max-width: 100%;
  }
  
  #side-nav nav dl {
    padding: 0 15px;
  }
  
  #side-nav nav dl dt {
    font-size: 16px;
    padding: 12px 0;
  }
  
  #side-nav nav dl dd a {
    font-size: 14px;
    padding: 8px 0;
  }
  
  /* Main content improvements */
  #grid-cont {
    padding: 0 15px;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  
  .chapter {
    margin: 0;
    padding: 0;
  }
  
  .chapter-title {
    font-size: 28px;
    margin-bottom: 20px;
    text-align: center;
  }
  
  /* Table of contents mobile optimization */
  .chapter-toc {
    margin-bottom: 30px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
  }
  
  .chapter-toc h1 {
    font-size: 18px;
    margin-bottom: 15px;
  }
  
  .chapter-toc ul {
    list-style: none;
    padding: 0;
  }
  
  .chapter-toc li {
    margin-bottom: 8px;
  }
  
  .chapter-toc a {
    display: block;
    padding: 8px 12px;
    background: #fff;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  }
  
  /* Article layout improvements */
  .article {
    margin-bottom: 20px;
    padding: 0;
    width: 100% !important;
  }

  /* Adjust h2 article title margin */
  h2.article-title {
    margin  : 0px;
  }

  .article-title {
    text-align: left;
    font-size: 24px;
    margin-bottom: 15px;
  }

  .article-content {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
  }
  
  .module-list {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .module-list > div {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  /* Fix all section layouts */
  .moduleF1,
  .moduleE1,
  .moduleA1,
  .moduleB1,
  .moduleC1,
  .moduleD1,
  .moduleG1 {
    width: 100% !important;
    max-width: 100% !important;
    padding-bottom: 10px;
  }
  
  .icon-header {
    margin-bottom: 10px;
    text-align: center;
  }
  
  .icon-header img {
    width: 40px;
    height: 40px;
    margin-bottom: 10px;
  }
  
  .icon-header h1 {
    font-size: 22px;
    line-height: 1.3;
    margin: 0;
  }
  
  /* Module content improvements - Override existing flexbox layouts */
  .module-body {
    padding: 0;
    width: 100%;
    margin-bottom: 10px;
  }
  
  .chapter .article-list .article .module-body--lg {
    display: block !important;
    width: 100% !important;
    flex-direction: column !important;
  }
  
  .chapter .article-list .article .module-body--lg > div {
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 20px;
    padding: 0 !important;
    padding-right: 0 !important;
    float: none !important;
    display: block !important;
    flex: none !important;
  }
  
  .chapter .article-list .article .module-body--lg > div:last-child {
    margin-bottom: 0;
  }
  
  /* Fix wrap-text layouts specifically */
  .chapter .article-list .article .module-body--wrap-text {
    display: block !important;
    width: 100% !important;
  }
  
  .chapter .article-list .article .module-body--wrap-text > div {
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 20px;
    padding: 0 !important;
    padding-right: 0 !important;
    float: none !important;
    display: block !important;
    flex: none !important;
  }
  
  .chapter .article-list .article .module-body--wrap-text > div + div {
    flex: none !important;
  }
  
  /* Typography improvements */
  .module-body p {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 16px;
  }
  
  .big-letter {
    font-size: 18px;
    line-height: 1.5;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden;
  }
  
  .big-letter span {
    font-size: 48px;
    line-height: 1;
    float: left;
    margin: 0 8px 8px 0;
  }
  
  /* Clear floats after big letters */
  .big-letter::after {
    content: "";
    display: table;
    clear: both;
  }
  
  /* Image improvements */
  .wrap-image {
    width: 100%;
    height: 200px;
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    margin-bottom: 20px;
  }
  
  /* Figure improvements */
  .figure-group {
    margin: 20px 0;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden;
  }
  
  .figure-row {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .figure-row figure {
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 20px;
    box-sizing: border-box;
  }
  
  /* General figcaption fixes for mobile */
  figcaption {
    width: 100% !important;
    max-width: 100% !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    box-sizing: border-box;
    padding: 8px 0;
  }
  
  figcaption p {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    font-size: 14px;
    line-height: 1.5;
  }
  
  .figure-row figure img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    box-sizing: border-box;
  }
  
  /* Additional media element fixes */
  .media img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto;
    box-sizing: border-box;
  }
  
  .figure-row figure figcaption {
    padding: 12px 0;
    font-size: 14px;
    line-height: 1.5;
    color: #666;
    text-align: center;
    width: 100% !important;
    max-width: 100% !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    box-sizing: border-box;
  }
  
  .figure-row figure figcaption p {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }
  
  /* Scrolling container improvements */
  .scrolling-container {
    display: block;
    overflow: visible;
  }
  
  .scrolling-container figure {
    width: 100%;
    margin-bottom: 20px;
  }
  
  .scrolling-container figure img {
    width: 100%;
    height: auto;
    border-radius: 8px;
  }
  
  /* Footer improvements */
  footer {
    margin-top: 40px;
    padding: 20px 15px;
  }
  
  .footer-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  
  .footer-grid-L,
  .footer-grid-R {
    width: 100%;
    text-align: center;
  }
  
  .footer-text {
    font-size: 14px;
    line-height: 1.4;
  }
  
  .footer-text .direction {
    display: block;
    margin-bottom: 5px;
  }
  
  .footer-text .material-icons {
    font-size: 20px;
  }
  
  /* Remove vertical line from footer on mobile */
  .footer-L,
  .footer-R {
    display: none !important;
  }
}

/* Additional mobile-specific improvements for smaller screens */
@media screen and (max-width: 480px) {
  /* Further reduce font sizes for very small screens */
  .chapter-title {
    font-size: 24px;
  }
  
  .icon-header h1 {
    font-size: 20px;
  }
  
  .module-body p {
    font-size: 15px;
  }
  
  .big-letter span {
    font-size: 40px;
  }
  
  /* Improve spacing for small screens */
  #grid-cont {
    padding: 0 10px;
  }
  
  .article {
    margin-bottom: 30px;
  }
  
  .chapter-toc {
    padding: 12px;
  }
  
  .wrap-image {
    height: 150px;
  }
  
  /* Improve header for very small screens */
  .header-wrapper .header-title {
    font-size: 16px;
  }
  
  .header-title .section-title {
    font-size: 18px;
  }
  
  .header-title .chapter-title {
    font-size: 14px;
  }
}

/* Landscape orientation improvements */
@media screen and (max-width: 768px) and (orientation: landscape) {
  .wrap-image {
    height: 120px;
  }
  
  .chapter-title {
    font-size: 24px;
    margin-bottom: 15px;
  }
  
  .article {
    margin-bottom: 25px;
  }
}

/* Touch target improvements */
@media screen and (max-width: 768px) {
  /* Ensure all clickable elements have adequate touch targets */
  .hamburger-button {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .chapter-toc a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 12px;
  }
  
  #side-nav nav dl dd a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 12px 0;
  }
  
  .footer-text {
    min-height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
}

/* Improved readability and accessibility */
@media screen and (max-width: 768px) {
  /* Better contrast and readability - but don't override theme colors */
  .module-body p {
    /* Don't override color - preserve the original theme colors */
    text-align: left;
  }
  
  .chapter-toc a {
    color: #0066cc;
    transition: background-color 0.3s ease;
  }
  
  .chapter-toc a:hover,
  .chapter-toc a:focus {
    background-color: #e6f3ff;
  }
  
  /* Ensure proper spacing between elements */
  .icon-header {
    margin-bottom: 25px;
  }
  
  .module-body--lg > div + div {
    margin-top: 20px;
  }
  
  /* Make sure images don't exceed container */
  img {
    max-width: 100%;
    height: auto;
  }
  
/* Video and media elements */
video {
  width: 100% !important;
  height: auto !important;
  max-width: 100% !important;
  display: block !important;
}

iframe {
  max-width: 100%;
  height: auto;
  width: auto;
}
  
  /* Additional content layout improvements - Override magazine flexbox */
  .chapter .article-list .article .module-body--wrap-text .magazine-layout {
    display: block !important;
    width: 100% !important;
    clear: both;
    flex-direction: column !important;
  }
  
  .chapter .article-list .article .module-body--wrap-text .magazine-layout div {
    width: 100% !important;
    margin-bottom: 15px;
    float: none !important;
    display: block !important;
    flex: none !important;
  }
  
  .chapter .article-list .article .module-body--wrap-text .magazine-layout div + div {
    margin-top: 15px;
    flex: none !important;
  }
  
  /* Fix any floating elements that might cause narrow columns */
  .module-body--lg .wrap-image {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 20px 0 !important;
  }
  
  /* Ensure paragraphs take full width */
  .chapter .article-list .article .module-body--lg p,
  .chapter .article-list .article .module-body--wrap-text p {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  /* Override the specific paragraph margin rule */
  .chapter .article-list .article .module-body--lg p {
    margin-right: 0 !important;
  }
  
  /* Improve section spacing */
  .moduleA1,
  .moduleB1,
  .moduleC1,
  .moduleD1,
  .moduleE1,
  .moduleF1,
  .moduleG1 {
    margin-bottom: 30px;
  }
  
  /* Better quote styling */
  quote {
    font-style: italic;
    color: #555;
  }
  
  /* Improve strong/bold text readability - but preserve existing colors */
  strong,
  b {
    font-weight: 600;
    /* Don't override color - let the original theme handle it */
  }
  
  /* Better link styling */
  a {
    color: #0066cc;
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 102, 204, 0.3);
    transition: all 0.3s ease;
  }
  
  a:hover,
  a:focus {
    color: #0056b3;
    border-bottom-color: #0056b3;
  }
  
  /* Remove blue border from footer links to prevent overlap */
  .footer-text,
  .footer-text:hover,
  .footer-text:focus {
    border-bottom: none;
  }
  
  /* Make footer buttons display inline and show text labels */
  footer .footer-grid {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
  }
  
  /* Position footer buttons properly */
  footer .footer-grid .footer-grid-L {
    position: relative !important;
    left: auto !important;
    width: 50% !important;
    text-align: left !important;
  }
  
  footer .footer-grid .footer-grid-R {
    position: relative !important;
    right: auto !important;
    width: 50% !important;
    text-align: right !important;
  }
  
  /* Override Google CSS that hides footer text labels on mobile - force them to show with high specificity */
  @media screen and (max-width: 760px) {
    footer .footer-grid .footer-grid-L .footer-text span,
    footer .footer-grid .footer-grid-L .footer-text div,
    footer .footer-grid .footer-grid-R .footer-text span,
    footer .footer-grid .footer-grid-R .footer-text div {
      display: inline-block !important;
      font-size: 11px !important;
      line-height: 1.2 !important;
      margin-left: 4px !important;
      visibility: visible !important;
      opacity: 1 !important;
    }
    
    /* Force direction labels to show */
    footer .footer-grid .footer-grid-L .footer-text span.direction,
    footer .footer-grid .footer-grid-R .footer-text span.direction {
      display: block !important;
      font-size: 9px !important;
      opacity: 0.8 !important;
      margin-bottom: 1px !important;
      margin-left: 0 !important;
      visibility: visible !important;
    }
    
    /* Force page name divs to show */
    footer .footer-grid .footer-grid-L .footer-text div,
    footer .footer-grid .footer-grid-R .footer-text div {
      display: block !important;
      font-size: 11px !important;
      font-weight: 500 !important;
      margin-left: 0 !important;
      visibility: visible !important;
    }
  }
  
  /* Make sure arrows are visible and properly positioned */
  footer .footer-grid .footer-grid-L .footer-text .arrow-L,
  footer .footer-grid .footer-grid-R .footer-text .arrow-R {
    display: inline-block !important;
    margin-right: 12px !important;
    float: none !important;
    font-size: 18px !important;
  }
  
  /* Add specific padding for right arrow (goes before text) */
  footer .footer-grid .footer-grid-R .footer-text .arrow-R {
    margin-right: 12px !important;
    margin-left: 0 !important;
  }
  
  /* Add specific padding for left arrow (goes after text) */
  footer .footer-grid .footer-grid-L .footer-text .arrow-L {
    margin-left: 12px !important;
    margin-right: 0 !important;
  }
  
  /* Improve list styling if any */
  ul,
  ol {
    padding-left: 20px;
    margin-bottom: 16px;
  }
  
  li {
    margin-bottom: 8px;
    line-height: 1.6;
  }
  
  /* Better blockquote styling */
  blockquote {
    border-left: 4px solid #0066cc;
    padding-left: 16px;
    margin: 20px 0;
    font-style: italic;
    color: #555;
  }
  
  /* Mobile-specific focus styles */
  .hamburger-button:focus,
  .chapter-toc a:focus,
  #side-nav a:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
  }
  
  /* Improve text selection */
  ::selection {
    background-color: rgba(0, 102, 204, 0.2);
    color: #000;
  }
  
  ::-moz-selection {
    background-color: rgba(0, 102, 204, 0.2);
    color: #000;
  }
  
  /* Final touch target improvements */
  .icon-header img {
    cursor: default;
    touch-action: manipulation;
  }
  
  /* Improve button and link spacing */
  .hamburger-button,
  .chapter-toc a,
  #side-nav a,
  .footer-text {
    margin: 2px;
    touch-action: manipulation;
  }
  
  /* Prevent text selection on interactive elements */
  .hamburger-button,
  .icon-header img {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
  }
  
  /* Improve tap highlighting */
  .hamburger-button,
  .chapter-toc a,
  #side-nav a,
  .footer-text {
    -webkit-tap-highlight-color: rgba(0, 102, 204, 0.2);
  }
  
  /* Prevent zoom on double tap for specific elements */
  .hamburger-button,
  .chapter-toc a,
  #side-nav a {
    touch-action: manipulation;
  }
  
  /* Improve form elements if any */
  input,
  textarea,
  button,
  select {
    min-height: 44px;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  /* Improve horizontal scrolling areas */
  .scrolling-container {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
} 

/* Better responsive image handling - prevents blurriness */
img {
  max-width: 100%;
  height: auto;
  /* Preserve image quality */
  image-rendering: auto;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  /* Ensure sharp rendering on high-DPI displays */
  -ms-interpolation-mode: bicubic;
  /* Prevent blurry scaling */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* Optimize for mobile */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* Specific image fixes without aggressive scaling */
.figure-row figure img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  /* Remove aggressive width forcing */
  width: auto;
  /* Preserve aspect ratio */
  object-fit: contain;
  /* Prevent blur on scaling */
  image-rendering: auto;
}

/* Media images - preserve quality */
.media img {
  max-width: 100%;
  height: auto;
  /* Remove aggressive scaling */
  width: auto;
  /* Preserve aspect ratio and quality */
  object-fit: contain;
  box-sizing: border-box;
  /* Prevent blurry rendering */
  image-rendering: auto;
}

/* Scrolling container images */
.scrolling-container figure img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  /* Remove aggressive width forcing */
  width: auto;
  /* Preserve aspect ratio */
  object-fit: contain;
}

/* Video and media elements */
iframe,
video {
  max-width: 100%;
  height: auto;
  /* Remove aggressive scaling */
  width: auto;
}

/* Allow YouTube iframes in media containers to use specified dimensions */
.media iframe {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
} 

/* Force footer text labels to always be visible - comprehensive override */
footer .footer-grid .footer-grid-L .footer-text span,
footer .footer-grid .footer-grid-L .footer-text div,
footer .footer-grid .footer-grid-R .footer-text span,
footer .footer-grid .footer-grid-R .footer-text div {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  font-size: 12px !important;
  line-height: 1.3 !important;
}

/* Ensure direction labels are visible */
footer .footer-grid .footer-grid-L .footer-text span.direction,
footer .footer-grid .footer-grid-R .footer-text span.direction {
  display: block !important;
  font-size: 10px !important;
  opacity: 0.7 !important;
  margin-bottom: 6px !important;
  margin-top: 4px !important;
  visibility: visible !important;
}

/* Ensure page name divs are visible */
footer .footer-grid .footer-grid-L .footer-text div,
footer .footer-grid .footer-grid-R .footer-text div {
  display: block !important;
  font-size: 12px !important;
  margin-top: 8px !important;
  font-weight: 500 !important;
  visibility: visible !important;
} 

/* Ensure footer has adequate height and positioning */
footer {
  min-height: 60px !important;
  padding: 8px 16px !important;
  box-sizing: border-box !important;
  position: relative !important;
  z-index: 1 !important;
  margin-bottom: 0 !important;
  bottom: 0 !important;
  overflow: visible !important;
}

/* Ensure footer text has proper vertical alignment */
footer .footer-grid .footer-grid-L .footer-text,
footer .footer-grid .footer-grid-R .footer-text {
  padding: 4px 0 !important;
  line-height: 1.2 !important;
  vertical-align: top !important;
  height: auto !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
}

footer .footer-grid .footer-grid-R .footer-text {
  align-items: flex-end !important;
} 

/* Ensure page body provides space for footer */
body {
  padding-bottom: 20px !important;
}

/* Ensure main content doesn't overlap footer */
#grid-cont {
  margin-bottom: 10px !important;
  padding-bottom: 10px !important;
}

/* Make footer grid more compact and ensure it fits in viewport */
footer .footer-grid {
  max-width: 100% !important;
  padding: 0 8px !important;
  box-sizing: border-box !important;
  height: auto !important;
  min-height: 40px !important;
} 

/* Mobile-specific footer viewport fixes */
@media screen and (max-width: 768px) {
  footer {
    position: relative !important;
    bottom: auto !important;
    margin-top: 10px !important;
    margin-bottom: 10px !important;
    min-height: 50px !important;
  }
  
  body {
    padding-bottom: 10px !important;
  }
  
  /* Compact footer text on mobile */
  footer .footer-grid .footer-grid-L .footer-text span,
  footer .footer-grid .footer-grid-L .footer-text div,
  footer .footer-grid .footer-grid-R .footer-text span,
  footer .footer-grid .footer-grid-R .footer-text div {
    font-size: 11px !important;
    line-height: 1.1 !important;
  }
  
  footer .footer-grid .footer-grid-L .footer-text span.direction,
  footer .footer-grid .footer-grid-R .footer-text span.direction {
    font-size: 9px !important;
    margin-bottom: 1px !important;
  }
  
    /* Fix video display in media containers */
  .media video {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    display: block !important;
    border-radius: 8px;
    box-sizing: border-box;
  }
  
  /* Ensure figure containing video takes full width */
  .figure-row figure:has(video) {
    width: 100% !important;
  }
  
  /* Ensure media container for video takes full width */
  .media:has(video) {
    width: 100% !important;
    max-width: 100% !important;
  }
} 