/* ============================================================================
   Theme tokens — change these to retheme the whole site.
============================================================================ */
:root, [data-theme="dark"] {
  --bg:        #06060f;
  --bg-2:      #0a0b15;
  --bg-rgb:    6, 6, 15;
  --text:      #eef0f7;
  --muted:     rgba(238, 240, 247, 0.58);
  --faint:     rgba(238, 240, 247, 0.38);
  --accent:    #7c5cff;   /* purple */
  --accent-2:  #22d3ee;   /* cyan   */
  --panel:     rgba(255, 255, 255, 0.045);
  --panel-brd: rgba(124, 92, 255, 0.20);
  --panel-brd-2: rgba(124, 92, 255, 0.34);
  --radius:    14px;
  --particle-a: #22d3ee;
  --particle-b: #7c5cff;
  --particle-blend: add;
  --maxw:      980px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ---- Light ---- */
[data-theme="light"] {
  --bg: #f6f7fb; --bg-2: #eceef5; --bg-rgb: 246, 247, 251;
  --text: #15161d; --muted: rgba(21,22,29,0.62); --faint: rgba(21,22,29,0.42);
  --accent: #6a4ef0; --accent-2: #0d9aab;
  --panel: rgba(20, 20, 50, 0.035);
  --panel-brd: rgba(60, 40, 160, 0.18); --panel-brd-2: rgba(60, 40, 160, 0.32);
  --particle-a: #6a4ef0; --particle-b: #0d9aab; --particle-blend: normal;
}

/* ---- Ticker — live market chart (finance) ---- */
[data-theme="ticker"] {
  --bg: #060a08; --bg-2: #0c130f; --bg-rgb: 6, 10, 8;
  --text: #f3ecd8; --muted: rgba(243,236,216,0.62); --faint: rgba(243,236,216,0.42);
  --accent: #f0a92e; --accent-2: #35d07a;
  --panel: rgba(240, 169, 46, 0.06);
  --panel-brd: rgba(240, 169, 46, 0.26); --panel-brd-2: rgba(53, 208, 122, 0.45);
  --radius: 6px;
  --font: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .45s ease, color .45s ease;
}

a { color: inherit; text-decoration: none; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* page fade-in */
body.loading .hero-inner { opacity: 0; transform: translateY(10px); }
.hero-inner { transition: opacity .8s ease, transform .8s ease; }

/* ============================================================================
   Top bar
============================================================================ */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px clamp(18px, 5vw, 40px);
  background: linear-gradient(to bottom, rgba(var(--bg-rgb),0.85), rgba(var(--bg-rgb),0));
  backdrop-filter: blur(6px);
}
.brand { font-weight: 600; font-size: 15px; letter-spacing: .01em; }
.topnav { display: flex; gap: 22px; font-size: 14px; }
.topnav a { color: var(--muted); transition: color .2s; }
.topnav a:hover { color: var(--text); }
@media (max-width: 560px) {
  .topbar { padding: 14px 16px; gap: 12px; }
  .brand { font-size: 13px; flex: 0 0 auto; }
  .topnav { gap: 14px; font-size: 12px; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav { scrollbar-width: none; }
  .topnav a { flex: 0 0 auto; }
}
@media (max-width: 380px) {
  .brand { font-size: 12px; }
  .topnav { gap: 12px; font-size: 11px; }
}

/* ============================================================================
   Hero
============================================================================ */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 90px 20px 40px;
  overflow: hidden;
}
.hero-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; z-index: 0;
}
/* static fallback shown when motion is off / no WebGL */
.hero-fallback {
  position: absolute; inset: 0; z-index: 0; display: none;
  background:
    radial-gradient(60% 50% at 50% 38%, rgba(124,92,255,0.28), transparent 70%),
    radial-gradient(50% 40% at 65% 60%, rgba(34,211,238,0.18), transparent 70%);
}
body.no-motion .hero-canvas { display: none; }
body.no-motion .hero-fallback { display: block; }

