/* ════════════════════════════════════════════════════════════════════════
   Khipu Research Labs — Cohort 01
   Hybrid Dark Editorial — Arumira/Khipu design system
   ════════════════════════════════════════════════════════════════════════ */

@import url('../lib/krl-tokens.css');

:root {
  /* Tweakable parameters (overridden by Tweaks panel) */
  --t-bg:           var(--krl-bg);            /* #0A0F1A */
  --t-surface:      var(--krl-surface);       /* #111827 */
  --t-surface-hi:   var(--krl-surface-raised);
  --t-fg1:          var(--krl-fg1);
  --t-fg2:          var(--krl-fg2);
  --t-fg3:          var(--krl-fg3);
  --t-rule:         rgba(249, 250, 251, 0.08);
  --t-rule-strong:  rgba(249, 250, 251, 0.16);

  /* Editorial accent — defaults to gold (system primary CTA color),
     functions as the "oxblood substitute" of the original page */
  --t-accent:       var(--krl-accent);        /* #C7953F gold */
  --t-accent-deep:  #A6792B;
  --t-accent-faint: rgba(199, 149, 63, 0.10);

  /* Type weights — tweakable */
  --t-display-weight: 300;
  --t-wonk: 1;

  /* Rhythm */
  --t-gutter: clamp(20px, 4vw, 64px);
  --t-rule-w: 0.5px;
  --t-measure: 60ch;

  --t-ease: var(--krl-ease);
}

/* Light-mode override (also applied via system pref when data-theme="system") */
[data-theme="light"],
[data-theme="system"] {
  --t-bg:           #F4F1EA;
  --t-surface:      #ECE8DD;
  --t-surface-hi:   #E2DCCD;
  --t-fg1:          #1A1A1A;
  --t-fg2:          #3A352E;
  --t-fg3:          #6B6358;
  --t-rule:         rgba(26, 26, 26, 0.10);
  --t-rule-strong:  rgba(26, 26, 26, 0.20);
}
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --t-bg:           var(--krl-bg);
    --t-surface:      var(--krl-surface);
    --t-surface-hi:   var(--krl-surface-raised);
    --t-fg1:          var(--krl-fg1);
    --t-fg2:          var(--krl-fg2);
    --t-fg3:          var(--krl-fg3);
    --t-rule:         rgba(249, 250, 251, 0.08);
    --t-rule-strong:  rgba(249, 250, 251, 0.16);
  }
}

/* Accent variants */
[data-accent="oxblood"] {
  --t-accent:       #B5462E;
  --t-accent-deep:  #8B2A1F;
  --t-accent-faint: rgba(181, 70, 46, 0.12);
}
[data-accent="blue"] {
  --t-accent:       #4D9DC2;
  --t-accent-deep:  #1B6B93;
  --t-accent-faint: rgba(77, 157, 194, 0.12);
}
[data-accent="gold"] {
  --t-accent:       #C7953F;
  --t-accent-deep:  #A6792B;
  --t-accent-faint: rgba(199, 149, 63, 0.10);
}

/* Auto accent: tracks resolved theme.
   - light theme  → oxblood
   - dark theme   → blue
   - system theme → oxblood by default, blue when OS prefers dark */
[data-accent="auto"] {
  --t-accent:       #B5462E;
  --t-accent-deep:  #8B2A1F;
  --t-accent-faint: rgba(181, 70, 46, 0.12);
}
[data-theme="dark"][data-accent="auto"] {
  --t-accent:       #4D9DC2;
  --t-accent-deep:  #1B6B93;
  --t-accent-faint: rgba(77, 157, 194, 0.12);
}
@media (prefers-color-scheme: dark) {
  [data-theme="system"][data-accent="auto"] {
    --t-accent:       #4D9DC2;
    --t-accent-deep:  #1B6B93;
    --t-accent-faint: rgba(77, 157, 194, 0.12);
  }
}

/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  background: var(--t-bg);
  color: var(--t-fg1);
  font-family: var(--krl-font-sans);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'kern','liga','calt','cv02','cv03','cv11';
  transition: background 240ms var(--t-ease), color 240ms var(--t-ease);
}

/* Faint horizontal rule texture (page lines, like a ledger) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    0deg, transparent 0, transparent 31px,
    var(--t-rule) 31px, var(--t-rule) 32px
  );
  z-index: 0;
  opacity: 0.5;
}

/* Waves background — interactive dot mesh, drawn between the rule texture and content.
   z-index 0 with body::before also at 0, but the canvas comes later in DOM so paints on top
   of the rule pattern. main is z:1 so all content sits above the waves. */
.waves-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  display: block;
}
/* Hide on print */
@media print { .waves-bg { display: none; } }

