/* Tools menu in the site header (tools-menu.js). A disclosure: one button that shows or hides a list of links.
   Loaded on every public page right after a11y.css. Only tokens from styles.css. Without JavaScript the button is a
   link to #tm-list and the list opens with :target, so the tools stay reachable. */

.tm { display: flex; }                                   /* sits first in .nav-cta, left of the header buttons */
.tm-btn {
  display: inline-flex; align-items: center; gap: 9px; min-height: 44px; padding: 0 12px;
  background: none; border: 1px solid transparent; border-radius: var(--r-sm); color: var(--muted);
  font: 500 .90625rem/1 var(--sans); letter-spacing: 0; white-space: nowrap; cursor: pointer;
  transition: color .2s, border-color .2s, background-color .2s;
}
.tm-btn::after {                                         /* caret, drawn with two borders */
  content: ""; width: 7px; height: 7px; margin-top: -4px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg); transition: transform .2s var(--ease);
}
.tm-btn:hover, .tm-open .tm-btn, .tm:has(.tm-panel:target) .tm-btn { color: var(--text); border-color: var(--line2); }
.tm-open .tm-btn { background: rgba(255,255,255,.05); }
.tm-open .tm-btn::after { margin-top: 3px; transform: rotate(-135deg); }

/* The list hangs from the header (position: sticky makes it the containing block), right-aligned to the gutter. */
.tm-panel {
  position: absolute; top: 100%; right: var(--gut); z-index: 5; width: 372px; max-width: calc(100vw - 2 * var(--gut));
  margin-top: 1px; background: var(--bg2); border: 1px solid var(--line2); border-top: 2px solid var(--hot);
}
.tm-list { list-style: none; margin: 0; padding: 6px 0; }
.tm-list li + li { border-top: 1px solid var(--line); }
.tm-list .tm-rq { margin-top: 6px; border-top-color: var(--line2); }
.tm-list a {
  display: grid; gap: 4px; min-height: 44px; padding: 11px 16px 12px 13px; border-left: 3px solid transparent;
  color: var(--text); text-decoration: none; transition: background-color .15s, border-color .15s;
}
.tm-list b { font: 600 .9375rem/1.25 var(--sans); }
.tm-list span { font: 400 .84375rem/1.4 var(--sans); color: var(--muted); }
.tm-list a:hover { background: var(--card2); border-left-color: var(--line2); }
.tm-list a:focus-visible { outline-offset: -2px; background: var(--card2); }
.tm-list a[aria-current="page"] { border-left-color: var(--hot); background: rgba(255,106,19,.06); }
.tm-list a[aria-current="page"] b { color: var(--hot2); }

/* No JavaScript (and before tools-menu.js runs): closed until the link targets it. */
html:not(.tm-js) .tm-panel { display: none; }
html:not(.tm-js) .tm-panel:target { display: block; }
.tm-btn:focus-visible { outline-offset: 0; }

@media (prefers-reduced-motion: no-preference) {
  .tm-open .tm-panel { animation: tm-in .16s var(--ease); }
}
@keyframes tm-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .tm-btn, .tm-btn::after, .tm-list a { transition: none; }
}

/* Phones: a compact bordered "Tools" button beside the header buttons; the list spans the screen under the header. */
@media (max-width: 480px) {
  .tm-btn { min-width: 44px; padding: 0 6px; justify-content: center; border-color: var(--line2); font: 600 .875rem/1 var(--display); letter-spacing: .06em; text-transform: uppercase; }   /* same face as Reorder and Get a quote beside it */
  .tm-btn::after { display: none; }
  .tm-panel { left: 0; right: 0; width: auto; max-width: none; border-left: 0; border-right: 0; max-height: calc(100vh - 120px); overflow-y: auto; }
  .tm-list a { padding: 12px var(--gut) 13px calc(var(--gut) - 3px); }
}
@media (max-width: 400px) { .nav { column-gap: 6px; } }        /* so the logo, Tools, Reorder and Get a quote share one row at 375 */

/* Too tight for one row (tools-menu.js measures and sets .tm-tight; without JS the narrowest phones get this):
   the logo and the buttons keep the first row and Tools becomes a full-width row under them. */
.nav.tm-tight { flex-wrap: wrap; column-gap: 6px; }
.nav.tm-tight .nav-cta { display: contents; }
.nav.tm-tight .brand { margin-right: auto; }
.nav.tm-tight .tm { order: 9; flex: 1 0 100%; margin: 8px calc(-1 * var(--gut)) -8px; border-top: 1px solid var(--line); }
.nav.tm-tight .tm-btn { width: 100%; justify-content: space-between; padding: 0 var(--gut); border: 0; border-radius: 0; font-size: .90625rem; }
.nav.tm-tight .tm-btn::after { display: block; margin-right: 4px; }
@media (max-width: 389px) {
  html:not(.tm-js):not(.js) .nav:has(.tm) { flex-wrap: wrap; column-gap: 6px; }
  html:not(.tm-js):not(.js) .nav:has(.tm) .nav-cta { display: contents; }
  html:not(.tm-js):not(.js) .nav:has(.tm) .brand { margin-right: auto; }
  html:not(.tm-js):not(.js) .nav .tm { order: 9; flex: 1 0 100%; margin: 8px calc(-1 * var(--gut)) -8px; border-top: 1px solid var(--line); }
  html:not(.tm-js):not(.js) .nav .tm-btn { width: 100%; justify-content: flex-start; padding: 0 var(--gut); border: 0; border-radius: 0; font-size: .90625rem; }
}

@media print { .tm { display: none; } }
