/* Public child-site refinements. Loaded after each edition's existing theme. */

/* Versioned themes force balanced/nowrap headings, sometimes inside a span.
   Only wrapping needs priority; the existing colors, fonts and sizes remain. */
body[class] :is(h1, h2, h3, h4) {
  white-space: normal !important;
  text-wrap: wrap !important;
  word-break: normal;
  overflow-wrap: break-word;
}

body[class] :is(h1, h2, h3, h4) br {
  display: none;
}

/* Keep the existing hero-title treatment outside this subheading change. */
body[class] h1 :is(.keep, .nowrap, .no-wrap, .keep-all, [class*="nowrap"], [class*="keep"]) {
  display: inline;
  white-space: normal !important;
  text-wrap: wrap !important;
  word-break: normal;
  overflow-wrap: break-word;
  max-width: 100%;
}

/* Balance short headings instead of leaving one or two characters stranded.
   Older browsers keep normal Japanese wrapping. Existing phrase spans below
   remain the fallback for product names and other deliberately grouped words. */
body[class] main :is(h2, h3, h4) {
  text-wrap: balance !important;
  word-break: auto-phrase;
}

body[class] main h2 {
  text-wrap: pretty !important;
}

body[class] main :is(h2, h3) .cms-heading-phrase {
  display: inline-block;
  white-space: nowrap;
  max-width: 100%;
}

body[class] main :is(h2, h3, h4) :is(.keep, .nowrap, .no-wrap, .keep-all, [class*="nowrap"], [class*="keep"]) {
  display: inline-block;
  white-space: nowrap !important;
  max-width: 100%;
}

/* These three display lines have different type sizes; merging them into one
   inline run splits Webサイト制作 and defeats the original hierarchy. */
body.r23-home #section-02 .r23-point-heading h2 .r23-point-line {
  display: block;
  white-space: nowrap;
}

body.r23-home #design-samples #samples-heading .r26-gallery-line {
  display: inline-block;
  white-space: nowrap !important;
}

body.r23-home.r15-home #section-03 .beauty-point-line {
  display: block;
}

body.r23-home.r15-home #section-03 .beauty-copy-phrase {
  display: inline-block;
  white-space: nowrap;
}

body.r23-home #section-03 .r25-point-line {
  display: inline;
  white-space: normal;
}

/* A fixed two-line card title can leave a fragment on a third line. Let the
   available card width choose balanced lines without changing its type size. */
body.r23-home #section-06 .r12-speed-grid h3 .r26-speed-line {
  display: inline;
  white-space: normal;
}

/* Chromium's phrase breaker splits 中小企業 after 中. Balanced normal wrapping
   keeps this fixed comparison title in two readable halves on narrow screens. */
body.r23-home[data-industry="it"] #comparison-4 {
  word-break: normal;
}

@media (max-width: 600px) {
  /* Give comparison titles the full card width; the number has its own row. */
  body.r23-home #section-02 .r13-comparison-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
}

/* Use the original site's heading sizes. Wrapping must never opt into the
   legacy single-line fitting variable or a smaller mobile font-size. */

/* Match the original golf gallery scale in the salon edition as requested.
   Its longer wording may use another line instead of reducing the type. */
@media (max-width: 600px) {
  body.r23-home.r15-home[data-industry="medical"] #design-samples #samples-heading {
    font-size: clamp(36px, 11.4vw, 60px);
  }
}

body.r23-home.r15-home[data-industry="medical"] #design-samples #samples-heading .r26-gallery-line {
  max-width: 100%;
  white-space: normal !important;
}

body.r19-home.r15-home .r12-section .r12-heading .r19-gold {
  color: inherit;
  background: none;
}

/* Keep the original observer/event hooks, with stationary, always-visible text. */
body:is(.page-home, .page-plans, .page-faq, .page-contact, .page-columns, .page-article) .wipe-heading,
body:is(.page-home, .page-plans, .page-faq, .page-contact, .page-columns, .page-article) .wipe-heading:is([data-wipe-state="waiting"], [data-wipe-state="running"], [data-wipe-state="done"]),
body:is(.r14-home, .r15-home).r14-motion-ready .r14-reveal-heading,
body.r23-home.r15-home .r12-section .r14-reveal-heading,
body.r23-home #section-02 .r23-point-heading h2.r14-reveal-heading {
  opacity: 1;
  transform: none;
  transition: none;
}

body .r14-heading-text,
body:is(.r14-home, .r15-home).r14-motion-ready .r14-reveal-heading:is([data-wipe-state="waiting"], [data-wipe-state="running"], [data-wipe-state="done"]) .r14-heading-text {
  opacity: 1;
  transform: none;
  transition: none;
}