/* ── Skip link ────────────────────────────────────────── */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--t-fg1); color: var(--t-bg);
  padding: 8px 14px; text-decoration: none;
  font-family: var(--krl-font-mono); font-size: 12px; z-index: 100;
}
.skip-link:focus { left: 12px; top: 12px; }

/* ── Layout primitives ────────────────────────────────── */
.container {
  width: 100%; max-width: 1240px;
  margin: 0 auto; padding: 0 var(--t-gutter);
  position: relative;
}
.container--narrow { max-width: 760px; }

main { position: relative; z-index: 1; }

.section {
  padding: clamp(80px, 12vw, 180px) 0;
  position: relative;
}

/* Two-column split: numbered label rail + body */
.split {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: clamp(40px, 6vw, 96px);
  align-items: start;
}
@media (max-width: 820px) {
  .split { grid-template-columns: 1fr; gap: 24px; }
}

.split__label {
  position: sticky; top: 100px;
  display: flex; flex-direction: column; gap: 2px;
}

/* Numerals — three modes (Kastroo is the brand Didone display; perfect for big section numerals) */
.numeral {
  font-family: var(--krl-font-display);
  color: var(--t-accent);
  letter-spacing: -0.02em;
  font-feature-settings: 'lnum';
  line-height: 0.85;
}
[data-numerals="small"] .numeral {
  font-size: 22px; font-weight: 400;
}
[data-numerals="drop"] .numeral {
  font-size: clamp(64px, 7vw, 112px);
  font-weight: 300;
  font-style: italic;
  margin-bottom: 4px;
}
[data-numerals="mono"] .numeral {
  font-family: var(--krl-font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--t-accent);
}

.label {
  font-family: var(--krl-font-mark);
  font-size: 11px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--t-fg2);
  font-weight: 400;
}

/* ── Page chrome (top bar) ────────────────────────────── */
.chrome {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--t-bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: var(--t-rule-w) solid var(--t-rule);
}
.chrome__inner {
  max-width: 1240px; margin: 0 auto;
  padding: 14px var(--t-gutter);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}

.mark {
  display: inline-flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--t-fg1);
  min-width: 0;
}
.mark__glyph {
  width: 28px; height: 28px;
  flex: 0 0 auto;
  display: block;
  /* PNG logo is red on transparent — accent-shift via CSS filter so it tracks oxblood/gold/blue accent */
  object-fit: contain;
}
.mark__text { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.mark__name {
  font-family: var(--krl-font-mark);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
}
.mark__tag {
  font-family: var(--krl-font-mono);
  font-size: 9px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--t-fg3);
  margin-top: 4px;
}

.chrome__stamp {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border: var(--t-rule-w) solid var(--t-rule-strong);
  font-family: var(--krl-font-display);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--t-fg2);
  border-radius: var(--krl-r-sm);
  white-space: nowrap;
  flex-shrink: 0;
}
.mark__tag { white-space: nowrap; }
.stamp__dot {
  width: 6px; height: 6px;
  background: var(--t-accent);
  border-radius: 50%;
  animation: pulse 2.4s var(--t-ease) infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.45; transform: scale(1); }
  50%      { opacity: 1; transform: scale(1.25); }
}

@media (max-width: 520px) {
  .mark__tag { display: none; }
  .mark__name { font-size: 12px; letter-spacing: 0.14em; }
  .mark__glyph { width: 24px; height: 24px; }
  .chrome__stamp { padding: 5px 9px; font-size: 10px; letter-spacing: 0.12em; }
  .chrome__inner { padding: 12px 16px; gap: 10px; }
}
@media (max-width: 380px) {
  .chrome__stamp .stamp__label-long { display: none; }
}

/* ── Vertical scroll thread ───────────────────────────── */
.thread {
  position: fixed; top: 0;
  left: clamp(8px, 1.6vw, 22px);
  height: 100vh; width: 4px;
  pointer-events: none; z-index: 5;
}
@media (max-width: 820px) { .thread { display: none; } }
.thread__svg { width: 100%; height: 100%; }
.thread__line {
  stroke: var(--t-fg3);
  stroke-width: 1;
  stroke-dasharray: 1, 4;
  opacity: 0.4;
}
.thread__progress {
  position: absolute; top: 0; left: 0;
  width: 4px; background: var(--t-accent);
  height: 0;
  transition: height 80ms linear;
}

/* ── Hero ─────────────────────────────────────────────── */
.hero {
  padding: clamp(80px, 12vw, 160px) 0 clamp(72px, 10vw, 120px);
  position: relative;
  overflow: hidden;
}
.hero__inner { position: relative; z-index: 2; max-width: 1100px; }

.kicker {
  font-family: var(--krl-font-display);
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--t-accent);
  margin: 0 0 32px;
  display: inline-flex;
  align-items: center; gap: 12px;
}
.kicker::before {
  content: ''; width: 28px; height: 1px;
  background: var(--t-accent);
}

