/* lang-history 고유 컴포넌트. 토큰·기본 타이포·네비바·히어로·표·푸터는 common/doc.css 가 제공한다 */
:root {
  --tag-lang: #7c3aed;
  --tag-std: #0f766e;
  --tag-tool: #b45309;
  --tag-rt: #1d5fbf;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tag-lang: #a78bfa;
    --tag-std: #2dd4bf;
    --tag-tool: #fbbf24;
    --tag-rt: #58a6ff;
  }
}
:root[data-theme="dark"] {
  --tag-lang: #a78bfa;
  --tag-std: #2dd4bf;
  --tag-tool: #fbbf24;
  --tag-rt: #58a6ff;
}

/* Stat row: tools you need beyond the official toolchain */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px 20px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
}
.stat b {
  display: block;
  font-family: var(--f-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat b small {
  font-family: var(--f-body);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
  margin-left: 6px;
}
.stat span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

/* Release timeline: 세로선을 항목마다 그려서 다단으로 나뉘어도 선이 이어진다 */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.release,
details.minor {
  margin-left: 8px;
  padding: 0 0 22px 24px;
  border-left: 2px solid var(--line);
  break-inside: avoid;
}
.release {
  position: relative;
}
.release::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 7px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--muted);
}
.release.major::before {
  left: -9px;
  top: 5px;
  width: 16px;
  height: 16px;
  background: var(--link);
  border-color: var(--link);
}
.release .head {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
}
.release .ver {
  font-family: var(--f-mono);
  font-weight: 600;
  font-size: 16px;
}
.release.major .ver {
  font-size: 19px;
}
.release .date {
  font-family: var(--f-mono);
  font-size: 12.5px;
  color: var(--muted);
}
.release ul {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  font-size: 15px;
  line-height: 1.6;
}
.release li {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 2px 0;
}
.release li .muted {
  color: var(--muted);
}
.release code,
details.minor code,
.sheet code {
  white-space: normal;
  overflow-wrap: anywhere;
}
.tag {
  flex: none;
  min-width: 58px;
  text-align: center;
  font-family: var(--f-mono);
  font-size: 11px;
  line-height: 1.5;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.tag.lang {
  color: var(--tag-lang);
  border-color: color-mix(in srgb, var(--tag-lang) 45%, transparent);
}
.tag.std {
  color: var(--tag-std);
  border-color: color-mix(in srgb, var(--tag-std) 45%, transparent);
}
.tag.tool {
  color: var(--tag-tool);
  border-color: color-mix(in srgb, var(--tag-tool) 45%, transparent);
}
.tag.rt {
  color: var(--tag-rt);
  border-color: color-mix(in srgb, var(--tag-rt) 45%, transparent);
}
.badge {
  flex: none;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--link);
  color: var(--surface);
}
.badge.breaking {
  background: var(--con);
}
.badge.absorb {
  background: var(--tag-tool);
}
details.minor {
  margin-top: -6px;
}
details.minor summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
details.minor ul {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.6;
}
details.minor li {
  padding: 2px 0;
}
details.minor .ver {
  font-family: var(--f-mono);
  font-weight: 600;
  color: var(--ink);
  margin-right: 8px;
}

/* Clickable items open the bottom sheet */
.link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
  text-decoration: underline dotted var(--muted);
  text-underline-offset: 3px;
}
.link:hover {
  color: var(--link);
  text-decoration-color: var(--link);
}

/* Tooling lanes: packed gantt, label on bar, thickness = usage */
/* 오른쪽 끝 막대의 종료 눈금(1px)이 스크롤을 만들지 않도록 여유를 둔다 */
.lanes-wrap {
  overflow-x: auto;
  padding-right: 2px;
}
.lanes {
  --cols: 16;
  min-width: 680px;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-auto-rows: 32px;
  padding-top: 18px;
  background-image: linear-gradient(to right, var(--line) 1px, transparent 1px);
  background-size: calc(100% / var(--cols)) 100%;
}
.lanes .yr {
  grid-row: 1;
  align-self: start;
  margin-top: -18px;
  padding-left: 4px;
  font-family: var(--f-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}
.bar {
  grid-row: var(--lane);
  align-self: center;
  position: relative;
  height: 8px;
  margin-top: 10px;
  border: 0;
  border-radius: 3px;
  padding: 0;
  background: var(--muted);
  cursor: pointer;
  font: inherit;
}
.bar.dominant {
  height: 14px;
  background: var(--link);
}
.bar.common {
  height: 9px;
  background: var(--muted);
}
.bar.niche {
  height: 5px;
  background: var(--axis);
}
.bar.end::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -5px;
  bottom: -5px;
  width: 2px;
  background: var(--muted);
}
.bar:hover {
  filter: brightness(1.15);
  outline: 2px solid var(--link);
  outline-offset: 2px;
}
.bar .name {
  position: absolute;
  left: 0;
  bottom: 100%;
  margin-bottom: 3px;
  line-height: 1;
  white-space: nowrap;
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--ink);
}
.bar.dominant .name {
  font-weight: 600;
  color: var(--link);
}
.bar.niche .name {
  color: var(--muted);
}
.legend .d,
.legend .c,
.legend .n,
.legend .e {
  flex: none;
  width: 26px;
  border-radius: 3px;
}
.legend .d {
  height: 14px;
  background: var(--link);
}
.legend .c {
  height: 9px;
  background: var(--muted);
}
.legend .n {
  height: 5px;
  background: var(--axis);
}
.legend .e {
  width: 2px;
  height: 14px;
  background: var(--muted);
  margin-left: 12px;
}

