/*
 * Smartphone resilience layer
 * Keeps the existing visual design while covering narrow phones, landscape
 * phones, safe areas, long labels and iOS form behaviour.
 */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

@supports (overflow: clip) {
  html,
  body {
    overflow-x: clip;
  }
}

.wrap,
.header-inner,
.hero-copy,
.hero-copy .wrap,
.quote-title,
.quote-fields,
.fb-head,
.fb-body,
.fb-points,
.price-card,
.price-card .p-row,
.price-card .p-info,
.faq-item,
.fbm-actions,
.fbm-call {
  min-width: 0;
}

img,
svg,
input,
select,
button {
  max-width: 100%;
}

/* Keep feature photos compact before and after native lazy-loading. */
.fb-body img {
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

/*
 * On phones the hero is one block: the photo fills it, the mechanic stays
 * clear at the top, and the copy sits below him on a gradient into navy.
 * The height comes from the content, so no min-height here.
 */
@media (max-width: 600px), (max-width: 932px) and (orientation: landscape) {
  .hero::after {
    display: none;
  }

  .hero-media img,
  .hero img {
    object-position: center 34%;
  }

  .hero-copy .wrap {
    padding-top: 16px;
    padding-bottom: 12px;
  }

  .hero-copy h1,
  .hero-copy p {
    max-width: 760px;
  }
}

@media (max-width: 600px) {
  html,
  body {
    width: 100%;
    min-width: 0;
    overscroll-behavior-x: none;
  }

  body {
    position: relative;
  }

  header,
  main,
  section,
  footer,
  .hero,
  .fixed-bottom-menu {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  @supports (overflow: clip) {
    header,
    main,
    section,
    footer,
    .hero,
    .fixed-bottom-menu {
      overflow-x: clip;
    }
  }

  body.has-fixed-bottom {
    padding-bottom: calc(196px + env(safe-area-inset-bottom, 0px));
  }

  .wrap,
  .header-inner {
    width: 100%;
    max-width: 100%;
    gap: 8px;
  }

  .header-inner > .logo {
    width: clamp(108px, 36vw, 150px);
    max-width: 42%;
    height: auto;
    flex: 0 1 auto;
  }

  .header-urgent {
    min-width: 0;
    max-width: 58%;
    flex: 0 1 auto;
  }

  .hero-copy h1,
  .hero-copy p,
  .sec-title,
  .sec-sub,
  .fb-head h3,
  .faq-item .q,
  .faq-item .a {
    overflow-wrap: anywhere;
  }

  /* FVの主役は「最短5分着！」。地域見出しは読める大きさに留める。 */
  .hero-copy h1 {
    font-size: clamp(17px, 4.7vw, 21px);
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .hero-actions a,
  .hero-action-primary,
  .hero-action-secondary {
    width: 100%;
    min-width: 0;
    padding-right: 12px;
    padding-left: 12px;
  }

  .hero-action-primary {
    flex: none;
  }

  .fb-head h3,
  .fb-points,
  .price-card .p-info {
    min-width: 0;
  }

  .feature-block {
    width: 100%;
    max-width: 100%;
    margin-right: 0;
    margin-left: 0;
  }

  .service-list,
  .area-list,
  .steps,
  .price-grid,
  .voices,
  .voices-carousel,
  .faq-list {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .service-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .area-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .service-list > *,
  .area-list > *,
  .step,
  .price-card,
  .voice,
  .faq-item {
    max-width: 100%;
    min-width: 0;
  }

  .voices-carousel {
    overflow: hidden;
  }

  .voices-arrow.prev {
    left: 0;
  }

  .voices-arrow.next {
    right: 0;
  }

  .voices-viewport {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overscroll-behavior-x: contain;
    touch-action: pan-y;
  }

  .voices-track {
    width: 100%;
    max-width: 100%;
  }

  .voices-viewport .voice {
    flex: 0 0 calc(100% - 18px);
    width: calc(100% - 18px);
    max-width: calc(100% - 18px);
    margin-right: 18px;
  }

  .quote-fields select,
  .quote-fields input,
  .field input,
  .field select {
    /* Prevent automatic page zoom when focusing a field in iOS Safari. */
    font-size: 16px;
  }

  .fixed-bottom-menu {
    right: 0;
    left: 0;
  }

  .fbm-badge {
    max-width: calc(100% - 16px);
  }

  .fbm-actions {
    width: 100%;
    max-width: 100%;
  }

  /* 端末下端の安全領域はパネル側で塗る。バー全体に背景を敷くと吹き出しの周りまで色が付く。 */
  .fbm-panel {
    padding-right: max(10px, env(safe-area-inset-right, 0px));
    padding-left: max(10px, env(safe-area-inset-left, 0px));
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .fbm-number {
    font-size: clamp(21px, 7.2vw, 26px);
    gap: 4px;
    letter-spacing: 0;
  }

  .fbm-phone-ic {
    width: 22px;
    height: 22px;
  }

  .fbm-tap-ic {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 420px) {
  header {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .header-urgent {
    padding: 8px 10px;
    gap: 4px;
    font-size: 12px;
  }

  .header-urgent .u-click {
    padding: 2px 6px;
    font-size: 10px;
  }

  .quote-head {
    padding-right: 16px;
    padding-left: 16px;
  }

  .quote-head-inner {
    gap: 10px;
  }

  .quote-badge {
    width: 68px;
    height: 68px;
  }

  .quote-badge span {
    font-size: 11px;
  }

  .quote-badge strong {
    font-size: 19px;
  }

  .quote-eyebrow {
    gap: 6px;
    font-size: 14px;
  }

  .quote-eyebrow .dots {
    min-width: 8px;
  }

  .quote-eyebrow svg {
    width: 24px;
    height: 24px;
  }

  .quote-title h2 {
    font-size: 21px;
  }

  .price-card,
  .price-card .p-row {
    flex-direction: column;
    gap: 10px;
  }

  .price-card .p-price {
    align-self: flex-start;
    text-align: left;
  }

  /* Estimate page */
  .brand {
    min-width: 0;
    font-size: 15px;
    line-height: 1.35;
  }

  .head-note {
    flex: 0 0 auto;
    padding: 4px 7px;
    font-size: 10px;
  }

  .lead {
    padding-right: 16px;
    padding-left: 16px;
  }

  .lead h1 {
    font-size: 22px;
  }

  .card {
    padding: 22px 16px 26px;
  }

  .tel-cta a {
    width: 100%;
    justify-content: center;
    padding-right: 12px;
    padding-left: 12px;
    font-size: clamp(21px, 7vw, 24px);
  }
}

/*
 * Production mobile FV
 * Keep the first screen calm and legible: photo, message, facts, then one CTA.
 */
@media (max-width: 600px) {
  body.has-fixed-bottom {
    padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  }

  header {
    position: relative;
    padding: 8px 0;
  }

  .header-inner {
    min-height: 44px;
    padding-right: 14px;
    padding-left: 14px;
  }

  .header-inner > .logo,
  header .logo {
    width: 126px;
    max-width: 42%;
  }

  .header-urgent {
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 12px;
    box-shadow: none;
  }

  .hero {
    display: block;
    min-height: 0;
    background: #174b91;
  }

  .hero-media {
    position: relative;
    height: clamp(205px, 57vw, 232px);
    -webkit-mask-image: none;
    mask-image: none;
  }

  .hero-media::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 48px;
    background: linear-gradient(to bottom, rgba(23,75,145,0), #174b91);
    pointer-events: none;
  }

  .hero-media img,
  .hero img {
    object-position: center 38%;
  }

  .hero::before,
  .hero::after,
  .hero-scrim {
    display: none;
  }

  .hero-copy {
    margin-top: -24px;
    padding: 0;
    background: transparent;
  }

  .hero-copy .wrap {
    padding: 0 16px 14px;
  }

  .hero-badge {
    margin: 0 0 7px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 10px;
    letter-spacing: 0;
    box-shadow: none;
  }

  .hero-copy h1 {
    margin: 0 0 4px;
    font-size: 20px;
    line-height: 1.35;
    letter-spacing: 0;
    text-shadow: none;
  }

  .hero-copy p {
    font-size: 11px;
    line-height: 1.5;
    text-shadow: none;
  }

  .hero-rush {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 9px;
  }

  .hero-rush .l {
    gap: 4px;
    margin: 0;
    font-size: 11px;
    white-space: nowrap;
    text-shadow: none;
  }

  .hero-rush strong {
    font-size: 31px;
    line-height: 1;
    white-space: nowrap;
    text-shadow: none;
  }

  .hero-solve {
    margin-top: 5px;
    font-size: 13px !important;
  }

  .hero-guar {
    gap: 6px;
    margin-top: 8px;
  }

  .hero-guar li {
    flex: 1 1 0;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    padding: 6px 5px;
    border-radius: 5px;
    box-shadow: none;
  }

  .hero-guar span {
    font-size: 9px;
  }

  .hero-guar em {
    font-size: 12px;
    white-space: nowrap;
  }

  .hero .fvd-band {
    padding: 0 12px 12px;
    background: #174b91;
  }

  /* The persistent phone button already provides the mobile CTA. */
  .fvd {
    display: none;
  }

  .fvd-badges {
    gap: 1px;
    overflow: hidden;
    border-radius: 8px;
    background: #dce5f1;
  }

  .fvd-badges li {
    width: auto;
    height: 54px;
    flex: 1 1 0;
    padding: 7px 2px 5px;
    background: #fff;
  }

  .fvd-badges .v {
    color: #174b91;
    font-size: 17px;
    line-height: 1.15;
  }

  .fvd-badges .v small {
    font-size: 9px;
  }

  .fvd-badges .t {
    color: #52657c;
    font-size: 9px;
  }

  .fixed-bottom-menu {
    filter: none;
    text-align: left;
  }

  .fixed-bottom-menu .fbm-badge,
  .fbm-note,
  .fbm-diag,
  .fbm-sub {
    display: none;
  }

  .fbm-panel {
    margin: 0;
    padding: 8px max(10px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
    background: rgba(16, 58, 118, .98);
    box-shadow: 0 -2px 10px rgba(12, 36, 72, .18);
  }

  .fbm-actions {
    max-width: 480px;
  }

  .fbm-call {
    min-height: 68px;
    padding: 6px 10px;
    border-radius: 8px;
  }

  .fbm-call-label {
    font-size: 11px;
    line-height: 1.2;
  }

  .fbm-number {
    gap: 4px;
    font-size: clamp(23px, 7.2vw, 28px);
  }

  .fbm-phone-ic {
    width: 20px;
    height: 20px;
  }

  .fbm-tap-ic {
    display: none;
  }
}

@media (max-width: 360px) {
  .header-inner > .logo {
    width: 108px;
  }

  .header-urgent .u-click {
    display: none;
  }

  .hero-problem {
    white-space: normal;
  }

  .area-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .service-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fbm-panel {
    padding-right: 8px;
    padding-left: 8px;
  }

  .fbm-call {
    padding-right: 6px;
    padding-left: 6px;
  }

  .fbm-call-label {
    font-size: 12px;
  }

  /* 320px 幅でも1行に収める。折り返すとバーが高くなり本文の下余白と合わなくなる。 */
  .fbm-sub {
    font-size: 10px;
  }
}

/* Keep the fixed call bar useful without consuming most of a landscape phone. */
@media (max-width: 932px) and (max-height: 500px) and (orientation: landscape) {
  body.has-fixed-bottom {
    padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  }

  .fbm-badge,
  .fbm-note,
  .fbm-sub,
  .fbm-diag {
    display: none;
  }

  .fbm-panel {
    margin-top: 0;
    padding-top: 6px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  }

  .fbm-call {
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .fbm-call-label {
    font-size: 11px;
  }

  .fbm-number {
    font-size: 22px;
  }
}
