/* ════════════════════════════════════════════
   timeline.css — /timeline 페이지 전용 스타일
   claude.css 디자인 시스템 호환 (토큰 활용, OKLCH 일관)
   ════════════════════════════════════════════ */

/* — Page header — */
.page-header {
  margin-bottom: 56px;
}
.page-header .eyebrow {
  display: inline-block;
  font-family: var(--f-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent-deep);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.page-header h1 {
  margin-top: 14px;
  font-size: clamp(40px, 6vw, 64px);
  color: var(--ink);
}
.page-header .lede {
  margin-top: 16px;
  max-width: 720px;
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.page-header .lede strong {
  font-weight: 600;
  color: var(--ink);
}
.page-header h1 em.accent-text {
  font-family: var(--f-serif);
  font-style: italic;
  color: var(--accent-ink);
}

/* — Section 구분 — */
.timeline-section {
  margin-top: 56px;
}
.section-label {
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-mute);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.timeline-section .caption {
  margin-top: 12px;
  font-family: var(--f-body);
  font-size: 13px;
  color: var(--ink-mute);
}

/* — Timeline list — */
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.timeline-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 24px;
  align-items: baseline;
  padding: 22px 26px;
}

.timeline-year {
  font-size: 26px;
  color: var(--ink-mute);
  font-weight: 400;
  letter-spacing: -0.01em;
}

.timeline-body {
  min-width: 0;
}

.timeline-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
}

.timeline-title {
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.01em;
}
.timeline-title a {
  color: var(--ink);
  text-decoration: none;
  transition: color 0.15s;
}
.timeline-title a:hover {
  color: var(--accent-ink);
  text-decoration: none;
}

.timeline-body .org {
  font-size: 12.5px;
  color: var(--ink-mute);
}

.timeline-body .desc {
  margin: 10px 0 0;
  font-family: var(--f-body);
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink-soft);
}

.timeline-body .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 18px;
  margin-top: 14px;
  font-family: var(--f-body);
  font-size: 12.5px;
  color: var(--ink-mute);
}

.timeline-body .meta .ext-link {
  color: var(--accent-ink);
  text-decoration: none;
}
.timeline-body .meta .ext-link:hover {
  text-decoration: underline;
}

/* — Search / filter — */
.timeline-search {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 36px;
}
.timeline-search-input {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card-elev);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.timeline-search-input::placeholder {
  color: var(--ink-mute);
}
.timeline-search-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.timeline-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.timeline-filter {
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink-soft);
  font-family: var(--f-body);
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.timeline-filter:hover {
  border-color: var(--rule-strong);
  background: var(--card-elev);
}
.timeline-filter.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.timeline-search-empty {
  padding: 40px 0;
  text-align: center;
  font-family: var(--f-body);
  font-size: 14.5px;
  color: var(--ink-mute);
}

/* — DAG canvas container — */
.timeline-dag {
  width: 100%;
  height: 640px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--card);
  overflow: hidden;
}

/* — Legend (타입별 시각 시스템 가이드) — */
.dag-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--f-body);
  font-size: 13px;
  color: var(--ink-soft);
}
.dag-legend li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.legend-mark {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border: 1.5px solid var(--rule-strong);
  background: var(--paper-2);
}
.legend-model {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border-color: var(--accent-deep);
}
.legend-paper {
  width: 18px;
  height: 14px;
  border-radius: 4px;
  background: var(--teal-soft);
  border-color: var(--teal);
}
.legend-org {
  width: 16px;
  height: 16px;
  background: var(--gold-soft);
  border-color: var(--gold);
  transform: rotate(45deg);
}
.legend-concept {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--paper-3);
  border-color: var(--rule-strong);
}
.legend-center {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--accent-deep);
}

/* — Glossary term card target highlight (hash anchor 도착 강조) — */
.term-card {
  scroll-margin-top: 96px;
}
.term-card:target {
  /* Unit 3 (dev-14, ADR-0017) — minimal brand-pack 헌법 ≤200ms 준수 (구 2400ms = 12× 초과) */
  animation: term-card-arrive 180ms cubic-bezier(0.2, 0, 0, 1) both;
  border-color: var(--accent) !important;
  box-shadow:
    0 0 0 2px var(--accent-soft),
    0 12px 36px -12px rgba(201, 100, 66, 0.34) !important;
}
@keyframes term-card-arrive {
  0% {
    background-color: var(--accent-soft);
  }
  35% {
    background-color: var(--accent-soft);
  }
  100% {
    background-color: var(--card);
  }
}
@media (prefers-reduced-motion: reduce) {
  .term-card:target {
    animation: none;
  }
}

