/*
 * MATAMET interaction and accessibility recovery 1.4.3
 * Scope: Materials Library card states, Steel Lab home layout, focus,
 * reduced motion and high-contrast support. No global viewport geometry.
 */

/* --------------------------------------------------------------------------
   1. Materials Library: legible selected, hover and keyboard-focus states
   -------------------------------------------------------------------------- */
body.matamet-route--materials-library .immes-ref-class-card {
  color: #151719 !important;
  transition: border-color 140ms ease, background-color 140ms ease,
    box-shadow 140ms ease, transform 140ms ease !important;
}
body.matamet-route--materials-library .immes-ref-class-card strong {
  color: #151719 !important;
  font-size: clamp(.98rem, .92rem + .12vw, 1.08rem) !important;
  line-height: 1.27 !important;
}
body.matamet-route--materials-library .immes-ref-class-card p {
  color: #40545a !important;
  font-size: .875rem !important;
  line-height: 1.5 !important;
}
body.matamet-route--materials-library .immes-ref-class-card small {
  color: #123F46 !important;
  font-size: .78rem !important;
}
body.matamet-route--materials-library .immes-ref-class-card:not(.is-active):hover,
body.matamet-route--materials-library .immes-ref-class-card:not(.is-active):focus-visible {
  background: #E8DDD2 !important;
  border-color: #C7653B !important;
  color: #151719 !important;
  box-shadow: 0 8px 22px rgba(21, 23, 25, .08) !important;
}
body.matamet-route--materials-library .immes-ref-class-card:not(.is-active):hover :where(strong, p, small),
body.matamet-route--materials-library .immes-ref-class-card:not(.is-active):focus-visible :where(strong, p, small) {
  color: inherit !important;
}
body.matamet-route--materials-library .immes-ref-class-card.is-active,
body.matamet-route--materials-library .immes-ref-class-card.is-active:hover,
body.matamet-route--materials-library .immes-ref-class-card.is-active:focus-visible {
  background: #123F46 !important;
  border-color: #C7653B !important;
  color: #FFFFFF !important;
  box-shadow: inset 0 -3px 0 #C7653B !important;
}
body.matamet-route--materials-library .immes-ref-class-card.is-active :where(strong, p, small) {
  color: #FFFFFF !important;
}
body.matamet-route--materials-library .immes-ref-class-card.is-active .immes-ref-class-mark {
  background: rgba(255,255,255,.14) !important;
  border-color: rgba(255,255,255,.34) !important;
  color: #FFFFFF !important;
}
body.matamet-route--materials-library .immes-ref-class-card.is-active small {
  background: rgba(255,255,255,.14) !important;
}
body.matamet-route--materials-library :where(
  .immes-ref-class-card,
  .immes-ref-collection-card,
  .immes-process-card,
  .immes-ref-family-link,
  .immes-ref-searchbar button,
  .immes-ref-mode-bar button
) {
  min-block-size: 44px;
}

/* --------------------------------------------------------------------------
   2. Steel Lab: remove theme wrapper gaps and balance unequal category cards
   -------------------------------------------------------------------------- */
body.matamet-route--steel-lab .page-main,
body.immes-steel-virtual-lab-page .page-main {
  inline-size: 100% !important;
  max-inline-size: none !important;
  min-block-size: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}
body.matamet-route--steel-lab .page-shell,
body.immes-steel-virtual-lab-page .page-shell,
body.matamet-route--steel-lab .entry-content,
body.immes-steel-virtual-lab-page .entry-content {
  inline-size: 100% !important;
  max-inline-size: none !important;
  min-block-size: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}
