:root {
  --bg:        #080c10;
  --glass:     rgba(255,255,255,0.04);
  --glass-b:   rgba(255,255,255,0.09);
  --border:    var(--iatv-btn-border);
  --text:      var(--body-text);
  --muted:     var(--sec-text);
  --green-dim: rgba(22,163,74,0.18);
  --green-lo:  #14532d;
  --green-md:  #16a34a;
  --green-hi:  #22c55e;
  --green-max: #4ade80;
  --glow-lo:   rgba(22,163,74,0.35);
  --glow-hi:   rgba(74,222,128,0.6);
  --gold:      #f59e0b;
  --gold-glow: rgba(245,158,11,0.3);
  --radius-card: 24px;
  --radius-cell: 4px;
  --cell: 12px;
  --gap:  3px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body:    'Inter', sans-serif;
}

#github {
  position: relative;
  background-image:
    radial-gradient(ellipse 60% 40% at 20% 60%, rgba(22,163,74,0.07) 0%, transparent 70%),
    radial-gradient(ellipse 50% 35% at 80% 20%, rgba(245,158,11,0.05) 0%, transparent 70%);
  opacity: 1;
  padding-block: 12px 0px;
  pointer-events: auto;
  
  animation: github-appear linear both;
  animation-timeline: scroll();
  animation-range: 80px 240px;
}
@keyframes github-appear {
  to {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transform: translateY(-20px);
  }
}

/* ─── Card ─────────────────────────────────────── */
.card {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1.25rem;
  z-index: 1000;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04) inset,
    0 32px 64px rgba(0,0,0,0.5),
    0 0 80px rgba(22,163,74,0.06);
  animation: cardIn .5s cubic-bezier(.22,.68,0,1.2) both;
}
@keyframes cardIn {
  from { opacity:0; transform: translateY(15px) scale(.98); }
  to   { opacity:1; transform: none; }
}



/* ─── Profile header ─────────────────────────── */
.profile {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.85rem;
  animation: fadeUp .4s ease both;
}
@keyframes fadeUp {
  from { opacity:0; transform: translateY(8px); }
  to   { opacity:1; transform: none; }
}
.avatar-ring {
  position: relative;
  flex-shrink: 0;
  width: 52px; height: 52px;
}
.avatar-ring::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #16a34a, #4ade80, #f59e0b, #16a34a);
  animation: spin 2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.avatar-ring::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #16a34a, #4ade80, #f59e0b, #16a34a);
  filter: blur(6px);
  opacity: .5;
  animation: spin 4s linear infinite;
}
.avatar-img {
  position: relative;
  z-index: 1;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  object-fit: cover;
  display: block;
}
.profile-text { flex: 1; min-width: 0; }
.github-link {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: .3rem .7rem;
  transition: border-color .15s, color .15s;
  flex-shrink: 0;
}
.github-link:hover { border-color: rgba(22,163,74,.4); color: var(--green-hi); }

/* ─── Divider ─────────────────────────────────── */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 0.75rem 0;
}

/* ─── Stats strip ─────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
  animation: fadeUp .4s .05s ease both;
}
.stat-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: .4rem .6rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  white-space: nowrap;
  gap: .4rem;
  transition: border-color .2s, box-shadow .2s;
}
.stat-card:hover {
  border-color: rgba(22,163,74,0.3);
  box-shadow: 0 0 20px rgba(22,163,74,0.1);
}
.stat-val {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(135deg, #4ade80, #22c55e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-val.gold {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  -webkit-background-clip: text;
  background-clip: text;
}
.stat-lbl {
  font-size: .68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 500;
}

/* ─── Graph ──────────────────────────────────── */
.graph-section { animation: fadeUp .4s .1s ease both; }
.graph-title {
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  margin-bottom: .75rem;
}
.graph-scroll {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scroll-behavior: smooth;
}
.graph-scroll::-webkit-scrollbar { height: 3px; }
.graph-scroll::-webkit-scrollbar-track { background: transparent; }
.graph-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.graph-canvas {
  display: inline-flex;
  flex-direction: column;
  gap: 0;
  min-width: 100%;
}