/* particles run only for dark + light; every other theme uses the 2D scene canvas */
#hero-canvas-2d { display: none; }
html:not([data-theme="dark"]):not([data-theme="light"]) #hero-canvas { display: none; }
html:not([data-theme="dark"]):not([data-theme="light"]) #hero-canvas-2d { display: block; }
html:not([data-theme="dark"]):not([data-theme="light"]) .hero-hint { display: none; }
body.no-motion #hero-canvas, body.no-motion #hero-canvas-2d { display: none !important; }

.hero-inner { position: relative; z-index: 2; max-width: 640px; }
/* circular hero photo — the gradient ring recolours with each theme */
.hero-avatar {
  width: clamp(96px, 15vw, 128px); aspect-ratio: 1; margin: 0 auto 22px; padding: 3px;
  border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}
.hero-avatar img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: center 28%;
  display: block; border: 3px solid var(--bg);
}
/* soft scrim so the text stays legible over the particle field */
.hero-inner::before {
  content: ""; position: absolute; z-index: -1; inset: -70px -60px; pointer-events: none;
  background: radial-gradient(70% 62% at 50% 50%,
    rgba(var(--bg-rgb),0.88) 0%, rgba(var(--bg-rgb),0.6) 52%, transparent 82%);
}
.eyebrow {
  font-size: 12px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--accent-2); margin: 0 0 14px;
}
.hero-name {
  font-size: clamp(40px, 9vw, 78px); line-height: 1.02; margin: 0;
  font-weight: 600; letter-spacing: -0.02em;
}
.hero-tagline { font-size: clamp(16px, 2.4vw, 21px); margin: 16px 0 0; color: var(--text); }
.hero-bio { font-size: clamp(14px, 1.8vw, 16px); color: var(--muted); margin: 16px auto 0; max-width: 600px; }
.hl { color: var(--accent-2); font-weight: 500; }

.socials { list-style: none; display: flex; gap: 12px; justify-content: center; padding: 0; margin: 26px 0 0; }
.socials a {
  width: 42px; height: 42px; display: grid; place-items: center;
  border: 1px solid var(--panel-brd); border-radius: 50%;
  color: var(--text); background: var(--panel);
  transition: transform .2s, border-color .2s, color .2s;
}
.socials a:hover { transform: translateY(-3px); border-color: var(--panel-brd-2); color: #fff; }
.socials svg { width: 18px; height: 18px; }

.scroll-cue {
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 2;
  width: 26px; height: 42px; border: 1.5px solid var(--faint); border-radius: 20px;
  display: grid; place-items: start center; padding-top: 8px;
}
.scroll-cue span { width: 4px; height: 8px; border-radius: 4px; background: var(--accent-2); animation: cue 1.6s infinite; }
@keyframes cue { 0%{opacity:0;transform:translateY(0)} 40%{opacity:1} 80%{opacity:0;transform:translateY(12px)} 100%{opacity:0} }
@media (prefers-reduced-motion: reduce) { .scroll-cue span { animation: none; } }

/* ============================================================================
   Sections
============================================================================ */
.section {
  max-width: var(--maxw); margin: 0 auto;
  padding: clamp(56px, 11vw, 110px) clamp(18px, 5vw, 40px);
}
.section-head { margin-bottom: 28px; }
.section-head h2 { font-size: clamp(24px, 4vw, 34px); margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.section-sub { color: var(--muted); margin: 8px 0 0; font-size: 15px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-brd);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}

/* reveal on scroll */
[data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
[data-reveal].in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { [data-reveal] { opacity: 1; transform: none; transition: none; } }

/* featured */
.featured { padding: clamp(20px, 4vw, 32px); margin-bottom: 16px; }
.featured .tag-row { margin-bottom: 14px; }
.featured h3 { font-size: clamp(22px, 3.4vw, 30px); margin: 0 0 10px; font-weight: 600; }
.featured p { color: var(--muted); margin: 0 0 18px; max-width: 56ch; }
.featured .pill-label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-2); }

