/*
 * Shared section-heading types. Load before legacy stylesheets so this layer
 * owns important typography and spacing. Hero and card titles are not marked.
 * en: offerings, process, results/people, FAQ.
 * ja: challenges, approach/value, quality/reasons, audience, consultation.
 * related: secondary Japanese headings introducing a related service.
 */
@layer section-heading-system {
  [data-section-heading] {
    --section-type-en: clamp(35px, 4.583333vw, 66px);
    --section-type-ja: 24px;
    --section-type-gap: 24px;
  }
  :is([data-section-heading="ja"], [data-section-heading="related"]) {
    --section-type-en: 12px;
    --section-type-ja: clamp(28px, 3.055556vw, 44px);
  }
  [data-section-heading="related"] [data-section-part="ja"] {
    --section-type-ja: clamp(1.625rem, 2.222222vw, 2rem);
  }
  [data-section-heading]:not([data-section-layout="preserve"]) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-auto-flow: row !important;
    gap: var(--section-type-gap) !important;
    align-content: start !important;
    align-items: start !important;
    justify-items: start !important;
    text-align: left !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
  }
  [data-section-title-block] { display: contents !important; }
  .section-heading-label {
    --section-icon-size: 20px;
    --section-icon-gap: 12px;
    display: flex;
    align-items: center;
    gap: var(--section-icon-gap);
    max-inline-size: 100%;
    min-inline-size: 0;
  }
  [data-inline-section-heading]:not([data-section-layout="preserve"]) .section-heading-label { order: 0 !important; }
  [data-inline-section-heading] .section-heading-label > [data-section-part="en"] {
    flex: 1 1 auto;
    margin: 0 !important;
    min-inline-size: 0;
    text-align: start !important;
  }
  /* Keep the full line box on display headings so rounded glyphs have room. */
  :is([data-section-heading="ja"], [data-section-heading="related"]) .section-heading-label > [data-section-part="en"] {
    text-box: trim-both cap alphabetic;
  }
  .section-heading-icon {
    flex: none;
    inline-size: var(--section-icon-size);
    block-size: var(--section-icon-size);
    color: #c9002e;
    shape-rendering: geometricPrecision;
  }
  [data-inline-section-heading] > [data-section-part="ja"] {
    padding-inline-start: var(--section-heading-start-padding, 0px) !important;
  }
  #faq [data-inline-section-heading] .section-heading-label { --section-icon-gap: 16px; }
  #faq [data-inline-section-heading] > [data-section-part="ja"] { padding-inline-start: 36px !important; }
  [data-inline-section-heading] .eb-ph-heading > .section-heading-label,
  [data-inline-section-heading].consult-info > .section-heading-label {
    margin-block-end: var(--section-type-gap);
  }
  [data-inline-section-heading].impact-copy { row-gap: var(--section-type-gap) !important; }
  [data-section-lead-block] {
    display: grid !important;
    gap: var(--section-type-gap) !important;
    padding: 0 !important;
  }
  [data-section-lead-block] > * { margin-block: 0 !important; }
  [data-section-heading]:not([data-section-layout="preserve"]) > *,
  [data-section-title-block] > [data-section-part] {
    margin-block: 0 !important;
    order: 2 !important;
    min-width: 0 !important;
  }
  [data-section-heading] [data-section-part] {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    text-align: inherit !important;
    white-space: normal !important;
  }
  [data-section-heading] [data-section-part="en"] {
    font-family: "DM Sans", sans-serif !important;
    font-size: var(--section-type-en) !important;
    font-weight: 400 !important;
    line-height: 1.05 !important;
    letter-spacing: -.035em !important;
  }
  :is([data-section-heading="ja"], [data-section-heading="related"]) [data-section-part="en"] {
    font-weight: 500 !important;
    line-height: 1.3 !important;
    letter-spacing: .02em !important;
  }
  [data-section-heading] [data-section-part="ja"] {
    font-family: "Gen Interface JP", "Noto Sans JP", sans-serif !important;
    font-size: var(--section-type-ja) !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    letter-spacing: .02em !important;
  }
  /* Preserved layouts keep their authored order, including copy and buttons. */
  [data-section-heading]:not([data-section-layout="preserve"]) [data-section-part="en"] {
    order: 0 !important;
  }
  [data-section-heading]:not([data-section-layout="preserve"]) [data-section-part="ja"] {
    order: 1 !important;
  }
  [data-section-heading] [data-section-part="lead"] {
    font-family: "Gen Interface JP", "Noto Sans JP", sans-serif !important;
    font-size: 16px !important;
    font-weight: 400 !important;
    line-height: 1.8 !important;
    letter-spacing: .02em !important;
  }
  /* Older homepage subtitles contain local size overrides inside the title. */
  [data-section-part="ja"] :is(.h2-tag, .h2-main) {
    font-size: inherit !important;
    font-weight: inherit !important;
    line-height: inherit !important;
    letter-spacing: inherit !important;
  }
  @media (max-width: 680px) {
    [data-section-heading] {
      --section-type-en: 35px;
      --section-type-ja: 18px;
      --section-type-gap: 16px;
    }
    :is([data-section-heading="ja"], [data-section-heading="related"]) {
      --section-type-en: 11px;
      --section-type-ja: 28px;
    }
  }
}
