/* HowItWorks (Living Spreadsheet) — Demo ↔ PlatformDemo 사이 들어가는 섹션.
   외부 reference (자체 :root + DM Mono UPPERCASE + 다중 accent) 를
   우리 사이트 토큰/strip-mono/sentence-case 톤으로 정합화한 버전. */

.hiw {
  /* .lenses / .chapter* 와 같은 컨테이너 alias 패턴.
     글로벌은 --mint 만 정의돼 있어서 .lenses 안과 밖이 단절됨 — 여기서 다시 묶음. */
  --accent: var(--mint);
  --accent-soft: rgba(var(--mint-rgb), 0.14);
  --accent-softer: rgba(var(--mint-rgb), 0.06);
  --hot: #DC2626;
  --hot-soft: rgba(220, 38, 38, 0.10);
  --bg-soft: #F5F5F2;
  --bg-tech: #FAFAF7;
  --mono: var(--font-jetbrains-mono), 'JetBrains Mono', 'SF Mono', 'Fira Code', Consolas, monospace;
}

/* Typography — chapter intro 톤 매칭. uppercase/tracked letter-spacing 없음. */
.hiw-eyebrow {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
}
.hiw-headline {
  margin: 0 0 14px;
  font-size: clamp(30px, 4vw, 54px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.04em;
  color: var(--ink);
}
.hiw-sub {
  margin: 0 0 40px;
  max-width: 560px;
  font-size: 17px;
  line-height: 1.55;
  color: var(--muted);
  word-break: keep-all;
}

/* Unified grid — main(좌 docs + pipe + sheet) + decisions panel(우) */
.hiw-unified {
  display: grid;
  grid-template-columns: 1fr 200px;
  align-items: stretch;
}
.hiw-main {
  display: grid;
  grid-template-columns: 200px 96px 1fr;
  align-items: center;
}

/* Section labels (좌/우 라벨, sheet 안 col head) — strip-mono 정책 따라 sentence case. */
.hiw-left-label,
.hiw-right-label {
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* 좌: 비정형 소스 카드들 (4개) */
.hiw-docs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hiw-doc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.4s, transform 0.4s;
}
.hiw-doc.show { opacity: 1; transform: translateX(0); }
.hiw-doc.fade { opacity: 0.25; transform: translateX(6px); }
.hiw-doc-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 6px;
  background: var(--bg-soft);
  color: var(--muted);
  /* PDF/DOC/TXT/WEB 4글자 코드성 — chapter3 tflow-phase-month 선례. */
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
}
/* Sources doc-icon — 4종 색 부여하면 아래 use case 5색과 hue 충돌 (적/파/주/녹).
   PDF/DOC/TXT/WEB 4글자 텍스트 자체로 구분 충분 → neutral chip 통일.
   단 row 의 WEB 2개는 conflict (bearish/bullish) 표현이 핵심이라 별도 색 유지. */
.hiw-doc-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.2;
}
.hiw-doc-type {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

/* 중: ingestion pipe + particle */
.hiw-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 24px;
}
.hiw-mid-arrow {
  position: relative;
  width: 100%;
  height: 2px;
  background: var(--line);
}
.hiw-mid-arrow-line {
  position: absolute;
  right: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid var(--line);
}
.hiw-particle {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
}
.hiw-mid-tag {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* 우: shared intelligence sheet */
.hiw-sheet {
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: 0 4px 24px rgba(var(--mint-rgb), 0.10);
}
.hiw-sheet-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--bg);
}
.hiw-sheet-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bg);
  animation: hiw-blink 2s infinite;
}
@keyframes hiw-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.hiw-sheet-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0.01em;
}

