/* =========================================================
   Layout polish — loaded after readability.css.
   余白・文字位置・折り返しの最終調整（全ページ共通）
   ========================================================= */

/* ---------- 1. 日本語の折り返し（文節単位で改行） ---------- */
main :is(p, li, h1, h2, h3, h4, .lead, figcaption, dt, dd, label, small, .button, .text-link),
main :is([class*="__lead"], [class*="__label"], [class*="__title"], [class*="__category"], [class*="-card"] span),
.site-footer :is(p, a, span) {
  word-break: auto-phrase;
}
main :is(h1, h2, h3, h4) { text-wrap: balance; }
main p { text-wrap: pretty; }

/* ---------- 2. ヘッダー：1280px以上は1行にまとめる ---------- */
@media (min-width: 1280px) {
  body .site-header { height: 96px; min-height: 0; padding-block: 0; gap: clamp(24px, 2.4vw, 40px); }
  body .site-logo { width: clamp(150px, 11.5vw, 185px); }
  body .global-nav { flex-direction: row; align-items: center; justify-content: flex-end; gap: clamp(20px, 2vw, 36px); }
  body .global-nav ul { width: auto; justify-content: flex-end; gap: clamp(16px, 1.45vw, 28px); }
  body .global-nav li a, body .global-nav li > .inactive-link { padding-block: 8px; }
  body .header-actions { gap: 12px; }
  body .header-actions .button { min-height: 42px; padding-inline: 16px; }
  body[class] .global-nav [aria-current="page"]::after { bottom: -2px; }
}
@media (min-width: 1280px) and (max-width: 1439px) {
  body .site-header { padding-inline: 3%; gap: 20px; }
  body .site-logo { width: 140px; }
  body .site-header .global-nav ul { gap: 10px; }
  body .site-header .global-nav { gap: 14px; }
  body .header-actions { gap: 10px; }
  body .header-actions .button { padding-inline: 12px; }
  body .global-nav li a, body .global-nav li > .inactive-link { font-size: 12.5px; }
  body .header-actions .lang-link { gap: 5px; }
}

/* ---------- 3. コンパクトフッター：本文と同じ幅にそろえる ---------- */
body[class] .site-footer--compact .footer-bottom {
  width: min(90%, var(--content)); max-width: none; min-height: 0;
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center;
  gap: 28px 48px; padding-block: 52px 40px;
}
body[class] .site-footer--compact .footer-logo { width: 180px; margin: 0; }
body[class] .site-footer--compact nav { justify-content: flex-end; padding: 0; margin: 0; gap: 4px 22px; }
body[class] .site-footer--compact .footer-meta {
  grid-column: 1 / -1; max-width: none; margin: 0; padding: 22px 0 0;
  justify-content: flex-start; border-top: 1px solid #ffffff1f;
}
body[class] .site-footer--compact .copyright { flex-basis: auto; margin-left: auto; text-align: right; }
@media (max-width: 1000px) {
  body[class] .site-footer--compact .footer-bottom { grid-template-columns: 1fr; gap: 24px; }
  body[class] .site-footer--compact nav { justify-content: flex-start; }
}
@media (max-width: 767px) {
  body[class] .site-footer--compact .footer-bottom { display: grid; padding-block: 40px 32px; }
  body[class] .site-footer--compact .footer-logo, body[class] .site-footer--compact nav { margin: 0; }
  body[class] .site-footer--compact .copyright { flex-basis: 100%; margin-left: 0; text-align: left; }
}
@media (max-width: 640px) {
  body[class] .site-footer--compact .footer-bottom { width: calc(100% - 32px); }
  body[class] .site-footer--compact .footer-logo { width: 160px; }
}
/* トップの通常フッター */
@media (max-width: 640px) {
  .site-footer .footer-bottom nav { gap: 2px 20px; }
}

/* ---------- 4. 共通：2ボタン並びはスマホで同幅に ---------- */
@media (max-width: 480px) {
  body main .button-row:has(> .button + .button) > .button { flex: 1 1 100%; }
}