/* Month label row */
.month-row {
  display: flex;
  padding-left: 26px; /* day-label column width */
  margin-bottom: 4px;
  position: relative;
  height: 16px;
}
.month-label {
  position: absolute;
  font-size: .68rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: .03em;
  white-space: nowrap;
  top: 0;
  transform: none;
}

/* Day grid */
.day-grid {
  display: flex;
  gap: 0;
}
.day-label-col {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  margin-right: 6px;
  width: 20px;
  flex-shrink: 0;
}
.day-lbl {
  height: var(--cell);
  font-size: .63rem;
  color: var(--muted);
  text-align: right;
  line-height: var(--cell);
  user-select: none;
}
.weeks-grid {
  display: flex;
  gap: var(--gap);
}
.week-col {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex-shrink: 0;
}

/* Cells */
.cell {
  width: var(--cell);
  height: var(--cell);
  border-radius: var(--radius-cell);
  background: rgba(255,255,255,0.04);
  flex-shrink: 0;
  cursor: default;
  transition: transform .12s, box-shadow .12s;
  position: relative;
}
.cell[data-l="0"] { background: rgba(255,255,255,0.04); }
.cell[data-l="1"] { background: var(--green-lo); }
.cell[data-l="2"] { background: #166534; }
.cell[data-l="3"] { background: var(--green-md); }
.cell[data-l="4"] { background: var(--green-hi); box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.cell[data-l="5"] { background: var(--green-max); box-shadow: 0 0 10px rgba(74,222,128,0.7), 0 0 20px rgba(74,222,128,0.3); }

.cell:hover {
  transform: scale(1.5);
  z-index: 10;
  box-shadow: 0 0 14px var(--glow-hi) !important;
}
/* pulse animation for high-activity cells */
.cell[data-l="5"] { animation: pulse 2.5s ease-in-out infinite; }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 10px rgba(74,222,128,0.7), 0 0 20px rgba(74,222,128,0.3); }
  50%      { box-shadow: 0 0 16px rgba(74,222,128,0.9), 0 0 32px rgba(74,222,128,0.5); }
}

/* ─── Legend ─────────────────────────────────── */
.legend {
  display: flex;
  align-items: center;
  gap: .35rem;
  justify-content: flex-end;
}

.leg-cell {
  width: 10px; height: 10px;
  border-radius: 3px;
}

/* ─── Status / Loader ─────────────────────────── */
.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: 2.5rem 0;
  font-size: .85rem;
  color: var(--muted);
  min-height: 100px;
}
.status.err { color: #f87171; }
.ring-loader {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(22,163,74,0.2);
  border-top-color: var(--green-hi);
  animation: spin .7s linear infinite;
}

/* ─── Tooltip ─────────────────────────────────── */
#tip {
  position: fixed;
  background: rgba(15,20,25,0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(22,163,74,0.3);
  border-radius: 10px;
  padding: .4rem .75rem;
  font-size: .75rem;
  color: var(--text);
  pointer-events: none;
  z-index: 19999;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .12s;
  box-shadow: 0 0 20px rgba(22,163,74,0.2), 0 4px 16px rgba(0,0,0,.5);
}
#tip.on { opacity: 1; }
#tip .tip-count { color: var(--green-hi); font-weight: 600; }

/* ─── Responsive ─────────────────────────────── */
@media (max-width: 768px) {
  #github {
    width: 100%;
  }

  #github .container {
    width: 100%;
    padding-inline: 16px;
  }

  .card {
    padding: .85rem;
    width: 100%;
  }

  .profile {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: relative;
    padding-top: 48px;
    gap: 12px;
  }

  .github-link span {
    display: none;
  }

  .avatar-ring {
    display: block !important;
    position: absolute;
    top: 0;
    left: 0;
  }

  .avatar-ring, .avatar-img {
    width: 35px;
    height: 35px;
  }

  .github-link {
    padding: 0;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    position: absolute;
    top: 0;
    right: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .profile-text {
    width: 100%;
  }

  .stat-val {
    font-size: .95rem !important;
    font-weight: 700;
  }
}

@media (max-width: 520px) {
  :root {
    --cell: 10px;
    --gap: 2px;
    --radius-cell: 3px;
  }
  .stat-val {
    font-size: .85rem !important;
  }
  .stat-lbl {
    font-size: .6rem;
  }
}