/**
 * 股票页专用样式
 * —— 行情脊 quote-spine（签名元素）
 * —— 列表板 / 筛选 / 卡片
 * —— 详情报价条 / K 线
 */

/* ========== 行情脊：全宽墨色胶带，价格等宽跳动 ========== */
.quote-spine {
  position: relative;
  height: var(--spine-h);
  background: linear-gradient(180deg, var(--spine) 0%, #10192a 100%);
  color: #d7e2f2;
  overflow: hidden;
  border-bottom: 1px solid rgba(18, 140, 126, 0.35);
}

.quote-spine::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--signal);
  box-shadow: 0 0 18px rgba(18, 140, 126, 0.65);
  animation: spine-scan 4.8s ease-in-out infinite;
}

.quote-spine__track {
  display: flex;
  align-items: center;
  gap: 0;
  height: 100%;
  width: max-content;
  animation: spine-marquee 48s linear infinite;
  will-change: transform;
}

.quote-spine:hover .quote-spine__track {
  animation-play-state: paused;
}

.quote-spine__item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  padding: 0 22px;
  white-space: nowrap;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.86rem;
  line-height: 1;
}

.quote-spine__sym {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #f3f7ff;
}

.quote-spine__px {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 0.95rem;
}

.quote-spine__chg {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  opacity: 0.95;
}

.quote-spine__empty {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 20px;
  color: rgba(215, 226, 242, 0.55);
  font-size: 0.85rem;
}

@keyframes spine-marquee {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

@keyframes spine-scan {
  0%,
  100% {
    transform: translateX(0);
    opacity: 0.55;
  }
  50% {
    transform: translateX(40vw);
    opacity: 1;
  }
}

/* ========== 页面引言（居中） ========== */
.board-intro {
  padding: 28px 0 8px;
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
}

.board-intro__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.7rem, 3.2vw, 2.35rem);
  letter-spacing: 0.01em;
  line-height: var(--leading-tight);
}

.board-intro__desc {
  margin: 0;
  max-width: 36rem;
  color: var(--ink-soft);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
}

.board-meta {
  margin-top: 6px;
  max-width: 40rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink-soft);
  text-align: center;
}

.board-meta a {
  color: var(--signal);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.board-meta a:hover {
  color: var(--ink);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(14, 22, 40, 0.04);
  border: 1px solid var(--line);
  font-weight: 500;
  color: var(--ink-soft);
}

.live-pill__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.live-pill.is-live .live-pill__dot {
  background: var(--signal);
  box-shadow: 0 0 0 0 rgba(18, 140, 126, 0.55);
  animation: live-pulse 1.8s ease-out infinite;
}

.live-pill.is-error {
  color: var(--up);
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(18, 140, 126, 0.45);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(18, 140, 126, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(18, 140, 126, 0);
  }
}

/* ========== 市场筛选 ========== */
/* 市场 Tab 左 + 搜索右 */
.board-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin: 20px 0 16px;
}

.market-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.market-tabs a,
.market-tabs button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink-soft);
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}

.market-tabs a.is-active,
.market-tabs button.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #f4f7fb;
}

.board-search {
  position: relative;
  /* 给搜索区明确宽度，避免 flex 收缩后 100% 算不出目标值 */
  flex: 0 1 420px;
  width: 420px;
  max-width: 100%;
  margin-left: auto;
  z-index: 20;
}

.board-search__field {
  position: relative;
  width: 100%;
}

.board-search input[type="search"] {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
}

.board-search input[type="search"]::placeholder {
  color: var(--muted);
}

.board-search input[type="search"]:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--signal);
}

/* 下拉结果 */
.board-search__panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 360px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.board-search__item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: inherit;
}

.board-search__item:last-child {
  border-bottom: 0;
}

.board-search__item:hover,
.board-search__item:focus-visible {
  background: rgba(18, 140, 126, 0.08);
  color: inherit;
}

.board-search__item img,
.board-search__icon-ph {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--mist);
  flex-shrink: 0;
  object-fit: cover;
}

.board-search__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.board-search__sym {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.25;
}

