/* "Who became who" lineage charts (plants/, railroads/), drawn by js/lineage.js.
   Lane colors come from each page's JSON (--lane on the lane, --trunk on main). */
.lineage-page {
  --lane: var(--brand-2);
  --trunk: #1f5f8b;
  --n: 4;
}
.lineage-page .page-head .section-note { margin-bottom: 0.6rem; }
.lineage-page .page-head .small { margin: 0; }

.year-pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  background: var(--card);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
  padding: 0.65rem 0.9rem;
  margin: 0 0 1rem;
}
.year-pick label {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.03em;
  color: var(--brand);
  white-space: nowrap;
}
.year-pick output {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.year-pick input[type="range"] {
  flex: 1 1 220px;
  min-width: 0;
  accent-color: var(--brand-2);
}
.year-pick button {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
}
.year-pick button[disabled] { opacity: 0.45; cursor: default; }

/* —— Cards —— */
.lin-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--rule);
  border-top: 4px solid var(--lane);
  box-shadow: var(--shadow);
  transition: opacity 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.lin-card .lin-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 4.6rem;
  padding: 0.55rem 0.8rem;
  background: linear-gradient(180deg, #ffffff 0%, #eef3f6 100%);
  border-bottom: 1px solid var(--rule);
}
.lin-card .lin-logo img {
  max-width: min(100%, 190px);
  max-height: 3.3rem;
  width: auto;
  height: auto;
  object-fit: contain;
}
.lin-card .wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  color: var(--lane);
  border: 2px solid currentColor;
  padding: 0.25rem 0.5rem;
}
.lin-card .lin-body { padding: 0.6rem 0.75rem 0.7rem; }
.lin-card h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  line-height: 1.15;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--brand);
}
.lin-card .yrs {
  margin: 0.1rem 0 0.3rem;
  font-weight: 700;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  color: var(--lane);
}
.lin-card .made { margin: 0; font-size: 0.9rem; line-height: 1.35; color: var(--ink-soft); }
.lin-card .note { margin: 0.3rem 0 0; font-size: 0.8rem; line-height: 1.35; color: var(--muted); }
.lin-card .under {
  margin: 0 0 0.1rem;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.has-year .lin-card { opacity: 0.38; }
.has-year .lin-card.on {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow: 0 0 0 3px var(--accent), var(--shadow);
}

/* —— Handoffs (connectors) —— */
.handoff {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.2rem 0;
  color: var(--lane);
}
.handoff::before {
  content: "";
  width: 2px;
  height: 0.9rem;
  background: currentColor;
}
.handoff::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid currentColor;
}
.handoff span {
  order: 0;
  display: block;
  max-width: 100%;
  margin: 0.15rem 0;
  padding: 0.15rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid currentColor;
  border-color: var(--lane);
  border-radius: 999px;
}

/* —— Trunk: AS&W → Davison → PC&I → PC&C —— */
.trunk {
  --lane: var(--trunk);
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
  align-items: stretch;
  gap: 0;
  margin: 0 0 0.2rem;
  padding: 0;
  list-style: none;
}
.trunk > li { min-width: 0; }
.trunk .handoff {
  flex-direction: row;
  justify-content: center;
  width: 6.2rem;
  padding: 0 0.25rem;
}
.trunk .handoff::before { width: 0.5rem; height: 2px; }
.trunk .handoff::after {
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid currentColor;
  border-right: 0;
}
.trunk .handoff span { border-radius: 0.6rem; font-size: 0.74rem; padding: 0.2rem 0.4rem; }

/* —— The 1960s split —— */
.split {
  position: relative;
  height: 4.4rem;
  margin: 0 0 0.2rem;
  color: var(--trunk);
}
.split .drop {
  position: absolute;
  top: 0;
  left: calc(100% - 50% / var(--n) - 1px);
  width: 2px;
  height: 1.6rem;
  background: currentColor;
}
.split .bar {
  position: absolute;
  top: 1.6rem;
  left: calc(50% / var(--n));
  right: calc(50% / var(--n));
  height: 2px;
  background: currentColor;
}
.split .label {
  position: absolute;
  top: 0.65rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.2rem 0.75rem;
  background: var(--brand);
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* —— Lanes —— */
.lanes {
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}
.lane { position: relative; }
.lane-head {
  position: relative;
  text-align: center;
  padding: 0.4rem 0.5rem 0.45rem;
  background: var(--lane);
  color: #fff;
}
.lane-head::before {
  content: "";
  position: absolute;
  left: calc(50% - 1px);
  bottom: 100%;
  width: 2px;
  height: 2.8rem;
  background: var(--trunk);
}
.lane-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.1;
}
.lane-head a {
  display: inline-block;
  margin-top: 0.1rem;
  font-size: 0.78rem;
  color: #fff;
  opacity: 0.9;
}
.lane-steps { list-style: none; margin: 0; padding: 0; }
.lane-steps > li:first-child { margin-top: 0.7rem; }
.lane-end {
  margin: 0;
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
  line-height: 1.35;
  font-weight: 600;
  border: 2px dashed var(--lane);
  background: var(--paper);
  color: var(--ink);
}
.lane-end b {
  display: block;
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lane);
}
.lane-end.is-open { border-style: solid; }