/* Bottom sheet (Popover API, no JS) */
.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-height: 60vh;
  margin: 0;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  overflow: auto;
  box-shadow: 0 -8px 30px rgb(0 0 0 / 0.18);
}
.sheet::backdrop {
  background: rgb(0 0 0 / 0.35);
}
.sheet-inner {
  max-width: 1776px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) 28px
    max(16px, env(safe-area-inset-left, 0px));
}
.sheet header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.sheet h3 small {
  font-family: var(--f-mono);
  font-size: 12.5px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 10px;
}
.sheet-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.sheet-close:hover {
  border-color: var(--muted);
  color: var(--ink);
}
.sheet dl {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px 12px;
}
.sheet dt {
  font-family: var(--f-mono);
  font-size: 12.5px;
  line-height: 24px;
  color: var(--muted);
}
.sheet ul {
  padding-left: 18px;
}
.sheet .chip {
  font-family: var(--f-mono);
  font-weight: 400;
  margin: 0 4px 4px 0;
  vertical-align: baseline;
  white-space: normal;
  border-color: var(--line);
  color: var(--muted);
}
.sheet .chip.win {
  color: var(--link);
  border-color: var(--link);
}

/* Chips that open another sheet */
button.chip {
  cursor: pointer;
  background: none;
}
button.chip:hover {
  color: var(--link);
  border-color: var(--link);
}
.chip.link {
  text-decoration: none;
}

/* Overview: cross-language summary table */
.summary {
  min-width: 720px;
}
.summary tbody th[scope="row"] {
  white-space: nowrap;
}
.summary small {
  font-size: 12.5px;
  color: var(--muted);
}
.how {
  font-family: var(--f-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
}
.how.builtin {
  color: var(--tag-tool);
  border: 1px solid color-mix(in srgb, var(--tag-tool) 45%, transparent);
}
.how.fast {
  color: var(--tag-rt);
  border: 1px solid color-mix(in srgb, var(--tag-rt) 45%, transparent);
}

/* Local cleanup table: reason chips */
.how.dep {
  color: var(--con);
  border: 1px solid color-mix(in srgb, var(--con) 45%, transparent);
}
.how.arch {
  color: var(--muted);
  border: 1px solid var(--line);
}
.how.rep {
  color: var(--link);
  border: 1px solid color-mix(in srgb, var(--link) 45%, transparent);
}

/* Long-lived version badge + EOL marker (Python 2.7, Node LTS, ...) */
.badge.long {
  background: var(--tag-std);
}
.release.eol::before {
  background: var(--tag-std);
  border-color: var(--tag-std);
}

/* Two-track release timelines side by side (ES editions / runtimes) */
.releases-2col {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

/* Edition band above the release timeline (Rust editions, ES editions) */
.editions {
  --cols: 16;
  min-width: 680px;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  padding-top: 18px;
  background-image: linear-gradient(to right, var(--line) 1px, transparent 1px);
  background-size: calc(100% / var(--cols)) 100%;
}
.editions .yr {
  grid-row: 1;
  margin-top: -18px;
  padding-left: 4px;
  font-family: var(--f-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}
.editions .ed {
  grid-row: 2;
  border: 0;
  border-right: 2px solid var(--surface);
  padding: 5px 8px;
  font: inherit;
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  color: var(--ink);
  background: color-mix(in srgb, var(--link) 22%, var(--surface));
}
.editions .ed.e2018 {
  background: color-mix(in srgb, var(--link) 45%, var(--surface));
}
.editions .ed.e2021 {
  background: color-mix(in srgb, var(--link) 70%, var(--surface));
  color: var(--surface);
}
.editions .ed.e2024 {
  background: var(--link);
  color: var(--surface);
  border-radius: 0 4px 4px 0;
}
.editions .ed.pre {
  background: var(--code-bg);
  color: var(--muted);
  font-weight: 400;
  cursor: default;
  border-radius: 4px 0 0 4px;
}
.editions .ed:not(.pre):hover {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}
.editions .ed small {
  font-weight: 400;
  opacity: 0.8;
  margin-left: 6px;
}

@media (min-width: 900px) {
  .releases-2col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1100px) {
  section > .timeline {
    columns: 2;
    column-gap: 32px;
  }
}
@media (max-width: 767px) {
  .summary.pin {
    min-width: 880px;
  }
  .sheet-close {
    min-height: 44px;
  }
}
@media (max-width: 640px) {
  .sheet dl {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }
  .sheet dt {
    line-height: 1.6;
  }
  .sheet dd {
    margin-bottom: 8px;
  }
}