.board-search__name {
  color: var(--muted);
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-search__meta.is-name-first .board-search__sym {
  font-weight: 600;
}

.board-search__meta.is-name-first .board-search__name {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

.board-search__empty,
.board-search__more {
  padding: 12px;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========== 列表桌面表格 ========== */
.quote-board {
  margin: 8px 0 24px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.quote-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: var(--text-md);
}

.quote-table th {
  text-align: left;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
  color: var(--muted);
  padding: 14px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(228, 235, 243, 0.55);
  white-space: nowrap;
}

.quote-table td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.quote-table tbody tr {
  transition: background 0.15s ease;
}

.quote-table tbody tr:hover {
  background: rgba(18, 140, 126, 0.05);
}

.quote-table tbody tr.flash-up {
  animation: flash-up 0.55s ease;
}

.quote-table tbody tr.flash-down {
  animation: flash-down 0.55s ease;
}

@keyframes flash-up {
  from {
    background: rgba(225, 29, 72, 0.12);
  }
  to {
    background: transparent;
  }
}

@keyframes flash-down {
  from {
    background: rgba(15, 118, 110, 0.12);
  }
  to {
    background: transparent;
  }
}

.cell-name {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.cell-name img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--mist);
  object-fit: cover;
  flex-shrink: 0;
}

/* 左图标；默认右上代码 / 右下中文名；港股韩股用 is-name-first 对调视觉 */
.cell-name__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  min-width: 0;
}

.cell-name__sym {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
}

.cell-name__desc {
  display: block;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

/* 港股 / 韩股：名称在上（主样式）、代码在下（次样式） */
.cell-name__text.is-name-first .cell-name__desc {
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 500;
  max-width: 260px;
}

.cell-name__text.is-name-first .cell-name__sym {
  color: var(--muted);
  font-family: var(--font-num);
  font-size: var(--text-sm);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-weight: 500;
}

.badge-ex {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: var(--radius);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--signal-soft);
  color: var(--signal);
}

.badge-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: var(--radius);
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(14, 22, 40, 0.05);
  color: var(--ink-soft);
}

.board-empty,
.board-hint {
  padding: 28px 18px;
  color: var(--muted);
  text-align: center;
}

/* 分页 */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
  margin: 8px 0 32px;
  font-size: 0.88rem;
}

.pager a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  line-height: 1;
}

.pager a:hover {
  background: var(--signal-soft);
}

.pager span {
  color: var(--muted);
  padding: 0 4px;
}

/* 手机卡片列表 */
.quote-cards {
  display: none;
  gap: 10px;
  margin: 8px 0 24px;
}

.quote-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  padding: 16px;
  min-height: 88px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.quote-card__left {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.quote-card__right {
  text-align: right;
  align-self: center;
}

.quote-card__px {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  font-weight: 600;
}

.quote-card__chg {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
  font-weight: 500;
}

/* ========== 详情页 ========== */
.detail-head {
  padding: 24px 0 0;
  display: grid;
  gap: 16px;
}

.detail-back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink-soft);
  font-weight: 500;
  width: fit-content;
}

.detail-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
}

.detail-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
  min-width: 0;
}

.detail-trade-links {
  margin: 0;
  max-width: 28rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink-soft);
  text-align: right;
}

.detail-trade-links a {
  color: var(--signal);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.detail-trade-links a:hover {
  color: var(--ink);
}

.detail-identity img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--mist);
}

.detail-identity h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.55rem, 3vw, 2.1rem);
  letter-spacing: 0.01em;
  line-height: var(--leading-tight);
}

/* 港股 / 韩股详情：中文名用黑体更清晰 */
.detail-identity.is-name-first h1 {
  font-family: var(--font-sans);
  font-weight: 600;
}

.detail-identity p {
  margin: 4px 0 0;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

.detail-identity.is-name-first p {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
}

.quote-strip {
  display: grid;
  /* 左侧给长数字（韩股）留足空间，与右侧拉开间距 */
  grid-template-columns: minmax(220px, max-content) minmax(0, 1fr);
  gap: 20px 56px;
  align-items: center;
  padding: 20px 24px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

/* 默认 PC：价在上、状态在下居中 */
.quote-strip__main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  padding-right: 40px;
  border-right: 1px solid var(--line);
}

.quote-strip__price-col {
  min-width: 0;
  width: 100%;
}

.quote-strip__last-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.quote-strip__ccy {
  font-family: var(--font-num);
  font-size: clamp(1.1rem, 2.4vw, 1.4rem);
  font-weight: 600;
  color: var(--ink-soft);
  line-height: 1;
  flex-shrink: 0;
}

.quote-strip__last {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-size: clamp(1.55rem, 3.6vw, 2.3rem);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.15;
  word-break: break-all;
}

.quote-strip__chg {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
  font-size: var(--text-base);
  font-weight: 500;
}

/* 时段状态：仅显示文案，居中 + 青绿底色 */
.quote-strip__session {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  align-self: center;
  min-width: 4.5em;
  padding: 8px 14px;
  background: var(--signal-soft);
  border: 1px solid rgba(18, 140, 126, 0.22);
  text-align: center;
  line-height: 1.3;
}

.quote-strip__session [data-q="status"] {
  display: block;
  width: 100%;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--signal);
  text-align: center;
}

