/*
 * Shared mobile refinements.
 * Every rule is scoped by the body class added by this plugin so theme pages
 * outside 100kinlab content are not changed.
 */
@media (max-width: 720px) {
  body.hrp-mobile-ui {
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
  }

  body.hrp-mobile-ui :where(
    .srp-page,
    .single-reviewtotal-page,
    .arc-page,
    .rs-page,
    .reg-page,
    .product-summary-main,
    .hrp-compare,
    .goditems-single-wrap,
    .hrv-wrap,
    .hrp-contact-form-wrap
  ),
  body.hrp-mobile-ui :where(
    .srp-page,
    .single-reviewtotal-page,
    .arc-page,
    .rs-page,
    .reg-page,
    .product-summary-main,
    .hrp-compare,
    .goditems-single-wrap,
    .hrv-wrap,
    .hrp-contact-form-wrap
  ) *,
  body.hrp-mobile-ui .entry-content,
  body.hrp-mobile-ui .entry-content * {
    box-sizing: border-box;
  }

  body.hrp-mobile-ui :where(
    .srp-page,
    .single-reviewtotal-page,
    .arc-page,
    .rs-page,
    .reg-page,
    .product-summary-main,
    .hrp-compare,
    .goditems-single-wrap,
    .hrv-wrap,
    .hrp-contact-form-wrap
  ) {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  /* Standard editorial articles: readable line length without oversized gaps. */
  body.hrp-mobile-ui.single-post .entry-content {
    max-width: 100%;
    font-size: 16px;
    line-height: 1.85;
    overflow-wrap: anywhere;
  }

  body.hrp-mobile-ui.single-post .entry-content :where(p, ul, ol) {
    margin-block: .85em;
  }

  body.hrp-mobile-ui.single-post .entry-content :where(h2, h3, h4) {
    scroll-margin-top: 64px;
    text-wrap: pretty;
  }

  body.hrp-mobile-ui.single-post .entry-content h2 {
    margin-block: 1.65em .75em;
    font-size: clamp(1.25rem, 5.8vw, 1.55rem);
    line-height: 1.45;
  }

  body.hrp-mobile-ui.single-post .entry-content h3 {
    margin-block: 1.35em .55em;
    font-size: clamp(1.08rem, 4.8vw, 1.28rem);
    line-height: 1.5;
  }

  body.hrp-mobile-ui.single-post .entry-content :where(img, video, iframe) {
    max-width: 100%;
    height: auto;
  }

  body.hrp-mobile-ui.single-post .entry-content :where(figure, .wp-block-image) {
    max-width: 100%;
    margin-inline: 0;
  }

  body.hrp-mobile-ui.single-post .entry-content :where(table) {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    font-size: .86rem;
    white-space: nowrap;
  }

  body.hrp-mobile-ui.single-post .entry-content :where(blockquote, .wp-block-quote) {
    margin-inline: 0;
    padding: .75rem .85rem;
  }

  body.hrp-mobile-ui.single-post .entry-content .wp-block-columns {
    gap: .75rem;
  }

  body.hrp-mobile-ui.single-post .entry-content :where(.wp-block-button, .wp-block-button__link) {
    max-width: 100%;
  }

  body.hrp-mobile-ui.single-post .entry-content .wp-block-button__link {
    min-height: 44px;
    padding: .65rem 1rem;
    line-height: 1.35;
  }

  /* Review detail: keep the article dense and prevent a second bulky sidebar flow. */
  body.hrp-mobile-ui .srp-page {
    padding-inline: .625rem !important;
  }

  body.hrp-mobile-ui .srp-layout,
  body.hrp-mobile-ui .srp-content {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
  }

  /*
   * The legacy review card kept 30px of inner padding on phones. Together
   * with the theme and page gutters it reduced the readable line length too
   * far. Let the article body reach the page edge and retain one small,
   * consistent reading gutter instead of nesting another framed card.
   */
  body.hrp-mobile-ui .review-body-section {
    width: auto !important;
    margin-inline: -.625rem !important;
    padding: 1rem .875rem 1.15rem !important;
    border-inline: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  body.hrp-mobile-ui .review-body-section::after {
    display: none !important;
  }

  body.hrp-mobile-ui .review-body-shell,
  body.hrp-mobile-ui .review-content,
  body.hrp-mobile-ui .review-content-card {
    width: 100% !important;
    max-width: none !important;
  }

  body.hrp-mobile-ui .review-body-section .review-content {
    font-size: 1rem !important;
    line-height: 1.82 !important;
    letter-spacing: 0 !important;
    overflow-wrap: anywhere;
  }

  body.hrp-mobile-ui .review-body-section .review-content p {
    margin-bottom: 1.15em !important;
    font-size: 1rem !important;
    line-height: 1.82 !important;
    letter-spacing: 0 !important;
  }

  body.hrp-mobile-ui .review-body-section .review-content h3 {
    padding: .55rem .7rem .55rem .8rem !important;
    border-left-width: 3px !important;
    font-size: 1.05rem !important;
    line-height: 1.5 !important;
  }

  body.hrp-mobile-ui .srp-sidebar {
    gap: .75rem !important;
  }

  body.hrp-mobile-ui .srp-context-bar {
    overflow-x: auto;
    flex-wrap: nowrap !important;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }

  body.hrp-mobile-ui .srp-context-bar::-webkit-scrollbar {
    display: none;
  }

  body.hrp-mobile-ui .srp-context-item {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  /* Product/review summary: compact vertical cards, horizontal rails where useful. */
  body.hrp-mobile-ui .single-reviewtotal-page {
    padding-inline: .625rem !important;
  }

  body.hrp-mobile-ui .rt-hero,
  body.hrp-mobile-ui .rt-section,
  body.hrp-mobile-ui .rt-summary,
  body.hrp-mobile-ui .rt-store-block {
    margin-block: .65rem !important;
    padding: .75rem !important;
    border-radius: 14px !important;
  }

  body.hrp-mobile-ui .rt-hero h1 {
    margin-block: .5rem !important;
    font-size: clamp(1.25rem, 6vw, 1.45rem) !important;
  }

  body.hrp-mobile-ui .rt-hero-card {
    padding: .7rem !important;
    border-radius: 14px !important;
  }

  body.hrp-mobile-ui .rt-mobile-toc {
    margin-block: .65rem !important;
    border-radius: 12px !important;
  }

  body.hrp-mobile-ui .rt-mobile-toc summary {
    min-height: 44px;
    padding-block: .65rem !important;
  }

  body.hrp-mobile-ui .rt-review-scroll {
    gap: .65rem !important;
  }

  body.hrp-mobile-ui .rt-rank-card {
    min-width: min(78vw, 280px) !important;
    border-radius: 14px !important;
  }

  /* Review archive: fewer stacked controls and denser cards. */
  body.hrp-mobile-ui .arc-page {
    padding-inline: .625rem !important;
  }

  body.hrp-mobile-ui .arc-hero {
    padding: 1.05rem .75rem .9rem !important;
    border-radius: 0 0 16px 16px !important;
  }

  body.hrp-mobile-ui .arc-hero h1 {
    font-size: clamp(1.3rem, 6vw, 1.55rem) !important;
  }

  body.hrp-mobile-ui .arc-hero__sub {
    margin-top: .25rem !important;
    font-size: .78rem !important;
  }

  body.hrp-mobile-ui .arc-stats {
    margin-top: .55rem !important;
    gap: .3rem !important;
  }

  body.hrp-mobile-ui .arc-toolbar {
    margin-inline: -.625rem;
    padding-inline: .625rem !important;
  }

  body.hrp-mobile-ui .arc-grid {
    gap: .55rem !important;
  }

  body.hrp-mobile-ui .arc-card {
    border-radius: 12px !important;
  }

  body.hrp-mobile-ui .arc-body {
    gap: .2rem !important;
    padding: .55rem .58rem !important;
  }

  body.hrp-mobile-ui .arc-controls {
    position: relative;
    z-index: 1;
  }

  body.hrp-mobile-ui .arc-search-clear {
    width: 40px !important;
    height: 40px !important;
  }

  /* Submit/register/account screens: form rhythm without shrinking tap targets. */
  body.hrp-mobile-ui .rs-page {
    line-height: 1.45 !important;
  }

  body.hrp-mobile-ui .rs-mobile-compose-header {
    height: 50px !important;
  }

  body.hrp-mobile-ui #rs-step-1 {
    padding-inline: .875rem !important;
  }

  body.hrp-mobile-ui .rs-rating {
    padding-block: .7rem !important;
  }

  body.hrp-mobile-ui .rs-mobile-quick-review,
  body.hrp-mobile-ui .rs-cardfield,
  body.hrp-mobile-ui .rs-mobile-section-head {
    padding-block: .65rem !important;
  }

  body.hrp-mobile-ui #rs-quick-review {
    min-height: 104px !important;
  }

  body.hrp-mobile-ui .rs-photo-wrap {
    gap: .55rem !important;
    padding-bottom: .75rem !important;
  }

  body.hrp-mobile-ui .rs-photo-wrap__main,
  body.hrp-mobile-ui .rs-photo-main,
  body.hrp-mobile-ui .rs-photo-main__inner {
    width: 120px !important;
    height: 120px !important;
    flex-basis: 120px !important;
  }

  body.hrp-mobile-ui .rs-photo-sub,
  body.hrp-mobile-ui .rs-photo-sub__inner {
    width: 76px !important;
    height: 104px !important;
    flex-basis: 76px !important;
  }

  body.hrp-mobile-ui .rs-photo-main__actions,
  body.hrp-mobile-ui .rs-photo-sub__actions {
    grid-template-columns: repeat(2, 32px) !important;
    gap: 4px !important;
  }

  body.hrp-mobile-ui .rs-iconbtn {
    width: 32px !important;
    height: 32px !important;
  }

  body.hrp-mobile-ui .reg-page {
    padding: .75rem .625rem 2.25rem !important;
  }

  body.hrp-mobile-ui .reg-benefits,
  body.hrp-mobile-ui .reg-card {
    padding: .9rem .8rem !important;
    border-radius: 14px !important;
  }

  body.hrp-mobile-ui .reg-benefits__list {
    gap: .35rem !important;
  }

  body.hrp-mobile-ui .reg-group {
    margin-bottom: .9rem !important;
  }

  body.hrp-mobile-ui .reg-password-toggle {
    min-height: 44px !important;
  }

  /* Product index and compare screen. */
  body.hrp-mobile-ui main.product-summary-main,
  body.hrp-mobile-ui .hrp-compare {
    margin-top: .75rem !important;
    padding-inline: .625rem !important;
  }

  body.hrp-mobile-ui .ps-index-hero,
  body.hrp-mobile-ui .product-hero {
    margin-bottom: .75rem !important;
    padding: .8rem .7rem !important;
    border-radius: 14px !important;
  }

  body.hrp-mobile-ui .ps-index-stats {
    gap: .4rem !important;
    margin-top: .55rem !important;
  }

  body.hrp-mobile-ui .ps-index-stat {
    padding: .4rem .65rem !important;
  }

  body.hrp-mobile-ui .ps-toolbar {
    gap: .45rem !important;
  }

  body.hrp-mobile-ui .product-list-grid {
    gap: .55rem !important;
  }

  body.hrp-mobile-ui .ps-card {
    border-radius: 12px !important;
  }

  body.hrp-mobile-ui .ps-card-body {
    gap: .35rem !important;
    padding: .6rem .65rem .7rem !important;
  }

  body.hrp-mobile-ui .hrp-compare {
    padding-bottom: 2.5rem !important;
  }

  body.hrp-mobile-ui .hrp-compare__header {
    margin-bottom: .85rem !important;
  }

  body.hrp-mobile-ui .hrp-compare__header h1 {
    margin-bottom: .3rem !important;
    font-size: 1.45rem !important;
  }

  body.hrp-mobile-ui .hrp-compare-actions {
    margin-top: .65rem !important;
  }

  body.hrp-mobile-ui .hrp-compare-grid {
    gap: .6rem !important;
    padding-bottom: .5rem !important;
  }

  body.hrp-mobile-ui .hrp-compare-card {
    min-width: min(78vw, 290px) !important;
    border-radius: 14px !important;
  }

  body.hrp-mobile-ui .hrp-compare-body {
    padding: .75rem !important;
  }

  body.hrp-mobile-ui .hrp-compare-body h2 {
    min-height: 0 !important;
    margin-bottom: .6rem !important;
    font-size: 1rem !important;
  }

  body.hrp-mobile-ui .hrp-compare-dl div {
    min-height: 42px !important;
    padding-block: .4rem !important;
  }

  /* Feature and account-list templates. */
  body.hrp-mobile-ui .goditems-single-wrap {
    margin-top: .65rem !important;
    padding-inline: .625rem !important;
  }

  body.hrp-mobile-ui .goditems-breadcrumb,
  body.hrp-mobile-ui .goditems-updated {
    margin-bottom: .75rem !important;
  }

  body.hrp-mobile-ui .goditems-lead {
    margin-bottom: 1rem !important;
    padding: .65rem .7rem !important;
    line-height: 1.65 !important;
  }

  body.hrp-mobile-ui .goditems-single-content .god-items-list {
    gap: .7rem !important;
  }

  body.hrp-mobile-ui .hrv-wrap {
    padding-inline: .625rem !important;
  }

  body.hrp-mobile-ui .hrv-card-grid {
    gap: .75rem !important;
  }

  body.hrp-mobile-ui .hrv-confirm-dialog {
    max-height: calc(100dvh - 2rem);
    overflow: auto;
  }

  body.hrp-mobile-ui .hrp-contact-form {
    margin-top: .75rem !important;
    padding: .9rem .75rem !important;
    border-radius: 14px !important;
  }

  /* Universal mobile safety for plugin-owned controls. */
  body.hrp-mobile-ui :where(
    .srp-page,
    .single-reviewtotal-page,
    .arc-page,
    .rs-page,
    .reg-page,
    .product-summary-main,
    .hrp-compare,
    .goditems-single-wrap,
    .hrv-wrap,
    .hrp-contact-form-wrap
  ) :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    max-width: 100%;
    font-size: 16px;
  }

  body.hrp-mobile-ui :where(
    .srp-page,
    .single-reviewtotal-page,
    .arc-page,
    .rs-page,
    .reg-page,
    .product-summary-main,
    .hrp-compare,
    .goditems-single-wrap,
    .hrv-wrap,
    .hrp-contact-form-wrap
  ) :where(button, [role="button"], input[type="submit"], input[type="button"]) {
    touch-action: manipulation;
  }
}

@media (max-width: 374px) {
  body.hrp-mobile-ui .product-list-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  body.hrp-mobile-ui .ps-card-title {
    font-size: .9rem !important;
  }

  body.hrp-mobile-ui .rs-photo-wrap__main,
  body.hrp-mobile-ui .rs-photo-main,
  body.hrp-mobile-ui .rs-photo-main__inner {
    width: 108px !important;
    height: 108px !important;
    flex-basis: 108px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.hrp-mobile-ui *,
  body.hrp-mobile-ui *::before,
  body.hrp-mobile-ui *::after {
    scroll-behavior: auto !important;
  }
}