.hero__h {
  font-family: var(--krl-font-headline);
  font-weight: var(--t-display-weight);
  font-size: clamp(56px, 11vw, 156px);
  line-height: 0.92;
  letter-spacing: -0.025em;
  margin: 0 0 40px;
  color: var(--t-fg1);
}
.hero__line { display: block; }
.hero__line--accent {
  font-style: italic;
  color: var(--t-accent);
  font-feature-settings: 'wonk' var(--t-wonk);
}

.hero__sub {
  font-family: var(--krl-font-headline);
  font-weight: 400;
  font-size: clamp(18px, 1.8vw, 23px);
  line-height: 1.5;
  max-width: 56ch;
  margin: 0 0 40px;
  color: var(--t-fg2);
  letter-spacing: -0.005em;
}

.hero__meta {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 14px 22px;
  font-family: var(--krl-font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--t-fg2);
  margin: 0 0 56px;
}
.meta__item {
  display: inline-flex; gap: 8px; align-items: baseline;
}
.meta__k {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--t-fg1);
  font-size: 10px;
  font-weight: 500;
}
.meta__v {
  font-variant-numeric: tabular-nums;
}
.meta__sep { color: var(--t-rule-strong); }

@media (max-width: 520px) {
  .meta__sep { display: none; }
  .hero__meta { gap: 10px 14px; }
}

.hero__cue {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 0;
  font-family: var(--krl-font-mono);
  font-size: 11px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--t-fg3);
  text-decoration: none;
  transition: color 200ms var(--t-ease);
}
.hero__cue svg { transition: transform 400ms var(--t-ease); }
.hero__cue:hover { color: var(--t-accent); }
.hero__cue:hover svg { transform: translateY(4px); }

/* Reveal stagger */
.reveal {
  opacity: 0; transform: translateY(14px);
  animation: reveal 900ms var(--t-ease) forwards;
  animation-delay: var(--d, 0ms);
}
@keyframes reveal { to { opacity: 1; transform: translateY(0); } }

/* ── Hero ambient khipu canvas ────────────────────────── */
.hero__khipu {
  position: absolute;
  top: 0; right: -4%; bottom: 0;
  width: 56%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.78;
  mask-image: linear-gradient(to right, transparent 0%, #000 28%, #000 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 28%, #000 100%);
}
.hero__khipu svg { width: 100%; height: 100%; display: block; }
@media (max-width: 820px) {
  .hero__khipu { width: 78%; right: -10%; opacity: 0.35; }
}

/* ── Section typography ───────────────────────────────── */
.h2 {
  font-family: var(--krl-font-headline);
  font-weight: 350;
  font-size: clamp(34px, 4.6vw, 60px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 0 0 28px;
  color: var(--t-fg1);
  max-width: 22ch;
}
.h2 em {
  font-style: italic;
  color: var(--t-accent);
  font-feature-settings: 'wonk' var(--t-wonk);
}

.lede {
  font-family: var(--krl-font-headline);
  font-weight: 400;
  font-size: clamp(17px, 1.4vw, 19.5px);
  line-height: 1.6;
  color: var(--t-fg2);
  max-width: var(--t-measure);
  margin: 0 0 18px;
  letter-spacing: -0.003em;
}
.lede em {
  font-style: italic;
  color: var(--t-accent);
  font-feature-settings: 'wonk' var(--t-wonk);
}

.caps {
  font-family: var(--krl-font-mono);
  font-size: 0.82em;
  letter-spacing: 0.06em;
  color: var(--t-fg1);
  background: var(--t-accent-faint);
  padding: 1px 7px;
  border-radius: 2px;
  white-space: nowrap;
}

.section--premise {
  border-top: var(--t-rule-w) solid var(--t-rule);
}

/* ── Ledger ───────────────────────────────────────────── */
.section--ledger {
  background: var(--t-surface);
  border-top: var(--t-rule-w) solid var(--t-rule);
  border-bottom: var(--t-rule-w) solid var(--t-rule);
}

.ledger {
  margin-top: 64px;
  position: relative;
}

.ledger-stage {
  position: relative;
  padding: 64px 0 32px;
  min-height: 220px;
}
[data-orient="vertical"] .ledger-stage {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 64px;
  padding: 32px 0;
  align-items: start;
}
@media (max-width: 820px) {
  [data-orient="vertical"] .ledger-stage { grid-template-columns: 1fr; gap: 32px; }
}

/* Woven cord SVG layer */
.ledger__cord {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
[data-orient="horizontal"] .ledger__cord svg { width: 100%; height: 140px; }
[data-orient="vertical"] .ledger__cord {
  position: relative; width: 280px; height: auto;
}
[data-orient="vertical"] .ledger__cord svg { width: 100%; height: 600px; }

.cord__strand {
  fill: none;
  stroke: var(--t-fg2);
  stroke-width: 0.6;
  opacity: 0.55;
}
.cord__strand--accent {
  stroke: var(--t-accent);
  opacity: 0.35;
}

.ledger__list {
  list-style: none; margin: 0; padding: 0;
  position: relative; z-index: 2;
}
[data-orient="horizontal"] .ledger__list {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
}
[data-orient="vertical"] .ledger__list {
  display: flex; flex-direction: column;
  gap: 64px;
  padding-top: 80px;
}
@media (max-width: 820px) {
  [data-orient="horizontal"] .ledger__list { grid-template-columns: repeat(3, 1fr); row-gap: 56px; }
}
@media (max-width: 560px) {
  /* Replaced by mobile ledger redesign at end of file */
}

.knot {
  appearance: none; background: transparent; border: 0; padding: 0;
  display: flex; flex-direction: column; align-items: center;
  gap: 18px;
  cursor: pointer;
  font-family: var(--krl-font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--t-fg3);
  transition: color 240ms var(--t-ease);
  position: relative;
}
[data-orient="vertical"] .knot {
  flex-direction: row;
  justify-content: flex-start;
  width: 100%;
  gap: 24px;
}

.knot__core {
  position: relative;
  width: 16px; height: 16px;
  display: grid; place-items: center;
}
.knot__node {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--t-bg);
  border: 1.25px solid var(--t-fg2);
  position: relative;
  transition: all 280ms var(--t-ease);
}
/* Secondary "standards rating" knots stacked above the main node */
.knot__rating {
  position: absolute;
  top: -22px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 3px;
  opacity: 0.55;
  transition: opacity 240ms var(--t-ease);
}
[data-orient="vertical"] .knot__rating {
  position: absolute;
  top: 50%; left: -28px;
  transform: translateY(-50%);
  flex-direction: column;
}
.knot__rating-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--t-fg2);
}
.knot__rating-dot.is-on { background: var(--t-accent); }

