/* KA — Kernel Assiomatico
   A relational field using the existing MAIOS technical-page grammar. */

body[data-surface="ka"] .page-hero-layout {
  grid-template-columns: minmax(0, 0.92fr) minmax(31rem, 1.08fr);
  gap: clamp(2.5rem, 5vw, 6rem);
  align-items: center;
}

body[data-surface="ka"] .package-hero h1 {
  max-width: 15ch;
  font-size: var(--type-title-page);
  line-height: 0.94;
}

body[data-surface="ka"] .lead { max-width: 39rem; }
body[data-surface="ka"] .ka-field-preview { margin: 0; min-width: 0; }

body[data-surface="ka"] .section {
  padding-block: clamp(4.5rem, 7vw, 6.75rem);
}

body[data-surface="ka"] .section h2 {
  max-width: 16ch;
  font-size: var(--type-title-section);
  line-height: 1.03;
}

body[data-surface="ka"] .ka-field-preview__frame {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3.25rem minmax(0, 1fr) 3.25rem minmax(0, 1fr);
  align-items: center;
  min-height: 26rem;
  padding: 5.2rem 1.35rem 5.4rem;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(color-mix(in srgb, var(--line) 56%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--line) 56%, transparent) 1px, transparent 1px),
    color-mix(in srgb, var(--expression-field) 74%, var(--choice));
  background-size: 2.65rem 2.65rem;
  box-shadow: 0.72rem 0.8rem 0 color-mix(in srgb, var(--expression) 30%, transparent);
}

body[data-surface="ka"] .ka-field-preview__return {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

body[data-surface="ka"] .ka-field-preview__return path {
  fill: none;
  stroke: color-mix(in srgb, var(--expression) 72%, var(--ink));
  stroke-width: 2;
  stroke-dasharray: 7 8;
}

body[data-surface="ka"] .ka-field-preview__node {
  position: relative;
  z-index: 2;
  min-height: 9.6rem;
  padding: 1rem;
  border: 1px solid var(--line-strong);
  background: var(--choice);
  box-shadow: 0.35rem 0.4rem 0 color-mix(in srgb, var(--expression) 24%, transparent);
}

body[data-surface="ka"] .ka-field-preview__node--result { background: color-mix(in srgb, var(--expression-soft) 58%, var(--choice)); }
body[data-surface="ka"] .ka-field-preview__node--horizon { background: color-mix(in srgb, var(--expression-field) 64%, var(--choice)); }

body[data-surface="ka"] .ka-field-preview__node > span,
body[data-surface="ka"] .ka-field-preview__core > span,
body[data-surface="ka"] .ka-kernel-facts > article > span,
body[data-surface="ka"] .ka-state-grid > article > span {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--expression-text);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

body[data-surface="ka"] .ka-field-preview__node strong {
  display: block;
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  line-height: 1.12;
}

body[data-surface="ka"] .ka-field-preview__node small {
  display: block;
  margin-top: 0.55rem;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.35;
}

body[data-surface="ka"] .ka-field-preview__passage {
  position: relative;
  z-index: 1;
  height: 2px;
  background: var(--line-strong);
}

body[data-surface="ka"] .ka-field-preview__passage::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -0.08rem;
  width: 0.55rem;
  height: 0.55rem;
  border-top: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
  transform: translateY(-50%) rotate(45deg);
}

body[data-surface="ka"] .ka-field-preview__core {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 1.2rem;
  width: min(18rem, calc(100% - 2.4rem));
  padding: 0.75rem 1rem;
  border: 1px solid var(--line-strong);
  background: #173f43;
  color: #fff;
  text-align: center;
  transform: translateX(-50%);
}

body[data-surface="ka"] .ka-field-preview__core > span { margin-bottom: 0.15rem; color: var(--expression-soft); }
body[data-surface="ka"] .ka-field-preview__core strong { font-size: 0.92rem; }

