/* Grinding Advisor — dial navigation (replaces the hamburger dropdown).
   A graduated instrument dial: sections own equal segments, pages ride two
   inner rings, search floats over the face. All classes are dn- prefixed.
   Revert: remove the dial-nav.css/dial-nav.js tags from the pages and the
   classic .mobile-menu takes over again (its toggle handler is untouched
   until this script successfully initializes). */

/* The dial takes over navigation: once it has initialized (html.dn-on), the
   header's Search button and hamburger leave the header entirely. A floating
   mini dial-face button at bottom-center is the menu opener on every page. */
html.dn-on .site-header .nav-toggle,
html.dn-on .site-header .search-btn { display: none !important; }

.dn-fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 280;
  width: 72px; height: 72px; border-radius: 50%; border: 0; padding: 0;
  background: transparent; cursor: pointer;
  filter: drop-shadow(0 8px 20px rgba(19, 26, 35, .35));
}
.dn-fab svg { display: block; width: 100%; height: 100%; }
.dn-fab:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

.dn-peek {
  position: fixed; top: 0; left: 0; right: 0; height: 16vh; z-index: 290;
  display: none; cursor: pointer;
}
.dn-peek.on { display: block; }

.dn-overlay {
  position: fixed; left: 0; right: 0; bottom: 0; top: 16vh; z-index: 300;
  background: transparent;
  display: flex; flex-direction: column; touch-action: none;
  color-scheme: light;
}
.dn-overlay[hidden] { display: none; }
.dn-window { position: relative; width: 100%; overflow: hidden; flex: 1; cursor: grab; }
.dn-window.grabbing { cursor: grabbing; }
.dn-window svg { position: absolute; display: block; }
.dn-needle {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 6; pointer-events: none;
  width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent;
  border-top: 12px solid var(--amber);
}
.dn-needle-line {
  position: absolute; left: -1.5px; top: 2px; width: 3px; height: 40px; background: var(--amber);
}

/* search: a bare stadium — tap it and it opens to the top of the face, with
   the magnifier at the right end acting as the search (enter) button */
.dn-search {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 8;
  width: 64px; height: 48px; display: flex; align-items: center; gap: 0;
  padding: 0 8px 0 10px; background: var(--paper); cursor: text;
  border: 1px solid var(--steel-300); border-radius: 24px;
  box-shadow: 0 14px 34px rgba(19, 26, 35, .35), inset 0 1px 0 #ffffff, inset 0 -2px 4px rgba(19, 26, 35, .10);
  transition: width .3s ease, top .3s ease;
}
.dn-search input {
  display: none; flex: 0 0 0; min-width: 0; width: 0; height: 46px; border: 0; padding: 0 4px; font: inherit; font-size: 16px;
  background: transparent; color: var(--steel-900); touch-action: auto; opacity: 0; pointer-events: none;
  -webkit-appearance: none; appearance: none; border-radius: 0; transition: opacity .2s ease;
}
.dn-go {
  flex: 0 0 auto; width: 38px; height: 38px; margin: 0 auto; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 50%; color: var(--steel-500); cursor: pointer;
}
.dn-search.open { width: min(470px, 94vw); padding: 0 8px 0 18px; gap: 8px; outline: 2px solid var(--amber); outline-offset: 2px; cursor: default; }
.dn-search.open input { display: block; flex: 1; width: auto; opacity: 1; pointer-events: auto; }
.dn-search.open .dn-go { margin: 0 0 0 auto; color: var(--amber-ink); }
.dn-search input:focus { outline: none; }

/* search results (same spare format as the site search: filepath + match in context) */
.dn-results {
  position: absolute; left: 50%; transform: translateX(-50%); top: 76px; z-index: 7;
  width: min(470px, 94vw); max-height: calc(100% - 92px); overflow-y: auto; touch-action: pan-y;
  background: var(--paper); border: 1px solid var(--steel-300); box-shadow: 0 18px 40px rgba(19, 26, 35, .4);
  display: none;
}
.dn-results.show { display: block; }
.dn-results a {
  display: flex; flex-direction: column; gap: 2px; padding: 11px 14px; min-height: 48px;
  border-bottom: 1px solid var(--steel-100); text-decoration: none;
}
.dn-results a:last-child { border-bottom: 0; }
.dn-results a:hover, .dn-results a:active { background: var(--steel-050); }
.dn-results .dn-r-path { font-family: var(--mono); font-size: 12px; color: var(--amber-ink); word-break: break-all; }
.dn-results .dn-r-excerpt { font-size: 13.5px; color: var(--steel-700); line-height: 1.45; }
.dn-results .dn-r-excerpt mark { background: transparent; color: var(--amber-ink); font-weight: 700; }
.dn-results .dn-r-empty { padding: 14px; font-size: 14px; color: var(--steel-500); margin: 0; }

/* SVG dial text — full-strength on the off-white face; active page turns amber-brown under the needle */
.dn-sec { font-family: var(--font); font-weight: 800; letter-spacing: 2px; fill: var(--steel-900); }
.dn-pg { font-family: var(--font); font-weight: 700; fill: #1c242e; }
.dn-pg.active { font-weight: 800; fill: var(--amber-ink); }

/* While the dial is open, the rotor's reticle hub fades out and a fixed
   search medallion takes its place at the same spot (Jobi 2026-10-20:
   a test user could not find the search — the hub now IS the search). */
.dn-hub-rotor { transition: opacity .3s ease; }
.dn-overlay.is-open .dn-hub-rotor { opacity: 0; }
.dn-hubsearch {
  position: absolute; left: 50%; transform: translate(-50%, -50%); z-index: 7;
  border: 0; padding: 0; background: transparent; cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity .3s ease;
}
.dn-overlay.is-open .dn-hubsearch { opacity: 1; pointer-events: auto; }
.dn-hubsearch svg { display: block; width: 100%; height: 100%; }
.dn-hubsearch:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 50%; }
