/* REFTHE control system v1 · M2 · 2026-10
 *
 * Shared geometry and interaction rules for operational controls. Sections
 * may override only --control-accent; all other measurements stay global.
 */
:root {
  --control-height: 48px;
  --control-border-width: 1px;
  --control-radius: 12px;
  --control-focus-width: 3px;
  --control-focus-offset: 3px;
  --control-icon-target: 48px;
  --control-icon-box: 32px;
  --control-icon-size: 20px;
  --control-gap: 10px;
  --control-padding-inline: 16px;
  --control-font-size: 15px;
  --control-active-mark: 3px;
  --control-accent: #176c68;
  --control-surface: #fff;
  --control-ink: color-mix(in srgb, var(--control-accent) 82%, #102f2d);
  --control-border-color: color-mix(in srgb, var(--control-accent) 55%, #d9e4e2);
  --control-hover: color-mix(in srgb, var(--control-accent) 7%, #fff);
  --control-muted: #687875;
  --control-disabled-bg: #edf1f0;
  --control-shadow: 0 5px 14px color-mix(in srgb, var(--control-accent) 10%, transparent);
}

body.library-page-v2,
body.manufacturer-library-page {
  --control-accent: #175dad;
}

body.tools-page,
body.equipment-collection,
body.catalog-page,
body.safety-page {
  --control-accent: #815b00;
}

body.inverter-page,
body.inverter-detail-page,
body.manual-page {
  --control-accent: #5f499b;
}

body.faults-page,
body.diagnostic-page,
body.fault-answer-page,
body.fault-path-page {
  --control-accent: #136a58;
}

body.calc-page {
  --control-accent: #08767b;
}

/* Text fields use the same physical target, border, radius and focus model. */
html body :where(
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
  select,
  textarea
) {
  box-sizing: border-box;
  min-height: var(--control-height) !important;
  border: var(--control-border-width) solid var(--control-border-color) !important;
  border-radius: var(--control-radius) !important;
  background-color: var(--control-surface) !important;
  color: var(--control-ink) !important;
  font-size: max(var(--control-font-size), 1rem);
  line-height: 1.35;
}

html body :where(textarea) {
  min-height: calc(var(--control-height) * 2) !important;
}

/* Every ordinary button reaches the same mobile target. Card-shaped buttons
 * keep their component styling and dimensions. */
html body button:not(.brand-tile):not(.site-entrance__mark):not(.feedback-toggle) {
  box-sizing: border-box;
  min-height: var(--control-height) !important;
  border-radius: var(--control-radius) !important;
}

/* Allow-list of operational buttons and action links. Large navigation cards
 * keep their own dimensions, but inherit the same focus treatment below. */
html body :where(
  form button,
  button.icon-button,
  button.menu-toggle,
  button[aria-pressed],
  button[aria-selected],
  [role="button"],
  [role="tab"],
  a.button,
  .btn,
  .case-link,
  .text-action,
  .text-link,
  .search-primary-link,
  .button-outline,
  .button-light,
  .button-secondary,
  .button-accent,
  .safety-button,
  .safety-button-dark,
  .safety-button-light,
  .safety-button-outline,
  .ec-button,
  .ec-button-dark,
  .ec-button-outline,
  .guide-open,
  .answer-back,
  .clinic-back,
  .fault-object-submit,
  .fault-alarm-cta,
  .search-alarm,
  .field-primary,
  .guided-action-link,
  .inverter-fast-submit,
  .inverter-fast-chip,
  .inverter-fast-clear,
  .tools-path-link,
  .purchase-link,
  .price-link,
  .affiliate-cta,
  .detail-source,
  .guide-resource-link,
  .seasonal-partner__action,
  .product-action,
  .book-open,
  .load-more-button,
  .progressive-disclosure,
  .section-index a,
  .field-shortcuts a,
  .section-nav a,
  .tool-card-actions a,
  .document-actions a,
  .controller-card-actions a,
  .premium-card-actions a,
  .danfoss-card-actions a,
  .temperature-card-actions a,
  .manual-product-actions a,
  .bench-actions a,
  .bench-symptom-grid a,
  .branch-actions a,
  .silo-actions a,
  .fault-card-bottom a,
  .lean-bottom > a
) {
  box-sizing: border-box;
  min-height: var(--control-height) !important;
  border-width: var(--control-border-width) !important;
  border-style: solid !important;
  border-color: var(--control-border-color) !important;
  border-radius: var(--control-radius) !important;
  background-color: var(--control-surface) !important;
  color: var(--control-ink) !important;
  font-size: max(var(--control-font-size), .9375rem);
  line-height: 1.2;
}

html body :where(
  a.button,
  .btn,
  .case-link,
  .text-action,
  .text-link,
  .search-primary-link,
  .button-outline,
  .button-light,
  .button-secondary,
  .button-accent,
  .safety-button,
  .safety-button-dark,
  .safety-button-light,
  .safety-button-outline,
  .ec-button,
  .ec-button-dark,
  .ec-button-outline,
  .guide-open,
  .guided-action-link,
  .inverter-fast-chip,
  .tools-path-link,
  .purchase-link,
  .price-link,
  .affiliate-cta,
  .detail-source,
  .guide-resource-link,
  .seasonal-partner__action,
  .product-action,
  .book-open,
  .load-more-button,
  .progressive-disclosure,
  .section-index a,
  .field-shortcuts a,
  .section-nav a,
  .tool-card-actions a,
  .document-actions a,
  .controller-card-actions a,
  .premium-card-actions a,
  .danfoss-card-actions a,
  .temperature-card-actions a,
  .manual-product-actions a,
  .bench-actions a,
  .bench-symptom-grid a,
  .branch-actions a,
  .silo-actions a,
  .fault-card-bottom a,
  .lean-bottom > a
) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--control-gap);
  padding: 0 var(--control-padding-inline) !important;
  text-decoration: none !important;
}

html body :where(button.icon-button, button.menu-toggle, .inverter-fast-clear) {
  width: var(--control-icon-target) !important;
  min-width: var(--control-icon-target) !important;
  height: var(--control-icon-target) !important;
  min-height: var(--control-icon-target) !important;
  padding: 0 !important;
}

html body :where(
  button.icon-button,
  button.menu-toggle,
  .inverter-fast-clear,
  [data-action-icon]
) :where(svg, img, .refthe-action-icon, .route-icon) {
  width: var(--control-icon-size) !important;
  height: var(--control-icon-size) !important;
  max-width: var(--control-icon-size) !important;
  max-height: var(--control-icon-size) !important;
}

html body :where(summary) {
  box-sizing: border-box;
  min-height: var(--control-height) !important;
  border-radius: var(--control-radius) !important;
  cursor: pointer;
}

/* One ring for keyboard navigation on every section. */
html body :where(
  a[href],
  button,
  input,
  select,
  textarea,
  summary,
  [tabindex]:not([tabindex="-1"])
):focus-visible {
  outline: var(--control-focus-width) solid var(--control-accent) !important;
  outline-offset: var(--control-focus-offset) !important;
  box-shadow: 0 0 0 2px var(--control-surface) !important;
}

@media (hover: hover) {
  html body :where(
    form button,
    button[aria-pressed],
    button[aria-selected],
    [role="button"],
    [role="tab"],
    a.button,
    .btn,
    .case-link,
    .text-action,
    .text-link,
    .guide-open,
    .inverter-fast-chip,
    .tools-path-link,
    .purchase-link,
    .price-link,
    .affiliate-cta,
    .product-action,
    .section-index a,
    .field-shortcuts a,
    .section-nav a,
    .fault-card-bottom a
  ):not(:disabled):not([aria-disabled="true"]):hover {
    border-color: var(--control-accent) !important;
    background-color: var(--control-hover) !important;
    color: var(--control-ink) !important;
    box-shadow: var(--control-shadow) !important;
  }
}

/* Active is visible through colour and a persistent inset mark. */
html body :where(
  button[aria-pressed="true"],
  button[aria-selected="true"],
  [role="tab"][aria-selected="true"],
  .section-index a[aria-current="page"],
  .field-shortcuts a[aria-current="page"],
  .section-nav a[aria-current="page"]
) {
  border-color: var(--control-accent) !important;
  background-color: var(--control-accent) !important;
  color: #fff !important;
  box-shadow: inset 0 calc(-1 * var(--control-active-mark)) 0 rgba(0, 0, 0, .24) !important;
}

html body :where(
  button:disabled,
  input:disabled,
  select:disabled,
  textarea:disabled,
  [aria-disabled="true"]
) {
  border-color: #c7d0ce !important;
  background-color: var(--control-disabled-bg) !important;
  color: var(--control-muted) !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
  opacity: 1 !important;
}

@media (max-width: 720px) {
  html body .primary-nav > a {
    min-height: var(--control-height) !important;
  }
}

/* The locale control is part of the initial HTML. Keep its reserved box out
 * of the large bookmark-nav rules that some legacy headers still apply. */
html body > header nav.site-locale-flags,
html body nav.site-locale-flags[data-locale-control="1"] {
  display: inline-flex !important;
  grid-template-columns: none !important;
  flex: 0 0 216px !important;
  width: 216px !important;
  min-width: 216px !important;
  max-width: 216px !important;
  height: 60px !important;
  min-height: 60px !important;
  max-height: 60px !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 4px !important;
  padding: 5px !important;
}

html body nav.site-locale-flags[data-locale-control="1"] > a[data-locale] {
  flex: 0 0 48px !important;
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  height: 48px !important;
  min-height: 48px !important;
  max-height: 48px !important;
  padding: 0 !important;
  border-radius: var(--control-radius) !important;
}

@media (max-width: 520px) {
  html body > header nav.site-locale-flags,
  html body nav.site-locale-flags[data-locale-control="1"] {
    flex-basis: 208px !important;
    width: 208px !important;
    min-width: 208px !important;
    max-width: 208px !important;
    height: 58px !important;
    min-height: 58px !important;
    max-height: 58px !important;
    gap: 2px !important;
    padding: 4px !important;
  }
}

@media (forced-colors: active) {
  html body :where(button, input, select, textarea, summary, [role="button"], [role="tab"]) {
    border: var(--control-border-width) solid ButtonText !important;
  }
}

/* Field-first fault entry: keep the complete route index, but expose diagnosis
   in the first viewport instead of spending it on a decorative gateway. */
@media (min-width: 851px) {
  html body[class~="faults-page"] > header.site-header {
    display: flex !important;
    min-height: 86px !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 24px !important;
    padding: 10px max(24px, calc((100vw - 1240px) / 2)) !important;
  }

  html body[class~="faults-page"] > header.site-header .header-inner {
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  html body[class~="faults-page"] > header.site-header nav.site-locale-flags {
    margin: 0 !important;
  }

  html body[class~="faults-page"].entry-release .faults-hero {
    padding: 22px 0 28px !important;
  }

  html body[class~="faults-page"] .faults-hero h1 {
    margin: 8px 0 12px !important;
    font-size: clamp(32px, 3.2vw, 44px) !important;
  }

  html body[class~="faults-page"] .faults-hero h1 + p {
    margin-bottom: 14px !important;
  }

  html body[class~="faults-page"] .fault-search-object {
    margin-top: 12px !important;
  }

  html body[class~="faults-page"].entry-release > .entry-switch {
    min-height: 174px !important;
    padding: 92px max(24px, calc((100vw - 1240px) / 2)) 12px !important;
  }

  html body[class~="faults-page"].entry-release > .entry-switch::before {
    inset: 0 0 66px !important;
    background-size: 300px auto !important;
  }

  html body[class~="faults-page"].entry-release > .entry-switch a {
    min-height: 60px !important;
    border-radius: var(--control-radius) !important;
  }
}

@media (min-width: 601px) and (max-width: 850px) {
  html body[class~="faults-page"].entry-release > .entry-switch {
    min-height: 210px !important;
    padding: 68px 18px 12px !important;
  }
}

@media (max-width: 600px) {
  html body[class~="faults-page"].entry-release > .entry-switch {
    min-height: 212px !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    padding: 24px 12px 12px !important;
  }

  html body[class~="faults-page"].entry-release > .entry-switch::before {
    display: none !important;
  }

  html body[class~="faults-page"].entry-release > .entry-switch a {
    min-height: 54px !important;
    padding: 8px 5px !important;
  }

  html body[class~="faults-page"].entry-release > .entry-switch a:nth-of-type(7) {
    grid-column: 2 !important;
  }
}

/* Launch polish · 2026-10-29
 * One restrained visual language for the public release. This layer does not
 * alter routes or layouts: it removes prototype chrome, regularises surfaces
 * and makes field actions readable on a phone. */
:root {
  --launch-paper: #f7f6f1;
  --launch-surface: #fff;
  --launch-ink: #17383a;
  --launch-muted: #5f7472;
  --launch-rule: rgba(23, 79, 74, .18);
  --launch-card-radius: 16px;
  --launch-card-shadow: 0 8px 24px rgba(18, 58, 56, .075);
  --launch-card-shadow-hover: 0 14px 32px rgba(18, 58, 56, .12);
}

/* The shared header already identifies the area. The legacy strip made live
 * pages look like a preview or simulation environment. */
html body > .simulation-bar {
  display: none !important;
}

html body {
  color: var(--launch-ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html body :where(
  .guide-card,
  .tool-card,
  .command-grid > a,
  .document,
  .case,
  .library-shelf-card
) {
  border-color: var(--launch-rule) !important;
  border-radius: var(--launch-card-radius) !important;
  box-shadow: var(--launch-card-shadow) !important;
}

html body :where(.guide-card, .tool-card, .command-grid > a, .document, .case) {
  background-color: var(--launch-surface) !important;
}

@media (hover: hover) {
  html body :where(.guide-card, .tool-card, .command-grid > a, .document, .case):hover {
    border-color: color-mix(in srgb, var(--control-accent) 42%, #d9e4e2) !important;
    box-shadow: var(--launch-card-shadow-hover) !important;
  }
}

html body :where(
  .guide-card p,
  .tool-card-body > p,
  .command-grid p,
  .document p,
  .case p,
  .procedure-body p,
  .procedure-body li
) {
  color: var(--launch-muted);
  font-size: max(1rem, 16px) !important;
  line-height: 1.58 !important;
}

html body :where(
  .lead,
  .tools-hero-lead,
  .release-hero-copy > p,
  .faults-directory-head > p,
  .command-center-head p
) {
  max-width: 68ch;
  font-size: clamp(1rem, 1.25vw, 1.18rem) !important;
  line-height: 1.58 !important;
}

/* Operational links must remain usable with gloves or in poor light. */
html body :where(
  .procedure-body a,
  .document a,
  .affiliate-disclosure a
) {
  display: inline-flex !important;
  min-height: 44px !important;
  align-items: center;
  padding: 8px 12px !important;
  border-radius: 10px;
  font-size: max(.875rem, 14px) !important;
  line-height: 1.3 !important;
}

html body .affiliate-disclosure :where(p, a) {
  font-size: max(.875rem, 14px) !important;
  line-height: 1.5 !important;
}

html body :where(.hub-section-index a, .books-source-note, .book-info small) {
  font-size: max(.875rem, 14px) !important;
  line-height: 1.45 !important;
}

html body :where(.guide-card-meta, .guide-card-link) {
  font-size: max(.875rem, 14px) !important;
  line-height: 1.4 !important;
}

html body[class~="calc-page"] :where(.calc-workspace__heading p, .calc-method p, .calc-method li) {
  font-size: max(.875rem, 14px) !important;
  line-height: 1.55 !important;
}

html body > footer {
  border-top: 1px solid var(--launch-rule);
  background: color-mix(in srgb, var(--launch-paper) 88%, white 12%);
  color: var(--launch-muted);
}

html body > footer a {
  min-height: 44px;
  color: var(--launch-ink);
  text-underline-offset: .22em;
}

/* Audit A5 · operational controls: readable copy and reliable touch targets. */
html .book-library .brand-tile .manual-open {
  font-size: max(.875rem, 14px) !important;
  line-height: 1.25 !important;
}

html body .rf-possibility-source a {
  display: inline-flex !important;
  min-height: 44px !important;
  align-items: center;
  padding: 9px 12px !important;
  font-size: max(.875rem, 14px) !important;
  line-height: 1.35 !important;
}

html .inverter-page > footer a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 8px 4px;
  font-size: max(.875rem, 14px) !important;
  line-height: 1.35;
}

@media (max-width: 620px) {
  :root { --launch-card-radius: 14px; }

  html body :where(.guide-card, .tool-card, .command-grid > a, .document, .case) {
    box-shadow: 0 5px 16px rgba(18, 58, 56, .07) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body :where(.guide-card, .tool-card, .command-grid > a, .document, .case) {
    transition: none !important;
    transform: none !important;
  }
}