body[data-surface="ka"] .ka-field-preview__caption {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.1rem 0 0;
  color: var(--ink-soft);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

body[data-surface="ka"] .ka-prospective-layout,
body[data-surface="ka"] .ka-quality-layout,
body[data-surface="ka"] .ka-kernel-layout,
body[data-surface="ka"] .ka-state-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: clamp(2.5rem, 4.5vw, 4.75rem);
  align-items: center;
}

body[data-surface="ka"] .ka-prospective-layout h2,
body[data-surface="ka"] .ka-quality-layout h2,
body[data-surface="ka"] .ka-kernel-layout h2,
body[data-surface="ka"] .ka-state-layout > div:first-child h2 { max-width: 12ch; }

body[data-surface="ka"] .ka-emphasis {
  margin-top: 0;
  color: var(--ink);
  font-size: clamp(1.14rem, 1.8vw, 1.45rem);
  line-height: 1.45;
}

body[data-surface="ka"] .ka-aperture-map,
body[data-surface="ka"] .ka-resultant-map,
body[data-surface="ka"] .ka-kernel-map,
body[data-surface="ka"] .ka-role-map,
body[data-surface="ka"] .ka-state-flow {
  margin: 0;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(color-mix(in srgb, var(--line) 42%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--line) 42%, transparent) 1px, transparent 1px),
    color-mix(in srgb, var(--expression-field) 68%, var(--choice));
  background-size: 2.25rem 2.25rem;
  box-shadow: 0.5rem 0.55rem 0 color-mix(in srgb, var(--expression) 22%, transparent);
}

body[data-surface="ka"] .ka-quality-intro { min-width: 0; }

body[data-surface="ka"] .ka-aperture-map {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.75rem auto 2.75rem minmax(0, 1fr);
  align-items: center;
  min-height: 10.5rem;
  margin-top: 2rem;
  padding: 1.5rem;
}

body[data-surface="ka"] .ka-aperture-map__state {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line-strong);
  background: var(--choice);
}

body[data-surface="ka"] .ka-aperture-map__state--open {
  background: color-mix(in srgb, var(--expression-soft) 54%, var(--choice));
}

body[data-surface="ka"] .ka-aperture-map__state span,
body[data-surface="ka"] .ka-resultant-map span,
body[data-surface="ka"] .ka-kernel-map span,
body[data-surface="ka"] .ka-role-map span,
body[data-surface="ka"] .ka-state-flow span {
  display: block;
  color: var(--expression-text);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

body[data-surface="ka"] .ka-aperture-map__state strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.9rem;
  line-height: 1.22;
}

body[data-surface="ka"] .ka-aperture-map__axis {
  position: relative;
  height: 2px;
  background: var(--line-strong);
}

body[data-surface="ka"] .ka-aperture-map__axis i {
  position: absolute;
  top: 50%;
  right: 0;
  width: 0.5rem;
  height: 0.5rem;
  border-top: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
  transform: translateY(-50%) rotate(45deg);
}

body[data-surface="ka"] .ka-aperture-map__core {
  display: grid;
  place-items: center;
  width: 4.3rem;
  aspect-ratio: 1;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: #173f43;
  color: #fff;
  text-align: center;
  box-shadow: 0 0 0 0.45rem color-mix(in srgb, var(--expression-soft) 45%, transparent);
}

body[data-surface="ka"] .ka-aperture-map__core strong { font-size: 1.1rem; }
body[data-surface="ka"] .ka-aperture-map__core span { color: var(--choice); font-size: 0.55rem; letter-spacing: 0.08em; }

body[data-surface="ka"] .ka-prospective-copy > p:not(.ka-emphasis) { max-width: 43rem; color: var(--ink-soft); }

body[data-surface="ka"] .ka-resultant-map {
  position: relative;
  display: grid;
  grid-template-columns: minmax(10rem, 0.8fr) minmax(13rem, 1.2fr);
  grid-template-areas:
    "result branches"
    "result next"
    "equation equation";
  gap: 1rem 2.4rem;
  min-height: 22rem;
  margin-top: 1.75rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  overflow: hidden;
}

body[data-surface="ka"] .ka-resultant-map__result {
  grid-area: result;
  align-self: stretch;
  display: grid;
  align-content: center;
  min-height: 10rem;
  padding: 1.25rem;
  border: 1px solid var(--line-strong);
  background: #173f43;
  color: #fff;
}