/* hover halo */
.knot__halo {
  position: absolute; inset: -10px;
  border-radius: 50%;
  border: 1px solid var(--t-accent);
  opacity: 0;
  transform: scale(0.6);
  transition: all 320ms var(--t-ease);
}

.knot:hover { color: var(--t-fg1); }
.knot:hover .knot__node {
  background: var(--t-accent);
  border-color: var(--t-accent);
  transform: scale(1.15);
}
.knot:hover .knot__rating { opacity: 1; }

.knot[aria-selected="true"] { color: var(--t-accent); }
.knot[aria-selected="true"] .knot__node {
  background: var(--t-accent);
  border-color: var(--t-accent-deep);
  box-shadow: 0 0 0 4px var(--t-surface), 0 0 0 5px var(--t-accent);
}
.knot[aria-selected="true"] .knot__halo {
  opacity: 1; transform: scale(1);
}
.knot[aria-selected="true"] .knot__rating { opacity: 1; }

.knot:focus-visible {
  outline: 2px solid var(--t-accent);
  outline-offset: 8px;
  border-radius: 2px;
}

/* hover trail — subtle stroke from previously-hovered knot to current */
.ledger__trail {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 1;
}
.trail__path {
  fill: none;
  stroke: var(--t-accent);
  stroke-width: 1;
  stroke-dasharray: 2, 4;
  opacity: 0;
  transition: opacity 240ms var(--t-ease);
}
.trail__path.is-on { opacity: 0.45; }

/* Detail panel */
.method-panel {
  margin-top: 56px;
  padding: 36px 40px;
  background: var(--t-bg);
  border: var(--t-rule-w) solid var(--t-rule-strong);
  border-top: 2px solid var(--t-accent);
  border-radius: var(--krl-r-lg);
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 48px;
  min-height: 220px;
  position: relative;
  z-index: 2;
  box-shadow: var(--krl-shadow-2);
}
[data-orient="vertical"] .method-panel { margin-top: 32px; }
@media (max-width: 820px) {
  .method-panel { grid-template-columns: 1fr; padding: 24px; gap: 24px; }
}

.method-panel__abbr {
  font-family: var(--krl-font-mono);
  font-size: 11px;
  letter-spacing: 0.20em;
  color: var(--t-accent);
  text-transform: uppercase;
  margin: 0 0 10px;
}
.method-panel__title {
  font-family: var(--krl-font-headline);
  font-weight: 400;
  font-size: 32px;
  line-height: 1.05;
  letter-spacing: -0.015em;
  margin: 0 0 16px;
  color: var(--t-fg1);
}
.method-panel__body {
  font-family: var(--krl-font-headline);
  font-size: 16px;
  line-height: 1.6;
  color: var(--t-fg2);
  margin: 0;
}

