@property --angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

:root {
  --bg: #fafbfc;
  --fg: #0a0a0b;
  --muted: #73737d;
  --border: #e5e7eb;
  --card: #ffffff;
  --accent: #000000;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --ava: 80px;
  --dot-x: 54px;
  --gap: 22px;
  --skel-base: #efefef;
  --skel-shine: #f8f8f8;
  --spark-dark: rgba(0,0,0,0.15);
  --spark-mid: #111;
  --theme-toggle-bg: rgba(0,0,0,0.06);
  --theme-toggle-hover: rgba(0,0,0,0.1);
  color-scheme: light;
}

/* ── Dark theme ── */
[data-theme="dark"] {
  --bg: #0d0d0f;
  --fg: #f0f0f2;
  --muted: #8a8a96;
  --border: #1f2028;
  --card: #141418;
  --accent: #ffffff;
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.12);
  --skel-base: #1a1a1e;
  --skel-shine: #22222a;
  --spark-dark: rgba(255,255,255,0.1);
  --spark-mid: #d0d0d8;
  --theme-toggle-bg: rgba(255,255,255,0.08);
  --theme-toggle-hover: rgba(255,255,255,0.13);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0d0f;
    --fg: #f0f0f2;
    --muted: #8a8a96;
    --border: #1f2028;
    --card: #141418;
    --accent: #ffffff;
    --green: #22c55e;
    --green-bg: rgba(34,197,94,0.12);
    --skel-base: #1a1a1e;
    --skel-shine: #22222a;
    --spark-dark: rgba(255,255,255,0.1);
    --spark-mid: #d0d0d8;
    --theme-toggle-bg: rgba(255,255,255,0.08);
    --theme-toggle-hover: rgba(255,255,255,0.13);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  transition:
    background-color 0.35s ease,
    color 0.35s ease;
}

body {
  font-family: "Geist", sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

.canvas {
  width: 100%;
  max-width: 650px;
  padding: 70px 20px 80px 0;
  position: relative;
}

/* ── Thread ── */
.thread {
  position: absolute;
  left: var(--dot-x);
  top: 70px;
  width: 2px;
  background: var(--border);
  border-radius: 2px;
  transform: translateX(-50%);
  overflow: hidden;
}

.spark {
  position: absolute;
  left: 0;
  width: 100%;
  height: 90px;
  border-radius: 2px;
  transition: background 0.4s ease;
}

/* ── Nodes ── */
.node {
  position: relative;
  padding-left: calc(var(--dot-x) + var(--gap));
  margin-bottom: 60px;
  animation: fadeUp 0.7s cubic-bezier(0.2, 1, 0.2, 1) backwards;
}
.node:nth-child(2) {
  animation-delay: 0.05s;
}
.node:nth-child(3) {
  animation-delay: 0.12s;
}
.node:nth-child(4) {
  animation-delay: 0.19s;
}
.node:nth-child(5) {
  animation-delay: 0.26s;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Avatar ── */
.dot-avatar {
  position: absolute;
  left: var(--dot-x);
  top: 0;
  transform: translateX(-50%);
  z-index: 3;
}

.ava {
  width: var(--ava);
  height: var(--ava);
  border-radius: 50%;
  object-fit: cover;
  display: block;
  box-shadow:
    0 0 0 5px var(--bg),
    0 8px 24px rgba(0, 0, 0, 0.1);
  transition:
    transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.4s;
}
.ava:hover {
  transform: scale(1.08) rotate(-4deg);
}
.ava.pulse-green {
  box-shadow:
    0 0 0 5px var(--bg),
    0 0 0 8px rgba(22, 163, 74, 0.3),
    0 8px 24px rgba(0, 0, 0, 0.1);
}

.node-avatar {
  min-height: var(--ava);
}

/* ── Dots ── */
.dot {
  position: absolute;
  left: var(--dot-x);
  top: 6px;
  transform: translateX(-50%);
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--card);
  border: 2.5px solid var(--accent);
  box-shadow: 0 0 0 4px var(--bg);
  z-index: 3;
  transition:
    background 0.3s,
    border-color 0.3s,
    box-shadow 0.3s;
}

.dot.green {
  background: var(--green);
  border-color: var(--green);
  box-shadow:
    0 0 0 4px var(--bg),
    0 0 0 7px rgba(22, 163, 74, 0.35);
  animation: dotPulse 1.8s ease-in-out infinite;
}

@keyframes dotPulse {
  0%,
  100% {
    box-shadow:
      0 0 0 4px var(--bg),
      0 0 0 7px rgba(22, 163, 74, 0.35);
  }
  50% {
    box-shadow:
      0 0 0 4px var(--bg),
      0 0 0 12px rgba(22, 163, 74, 0);
  }
}

/* ── Section label ── */
.lbl {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Active card ── */
.active-card {
  --r: 22px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 26px 28px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.04);
  position: relative;
  isolation: isolate;
  transition:
    transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.35s,
    border-color 0.3s;
}
.active-card:hover {
  transform: translateY(-3px) scale(1.005);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.08);
}

