@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=Quicksand:wght@700&display=swap');

/* The site header (views/partials/siteHeader.ejs, and Header.tsx in the
   React workspace). Everything is scoped under .sh and set explicitly,
   because the pages it sits on load Bootstrap 4 or 5, mainUI.css or
   styles.css, whose element rules would otherwise reach in.

   Server-rendered pages fix the bar to the top at 65px, the height their
   layouts already leave room for. The React workspace adds .sh--flow so it
   scrolls with the page. */

.sh {
  --sh-h: 65px;
  --sh-bar: #1F262E;
  --sh-bar-2: #343E49;
  --sh-bar-ink: #C9D1D9;
  --sh-accent: #F2B705;
  --sh-ink: #1B232C;
  --sh-ink-2: #3E4954;
  --sh-muted: #5B6672;
  --sh-line: #D9DEE4;
  --sh-hover: #F3F5F7;
  position: fixed; top: 0; left: 0; right: 0; z-index: 1030;
  display: flex; align-items: center; gap: 20px;
  height: var(--sh-h); padding: 0 24px; box-sizing: border-box;
  background: var(--sh-bar); color: var(--sh-bar-ink);
  font: 400 14px/1.45 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  text-align: left;
}
.sh.sh--flow { position: relative; z-index: 30; }
.sh *, .sh *::before, .sh *::after { box-sizing: border-box; }
.sh ul { list-style: none; margin: 0; padding: 0; }
.sh svg { margin: 0; flex: none; }   /* mainUI.css centers svg with auto margins */
.sh a { text-decoration: none; }
.sh a:hover, .sh a:focus { text-decoration: none; }
.sh button { font: inherit; margin: 0; text-transform: none; -webkit-appearance: none; appearance: none; }
/* Bootstrap outlines every focused button; keep the ring for keyboard use only */
.sh a:focus, .sh button:focus, .sh select:focus { outline: none; }
.sh a:focus-visible, .sh button:focus-visible, .sh select:focus-visible {
  outline: 2px solid var(--sh-accent); outline-offset: 2px;
}

