/* 企業 M&A 系譜 — 固有スタイル */

.mag-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

.mag-page h1 {
  font-family: 'Shippori Mincho', serif;
  font-weight: 500;
  font-size: 1.7rem;
  margin: 0 0 0.5rem;
  color: var(--color-aitetsu, #2a3b50);
}

.mag-intro {
  color: #555;
  font-size: 0.92rem;
  line-height: 1.7;
  margin: 0 0 1rem;
}

.mag-controls {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
  font-size: 0.85rem;
}

.mag-controls button {
  border: 1px solid #c9c9c9;
  background: #fff;
  padding: 0.25rem 0.7rem;
  font-size: 0.82rem;
  cursor: pointer;
  border-radius: 3px;
}

.mag-controls button:hover {
  background: #f3ede2;
}

.mag-controls button.mag-sector-active {
  background: #2a3b50;
  color: #f7f1e3;
  border-color: #2a3b50;
}

.mag-controls button.mag-sector-active:hover {
  background: #1f2c3c;
}

.mag-sector-filter {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 100%;
  min-width: 0;
}

.mag-sector-tabs {
  display: flex;
  gap: 0.2rem;
  border-bottom: 1px solid #d8d3c8;
}

.mag-controls .mag-sector-tab {
  border: 1px solid transparent;
  background: transparent;
  color: #555;
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 3px 3px 0 0;
  margin-bottom: -1px;
}

.mag-controls .mag-sector-tab:hover {
  background: transparent;
  color: #2a3b50;
}

.mag-controls .mag-sector-tab.active {
  background: #faf6ee;
  border-color: #d8d3c8;
  color: #2a3b50;
  font-weight: 600;
}

.mag-tab-count {
  font-size: 0.78em;
  opacity: 0.7;
  margin-left: 0.3em;
}

#mag-sector-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.mag-search {
  position: relative;
  display: inline-block;
}

#mag-search-input {
  border: 1px solid #c9c9c9;
  background: #fff;
  padding: 0.25rem 0.6rem;
  font-size: 0.82rem;
  border-radius: 3px;
  width: 16ch;
  font-family: 'Noto Sans JP', sans-serif;
}

#mag-search-input:focus {
  outline: 1px solid #2a3b50;
  outline-offset: -1px;
  width: 22ch;
}

.mag-search-results {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  z-index: 30;
  margin: 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid #c9c9c9;
  border-radius: 3px;
  min-width: 24ch;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.mag-search-result {
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 0.85rem;
  border-bottom: 1px solid #f0eadc;
}

.mag-search-result:last-child {
  border-bottom: none;
}

.mag-search-result:hover {
  background: #f3ede2;
}

.mag-search-name {
  color: #1a1a1a;
}

.mag-search-sector {
  color: #888;
  font-size: 0.72rem;
  white-space: nowrap;
}

.mag-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-left: auto;
  font-size: 0.78rem;
  color: #555;
}

.mag-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.mag-legend-line {
  display: inline-block;
  vertical-align: middle;
}

.mag-canvas-wrap {
  position: relative;
  border: 1px solid #d8d3c8;
  background: #faf6ee;
  overflow: auto;
  max-height: 78vh;
  -webkit-overflow-scrolling: touch;
}

.mag-mobile-hint {
  display: none;
  text-align: center;
  font-size: 0.78rem;
  color: #888;
  margin: 0 0 0.4rem;
}

@media (max-width: 768px) {
  .mag-page {
    padding: 1rem 0.6rem 3rem;
  }

  .mag-mobile-hint {
    display: block;
  }

  .mag-page h1 {
    font-size: 1.4rem;
  }

  .mag-intro {
    font-size: 0.85rem;
  }

  .mag-controls {
    font-size: 0.78rem;
    gap: 0.4rem;
  }

  .mag-legend {
    margin-left: 0;
    flex-basis: 100%;
    font-size: 0.72rem;
    gap: 0.6rem;
  }

  #mag-search-input {
    width: 12ch;
  }

  #mag-search-input:focus {
    width: 16ch;
  }
}

@media (max-width: 480px) {
  .mag-page {
    padding: 0.8rem 0.4rem 2.5rem;
  }

  .mag-page h1 {
    font-size: 1.25rem;
  }
}

#mag-svg {
  display: block;
  font-family: 'Noto Sans JP', sans-serif;
}

.mag-axis text {
  font-size: 11px;
  fill: #555;
}

.mag-axis line,
.mag-axis path {
  stroke: #b8b1a0;
}

.mag-lineage-bg {
  fill: #f5efe1;
}

.mag-lineage-bg.alt {
  fill: #f0e8d4;
}

.mag-lineage-label {
  font-size: 11px;
  fill: #555;
  font-weight: 500;
}

.mag-node rect {
  stroke: #2a3b50;
  stroke-width: 1px;
  cursor: pointer;
  transition: filter 0.15s;
}

.mag-node:hover rect {
  filter: brightness(0.93);
}

.mag-node text {
  font-size: 11px;
  fill: #1a1a1a;
  pointer-events: none;
  dominant-baseline: middle;
}

.mag-node.status-active rect {
  fill: #c83e3e;
  fill-opacity: 0.18;
  stroke: #c83e3e;
}

.mag-node.status-merged rect {
  fill: #2a3b50;
  fill-opacity: 0.10;
}

.mag-node.status-split rect {
  fill: #6b4f8c;
  fill-opacity: 0.12;
  stroke: #6b4f8c;
}