.active-card::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: calc(var(--r) + 2px);
  background: conic-gradient(
    from var(--angle),
    transparent 0deg,
    #16a34a 40deg,
    #4ade80 70deg,
    #16a34a 110deg,
    transparent 160deg
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 2px;
  opacity: 0;
  z-index: -1;
  pointer-events: none;
  animation: traceSpin 1.6s linear infinite;
  transition: opacity 0.3s;
}

.active-card.traced::before {
  opacity: 1;
}

@keyframes traceSpin {
  to {
    --angle: 360deg;
  }
}

.active-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.active-name {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  flex: 1;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  color: var(--green);
  background: var(--green-bg);
  border-radius: 100px;
  padding: 4px 10px;
  flex-shrink: 0;
  margin-top: 2px;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: badgeDot 2s infinite;
}
@keyframes badgeDot {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.7);
  }
}

.active-desc {
  font-size: 0.93rem;
  color: var(--muted);
  line-height: 1.65;
}
.active-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}
.stars {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 800;
  color: #d97706;
}
.stars svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}
.ago {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--muted);
}

/* ── Grid ── */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.gcard {
  --r: 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  position: relative;
  isolation: isolate;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.03);
  transition:
    transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.3s,
    border-color 0.2s;
}
.gcard:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.07);
}

.gcard::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: calc(var(--r) + 2px);
  background: conic-gradient(
    from var(--angle),
    transparent 0deg,
    #111 50deg,
    #666 80deg,
    #111 110deg,
    transparent 160deg
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 2px;
  opacity: 0;
  z-index: -1;
  pointer-events: none;
  animation: traceSpin 1.4s linear infinite;
  transition: opacity 0.25s;
}
.gcard.traced::before {
  opacity: 1;
}

.gcard-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}
.gname {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  flex: 1;
}
.gdesc {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── GitHub button ── */
.proj-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.gh-btn {
  width: 46px;
  height: 46px;
  background: var(--accent);
  color: var(--card);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  transition:
    transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.35s;
  position: relative;
  isolation: isolate;
}
.gh-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
}
.gh-btn.glowing {
  box-shadow:
    0 0 0 3px var(--bg),
    0 0 0 6px rgba(0, 0, 0, 0.4),
    0 0 18px rgba(0, 0, 0, 0.3),
    0 4px 14px rgba(0, 0, 0, 0.15);
  animation: ghGlow 0.6s ease-in-out infinite alternate;
}
@keyframes ghGlow {
  from {
    box-shadow:
      0 0 0 3px var(--bg),
      0 0 0 5px rgba(0, 0, 0, 0.3),
      0 0 12px rgba(0, 0, 0, 0.2);
  }
  to {
    box-shadow:
      0 0 0 3px var(--bg),
      0 0 0 8px rgba(0, 0, 0, 0.5),
      0 0 24px rgba(0, 0, 0, 0.35);
  }
}
.gh-btn svg {
  width: 21px;
  height: 21px;
}

/* Dark mode: flip GitHub button so it stays dark bg / light icon */
[data-theme="dark"] .gh-btn {
  background: var(--card);
  color: var(--fg);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .gh-btn {
    background: var(--card);
    color: var(--fg);
  }
}