/* wordmark */
.sh .sh-brand { display: flex; align-items: baseline; gap: 8px; flex: none; color: #FFFFFF; }
.sh .sh-brand:hover { color: #FFFFFF; }
.sh .sh-brand-name { font-family: 'Quicksand', 'IBM Plex Sans', sans-serif; font-weight: 700; font-size: 22px; line-height: 1; }
.sh .sh-brand-beta { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sh-accent); }

/* calculator tools (File menu, code edition, units) */
.sh .sh-tools { display: flex; align-items: center; gap: 10px; flex: none; }
.sh .sh-tools .droop { margin: 0; width: auto; flex-direction: row; }
.sh .sh-tools .droop .nav-link { color: var(--sh-bar-ink); padding: 8px 12px; border-radius: 6px; font-size: 14px; font-weight: 500; }
.sh .sh-tools .droop .nav-link:hover,
.sh .sh-tools .droop .nav-link:focus,
.sh .sh-tools .droop .show > .nav-link { color: #FFFFFF !important; background: var(--sh-bar-2); }   /* !important: mainUI.css a.drop:hover */
.sh select.closet1 {
  height: 34px; margin: 0; padding: 0 28px 0 10px;
  border: 1px solid #4A5562; border-radius: 6px;
  background: #2A333D url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23C9D1D9' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center;
  color: #E4E8EC; font: 400 13px 'IBM Plex Sans', sans-serif;
  -webkit-appearance: none; appearance: none; cursor: pointer;
}
.sh .sh-tools select.droop1 { width: 9.5em !important; }
.sh select.closet1 option { color: var(--sh-ink); background: #FFFFFF; }
.sh .sh-panel-tools { display: none; }

/* main links */
.sh .sh-panel { display: contents; }
.sh .sh-panel-head, .sh .sh-burger, .sh .sh-backdrop { display: none; }
.sh .sh-nav { display: flex; margin-left: auto; }
.sh--calc .sh-nav { margin-left: auto; }
.sh .sh-links { display: flex; align-items: center; gap: 2px; }
.sh .sh-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px;
  border: 0; border-radius: 6px; background: none; cursor: pointer;
  color: var(--sh-bar-ink); font-size: 14px; font-weight: 500; line-height: 1.2; white-space: nowrap;
}
.sh .sh-link:hover, .sh .sh-drop.is-open > .sh-link { color: #FFFFFF; background: var(--sh-bar-2); }
.sh .sh-link.is-active { color: #FFFFFF; background: var(--sh-bar-2); font-weight: 600; }
.sh .sh-chev { transition: transform .15s ease; }
.sh .sh-drop.is-open .sh-chev { transform: rotate(180deg); }

/* dropdowns (Resources, account) */
.sh .sh-drop { position: relative; }
.sh .sh-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 1040;
  min-width: 200px; padding: 6px; display: flex; flex-direction: column;
  background: #FFFFFF; border: 1px solid var(--sh-line); border-radius: 8px;
  box-shadow: 0 10px 28px rgba(27, 35, 44, 0.16);
}
/* closed unless the dropdown is open (a class, not [hidden]: Bootstrap makes
   [hidden] !important, and the phone panel lists the account menu open) */
.sh .sh-drop > .sh-menu { display: none; }
.sh .sh-drop.is-open > .sh-menu { display: flex; }
/* both menus sit near the right edge of the bar, so they open leftward */
.sh .sh-links .sh-menu { left: auto; right: 0; }
.sh .sh-menu--right { left: auto; right: 0; min-width: 230px; }
.sh .sh-item {
  display: flex; align-items: center; min-height: 38px; padding: 0 12px; border-radius: 6px;
  color: var(--sh-ink); font-size: 14px; font-weight: 500; white-space: nowrap;
}
.sh .sh-item:hover, .sh .sh-item:focus { color: var(--sh-ink); background: var(--sh-hover); }
.sh .sh-who { display: flex; flex-direction: column; padding: 8px 12px 10px; margin-bottom: 4px; border-bottom: 1px solid #EDF0F3; }
.sh .sh-who strong { color: var(--sh-ink); font-weight: 600; font-size: 14px; }
.sh .sh-who span { color: var(--sh-muted); font-size: 12px; overflow-wrap: anywhere; }

/* account and login */
.sh .sh-auth { display: flex; align-items: center; gap: 8px; flex: none; }
.sh .sh-avatar {
  width: 38px; height: 38px; border: 0; border-radius: 50%; padding: 0; cursor: pointer;
  background: var(--sh-accent); color: var(--sh-ink); font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.sh .sh-btn {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 6px;
  border: 1px solid #5B6672; color: #FFFFFF; font-weight: 500; font-size: 14px; white-space: nowrap;
}
.sh .sh-btn:hover { color: #FFFFFF; border-color: #8A949E; }
.sh .sh-btn--primary { background: var(--sh-accent); border-color: var(--sh-accent); color: var(--sh-ink); font-weight: 600; }
.sh .sh-btn--primary:hover { color: var(--sh-ink); background: #FFC926; border-color: #FFC926; }

/* ---- phone and tablet: the links move into a panel behind a menu button ---- */
@media (max-width: 860px) {
  .sh:not(.sh--calc) { padding: 0 8px 0 16px; }
  .sh:not(.sh--calc) .sh-burger { display: inline-flex; }
  .sh:not(.sh--calc) .sh-panel { display: none; }
  .sh:not(.sh--calc).is-open .sh-panel { display: flex; }
  .sh:not(.sh--calc).is-open .sh-backdrop { display: block; }
}
@media (max-width: 1200px) {
  .sh--calc { padding: 0 8px 0 16px; gap: 12px; }
  .sh--calc .sh-burger { display: inline-flex; }
  .sh--calc .sh-panel { display: none; }
  .sh--calc.is-open .sh-panel { display: flex; }
  .sh--calc.is-open .sh-backdrop { display: block; }
}
.sh .sh-burger {
  margin-left: auto; width: 44px; height: 44px; align-items: center; justify-content: center;
  border: 0; border-radius: 6px; background: none; color: #FFFFFF; cursor: pointer; flex: none;
}
.sh .sh-backdrop { position: fixed; inset: var(--sh-h) 0 0 0; background: rgba(15, 20, 26, 0.45); z-index: 1040; }
.sh.is-open .sh-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 1050;
  width: 320px; max-width: 88vw; overflow-y: auto;
  flex-direction: column; background: #FFFFFF; color: var(--sh-ink);
  box-shadow: -4px 0 24px rgba(15, 20, 26, 0.25);
}
.sh.is-open .sh-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--sh-h); padding: 0 8px 0 20px; border-bottom: 1px solid var(--sh-line); flex: none;
}
.sh.is-open .sh-panel-head span { font-weight: 600; font-size: 16px; }
.sh .sh-panel-close {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 6px; background: none; color: var(--sh-ink-2); cursor: pointer;
}
.sh.is-open .sh-panel-tools { display: none; flex-direction: column; gap: 10px; padding: 16px 20px; border-bottom: 1px solid #EDF0F3; }
.sh.is-open .sh-panel-tools select.closet1 { width: 100% !important; height: 40px; background-color: #FFFFFF; color: var(--sh-ink); border-color: #C5CCD4; display: block; margin: 0; }
.sh.is-open .sh-nav { margin: 0; display: block; }
.sh.is-open .sh-links { flex-direction: column; align-items: stretch; gap: 0; }
.sh.is-open .sh-link {
  width: 100%; min-height: 50px; padding: 0 20px; border-radius: 0; justify-content: space-between;
  color: var(--sh-ink); font-size: 16px; border-bottom: 1px solid #EDF0F3;
}
.sh.is-open .sh-link:hover, .sh.is-open .sh-drop.is-open > .sh-link { color: var(--sh-ink); background: var(--sh-hover); }
.sh.is-open .sh-link.is-active { color: var(--sh-ink); background: none; box-shadow: inset 3px 0 0 var(--sh-accent); }
.sh.is-open .sh-menu {
  position: static; min-width: 0; padding: 4px 0; border: 0; border-radius: 0; box-shadow: none;
  background: #F8F9FA; border-bottom: 1px solid #EDF0F3;
}
.sh.is-open .sh-item { min-height: 44px; padding: 0 20px 0 36px; border-radius: 0; color: var(--sh-ink-2); font-size: 15px; font-weight: 400; }
.sh.is-open .sh-auth { margin-top: auto; padding: 16px 20px 24px; border-top: 1px solid var(--sh-line); flex-wrap: wrap; }
.sh.is-open .sh-btn { flex: 1 1 0; justify-content: center; min-height: 44px; color: var(--sh-ink); border-color: #C5CCD4; }
.sh.is-open .sh-btn--primary { border-color: var(--sh-accent); }
/* in the panel the account menu is simply listed, not a dropdown */
.sh.is-open .sh-account { width: 100%; }
.sh.is-open .sh-account .sh-avatar { display: none; }
.sh.is-open .sh-account > .sh-menu { display: flex; background: none; border: 0; padding: 0; margin: 0 -20px; }
.sh.is-open .sh-account .sh-who { padding: 0 20px 10px; border: 0; }
.sh.is-open .sh-account .sh-item { padding-left: 20px; }

/* phones: the code and units selects leave the bar for the panel */
@media (max-width: 560px) {
  .sh .sh-tools select.droop1 { display: none; }
  .sh.is-open .sh-panel-tools { display: flex; }
  .sh .sh-brand-name { font-size: 19px; }
  .sh--calc .sh-brand-beta { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sh .sh-chev { transition: none; }
}
