/* Protocol page. Lab SOP, not a landing. */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: auto; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

:lang(ja) body { line-height: 1.7; }

.wrap {
  max-width: var(--flow);
  margin: 0 auto;
  padding: 0 24px;
}

.measure { max-width: var(--measure); }

a { color: var(--ink); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

code, pre, kbd { font-family: var(--mono); }
code { font-size: 0.875em; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 14px;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* masthead: not sticky, not frosted */
.mast {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.mast-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.wordmark {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0;
}

.wordmark:hover { text-decoration: underline; }

.mast-nav {
  display: flex;
  gap: 16px;
  font-size: 13px;
}

.mast-nav a {
  color: var(--mute);
  text-decoration: none;
}

.mast-nav a:hover,
.mast-nav a[aria-current="page"] {
  color: var(--ink);
  text-decoration: underline;
}

.ident {
  padding: 40px 0 8px;
}

.ident h1 {
  font-family: var(--sans);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin: 0 0 14px;
  font-style: normal;
}

.ident p {
  margin: 0 0 12px;
  color: var(--ink);
  max-width: var(--measure);
}

.ident p:last-child { margin-bottom: 0; }

.ident .by {
  color: var(--mute);
  font-size: 14px;
}

.ident .by code { font-size: 12.5px; }

.block { padding: 36px 0 8px; }

.sec {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--mute);
  margin: 0 0 18px;
  text-transform: none;
  letter-spacing: 0;
}

/* vertical rail */
.gates {
  list-style: none;
  margin: 0;
  padding: 0 8px 0 0;
  position: relative;
}

.gates::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 10px;
  bottom: 36px;
  width: 1px;
  background: var(--line);
}

.gates > li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 48px;
  position: relative;
  padding: 0 0 28px;
}

.gates > li:last-child { padding-bottom: 0; }

.n {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--ink);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.n-src {
  width: 8px;
  height: 8px;
  margin: 12px;
  border: 1px solid var(--ink);
  background: var(--bg);
}

.src {
  margin: 6px 0 4px;
  font-family: var(--mono);
  font-size: 13px;
}

.g h3 {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  margin: 5px 0 10px;
  line-height: 1.3;
}

.g h3 .aka {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--mute);
  margin-left: 8px;
}

.rows { margin: 0; }

.rows > div {
  display: grid;
  grid-template-columns: 3.6rem 1fr;
  gap: 10px 12px;
  margin: 0 0 8px;
}

.rows > div:last-child { margin-bottom: 0; }

.rows dt {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--mute);
  padding-top: 2px;
}

.rows dd {
  margin: 0;
  font-size: 14.5px;
  color: var(--ink);
}

.kill {
  color: var(--kill);
  font-weight: 600;
}

.ok { color: var(--ok); }
.hal { color: var(--kill); }

/* right-hand loop 5 → 2 */
.loop-a::after,
.loop-m::after,
.loop-z::after { content: none; }

.reenter {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
}

.reenter .arrow { color: var(--mute); }

@media (max-width: 720px) {
  .gates > li { gap: 40px; }
}

/* Record rows: 1px lines, no cards, no shadows */
.rec-wrap {
  overflow-x: auto;
}

.rec {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.45;
}

.rec th {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--mute);
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 0 12px 8px 0;
  white-space: nowrap;
  vertical-align: bottom;
}

.rec td {
  border-bottom: 1px solid var(--line);
  padding: 8px 12px 8px 0;
  vertical-align: top;
}

.rec th:last-child,
.rec td:last-child { padding-right: 0; }