body[data-surface="ka"] .ka-resultant-map__result::after {
  content: "";
  position: absolute;
  top: 4.8rem;
  left: calc(38% - 0.25rem);
  width: 2.6rem;
  height: 2px;
  background: var(--line-strong);
}

body[data-surface="ka"] .ka-resultant-map__result span { color: var(--expression-soft); }
body[data-surface="ka"] .ka-resultant-map__result strong { margin-top: 0.4rem; font-size: clamp(1.2rem, 2vw, 1.7rem); }

body[data-surface="ka"] .ka-resultant-map__branches {
  grid-area: branches;
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  align-self: end;
}

body[data-surface="ka"] .ka-resultant-map__branches::before {
  content: "";
  position: absolute;
  right: 8%;
  bottom: -1.05rem;
  left: 8%;
  height: 1px;
  background: var(--line-strong);
}

body[data-surface="ka"] .ka-resultant-map__branches span {
  position: relative;
  padding: 0.8rem 0.45rem;
  border: 1px solid var(--line-strong);
  background: var(--choice);
  text-align: center;
}

body[data-surface="ka"] .ka-resultant-map__branches span:nth-child(2) { background: color-mix(in srgb, var(--expression-soft) 56%, var(--choice)); }
body[data-surface="ka"] .ka-resultant-map__branches span:nth-child(3) { opacity: 0.58; }

body[data-surface="ka"] .ka-resultant-map__next {
  grid-area: next;
  padding: 1rem;
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--expression-soft) 58%, var(--choice));
}

body[data-surface="ka"] .ka-resultant-map__next strong { display: block; margin-top: 0.3rem; }

body[data-surface="ka"] .ka-resultant-map__equation {
  grid-area: equation;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0.4rem 0 0;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line-strong);
  font-size: 0.83rem;
}

body[data-surface="ka"] .ka-resultant-map__equation span { color: var(--ink); }
body[data-surface="ka"] .ka-resultant-map__equation b,
body[data-surface="ka"] .ka-resultant-map__equation i { color: var(--expression-text); font-size: 1.1rem; font-style: normal; }

body[data-surface="ka"] .ka-quality-layout {
  grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
}

body[data-surface="ka"] .ka-quality-pairs {
  border-top: 1px solid var(--line-strong);
}

body[data-surface="ka"] .ka-quality-pairs article {
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--choice) 78%, transparent);
}

body[data-surface="ka"] .ka-quality-pairs article > div {
  min-width: 0;
  padding: clamp(1rem, 2vw, 1.45rem);
}

body[data-surface="ka"] .ka-quality-pairs article > div + div {
  border-left: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--expression-soft) 42%, var(--choice));
}

body[data-surface="ka"] .ka-quality-pairs span {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--expression-text);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

body[data-surface="ka"] .ka-quality-pairs h3,
body[data-surface="ka"] .ka-quality-pairs p { margin: 0; }

body[data-surface="ka"] .ka-quality-pairs h3 { font-size: clamp(1rem, 1.35vw, 1.18rem); }
body[data-surface="ka"] .ka-quality-pairs p { color: var(--ink-soft); font-size: 0.94rem; }

body[data-surface="ka"] .ka-quality-line {
  display: grid;
  grid-template-columns: minmax(8rem, 0.9fr) auto minmax(7rem, 0.8fr) auto minmax(11rem, 1.2fr);
  align-items: stretch;
  margin-top: 2.25rem;
  border: 1px solid var(--line-strong);
  background: var(--choice);
}

body[data-surface="ka"] .ka-quality-line > * {
  display: grid;
  place-items: center;
  min-height: 5.75rem;
  padding: 0.9rem;
  text-align: center;
}

