.net {
  --leaf-h: 48px;
  --hub-h: 58px;
  --core-h: 188px;
  --lab-h: 24px;
  --lab-gap: 6px;
  --stack-gap: 8px;
  --fade: 180ms;
  --soft: cubic-bezier(0.22, 1, 0.36, 1);
  --dim: 0.5;
  --wire: color-mix(in oklab, var(--pale) 38%, var(--night));
  --wire-lit: var(--gold);
  position: relative;
  isolation: isolate;
}

.net__wires {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.net__wires path {
  fill: none;
  stroke-linejoin: miter;
  stroke-linecap: square;
}
.w {
  stroke: var(--wire);
  stroke-width: 2;
  opacity: 1;
  transition: stroke var(--fade) var(--soft), opacity var(--fade) var(--soft);
}
.w--main { stroke: var(--orange); stroke-width: 4; }
.w.is-lit { stroke: var(--wire-lit); }
.w--main.is-lit { stroke: var(--orange); }
.net.is-tracing .w:not(.is-lit) { opacity: 0.4; }

.w--signal {
  stroke: var(--cream);
  stroke-width: 4;
  stroke-linecap: butt;
  stroke-dasharray: 2 200;
  stroke-dashoffset: 2;
  opacity: 1;
  transition: opacity var(--fade) ease-out;
  animation: net-signal 7s cubic-bezier(0.45, 0, 0.55, 1) 1.6s infinite;
}
@keyframes net-signal {
  0% { stroke-dashoffset: 2; }
  55% { stroke-dashoffset: -100; }
  100% { stroke-dashoffset: -100; }
}
.net.is-tracing .w--signal { opacity: 0; }
.calm .w--signal { display: none; }

.net__grp,
.net__core,
.net__hub,
.net__leaves { position: relative; z-index: 1; }

.net__list { display: flex; flex-direction: column; gap: var(--stack-gap); }
.net__list > li { display: flex; }

.nd {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--leaf-h);
  padding: 8px 18px;
  border: 0;
  border-radius: 3px;
  background: var(--pale);
  color: var(--deep);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.15;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
  opacity: 1;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--fade) var(--soft),
    color var(--fade) var(--soft),
    box-shadow var(--fade) var(--soft),
    opacity var(--fade) var(--soft);
}
.nd:focus-visible { outline: 2px solid var(--cream); outline-offset: 3px; }
.nd--core:focus-visible { outline-offset: 5px; }
.nd::selection { background: var(--orange); color: var(--on-orange); }

.nd--main { background: var(--orange); color: var(--on-orange); font-weight: 700; }

.nd--hub {
  width: auto;
  min-height: var(--hub-h);
  padding: 8px 22px;
  background: var(--cream);
  color: var(--deep);
  font-weight: 700;
  font-size: clamp(1.1875rem, 1.5vw, 1.5625rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-transform: none;
  white-space: nowrap;
}

.nd--core {
  --pin: 13px;
  --pin-w: 6px;
  --pin-edge: 22px;
  position: relative;
  display: block;
  width: 100%;
  min-height: var(--core-h);
  height: var(--core-h);
  padding: 0;
  background: transparent;
  color: var(--cream);
  text-transform: none;
}
.chip__body {
  position: absolute;
  inset: var(--pin);
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: var(--green);
  box-shadow: inset 0 0 0 3px var(--green);
  transition: box-shadow var(--fade) var(--soft);
}
.chip__body::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 12px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--orange);
  animation: chip-live 1.8s steps(2, jump-none) infinite;
}
@keyframes chip-live { 50% { background: var(--deep); } }
.calm .chip__body::before { animation: none; }
.chip__body::after {
  content: "";
  position: absolute;
  inset: 26px;
  border: 2px solid color-mix(in oklab, var(--pale) 22%, var(--green));
  border-radius: 2px;
}
.chip__mark {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.125rem, 2.7vw, 2.75rem);
  line-height: 1;
  letter-spacing: 0.01em;
}
.chip__pins {
  position: absolute;
  display: flex;
  justify-content: space-between;
}
.chip__pins--t,
.chip__pins--b { left: calc(var(--pin) + var(--pin-edge)); right: calc(var(--pin) + var(--pin-edge)); height: var(--pin); }
.chip__pins--l,
.chip__pins--r { top: calc(var(--pin) + var(--pin-edge)); bottom: calc(var(--pin) + var(--pin-edge)); width: var(--pin); flex-direction: column; }
.chip__pins--t { top: 0; }
.chip__pins--b { bottom: 0; }
.chip__pins--l { left: 0; }
.chip__pins--r { right: 0; }
.chip__pins i {
  display: block;
  flex: none;
  background: var(--pale);
  transition: background-color var(--fade) var(--soft);
}
.chip__pins--t i,
.chip__pins--b i { width: var(--pin-w); }
.chip__pins--l i,
.chip__pins--r i { height: var(--pin-w); }
.chip__pins--t i { border-radius: 1px 1px 0 0; }
.chip__pins--b i { border-radius: 0 0 1px 1px; }
.chip__pins--l i { border-radius: 1px 0 0 1px; }
.chip__pins--r i { border-radius: 0 1px 1px 0; }

