/* ==========================================================================
   Knowledge Index chapter — normal-flow thesis + one five-state captured deck.
   The controller owns state timing; CSS owns only the stable composition.
   ========================================================================== */

.index-prelude {
  min-height: 100svh;
  background: #000;
  color: #f2f0ec;
}

.index-prelude > .sheet {
  min-height: 100svh;
  display: flex;
  align-items: center;
}

.ix-prelude-copy {
  position: absolute;
  left: calc(150 * var(--u));
  top: 50%;
  width: calc(1140 * var(--u));
  transform: translateY(-50%);
}

.ix-prelude-copy .label-row-s {
  position: static;
  display: flex;
  margin-bottom: calc(26 * var(--u));
}

.ix-prelude-copy .label-row-s .ld { background: #9a9a92; }
.ix-prelude-copy .label-row-s .lt { color: #f2f2f2; }

.ix-prelude-copy h2 {
  max-width: calc(1140 * var(--u));
  margin: 0;
  color: #f2f0ec;
  font-family: var(--serif);
  font-size: calc(42 * var(--u));
  font-weight: 400;
  line-height: calc(55 * var(--u));
}

.ix-sentinel {
  position: relative;
  z-index: 0;
  height: 0;
  pointer-events: none;
}

.index-chapter {
  position: relative;
  height: 180svh;
  background: #000;
}

.index-chapter .ix-pin {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
  background: linear-gradient(180deg, #000 0%, #000 90%, #232321 100%);
}

.index-chapter .ix-stage {
  position: relative;
  width: calc(1440 * var(--u));
  height: 100%;
  margin: 0 auto;
}

.index-chapter .ix-copy-pane,
.index-chapter .ix-atom-pane {
  position: absolute;
}

.index-chapter .ix-copy-pane {
  inset: 0;
}

.index-chapter .ix-atom-pane {
  left: calc(812 * var(--u));
  top: 50%;
  width: calc(520 * var(--u));
  height: calc(400 * var(--u));
  transform: translateY(-50%);
}

.index-chapter .ix-slide {
  position: absolute;
  left: calc(150 * var(--u));
  top: 50%;
  width: calc(560 * var(--u));
  margin: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-50%);
  will-change: opacity;
}

.index-chapter .ix-slide.live {
  opacity: 1;
  visibility: visible;
}

.index-chapter .ix-slide small {
  display: block;
  margin: 0 0 calc(18 * var(--u));
  color: #9a9a92;
  font-family: "IBM Plex Mono", monospace;
  font-size: calc(12 * var(--cu));
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.index-chapter .ix-slide h3 {
  max-width: calc(560 * var(--u));
  margin: 0 0 calc(18 * var(--u));
  color: #f2f0ec;
  font-family: var(--serif);
  font-size: calc(42 * var(--u));
  font-weight: 400;
  line-height: calc(58 * var(--u));
}

.index-chapter .ix-slide p {
  max-width: calc(572 * var(--cu));
  margin: 0;
  color: rgba(242, 240, 236, 0.80);
  font-family: var(--sans);
  font-size: calc(18 * var(--cu));
  line-height: calc(31 * var(--cu));
}

.index-chapter .ix-body-section {
  display: block;
}

.index-chapter .ix-body-section + .ix-body-section {
  margin-top: calc(12 * var(--cu));
}

.index-chapter .x-field,
.index-chapter [data-x-field] {
  position: absolute;
  left: 0;
  top: 0;
  width: 520px;
  height: 400px;
  margin: 0;
  transform-origin: top left;
}

.index-chapter .x-atom {
  background: #45453f;
  will-change: auto;
}
.index-chapter .x-atom.on { background: #e6e3da; }
.index-chapter .x-atom.on.shade-1 { background: #8f8c84; }
.index-chapter .x-atom.on.shade-2 { background: #a8a59c; }
.index-chapter .x-atom.on.shade-3 { background: #c6c3ba; }
.index-chapter .x-atom.on.shade-4 { background: #f0ede6; }

.index-chapter[data-ix-state="3"] .x-atom.on,
.index-chapter[data-ix-target="3"] .x-atom.on {
  filter: brightness(0.72) saturate(0.9);
}

.index-chapter.ix-resolving .x-atom.on { box-shadow: 0 0 12px rgba(245, 243, 239, 0.28); }
.index-chapter.ix-resolving .x-atom.on[data-col="0"] { background: #fbfaf7; }
.index-chapter.ix-resolving .x-atom.on[data-col="1"] { background: #f3f1ec; }
.index-chapter.ix-resolving .x-atom.on[data-col="2"] { background: #eae7e1; }
.index-chapter.ix-resolving .x-atom.on[data-col="3"] { background: #e0ddd5; }
.index-chapter.ix-resolving .x-atom.on[data-col="4"] { background: #d5d2c9; }
.index-chapter.ix-resolving .x-atom.on[data-col="5"] { background: #c9c6bc; }
.index-chapter.ix-resolving .x-atom.on[data-col="6"] { background: #bcb9af; }
.index-chapter.ix-resolving .x-atom.on[data-col="7"] { background: #aeaba1; }
.index-chapter.ix-resolving .x-atom.on[data-col="8"] { background: #9f9c92; }
.index-chapter.ix-resolving .x-atom.on[data-col="9"] { background: #8f8c84; }

@media (max-width: 900px) {
  .index-prelude,
  .index-prelude > .sheet {
    min-height: clamp(520px, 70svh, 620px);
  }

  .index-prelude > .sheet {
    width: 100%;
    height: auto !important;
    padding: clamp(68px, 10svh, 90px) 20px;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    text-align: center;
  }

  .index-prelude {
    position: relative;
    overflow: hidden;
    isolation: isolate;
  }

  .index-prelude > .sheet { position: relative; z-index: 1; }

  .index-prelude > .sheet > .ix-prelude-copy {
    position: relative;
    left: auto;
    top: auto;
    width: min(100%, 360px);
    padding: 0;
    transform: none;
  }

  .ix-prelude-copy .label-row-s {
    justify-content: center;
    margin-bottom: 20px;
  }
  .ix-prelude-copy .label-row-s .ld { width: 14px; height: 14px; }
  .ix-prelude-copy .label-row-s .lt { font-size: 12px; line-height: 14px; }

  .ix-prelude-copy h2 {
    max-width: min(100%, 350px);
    margin-right: auto;
    margin-left: auto;
    font-size: 22px;
    line-height: 27.456px;
    text-align: center;
    text-wrap: balance;
  }

  .index-chapter {
    height: auto;
    min-height: 0;
    overflow-x: clip;
  }

  .index-chapter .ix-pin {
    position: relative;
    top: auto;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .index-chapter .ix-stage {
    width: 100%;
    height: auto;
  }

  .index-chapter .ix-atom-pane {
    position: sticky;
    left: auto;
    right: auto;
    top: 0;
    width: calc(100% - 52px);
    height: 42svh;
    margin-right: auto;
    margin-left: auto;
    transform: none;
    z-index: 2;
    overflow: hidden;
    background: linear-gradient(180deg, #000 0%, #000 78%, rgba(0,0,0,0.96) 90%, rgba(0,0,0,0) 100%);
  }

  .index-chapter .ix-copy-pane {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    z-index: 1;
    margin-top: -42svh;
    padding: 0 20px 20px;
    overflow: visible;
    background: #000;
  }

  .index-chapter .ix-slide {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    width: auto;
    min-height: 100svh;
    padding: 40svh 0 0;
    box-sizing: border-box;
    display: block;
    opacity: 1;
    visibility: visible;
    transform: none;
  }

  .index-chapter .ix-slide-copy {
    position: sticky;
    top: 40svh;
    width: min(100%, 360px);
    margin: 0 auto;
    padding: 0 0 8svh;
    box-sizing: border-box;
    background: #000;
    text-align: center;
  }

  .index-chapter .ix-slide small {
    text-align: center;
    margin-bottom: 13px;
    font-size: var(--mobile-meta-size, 10px);
  }

  .index-chapter .ix-slide h3 {
    width: min(100%, 350px);
    min-height: 94px;
    margin: 0 auto 17px;
    font-size: clamp(27px, 7.2vw, 31px);
    line-height: 1.1;
    text-align: center;
    text-wrap: balance;
  }
  .index-chapter .ix-slide h3 br { display: none; }

  .index-chapter .ix-slide p {
    max-width: 334px;
    margin-right: auto;
    margin-left: auto;
    font-size: var(--mobile-body-size, 15px);
    line-height: var(--mobile-body-leading, 1.52);
    text-align: center;
    text-wrap: pretty;
  }

  .index-chapter .ix-body-section + .ix-body-section {
    margin-top: 0.72em;
  }
  .index-chapter .ix-slide strong.ix-body-section {
    font-family: var(--serif);
    font-size: clamp(18px, 4.9vw, 21px);
    font-weight: 400;
    line-height: 1.3;
    text-wrap: balance;
  }

  /* Mobile scroll directly scrubs the lattice, so give that progression a
     wider monochrome range than desktop and continuously sweep brightness
     across each transition. Class changes remain staggered per atom; this
     makes the cumulative greyscale change unmistakable instead of a subtle
     flicker between neighbouring mid-greys. */
  .index-chapter .x-atom {
    background: #2b2b27;
    transition: background-color 90ms linear, filter 90ms linear, box-shadow 90ms linear;
  }
  .index-chapter .x-atom.on {
    filter: brightness(calc(0.58 + var(--ix-mobile-progress, 1) * 0.62)) contrast(1.12);
  }
  .index-chapter .x-atom.on.shade-1 { background: #55534e; }
  .index-chapter .x-atom.on.shade-2 { background: #85827a; }
  .index-chapter .x-atom.on.shade-3 { background: #c9c5ba; }
  .index-chapter .x-atom.on.shade-4 { background: #fffdf6; }
  .index-chapter[data-ix-state="3"] .x-atom.on,
  .index-chapter[data-ix-target="3"] .x-atom.on {
    filter: brightness(calc(0.50 + var(--ix-mobile-progress, 1) * 0.58)) contrast(1.16);
  }
}

@media (max-width: 900px) and (max-height: 620px) {
  .index-chapter .ix-atom-pane {
    height: 38svh;
  }

  .index-chapter .ix-copy-pane {
    margin-top: -38svh;
    padding-bottom: 10px;
  }

  .index-chapter .ix-slide {
    min-height: 135svh;
    padding: 38svh 0 0;
  }

  .index-chapter .ix-slide-copy {
    top: 38svh;
    padding: 4svh 0 6svh;
  }

  .index-chapter .ix-slide small {
    margin-bottom: 8px;
    font-size: 8.5px;
  }

  .index-chapter .ix-slide h3 {
    margin-bottom: 9px;
    font-size: 23px;
    line-height: 1.14;
  }

  .index-chapter .ix-slide p {
    font-size: 13.5px;
    line-height: 1.34;
  }

  .index-prelude > .sheet { padding-top: clamp(58px, 13svh, 76px); }
}

@media (prefers-reduced-motion: reduce) {
  .index-chapter .x-atom { transition: none; }
}

/* --- per-word stage reveal (Tarak 2026-07-28) -----------------------------
   index-controller.js splits the stage copy into .ix-word spans and drives
   their opacity/blur from the deck's own copyProgress. inline-block is what
   makes a per-word transform/filter render at all; the negative-margin trick
   is unnecessary because the splitter preserves the original whitespace text
   nodes between words. */
.x-step .ix-word {
  display: inline-block;
  will-change: opacity, filter;
}

/* Links keep their own decoration: the word spans sit INSIDE the anchor, so
   without this the underline breaks into per-word segments. */
.x-step a .ix-word { display: inline; will-change: auto; }

@media (prefers-reduced-motion: reduce) {
  .x-step .ix-word { display: inline; opacity: 1 !important; filter: none !important; will-change: auto; }
}