.hiw-sheet-cols {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-tech);
}
.hiw-col-head {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.hiw-col-head--wide { flex: 3; }

.hiw-rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  min-height: 220px;
}
.hiw-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 0.3s, transform 0.3s, background 0.3s, border-color 0.3s;
}
.hiw-row.in { opacity: 1; transform: translateX(0); }
.hiw-row.flash {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.hiw-row-dot {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}
.hiw-row-src {
  flex-shrink: 0;
  width: 32px;
  /* 코드성 라벨만 mono 보존 — strip-mono 예외. */
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
/* row-dot, row-src 는 neutral 기본값 유지. WEB 2개 row (lr6, lr7) 는
   conflict-a / conflict-b 규칙으로 hot vs accent.
   row-tag 는 type 차원 (fact / signal / event) 별 색조 유지 — reference 원본
   3색. row 별 type 매핑:
     lr0, lr2 = fact   (녹)
     lr1, lr5 = signal (파)
     lr3, lr4 = event  (주) */
#hiw-lr0 .hiw-row-tag, #hiw-lr2 .hiw-row-tag {
  background: rgba(26, 122, 94, 0.12); color: #1A7A5E;
}
#hiw-lr1 .hiw-row-tag, #hiw-lr5 .hiw-row-tag {
  background: rgba(44, 95, 224, 0.12); color: #2C5FE0;
}
#hiw-lr3 .hiw-row-tag, #hiw-lr4 .hiw-row-tag {
  background: rgba(192, 112, 0, 0.12); color: #C07000;
}
.hiw-row-claim {
  flex: 3;
  padding-right: 6px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--ink);
}
.hiw-row-claim strong { font-weight: 600; }
.hiw-row-tag {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Conflict rows — bearish=hot, bullish=accent. 의미 대조 두 색만. */
.hiw-row--conflict-a { border-left: 2.5px solid var(--hot); }
.hiw-row--conflict-b { border-left: 2.5px solid var(--accent); }
.hiw-row--conflict-a .hiw-row-dot { background: var(--hot); }
.hiw-row--conflict-b .hiw-row-dot { background: var(--accent); }
.hiw-row--conflict-a .hiw-row-src { color: var(--hot); }
.hiw-row--conflict-b .hiw-row-src { color: var(--accent); }
.hiw-row--conflict-a .hiw-row-tag {
  background: var(--hot-soft);
  color: var(--hot);
}
.hiw-row--conflict-b .hiw-row-tag {
  background: var(--accent-soft);
  color: var(--accent);
}

.hiw-conflict-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 2px 2px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg-tech);
  font-size: 12px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.4s;
}
.hiw-conflict-note.in { opacity: 1; }
.hiw-conflict-dot {
  display: inline-block;
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.hiw-conflict-dot--a { background: var(--hot); }
.hiw-conflict-dot--b { background: var(--accent); }

/* 우 패널: recompose under any lens */
.hiw-decisions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-left: 24px;
  padding-left: 24px;
  border-left: 1px solid var(--line);
}
.hiw-dec-label {
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.hiw-dec-arrow-h {
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--line);
}
.hiw-dec-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hiw-dec-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  cursor: default;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 0.35s, transform 0.35s, border-color 0.18s, background 0.18s;
}
.hiw-dec-item.in { opacity: 1; transform: translateX(0); }
.hiw-dec-item:hover { border-color: var(--accent); }
.hiw-dec-item.dec-pulse {
  border-color: var(--accent);
  background: var(--accent-softer);
}
.hiw-dec-dot {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
/* Use case dot 5색 — reference 원본 톤. 작은 dot 7×7px 영역이라 사이트
   전체 톤 영향 미미하면서 5종 use case 시각 구분 제공. */
#hiw-dec0 .hiw-dec-dot { background: #E24B4A; }
#hiw-dec1 .hiw-dec-dot { background: #378ADD; }
#hiw-dec2 .hiw-dec-dot { background: #1A7A5E; }
#hiw-dec3 .hiw-dec-dot { background: #854F0B; }
#hiw-dec4 .hiw-dec-dot { background: #7C3AED; }
.hiw-dec-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.25;
}
.hiw-dec-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

/* Responsive
   ───────────────────────────────────────────────────────────────────────────
   900px↓: .hiw-unified 와 .hiw-main 둘 다 1열 stack — 좌(docs) / 중(pipe)
           / 우(sheet) 가 세로로. 가운데 화살표는 가로 → 세로 흐름 시각화.
   640px↓: 타이포 / 카드 / row 크기 축소. */
@media (max-width: 900px) {
  .hiw-unified { grid-template-columns: 1fr; }
  .hiw-main {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  /* 모바일에선 sources(위) → ingestion(중) → structure(아래) 가 세로 흐름.
     가로 라인/오른쪽 화살표 그대로 두면 흐름이 어긋나 보임. column 으로 뒤집고
     vertical bar + ↓ 화살표로 재구성. */
  .hiw-mid {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
  }
  .hiw-mid-arrow {
    flex: none;
    width: 2px;
    height: 28px;
  }
  .hiw-mid-arrow-line {
    right: auto;
    left: 50%;
    top: auto;
    bottom: -1px;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 7px solid var(--line);
    border-bottom: none;
  }
  .hiw-particle {
    top: 0;
    left: 50%;
    transform: translate(-50%, 0);
  }
  .hiw-sheet { max-width: 100%; }
  .hiw-decisions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    margin: 24px 0 0;
    padding: 24px 0 0;
    border-left: none;
    border-top: 1px solid var(--line);
  }
  .hiw-dec-label,
  .hiw-dec-arrow-h { display: none; }
  .hiw-dec-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
  .hiw-dec-item { flex: 1 1 calc(50% - 6px); }
}
@media (max-width: 640px) {
  .hiw-headline { font-size: clamp(26px, 6vw, 36px); }
  .hiw-sub { font-size: 15px; margin-bottom: 32px; }
  .hiw-doc { padding: 8px 10px; gap: 8px; }
  .hiw-doc-icon { width: 32px; height: 32px; font-size: 10px; }
  .hiw-doc-name { font-size: 12px; }
  .hiw-doc-type { font-size: 10px; }
  .hiw-sheet-top { padding: 8px 12px; }
  .hiw-sheet-label { font-size: 11px; }
  .hiw-rows { min-height: auto; padding: 6px; }
  .hiw-row {
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 6px;
  }
  .hiw-row-claim {
    flex: 1 1 100%;
    font-size: 11.5px;
    padding-right: 0;
  }
  .hiw-row-tag { font-size: 10px; }
  .hiw-conflict-note { font-size: 11px; padding: 8px 10px; }
  .hiw-dec-item { flex: 1 1 100%; }
}
