/* FORMULA localization safety layer.
   RU is intentionally untouched. Rules below activate only in non-RU deploys. */

html[data-formula-locale="de"] body,
html[data-formula-locale="de"] button,
html[data-formula-locale="de"] input,
html[data-formula-locale="de"] textarea,
html[data-formula-locale="de"] select,
html[data-formula-locale="de"] summary {
  hyphens: auto;
  -webkit-hyphens: auto;
}

html[data-formula-locale]:not([data-formula-locale="ru"]) body {
  overflow-wrap: break-word;
}

/* Navigation and compact controls: allow translated copy to grow vertically. */
html[data-formula-locale]:not([data-formula-locale="ru"]) .nav-link,
html[data-formula-locale]:not([data-formula-locale="ru"]) .list-card-badge.mini-badge,
html[data-formula-locale]:not([data-formula-locale="ru"]) .learn-system-cta {
  white-space: normal !important;
  height: auto !important;
  line-height: 1.18 !important;
  text-align: center;
}

html[data-formula-locale]:not([data-formula-locale="ru"]) .list-card-badge.mini-badge {
  max-width: 100%;
  overflow-wrap: break-word;
}

/* Learn landing card: preserve the composition, but do not force CTA onto one line. */
html[data-formula-locale]:not([data-formula-locale="ru"]) .learn-system-copy,
html[data-formula-locale]:not([data-formula-locale="ru"]) .learn-system-copy h2,
html[data-formula-locale]:not([data-formula-locale="ru"]) .learn-system-copy p {
  min-width: 0;
}

/* Intro lesson image overlays: translated titles may use multiple lines. */
html[data-formula-locale]:not([data-formula-locale="ru"]) .stage-overlay {
  align-items: flex-start !important;
  max-width: calc(100% - 28px) !important;
}
html[data-formula-locale]:not([data-formula-locale="ru"]) .stage-title {
  min-width: 0;
  line-height: 1.08 !important;
  overflow-wrap: break-word;
}

/* Diagnostic: title rows must be content-driven in EN/DE. */
html[data-formula-locale]:not([data-formula-locale="ru"]) .care-step {
  grid-template-rows: minmax(36px,auto) 112px minmax(36px,auto) !important;
}
html[data-formula-locale]:not([data-formula-locale="ru"]) .start-formula-unit,
html[data-formula-locale]:not([data-formula-locale="ru"]) .care-rhythm-hint {
  white-space: normal !important;
}
html[data-formula-locale]:not([data-formula-locale="ru"]) .care-rhythm-hint {
  text-align: right;
}
@media (max-width:430px) {
  html[data-formula-locale]:not([data-formula-locale="ru"]) .care-step {
    grid-template-rows: minmax(34px,auto) 100px minmax(34px,auto) !important;
  }
}

/* Diary: meaningful user values must wrap instead of being truncated. */
html[data-formula-locale]:not([data-formula-locale="ru"]) .diary-choice-details summary {
  grid-template-columns: minmax(0,1fr) minmax(0,1fr) 20px;
}
html[data-formula-locale]:not([data-formula-locale="ru"]) .diary-choice-details summary b,
html[data-formula-locale]:not([data-formula-locale="ru"]) .diary-drying-details[open] summary b:not(:empty),
html[data-formula-locale]:not([data-formula-locale="ru"]) .diary-history-approved-meta-cell b,
html[data-formula-locale]:not([data-formula-locale="ru"]) .diary-history-approved-product-subline span,
html[data-formula-locale]:not([data-formula-locale="ru"]) .diary-progress-metric span {
  max-width: none !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  overflow-wrap: break-word;
}
html[data-formula-locale]:not([data-formula-locale="ru"]) .diary-progress-metric {
  height: auto !important;
}

/* Product Base topbar: translated section names may use two lines. */
html[data-formula-locale]:not([data-formula-locale="ru"]) .base-page .base-menu-title {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  line-height: 1.12 !important;
  overflow-wrap: break-word;
}

/* V578 QA stress: at 320px the lesson cards' legacy aspect-ratio + min-height
   can force the grid item wider than its track. Keep RU untouched; EN/DE use
   content-driven height on the smallest supported viewport. */
@media (max-width: 340px) {
  html[data-formula-locale]:not([data-formula-locale="ru"]) .learn-lesson-card {
    width: 100% !important;
    max-width: 100% !important;
    aspect-ratio: auto !important;
  }
}
@media (max-width: 340px) {
  html[data-formula-locale]:not([data-formula-locale="ru"]) .learn-system-card {
    width: 100% !important;
    max-width: 100% !important;
    aspect-ratio: auto !important;
  }
}


/* V585 — intrinsic tab sizing and German typographic safety.
 * Only non-Russian locales. The reference RU layout is never modified.
 * Text may occupy more lines; tracks/controls must grow with their content.
 */
html[data-formula-locale]:not([data-formula-locale="ru"]) .tier-switch {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  min-width: 0;
}
html[data-formula-locale]:not([data-formula-locale="ru"]) #dandruffTierSwitch {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}
html[data-formula-locale]:not([data-formula-locale="ru"]) .tier-switch .tier-tab {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 100%;
  height: auto;
  min-height: 44px;
  padding: 7px 5px 9px;
  font-size: clamp(11px, 3.15vw, 14px);
  line-height: 1.18;
  letter-spacing: normal;
  text-align: center;
  text-wrap: balance;
  white-space: normal !important; /* override legacy inline nowrap */
  word-break: normal;
  overflow-wrap: break-word; /* emergency only, after native word/hyphen breaks */
  hyphens: auto;
  -webkit-hyphens: auto;
}
html[data-formula-locale]:not([data-formula-locale="ru"]) #dandruffTierSwitch .tier-tab {
  font-size: clamp(11.3px, 3vw, 12.8px);
  padding-inline: 3px;
  letter-spacing: normal;
}
html[data-formula-locale]:not([data-formula-locale="ru"]) .diary-tabs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}
html[data-formula-locale]:not([data-formula-locale="ru"]) .diary-tab {
  min-width: 0;
  min-height: 42px;
  padding: 7px 5px;
  white-space: normal;
  line-height: 1.2;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
  -webkit-hyphens: auto;
  text-wrap: balance;
}
/* Normal prose: native language-sensitive hyphenation. No forced arbitrary
   splitting within German words unless a single unbreakable token requires it. */
html[data-formula-locale="de"] .hero h1,
html[data-formula-locale="de"] .notice h2,
html[data-formula-locale="de"] .section-head h2,
html[data-formula-locale="de"] .learn-lesson-card h3,
html[data-formula-locale="de"] .list-card-title,
html[data-formula-locale="de"] .diary-hero-v3 h1,
html[data-formula-locale="de"] .diary-card h2,
html[data-formula-locale="de"] .diary-insight-card h3 {
  word-break: normal !important;
  hyphens: manual;
  -webkit-hyphens: manual;
  overflow-wrap: break-word; /* last resort if no legal break is available */
}
/* Small navigation and badges keep intact terms where possible. */
html[data-formula-locale]:not([data-formula-locale="ru"]) .base-menu-title,
html[data-formula-locale]:not([data-formula-locale="ru"]) .panel-kicker,
html[data-formula-locale]:not([data-formula-locale="ru"]) .list-card-tag,
html[data-formula-locale]:not([data-formula-locale="ru"]) .modal-tag {
  min-width: 0;
  word-break: normal;
  overflow-wrap: break-word;
}
