/* Process-line / P&ID navigation — compact dropdown, not a full-page sheet */

.nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 16px;
  padding: 10px 32px 14px;
}
.nav-logo {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  line-height: 0;
  border-radius: 2px;
}
.nav-logo:focus-visible {
  outline: 2px solid #1D4ED8;
  outline-offset: 3px;
}
.nav-logo-mark { position: relative; display: block; }
.nav-logo-gear {
  position: absolute;
  left: 0; top: 0;
  width: 36px; height: 36px;
  overflow: hidden;
  transform-origin: 50% 50%;
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
  z-index: 1;
}
.nav-logo-gear-inner {
  position: relative;
  display: block;
  height: 36px;
  width: calc(36px * 1473 / 267);
}
.nav-logo-gear .nav-logo-body {
  height: 36px;
  width: calc(36px * 1473 / 267);
}
.nav-logo-word {
  position: absolute;
  inset: 0;
  clip-path: inset(0 0 0 36px);
  pointer-events: none;
}
.nav-logo-word .nav-logo-body {
  display: block;
  height: 36px;
  width: 100%;
}
.nav-logo.is-open .nav-logo-gear { transform: rotate(80deg); }
.btn-compact { padding: 8px 14px; font-size: 13px; }
/* Visible shape matches the original Get in touch compact pill.
   Invisible hit area keeps a 44px tap target without changing the look. */
#pid-menu-btn {
  position: relative;
}
#pid-menu-btn::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(100%, 44px);
  height: max(100%, 44px);
  transform: translate(-50%, -50%);
}