/* Replace the full-height wipe with a short, quiet underline. */
body:is(.page-home, .page-plans, .page-faq, .page-contact, .page-columns, .page-article) .wipe-heading::after,
body:is(.r14-home, .r15-home).r14-motion-ready .r14-reveal-heading::after,
body.r23-home.r15-home .r12-section .r14-reveal-heading::after,
body.r23-home #section-02 .r23-point-heading h2.r14-reveal-heading::after,
body.r23-home #design-samples #samples-heading::after {
  content: "";
  position: absolute;
  inset: auto auto -.18em 0;
  z-index: 0;
  width: min(100%, 9rem);
  height: 2px;
  border: 0;
  border-radius: 1px;
  background: linear-gradient(90deg, transparent, var(--edition-primary, var(--yellow, #5db095)), transparent);
  background-size: 200% 100%;
  background-position: 100% 50%;
  opacity: .28;
  clip-path: none;
  transform: none;
  box-shadow: none;
  pointer-events: none;
}

body:is(.page-home, .page-plans, .page-faq, .page-contact, .page-columns, .page-article) .wipe-heading.is-wiping::after {
  animation: heading-wipe 650ms ease-out both;
}

body:is(.r14-home, .r15-home).r14-motion-ready .r14-reveal-heading[data-wipe-state="running"]::after {
  animation: r15-bar-pass 650ms ease-out both;
}

/* Names are retained because site.js completes reveal state on animationend. */
@keyframes heading-wipe {
  0% { opacity: .22; background-position: 100% 50%; }
  45% { opacity: .55; background-position: 0 50%; }
  100% { opacity: .28; background-position: -100% 50%; }
}

@keyframes r15-bar-pass {
  0% { opacity: .22; background-position: 100% 50%; }
  45% { opacity: .55; background-position: 0 50%; }
  100% { opacity: .28; background-position: -100% 50%; }
}

@keyframes r14-heading-arrive {
  from { opacity: 1; transform: none; }
  to { opacity: 1; transform: none; }
}

@keyframes r15-heading-arrive {
  from { opacity: 1; transform: none; }
  to { opacity: 1; transform: none; }
}

/* These classes identify only the source heading and its immediately following
   list; later CTA copy keeps the ordinary article typography. */
body.page-article .article-layout > .prose h2.cms-sources-heading {
  margin: 38px 0 12px;
  padding: 0;
  font-size: 18px;
  line-height: 1.5;
  font-weight: 700;
}

/* Keep the original article heading size; only its decoration is simplified. */
body.page-article .article-layout > .prose h2:not(.cms-sources-heading) {
  line-height: 1.55;
  padding-top: 0;
}

body.page-article .article-layout > .prose h2::before {
  content: none;
}

body .prose .cms-sources-heading::before {
  content: none;
  display: none;
}

body .prose .cms-sources-list {
  margin: 0 0 26px;
  padding-left: 1.5em;
  font-size: 13px;
  line-height: 1.7;
}

body .prose .cms-sources-list :is(li, p, a) {
  font-size: inherit;
  line-height: inherit;
}

body .prose .cms-sources-list li {
  margin-bottom: .6em;
}

body .prose .cms-sources-list a {
  overflow-wrap: anywhere;
  word-break: normal;
}

@media (prefers-reduced-motion: reduce) {
  body[class] :is(.wipe-heading, .r14-reveal-heading),
  body[class] .r14-heading-text {
    opacity: 1;
    transform: none;
    transition: none;
    animation: none;
  }

  body[class] :is(.wipe-heading, .r14-reveal-heading)::after {
    animation: none;
    opacity: .2;
    box-shadow: none;
  }
}

/* Give long-form reading more room, without enlarging navigation or sources. */
body.page-article .article-layout > .prose {
  font-size: 18.7px;
  line-height: 2.15;
}

body.page-article .article-layout > .prose > p {
  margin-bottom: 1.5em;
}

body.page-article .article-layout > .prose table {
  font-size: 16.5px;
  line-height: 2;
}

@media (min-width: 1200px) {
  body.page-article .article-layout {
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 52px;
  }
}

@media (max-width: 900px) {
  body.page-article .article-layout > .prose { font-size: 17.6px; }
}

@media (max-width: 600px) {
  body.page-article .article-layout > .prose { font-size: 16.5px; }
  body.page-article .article-layout > .prose table { font-size: 15.4px; }
}

/* The column footer has a brand and two navigation groups. Keep all three
   together on desktop without changing the existing type or logo sizes. */
body:is(.page-columns, .page-article) .site-footer .footer-grid {
  display: flex;
  align-items: center;
  gap: 24px 30px;
}

body:is(.page-columns, .page-article) .footer-grid > div:first-child {
  margin-right: auto;
}

body:is(.page-columns, .page-article) .site-footer .brand {
  margin-bottom: 0;
}

body:is(.page-columns, .page-article) .site-footer nav {
  flex-wrap: nowrap;
  flex-shrink: 0;
  gap: 15px 24px;
}

body:is(.page-columns, .page-article) .site-footer nav a {
  white-space: nowrap;
}

@media (max-width: 999px) {
  body:is(.page-columns, .page-article) .site-footer .footer-grid {
    flex-wrap: wrap;
  }

  body:is(.page-columns, .page-article) .footer-grid > div:first-child {
    flex-basis: 100%;
  }
}

@media (max-width: 600px) {
  body:is(.page-columns, .page-article) .site-footer nav {
    flex-wrap: wrap;
    flex-shrink: 1;
    gap: 9px 22px;
  }
}
