/* ================================================================
   chart.css — 個別銘柄チャートページ
================================================================ */

.chart-page { padding: var(--sp-6) 0 var(--sp-16); }

/* ── HERO ── */
.chart-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.chart-hero__left {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}
.chart-hero__coin-badge {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chart-hero__symbol { font-size: 18px; font-weight: 900; }
.chart-hero__title { font-size: clamp(18px, 2.5vw, 24px); font-weight: 700; color: var(--color-text); margin: 0 0 4px; }
.chart-hero__sub   { font-size: 12px; color: var(--color-text-muted); margin: 0; }

.chart-hero__price-wrap { text-align: right; }
.chart-hero__price  { font-size: clamp(24px, 4vw, 36px); font-weight: 900; color: var(--color-text); line-height: 1; }
.chart-hero__change { font-size: 15px; font-weight: 700; margin: 4px 0; }
.chart-hero__change--up   { color: #dc2626; }
.chart-hero__change--down { color: #16a34a; }
.chart-hero__range  { font-size: 11px; color: var(--color-text-muted); }

/* ── メインチャート ── */
.chart-main-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow-sm);
}

.chart-periods {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.chart-period {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-full);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  font-family: var(--font-sans);
}
.chart-period:hover    { border-color: var(--color-primary); color: var(--color-primary); }
.chart-period.is-active { background: var(--color-primary); color: var(--blue-900); border-color: var(--color-primary); }

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  min-height: 180px;
}
#main-chart { display: block; width: 100%; }

.chart-loading {
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  gap: 6px;
  background: rgba(255,255,255,.8);
  border-radius: var(--r-lg);
}
.chart-loading__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-primary);
  animation: chartDot .8s ease-in-out infinite;
}
.chart-loading__dot:nth-child(2) { animation-delay: .15s; }
.chart-loading__dot:nth-child(3) { animation-delay: .3s; }
@keyframes chartDot { 0%,80%,100%{transform:scale(0.6);opacity:.4} 40%{transform:scale(1);opacity:1} }

/* ツールチップ */
.chart-tooltip {
  position: absolute;
  background: var(--gray-900);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: var(--r-md);
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
}

/* ── CTAストリップ ── */
.chart-cta-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  background: linear-gradient(135deg, var(--blue-900), var(--blue-700));
  border-radius: var(--r-xl);
  padding: var(--sp-5) var(--sp-6);
  margin-bottom: var(--sp-6);
}
.chart-cta-strip__text { font-size: 14px; color: rgba(255,255,255,.8); line-height: 1.6; }
.chart-cta-strip__text strong { color: #fff; }

/* ── レートグリッド ── */
.chart-rate-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-8);
}
@media (max-width: 639px) { .chart-rate-grid { grid-template-columns: repeat(2, 1fr); } }

.chart-rate-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: flex; flex-direction: column; gap: 4px;
}
.chart-rate-card__label { font-size: 10px; color: var(--color-text-muted); font-weight: 600; letter-spacing: .05em; }
.chart-rate-card__value { font-size: 15px; font-weight: 700; color: var(--color-text); line-height: 1.3; }
.chart-rate-card__value--up   { color: #dc2626; }
.chart-rate-card__value--down { color: #16a34a; }

/* ── 銘柄一覧 ── */
.chart-coins-section { margin-bottom: var(--sp-8); }
.chart-coins-section__title {
  font-size: 18px; font-weight: 700; color: var(--color-text);
  margin: 0 0 var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 2px solid var(--color-border-light);
}
.chart-coins-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
}
@media (min-width: 768px) { .chart-coins-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1024px) { .chart-coins-grid { grid-template-columns: repeat(6, 1fr); } }

.chart-coin-chip {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--sp-3) var(--sp-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-lg);
  text-decoration: none;
  transition: var(--transition-fast);
}
.chart-coin-chip:hover { border-color: var(--color-primary); background: var(--color-primary-dim); }
.chart-coin-chip.is-active { border-color: var(--color-primary); background: var(--color-primary-dim); }
.chart-coin-chip__symbol { font-size: 11px; font-weight: 800; line-height: 1; }
.chart-coin-chip__name   { font-size: 10px; color: var(--color-text-muted); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-coin-chip__price  { font-size: 11px; font-weight: 600; color: var(--color-text); margin-top: 2px; }

/* ── 前後ナビ ── */
.chart-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--color-border-light);
  margin-top: var(--sp-4);
}
.chart-nav__link {
  font-size: 13px; font-weight: 600;
  color: var(--color-primary-dark);
  text-decoration: none;
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-lg);
  transition: var(--transition-fast);
}
.chart-nav__link:hover { border-color: var(--color-primary); background: var(--color-primary-dim); }
.chart-nav__link--next { margin-left: auto; }

