/* ============================================================
   Carlton King — personal site
   Coding / terminal theme · Math · Quant · AI
   ============================================================ */

:root {
  --bg: #0b0b0c;
  --surface: #141417;
  --surface-2: #1e1e22;
  --ink: #f3f3f4;
  --muted: #8b8b90;
  --line: #2c2c30;
  --accent: #f3f3f4;
  --accent-hover: #ffffff;
  --accent-ink: #0b0b0c;
  --accent-soft: rgba(243, 243, 244, 0.09);
  --cyan: #b4b4b9;
  --hero-glow: rgba(243, 243, 244, 0.06);
  --particle: 243, 243, 244;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 2px 6px rgba(0, 0, 0, 0.5), 0 20px 48px rgba(0, 0, 0, 0.5);
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, "Liberation Mono", monospace;
  --header-h: 68px;
}

[data-theme="light"] {
  --bg: #f5f5f6;
  --surface: #ffffff;
  --surface-2: #eaeaec;
  --ink: #1a1a1c;
  --muted: #6a6a6e;
  --line: #dcdcdf;
  --accent: #1a1a1c;
  --accent-hover: #000000;
  --accent-ink: #ffffff;
  --accent-soft: rgba(26, 26, 28, 0.07);
  --cyan: #6a6a6e;
  --hero-glow: rgba(26, 26, 28, 0.05);
  --particle: 26, 26, 28;
  --shadow: 0 1px 2px rgba(20, 30, 30, 0.05), 0 10px 30px rgba(20, 30, 30, 0.08);
  --shadow-hover: 0 2px 6px rgba(20, 30, 30, 0.08), 0 18px 44px rgba(20, 30, 30, 0.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }

body {
  margin: 0;
  font-family: var(--mono);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background 0.35s ease, color 0.35s ease;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

.container { width: min(1080px, 92%); margin: 0 auto; }

h1, h2, h3 { font-family: var(--mono); line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.01em; font-weight: 700; }
h2 { font-size: clamp(1.6rem, 3.6vw, 2.2rem); }
h3 { font-size: 1.05rem; }

p { margin: 0 0 1em; }

a { color: var(--accent); }

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

.eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.6rem;
}

.lede { font-size: 1rem; color: var(--muted); max-width: 640px; }

/* code color helpers */
.t-acc { color: var(--accent); }
.t-cyan { color: var(--cyan); }
.t-k { color: var(--cyan); font-weight: 600; }
.t-d { color: var(--muted); }
.t-dim { color: var(--muted); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.6rem 1rem;
  z-index: 300;
  border-radius: 0 0 8px 0;
  font-family: var(--mono);
}
.skip-link:focus { left: 0; }

/* ---------- Scroll progress ---------- */
.scroll-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 120;
  background: transparent;
}
#scrollProgressBar {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  transition: width 0.08s linear;
}

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.site-header.scrolled { border-bottom-color: var(--line); box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  gap: 1rem;
}

.brand {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.brand-dot { color: var(--accent); }

.nav-right { display: flex; align-items: center; gap: 0.4rem; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav-links a:hover { color: var(--ink); background: var(--surface-2); }
.nav-links a.active { color: var(--accent); background: var(--accent-soft); }
.nav-links .btn { margin-left: 0.4rem; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.2s ease, color 0.15s ease;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px) rotate(8deg); }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 8px;
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2); }
.btn:active { transform: translateY(0); }

.btn-sm { padding: 0.38rem 0.9rem; font-size: 0.8rem; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px var(--accent-soft);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }

.btn-ghost { background: transparent; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: clamp(4rem, 10vw, 7rem) 0 clamp(4rem, 8vw, 6rem);
  text-align: center;
  overflow: hidden;
}

.hero-glow {
  position: absolute;
  inset: -20% -10% auto;
  height: 120%;
  background:
    radial-gradient(ellipse 55% 45% at 30% 30%, var(--hero-glow), transparent 70%),
    radial-gradient(ellipse 45% 40% at 75% 60%, var(--hero-glow), transparent 70%);
  pointer-events: none;
  animation: glowDrift 14s ease-in-out infinite alternate;
}
@keyframes glowDrift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(3%, -3%, 0) scale(1.08); }
}

