/*
 * Mobile interaction and reading guardrails.
 * Loaded after the structural and legacy override styles.
 */

@media (max-width: 768px) {
  html {
    overflow-x: hidden;
  }

  html:root body,
  html:root body * {
    box-sizing: border-box;
  }

  html:root body img,
  html:root body video,
  html:root body iframe,
  html:root body svg {
    max-width: 100%;
  }

  html:root body img,
  html:root body video {
    height: auto;
  }

  html:root body .scrollable-table,
  html:root body .wp-block-table,
  html:root body table {
    max-width: 100%;
  }

  html:root body .scrollable-table,
  html:root body .wp-block-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  html:root body input,
  html:root body select,
  html:root body textarea,
  html:root body button {
    max-width: 100%;
  }

  html:root body .nlr-page,
  html:root body .entry-content,
  html:root body .article-body,
  html:root body .entry-card-content,
  html:root body .widget {
    overflow-wrap: anywhere;
  }

  .nlr-sticky-cta {
    bottom: 0;
    left: 0;
    padding:
      8px
      max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
    position: fixed;
    right: 0;
    transform: translate3d(0, calc(100% + env(safe-area-inset-bottom)), 0);
    transition: opacity .2s ease, transform .2s ease;
    width: 100%;
    will-change: opacity, transform;
    z-index: 10000;
  }

  .nlr-sticky-cta.is-visible {
    transform: translate3d(0, 0, 0);
  }

  body.nlr-has-mobile-footer-menu .nlr-sticky-cta {
    bottom: 50px;
  }

  .nlr-sticky-cta a {
    min-height: 56px;
    touch-action: manipulation;
  }

  html:root body .btn,
  html:root body .nlr-page .btn,
  html:root body .nlr-home-intro-actions a,
  html:root body .nlr-actions a,
  html:root body .nlr-compact-item a,
  html:root body .nlr-review-search input[type="search"],
  html:root body .nlr-review-search button,
  html:root body .wp-block-search .wp-block-search__input,
  html:root body .wp-block-search .wp-block-search__button,
  html:root body .search-form input[type="search"],
  html:root body .search-form input[type="text"],
  html:root body .search-form button,
  html:root body .search-submit {
    min-height: 48px !important;
  }

  html:root body.home .nlr-page .nlr-review-search input[type="search"],
  html:root body.home .nlr-page .nlr-review-search button {
    min-height: 48px !important;
  }

  html:root body .nlr-conversion-strip,
  html:root body .nlr-premium-cta,
  html:root body .nlr-home-utility {
    align-items: stretch !important;
    flex-direction: column !important;
  }

  html:root body .nlr-conversion-strip .nlr-actions,
  html:root body .nlr-premium-cta .nlr-actions,
  html:root body .nlr-home-utility .nlr-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100%;
  }

  html:root body .nlr-conversion-strip .nlr-actions a,
  html:root body .nlr-premium-cta .nlr-actions a,
  html:root body .nlr-home-utility .nlr-actions a {
    justify-content: center;
    margin: 0 !important;
    text-align: center;
    width: 100%;
  }

  html:root body #content-in,
  html:root body .content-in,
  html:root body .main,
  html:root body .sidebar {
    max-width: 100%;
  }

  .nlr-compact-item a,
  .btn,
  .nlr-page .btn,
  .nlr-review-search button,
  .wp-block-search .wp-block-search__button,
  .search-form button,
  .search-submit {
    touch-action: manipulation;
  }

  html:root body .nlr-page,
  html:root body.single-post .entry-content,
  html:root body.single-post .article-body {
    padding-left: max(16px, env(safe-area-inset-left)) !important;
    padding-right: max(16px, env(safe-area-inset-right)) !important;
  }

  html:root body.home .nlr-page {
    padding-left: max(16px, env(safe-area-inset-left)) !important;
    padding-right: max(16px, env(safe-area-inset-right)) !important;
  }

  html:root body .toc,
  html:root body .toc-wrap {
    box-sizing: border-box !important;
    display: block !important;
    margin-left: -8px !important;
    margin-right: -8px !important;
    max-width: 100% !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  html:root body .toc-content,
  html:root body .toc-list {
    box-sizing: border-box !important;
    display: block !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  html:root body .toc-title {
    display: block !important;
    width: 100% !important;
  }

  html:root body .toc {
    padding-left: 16px !important;
    padding-right: 16px !important;
    width: calc(100% + 16px) !important;
  }

  html:root body.nlr-has-mobile-footer-menu #container,
  html:root body.nlr-has-mobile-footer-menu #content,
  html:root body.nlr-has-mobile-footer-menu .container {
    padding-bottom: calc(64px + env(safe-area-inset-bottom)) !important;
  }

  .nlr-review-article,
  .single-post .entry-content {
    font-size: 1rem;
    line-height: 1.8;
  }

  .nlr-review-article p,
  .single-post .entry-content > p {
    line-height: 1.8;
    margin-bottom: 1.25em !important;
  }

  .nlr-site-footer {
    margin-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  body.nlr-has-mobile-footer-menu .nlr-site-footer {
    margin-bottom: calc(138px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 430px) {
  html:root body .nlr-page,
  html:root body.single-post .entry-content,
  html:root body.single-post .article-body {
    padding-left: max(16px, env(safe-area-inset-left)) !important;
    padding-right: max(16px, env(safe-area-inset-right)) !important;
  }

  html:root body.home .nlr-page .nlr-compact-item a {
    grid-template-columns: 40px minmax(0, 1fr) !important;
  }

  html:root body.home .nlr-page .nlr-compact-rank {
    grid-column: 1;
  }

  html:root body.home .nlr-page .nlr-compact-thumb {
    grid-column: 2;
  }

  html:root body.home .nlr-page .nlr-compact-body {
    grid-column: 1 / -1;
  }

  html:root body .nlr-submission-hero,
  html:root body .nlr-submission-reward,
  html:root body .nlr-review-submission-form,
  html:root body .nlr-contact-form-wrap {
    border-radius: 8px;
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
}

@media (max-width: 768px) {
  html:root body.page .sns-share-buttons,
  html:root body.page .sns-buttons {
    box-sizing: border-box !important;
    display: grid !important;
    gap: 4px !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  html:root body.page .sns-share-buttons a,
  html:root body.page .sns-buttons a {
    margin: 0 !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  html:root body .nlr-plans-page,
  html:root body .nlr-plans-page .nlr-subscription-signup,
  html:root body .nlr-plans-page .nlr-subscription-signup__body,
  html:root body .nlr-plans-page .nlr-subscription-signup__panel {
    box-sizing: border-box !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  html:root body .nlr-plans-page .nlr-subscription-signup {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  html:root body .nlr-plans-page .nlr-subscription-signup__button {
    overflow-wrap: anywhere !important;
    white-space: normal !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nlr-sticky-cta {
    transition: none;
  }
}
