/* Localized pages use the document language set by both the server and the in-page translator. */
[data-step-number]::before { content: attr(data-zh-number); }
html:not(:lang(zh)) [data-step-number]::before { content: attr(data-step-number); }

/* Leave room for the full language code and the menu button on small phones. */
@media (max-width: 360px) {
  .header-inner { width: calc(100% - 24px); gap: 6px; }
  .brand { gap: 5px; }
  .brand img { width: 36px; }
  .brand-text small { letter-spacing: .14em; }
}
@media (min-width: 981px) and (max-width: 1100px) {
  html:lang(zh) .hero-aside { gap: 12px; }
  html:lang(zh) .hero-medal { max-inline-size: calc(100% - 72px); }
}

html[lang]:not(:lang(zh)) {
  --copy-leading: 1.5;
  --reading-leading: 1.62;
  --heading-leading: 1.2;
}
html:is(:lang(ja), :lang(th), :lang(ar)) {
  --copy-leading: 1.62;
  --reading-leading: 1.72;
  --heading-leading: 1.32;
}

html[lang]:not(:lang(zh)) {
  body { line-height: var(--copy-leading); overflow-wrap: anywhere; }
  :is(h1, h2, h3) { line-height: var(--heading-leading); letter-spacing: normal; hyphens: auto; }
  :is(.prose, .timeline p, .factory-copy > p, .factory-cooperation p, .factory-section .section-head p,
      .history-heading p, .report-meta .note) { line-height: var(--reading-leading); }
  :is(.spec-table div, .report-meta .spec-table div, .factory-source, .product-card p,
      .factory-metrics dt, .equipment-grid dt) { line-height: var(--copy-leading); }
  :is(.topbar, .button, .header-cta, .brand-text strong, .seal-tag,
      .footer-slogan, .footer-group h2, .factory-photo figcaption, .history-photo figcaption) { letter-spacing: normal; }

  /* Short Chinese labels can become several words in the same navigation slot. */
  .header-inner { gap: clamp(10px, 1.4vw, 22px); }
  .brand { flex: 0 1 auto; min-inline-size: 0; }
  .brand img { flex: none; }
  .brand-text { min-inline-size: 0; max-inline-size: 10rem; }
  .brand-text strong { font-size: clamp(18px, 1.6vw, 23px); }
  .brand-text small { letter-spacing: .12em; }
  #main-nav { min-inline-size: 0; align-items: center; }
  #main-nav a, .header-cta { white-space: normal; line-height: 1.25; letter-spacing: normal; }
  #main-nav > a { padding-inline: clamp(6px, .65vw, 10px); text-align: center; }
  .header-cta { max-inline-size: 11rem; text-align: center; }
  .header-actions, .menu-toggle { flex-shrink: 0; }

  /* Keep the translated caption under the medal and allow the headline to wrap naturally. */
  .hero-inner { grid-template-columns: minmax(0, 1.3fr) minmax(0, .7fr); }
  .hero-title { font-size: clamp(34px, 4.9vw, 72px); line-height: var(--heading-leading); letter-spacing: normal; }
  .hero-subtitle { font-size: clamp(18px, 1.8vw, 25px); letter-spacing: normal; line-height: var(--copy-leading); }
  .hero-aside { flex-direction: column; gap: 16px; }
  .vertical-text {
    writing-mode: horizontal-tb; border: 0; padding: 0; margin-inline: auto;
    max-inline-size: 28ch; font-size: 16px; letter-spacing: normal; text-align: center;
  }
  .page-hero h1 { letter-spacing: normal; }
  .section-head.center { gap: 12px; }

  /* Long options must never set the width of a form or its neighboring column. */
  :is(.consult-form, .consult-faq, .field, .contact-info, .product-summary, .product-gallery, .prose) { min-inline-size: 0; }
  .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-row .field { display: grid; grid-template-rows: 1fr auto; }
  .field :is(input, select, textarea) { inline-size: 100%; min-inline-size: 0; max-inline-size: 100%; }
  .faq-item summary { align-items: center; line-height: var(--copy-leading); }
  .faq-toggle, .consent input { flex: none; }
  .article-toc ol { padding-inline-start: 1.3em; }
  .spec-chips span { display: inline; margin-inline-end: .45em; }
  .spec-chips li, .spec-table dt { hyphens: auto; }
  .spec-table div, .report-meta .spec-table div { grid-template-columns: minmax(0, 34%) minmax(0, 1fr); }
  .factory-metrics dd, .factory-cooperation .button { white-space: normal; }
  .factory-metrics dd { line-height: var(--copy-leading); }
  .profile-stats dt, .equipment-grid dt { hyphens: auto; }
  /* Translated quantities may be a numeral, a phrase or a single inflected word. */
  .equipment-grid dd { color: var(--purple-800); font: 500 22px/1.25 var(--serif); }
  .equipment-grid dd strong { font: inherit; }
  @supports (grid-template-rows: subgrid) {
    :is(.profile-stats, .factory-metrics) > div {
      display: grid; grid-row: span 2; grid-template-rows: subgrid; row-gap: 6px;
    }
    :is(.profile-stats, .factory-metrics) :is(dt, dd) { align-self: start; margin-block: 0; }
  }
  .timeline { grid-auto-rows: auto; }
  .timeline-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
  .timeline-heading time { max-inline-size: 100%; font-size: clamp(26px, 2.4vw, 36px); }
  .timeline-heading h3 { flex: 1 1 12ch; min-inline-size: 0; }
  .report-layout > .table-scroll { align-self: start; }
  .report-layout .report-table { height: auto; }
  .footer-legal, .report-viewer-controls { flex-wrap: wrap; }
  .report-viewer-header h2 { flex: 1; min-inline-size: 0; }
  .report-viewer-header button { flex: none; }

  @media (min-width: 981px) {
    .consult-inner:not(.consult-single) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .consult-faq .faq-item { flex: none; }
    .consult-faq .faq-item summary { height: auto; }
  }
  @media (min-width: 1201px) {
    .brand { flex-shrink: 0; }
    #main-nav > a, .header-cta { overflow-wrap: normal; }
  }
  /* Long translated labels need the compact menu before the Chinese breakpoint. */
  @media (min-width: 981px) and (max-width: 1200px) {
    .menu-toggle { display: block; order: 3; margin-left: 0; }
    #main-nav {
      display: none; position: absolute; inset: 100% 0 auto; flex-direction: column;
      gap: 0; padding: 10px 20px 20px; max-height: calc(100dvh - 116px); overflow-y: auto;
      background: var(--paper); border-block-end: 1px solid var(--line); box-shadow: var(--shadow);
    }
    .nav-open #main-nav { display: flex; }
    #main-nav > a { border-block-end: 1px solid var(--line); }
  }
  @media (max-width: 1200px) {
    .header-actions { margin-left: 0; margin-inline-start: auto; }
    #main-nav { align-items: stretch; }
    #main-nav > a { text-align: start; padding: 12px 4px; }
  }
  @media (max-width: 980px) {
    .hero-inner { grid-template-columns: minmax(0, 1fr); }
  }
  @media (max-width: 640px) {
    .header-inner { gap: 8px; }
    .brand { gap: 6px; }
    .hero-inner { padding-block: 48px 92px; }
    .form-row { grid-template-columns: minmax(0, 1fr); }
    .products-home .section-head { align-items: flex-start; flex-wrap: wrap; }
    .products-home .text-link { max-inline-size: 100%; flex-shrink: 1; }
    .section-head { gap: 12px; }
    .report-viewer-header { flex-wrap: wrap; }
  }
}

/* Offscreen controls on the physical left create an extra scrollable canvas in RTL. */
html:lang(ar) {
  .header-language .gt_float_switcher .gt_options { inset-inline-end: auto !important; left: 0 !important; right: auto !important; }
  .skip-link:not(:focus), .form-honey {
    inset-inline: 0 auto; inline-size: 1px; block-size: 1px; overflow: hidden;
    clip-path: inset(50%); padding: 0; white-space: nowrap;
  }
  .skip-link:focus { left: auto; inset-inline-start: 8px; }
  .report-table th { text-align: start; }
  .article-toc ol, .prose ul { padding-left: 0; padding-inline-start: 1.3em; }
  .topbar a, a[href^="tel:"] { unicode-bidi: isolate; }
  .craft-steps li:not(:last-child)::after { right: auto; left: -16px; transform: rotate(-135deg); }
  @media (max-width: 980px) {
    .craft-timeline::before { left: auto; inset-inline-start: 24px; }
    .craft-timeline li { padding-left: 0; padding-inline-start: 56px; }
  }
}