body[data-surface="ka"] .ka-quality-line > span {
  background: #173f43;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

body[data-surface="ka"] .ka-quality-line > b,
body[data-surface="ka"] .ka-quality-line > i {
  min-height: 0;
  padding-inline: 0.25rem;
  color: var(--expression-text);
  font-size: 1.3rem;
  font-style: normal;
}

body[data-surface="ka"] .ka-quality-line > strong { font-size: 0.94rem; line-height: 1.35; }

body[data-surface="ka"] .ka-kernel-facts,
body[data-surface="ka"] .ka-state-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}

body[data-surface="ka"] .ka-kernel-composition { min-width: 0; }

body[data-surface="ka"] .ka-kernel-map {
  position: relative;
  min-height: 25rem;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

body[data-surface="ka"] .ka-kernel-map__orbit,
body[data-surface="ka"] .ka-kernel-map__orbit i {
  position: absolute;
  top: 50%;
  left: 42%;
  border: 1px solid color-mix(in srgb, var(--line-strong) 72%, transparent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

body[data-surface="ka"] .ka-kernel-map__orbit { width: 17rem; aspect-ratio: 1; }
body[data-surface="ka"] .ka-kernel-map__orbit i:nth-child(1) { width: 12.5rem; aspect-ratio: 1; }
body[data-surface="ka"] .ka-kernel-map__orbit i:nth-child(2) { width: 7.6rem; aspect-ratio: 1; }
body[data-surface="ka"] .ka-kernel-map__orbit i:nth-child(3) { width: 0.6rem; aspect-ratio: 1; background: var(--expression); }

body[data-surface="ka"] .ka-kernel-map__core {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 42%;
  display: grid;
  place-items: center;
  width: 8rem;
  aspect-ratio: 1;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: #173f43;
  color: #fff;
  text-align: center;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 0.65rem color-mix(in srgb, var(--expression-soft) 38%, transparent);
}

body[data-surface="ka"] .ka-kernel-map__core span { color: var(--expression-soft); }
body[data-surface="ka"] .ka-kernel-map__core strong { font-size: 2.1rem; line-height: 1; }

body[data-surface="ka"] .ka-kernel-map__current {
  position: absolute;
  z-index: 3;
  right: 1.25rem;
  bottom: 2rem;
  width: min(13.5rem, 42%);
  padding: 1rem;
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--expression-soft) 62%, var(--choice));
  box-shadow: 0.35rem 0.4rem 0 color-mix(in srgb, var(--expression) 24%, transparent);
}

body[data-surface="ka"] .ka-kernel-map__current::before {
  content: "";
  position: absolute;
  right: 100%;
  bottom: 50%;
  width: 5rem;
  height: 1px;
  background: var(--line-strong);
  transform: rotate(19deg);
  transform-origin: right;
}

body[data-surface="ka"] .ka-kernel-map__current strong,
body[data-surface="ka"] .ka-kernel-map__current small { display: block; }
body[data-surface="ka"] .ka-kernel-map__current strong { margin-top: 0.3rem; font-size: 1.2rem; }
body[data-surface="ka"] .ka-kernel-map__current small { margin-top: 0.3rem; color: var(--ink-soft); }

body[data-surface="ka"] .ka-kernel-map__label {
  position: absolute;
  z-index: 1;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--choice) 86%, transparent);
}

body[data-surface="ka"] .ka-kernel-map__label--identity { top: 1.3rem; left: 8%; }
body[data-surface="ka"] .ka-kernel-map__label--source { top: 2.7rem; right: 8%; }
body[data-surface="ka"] .ka-kernel-map__label--coherence { bottom: 1.4rem; left: 5%; }

body[data-surface="ka"] .ka-kernel-facts article,
body[data-surface="ka"] .ka-state-grid article {
  min-width: 0;
  padding: clamp(1.35rem, 3vw, 2.25rem);
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--choice) 76%, transparent);
}

body[data-surface="ka"] .ka-kernel-facts article:last-child,
body[data-surface="ka"] .ka-state-grid article:last-child { background: color-mix(in srgb, var(--expression-soft) 50%, var(--choice)); }

body[data-surface="ka"] .ka-kernel-facts h3,
body[data-surface="ka"] .ka-state-grid h3 { margin-top: 0; }