.chip__pins [data-pin="in"],
.chip__pins [data-pin="out"] { height: 10px; background: var(--orange); }
.chip__pins [data-pin="set"],
.chip__pins [data-pin="built"] { background: var(--cream); }
.chip__pins [data-pin].is-lit { background: var(--gold); }
.chip__pins [data-pin="in"].is-lit,
.chip__pins [data-pin="out"].is-lit { background: var(--orange); }
.net__dot { color: var(--orange); }

.nd.is-lit { background: var(--cream); color: var(--deep); }
.nd.is-on { background: var(--gold); color: var(--deep); }
.nd--main.is-lit,
.nd--main.is-on { background: var(--orange); color: var(--on-orange); }
.nd--main.is-on { box-shadow: inset 0 0 0 3px var(--on-orange); }
.nd--core.is-lit,
.nd--core.is-on { background: transparent; color: var(--cream); }
.nd--core.is-on .chip__body { box-shadow: inset 0 0 0 3px var(--gold); }
.nd--core.is-on .chip__pins i:not([data-pin]) { background: var(--cream); }
.net.is-tracing .nd:not(.is-lit):not(.is-on) { opacity: var(--dim); }

@media (hover: hover) {
  .net:not(.is-tracing) .nd:not(.nd--main):not(.nd--core):hover { background: var(--cream); }
}

.net__label {
  display: flex;
  align-items: center;
  height: var(--lab-h);
  margin-bottom: var(--lab-gap);
  color: var(--pale);
  font-family: var(--font-display);
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: opacity var(--fade) var(--soft);
}
.net__label--req { color: var(--orange); }
.net__list + .net__label { margin-top: 16px; }
.net.is-tracing .net__label { opacity: var(--dim); }

.net__hint {
  position: relative;
  z-index: 1;
  color: var(--pale);
  font-family: var(--font-display);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: opacity var(--fade) var(--soft);
}
.net.is-tracing .net__hint { opacity: var(--dim); }

