/* === Analytics Dashboard CSS === */

:root {
  --bg: #fcfcfd;
  --bg-alt: #f5f5fa;
  --surface: #ffffff;
  --border: #e8e8f0;
  --text: #111118;
  --text-secondary: #4a4a62;
  --text-tertiary: #6b6b80;
  --accent: #6b47f0;
  --accent-soft: rgba(107, 71, 240, 0.06);
  --accent-light: #ede8fe;
  --cyan: #00b4d8;
  --gradient: linear-gradient(135deg, #7c5bf5 0%, #00b4d8 100%);
  --nav-bg: rgba(252, 252, 253, 0.8);
  --glow: 0 0 0 transparent;
  --card-shadow: 0 2px 16px rgba(0,0,0,0.04);
  --green: #34d399;
  --orange: #f59e0b;
  --red: #ef4444;
}

[data-theme="dark"] {
  --bg: #0a0a14;
  --bg-alt: #0f0f1e;
  --surface: #14142a;
  --border: #1e1e3a;
  --text: #f0f0f8;
  --text-secondary: #b8b8d0;
  --text-tertiary: #9595b0;
  --accent: #9d7fff;
  --accent-soft: rgba(157, 127, 255, 0.1);
  --accent-light: #1e1540;
  --nav-bg: rgba(10, 10, 20, 0.85);
  --glow: 0 0 30px rgba(124, 91, 245, 0.15);
  --card-shadow: 0 4px 24px rgba(0,0,0,0.3);
  --green: #6ee7b7;
  --orange: #fbbf24;
  --red: #f87171;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Noto Sans JP', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.4s ease;
  line-height: 1.6;
}

::selection { background: var(--accent-light); color: var(--accent); }

/* === Nav === */
.analytics-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border-bottom: 1px solid var(--border);
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 2rem;
  transition: background 0.4s, border-color 0.4s;
}

.analytics-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-size: 1.3rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
}
.nav-logo .nav-back {
  margin-right: 6px;
  font-size: 0.9rem;
  opacity: 0.5;
  font-weight: 300;
  transition: opacity 0.2s;
}
.nav-logo:hover .nav-back { opacity: 1; }
.nav-m { color: var(--text); transition: color 0.4s; }
.nav-ai {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}

.nav-center {
  font-size: 0.7rem;
  font-weight: 300;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: border-color 0.2s, color 0.2s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* === Main Content === */
.analytics-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 100px 2rem 4rem;
}

.analytics-header {
  margin-bottom: 3rem;
}

.analytics-header h1 {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}

.analytics-header p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 300;
}

.analytics-timestamp {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 0.5rem;
}

/* === Section Headers === */
.section-title {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  width: fit-content;
}

.section-title::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 100%;
  height: 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 8' preserveAspectRatio='none'%3E%3Cpath d='M0 5 Q10 0 20 5 Q30 10 40 5 Q50 0 60 5 Q70 10 80 5 Q90 0 100 5 Q110 10 120 5 Q130 0 140 5 Q150 10 160 5 Q170 0 180 5 Q190 10 200 5' fill='none' stroke='%23a78bfa' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  opacity: 0.6;
}

[data-theme="dark"] .section-title::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 8' preserveAspectRatio='none'%3E%3Cpath d='M0 5 Q10 0 20 5 Q30 10 40 5 Q50 0 60 5 Q70 10 80 5 Q90 0 100 5 Q110 10 120 5 Q130 0 140 5 Q150 10 160 5 Q170 0 180 5 Q190 10 200 5' fill='none' stroke='%2367e8f9' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  opacity: 0.5;
}

.section-emoji { font-size: 1.2rem; }

/* === Card Grid === */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 3rem;
}

.card-grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

.card-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* === Cards === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--card-shadow);
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 8px 32px rgba(124,91,245,0.1);
}

[data-theme="dark"] .card:hover {
  box-shadow: 0 8px 32px rgba(124,91,245,0.2), var(--glow);
}

.card-wide { grid-column: span 2; }

/* === Stat Number Cards === */
.stat-number {
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.stat-sub {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-top: 0.25rem;
}

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 0.5rem;
  padding: 2px 8px;
  border-radius: 12px;
}

.trend-up { background: rgba(52,211,153,0.1); color: var(--green); }
.trend-neutral { background: var(--accent-soft); color: var(--accent); }

/* === Chart Containers === */
.chart-container {
  position: relative;
  margin-top: 1rem;
}

.chart-container canvas {
  width: 100% !important;
  height: auto !important;
}

.donut-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* === Lighthouse Scores === */
.lighthouse-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 0.75rem;
}

.lighthouse-item {
  text-align: center;
}

.lighthouse-ring {
  position: relative;
  width: 72px; height: 72px;
  margin: 0 auto 0.5rem;
}