.rec .code {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.rec .id {
  font-family: var(--mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.rec .name { font-weight: 600; }

.lenses {
  margin: 0 0 28px;
}

.lenses > div {
  display: grid;
  grid-template-columns: minmax(9rem, 13.5rem) 1fr;
  gap: 6px 16px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.lenses dt {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.lenses dd {
  margin: 0;
  font-size: 14px;
}

.intro {
  margin: 0 0 12px;
  font-size: 14.5px;
  max-width: var(--measure);
}

.names {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14.5px;
}

.names li:not(:last-child)::after {
  content: " · ";
  color: var(--mute);
}

.verdict { margin-top: 8px; }

.ledger { font-size: 13.5px; }

.ledger th:nth-child(1),
.ledger td:nth-child(1) {
  width: 1.6rem;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--mute);
}

.out {
  margin: 12px 0 0;
  font-size: 14.5px;
}

.cli-wrap {
  margin-top: 20px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.cli {
  margin: 0;
  padding: 16px 18px;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
  background: var(--bg);
}

.cli .ok { color: var(--ok); font-weight: 700; }
.cli .hal { color: var(--kill); font-weight: 700; }

.case {
  margin: 12px 0 0;
  font-size: 14.5px;
}

.install {
  position: relative;
  border: 1px solid var(--line);
  background: var(--bg);
}

.install pre {
  margin: 0;
  padding: 16px 72px 16px 18px;
  font-size: 13.5px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.install .mcp { color: var(--mute); }

.copy {
  position: absolute;
  top: 8px;
  right: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 4px 10px;
  cursor: pointer;
}

.copy:hover { background: #f5f5f5; }
.copy:focus { outline: 1px solid var(--ink); outline-offset: 2px; }

.note {
  padding: 36px 0 8px;
  color: var(--mute);
  font-size: 13px;
  max-width: var(--measure);
}

.note p { margin: 0; }

.foot {
  border-top: 1px solid var(--line);
  margin-top: 40px;
  padding: 20px 0 40px;
  font-size: 13px;
  color: var(--mute);
}

.foot p { margin: 0 0 6px; }

.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.foot-links a { color: var(--mute); }
.foot-links a:hover { color: var(--ink); }

@media (max-width: 640px) {
  .lenses > div {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 10px 0;
  }
}



/* Scroll: the protocol draws itself. No scroll-jack. */
.rail-ink {
  position: absolute;
  left: 15px;
  top: 10px;
  width: 1px;
  height: 0;
  background: var(--ink);
  z-index: 0;
  pointer-events: none;
}

.js .gates > li {
  opacity: 0.55;
  transform: translateY(14px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.js .gates > li.is-on {
  opacity: 1;
  transform: none;
}

.js .n {
  transition: background 0.35s ease, color 0.35s ease, border-color 0.35s ease;
}

.js .gates > li.is-on .n:not(.n-src) {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.js .gates > li.is-on .n-src {
  background: var(--ink);
}
.js .reenter {
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.45s ease 0.15s, transform 0.45s ease 0.15s;
}

.js .gates.is-loop .reenter {
  opacity: 1;
  transform: none;
}

.js .gates > li.is-on .kill {
  animation: kill-flash 0.8s ease 1;
}

@keyframes kill-flash {
  0% { color: var(--ink); }
  40% { color: var(--kill); }
  100% { color: var(--kill); }
}

.js .block {
  opacity: 0.7;
  transform: translateY(18px);
  transition: opacity 0.65s ease, transform 0.65s ease;
}

.js .block.is-on {
  opacity: 1;
  transform: none;
}

.js .ident {
  opacity: 0;
  transform: translateY(10px);
  animation: ident-in 0.7s ease 0.08s forwards;
}

@keyframes ident-in {
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .gates > li,
  .js .block,
  .js .ident,
  .js .reenter {
    opacity: 1;
    transform: none;
    animation: none;
    transition: none;
  }
  .js .gates > li.is-on .kill { animation: none; }
}



.loop-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 3;
}

.loop-track {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  opacity: 0.55;
}

.loop-token {
  fill: var(--ink);
  stroke: var(--bg);
  stroke-width: 2;
}

.js .gates > li.is-now .n:not(.n-src) {
  background: var(--kill);
  border-color: var(--kill);
  color: var(--bg);
}

@media (prefers-reduced-motion: reduce) {
  .loop-token { display: none; }
  .loop-track { opacity: 1; }
}