/* ── 本文エリア ── */
.chart-body { margin-bottom: var(--sp-8); }

/* ── レスポンシブ ── */
@media (max-width: 767px) {
  .chart-hero { flex-direction: column; }
  .chart-hero__price-wrap { text-align: left; }
  .chart-cta-strip { flex-direction: column; }
  .chart-cta-strip .btn { width: 100%; justify-content: center; }
}

/* ── FAQ ── */
.chart-faq { margin-bottom: var(--sp-8); }
.chart-faq__title {
  font-size: 18px; font-weight: 700; color: var(--color-text);
  margin: 0 0 var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 2px solid var(--color-border-light);
}
.chart-faq__item {
  border-bottom: 1px solid var(--color-border-light);
}
.chart-faq__question {
  font-size: 14px; font-weight: 600; color: var(--color-text);
  padding: var(--sp-4) var(--sp-2);
  cursor: pointer;
  list-style: none;
  display: flex; align-items: flex-start; gap: var(--sp-3);
  user-select: none;
}
.chart-faq__question span { flex: 1; text-align: left; }
.chart-faq__question::-webkit-details-marker { display: none; }
.chart-faq__question::before { content: 'Q'; color: var(--color-primary); font-weight: 900; flex-shrink: 0; align-self: flex-start; }
.chart-faq__question::after  { content: '+'; color: var(--color-text-muted); font-size: 18px; flex-shrink: 0; margin-left: auto; }
details[open] .chart-faq__question::after { content: '−'; }
.chart-faq__answer {
  font-size: 13px; color: var(--color-text-sub); line-height: 1.75;
  padding: 0 var(--sp-2) var(--sp-4) calc(var(--sp-2) + 1.2em);
}

/* ── コインロゴ画像 */
.chart-hero__coin-logo {
  width: 36px; height: 36px;
  object-fit: contain; display: block;
}
.chart-coin-chip__logo {
  width: 20px; height: 20px;
  object-fit: contain; display: block;
}

/* ================================================================
   チャートページ レスポンシブ最適化
================================================================ */

/* ── モバイル（〜767px） */
@media (max-width: 767px) {

  /* ヒーロー */
  .chart-hero {
    flex-direction: column;
    gap: var(--sp-3);
  }
  .chart-hero__left { gap: var(--sp-3); }
  .chart-hero__coin-badge { width: 44px; height: 44px; }
  .chart-hero__coin-logo { width: 28px; height: 28px; }
  .chart-hero__title { font-size: 18px; }
  .chart-hero__price { font-size: 26px; }
  .chart-hero__price-wrap { text-align: left; }

  /* メインチャート */
  .chart-main-card { padding: var(--sp-4) var(--sp-3); }
  .chart-periods { gap: var(--sp-1); }
  .chart-period {
    font-size: 11px;
    padding: 4px 10px;
  }

  /* レートグリッド */
  .chart-rate-grid { gap: var(--sp-2); }
  .chart-rate-card { padding: var(--sp-3); }
  .chart-rate-card__value { font-size: 13px; }

  /* 銘柄チップ */
  .chart-coins-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-coin-chip { padding: var(--sp-2); }
  .chart-coin-chip__logo { width: 18px; height: 18px; }
  .chart-coin-chip__name { font-size: 9px; }
  .chart-coin-chip__price { font-size: 10px; }

  /* 前後ナビ */
  .chart-nav { flex-direction: column; gap: var(--sp-2); }
  .chart-nav__link { text-align: center; }
  .chart-nav__link--next { margin-left: 0; }

  /* FAQ */
  .chart-faq__title { font-size: 16px; }
  .chart-faq__question { font-size: 13px; padding: var(--sp-3) var(--sp-2); }
  .chart-faq__answer { font-size: 12px; }
}