/* Header scroll pipe — thin, few marks, tags only on hover */
.nav-pipe {
  position: relative;
  height: 28px;
  min-width: 0;
  align-self: end;
  margin: 0 8px;
}
.nav-pipe-rail {
  position: absolute;
  left: 10px; right: 10px;
  top: 50%;
  height: 6px;
  transform: translateY(-50%);
  border-top: 1.25px solid #161616;
  border-bottom: 1.25px solid #161616;
}
.nav-pipe-fill {
  position: absolute;
  left: 0; top: -1.25px; bottom: -1.25px;
  width: 0%;
  background: rgba(29, 78, 216, 0.28);
  border-top: 1.25px solid #1D4ED8;
  border-bottom: 1.25px solid #1D4ED8;
  transition: width 0.25s ease-out;
}
.nav-pipe-nodes {
  position: absolute;
  inset: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.nav-pipe-node {
  pointer-events: auto;
  appearance: none;
  border: 0;
  background: transparent;
  width: 24px;
  height: 28px;
  padding: 0;
  margin: 0;
  cursor: pointer;
  position: relative;
  color: inherit;
  text-decoration: none;
  /* <a> and <button> must share the same box; otherwise the two
     SOP links sit above the pipe while the button nodes sit on it. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  line-height: 0;
  vertical-align: middle;
  font: inherit;
}
.nav-pipe-node .valve {
  display: block;
  width: 11px;
  height: 11px;
  margin: 0 auto;
  color: #161616;
  background: #F5F6F7;
  transition: transform 0.3s ease, color 0.2s ease;
}
.nav-pipe-node.is-current .valve { color: #1D4ED8; transform: rotate(90deg); }
.nav-pipe-node:hover .valve,
.nav-pipe-node:focus-visible .valve { color: #1D4ED8; }
.nav-pipe-node:focus-visible { outline: 2px solid #1D4ED8; outline-offset: 2px; }
.nav-pipe-node[data-tag]::after {
  content: attr(data-tag);
  position: absolute;
  left: 50%;
  bottom: calc(100% - 2px);
  transform: translate(-50%, 4px);
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: #161616;
  background: rgba(245, 246, 247, 0.96);
  border: 1px solid #161616;
  padding: 1px 4px;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
.nav-pipe-node:hover::after,
.nav-pipe-node:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, -2px);
}

/* Overlay: dim the page; the sheet is a compact dropdown under the gear */
.pid-overlay {
  position: fixed;
  top: var(--nav-h);
  left: 0; right: 0; bottom: 0;
  z-index: 180;
  background: rgba(22, 22, 22, 0.22);
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 8px 24px 24px 32px;
}
.pid-overlay[hidden] { display: none; }

.pid-sheet {
  position: relative;
  width: min(800px, calc(100vw - 48px));
  max-width: 800px;
  height: auto;
  max-height: calc(100dvh - var(--nav-h) - 24px);
  overflow: auto;
  margin: 0;
  background-color: #F5F6F7;
  background-image:
    linear-gradient(rgba(29, 78, 216, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 78, 216, 0.035) 1px, transparent 1px);
  background-size: 40px 40px;
  border: 1px solid #161616;
  color: #161616;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 28px rgba(17, 17, 17, 0.16);
  transform-origin: 28px 0;
}
.pid-reg { display: none; }

.pid-sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 8px 16px;
  flex: none;
}
.pid-kicker {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #3F3F3F;
  margin: 0 0 1px;
}
.pid-sheet-head h2 {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.03em;
  margin: 0;
  line-height: 1.2;
}
.pid-close {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  margin-left: auto;
}
.pid-close-plate {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #161616;
  background: #F5F6F7;
  padding: 4px 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.12em;
}
.pid-close:hover .pid-close-plate,
.pid-close:focus-visible .pid-close-plate { background: #60A5FA; }
.pid-close:focus-visible { outline: 2px solid #1D4ED8; outline-offset: 2px; }

.pid-line {
  position: relative;
  flex: none;
  padding: 8px 16px 14px;
  min-height: 0;
}
.pid-rail {
  position: absolute;
  left: 28px;
  right: 28px;
  top: 61px;
  height: 10px;
  pointer-events: none;
  color: #161616;
}
.pid-pipe-draw {
  display: block;
  width: 100%;
  height: 10px;
  overflow: visible;
}
.pid-pipe-path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.pid-overlay.is-open .pid-pipe-path {
  animation: pid-draw 420ms 320ms ease-out forwards;
}
.pid-rail-draw {
  position: absolute;
  left: 0; top: 2px; bottom: 2px;
  width: 100%;
  border-top: 1px solid #1D4ED8;
  border-bottom: 1px solid #1D4ED8;
  transform-origin: left center;
  transform: scaleX(0);
  opacity: 0;
  pointer-events: none;
}
.pid-line.is-hover .pid-rail-draw {
  transform: scaleX(var(--draw, 0));
  opacity: 1;
  transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.2s ease;
}

.pid-stations {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  position: relative;
  z-index: 1;
}
.pid-stations > li { min-width: 0; }
.pid-station {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: center;
  cursor: pointer;
  padding: 6px 4px 8px;
  color: inherit;
  text-decoration: none;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  opacity: 0;
  transform: translateY(8px);
}
.pid-overlay.is-open .pid-station {
  animation: pid-pop 260ms ease-out forwards;
}
.pid-overlay.is-open .pid-stations > li:nth-child(1) .pid-station { animation-delay: 0.42s; }
.pid-overlay.is-open .pid-stations > li:nth-child(2) .pid-station { animation-delay: 0.48s; }
.pid-overlay.is-open .pid-stations > li:nth-child(3) .pid-station { animation-delay: 0.54s; }
.pid-overlay.is-open .pid-stations > li:nth-child(4) .pid-station { animation-delay: 0.60s; }
.pid-overlay.is-open .pid-stations > li:nth-child(5) .pid-station { animation-delay: 0.66s; }
.pid-overlay.is-open .pid-stations > li:nth-child(6) .pid-station { animation-delay: 0.72s; }

.pid-station:focus-visible { outline: 2px solid #1D4ED8; outline-offset: 2px; }
.pid-symbol {
  width: 40px;
  height: 40px;
  display: block;
  color: #161616;
  margin: 0 0 8px;
}
.pid-station:hover .pid-symbol,
.pid-station:focus-visible .pid-symbol,
.pid-station.is-active .pid-symbol,
.pid-station.is-current .pid-symbol { color: #1D4ED8; }
.pid-valve-node {
  width: 12px;
  height: 12px;
  margin: 0 0 8px;
  color: #161616;
  background: #F5F6F7;
  transition: transform 0.35s ease, color 0.2s ease;
  position: relative;
  z-index: 2;
}
.pid-station.is-current .pid-valve-node,
.pid-station.is-active .pid-valve-node {
  color: #1D4ED8;
  transform: rotate(90deg);
}
.pid-tag {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  border: 1px solid currentColor;
  padding: 2px 5px 1px;
  margin: 0 0 5px;
  background: #F5F6F7;
  line-height: 1;
}
.pid-name {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #161616;
  margin: 0 0 3px;
  line-height: 1.25;
}
.pid-caption {
  font-family: "Space Grotesk", sans-serif;
  font-size: 11px;
  line-height: 1.3;
  color: #3F3F3F;
  max-width: 15ch;
  min-height: 2.6em;
}

.pid-slug {
  position: absolute;
  top: 63px;
  left: 28px;
  width: 10px;
  height: 6px;
  border-radius: 1px;
  background: #60A5FA;
  border: 1px solid #1D4ED8;
  pointer-events: none;
  opacity: 0;
  z-index: 3;
}
.pid-slug.is-run { opacity: 1; }

.pid-titleblock {
  position: static;
  align-self: flex-end;
  margin: 2px 16px 14px auto;
  border: 1px solid #161616;
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #F5F6F7;
  padding: 3px 8px;
  white-space: nowrap;
}

body.pid-open { overflow: hidden; }

/* Open: unfurl from the gear. Close: furl back. */
.pid-overlay.is-open .pid-sheet {
  animation: pid-unfurl 350ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.pid-overlay.is-closing .pid-sheet {
  animation: pid-furl 280ms ease-in both;
}
.pid-overlay.is-closing .pid-station {
  animation: pid-pop-out 160ms ease-in both;
}
.pid-overlay.is-closing .pid-stations > li:nth-child(1) .pid-station { animation-delay: 0.12s; }
.pid-overlay.is-closing .pid-stations > li:nth-child(2) .pid-station { animation-delay: 0.09s; }
.pid-overlay.is-closing .pid-stations > li:nth-child(3) .pid-station { animation-delay: 0.06s; }
.pid-overlay.is-closing .pid-stations > li:nth-child(4) .pid-station { animation-delay: 0.03s; }
.pid-overlay.is-closing .pid-stations > li:nth-child(5) .pid-station { animation-delay: 0.03s; }
.pid-overlay.is-closing .pid-stations > li:nth-child(6) .pid-station { animation-delay: 0s; }
.pid-overlay.is-closing .pid-pipe-path {
  animation: pid-undraw 240ms ease-in both;
}

@keyframes pid-unfurl {
  from {
    clip-path: inset(0 100% 0 0);
    transform: scaleX(0.16) scaleY(0.92);
    opacity: 0.5;
  }
  to {
    clip-path: inset(0 0 0 0);
    transform: none;
    opacity: 1;
  }
}
@keyframes pid-furl {
  from {
    clip-path: inset(0 0 0 0);
    transform: none;
    opacity: 1;
  }
  to {
    clip-path: inset(0 100% 0 0);
    transform: scaleX(0.16) scaleY(0.92);
    opacity: 0.4;
  }
}
@keyframes pid-draw { to { stroke-dashoffset: 0; } }
@keyframes pid-undraw { from { stroke-dashoffset: 0; } to { stroke-dashoffset: 1; } }
@keyframes pid-pop {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes pid-pop-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(6px); }
}

@media (prefers-reduced-motion: reduce) {
  .nav-logo-gear,
  .pid-valve-node,
  .nav-pipe-node .valve,
  .pid-slug,
  .pid-rail-draw,
  .nav-pipe-fill { transition: none !important; }
  .pid-overlay.is-open .pid-sheet,
  .pid-overlay.is-closing .pid-sheet,
  .pid-overlay.is-open .pid-station,
  .pid-overlay.is-closing .pid-station,
  .pid-overlay.is-open .pid-pipe-path,
  .pid-overlay.is-closing .pid-pipe-path {
    animation: none !important;
  }
  .pid-overlay.is-open .pid-station,
  .pid-overlay.is-open .pid-pipe-path { opacity: 1; transform: none; stroke-dashoffset: 0; }
}

/* Phone: keep a full-screen drawing sheet */
@media (max-width: 800px) {
  .nav {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    grid-template-areas:
      "logo cta"
      "pipe pipe";
    align-items: center;
    row-gap: 4px;
    padding: 10px 16px 8px;
    column-gap: 8px;
  }
  .nav-logo { grid-area: logo; justify-self: start; }
  .nav-right { grid-area: cta; }
  .nav-pipe { grid-area: pipe; height: 26px; margin: 0; }
  .nav-logo-gear, .nav-logo-gear-inner { height: 30px; }
  .nav-logo-gear { width: 30px; }
  .nav-logo-gear-inner,
  .nav-logo-gear .nav-logo-body { width: calc(30px * 1473 / 267); }
  .nav-logo-gear .nav-logo-body,
  .nav-logo-word .nav-logo-body { height: 30px; }
  .nav-logo-word { clip-path: inset(0 0 0 30px); }
  .nav-pipe-node[data-tag]::after { display: none; }

  .pid-overlay {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }
  .pid-sheet {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    transform-origin: 24px 0;
    box-shadow: none;
  }
  .pid-sheet-head { padding: 16px 18px 6px; }
  .pid-sheet-head h2 { font-size: 20px; }
  .pid-line { padding: 8px 16px 12px; flex: none; }
  .pid-rail {
    left: 20px;
    right: auto;
    top: 12px;
    bottom: 12px;
    width: 8px;
    height: auto;
    border-left: 1.1px solid #161616;
    border-right: 1.1px solid #161616;
  }
  .pid-pipe-draw,
  .pid-rail-draw { display: none; }
  .pid-stations { grid-template-columns: 1fr; gap: 0; }
  .pid-station,
  .pid-overlay.is-open .pid-station,
  .pid-overlay.is-open .pid-stations > li .pid-station {
    animation: none;
    opacity: 1;
    transform: none;
    display: grid;
    grid-template-columns: 36px 1fr;
    grid-template-rows: auto auto auto;
    column-gap: 12px;
    row-gap: 2px;
    justify-items: start;
    text-align: left;
    padding: 12px 12px 12px 44px;
    min-height: 68px;
    width: auto;
  }
  .pid-symbol {
    width: 36px; height: 36px; margin: 0;
    grid-column: 1; grid-row: 1 / 4;
    align-self: center;
  }
  .pid-valve-node { display: none; }
  .pid-tag { margin: 0; grid-column: 2; grid-row: 1; }
  .pid-name, .pid-caption { max-width: none; min-height: 0; }
  .pid-name { grid-column: 2; grid-row: 2; margin: 0; }
  .pid-caption { grid-column: 2; grid-row: 3; padding: 0; }
  .pid-slug { display: none; }
  .pid-titleblock { margin: 8px 16px 16px auto; }
}

@media (max-width: 430px) {
  .nav-right .btn-compact { letter-spacing: 0; }
}