.method-panel__list {
  font-family: var(--krl-font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--t-fg2);
  list-style: none; margin: 0; padding: 0;
}
.method-panel__list li {
  display: flex; gap: 14px;
  padding: 8px 0;
  border-bottom: var(--t-rule-w) solid var(--t-rule);
}
.method-panel__list li:last-child { border-bottom: 0; }
.method-panel__list .k {
  flex: 0 0 110px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 10px;
  color: var(--t-fg3);
  padding-top: 1px;
}
.method-panel__list .v { color: var(--t-fg1); flex: 1; }

.method-panel.is-fading { opacity: 0; transition: opacity 120ms var(--t-ease); }

/* ── Cohort terms ─────────────────────────────────────── */
.terms {
  margin: 36px 0 0; padding: 0;
  border-top: var(--t-rule-w) solid var(--t-rule);
}
.terms__row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
  padding: 24px 0;
  border-bottom: var(--t-rule-w) solid var(--t-rule);
}
@media (max-width: 600px) {
  .terms__row { grid-template-columns: 1fr; gap: 6px; }
}
.terms dt {
  font-family: var(--krl-font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--t-accent);
  padding-top: 4px;
}
.terms dd {
  font-family: var(--krl-font-headline);
  font-size: 18px;
  line-height: 1.55;
  color: var(--t-fg2);
  margin: 0;
  letter-spacing: -0.005em;
}

/* ── Not-for ──────────────────────────────────────────── */
.section--not-for {
  background: #050810;
  color: var(--krl-fg1);
  padding: clamp(72px, 10vw, 140px) 0;
  border-top: 2px solid var(--t-accent);
}
[data-theme="light"] .section--not-for {
  background: #1A1A1A; color: #F4F1EA;
}
.not-for {
  max-width: 760px; margin: 0 auto;
  text-align: center;
}
.not-for__lead {
  font-family: var(--krl-font-mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--t-accent);
  margin: 0 0 24px;
}
.not-for__body {
  font-family: var(--krl-font-headline);
  font-weight: 350;
  font-size: clamp(22px, 2.4vw, 30px);
  line-height: 1.4;
  margin: 0;
  letter-spacing: -0.01em;
}
.not-for__body em {
  font-style: italic;
  color: var(--t-accent);
  font-feature-settings: 'wonk' var(--t-wonk);
}

/* ── Form ─────────────────────────────────────────────── */
.section--form {
  border-top: var(--t-rule-w) solid var(--t-rule);
}
.form-wrap { position: relative; }
.form { margin-top: 32px; }

.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

.field { margin-bottom: 32px; }
.field__label {
  display: block;
  font-family: var(--krl-font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--t-fg2);
  margin-bottom: 12px;
}
.field__hint {
  display: block; margin-top: 4px;
  font-family: var(--krl-font-sans);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--t-fg3);
}