/* ── Skeletons ── */
.skel {
  border-radius: 22px;
  background: linear-gradient(90deg, var(--skel-base) 25%, var(--skel-shine) 50%, var(--skel-base) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite;
}
.skel-active {
  height: 130px;
}
.skel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.skel-card {
  height: 90px;
  border-radius: 16px;
}

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

/* ── Theme toggle button ── */
.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  transition:
    background 0.3s,
    border-color 0.3s,
    transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s;
  color: var(--fg);
}
.theme-toggle:hover {
  transform: scale(1.12) rotate(15deg);
  box-shadow: 0 6px 20px rgba(0,0,0,0.14);
  background: var(--theme-toggle-hover);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
  position: absolute;
  transition:
    opacity 0.3s ease,
    transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.icon-sun {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}
.icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}
[data-theme="dark"] .icon-sun,
:root:not([data-theme="light"]):is(.dark-os) .icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}
[data-theme="dark"] .icon-moon,
:root:not([data-theme="light"]):is(.dark-os) .icon-moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

/* ── Socials ── */
.socials {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 100px;
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  transition:
    background 0.25s,
    color 0.25s,
    transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.25s,
    border-color 0.25s;
}
.pill svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  transition: color 0.25s;
}
.pill:hover {
  background: var(--accent);
  color: var(--card);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}
.pill:hover svg {
  color: var(--card) !important;
}

.pill.glowing {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.08),
    0 4px 14px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: -50px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 11px 22px;
  border-radius: 50px;
  font-size: 0.83rem;
  font-weight: 700;
  transition: bottom 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 999;
  white-space: nowrap;
}
.toast.on {
  bottom: 36px;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

@media (min-width: 1280px) {
  :root {
    --ava: 92px;
    --dot-x: 60px;
    --gap: 26px;
  }
  .canvas {
    padding-top: 90px;
  }
  .thread {
    top: 90px;
  }
  .active-card {
    padding: 32px 34px;
  }
  .active-name {
    font-size: 1.65rem;
  }
}

@media (min-width: 900px) and (max-width: 1279px) {
  .canvas {
    max-width: 720px;
  }
}

@media (max-width: 899px) {
  .canvas {
    padding-top: 60px;
  }
  .thread {
    top: 60px;
  }
}

@media (min-width: 600px) and (max-width: 899px) {
  :root {
    --ava: 74px;
    --dot-x: 50px;
    --gap: 20px;
  }
  .canvas {
    max-width: 100%;
  }
  .active-card {
    padding: 22px 24px;
  }
  .active-name {
    font-size: 1.3rem;
  }
  .node {
    margin-bottom: 52px;
  }
}

@media (min-width: 380px) and (max-width: 599px) {
  :root {
    --ava: 68px;
    --dot-x: 46px;
    --gap: 18px;
  }
  .active-card {
    padding: 18px 20px;
    border-radius: 18px;
  }
  .active-name {
    font-size: 1.2rem;
  }
  .active-desc {
    font-size: 0.88rem;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .skel-grid {
    grid-template-columns: 1fr;
  }
  .gcard {
    padding: 14px 16px;
  }
  .node {
    margin-bottom: 48px;
  }
  .pill {
    padding: 10px 16px;
    font-size: 0.8rem;
  }
}

@media (max-width: 379px) {
  :root {
    --ava: 60px;
    --dot-x: 42px;
    --gap: 16px;
  }
  .active-card {
    padding: 16px 18px;
    border-radius: 16px;
    gap: 9px;
  }
  .active-name {
    font-size: 1.1rem;
  }
  .active-desc {
    font-size: 0.84rem;
  }
  .badge {
    font-size: 0.62rem;
    padding: 3px 8px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .skel-grid {
    grid-template-columns: 1fr;
  }
  .gcard {
    padding: 12px 14px;
    border-radius: 13px;
  }
  .gname {
    font-size: 0.85rem;
  }
  .gdesc {
    font-size: 0.73rem;
  }
  .node {
    margin-bottom: 42px;
  }
  .pill {
    padding: 9px 14px;
    font-size: 0.77rem;
    gap: 6px;
  }
  .pill svg {
    width: 15px;
    height: 15px;
  }
  .gh-btn {
    width: 40px;
    height: 40px;
  }
  .gh-btn svg {
    width: 18px;
    height: 18px;
  }
  .lbl {
    font-size: 0.66rem;
  }
}

@media (max-width: 319px) {
  :root {
    --ava: 54px;
    --dot-x: 38px;
    --gap: 14px;
  }
  .active-name {
    font-size: 1rem;
  }
  .pill {
    padding: 8px 12px;
    font-size: 0.73rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .spark {
    display: none;
  }
  .dot.green {
    animation: none;
  }
  .badge::before {
    animation: none;
  }
  .ava:hover {
    transform: none;
  }
  .active-card::before,
  .gcard::before {
    display: none;
  }
}