.hero-inner { position: relative; }

.hero-title { margin-bottom: 0.35em; }
.hero-name {
  display: inline-block;
  font-size: clamp(2.2rem, 7vw, 4.2rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-shadow: 0 0 24px var(--accent-soft);
}
.hero-name.decrypting {
  color: var(--accent);
  text-shadow: 0 0 22px var(--accent-soft);
}
.caret { color: var(--accent); animation: blink 1s steps(1) infinite; }
.hero-line-sub {
  display: block;
  font-size: clamp(1rem, 2.6vw, 1.5rem);
  font-weight: 500;
  letter-spacing: 0.06em;
  margin-top: 0.5em;
  color: var(--muted);
}

.hero .lede { margin: 0 auto 1.8rem; }

/* Terminal window */
.terminal {
  max-width: 640px;
  margin: 0 auto 1.8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  text-align: left;
}
.terminal-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.55rem 0.8rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.term-dot { width: 10px; height: 10px; border-radius: 50%; }
.t-red { background: #9a9a9f; }
.t-yellow { background: #6f6f74; }
.t-green { background: #4a4a4e; }
.terminal-title { margin-left: 0.5rem; font-size: 0.72rem; color: var(--muted); }
.terminal-body { padding: 1rem 1.1rem; font-size: 0.8rem; line-height: 1.8; }
.term-line { margin: 0; white-space: pre-wrap; }
.term-prompt { color: var(--accent); }
.term-out { color: var(--muted); }
.term-out .t-acc { color: var(--accent); }
.term-out .t-cyan { color: var(--cyan); }
.term-out .t-k { color: var(--cyan); font-weight: 600; }
.term-out .t-d { color: var(--muted); }
.term-out .t-dim { color: var(--muted); }

.hero-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }

.hero-links {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 1.4rem;
  flex-wrap: wrap;
  margin: 2rem 0 0;
  padding: 0;
  font-size: 0.82rem;
}
.hero-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}
.hero-links a:hover { color: var(--accent); }

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 1.6rem;
  transform: translateX(-50%);
  opacity: 0.55;
  transition: opacity 0.2s ease;
}
.scroll-hint:hover { opacity: 1; }
.mouse { display: block; width: 22px; height: 34px; border: 2px solid var(--muted); border-radius: 12px; position: relative; }
.wheel {
  position: absolute; top: 6px; left: 50%; width: 3px; height: 7px; margin-left: -1.5px;
  border-radius: 2px; background: var(--accent);
  animation: wheelScroll 1.8s ease-in-out infinite;
}
@keyframes wheelScroll {
  0% { transform: translateY(0); opacity: 1; }
  70% { transform: translateY(10px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}

/* ---------- Sections ---------- */
.section { padding: clamp(4rem, 9vw, 6.5rem) 0; }

.section-alt {
  position: relative;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.section-head { max-width: 640px; margin-bottom: 2.6rem; }
.section-head h2 { margin-bottom: 0; }

/* ---------- About ---------- */
.grid-about { display: grid; grid-template-columns: 1fr 1.35fr; gap: 3.5rem; align-items: start; }
.about-body p { color: var(--muted); }
.about-body p:first-child { font-size: 1rem; color: var(--ink); }
.about-body strong { color: var(--accent); }

.formula {
  margin: 1.6rem 0;
  padding: 1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--muted);
  overflow-x: auto;
}
.formula .f-op { color: var(--accent); }
.formula .f-var { color: var(--ink); }
.formula .f-sym { color: var(--cyan); font-weight: 700; }
.formula .f-fn { color: var(--cyan); }

.about-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 2.2rem; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.stat-num { display: block; font-size: 1.8rem; font-weight: 800; color: var(--accent); line-height: 1.1; }
.stat-label { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 0.3rem; }

/* ---------- Cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 1.3rem; }
.card {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem 1.5rem;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  opacity: 0; transition: opacity 0.25s ease;
}
.card:hover { transform: translateY(-6px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.card:hover::before { opacity: 1; }
.card h3 { margin-bottom: 0.35rem; }
.card p { font-size: 0.85rem; color: var(--muted); margin-bottom: 1rem; }

.card-icon {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 1rem;
  transition: transform 0.25s ease;
}
.card:hover .card-icon { transform: scale(1.08) rotate(-4deg); }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0; padding: 0; }
.tags li {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 0.2rem 0.7rem;
  transition: transform 0.15s ease;
}
.tags li:hover { transform: translateY(-1px); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: "";
  position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px;
  background: linear-gradient(to bottom, var(--accent), var(--line));
  border-radius: 2px;
}
.timeline-item { position: relative; padding: 0 0 2rem 2.2rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: "";
  position: absolute; left: 0; top: 6px; width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.timeline-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.timeline-card:hover { transform: translateX(6px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.timeline-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.15rem; }
.timeline-head h3 { margin-bottom: 0; }

.dates {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 0.18rem 0.65rem;
  white-space: nowrap;
}
.org { display: block; font-weight: 600; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.6rem; }
.timeline-card p, .school-item p { color: var(--muted); font-size: 0.86rem; margin-bottom: 0; }

/* ---------- Education ---------- */
.school-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.3rem; }
.school-item {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem 1.5rem;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.school-item:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.school-item h3 { margin-bottom: 0.2rem; }
.school-item p { margin-bottom: 0.8rem; }

/* ---------- Skills ---------- */
.skill-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.3rem; }
.skill-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.skill-block:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.skill-block h3 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 0.9rem; }

/* ---------- Contact ---------- */
.contact { padding-top: 1rem; }
.contact-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  padding: clamp(2.5rem, 6vw, 4rem);
  text-align: center;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.contact-card::before {
  content: "";
  position: absolute; top: -120px; left: 50%; transform: translateX(-50%);
  width: 420px; height: 240px;
  background: radial-gradient(ellipse, var(--hero-glow), transparent 70%);
  pointer-events: none;
}
.contact-card h2 { margin-bottom: 0.4em; }
.contact-card .lede { margin: 0 auto 1.8rem; }
.contact-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; position: relative; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 1.8rem 0; background: var(--surface); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.site-footer p { margin: 0; color: var(--muted); font-size: 0.78rem; }
.site-footer .t-acc { color: var(--accent); }
.site-footer .t-dim { color: var(--muted); }

.footer-links { display: flex; gap: 0.4rem; }
.footer-links a {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 8px; color: var(--muted); border: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.footer-links a:hover { color: var(--accent); border-color: var(--line); transform: translateY(-2px); }

.back-to-top {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 8px; border: 1px solid var(--line); color: var(--muted);
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.back-to-top:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-3px); }

/* ---------- Reveal on scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.7s cubic-bezier(0.22, 0.61, 0.36, 1), transform 0.7s cubic-bezier(0.22, 0.61, 0.36, 1);
  transition-delay: var(--reveal-delay, 0s);
}
.reveal.visible { opacity: 1; transform: none; }

[data-stagger] > .reveal:nth-child(1) { --reveal-delay: 0s; }
[data-stagger] > .reveal:nth-child(2) { --reveal-delay: 0.08s; }
[data-stagger] > .reveal:nth-child(3) { --reveal-delay: 0.16s; }
[data-stagger] > .reveal:nth-child(4) { --reveal-delay: 0.24s; }
[data-stagger] > .reveal:nth-child(5) { --reveal-delay: 0.32s; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
  .reveal { opacity: 1; transform: none; }
  #bg-canvas { display: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .grid-about { grid-template-columns: 1fr; gap: 1.2rem; }
}

@media (max-width: 760px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--line);
    padding: 0.5rem 4% 0.9rem; display: none;
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.2);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 0.7rem 0.75rem; }
  .nav-links .btn { margin: 0.4rem 0.75rem 0.2rem; justify-content: center; }

  .about-stats { grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
  .stat { padding: 0.85rem 0.5rem; }
  .stat-num { font-size: 1.5rem; }

  .contact-card { padding: 2rem 1.4rem; }
  .footer-inner { justify-content: center; text-align: center; }
}