.field input,
.field textarea {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--t-rule-strong);
  padding: 12px 0;
  font-family: var(--krl-font-headline);
  font-size: 19px;
  color: var(--t-fg1);
  transition: border-color 200ms var(--t-ease), background 200ms var(--t-ease);
  resize: vertical;
}
.field textarea {
  /* Textareas get a real container so the writing surface is unmistakable.
     Inputs stay on a single underline — they read fine because they're one line. */
  border: 1px solid var(--t-rule-strong);
  background: var(--t-surface);
  padding: 14px 16px;
  border-radius: 2px;
  font-family: var(--krl-font-sans);
  font-size: 17px;
  line-height: 1.55;
  min-height: 7em;
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-bottom-color: var(--t-accent);
}
.field textarea:focus {
  border-color: var(--t-accent);
  box-shadow: inset 0 0 0 1px var(--t-accent);
}
.field input::placeholder,
.field textarea::placeholder {
  color: var(--t-fg3);
  font-style: italic;
}
.field--error input, .field--error textarea {
  border-bottom-color: var(--t-accent);
}
.field--error textarea {
  border-color: var(--t-accent);
}
.field__error {
  margin: 6px 0 0; min-height: 1.2em;
  font-family: var(--krl-font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--t-accent);
}
.field__counter {
  margin: 6px 0 0; text-align: right;
  font-family: var(--krl-font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--t-fg3);
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex; align-items: center; gap: 14px;
  padding: 16px 28px;
  background: var(--t-accent);
  color: #FAF8F2;
  border: 0;
  font-family: var(--krl-font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 200ms var(--t-ease);
  border-radius: var(--krl-r-md);
  position: relative; overflow: hidden;
}
.btn__arrow { transition: transform 320ms var(--t-ease); }
.btn:hover { background: var(--t-accent-deep); color: var(--t-fg1); }
.btn:hover .btn__arrow { transform: translateX(6px); }
.btn:focus-visible {
  outline: 2px solid var(--t-accent);
  outline-offset: 4px;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.form__note {
  margin-top: 20px;
  font-family: var(--krl-font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--t-fg3);
  max-width: 56ch;
  line-height: 1.6;
}

/* ── Apply (CTA card → application.html) ──────────────── */
.section--apply {
  border-top: var(--t-rule-w) solid var(--t-rule);
}
.apply-wrap {
  position: relative;
  padding: 8px 0;
}
.apply-steps {
  list-style: none;
  margin: 36px 0 36px;
  padding: 28px 0;
  border-top: 1px solid var(--t-rule);
  border-bottom: 1px solid var(--t-rule);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  counter-reset: appstep;
}
.apply-steps li {
  display: flex; flex-direction: column; gap: 8px;
  padding-left: 0;
  position: relative;
}
.apply-steps li::before {
  content: '';
  position: absolute;
  top: 6px;
  left: -14px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--t-accent);
  opacity: 0.7;
}
.apply-steps__num {
  font-family: var(--krl-font-headline);
  font-style: italic;
  font-size: 22px;
  font-weight: 300;
  color: var(--t-accent);
  line-height: 1;
  letter-spacing: -0.01em;
}
.apply-steps__label {
  font-family: var(--krl-font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--t-fg2);
  line-height: 1.4;
}
.apply-cta {
  margin-top: 8px;
}
@media (max-width: 640px) {
  .apply-steps {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 22px 0;
    margin: 28px 0;
  }
  .apply-steps li {
    flex-direction: row; align-items: baseline; gap: 14px;
    padding-left: 16px;
  }
  .apply-steps li::before { top: 50%; transform: translateY(-50%); left: 0; }
  .apply-steps__num { font-size: 20px; flex-shrink: 0; min-width: 1.4em; }
  .apply-steps__label { font-size: 11px; letter-spacing: 0.12em; }
}

/* ── Receipt (kept for application.html success state) ── */
.receipt {
  margin: 32px 0 0;
  padding: 40px 44px 36px;
  border: 1px solid var(--t-rule-strong);
  background:
    repeating-linear-gradient(0deg,
      transparent 0, transparent 27px,
      var(--t-rule) 27px, var(--t-rule) 28px),
    var(--t-bg);
  border-radius: var(--krl-r-lg);
  position: relative;
  font-family: var(--krl-font-mono);
  animation: reveal 800ms var(--t-ease) forwards;
}
.receipt__perforation {
  position: absolute; top: -8px; left: 0; right: 0;
  height: 16px;
  background-image: radial-gradient(circle at 8px 8px, var(--t-bg) 5px, transparent 5.5px);
  background-size: 16px 16px;
  background-position: -8px 0;
}
.receipt__head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 24px;
  border-bottom: 1px solid var(--t-rule);
  padding-bottom: 20px; margin-bottom: 24px;
}
.receipt__title {
  font-family: var(--krl-font-display);
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--t-fg2);
  margin: 0 0 8px;
}
.receipt__h {
  font-family: var(--krl-font-headline);
  font-weight: 400;
  font-size: 36px;
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--t-fg1);
}
.receipt__h em { font-style: italic; color: var(--t-accent); }
.receipt__stamp {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 92px; height: 92px;
  border: 1.5px solid var(--t-accent);
  border-radius: 50%;
  color: var(--t-accent);
  font-family: var(--krl-font-display);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.2;
  transform: rotate(-8deg);
  position: relative;
}
.receipt__stamp::before {
  content: ''; position: absolute; inset: 4px;
  border: 0.5px solid var(--t-accent);
  border-radius: 50%;
  opacity: 0.5;
}
.receipt__stamp span { font-weight: 700; }

.receipt__rows { display: grid; gap: 12px; margin-bottom: 24px; }
.receipt__row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 16px;
  font-size: 12px;
  letter-spacing: 0.04em;
}
.receipt__row dt {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 10px;
  color: var(--t-fg3);
  margin: 0;
}
.receipt__row dd {
  margin: 0;
  color: var(--t-fg1);
  font-variant-numeric: tabular-nums;
}
.receipt__body {
  font-family: var(--krl-font-headline);
  font-size: 16px;
  line-height: 1.55;
  color: var(--t-fg2);
  margin: 0;
  letter-spacing: -0.005em;
}