/* ---------- 5. TOP ---------- */
body.top-page .case-card span { word-break: auto-phrase; padding-inline: 6px; line-height: 1.5; }
body.top-page .steps__grid { align-items: center; }
@media (max-width: 1000px) {
  body.top-page .platform-links { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; }
  body.top-page .platform-links a,
  body.top-page .platform-links a:first-child { flex-direction: column; align-items: center; gap: 10px; padding: 6px 8px; text-align: center; border-right: 1px solid #ffffff40; }
  body.top-page .platform-links a:last-child { border-right: 0; }
  body.top-page .platform-links span { font-size: 17px; }
  body.top-page .platform-links::before { left: 0; }
  body.top-page .reach__items b { font-size: clamp(40px, 5.6vw, 54px); }
}
@media (max-width: 640px) {
  /* 5項目を 3＋2 でバランスよく */
  body.top-page .platform-links { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; }
  body.top-page .platform-links a,
  body.top-page .platform-links a:first-child { grid-column: span 2; min-height: 0; padding: 16px 6px; border-bottom: 1px solid #ffffff30; border-right: 1px solid #ffffff30; }
  body.top-page .platform-links a:nth-child(n+4) { grid-column: span 3; border-bottom: 0; }
  body.top-page .platform-links a:nth-child(3), body.top-page .platform-links a:last-child { border-right: 0; }
  body.top-page .platform-links span { font-size: 16px; }
  body.top-page .case-card span { font-size: 12px; padding-inline: 4px; }
  body.top-page .reach__items b { font-size: 42px; }
}

/* ---------- 6. WERIAとは ---------- */
body .about-platform__grid { row-gap: 0; }
body .about-platform__grid > li { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0; margin-bottom: 20px; }
body .about-platform__heading { flex-wrap: nowrap; align-items: flex-start; }
body .about-platform__heading > div { min-width: 0; }
body .about-platform__heading > span { flex: none; overflow-wrap: normal; }
body .about-platform__grid > li > img { align-self: start; }
@media (max-width: 640px) {
  body .about-platform__grid > li { margin-bottom: 16px; }
}

/* ---------- 7. ソリューション ---------- */
body .solution-row__layout { padding-block: 56px; }
body .solutions-list { padding-bottom: 0; }
@media (max-width: 1000px) {
  body .solution-row__layout { padding-block: 44px; }
  body .solutions-overview__intro { grid-template-columns: 1fr; gap: 18px; }
  body .solutions-overview__intro > p { border-left: 0; padding-left: 0; font-size: 14px; }
}
@media (min-width: 768px) and (max-width: 1000px) {
  body .solutions-hero__layout { display: block; }
  body .solutions-hero__vision { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; width: 100%; margin-top: 56px; }
  body .solutions-hero__vision > p { margin: 0; font-size: 22px; }
}
@media (max-width: 767px) {
  body .solution-row__layout { grid-template-columns: minmax(0, 1fr); padding-block: 40px; }
  body .solution-row__pager { display: none; }
  body .solutions-index { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
  body .solutions-index a { font-size: 11px; letter-spacing: 0; }
  body .solutions-index a > span { font-size: 22px; }
  body .solutions-cta__vision { margin-top: 44px; }
}

/* ---------- 8. 活用事例：一覧を本文と同じ幅に ---------- */
body .usage-catalog > .container-wide { width: min(90%, var(--content)); }
body .usage-filter > span { word-break: keep-all; }
@media (max-width: 1000px) {
  body .usage-filter > span { white-space: nowrap; }
}
@media (max-width: 640px) {
  body .usage-catalog > .container-wide { width: calc(100% - 32px); }
}

/* ---------- 9. DPP ---------- */
body .dpp-voices .dpp-section-intro { align-items: center; }
@media (max-width: 767px) {
  body .dpp-benefit:last-child:nth-child(odd) { grid-column: 1 / -1; max-width: 280px; margin-inline: auto; }
}
@media (max-width: 374px) {
  body .dpp-benefit:last-child:nth-child(odd) { max-width: none; }
}

/* ---------- 11. 導入事例：業種フィルター ---------- */
@media (min-width: 768px) {
  body .studies-filters { flex-direction: column; gap: 12px; }
  body .studies-filters > p { margin: 0; }
  body .studies-filters > div { gap: 6px; }
  body .studies-filters button { padding: 8px 10px; }
}

/* フッターCTA：明るい太陽の上でも読めるように */
.site-footer .footer-cta p { text-shadow: 0 1px 12px #000c; }

/* ---------- 12. スマホ・タブレットのメニュー ---------- */
@media (max-width: 1279px) {
  body .global-nav { padding-top: 10px; }
  /* JP・デモを見る・お問い合わせ を1行に */
  body .header-actions { flex-wrap: nowrap; align-items: center; gap: 10px; }
  body .header-actions .lang-link { flex: none; gap: 6px; margin-right: 4px; }
  body .header-actions .inactive-link .lang-chevron { display: none; } /* 非表示の⌄が幅だけ取っていたため */
  body .header-actions .button { flex: 0 1 auto; min-width: 0; padding-inline: 14px; white-space: nowrap; }
}
@media (max-width: 360px) {
  body .header-actions { gap: 8px; }
  body .header-actions .button { padding-inline: 11px; font-size: 13px; }
}

/* ---------- 13. TOPヒーロー：右側の言語パネルが見切れないように ---------- */
/* 画像(1916×821)の左側は余白なので、右端基準で配置し、高さは画像の比率に合わせる */
@media (min-width: 1280px) {
  body.top-page .hero {
    min-height: max(560px, calc(100vw * 821 / 1916));
    background-size: cover;
    background-position: right center;
  }
}
/* 1001〜1279px は文字とスマホ画像が重なるため、スマホ・タブレットと同じく「文字の下に画像」 */
@media (min-width: 1001px) and (max-width: 1279px) {
  body.top-page .hero {
    --top-image-height: max(460px, calc(100vw * 821 / 1916)); /* 画像が横幅いっぱいになる高さ */
    min-height: 0; align-items: flex-start;
    background-size: auto var(--top-image-height); background-position: right bottom;
  }
  body.top-page .hero__content { padding-block: 56px calc(var(--top-image-height) + 20px); }
  body.top-page .hero::after { background: none; }
}