.lighthouse-ring svg {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}

.lighthouse-ring circle {
  fill: none;
  stroke-width: 4;
}

.lighthouse-ring .ring-bg {
  stroke: var(--border);
}

.lighthouse-ring .ring-fg {
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease;
}

.lighthouse-score {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.1rem;
  font-weight: 700;
}

.lighthouse-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.score-green { color: var(--green); }
.score-orange { color: var(--orange); }
.score-red { color: var(--red); }
.stroke-green { stroke: var(--green); }
.stroke-orange { stroke: var(--orange); }
.stroke-red { stroke: var(--red); }

/* === Spotify Card === */
.spotify-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
}

.spotify-art {
  width: 64px; height: 64px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.spotify-art img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.spotify-art-placeholder {
  width: 100%; height: 100%;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.5rem;
}

.spotify-info { flex: 1; min-width: 0; }

.spotify-track {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spotify-artist {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.spotify-album {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.spotify-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--green);
  font-weight: 600;
  margin-top: 0.5rem;
}

.spotify-eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}

.spotify-eq span {
  width: 3px;
  background: var(--green);
  border-radius: 2px;
  animation: eq 1.2s ease-in-out infinite;
}
.spotify-eq span:nth-child(1) { height: 40%; animation-delay: 0s; }
.spotify-eq span:nth-child(2) { height: 70%; animation-delay: 0.2s; }
.spotify-eq span:nth-child(3) { height: 50%; animation-delay: 0.4s; }

@keyframes eq {
  0%, 100% { height: 20%; }
  50% { height: 100%; }
}

.spotify-not-playing {
  color: var(--text-tertiary);
  font-size: 0.85rem;
  padding: 1rem 0;
}

/* === GitHub Section === */
.commit-list {
  list-style: none;
  margin-top: 0.75rem;
}

.commit-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  align-items: flex-start;
}

.commit-item:last-child { border-bottom: none; }

.commit-hash {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  color: var(--accent);
  flex-shrink: 0;
  padding: 1px 6px;
  background: var(--accent-soft);
  border-radius: 4px;
}

.commit-msg {
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.commit-date {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* === Bar Chart === */
.bar-chart-container {
  margin-top: 1rem;
  height: 140px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  padding-bottom: 1.5rem;
  position: relative;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.bar {
  width: 100%;
  max-width: 20px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
  opacity: 0.7;
  transition: opacity 0.2s, height 0.6s ease;
  min-height: 2px;
}

.bar:hover { opacity: 1; }

.bar-label {
  font-size: 0.55rem;
  color: var(--text-tertiary);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  max-height: 2rem;
  overflow: hidden;
}

/* === Cloudflare Placeholder === */
.placeholder-overlay {
  position: relative;
}

.placeholder-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-tertiary);
  background: var(--bg-alt);
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 0.75rem;
}

.placeholder-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-tertiary);
  opacity: 0.4;
}

/* === Blog Post List === */
.post-mini-list {
  margin-top: 0.75rem;
}

.post-mini {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.post-mini:last-child { border-bottom: none; }

.post-mini-title {
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 0.75rem;
}

.post-mini-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.post-mini-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
}

.badge-journal { background: rgba(124,91,245,0.1); color: var(--accent); }
.badge-column { background: rgba(0,180,216,0.1); color: #007590; }

.post-mini-words {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

/* === Footer === */
.analytics-footer {
  text-align: center;
  padding: 3rem 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

.footer-logo {
  font-size: 1.2rem; font-weight: 600; margin-bottom: 0.5rem;
}

/* === Responsive === */
@media (max-width: 900px) {
  .card-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .card-wide { grid-column: span 1; }
  .lighthouse-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .analytics-main { padding: 90px 1.25rem 3rem; }
  .analytics-header h1 { font-size: 1.8rem; }
  .card-grid { grid-template-columns: 1fr; }
  .card-grid-3 { grid-template-columns: 1fr; }
  .lighthouse-grid { grid-template-columns: repeat(2, 1fr); }
  .bar-chart-container { height: 100px; }
  .stat-number { font-size: 2.2rem; }
}

/* === Twitter / X === */
.tweet-list {
  margin-top: 0.5rem;
}

.tweet-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.tweet-item:last-child { border-bottom: none; }

.tweet-item.tweet-best {
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin: 0.25rem -0.75rem;
  border-bottom: none;
}

.tweet-text {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 0.35rem;
}

.tweet-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

.tweet-date {
  font-weight: 500;
}

.tweet-metric {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.bar-twitter {
  background: var(--cyan);
}

/* === Loading State === */
.loading-shimmer {
  background: linear-gradient(90deg, var(--bg-alt) 25%, var(--surface) 50%, var(--bg-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
  height: 2rem;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
