/* ============================================================
   Mobile QA layer
   共通CSSを壊さず、iPhone・小画面・キーボード操作の安定性を補う。
   ============================================================ */

html {
  max-width: 100%;
  overflow-x: hidden;
  scroll-padding-top: 92px;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  max-width: 100%;
  overflow-x: hidden;
  overflow-wrap: anywhere;
}

main,
section,
article,
aside,
header,
footer,
.wrap,
.grid,
.detail-grid,
.product-page-hero-grid,
.hub-hero-grid,
.theme-grid,
.category-priority-grid,
.product-lineup-grid,
.comparison-axis-grid,
.contact-panel-dark {
  min-width: 0;
  max-width: 100%;
}

.grid > *,
.detail-grid > *,
.product-page-hero-grid > *,
.hub-hero-grid > *,
.theme-grid > *,
.category-priority-grid > *,
.product-lineup-grid > *,
.comparison-axis-grid > * {
  min-width: 0;
  max-width: 100%;
}

img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button,
.button,
.nav a,
.footer-links a {
  min-height: 44px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(0, 154, 210, 0.34);
  outline-offset: 3px;
}

.site-header {
  top: env(safe-area-inset-top, 0px);
}

.menu {
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  border-radius: 10px;
}

.specs {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.direct-email,
.form-assistance a,
a[href^="mailto:"] {
  overflow-wrap: anywhere;
}

[id] {
  scroll-margin-top: 96px;
}

@media (max-width: 980px) {
  body.nav-is-open {
    overflow: hidden;
  }

  .nav {
    top: calc(74px + env(safe-area-inset-top, 0px));
    max-height: calc(100dvh - 74px - env(safe-area-inset-top, 0px));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 18px 38px rgba(11, 49, 67, 0.12);
  }

  .nav a {
    display: flex;
    align-items: center;
    padding: 10px 4px;
  }

  .nav .nav-cta {
    justify-content: center;
    padding-inline: 18px;
  }
}

@media (max-width: 640px) {
  html {
    scroll-padding-top: 80px;
  }

  .wrap {
    width: calc(100% - 28px);
    max-width: calc(100vw - 28px);
    margin-inline: auto;
  }

  .header-inner {
    min-height: 68px;
  }

  .brand {
    min-width: 0;
  }

  .brand > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav {
    top: calc(68px + env(safe-area-inset-top, 0px));
    max-height: calc(100dvh - 68px - env(safe-area-inset-top, 0px));
  }

  /* 日本語見出しに keep-all を使うと、iPhoneで一行が画面外へ伸びる。
     モバイルでは自然な禁則処理に戻し、必要に応じて文字単位で折り返す。 */
  .hero h1,
  .page-hero h1,
  .section h2,
  .theme-card h3,
  .priority-category h3 {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: normal;
    line-break: strict;
  }

  .actions,
  .theme-links,
  .product-card-actions {
    max-width: 100%;
  }

  .actions > *,
  .contact-submit,
  .resource-search-button,
  .resource-reset-button,
  .manufacturer-search-button,
  .manufacturer-reset-button {
    width: 100%;
    max-width: 100%;
  }

  .research-product-card,
  .product-card,
  .theme-card,
  .priority-category,
  .selection-note,
  .sidebox {
    min-width: 0;
    max-width: 100%;
  }

  .product-filter,
  .feature-list {
    max-width: 100%;
    overscroll-behavior-inline: contain;
  }

  .specs th,
  .specs td {
    min-width: 120px;
  }

  .footer {
    padding-bottom: calc(44px + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