body.matamet-route--steel-lab .matamet-app-intro--compact,
body.immes-steel-virtual-lab-page .matamet-app-intro--compact {
  display: none !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab {
  inline-size: min(calc(100% - 24px), 1560px) !important;
  max-inline-size: 1560px !important;
  min-block-size: 0 !important;
  margin: 12px auto 18px !important;
  background: #F6F3EC !important;
  font-size: 15px !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab :where(.svl-app, .svl-home-app, .svl-home-main, .svl-home),
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab :where(.svl-app, .svl-home-app, .svl-home-main, .svl-home) {
  min-block-size: 0 !important;
  block-size: auto !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-main,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-main {
  max-inline-size: 1560px !important;
  padding: 16px 16px 18px !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home {
  gap: 14px !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-library-section,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-library-section {
  margin: 0 !important;
  padding: 18px !important;
  background: #F6F3EC !important;
  border-color: #D8D1C7 !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-library-section > header,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-library-section > header {
  margin-block-end: 14px !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-library-section h2,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-library-section h2 {
  color: #123F46 !important;
  font-family: var(--matamet-font-display, "Newsreader", Georgia, serif) !important;
  font-size: clamp(1.55rem, 1.35rem + .55vw, 2rem) !important;
  font-weight: 500 !important;
  line-height: 1.08 !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-library-section header p,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-library-section header p {
  color: #556267 !important;
  font-size: .875rem !important;
  line-height: 1.5 !important;
}

/* CSS columns preserve source/focus order while balancing unequal card heights. */
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-family-grid,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family-grid {
  display: block !important;
  columns: 3 310px;
  column-gap: 14px !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-family,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family {
  display: inline-block !important;
  inline-size: 100% !important;
  margin: 0 0 14px !important;
  break-inside: avoid !important;
  vertical-align: top !important;
  overflow: hidden !important;
  background: #FEFDF9 !important;
  border-color: #D8D1C7 !important;
  border-radius: 10px !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-family > header,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family > header {
  min-block-size: 64px !important;
  padding: 12px 13px !important;
  background: linear-gradient(100deg, #E8DDD2 0%, #DDE7E5 100%) !important;
  border-block-end-color: #D8D1C7 !important;
  box-shadow: inset 3px 0 0 #C7653B !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-family > header > span,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family > header > span {
  color: #A54D2C !important;
  font-size: 1.05rem !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-family header h2,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family header h2 {
  color: #123F46 !important;
  font-family: var(--matamet-font-body, "Gabarito", Arial, sans-serif) !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-family header small,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family header small {
  color: #5B686C !important;
  font-size: .75rem !important;
  line-height: 1.25 !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-family button,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family button {
  min-block-size: 60px !important;
  padding: 9px 12px !important;
  background: #FEFDF9 !important;
  border-block-end-color: #D8D1C7 !important;
  color: #151719 !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-family button b,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family button b {
  color: #151719 !important;
  font-size: .9rem !important;
  line-height: 1.3 !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-family button small,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family button small {
  color: #5F6C70 !important;
  font-size: .76rem !important;
  line-height: 1.35 !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-process-code,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-process-code {
  min-inline-size: 42px !important;
  block-size: 34px !important;
  background: #DDE7E5 !important;
  color: #123F46 !important;
  font-size: .68rem !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-family button:hover,
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-family button:focus-visible,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family button:hover,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family button:focus-visible {
  background: #DDE7E5 !important;
  color: #151719 !important;
  box-shadow: inset 3px 0 0 #C7653B !important;
}
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-family button:hover :where(b, small),
body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-family button:focus-visible :where(b, small),
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family button:hover :where(b, small),
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family button:focus-visible :where(b, small) {
  color: inherit !important;
}
body.matamet-route--steel-lab .site-footer,
body.immes-steel-virtual-lab-page .site-footer {
  margin-block-start: 0 !important;
}

/* --------------------------------------------------------------------------
   3. Keyboard, motion and high-contrast accessibility safeguards
   -------------------------------------------------------------------------- */
body.matamet-platform :where(a, button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 3px solid #C7653B !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 2px #F6F3EC !important;
}
body.matamet-platform :where(h1, h2, h3, [id]) { scroll-margin-block-start: 110px; }
body.matamet-platform :where(p, li, dd, td, th, label, button, a) {
  overflow-wrap: break-word;
}
body.matamet-platform ::selection { background: #C7653B; color: #151719; }

@media (hover: hover) and (pointer: fine) {
  body.matamet-route--materials-library .immes-ref-class-card:not(.is-active):hover {
    transform: translateY(-2px) !important;
  }
}
@media (max-width: 980px) {
  body.matamet-route--steel-lab #immes-steel-virtual-lab,
  body.immes-steel-virtual-lab-page #immes-steel-virtual-lab {
    inline-size: calc(100% - 16px) !important;
    margin-block-start: 8px !important;
  }
  body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-family-grid,
  body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family-grid {
    columns: 2 280px;
  }
}
@media (max-width: 640px) {
  body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-main,
  body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-main {
    padding: 10px 8px 14px !important;
  }
  body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-library-section,
  body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-library-section {
    padding: 14px !important;
  }
  body.matamet-route--steel-lab #immes-steel-virtual-lab .svl-home-family-grid,
  body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family-grid {
    columns: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  html:focus-within { scroll-behavior: auto !important; }
  body.matamet-platform *,
  body.matamet-platform *::before,
  body.matamet-platform *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
  body.matamet-route--materials-library .immes-ref-class-card,
  body.matamet-route--steel-lab #immes-steel-virtual-lab button,
  body.immes-steel-virtual-lab-page #immes-steel-virtual-lab button {
    transform: none !important;
  }
}
@media (prefers-contrast: more) {
  body.matamet-platform :where(button, input, select, textarea, summary, .immes-ref-class-card, .svl-home-family) {
    border-width: 2px !important;
  }
}
@media (forced-colors: active) {
  body.matamet-platform :where(a, button, input, select, textarea, summary, .immes-ref-class-card, .svl-home-family) {
    forced-color-adjust: auto;
  }
  body.matamet-platform :where(a, button, input, select, textarea, summary):focus-visible {
    outline: 3px solid Highlight !important;
    box-shadow: none !important;
  }
}


/* --------------------------------------------------------------------------
   4. Exact defect recovery 1.4.4
   - Library card contrast independent of route/body-class detection.
   - Steel Lab process abbreviations stay on one line.
   - Metallurgy local route bar never follows the global header.
   -------------------------------------------------------------------------- */

/* Materials Library: use the application root so archive and page contexts
   receive identical interaction contrast. */
#immes-materials-library .immes-ref-class-card:not(.is-active),
.immes-materials-library-page #immes-materials-library .immes-ref-class-card:not(.is-active) {
  color: #151719 !important;
}
#immes-materials-library .immes-ref-class-card:not(.is-active) :where(strong, p, small),
.immes-materials-library-page #immes-materials-library .immes-ref-class-card:not(.is-active) :where(strong, p, small) {
  color: inherit !important;
}
#immes-materials-library .immes-ref-class-card:not(.is-active):is(:hover, :focus-visible),
.immes-materials-library-page #immes-materials-library .immes-ref-class-card:not(.is-active):is(:hover, :focus-visible) {
  background: #E8DDD2 !important;
  border-color: #C7653B !important;
  color: #151719 !important;
  box-shadow: 0 8px 22px rgba(21, 23, 25, .09) !important;
}
#immes-materials-library .immes-ref-class-card:not(.is-active):is(:hover, :focus-visible) .immes-ref-class-mark,
.immes-materials-library-page #immes-materials-library .immes-ref-class-card:not(.is-active):is(:hover, :focus-visible) .immes-ref-class-mark {
  background: #DDE7E5 !important;
  border-color: #9FB7B3 !important;
  color: #123F46 !important;
}
#immes-materials-library .immes-ref-class-card.is-active,
#immes-materials-library .immes-ref-class-card.is-active:is(:hover, :focus-visible),
.immes-materials-library-page #immes-materials-library .immes-ref-class-card.is-active,
.immes-materials-library-page #immes-materials-library .immes-ref-class-card.is-active:is(:hover, :focus-visible) {
  background: #123F46 !important;
  border-color: #C7653B !important;
  color: #FFFFFF !important;
  box-shadow: inset 0 -3px 0 #C7653B !important;
}
#immes-materials-library .immes-ref-class-card.is-active :where(strong, p, small),
.immes-materials-library-page #immes-materials-library .immes-ref-class-card.is-active :where(strong, p, small) {
  color: #FFFFFF !important;
}
#immes-materials-library .immes-ref-class-card.is-active .immes-ref-class-mark,
.immes-materials-library-page #immes-materials-library .immes-ref-class-card.is-active .immes-ref-class-mark {
  background: rgba(255,255,255,.15) !important;
  border-color: rgba(255,255,255,.38) !important;
  color: #FFFFFF !important;
}
#immes-materials-library .immes-ref-family-link:is(:hover, :focus-visible),
#immes-materials-library .immes-ref-family-group button:is(:hover, :focus-visible) {
  background: #DDE7E5 !important;
  color: #123F46 !important;
  border-color: #2F6268 !important;
}

/* Steel Lab: abbreviations are labels, not wrapping prose. */
#immes-steel-virtual-lab .svl-home-family button,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-family button {
  grid-template-columns: max-content minmax(0, 1fr) 14px !important;
}
#immes-steel-virtual-lab .svl-home-process-code,
body.immes-steel-virtual-lab-page #immes-steel-virtual-lab .svl-home-process-code {
  inline-size: auto !important;
  min-inline-size: 52px !important;
  max-inline-size: none !important;
  block-size: 34px !important;
  padding-inline: 8px !important;
  white-space: nowrap !important;
  overflow: visible !important;
  overflow-wrap: normal !important;
  word-break: keep-all !important;
  hyphens: none !important;
  font-size: .7rem !important;
  line-height: 1 !important;
  letter-spacing: 0 !important;
}

/* The four-item Metallurgy route bar is local navigation. Only the site header
   may remain sticky. The JS marker handles database-generated markup safely. */
body.matamet-route--metallurgy .matamet-metallurgy-local-nav,
body.matamet-route--metallurgy .matamet-metallurgy-local-nav-shell,
body.matamet-route--metallurgy .matamet-metallurgy-local-nav-sticky,
body.immes-metallurgy-page .matamet-metallurgy-local-nav,
body.immes-metallurgy-page .matamet-metallurgy-local-nav-shell,
body.immes-metallurgy-page .matamet-metallurgy-local-nav-sticky {
  position: static !important;
  inset: auto !important;
  inset-block-start: auto !important;
  top: auto !important;
  transform: none !important;
  translate: none !important;
  z-index: auto !important;
}