.mag-node.status-renamed rect {
  fill: #888;
  fill-opacity: 0.10;
  stroke: #888;
}

/* 買収以降の期間 (買収企業傘下) は半透明・破線で区別 */
.mag-node rect.mag-rect-post {
  fill: #888;
  fill-opacity: 0.06;
  stroke: #888;
  stroke-dasharray: 4 3;
  stroke-opacity: 0.55;
}

.mag-edge {
  fill: none;
  stroke: #2a3b50;
  opacity: 0.55;
}

.mag-edge.type-merger {
  stroke: #c83e3e;
  stroke-width: 4;
}

.mag-edge.type-acquisition {
  stroke: #2a3b50;
  stroke-width: 4;
}

.mag-edge.type-split {
  stroke: #6b4f8c;
  stroke-width: 3.2;
}

.mag-edge.type-rename {
  stroke: #999;
  stroke-width: 2;
}

.mag-edge.type-alliance {
  stroke: #999;
  stroke-width: 2;
  stroke-dasharray: 5 4;
}

/* ── ノードホバー時のハイライト・ディム ── */
.mag-node {
  transition: opacity 0.12s;
}

.mag-edge {
  transition: opacity 0.12s;
}

.mag-node.mag-dim {
  opacity: 0.18;
}

.mag-edge.mag-dim {
  opacity: 0.08;
}

.mag-edge.mag-hl {
  opacity: 0.95;
}

.mag-detail {
  margin-top: 1.2rem;
  padding: 1rem 1.2rem;
  background: #f7f1e3;
  border-left: 3px solid #2a3b50;
  font-size: 0.92rem;
  line-height: 1.7;
}

.mag-detail.hidden {
  display: none;
}

.mag-detail h3 {
  font-family: 'Shippori Mincho', serif;
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  color: #2a3b50;
}

.mag-detail .mag-detail-meta {
  color: #666;
  font-size: 0.82rem;
  margin: 0 0 0.6rem;
}

.mag-detail .mag-detail-summary {
  margin: 0 0 0.6rem;
}

.mag-detail .mag-detail-links a {
  color: #2a3b50;
  font-size: 0.85rem;
}

.mag-detail-timeline {
  margin: 0.8rem 0 0.4rem;
}

.mag-detail-timeline:empty {
  display: none;
}

.mag-tl-svg {
  display: block;
  font-family: 'Noto Sans JP', sans-serif;
}

.mag-tl-node rect {
  stroke-width: 1px;
}

.mag-tl-node text {
  font-size: 11px;
  fill: #1a1a1a;
  pointer-events: none;
  dominant-baseline: middle;
}

.mag-tl-node.is-current rect {
  fill: #c83e3e;
  fill-opacity: 0.22;
  stroke: #c83e3e;
}

.mag-tl-node.is-related rect {
  fill: #2a3b50;
  fill-opacity: 0.08;
  stroke: #2a3b50;
}

.mag-tl-node.is-related:hover rect {
  fill-opacity: 0.16;
}

.mag-detail-relations {
  margin: 0.6rem 0 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem 2rem;
}

.mag-relation-section {
  flex: 1 1 240px;
  min-width: 0;
}

.mag-relation-heading {
  margin: 0 0 0.3rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #555;
  letter-spacing: 0.06em;
}

.mag-relation-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mag-relation-item {
  font-size: 0.9rem;
  margin: 0.2rem 0;
  line-height: 1.5;
}

.mag-relation-link {
  color: #2a3b50;
  text-decoration: none;
  border-bottom: 1px dashed #888;
  cursor: pointer;
}

.mag-relation-link:hover {
  color: #c83e3e;
  border-bottom-color: #c83e3e;
}

.mag-relation-meta {
  font-size: 0.78rem;
  color: #777;
}

.mag-foot-note {
  margin-top: 1.5rem;
  padding: 0.8rem 1rem;
  background: #f3ede2;
  border-left: 2px solid #c8b88a;
  color: #555;
  font-size: 0.82rem;
  line-height: 1.65;
}

.mag-foot-note strong {
  color: #2a3b50;
}

.mag-affiliate {
  margin-top: 1.5rem;
  padding: 1rem 1.2rem;
  background: #faf6ee;
  border: 1px solid #d8d3c8;
  border-left: 3px solid #c83e3e;
}

.mag-affiliate-pr {
  font-size: 0.7rem;
  font-weight: 700;
  color: #c83e3e;
  letter-spacing: 0.12em;
  margin: 0 0 0.4rem;
}

.mag-affiliate-title {
  font-family: 'Shippori Mincho', serif;
  font-size: 1.05rem;
  margin: 0 0 0.6rem;
  color: #2a3b50;
  font-weight: 500;
}

.mag-affiliate-list {
  margin: 0;
  padding-left: 1.2rem;
  list-style: none;
}

.mag-affiliate-list li {
  margin: 0.35rem 0;
  position: relative;
}

.mag-affiliate-list li::before {
  content: '—';
  position: absolute;
  left: -1rem;
  color: #c8b88a;
}

.mag-affiliate-link {
  color: #2a3b50;
  text-decoration: none;
  font-size: 0.92rem;
}

.mag-affiliate-link:hover {
  text-decoration: underline;
  color: #c83e3e;
}

.mag-affiliate-list li.has-isbn::before {
  content: '★';
  color: #c8b88a;
}

.mag-affiliate-list li.has-isbn .mag-affiliate-link {
  color: #2a3b50;
  font-weight: 500;
}