/* ── 小さいスマホ（〜374px） */
@media (max-width: 374px) {
  .chart-periods { flex-wrap: wrap; }
  .chart-period { flex: 1; min-width: 0; text-align: center; }
  .chart-coins-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── タブレット（768px〜1023px） */
@media (min-width: 768px) and (max-width: 1023px) {
  .chart-rate-grid { grid-template-columns: repeat(3, 1fr); }
  .chart-coins-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ================================================================
   チャート一覧ページ（/chart_price/）
================================================================ */
.chart-list-page { padding: var(--sp-6) 0 var(--sp-16); }

/* ── ヘッダー */
.cl-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-6);
}
.cl-header__title {
  font-size: clamp(20px, 2.8vw, 28px);
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 var(--sp-2);
}
.cl-header__desc {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 0;
}
.cl-header__live {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
  padding-top: var(--sp-2);
}
.cl-live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16,185,129,.3);
  animation: clLivePulse 2s ease infinite;
  flex-shrink: 0;
}
@keyframes clLivePulse {
  0%,100% { box-shadow: 0 0 0 2px rgba(16,185,129,.3); }
  50%      { box-shadow: 0 0 0 5px rgba(16,185,129,.1); }
}

/* ── ツールバー */
.cl-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.cl-search-wrap { flex: 1; min-width: 200px; }
.cl-search {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-full);
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239EACBB' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 12px center;
  outline: none;
  transition: border-color .15s;
}
.cl-search:focus { border-color: var(--color-primary); }

.cl-sort-wrap { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }
.cl-sort-label { font-size: 12px; color: var(--color-text-muted); white-space: nowrap; }
.cl-sort {
  padding: 8px 28px 8px 12px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-md);
  font-size: 12px;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239EACBB' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.cl-sort:focus { border-color: var(--color-primary); }

/* ── テーブル */
.cl-table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.cl-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}
.cl-table__head { background: var(--gray-50); }
.cl-th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: .05em;
  text-align: right;
  border-bottom: 1px solid var(--color-border-light);
  white-space: nowrap;
}
.cl-th--coin { text-align: left; }
.cl-th--action { text-align: center; }

.cl-row { border-bottom: 1px solid var(--color-border-light); transition: background .1s; }
.cl-row:last-child { border-bottom: none; }
.cl-row:hover { background: var(--color-primary-dim); }

.cl-td {
  padding: 12px 16px;
  text-align: right;
  vertical-align: middle;
}
.cl-td--coin { text-align: left; }
.cl-td--action { text-align: center; }

/* コイン情報 */
.cl-coin {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  text-decoration: none;
}
.cl-coin__icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.cl-coin__icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cl-coin__info { display: flex; flex-direction: column; gap: 2px; }
.cl-coin__name   { font-size: 14px; font-weight: 600; color: var(--color-text); line-height: 1; }
.cl-coin__symbol { font-size: 11px; color: var(--color-text-muted); line-height: 1; }

/* 価格・変化 */
.cl-price { font-size: 14px; font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; }
.cl-change { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cl-change--up   { color: #dc2626; }
.cl-change--down { color: #16a34a; }
.cl-sub { font-size: 12px; color: var(--color-text-sub); font-variant-numeric: tabular-nums; }

/* チャートリンク */
.cl-chart-link {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-primary-dark);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--r-full);
  white-space: nowrap;
  transition: var(--transition-fast);
}
.cl-chart-link:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-dim);
}

/* ── レスポンシブ */
@media (max-width: 767px) {
  .cl-header { flex-direction: column; gap: var(--sp-3); }
  .cl-toolbar { gap: var(--sp-2); }
  .cl-search-wrap { min-width: 0; }
  .cl-sort-wrap { width: 100%; }
  .cl-sort { flex: 1; }
  /* 高値・安値列をSPで非表示 */
  .cl-th--high,
  .cl-th--low,
  .cl-td--high,
  .cl-td--low { display: none; }
  .cl-coin__name { font-size: 13px; }
  .cl-coin__icon { width: 30px; height: 30px; }
}