/* — Term link (용어 자동 링크 + tooltip) — */
.term-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-ink);
  cursor: help;
  position: relative;
  transition: background-color 0.15s, color 0.15s;
}
.term-link:hover,
.term-link:focus-visible {
  color: var(--accent-deep);
  background: var(--accent-soft);
  text-decoration: none;
  outline: none;
}
.term-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Tooltip — pure CSS, data-tip attribute */
.term-link::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: max-content;
  max-width: 280px;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--f-body);
  font-size: 13px;
  line-height: 1.55;
  font-weight: 400;
  letter-spacing: -0.003em;
  text-align: left;
  white-space: normal;
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 100;
}
.term-link::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--ink);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
  z-index: 100;
}
.term-link:hover::after,
.term-link:focus-visible::after,
.term-link:hover::before,
.term-link:focus-visible::before {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Mobile — tooltip 위치 조정 */
@media (max-width: 720px) {
  .term-link::after {
    left: 0;
    transform: translateX(0) translateY(4px);
    max-width: calc(100vw - 48px);
  }
  .term-link::before {
    left: 12px;
    transform: translateX(0);
  }
  .term-link:hover::after,
  .term-link:focus-visible::after {
    transform: translateX(0) translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .term-link,
  .term-link::after,
  .term-link::before {
    transition: none;
  }
}

/* — Node explanation (비전문가용 친절 설명) — */
.node-explanation .explanation-body {
  max-width: 720px;
  margin-top: 4px;
}
.node-explanation .explanation-body p {
  margin: 0 0 16px;
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.75;
  color: var(--ink-soft);
  letter-spacing: -0.003em;
}
.node-explanation .explanation-body p:last-child {
  margin-bottom: 0;
}
.node-explanation .explanation-body p strong {
  color: var(--ink);
  font-weight: 600;
}

/* — Node detail page — */
.node-detail .back-link {
  font-family: var(--f-body);
  font-size: 13.5px;
  color: var(--ink-mute);
  text-decoration: none;
  transition: color 0.15s;
}
.node-detail .back-link:hover {
  color: var(--ink);
}

.node-detail .relations {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  margin-top: 24px;
}
@media (min-width: 720px) {
  .node-detail .relations {
    grid-template-columns: 1fr 1fr;
  }
}

.relation-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.relation-item {
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
}
.relation-item a {
  font-family: var(--f-serif);
  font-size: 16px;
  color: var(--ink);
  text-decoration: none;
}
.relation-item a:hover {
  color: var(--accent-ink);
}
.relation-meta {
  margin-top: 4px;
  font-family: var(--f-body);
  font-size: 12.5px;
  color: var(--ink-mute);
}

.relation-empty {
  font-family: var(--f-body);
  font-size: 13.5px;
  color: var(--ink-mute);
}

/* — Depth analysis chips — */
.depth-layer {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 14px;
  align-items: baseline;
}
.depth-label {
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--ink-mute);
}
.depth-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.depth-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-family: var(--f-body);
  font-size: 12.5px;
  color: var(--ink);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.depth-chip:hover {
  background: var(--paper-3);
  border-color: var(--rule-strong);
  text-decoration: none;
}
.depth-chip .year {
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--ink-mute);
}

/* — Mini DAG container (node detail) — */
.mini-dag {
  width: 100%;
  height: 360px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
}

/* — Mobile — */
@media (max-width: 720px) {
  .timeline-card {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 18px 20px;
  }
  .timeline-year {
    font-size: 20px;
  }
  .timeline-title {
    font-size: 18px;
  }
  .page-header {
    margin-bottom: 36px;
  }
  .timeline-section {
    margin-top: 36px;
  }
  .timeline-dag {
    height: 380px;
  }
  .mini-dag {
    height: 260px;
  }
}

/* — Reduced motion — */
@media (prefers-reduced-motion: reduce) {
  .timeline-title a,
  .timeline-search-input,
  .timeline-filter,
  .depth-chip,
  .node-detail .back-link {
    transition: none;
  }
}

/* Unit 6 (dev-14, ADR-0017) — 모바일 터치 영역 44px (WCAG 2.5.5 AAA 지향) */
@media (max-width: 640px) {
  .depth-chip {
    min-height: 44px;
    padding: 8px 14px;
  }
  .timeline-filter {
    min-height: 44px;
    padding: 0 16px;
  }
}