/* —— Year table —— */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
  max-height: 78vh;
}
table.lineage-table { min-width: 70rem; font-size: 0.85rem; }
table.lineage-table thead th { position: sticky; top: 0; z-index: 2; }
table.lineage-table thead th:first-child { left: 0; z-index: 3; }
table.lineage-table tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--paper-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
table.lineage-table td.same { color: var(--muted); }
table.lineage-table tbody tr:nth-child(even) td { background: rgba(211, 221, 229, 0.35); }
table.lineage-table tbody tr.on td,
table.lineage-table tbody tr.on th { background: #fbedc4; }
table.lineage-table .sep { border-left: 2px solid var(--rule); }
.table-note { max-width: 70ch; color: var(--muted); font-size: 0.9rem; margin: 0.8rem 0 0; }

.tab-panel[hidden] { display: none; }

/* Cards the articles date only loosely: possibly running in the picked year. */
.has-year .lin-card.maybe {
  opacity: 0.85;
  outline: 2px dashed var(--accent);
  outline-offset: 3px;
}
.year-pick .year-help { flex-basis: 100%; margin: 0; font-size: 0.82rem; color: var(--muted); }
.year-pick .maybe-key { flex-basis: 100%; margin: 0; font-size: 0.82rem; color: var(--muted); }
.year-pick .maybe-key::before {
  content: "";
  display: inline-block;
  width: 1.4rem;
  height: 0.7rem;
  margin-right: 0.4rem;
  vertical-align: -0.05rem;
  border: 2px dashed var(--accent);
}
.lin-card .yrs .q { font-weight: 400; color: var(--muted); }

/* —— Merges: lanes that run into one company (e.g. two lines sold to one short line) —— */
.lanes.has-merge { grid-template-rows: auto auto; row-gap: 0; }
.lineage-page.no-trunk .lane-head::before { display: none; }
.lane.merges {
  align-self: stretch;
  display: flex;
  flex-direction: column;
}
.lane.merges .lane-steps { flex: 0 0 auto; }
.lane-tail {
  flex: 1 1 auto;
  min-height: 0.6rem;
  display: flex;
  justify-content: center;
}
.lane-tail::before {
  content: "";
  width: 2px;
  background: var(--lane);
}
.merge {
  position: relative;
  --lane: var(--trunk);
  padding-top: 0;
}
.merge .merge-join {
  position: relative;
  height: 1.6rem;
}
.merge .merge-join .bar {
  position: absolute;
  top: 0;
  height: 2px;
  left: calc(50% / var(--k));
  right: calc(50% / var(--k));
  background: var(--trunk);
}
.merge .merge-join::after {
  content: "";
  position: absolute;
  left: calc(50% - 1px);
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--trunk);
}
.merge .merge-label {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 0.2rem 0.75rem;
  background: var(--brand);
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
}
.merge .lane-steps {
  max-width: calc((100% - (var(--k) - 1) * 1rem) / var(--k));
  margin: 0 auto;
}
.merge .lane-steps > li:first-child { margin-top: 0; }
.merge .lane-steps::before {
  content: "";
  display: block;
  width: 2px;
  height: 0.9rem;
  margin: 0 auto;
  background: var(--trunk);
}

@media (max-width: 1040px) {
  .trunk { grid-template-columns: 1fr; max-width: 26rem; margin: 0 auto 0.2rem; }
  .trunk .handoff { flex-direction: column; width: auto; padding: 0.2rem 0; }
  .trunk .handoff::before { width: 2px; height: 0.9rem; }
  .trunk .handoff::after {
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid currentColor;
    border-bottom: 0;
  }
  .trunk .handoff span { border-radius: 999px; font-size: 0.8rem; padding: 0.15rem 0.55rem; }
  .split { height: auto; display: flex; flex-direction: column; align-items: center; }
  .split::before { content: ""; width: 2px; height: 0.9rem; background: currentColor; }
  .split .drop, .split .bar { display: none; }
  .split .label { position: static; transform: none; white-space: normal; text-align: center; }
  .split::after { content: ""; width: 2px; height: 0.9rem; background: currentColor; }
  .lanes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.6rem 1rem; }
  .lane-head::before { display: none; }
  .lanes.has-merge { grid-template-columns: 1fr; max-width: 30rem; margin: 0 auto; row-gap: 1.6rem; }
  .lanes.has-merge > * { grid-column: auto !important; grid-row: auto !important; }
  .merge .merge-join .bar { display: none; }
  .merge .merge-join { height: 0.9rem; }
  .merge .lane-steps { max-width: none; }
}
@media (max-width: 640px) {
  .lanes { grid-template-columns: 1fr; }
  .trunk { max-width: none; }
  .year-pick label { font-size: 1.05rem; }
}
  
/* —— Line filter (railroads): one chip per lane, in the lane's color —— */
.line-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 1rem;
}

.line-filter-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-right: 0.3rem;
}

.line-filter button {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border: 2px solid var(--lane, var(--brand));
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
}

.line-filter button[aria-pressed="true"] {
  background: var(--lane, var(--brand));
  color: #fff;
}

.line-filter .line-filter-all {
  border-color: var(--rule);
  background: none;
  color: var(--brand);
}

