/*
 * Transit Viewer CSS - Copied from city-subway-snippet-example.html
 * Scoped to .tcj-transit-viewer
 */

/* Root variables - colors will be set inline by JS */
.tcj-transit-viewer {
  /* 尺寸变量 */
  --circle-left: 28px;
  --circle-size: 20px;
  --line-left: 82px;
  --gap: 14px;
  --transfer-min: 200px;
  --name-max: clamp(160px, 65vw, 260px);
  --double-gap: 4px;
}

/* 外层容器 */
.tcj-transit-viewer {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.tcj-transit-viewer * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 顶部按钮 */
.tcj-line-menu {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
  justify-items: center;
}
.tcj-line-menu .tcj-tab {
  --btn-color: #333;
  width: 100%;
  padding: 8px 0;
  border: none;
  border-radius: 11px;
  cursor: pointer;
  text-align: center;
  color: #fff !important;
  background: var(--btn-color) !important;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: filter 0.15s, transform 0.1s;
  font-size: 12px;
}
.tcj-line-menu .tcj-tab:hover {
  filter: brightness(1.08);
}
.tcj-line-menu .tcj-tab.active {
  outline: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--btn-color), 0 2px 4px rgba(0, 0, 0, 0.25) inset;
  transform: translateY(-1px);
}
.tcj-line-menu .tcj-tab b {
  font-size: 12px;
}

/* 内容区 */
.tcj-line-content {
  position: relative;
  display: flex;
  justify-content: center;
}

/* 线路图容器 */
.tcj-vertical-map-wrapper {
  --line-color: #000;
  position: relative;
  padding: 20px 0;
  margin-left: 36px;
}

.tcj-vertical-map.short-route {
  --gap: 40px;
}

.tcj-vertical-map {
  position: relative;
  display: inline-block;
  padding-left: 56px;
  padding-top: 48px;
  margin: 0 auto;
}

/* 单/双线由站点 item 自己渲染，确保起止精准 */
.tcj-vertical-map::before,
.tcj-vertical-map::after,
.tcj-vertical-map.double::before,
.tcj-vertical-map.double::after {
  display: none !important;
}

/* 标题 */
.tcj-vertical-map-title {
  position: absolute;
  left: var(--line-left);
  top: 0;
  transform: translateX(-50%);
  background: var(--line-color);
  color: #fff;
  padding: 4px 12px 3px;
  border-radius: 6px;
  line-height: 1.1;
  font-size: 16px;
  white-space: nowrap;
  z-index: 3;
}

/* 轨道线片段 (自绘) - 基础单线逻辑 */
.tcj-vertical-map:not(.double) .tcj-station-item::before {
  content: "";
  position: absolute;
  left: var(--circle-left);
  top: 0;
  bottom: calc(-1 * (var(--gap) + (var(--conn-count) * 8px)));
  width: 4px;
  background: var(--line-color);
  transform: translateX(-50%);
  z-index: 1;
}

/* 第一站：从圆圈中心开始 */
.tcj-vertical-map:not(.double) .tcj-station-item.is-first::before {
  top: 50%;
}

/* 最后一站：在圆圈中心停止，不再向下延 */
.tcj-vertical-map:not(.double) .tcj-station-item.is-last::before {
  bottom: 50%;
}

/* 双细线片段逻辑 */
.tcj-vertical-map.double .tcj-station-item::before,
.tcj-vertical-map.double .tcj-station-item::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: calc(-1 * (var(--gap) + (var(--conn-count) * 8px)));
  width: 3px;
  background: var(--line-color);
  z-index: 1;
}

.tcj-vertical-map.double .tcj-station-item::before {
  left: calc(var(--circle-left) - 1px - var(--double-gap) / 2);
  transform: translateX(-50%);
}

.tcj-vertical-map.double .tcj-station-item::after {
  left: calc(var(--circle-left) + 1px + var(--double-gap) / 2);
  transform: translateX(-50%);
}

.tcj-vertical-map.double .tcj-station-item.is-first::before,
.tcj-vertical-map.double .tcj-station-item.is-first::after {
  top: 50%;
}