/* ── Footer ───────────────────────────────────────────── */
.foot {
  border-top: var(--t-rule-w) solid var(--t-rule);
  padding: 36px 0;
  font-family: var(--krl-font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--t-fg3);
}
.foot__inner {
  display: flex; justify-content: space-between;
  flex-wrap: wrap; gap: 24px; align-items: flex-end;
}
.foot__left { display: flex; align-items: center; gap: 16px; }
.foot__mark-glyph {
  width: 22px; height: 22px;
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
}
.foot__mark-text {
  display: flex; flex-direction: column; gap: 4px;
}
.foot__mark {
  font-family: var(--krl-font-mark);
  color: var(--t-fg1);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 12px;
}
.foot__sub { color: var(--t-fg3); }
.foot__meta { letter-spacing: 0.10em; }

/* Footer "branded" mode — adds the khipu glyph and broader composition */
[data-footer="branded"] .foot {
  padding: 56px 0 40px;
}
[data-footer="branded"] .foot__inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 48px;
  align-items: end;
}
[data-footer="branded"] .foot__cord {
  display: block;
  height: 80px;
  width: 100%;
  opacity: 0.5;
  align-self: end;
}
[data-footer="minimal"] .foot__cord { display: none; }

/* Foot mark glyph: in dark theme add a faint inversion for legibility */
[data-theme="dark"] .foot__mark-glyph,
[data-theme="dark"] .mark__glyph {
  filter: brightness(1.05);
}

/* ── Mobile pass (≤640px and ≤420px) ────────────────────── */
@media (max-width: 640px) {
  :root { --t-gutter: 20px; }

  /* Hero */
  .hero { padding: 56px 0 48px; }
  .hero__h { font-size: clamp(44px, 13vw, 72px); margin: 0 0 28px; }
  .hero__sub { font-size: 17px; line-height: 1.5; margin: 0 0 28px; }
  .hero__meta { gap: 8px 14px; margin: 0 0 36px; font-size: 11px; }
  .kicker { margin: 0 0 22px; font-size: 10.5px; letter-spacing: 0.18em; }
  .kicker::before { width: 20px; }

  /* Section rhythm */
  .section { padding: 64px 0; }
  .h2 { font-size: clamp(28px, 7vw, 36px); margin: 0 0 20px; }
  .lede { font-size: 16px; }

  /* Numerals — drop italic gets tamer on mobile so it doesn't dominate */
  [data-numerals="drop"] .numeral { font-size: 56px; margin-bottom: 0; }
  .split__label { position: static; flex-direction: row; align-items: baseline; gap: 14px; margin-bottom: 4px; }
  [data-numerals="drop"] .split__label { align-items: flex-end; }

  /* Ledger */
  .ledger { margin-top: 40px; }
  .ledger-stage { padding: 48px 0 16px; }
  .knot { gap: 14px; font-size: 9.5px; letter-spacing: 0.12em; }
  .knot__rating { top: -18px; }
  .method-panel { margin-top: 32px; padding: 24px 20px; gap: 20px; border-radius: 12px; }
  .method-panel__title { font-size: 26px; }
  .method-panel__body { font-size: 15px; }
  .method-panel__list .k { flex: 0 0 92px; }

  /* Cohort terms */
  .terms__row { padding: 18px 0; }
  .terms dd { font-size: 16px; }

  /* Not-for */
  .not-for__body { font-size: clamp(19px, 5vw, 24px); }

  /* Form */
  .field input { font-size: 17px; padding: 10px 0; }
  .field textarea { font-size: 16px; padding: 12px 14px; min-height: 6em; }
  .btn { padding: 14px 22px; font-size: 11px; letter-spacing: 0.14em; width: 100%; justify-content: center; }

  /* Receipt */
  .receipt { padding: 28px 22px 24px; }
  .receipt__head { gap: 16px; padding-bottom: 16px; margin-bottom: 18px; }
  .receipt__h { font-size: 28px; }
  .receipt__stamp { width: 72px; height: 72px; font-size: 9px; letter-spacing: 0.14em; }
  .receipt__row { grid-template-columns: 1fr; gap: 2px; padding: 6px 0; border-bottom: 1px dashed var(--t-rule); }
  .receipt__row:last-child { border-bottom: 0; }
  .receipt__rows { gap: 4px; }

  /* Footer — collapse to single column at all footer modes */
  .foot { padding: 32px 0; }
  [data-footer="branded"] .foot { padding: 36px 0 28px; }
  [data-footer="branded"] .foot__inner {
    grid-template-columns: 1fr;
    gap: 20px;
    align-items: stretch;
  }
  [data-footer="branded"] .foot__cord { height: 48px; opacity: 0.4; }
  .foot__left { gap: 12px; }
  .foot__mark { font-size: 11px; letter-spacing: 0.14em; }
  .foot__sub, .foot__meta { font-size: 10.5px; letter-spacing: 0.06em; }
}

@media (max-width: 420px) {
  /* Hero ambient khipu fades further on tiny viewports — let copy breathe */
  .hero__khipu { width: 92%; right: -16%; opacity: 0.18; }
  /* Hero h1 wrap: "knotted in." gets its own line already, just tighten */
  .hero__h { font-size: clamp(40px, 14vw, 60px); }
}