body[data-surface="ka"] .ka-kernel-facts p,
body[data-surface="ka"] .ka-state-grid p,
body[data-surface="ka"] .ka-role-grid p { color: var(--ink-soft); }

body[data-surface="ka"] .ka-role-head { align-items: end; }
body[data-surface="ka"] .ka-role-head {
  gap: clamp(2.5rem, 4vw, 4.5rem);
  margin-bottom: 2.5rem;
}
body[data-surface="ka"] .ka-role-head h2 { max-width: 20ch; }
body[data-surface="ka"] .ka-role-grid article {
  min-height: 0;
  background: color-mix(in srgb, var(--choice) 76%, transparent);
}
body[data-surface="ka"] .ka-role-grid article:first-child { background: color-mix(in srgb, var(--expression-soft) 58%, var(--choice)); }

body[data-surface="ka"] .ka-role-map {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.6rem;
  margin: 0 0 1.5rem;
  padding: clamp(1.1rem, 2.5vw, 1.8rem);
  overflow: hidden;
}

body[data-surface="ka"] .ka-role-map::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 8%;
  left: 8%;
  height: 2px;
  background: var(--line-strong);
}

body[data-surface="ka"] .ka-role-map > div {
  position: relative;
  z-index: 1;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line-strong);
  background: var(--choice);
}

body[data-surface="ka"] .ka-role-map > div::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -1rem;
  width: 0.55rem;
  aspect-ratio: 1;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--choice);
  transform: translateY(-50%);
}

body[data-surface="ka"] .ka-role-map > div:first-of-type::before { display: none; }
body[data-surface="ka"] .ka-role-map__focus { background: #173f43 !important; color: #fff; }
body[data-surface="ka"] .ka-role-map__focus span { color: var(--expression-soft); }
body[data-surface="ka"] .ka-role-map strong { display: block; margin-top: 0.35rem; font-size: clamp(1rem, 1.7vw, 1.3rem); }

body[data-surface="ka"] .ka-state-layout {
  grid-template-columns: 1fr;
  align-items: stretch;
}

body[data-surface="ka"] .ka-state-layout > div:first-child {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(30rem, 1.18fr);
  grid-template-rows: auto 1fr;
  gap: 0.8rem clamp(2.5rem, 4.5vw, 4.75rem);
  align-items: center;
}

body[data-surface="ka"] .ka-state-layout > div:first-child > .section-kicker {
  grid-column: 1;
  grid-row: 1;
}

body[data-surface="ka"] .ka-state-layout > div:first-child > h2 {
  grid-column: 1;
  grid-row: 2;
  margin-bottom: 0;
}

body[data-surface="ka"] .ka-state-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
body[data-surface="ka"] .ka-state-layout .section-actions { grid-column: 1; margin-top: 0; }

body[data-surface="ka"] .ka-state-flow {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  grid-column: 2;
  grid-row: 1 / 3;
  margin-top: 0;
  padding: 1.25rem;
  overflow: hidden;
}

body[data-surface="ka"] .ka-state-flow > div {
  position: relative;
  z-index: 1;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line-strong);
  background: var(--choice);
}

body[data-surface="ka"] .ka-state-flow > div:nth-of-type(2) { background: color-mix(in srgb, var(--expression-soft) 46%, var(--choice)); }
body[data-surface="ka"] .ka-state-flow > div:nth-of-type(3) { background: color-mix(in srgb, var(--expression-soft) 66%, var(--choice)); }
body[data-surface="ka"] .ka-state-flow > div strong { display: block; margin-top: 0.25rem; }

body[data-surface="ka"] .ka-state-flow > i {
  position: relative;
  z-index: 0;
  width: 2px;
  height: 1.75rem;
  margin-inline: auto;
  background: var(--line-strong);
}

body[data-surface="ka"] .ka-state-flow > i::after {
  content: "";
  position: absolute;
  right: 50%;
  bottom: -0.05rem;
  width: 0.48rem;
  height: 0.48rem;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: translateX(50%) rotate(45deg);
}

body[data-surface="ka"] .ka-state-flow > p {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line-strong);
  background: #173f43;
  color: #fff;
}