.tcj-vertical-map.double .tcj-station-item.is-last::before,
.tcj-vertical-map.double .tcj-station-item.is-last::after {
  bottom: 50%;
}

/* 站点容器 */
.tcj-station-item {
  --conn-count: 0;
  position: relative;
  margin-bottom: calc(var(--gap) + (var(--conn-count) * 8px));
  min-height: var(--circle-size);
}
.tcj-circle {
  position: absolute;
  left: var(--circle-left);
  top: 50%;
  transform: translate(-50%, -50%);
  width: var(--circle-size);
  height: var(--circle-size);
  border: 4px solid var(--line-color);
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  z-index: 2;
}
.tcj-station-item.transfer .tcj-circle::after {
  content: "↔";
  color: var(--line-color);
  font-size: 12px;
}
.tcj-station-name {
  font-size: 14px;
  color: #333;
  text-decoration: none;
  display: inline-block;
  max-width: var(--name-max);
  white-space: normal;
  word-break: break-word;
  line-height: 1.25;
}

.tcj-station-info {
  margin-left: 50px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: var(--circle-size);
}

/* 换乘块 */
.tcj-transfer-container {
  position: absolute;
  left: var(--circle-left);
  top: 50%;
  transform: translate(-100%, -50%);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 0;
  z-index: 1;
  min-width: var(--transfer-min);
}
.tcj-transfer-wrapper {
  display: flex;
  align-items: center;
}
.tcj-transfer-label {
  font-size: 12px;
  margin-right: 4px;
  white-space: normal;
  line-height: 1.1;
}
.tcj-transfer-line {
  width: 26px;
  height: 8px;
  border-radius: 4px;
}

/* 换乘按钮样式 */
.tcj-transfer-btn {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  outline: none;
  font-family: inherit;
  transition: opacity 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
}
.tcj-transfer-btn:hover {
  opacity: 0.7;
  transform: translateX(-2px);
}
.tcj-transfer-btn:active {
  transform: translateX(-1px) scale(0.98);
}
.tcj-transfer-btn .tcj-transfer-label {
  text-decoration: underline;
  text-decoration-color: rgba(0,0,0,0.2);
  text-underline-offset: 2px;
}
.tcj-transfer-btn:hover .tcj-transfer-label {
  text-decoration-color: currentColor;
}

/* Stop Statuses (closed, construction, planned) */
.tcj-station-item.closed .tcj-station-name,
.tcj-station-item.construction .tcj-station-name,
.tcj-station-item.planned .tcj-station-name {
  color: #bbb !important;
}

.tcj-station-item.closed .tcj-station-name {
  text-decoration: line-through !important;
}

.tcj-station-item.closed .tcj-circle,
.tcj-station-item.construction .tcj-circle,
.tcj-station-item.planned .tcj-circle {
  border-color: #bbb !important;
}

.tcj-station-item.planned .tcj-circle {
  border-style: dashed !important;
}

.tcj-status-label {
  font-size: 11px;
  color: #999;
  margin-top: 0;
  font-style: italic;
  line-height: 1;
}

/* 断开提示 */
.tcj-nc-tag {
  margin: 16px 0;
  text-align: center;
  font-size: 12px;
  color: #999;
  position: relative;
}
.tcj-nc-tag::before,
.tcj-nc-tag::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 40%;
  height: 2px;
  background: #ddd;
}
.tcj-nc-tag::before {
  left: 0;
}
.tcj-nc-tag::after {
  right: 0;
}

/* Mode selector (for multi-mode cities) */
.tcj-mode-selector {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 24px;
}
.tcj-mode-btn {
  padding: 8px 20px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: #666;
  transition: all 0.2s;
}
.tcj-mode-btn.active {
  background: #333;
  color: #fff;
  border-color: #333;
}

/* Pattern selector */
.tcj-pattern-selector {
  text-align: center;
  margin-bottom: 24px;
}
.tcj-pattern-label {
  font-weight: bold;
  font-size: 14px;
  margin-right: 8px;
}
.tcj-pattern-select {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #ddd;
  font-size: 14px;
}

/* Loading & Error */
.tcj-loading,
.tcj-error {
  text-align: center;
  padding: 60px;
  font-style: italic;
  color: #999;
}