/* project list */
.project-list { display: grid; gap: 12px; }
.project {
  display: flex; align-items: center; gap: 18px;
  padding: 18px 20px; border-radius: var(--radius);
  border: 1px solid transparent; border-bottom: 1px solid var(--panel-brd);
  transition: background .2s, border-color .2s, transform .2s;
}
.project:hover { background: var(--panel); border-color: var(--panel-brd-2); transform: translateX(4px); }
.project--static { cursor: default; }
.project--static:hover { transform: none; }
.project .p-main { flex: 1; min-width: 0; }
.project .p-name { font-size: 17px; font-weight: 600; }
.project .p-blurb { color: var(--muted); font-size: 14px; margin-top: 2px; }
.project .p-arrow { color: var(--faint); flex-shrink: 0; transition: color .2s, transform .2s; }
.project:hover .p-arrow { color: var(--accent-2); transform: translate(2px,-2px); }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-family: var(--mono); font-size: 11px; color: var(--accent-2);
  border: 1px solid var(--panel-brd); border-radius: 999px; padding: 3px 10px;
}

/* writing */
.posts { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.post {
  display: flex; align-items: baseline; justify-content: space-between; gap: 18px;
  padding: 16px 4px; border-top: 1px solid var(--panel-brd);
  transition: padding .2s;
}
.posts .post:last-child { border-bottom: 1px solid var(--panel-brd); }
.post:hover { padding-left: 12px; }
.post .post-title { font-size: 16px; }
.post:hover .post-title { color: #fff; }
.post .post-date { color: var(--faint); font-size: 13px; white-space: nowrap; font-family: var(--mono); }
.post--skeleton span { display: block; height: 14px; width: 60%; border-radius: 4px; background: var(--panel); }

/* subscribe */
.subscribe-panel { padding: clamp(22px, 5vw, 40px); text-align: center; }
.subscribe-panel h3 { font-size: clamp(20px, 3vw, 26px); margin: 0 0 8px; font-weight: 600; }
.subscribe-panel p { color: var(--muted); margin: 0 auto 20px; max-width: 44ch; }
.sub-form { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.sub-form input {
  flex: 1; min-width: 220px; max-width: 320px;
  background: rgba(0,0,0,0.25); border: 1px solid var(--panel-brd); color: var(--text);
  border-radius: 10px; padding: 12px 14px; font-size: 15px; font-family: inherit;
}
.sub-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,92,255,0.25); }
.btn {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #07070f; font-weight: 600; font-size: 15px;
  border: none; border-radius: 10px; padding: 12px 22px; cursor: pointer;
  transition: transform .15s, filter .15s;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn:active { transform: translateY(0); }
.sub-embed { width: 100%; border: none; border-radius: 10px; min-height: 90px; background: transparent; }
.sub-note { margin: 14px 0 0; font-size: 12px; color: var(--faint); font-family: var(--mono); }

/* footer — present on every page, social links live here */
.footer {
  max-width: var(--maxw); margin: 0 auto;
  padding: 36px clamp(18px, 5vw, 40px) 48px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  color: var(--faint); font-size: 13px; border-top: 1px solid var(--panel-brd);
}
.footer .socials { margin: 0; }
.footer-meta { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; justify-content: center; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--text); }

/* homepage: hero + footer share one screen so the social icons are visible */
body.home { display: flex; flex-direction: column; min-height: 100svh; }
body.home #main { flex: 1 1 auto; display: flex; min-height: 0; }
body.home .hero { min-height: 0; flex: 1; padding-top: 66px; padding-bottom: 6px; }
body.home .footer { padding-top: 14px; padding-bottom: 20px; border-top: none; }
body.home .hero-hint { display: none; }
/* compact the hero so it fits above the footer */
body.home .hero-avatar { width: clamp(76px, 12vw, 104px); margin-bottom: 14px; }
body.home .hero-name { font-size: clamp(34px, 7vw, 60px); }
body.home .eyebrow { margin-bottom: 10px; }
body.home .hero-tagline { margin-top: 10px; }
body.home .hero-bio { margin-top: 10px; }
body.home .hero-links { margin-top: 18px; }

@media (max-width: 560px) {
  .project { flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px 14px; }
  .project .p-main { width: 100%; }
  .project .tag-row { width: 100%; }
  .project .p-arrow { align-self: flex-end; margin-top: -4px; }
  .post { flex-direction: column; gap: 2px; }
  .post .post-date { font-size: 12px; }
}

/* ============================================================================
   Multi-page additions
============================================================================ */
/* active nav item */
.topnav a[aria-current="page"] { color: var(--text); }
.topnav a[aria-current="page"]::after {
  content: ""; display: block; height: 1.5px; margin-top: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* home hero CTA links */
.hero-links { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; margin-top: 30px; }
.hero-links a {
  font-size: 15px; color: var(--text);
  border: 1px solid var(--panel-brd); border-radius: 999px; padding: 9px 20px;
  background: var(--panel); transition: transform .2s, border-color .2s, background .2s;
}
.hero-links a:hover { transform: translateY(-3px); border-color: var(--panel-brd-2); }
.hero-links a span { color: var(--accent-2); }

.hero-hint {
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 2;
  font-size: 12px; color: var(--faint); letter-spacing: .04em;
}

/* inner page wrapper (clears the fixed top bar) */
.page {
  max-width: var(--maxw); margin: 0 auto;
  padding: clamp(110px, 16vw, 150px) clamp(18px, 5vw, 40px) 40px;
  min-height: 70vh;
}
.page-head { margin-bottom: 36px; }
.page-title {
  font-size: clamp(34px, 7vw, 60px); margin: 0; font-weight: 600; letter-spacing: -0.02em;
}
.page-sub { color: var(--muted); margin: 12px 0 0; font-size: clamp(15px, 2vw, 18px); }

/* résumé / about */
.resume-summary { font-size: 17px; color: var(--text); margin: 0 0 8px; }
.resume-h {
  font-size: 14px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-2);
  margin: 40px 0 18px; font-weight: 500;
}
.resume .tag-row { gap: 8px; }
.resume .tag { font-size: 13px; padding: 5px 14px; }
.timeline { display: grid; gap: 4px; }
.exp-item {
  padding: 18px 20px; border-radius: var(--radius);
  border-bottom: 1px solid var(--panel-brd); transition: background .2s, border-color .2s;
}
.exp-item:hover { background: var(--panel); }
.exp-top { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.exp-role { font-size: 17px; font-weight: 600; }
.exp-period { font-size: 13px; color: var(--faint); font-family: var(--mono); white-space: nowrap; }
.exp-org { font-size: 14px; color: var(--accent-2); margin-top: 2px; }
.exp-detail { font-size: 14px; color: var(--muted); margin: 8px 0 0; }
.skill-group { font-size: 13px; color: var(--text); margin: 16px 0 8px; font-weight: 500; }
.skill-group:first-of-type { margin-top: 0; }
.resume-dl { display: inline-block; margin-top: 20px; }

/* generic uppercase accent label (used on featured + reading) */
.pill-label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-2); }

