/* The memo under the hero: body copy, the footnote-style "key" links and the reference cards they open. */

.memo {
  display: flex;
  flex-direction: column;
  gap: var(--sp-para);
  margin-top: var(--sp-figure-memo);
  scroll-margin-top: 48px;
}
.memo p {
  max-width: var(--measure-body);
  color: var(--ink);
  font-size: var(--fs-body);
  line-height: 1.6;
  letter-spacing: 0;
  text-wrap: pretty;
}
.memo strong,
.memo .beat {
  color: var(--ink);
  font-weight: 500;
}
.memo .beat + p {
  margin-top: calc(var(--sp-beat-para) - var(--sp-para));
}

/* ---------- key links: an ink-to-green gradient wash that slides on hover, plus a little [+] box ---------- */

.memo .key {
  color: var(--link-end);
  font-weight: 500;
  text-decoration: none;
  background: linear-gradient(90deg in oklab, var(--link-start), var(--link-end), var(--link-start)) 0 0 / 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: background-position var(--dur-link) var(--ease-hover);
}
.memo .key:hover,
.memo .key:focus-visible,
.memo .key[aria-expanded="true"] {
  background-position: 100% 0;
}
.memo .key .fn {
  position: relative;
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-inline-start: 3px;
  border: 1px solid var(--link-frame);
  vertical-align: baseline;
  translate: 0 -1px;
  transition:
    background-color var(--dur-hover) var(--ease-hover),
    border-color var(--dur-hover) var(--ease-hover);
}
.memo .key .fn::before,
.memo .key .fn::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 2px;
  width: 5px;
  height: 1px;
  background: var(--link-end);
  transition:
    rotate var(--dur-hover) var(--ease-hover),
    background-color var(--dur-hover) var(--ease-hover);
}
.memo .key .fn::after {
  rotate: 90deg;
}
.memo .key:hover .fn,
.memo .key:focus-visible .fn {
  border-color: var(--link-end);
}
/* open: the + turns into an × on a filled box */
.memo .key[aria-expanded="true"] .fn {
  border-color: var(--link-end);
  background: var(--link-end);
}
.memo .key[aria-expanded="true"] .fn::before,
.memo .key[aria-expanded="true"] .fn::after {
  background: #fff;
}
.memo .key[aria-expanded="true"] .fn::before {
  rotate: 45deg;
}
.memo .key[aria-expanded="true"] .fn::after {
  rotate: 135deg;
}

/* ---------- reference cards (fixed layer, positioned by js/cards.js) ---------- */

.card-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

.pop {
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: min(400px, 100vw - 32px);
  margin: 0;
  padding: 24px;
  border: 1px solid #ffffff80;
  background: #fff;
  color: var(--ink);
  box-shadow:
    0 1px 2px #0b10150d,
    0 12px 32px -12px #0b10152e,
    0 32px 64px -24px #0b101529;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  filter: blur(4px);
  translate: 0 -6px;
  scale: 0.97;
  transition:
    opacity 0.16s var(--ease-out),
    scale 0.16s var(--ease-out),
    translate 0.16s var(--ease-out),
    filter 0.16s var(--ease-out),
    visibility 0s linear 0.16s;
}
/* the green stem that points back at the link */
.pop::before {
  content: "";
  position: absolute;
  top: -12px;
  left: calc(var(--tx, 16px) - 1px);
  width: 1px;
  height: 11px;
  background: var(--accent-text);
  transform-origin: 50% 0;
  scale: 1 0;
  transition: scale 0.16s var(--ease-out);
}
.pop.is-above {
  translate: 0 6px;
}
.pop.is-above::before {
  top: auto;
  bottom: -12px;
  transform-origin: 50% 100%;
}
.pop.is-leaving {
  filter: none;
  translate: 0 -3px;
  scale: 0.985;
}
.pop.is-above.is-leaving {
  translate: 0 3px;
}
.pop.is-on {
  opacity: 1;
  visibility: visible;
  filter: none;
  translate: 0;
  scale: 1;
  transition:
    opacity 0.2s var(--ease-out),
    scale 0.7s var(--spring-36),
    translate 0.7s var(--spring-36),
    filter 0.24s var(--ease-out),
    visibility 0s;
}
.pop.is-on::before {
  scale: 1;
  transition: scale 0.22s var(--ease-out) 80ms;
}
.pop > * {
  opacity: 0;
  translate: 0 4px;
  transition: none;
}
.pop.is-on > * {
  opacity: 1;
  translate: 0;
  transition:
    opacity 0.26s var(--ease-out),
    translate 0.42s var(--spring-36);
}
.pop.is-on > :first-child {
  transition-delay: 40ms;
}
.pop.is-on > :nth-child(2) {
  transition-delay: 80ms;
}
.pop.is-on > :nth-child(3) {
  transition-delay: 0.12s;
}
.pop.is-leaving > * {
  opacity: 1;
  translate: 0;
}

.pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-60);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: -0.004em;
}
.pop-tag {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid #e5e7eb;
  background: #fffc;
  color: var(--ink);
  font-weight: 600;
}
.pop-sq {
  display: block;
  flex: none;
  width: 6px;
  height: 6px;
  background: var(--accent-text);
}
.pop-org {
  white-space: nowrap;
}
.pop-body {
  margin: 0;
}
.pop-text {
  color: var(--ink-86);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.005em;
  text-wrap: pretty;
}
.pop-text strong {
  color: var(--ink);
  font-weight: 600;
}
.pop-foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 2px;
}
.pop-who {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}
.pop-role,
.pop-sub {
  color: var(--ink-60);
}
.pop-sub {
  font-weight: 400;
  text-wrap: pretty;
}
@media (prefers-reduced-motion: reduce) {
  .memo .key,
  .memo .key .fn,
  .memo .key .fn::before,
  .memo .key .fn::after {
    transition: none;
  }
  .memo .key:hover,
  .memo .key:focus-visible,
  .memo .key[aria-expanded="true"] {
    background-position: 0 0;
  }
  .pop,
  .pop.is-above,
  .pop.is-leaving {
    filter: none;
    translate: 0;
    scale: 1;
    transition:
      opacity 0.12s,
      visibility 0s linear 0.12s;
  }
  .pop.is-on {
    transition:
      opacity 0.12s,
      visibility 0s;
  }
  .pop::before,
  .pop.is-on::before {
    scale: 1;
    transition: none;
  }
  .pop > *,
  .pop.is-on > * {
    opacity: 1;
    translate: 0;
    transition: none;
  }
}
