/* Tokens */
:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface-2: #21262d;
  --border:    #30363d;
  --border-2:  #21262d;
  --text:      #e6edf3;
  --text-2:    #c9d1d9;
  --muted:     #8b949e;
  --accent:    #58a6ff;
  --accent-h:  #79c0ff;
  --green:     #3fb950;

  /* Heatmap contribution levels */
  --c0: #161b22;
  --c1: #0e4429;
  --c2: #006d32;
  --c3: #26a641;
  --c4: #39d353;

  --cell-size: 10px;
  --cell-gap:  2px;
  --cell-step: 12px; /* cell-size + cell-gap */

  --radius:    6px;
  --radius-sm: 4px;
  --radius-lg: 10px;

  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur:  150ms;

  --max-w: 1080px;
  --gap:   24px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); text-decoration: underline; }

img { display: block; max-width: 100%; }

/* Layout */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
}

.page-body {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding-top: var(--gap);
  padding-bottom: 48px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--gap);
  align-items: start;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-2);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.site-logo:hover { color: var(--text); text-decoration: none; opacity: 0.85; }

.logo-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
  text-decoration: none;
}

.icon-sm { width: 14px; height: 14px; flex-shrink: 0; }

/* Profile */
.profile-section {
  padding: 36px 0 28px;
  border-bottom: 1px solid var(--border-2);
  margin-bottom: 4px;
}

.profile-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.avatar-wrap { flex-shrink: 0; }

.avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 2px solid var(--border);
  object-fit: cover;
}

.skeleton-avatar {
  background: var(--surface-2);
  border-color: var(--border-2);
}

.profile-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-names {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.display-name {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.username {
  font-size: 18px;
  font-weight: 300;
  color: var(--muted);
  text-decoration: none;
}
.username:hover { color: var(--accent); text-decoration: none; }

.bio {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
  max-width: 540px;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}
.meta-item svg { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.75; }
.meta-item:is(a):hover { color: var(--accent); text-decoration: none; }

.profile-stats {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.stat-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: background var(--dur);
}
.stat-link:hover { background: var(--surface-2); color: var(--accent); text-decoration: none; }

.stat-count {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-label { color: var(--muted); }

.stat-sep { color: var(--border); font-size: 12px; padding: 0 2px; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-2);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

.card-meta {
  font-size: 12px;
  color: var(--muted);
}

.card-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.card-link:hover { color: var(--accent-h); text-decoration: underline; }

/* Heatmap */
.heatmap-outer {
  padding: 16px 20px 12px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.heatmap-outer::-webkit-scrollbar { height: 4px; }
.heatmap-outer::-webkit-scrollbar-track { background: transparent; }
.heatmap-outer::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.heatmap-placeholder {
  height: 112px; /* month label ~16px + gap + 7*12px - 2px gap = 16+8+82 = 106px, round up */
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  border-radius: var(--radius);
}

/* Heatmap structure */
.heatmap-wrap { display: inline-block; }

.month-labels {
  position: relative;
  height: 20px;
  margin-bottom: 4px;
}

.month-label {
  position: absolute;
  top: 0;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  user-select: none;
}

.heatmap-grid-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

.day-labels {
  display: grid;
  grid-template-rows: repeat(7, var(--cell-size));
  gap: var(--cell-gap);
  flex-shrink: 0;
}

.day-labels span {
  font-size: 9px;
  color: var(--muted);
  line-height: var(--cell-size);
  text-align: right;
  user-select: none;
}

.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, var(--cell-size));
  gap: var(--cell-gap);
  /* grid-template-columns set dynamically via JS */
}

.heatmap-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 2px;
  background: var(--c0);
  cursor: default;
  transition: opacity var(--dur);
}
.heatmap-cell:hover { outline: 1px solid rgba(255,255,255,0.25); outline-offset: 1px; }

.heatmap-cell[data-level="0"] { background: var(--c0); }
.heatmap-cell[data-level="1"] { background: var(--c1); }
.heatmap-cell[data-level="2"] { background: var(--c2); }
.heatmap-cell[data-level="3"] { background: var(--c3); }
.heatmap-cell[data-level="4"] { background: var(--c4); }

/* Legend */
.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 0 20px 14px;
}

.legend-label { font-size: 11px; color: var(--muted); }

.legend-cells {
  display: flex;
  gap: var(--cell-gap);
}

.legend-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 2px;
}
.legend-cell[data-level="0"] { background: var(--c0); border: 1px solid var(--border); }
.legend-cell[data-level="1"] { background: var(--c1); }
.legend-cell[data-level="2"] { background: var(--c2); }
.legend-cell[data-level="3"] { background: var(--c3); }
.legend-cell[data-level="4"] { background: var(--c4); }

/* Repos Grid */
.repos-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border-2);
}

.repo-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: var(--surface);
  text-decoration: none;
  transition: background var(--dur) var(--ease);
  min-height: 120px;
}
.repo-card:hover { background: var(--surface-2); text-decoration: none; }

.skeleton-card {
  background: var(--surface);
  min-height: 120px;
  animation: shimmer 1.8s ease-in-out infinite;
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
}

.repo-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.repo-icon { width: 14px; height: 14px; flex-shrink: 0; color: var(--muted); }

.repo-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.repo-card:hover .repo-name { color: var(--accent-h); }

.repo-badge {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1px 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.repo-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  flex: 1;
  /* clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.repo-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.repo-lang {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

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

.repo-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.repo-stat svg { width: 13px; height: 13px; }

/* Activity Feed */
.activity-feed { display: flex; flex-direction: column; }

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-2);
  transition: background var(--dur);
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--surface-2); }

.activity-icon-wrap {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
}
.activity-icon-wrap svg { width: 14px; height: 14px; }

.activity-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.activity-repo {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}
.activity-repo:hover { color: var(--accent-h); text-decoration: underline; }

.activity-desc {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-time {
  font-size: 11px;
  color: var(--muted);
}

/* Skeleton feed */
.skeleton-feed { display: flex; flex-direction: column; }

.skeleton-feed-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-2);
}
.skeleton-feed-item:last-child { border-bottom: none; }

.skeleton-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 6px; }

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

.skeleton-line,
.skeleton-icon {
  background: linear-gradient(90deg,
    var(--surface-2) 25%,
    var(--border)    50%,
    var(--surface-2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  border-radius: var(--radius-sm);
  height: 14px;
  color: transparent !important;
  pointer-events: none;
}

.skeleton-line.display-name { height: 22px; border-radius: var(--radius-sm); }
.skeleton-line.username { height: 18px; }
.skeleton-line.stat-count { height: 14px; display: inline-block; }

/* Tooltip */
.tooltip {
  position: fixed;
  z-index: 1000;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-2);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 100ms, transform 100ms;
}
.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Empty / Error states */
.empty-state {
  padding: 24px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-2);
  padding: 20px 0;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.footer-sep { color: var(--border); }

/* Responsive */
@media (max-width: 900px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .profile-layout {
    flex-direction: column;
    gap: 16px;
  }

  .avatar { width: 64px; height: 64px; }

  .display-name { font-size: 18px; }
  .username { font-size: 14px; }

  .repos-grid {
    grid-template-columns: 1fr;
  }

  .card-header { padding: 14px 16px; }
  .heatmap-outer { padding: 14px 16px 10px; }
  .heatmap-legend { padding: 0 16px 12px; }
  .repo-card { padding: 14px 16px; }
}

@media (max-width: 380px) {
  .profile-stats { gap: 2px; }
  .stat-sep { display: none; }
  .stat-link { padding: 4px 6px; background: var(--surface-2); border-radius: var(--radius); }
}