/* Now */
.now-updated { color: var(--faint); font-size: 13px; margin: 0 0 20px; font-family: var(--mono); }
.now-list { list-style: none; padding: 0; margin: 0; }
.now-list li {
  position: relative; padding: 16px 4px 16px 24px; font-size: 16px;
  border-top: 1px solid var(--panel-brd);
}
.now-list li:last-child { border-bottom: 1px solid var(--panel-brd); }
.now-list li::before {
  content: ""; position: absolute; left: 2px; top: 22px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent-2);
}

/* Uses */
.uses-group { margin-bottom: 8px; }
.uses-list {
  list-style: none; padding: 0; margin: 0 0 8px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 24px;
}
.uses-list li { padding: 10px 0; border-bottom: 1px solid var(--panel-brd); font-size: 15px; }

/* Reading */
.reading-current { margin-bottom: 26px; }
.reading-cur-title { font-size: 18px; font-weight: 500; margin-top: 6px; }
.book-list { display: grid; gap: 2px; }
.book {
  display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
  padding: 14px 4px; border-top: 1px solid var(--panel-brd);
}
.book-list .book:last-child { border-bottom: 1px solid var(--panel-brd); }
.book-title { font-size: 16px; }
.book-author { color: var(--muted); font-size: 14px; white-space: nowrap; }

