/* ========================================
   cocokin — 仮想通貨リアルタイム情報
   style.css
   © 2025 株式会社ヒューマニティドットジャパン
======================================== */

/* ---------- CSS変数：テーマ ---------- */
:root {
  --font-body: 'Noto Sans JP', sans-serif;
  --font-mono: 'Space Mono', monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.25s ease;
  --header-h: 56px;
  --sidebar-w: 220px;
}

/* ダークテーマ（デフォルト） */
[data-theme="dark"] {
  --bg: #0d0f14;
  --bg-card: #161b25;
  --bg-card2: #1e2535;
  --bg-header: rgba(13, 15, 20, 0.92);
  --border: #2a3248;
  --text: #e8eaf0;
  --text-sub: #8b95b0;
  --text-muted: #5a647a;
  --accent: #f7c948;
  --accent2: #3b82f6;
  --up: #22c55e;
  --down: #ef4444;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
  --sidebar-bg: #10141e;
  --sidebar-link-hover: #1e2535;
}

/* ライトテーマ */
[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-card: #ffffff;
  --bg-card2: #eef1f8;
  --bg-header: rgba(244, 246, 251, 0.95);
  --border: #dde3f0;
  --text: #1a1f2e;
  --text-sub: #5a647a;
  --text-muted: #9aa3b8;
  --accent: #d4a017;
  --accent2: #2563eb;
  --up: #16a34a;
  --down: #dc2626;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --sidebar-bg: #ffffff;
  --sidebar-link-hover: #eef1f8;
}

/* ---------- リセット・ベース ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  padding-top: var(--header-h);
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- ヘッダー ---------- */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  transition: background var(--transition);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent);
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.logo-icon { font-size: 1.3rem; }

.header-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-sub);
  transition: color var(--transition), background var(--transition);
}
.nav-link:hover {
  color: var(--text);
  background: var(--bg-card2);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-sub);
  font-size: 0.82rem;
  font-family: var(--font-body);
  transition: all var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}
.theme-icon { font-size: 1rem; }

/* ---------- サイドバー ---------- */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 90;
  transition: transform var(--transition), background var(--transition);
  transform: translateX(-100%);
}
.sidebar.open {
  transform: translateX(0);
}

.sidebar-toggle {
  position: fixed;
  top: calc(var(--header-h) + 16px);
  left: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-sub);
  font-size: 0.78rem;
  padding: 5px 10px;
  z-index: 95;
  transition: all var(--transition);
}
.sidebar-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.sidebar-content {
  padding: 48px 16px 24px;
}
.sidebar-title {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
  padding: 0 4px;
}
.sidebar-link {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-sub);
  transition: all var(--transition);
  margin-bottom: 2px;
}
.sidebar-link:hover {
  color: var(--text);
  background: var(--sidebar-link-hover);
}

/* ---------- ヒーロー ---------- */
.hero {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 60px 20px 48px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -60px; left: 50%;
  transform: translateX(-50%);
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(247,201,72,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero-title {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}
.hero-sub {
  font-size: 1.05rem;
  color: var(--text-sub);
  margin-bottom: 12px;
  font-weight: 500;
}
.hero-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto 24px;
  line-height: 1.7;
}
.hero-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.update-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.78rem;
  color: var(--text-sub);
  font-family: var(--font-mono);
}

.refresh-btn {
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 6px 16px;
  border-radius: 20px;
  transition: opacity var(--transition), transform var(--transition);
}
.refresh-btn:hover {
  opacity: 0.85;
  transform: scale(1.03);
}
.refresh-btn:active { transform: scale(0.97); }
.refresh-btn.loading { opacity: 0.5; pointer-events: none; }

/* ---------- グローバル統計 ---------- */
.global-stats {
  padding: 48px 0 24px;
}
.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 20px;
  letter-spacing: 0.02em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.stat-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.stat-card.loading { opacity: 0.5; }

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

/* ---------- 検索バー ---------- */
.search-section {
  padding: 24px 0;
}
.search-wrap {
  display: flex;
  gap: 12px;
  max-width: 600px;
}
.search-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font-body);
  transition: border-color var(--transition);
  outline: none;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); }

.currency-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font-body);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.currency-select:focus { border-color: var(--accent); }

/* ---------- コインテーブル ---------- */
.coins-section { padding: 0 0 48px; }

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.coin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.coin-table thead {
  background: var(--bg-card2);
  border-bottom: 1px solid var(--border);
}

.coin-table th {
  padding: 14px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.coin-table th:first-child { text-align: center; }
.coin-table th:nth-child(3),
.coin-table th:nth-child(4),
.coin-table th:nth-child(5),
.coin-table th:nth-child(6),
.coin-table th:nth-child(7) { text-align: right; }

.coin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  transition: background var(--transition);
}
.coin-table tr:last-child td { border-bottom: none; }
.coin-table tbody tr:hover td { background: var(--bg-card2); }

.coin-table td:first-child {
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  width: 48px;
}
.coin-table td:nth-child(3),
.coin-table td:nth-child(4),
.coin-table td:nth-child(5),
.coin-table td:nth-child(6),
.coin-table td:nth-child(7) { text-align: right; }

/* コイン名セル */
.coin-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.coin-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}
.coin-name { font-weight: 700; font-size: 0.9rem; }
.coin-symbol {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* 価格 */
.price {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.92rem;
}

/* 変動率 */
.change {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.change.up { color: var(--up); }
.change.down { color: var(--down); }
.change.flat { color: var(--text-muted); }

/* 時価総額・出来高 */
.mktcap, .volume {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-sub);
}

.detail-link {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--accent2);
  white-space: nowrap;
  transition: all var(--transition);
}
.detail-link:hover {
  background: var(--accent2);
  color: #fff;
  border-color: var(--accent2);
}

.loading-row {
  text-align: center;
  color: var(--text-muted);
  padding: 48px !important;
  font-size: 0.9rem;
}

/* ---------- Aboutセクション ---------- */
.about-section {
  padding: 48px 0 60px;
  border-top: 1px solid var(--border);
}
.about-text {
  color: var(--text-sub);
  font-size: 0.92rem;
  line-height: 1.8;
  max-width: 700px;
}
.ext-link {
  color: var(--accent2);
  text-decoration: underline;
}
.ext-link:hover { opacity: 0.8; }

/* ---------- フッター ---------- */
.footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 40px 20px 0;
  transition: background var(--transition);
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 48px;
  flex-wrap: wrap;
  padding-bottom: 32px;
}

.footer-logo {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 16px;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.footer-nav a, .footer-related a {
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: color var(--transition);
  padding: 2px 0;
}
.footer-nav a:hover, .footer-related a:hover { color: var(--text); }

.footer-right { flex: 1; }
.footer-related-title {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.footer-related {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.footer-bottom {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}
.footer-bottom a {
  color: var(--text-sub);
  transition: color var(--transition);
}
.footer-bottom a:hover { color: var(--accent); }

/* ---------- アニメーション ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.coin-table tbody tr {
  animation: fadeIn 0.3s ease both;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.spinning { display: inline-block; animation: spin 1s linear infinite; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 768px) {
  .header-nav { display: none; }
  .hero { padding: 40px 16px 36px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .search-wrap { flex-direction: column; }
  .coin-table th:nth-child(5),
  .coin-table td:nth-child(5),
  .coin-table th:nth-child(7),
  .coin-table td:nth-child(7) { display: none; }
  .footer-inner { flex-direction: column; gap: 24px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .coin-table th:nth-child(6),
  .coin-table td:nth-child(6) { display: none; }
}