body[data-surface="ka"] .ka-state-flow > p span { color: var(--expression-soft); font-size: 0.9rem; }
body[data-surface="ka"] .ka-state-flow > p strong { font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase; }

body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-aperture-map__core,
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-resultant-map__result,
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-kernel-map__core,
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-role-map__focus,
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-state-flow > p {
  animation: ka-relational-pulse 1.45s cubic-bezier(.2,.8,.2,1) both;
}

body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-field-preview__return path {
  animation: ka-draw-relation 1.8s ease-out both;
}

body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-aperture-map__state,
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-aperture-map__axis,
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-resultant-map__result,
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-resultant-map__branches,
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-resultant-map__next,
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-resultant-map__equation,
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-kernel-map__orbit,
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-kernel-map__label,
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-kernel-map__current,
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-role-map > div,
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-state-flow > div,
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] .ka-state-flow > i {
  animation: ka-relational-reveal 0.8s cubic-bezier(.2,.8,.2,1) both;
}

body[data-surface="ka"] [data-animate-on-view][data-visible="true"] > *:nth-child(2) { animation-delay: 90ms; }
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] > *:nth-child(3) { animation-delay: 180ms; }
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] > *:nth-child(4) { animation-delay: 270ms; }
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] > *:nth-child(5) { animation-delay: 360ms; }
body[data-surface="ka"] [data-animate-on-view][data-visible="true"] > *:nth-child(6) { animation-delay: 450ms; }

@keyframes ka-relational-reveal {
  from { opacity: 0.18; filter: saturate(0.55); }
  to { opacity: 1; filter: saturate(1); }
}