/* TIL */
.til-item { display: flex; gap: 16px; padding: 16px 4px; border-top: 1px solid var(--panel-brd); }
section[data-til] .til-item:last-child { border-bottom: 1px solid var(--panel-brd); }
.til-date { font-family: var(--mono); font-size: 12.5px; color: var(--faint); min-width: 92px; padding-top: 2px; }
.til-text { flex: 1; min-width: 0; font-size: 15.5px; }
.til-text .tag { margin-left: 6px; vertical-align: 1px; }

/* Bookmarks */
.bm-item { padding: 14px 4px; border-top: 1px solid var(--panel-brd); }
.bm-title { font-size: 16px; color: var(--text); }
.bm-title:hover { color: var(--accent-2); }
.bm-note { color: var(--muted); font-size: 13.5px; margin-top: 3px; }

/* Favorites (this-or-that) */
.fav-row {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 15px 4px; border-top: 1px solid var(--panel-brd); font-size: 16px;
}
section[data-favorites] .fav-row:last-child { border-bottom: 1px solid var(--panel-brd); }
.fav-opt { color: var(--muted); }
.fav-opt:first-child { text-align: right; }
.fav-opt:last-child { text-align: left; }
.fav-pick { color: var(--accent-2); font-weight: 500; }
.fav-or { font-family: var(--mono); font-size: 12px; color: var(--faint); }

/* Map */
#map {
  width: 100%; height: 460px; border-radius: var(--radius);
  border: 1px solid var(--panel-brd); overflow: hidden; background: var(--bg-2);
}
.leaflet-popup-content { font-family: var(--font); }

/* Playbook */
.play-item { display: flex; gap: 18px; padding: 22px 4px; border-top: 1px solid var(--panel-brd); }
.playbook .play-item:last-child { border-bottom: 1px solid var(--panel-brd); }
.play-num { font-family: var(--mono); font-size: 13px; color: var(--accent-2); min-width: 28px; padding-top: 2px; }
.play-main { flex: 1; min-width: 0; }
.play-title { font-size: 17px; font-weight: 500; }
.play-text { color: var(--muted); font-size: 14px; margin: 5px 0 0; max-width: 64ch; }

/* ============================================================================
   Theme switcher (floating, bottom-right)
============================================================================ */
.theme-switch {
  position: fixed; right: 20px; bottom: 20px; z-index: 50;
  display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 10px;
}
.theme-toggle {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--panel-brd-2); background: var(--bg-2); color: var(--text);
  display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  transition: transform .2s, border-color .2s;
}
.theme-toggle:hover { transform: translateY(-2px); border-color: var(--accent); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-menu {
  display: flex; flex-direction: column; gap: 4px; padding: 8px;
  border-radius: 14px; border: 1px solid var(--panel-brd); background: var(--bg-2);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  opacity: 0; transform: translateY(8px) scale(.96); transform-origin: bottom right;
  pointer-events: none; transition: opacity .18s ease, transform .18s ease;
}
.theme-switch[data-open="true"] .theme-menu { opacity: 1; transform: none; pointer-events: auto; }
.theme-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px 9px 11px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--text);
  font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; text-align: left;
  transition: background .15s, border-color .15s;
}
.theme-opt:hover { background: var(--panel); }
.theme-opt svg { width: 18px; height: 18px; color: var(--accent-2); flex-shrink: 0; }
.theme-opt[aria-checked="true"] { border-color: var(--accent); background: var(--panel); }
.theme-opt .opt-check { margin-left: 12px; opacity: 0; color: var(--accent); }
.theme-opt[aria-checked="true"] .opt-check { opacity: 1; }
@media (max-width: 560px) { .theme-switch { right: 14px; bottom: 14px; } }
