/* WMOL Tools — final scroll/heading polish (v10, November 10 2026)
   Scoped to /tools/. Does not alter existing product cards, card sizing,
   rail proportions, portrait columns, page transitions or other routes.
   Keep the original browser zoom: title + copy stay visible while the
   grid scrolls inside the frame, with the scrollbar at the frame's edge. */

/* HSK's black underline was left behind when the other HSK colors changed. */
#wmol-tools.tools-layout > .tools-hub[data-hub-theme="hsk"] .tools-hub-title::after,
#wmol-tools.tools-layout[data-hub-theme="hsk"] > .tools-hub .tools-hub-title::after {
  background: rgba(212,175,55,.90) !important;
}

/* Desktop browsers and large portrait monitors. Don't change mobile phone
   behavior: mobile retains its native scrolling, viewport widths and zoom. */
@media (min-width:701px) {
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout > .tools-hub {
    display:flex !important;
    flex-direction:column !important;
    overflow:hidden !important;
  }
  /* The Back control remains at the top, outside of the scroll region. */
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout > .tools-hub > .tools-back {
    flex:0 0 auto !important;
  }
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout > .tools-hub > .tools-hub-density-surface {
    display:flex !important;
    flex-direction:column !important;
    flex:1 1 auto !important;
    height:auto !important;
    min-height:0 !important;
    max-height:100% !important;
    overflow:hidden !important;
    /* v9 remains the sole owner of card/typography sizes. */
  }
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout .tools-hub-density-surface > .tools-hub-hero {
    flex:0 0 auto !important;
    min-height:0 !important;
    margin-bottom:0 !important; /* avoid doubling the old adjoining margins */
  }
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout .tools-hub-density-surface > .tools-grid {
    flex:1 1 auto !important;
    min-height:0 !important;
    max-height:none !important;
    overflow-y:auto !important;
    overflow-x:hidden !important;
    overscroll-behavior:contain;
    align-content:start !important;
    grid-auto-rows:max-content !important; /* never clip longer card descriptions */
    padding-bottom:24px !important;
    scrollbar-gutter:stable;
    scrollbar-width:thin;
    scrollbar-color:#aa8065 #e6d3c3;
  }
  /* Keep visible keyboard focus for the scrollable card region. */
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout .tools-hub-density-surface > .tools-grid:focus-visible {
    outline:2px solid rgba(212,175,55,.9) !important;
    outline-offset:-2px !important;
  }
  /* Chromium/Edge scrollbar: warm brown track inside the board's right edge. */
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout .tools-hub-density-surface > .tools-grid::-webkit-scrollbar {width:10px;}
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout .tools-hub-density-surface > .tools-grid::-webkit-scrollbar-track {background:#e6d3c3;border-radius:9px;}
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout .tools-hub-density-surface > .tools-grid::-webkit-scrollbar-thumb {background:#aa8065;border-radius:9px;border:2px solid #e6d3c3;}
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout .tools-hub-density-surface > .tools-grid::-webkit-scrollbar-thumb:hover {background:#765440;}
}

/* Landscape: move the scrollbar out to the inner edge of the board without
   shifting the columns or the title. This consumes the existing right padding;
   it does not scale the grid or the cream/brown frame. */
@media (min-width:901px) and (orientation:landscape) {
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout {
    --tools-v10-scroll-bleed:clamp(26px,2.2vw,48px);
  }
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout .tools-hub-density-surface > .tools-grid {
    box-sizing:border-box !important;
    width:calc(100% + var(--tools-v10-scroll-bleed)) !important;
    max-width:none !important;
    margin-right:calc(-1 * var(--tools-v10-scroll-bleed)) !important;
    padding-right:var(--tools-v10-scroll-bleed) !important;
  }
}

/* Short browser windows need the ordinary board scroll as a fall-back.
   Otherwise an unusually tall intro could leave no space to reach cards. */
@media (min-width:701px) and (max-height:600px) {
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout > .tools-hub {overflow-y:auto !important;}
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout > .tools-hub > .tools-hub-density-surface {flex:0 0 auto !important;max-height:none !important;overflow:visible !important;}
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout .tools-hub-density-surface > .tools-grid {flex:0 0 auto !important;min-height:auto !important;overflow:visible !important;}
}

/* Portrait desktop: no unused scrollbar gutter or changed card dimensions when the
   whole three-column grid already fits without needing to scroll. */
@media (min-width:701px) and (orientation:portrait) {
  html:root:not(.wmol-phone-device) #wmol-tools.tools-layout .tools-hub-density-surface > .tools-grid {
    scrollbar-gutter:auto !important;
  }
}