@keyframes ka-relational-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--expression) 52%, transparent); }
  55% { box-shadow: 0 0 0 0.7rem color-mix(in srgb, var(--expression) 18%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes ka-draw-relation {
  from { stroke-dashoffset: 80; opacity: 0.25; }
  to { stroke-dashoffset: 0; opacity: 1; }
}

@media (max-width: 1050px) {
  body[data-surface="ka"] .page-hero-layout { grid-template-columns: 1fr; }
  body[data-surface="ka"] .package-hero h1 { max-width: 12ch; }
  body[data-surface="ka"] .ka-field-preview { width: min(100%, 48rem); }
}

@media (max-width: 760px) {
  body[data-surface="ka"] .ka-prospective-layout,
  body[data-surface="ka"] .ka-quality-layout,
  body[data-surface="ka"] .ka-kernel-layout,
  body[data-surface="ka"] .ka-state-layout { grid-template-columns: 1fr; gap: 2rem; }

  body[data-surface="ka"] .ka-prospective-layout h2,
  body[data-surface="ka"] .ka-quality-layout h2,
  body[data-surface="ka"] .ka-kernel-layout h2,
  body[data-surface="ka"] .ka-state-layout > div:first-child h2 { max-width: 15ch; }

  body[data-surface="ka"] .ka-quality-line { grid-template-columns: 1fr; }
  body[data-surface="ka"] .ka-quality-line > * { min-height: 0; padding: 1rem; }
  body[data-surface="ka"] .ka-quality-line > b,
  body[data-surface="ka"] .ka-quality-line > i { transform: rotate(90deg); }
  body[data-surface="ka"] .ka-state-layout .section-actions { grid-column: 1; }
  body[data-surface="ka"] .ka-state-layout > div:first-child {
    display: block;
  }

  body[data-surface="ka"] .ka-state-layout > div:first-child > h2 { margin-bottom: 1.2rem; }

  body[data-surface="ka"] .ka-state-flow {
    display: grid;
    margin-top: 2rem;
  }

  body[data-surface="ka"] .ka-aperture-map {
    grid-template-columns: 1fr;
    gap: 0;
  }

  body[data-surface="ka"] .ka-aperture-map__axis {
    width: 2px;
    height: 2rem;
    margin-inline: auto;
  }

  body[data-surface="ka"] .ka-aperture-map__axis i {
    top: auto;
    right: 50%;
    bottom: 0;
    transform: translateX(50%) rotate(135deg);
  }

  body[data-surface="ka"] .ka-resultant-map {
    grid-template-columns: 1fr;
    grid-template-areas: "result" "branches" "next" "equation";
    gap: 1rem;
  }

  body[data-surface="ka"] .ka-resultant-map__result::after { display: none; }

  body[data-surface="ka"] .ka-role-map {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-surface="ka"] .ka-role-map::before,
  body[data-surface="ka"] .ka-role-map > div::before { display: none; }

  body[data-surface="ka"] .ka-quality-pairs article { grid-template-columns: 1fr; }
  body[data-surface="ka"] .ka-quality-pairs article > div + div {
    border-top: 1px solid var(--line-strong);
    border-left: 0;
  }
}

@media (max-width: 620px) {
  body[data-surface="ka"] .package-hero h1 { max-width: 13ch; font-size: var(--type-title-page); }

  body[data-surface="ka"] .ka-field-preview__frame {
    grid-template-columns: 1fr;
    gap: 0;
    min-height: 0;
    padding: 2rem 1.1rem 5.4rem;
  }

  body[data-surface="ka"] .ka-field-preview__node { min-height: 0; }

  body[data-surface="ka"] .ka-field-preview__passage {
    width: 2px;
    height: 2.5rem;
    margin-inline: auto;
  }

  body[data-surface="ka"] .ka-field-preview__passage::after {
    top: auto;
    right: 50%;
    bottom: -0.08rem;
    transform: translateX(50%) rotate(135deg);
  }

  body[data-surface="ka"] .ka-field-preview__return { display: none; }
  body[data-surface="ka"] .ka-kernel-facts,
  body[data-surface="ka"] .ka-state-grid { grid-template-columns: 1fr; }
  body[data-surface="ka"] .ka-field-preview__caption { flex-direction: column; gap: 0.25rem; }

  body[data-surface="ka"] .ka-kernel-map { min-height: 26rem; }
  body[data-surface="ka"] .ka-kernel-map__orbit,
  body[data-surface="ka"] .ka-kernel-map__orbit i,
  body[data-surface="ka"] .ka-kernel-map__core { left: 50%; }
  body[data-surface="ka"] .ka-kernel-map__current {
    right: 50%;
    bottom: 1.2rem;
    width: min(14rem, calc(100% - 2rem));
    transform: translateX(50%);
  }
  body[data-surface="ka"] .ka-kernel-map__current::before { display: none; }
  body[data-surface="ka"] .ka-role-map { grid-template-columns: 1fr; }
  body[data-surface="ka"] .ka-state-flow > p { align-items: flex-start; flex-direction: column; }
}

@media (forced-colors: active) {
  body[data-surface="ka"] .ka-field-preview__return path { stroke: CanvasText; }
}

@media (prefers-reduced-motion: reduce) {
  body[data-surface="ka"] [data-animate-on-view] * { animation: none !important; transition: none !important; }
}

/* KA follows the shared MAIOS accessibility floor. */
body[data-surface="ka"] .ka-field-preview__node > span,
body[data-surface="ka"] .ka-field-preview__core > span,
body[data-surface="ka"] .ka-kernel-facts > article > span,
body[data-surface="ka"] .ka-state-grid > article > span,
body[data-surface="ka"] .ka-field-preview__caption,
body[data-surface="ka"] .ka-aperture-map__state span,
body[data-surface="ka"] .ka-resultant-map span,
body[data-surface="ka"] .ka-kernel-map span,
body[data-surface="ka"] .ka-role-map span,
body[data-surface="ka"] .ka-state-flow span,
body[data-surface="ka"] .ka-quality-pairs span,
body[data-surface="ka"] .ka-quality-line > span,
body[data-surface="ka"] .ka-state-flow > p strong {
  font-size: var(--type-label);
}

body[data-surface="ka"] .ka-field-preview__node small,
body[data-surface="ka"] .ka-quality-pairs p,
body[data-surface="ka"] .ka-kernel-map__current small,
body[data-surface="ka"] .ka-role-grid p {
  font-size: var(--type-reading-small);
}