.net__note {
  position: absolute;
  z-index: 2;
  width: max-content;
  min-width: 12rem;
  color: var(--pale);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--fade) var(--soft), visibility 0s linear var(--fade);
}
.net__note.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--fade) var(--soft), visibility 0s;
}
.note__name {
  padding-bottom: 7px;
  border-bottom: 1px solid color-mix(in oklab, var(--gold) 55%, var(--night));
  color: var(--cream);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.15;
  letter-spacing: 0.02em;
  text-wrap: balance;
}
.note__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 9px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.5;
}
.note__body:empty { display: none; }
.note__text { text-wrap: pretty; }
.note__label {
  color: var(--gold);
  font-family: var(--font-display);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.note__list { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.note__list li { position: relative; padding-left: 12px; }
.note__list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 5px;
  height: 5px;
  background: var(--gold);
}
.note__codes { display: flex; flex-wrap: wrap; gap: 6px; }
.note__codes li {
  padding: 2px 8px;
  border: 1px solid color-mix(in oklab, var(--gold) 70%, var(--night));
  border-radius: 2px;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.08em;
}

.ldr {
  opacity: 0;
  transition: opacity var(--fade) var(--soft);
}
.ldr.is-on { opacity: 1; }
.ldr path {
  stroke: var(--cream);
  stroke-width: 1.5;
  stroke-dasharray: 1 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ldr rect { fill: var(--cream); }

@media (min-width: 1024px) {
  .net {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(10rem, 15rem) auto minmax(0, 1fr);
    column-gap: clamp(36px, 4.2vw, 72px);
    row-gap: clamp(36px, 3.2vw, 48px);
  }
  .net__grp { display: contents; }

  .net__grp--set .net__leaves,
  .net__grp--built .net__leaves {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }
  .net__grp--set .net__leaves { grid-row: 1; }
  .net__grp--built .net__leaves { grid-row: 4; }
  .net__grp--set .net__leaves .nd,
  .net__grp--built .net__leaves .nd { white-space: nowrap; }

  .net__grp--set .net__hub { grid-row: 2; grid-column: 2 / 5; justify-self: center; }
  .net__grp--built .net__hub { grid-row: 3; grid-column: 2 / 5; justify-self: center; align-self: end; }

  .net__grp--in .net__hub,
  .net__grp--out .net__hub {
    grid-row: 3;
    align-self: start;
    margin-top: calc((var(--core-h) - var(--hub-h)) / 2);
  }
  .net__grp--in .net__hub { grid-column: 2; }
  .net__grp--out .net__hub { grid-column: 4; }

  .net__grp--in .net__leaves {
    grid-row: 3;
    grid-column: 1;
    justify-self: end;
    width: min(100%, 20rem);
    margin-top: calc(var(--core-h) / 2 - var(--lab-h) - var(--lab-gap) - var(--leaf-h) / 2);
  }
  .net__grp--out .net__leaves {
    grid-row: 3;
    grid-column: 5;
    justify-self: start;
    width: min(100%, 20rem);
    margin-top: calc((var(--core-h) - var(--leaf-h)) / 2);
  }
  .net__grp--in .net__leaves { padding-bottom: var(--bot-room, 0px); }
  .net__grp--set .net__hub { margin-bottom: var(--top-room, 0px); }

  .net__core { grid-row: 3; grid-column: 3; align-self: start; }

  .net__hint {
    grid-row: 5;
    grid-column: 1 / -1;
    justify-self: center;
    margin-top: -8px;
  }
}

@media (min-width: 1024px) and (max-width: 1279px) {
  .net {
    --leaf-h: 46px;
    --core-h: 164px;
    grid-template-columns: minmax(0, 1fr) auto 10.5rem auto minmax(0, 1fr);
    column-gap: 28px;
  }
  .nd--core { --pin: 11px; --pin-w: 5px; --pin-edge: 18px; }
  .chip__body::after { inset: 22px; }
  .chip__mark { font-size: 2.125rem; }
  .net__leaves .nd { padding-inline: 12px; font-size: 0.875rem; letter-spacing: 0.03em; }
  .net__grp--set .net__leaves,
  .net__grp--built .net__leaves { gap: 6px; }
  .net__grp--set .net__leaves .nd,
  .net__grp--built .net__leaves .nd { padding-inline: 11px; font-size: 0.8125rem; letter-spacing: 0.03em; }
  .note__body { font-size: 0.875rem; line-height: 1.45; }
  .note__name { font-size: 1.0625rem; }
}

@media (max-width: 1023px) {
  .net {
    --leaf-h: 44px;
    --hub-h: 0px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .net__wires,
  .net__core { display: none; }
  .net__grp {
    display: block;
    border-radius: 10px;
    background: var(--night-raised);
    box-shadow: inset 0 0 0 1px var(--guide);
  }
  .nd--hub {
    width: 100%;
    padding: 12px 14px 10px;
    border-radius: 10px 10px 0 0;
    font-size: 1.375rem;
    white-space: normal;
    text-wrap: balance;
  }
  .net__leaves { padding: 10px; }
  .net__grp--in .net__list,
  .net__grp--set .net__leaves,
  .net__grp--built .net__leaves,
  .net__grp--out .net__leaves {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }
  .net__list > li { flex: 1 1 auto; max-width: 100%; }
  .net__grp--in .net__list:first-of-type > li { flex-basis: 100%; }
  .net__leaves .nd {
    padding: 6px 12px;
    font-size: var(--fs-label);
    letter-spacing: 0.06em;
  }
  .net__label {
    height: auto;
    margin: 2px 0 8px;
    color: var(--cream);
    font-size: 1.0625rem;
    letter-spacing: 0.06em;
  }
  .net__label--req { color: var(--orange); }
  .net__list + .net__label { margin-top: 12px; }

  .net__hint { order: -1; margin-bottom: 8px; text-transform: none; font-size: 1rem; letter-spacing: 0.02em; }
  .net__note--inline {
    position: relative;
    width: auto;
    min-width: 0;
    max-width: 34rem;
    margin: 10px 4px 0;
    padding: 0 0 8px;
  }
  .net__grp--in .net__leaves > .net__note--inline { margin: 0 4px 12px; }
  .net__note--inline.net__note { opacity: 1; visibility: visible; animation: note-in var(--fade) var(--soft); }
  .net__note--inline::before {
    content: "";
    position: absolute;
    left: var(--lx, 16px);
    bottom: 100%;
    height: var(--lh, 10px);
    border-left: 2px dotted var(--cream);
  }
  .net.is-tracing .nd:not(.is-lit):not(.is-on),
  .net.is-tracing .net__label { opacity: 1; }
  .net__note--inline:is([data-id="in"], [data-id="set"], [data-id="built"], [data-id="out"]) .note__name { display: none; }
  .net__note--inline:is([data-id="in"], [data-id="set"], [data-id="built"], [data-id="out"]) .note__body { padding-top: 0; }
  .net__tipli { flex: 1 1 100% !important; align-self: stretch !important; max-width: 100%; }
  .calm .net__note--inline { animation: none; }
}

@keyframes note-in { from { opacity: 0; } }

@media (max-width: 380px) {
  .net__leaves { padding: 8px; }
  .net__leaves .nd { padding-inline: 9px; letter-spacing: 0.04em; }
}
