/* Balanced Japanese typography and responsive layout corrections. */
:where(h1, h2, h3, h4),
.card h2,
.guide-card h2,
.contact-box h2 {
  text-wrap: balance;
  line-break: strict;
}

:where(p, li, summary) {
  text-wrap: pretty;
  line-break: strict;
}

html[lang="ja"] :where(h1, h2, h3, h4) {
  word-break: normal;
  overflow-wrap: normal;
}

/* Appraisal service hero: keep 「真贋鑑定」 together on desktop. */
body[data-someido-route="services"] #root > div > section:first-of-type > div > p:last-child {
  max-width: 52rem !important;
  margin-inline: auto;
  text-wrap: balance;
}

body[data-someido-route="services"] #root > div > section:nth-of-type(3) h3 {
  line-height: 1.5 !important;
  text-wrap: balance;
}

/* Request-flow final callout: enough width for a clean headline break. */
body[data-someido-route="flow"] main > section:nth-of-type(6) > div {
  max-width: 64rem !important;
}

body[data-someido-route="flow"] main > section:nth-of-type(6) h2 {
  max-width: 60rem;
  margin-inline: auto;
  line-height: 1.35 !important;
  text-wrap: balance;
}

body[data-someido-route="flow"] main > section:nth-of-type(6) h2 + p {
  max-width: 56rem;
  margin-inline: auto;
  text-wrap: pretty;
}

/* Cards remain generous enough that a final Japanese character is not orphaned. */
body[data-someido-route="home"] #root > div > section:nth-of-type(3) h3 {
  line-height: 1.5 !important;
  text-wrap: balance;
}

@media (min-width: 768px) {
  body[data-someido-route="services"] #root > div > section:nth-of-type(3) a {
    padding: 1.5rem !important;
  }

  body[data-someido-route="services"] #root > div > section:nth-of-type(3) h3 {
    font-size: clamp(1.15rem, 1.55vw, 1.4rem) !important;
  }
}

@media (min-width: 1280px) {
  body[data-someido-route="home"] #root > div > section:nth-of-type(3) > div > div.grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 640px) {
  .card {
    padding-inline: 1.35rem !important;
  }

  .card h2 {
    font-size: clamp(1.3rem, 5.8vw, 1.6rem) !important;
    line-height: 1.55 !important;
    text-wrap: balance;
  }

  .card p {
    font-size: 0.96rem;
    text-wrap: pretty;
  }

  .guide-card h2,
  .contact-box h2 {
    text-wrap: balance;
  }

  body[data-someido-route="flow"] main > section:nth-of-type(6) h2 {
    font-size: clamp(1.65rem, 8vw, 2.15rem) !important;
  }
}