/* ── Mobile ledger redesign (≤560px) ──────────────────────
   Compact horizontal cord-strip pattern: method-panel on top, with a tight
   stepper strip of 6 dots+line below it. Tap a dot to switch methods.
   Dots pulse to indicate current selection.
   Placed at end of file so it cascades over the earlier @media (max-width: 640px). */
@media (max-width: 560px) {
  /* Reverse order: method panel above, knot strip below. */
  [data-orient="vertical"] .ledger {
    display: flex;
    flex-direction: column-reverse;
    gap: 18px;
  }
  [data-orient="vertical"] .ledger-stage {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
    min-height: 0;
  }
  /* Hide heavy SVG cord — replaced by inline line in the dot strip */
  [data-orient="vertical"] .ledger__cord,
  [data-orient="vertical"] .ledger__trail {
    display: none;
  }
  /* The list becomes a horizontal strip with a thin line connecting dots */
  [data-orient="vertical"] .ledger__list {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between;
    align-items: center;
    gap: 0;
    padding: 14px 12px;
    border-top: 1px solid var(--t-rule);
    border-bottom: 1px solid var(--t-rule);
    position: relative;
  }
  /* The connecting cord line behind the dots */
  [data-orient="vertical"] .ledger__list::before {
    content: "";
    position: absolute;
    left: 22px; right: 22px;
    top: 50%; transform: translateY(-50%);
    height: 1px;
    background: var(--t-rule-strong);
    opacity: 0.5;
    z-index: 0;
  }
  [data-orient="vertical"] .ledger__list > li {
    border-bottom: 0;
    flex: 0 0 auto;
    position: relative;
    z-index: 1;
    background: var(--t-bg);
    padding: 0 4px;
  }
  /* Each knot becomes a tappable hit target with just the dot visible */
  [data-orient="vertical"] .knot {
    flex-direction: column;
    align-items: center;
    width: 36px;
    min-height: 36px;
    gap: 0;
    padding: 6px 0;
    background: var(--t-bg);
  }
  /* Hide the text label and rating dots on the strip — selection is shown by panel above */
  [data-orient="vertical"] .knot__label,
  [data-orient="vertical"] .knot__rating {
    display: none;
  }
  [data-orient="vertical"] .knot__core {
    width: 14px; height: 14px;
    flex-shrink: 0;
    place-items: center;
  }
  [data-orient="vertical"] .knot__node {
    width: 9px; height: 9px;
    background: var(--t-bg);
    border: 1.5px solid var(--t-fg2);
    transition: background 200ms var(--t-ease), border-color 200ms var(--t-ease), transform 200ms var(--t-ease);
  }
  /* Active dot: filled accent + pulse halo */
  [data-orient="vertical"] .knot[aria-selected="true"] .knot__node {
    background: var(--t-accent);
    border-color: var(--t-accent);
    transform: scale(1.15);
  }
  [data-orient="vertical"] .knot__halo {
    display: block;
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid var(--t-accent);
    opacity: 0;
    pointer-events: none;
  }
  [data-orient="vertical"] .knot[aria-selected="true"] .knot__halo {
    animation: knot-pulse 1800ms ease-in-out infinite;
  }
  /* Subtle pulse on the connecting line itself */
  [data-orient="vertical"] .ledger__list::after {
    content: "";
    position: absolute;
    left: 22px; right: 22px;
    top: 50%; transform: translateY(-50%);
    height: 1px;
    background: linear-gradient(
      90deg,
      transparent 0%,
      var(--t-accent) 45%,
      var(--t-accent) 55%,
      transparent 100%
    );
    opacity: 0.5;
    z-index: 0;
    animation: cord-pulse 2400ms ease-in-out infinite;
  }
  [data-orient="vertical"] .method-panel { margin-top: 0; }
}

@keyframes knot-pulse {
  0%, 100% { transform: scale(1); opacity: 0; }
  40% { transform: scale(1.6); opacity: 0.5; }
  70% { transform: scale(2.2); opacity: 0; }
}
@keyframes cord-pulse {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.6; }
}

/* iOS safe-area padding so chrome/footer respect notches */
@supports (padding: max(0px)) {
  .chrome__inner {
    padding-left: max(var(--t-gutter), env(safe-area-inset-left));
    padding-right: max(var(--t-gutter), env(safe-area-inset-right));
  }
}

/* ── Print ────────────────────────────────────────────── */
@media print {
  body { background: white; color: black; }
  .chrome, .thread, .hero__khipu, .hero__cue, .form, .btn, .tweaks-panel-root { display: none !important; }
  body::before { display: none; }
}