.quote-strip__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 20px;
  min-width: 0;
}

.quote-kv span {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-bottom: 4px;
}

.quote-kv strong {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: var(--text-md);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  /* 报价条→K线、K线→资料：同一间距 */
  margin: 16px 0;
}

.panel {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  padding: 16px;
  min-height: 280px;
  min-width: 0;
}

/* 资料区不需要与 K 线同高的占位 */
.panel-meta {
  min-height: 0;
  margin: 0 0 24px;
}

.panel h2 {
  margin: 0 0 12px;
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.kline-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.kline-toolbar button {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  min-height: 40px;
  min-width: 44px;
  padding: 0 12px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--ink-soft);
}

.kline-toolbar button.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

#kline-chart {
  width: 100%;
  height: 320px;
  background:
    linear-gradient(180deg, rgba(18, 140, 126, 0.04), transparent 40%),
    #f8fafc;
  border: 1px dashed rgba(14, 22, 40, 0.1);
  position: relative;
  overflow: hidden;
}

#kline-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.kline-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 16px;
  text-align: center;
}

/* display:grid 会盖掉原生 [hidden]，必须显式隐藏 */
.kline-placeholder[hidden],
.kline-placeholder.is-hidden {
  display: none !important;
}

/* 交易对资料：PC/Pad 一行两列；手机单列 */
.meta-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.meta-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.meta-list span {
  flex-shrink: 0;
  color: var(--muted);
}

.meta-list strong {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}

/* 类型 / 交易模式等中文值 */
.meta-list__text {
  font-family: var(--font-sans);
  font-variant-numeric: normal;
}

@media (max-width: 767px) {
  .meta-list {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

/* ========== 响应式 ========== */
/* Pad：保留表格并展示全部列（收紧字号/内边距，容器可横滑） */
@media (max-width: 1100px) and (min-width: 768px) {
  .quote-board {
    display: block;
    width: 100%;
  }

  .quote-cards {
    display: none;
  }

  .quote-table {
    min-width: 720px;
    font-size: 0.84rem;
  }

  .quote-table th,
  .quote-table td {
    padding: 10px 8px;
    white-space: nowrap;
  }

  .quote-table .col-open,
  .quote-table .col-prev,
  .quote-table .col-amt,
  .quote-table .col-high,
  .quote-table .col-low,
  .quote-table .col-status {
    display: table-cell;
  }

  .cell-name__desc {
    max-width: 140px;
  }

  .board-intro__title {
    display: block;
    font-size: clamp(1.45rem, 3.5vw, 2rem);
  }
}

/* 手机 + Pad：报价条上下排布 */
@media (max-width: 1100px) {
  .quote-strip {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .quote-strip__main {
    padding-right: 0;
    border-right: 0;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
  }

  .quote-strip__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Pad + 手机（≤1024）：状态在最新价右侧 */
@media (max-width: 1024px) {
  .quote-strip__main {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
  }

  .quote-strip__price-col {
    flex: 1 1 auto;
    width: auto;
  }

  .quote-strip__session {
    align-self: center;
  }
}

@media (max-width: 767px) {
  /* 手机：报价扩展字段改为 2 列，避免 12 项挤成一团 */
  .quote-strip__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 12px;
  }

  .detail-title-row {
    flex-direction: column;
    align-items: stretch;
  }

  .detail-trade-links {
    text-align: center;
    max-width: none;
    font-size: 0.84rem;
  }

  .quote-board {
    display: none;
  }

  .quote-cards {
    display: grid;
  }

  .board-intro__title {
    display: block;
    font-size: clamp(1.4rem, 5vw, 1.75rem);
  }

  .quote-spine__item {
    padding: 0 16px;
  }

  #kline-chart {
    height: 240px;
  }

  .board-toolbar {
    flex-direction: column;
    align-items: stretch;
    margin: 12px 0 10px;
    gap: 10px;
  }

  .market-tabs {
    justify-content: center;
  }

  .board-search {
    /* 纵向排列时勿沿用 flex-basis:420px，否则搜索区被撑出大块空白 */
    flex: 0 0 auto;
    margin-left: 0;
    width: 100%;
    height: auto;
  }

  .board-search__field {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .quote-spine__track,
  .quote-spine::before,
  .live-pill.is-live .live-pill__dot {
    animation: none !important;
  }
}
