/* ============================================================
   Lionel Ngunjiri — Landing
   ============================================================ */

:root {
  --bg:        #060814;
  --bg-soft:   #0b0e1f;
  --ink:       #eceef6;
  --ink-dim:   #9aa0b8;
  --ink-faint: #565d78;
  --line:      rgba(255,255,255,0.08);
  --line-soft: rgba(255,255,255,0.045);

  --cyan:   #5ce0e0;
  --blue:   #5b8cff;
  --violet: #a78bfa;
  --accent: var(--cyan);

  --grad: linear-gradient(110deg, #5ce0e0 0%, #5b8cff 48%, #a78bfa 100%);

  --maxw: 1240px;
  --gut: clamp(20px, 5vw, 80px);

  --f-display: 'Space Grotesk', system-ui, sans-serif;
  --f-body: 'Inter', system-ui, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, monospace;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-weight: 300;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  cursor: none;
}
@media (hover: none) { body { cursor: auto; } }

::selection { background: var(--cyan); color: #04121a; }

a { color: inherit; text-decoration: none; }
em { font-style: italic; }

.mono {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.hl {
  color: var(--accent);
  font-weight: 500;
}

/* ---------- Canvas ---------- */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

/* ---------- Scrim (legibility over 3D) ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(6,8,20,0.92) 0%, rgba(6,8,20,0.5) 34%, rgba(6,8,20,0) 64%),
    linear-gradient(180deg, rgba(6,8,20,0.55) 0%, rgba(6,8,20,0) 22%, rgba(6,8,20,0) 70%, rgba(6,8,20,0.85) 100%);
}

@media (max-width: 768px) {
  .scrim {
    background:
      linear-gradient(180deg, rgba(6,8,20,0.88) 0%, rgba(6,8,20,0.62) 42%, rgba(6,8,20,0.25) 66%, rgba(6,8,20,0.9) 100%);
  }
}

/* ---------- Grain ---------- */
.grain {
  position: fixed;
  inset: -50%;
  z-index: 2;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 8s steps(6) infinite;
}
@keyframes grain {
  0%,100%{transform:translate(0,0)} 20%{transform:translate(-4%,3%)}
  40%{transform:translate(3%,-4%)} 60%{transform:translate(-2%,2%)} 80%{transform:translate(4%,-2%)}
}

/* ---------- Cursor ---------- */
.cursor, .cursor-dot { position: fixed; top:0; left:0; z-index: 9999; pointer-events:none; border-radius:50%; mix-blend-mode: difference; }
.cursor {
  width: 34px; height: 34px;
  border: 1px solid rgba(255,255,255,0.65);
  transform: translate(-50%,-50%);
  transition: width .3s var(--ease), height .3s var(--ease), background .3s, border-color .3s;
}
.cursor-dot { width: 5px; height: 5px; background: #fff; transform: translate(-50%,-50%); }
.cursor.is-hover { width: 64px; height: 64px; background: rgba(255,255,255,0.08); border-color: transparent; }
@media (hover: none) { .cursor, .cursor-dot { display: none; } }

/* ---------- Loader ---------- */
.loader {
  position: fixed; inset: 0; z-index: 10000;
  background: var(--bg);
  display: grid; place-items: center;
  transition: opacity .8s var(--ease), visibility .8s;
}
.loader.is-done { opacity: 0; visibility: hidden; }
.loader__inner { width: min(80vw, 420px); text-align: left; }
.loader__mono { font-family: var(--f-mono); font-size: 11px; letter-spacing: .3em; color: var(--ink-faint); }
.loader__name { font-family: var(--f-display); font-weight: 600; font-size: clamp(22px,4vw,34px); letter-spacing: .02em; margin: 10px 0 22px; }
.loader__bar { height: 2px; background: var(--line); position: relative; overflow: hidden; }
.loader__bar span { position:absolute; inset:0; width:0; background: var(--grad); }
.loader__pct { font-family: var(--f-mono); font-size: 12px; color: var(--ink-dim); margin-top: 12px; text-align: right; }

/* ---------- Scroll progress ---------- */
.scroll-progress {
  position: fixed; top: 0; left: 0; width: 2px; height: 0%;
  background: var(--grad); z-index: 9000;
}

/* ---------- Nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px var(--gut);
  transition: padding .4s var(--ease), background .4s;
}
.nav.is-scrolled { padding-top: 14px; padding-bottom: 14px; background: rgba(6,8,20,0.55); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line-soft); }
.nav__logo { display: flex; align-items: center; gap: 12px; }
.nav__mark {
  font-family: var(--f-display); font-weight: 700; font-size: 15px;
  letter-spacing: -0.02em; border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 8px; line-height: 1;
}
.nav__sig { font-family: var(--f-display); font-weight: 500; font-size: 15px; letter-spacing: .01em; }
.nav__links { display: flex; align-items: center; gap: clamp(16px, 3vw, 38px); }
.nav__links a { font-size: 14px; color: var(--ink-dim); transition: color .3s; position: relative; }
.nav__links a:not(.nav__cta)::after {
  content:''; position:absolute; left:0; bottom:-4px; height:1px; width:0; background: var(--accent); transition: width .35s var(--ease);
}
.nav__links a:hover { color: var(--ink); }
.nav__links a:not(.nav__cta):hover::after { width: 100%; }
.nav__cta { border: 1px solid var(--line); border-radius: 100px; padding: 8px 16px; color: var(--ink) !important; transition: border-color .3s, background .3s; }
.nav__cta:hover { border-color: var(--accent); background: rgba(92,224,224,0.08); }
@media (max-width: 680px){ .nav__sig{ display:none; } .nav__links a:not(.nav__cta):not([href="#work"]){ display:none; } }

/* ---------- Layout ---------- */
section { position: relative; z-index: 3; padding: clamp(80px,12vh,160px) var(--gut); max-width: var(--maxw); margin: 0 auto; }
.section-index { margin-bottom: 48px; display: inline-block; padding-bottom: 8px; border-bottom: 1px solid var(--line); }

/* ---------- Hero ---------- */
.hero {
  min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
  padding-top: 120px; padding-bottom: 80px;
}
.hero__meta { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 28px; }
.hero__meta .mono { position: relative; padding-left: 16px; }
.hero__meta .mono::before { content:''; position:absolute; left:0; top:50%; width:6px; height:6px; border-radius:50%; background: var(--accent); transform: translateY(-50%); box-shadow: 0 0 10px var(--accent); }

.hero__title {
  font-family: var(--f-display); font-weight: 600;
  font-size: clamp(56px, 13vw, 188px); line-height: 0.92;
  letter-spacing: -0.04em; margin-bottom: 36px;
}
.hero__title .line { display: block; overflow: hidden; }
.hero__title .reveal { display: block; transform: translateY(110%); }
.hero__title .line:nth-child(2) .reveal {
  color: var(--accent);
}

.hero__lede {
  max-width: 620px; font-size: clamp(17px, 2.1vw, 22px); line-height: 1.55;
  color: var(--ink-dim); font-weight: 300;
}
.hero__lede strong { color: var(--ink); font-weight: 500; }
.hero__lede em { color: var(--ink); }

.hero__actions { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 44px; }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--f-display); font-size: 15px; font-weight: 500;
  padding: 15px 26px; border-radius: 100px; transition: transform .35s var(--ease), background .35s, color .35s, border-color .35s;
}
.btn--primary { background: var(--ink); color: var(--bg); }
.btn--primary svg { transition: transform .35s var(--ease); }
.btn--primary:hover { transform: translateY(-2px); }
.btn--primary:hover svg { transform: translateX(4px); }
.btn--ghost { border: 1px solid var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: var(--accent); background: rgba(92,224,224,0.06); transform: translateY(-2px); }

.hero__scroll { position: absolute; bottom: 40px; left: var(--gut); display: flex; align-items: center; gap: 14px; }
.hero__scroll-line { width: 50px; height: 1px; background: var(--line); position: relative; overflow: hidden; }
.hero__scroll-line::after { content:''; position:absolute; inset:0; width:50%; background: var(--accent); animation: scrollLine 2.2s var(--ease) infinite; }
@keyframes scrollLine { 0%{transform:translateX(-100%)} 100%{transform:translateX(200%)} }
.hero__coords { position: absolute; bottom: 40px; right: var(--gut); color: var(--ink-faint); }
@media (max-width: 680px){ .hero__coords{ display:none; } }

/* ---------- Strip ---------- */
.strip { max-width: none; padding: 24px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); overflow: hidden; background: rgba(6,8,20,0.4); }
.strip__track { display: flex; align-items: center; gap: 40px; white-space: nowrap; width: max-content; will-change: transform; }
.strip__track span { font-family: var(--f-display); font-size: clamp(22px,3vw,38px); font-weight: 500; color: var(--ink-faint); letter-spacing: -0.01em; }
.strip__dot { color: var(--accent) !important; font-size: 16px !important; }

/* ---------- About ---------- */
.about__grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: clamp(32px, 6vw, 90px); align-items: start; }
.about__statement { font-family: var(--f-display); font-weight: 500; font-size: clamp(30px, 4.6vw, 62px); line-height: 1.04; letter-spacing: -0.03em; }
.about__statement em { color: var(--accent); }
.reveal-line { display: block; }
.about__body p { color: var(--ink-dim); font-size: clamp(15px,1.5vw,17px); margin-bottom: 22px; }
.about__chips { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }
.about__chips li { font-family: var(--f-mono); font-size: 12px; color: var(--ink-dim); border: 1px solid var(--line); border-radius: 100px; padding: 7px 14px; transition: border-color .3s, color .3s; }
.about__chips li:hover { border-color: var(--accent); color: var(--ink); }
@media (max-width: 820px){ .about__grid{ grid-template-columns: 1fr; } }

/* ---------- Impact ---------- */
.impact__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.metric { background: var(--bg); padding: clamp(28px,3.4vw,46px); display: flex; flex-direction: column; gap: 14px; transition: background .4s; }
.metric:hover { background: var(--bg-soft); }
.metric__num { font-family: var(--f-display); font-weight: 600; font-size: clamp(40px, 6vw, 78px); line-height: 1; letter-spacing: -0.04em; }
.metric__num .prefix, .metric__num .suffix { font-size: 0.42em; color: var(--accent); font-weight: 500; vertical-align: baseline; }
.metric__num .prefix { font-size: 0.34em; }
.metric__label { color: var(--ink-dim); font-size: 14.5px; line-height: 1.5; max-width: 30ch; }
@media (max-width: 820px){ .impact__grid{ grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px){ .impact__grid{ grid-template-columns: 1fr; } }

/* ---------- Work / Timeline ---------- */
.work__head { font-family: var(--f-display); font-weight: 500; font-size: clamp(28px,4.4vw,58px); line-height: 1.05; letter-spacing: -0.03em; margin-bottom: 60px; }
.timeline { border-top: 1px solid var(--line); }
.entry {
  display: grid; grid-template-columns: 180px 1fr; gap: clamp(20px,4vw,60px);
  padding: clamp(28px,4vw,46px) 0; border-bottom: 1px solid var(--line);
  position: relative; transition: padding-left .45s var(--ease);
}
.entry::before { content:''; position:absolute; left:-2vw; top:0; height:100%; width:0; background: var(--grad); opacity:0; transition: opacity .4s; }
.entry:hover { padding-left: 18px; }
.entry:hover::before { opacity: 0.85; width: 2px; }
.entry__year { color: var(--ink-faint); padding-top: 6px; }
.entry__role { font-family: var(--f-display); font-weight: 500; font-size: clamp(20px,2.6vw,30px); letter-spacing: -0.02em; line-height: 1.2; }
.entry__co { color: var(--accent); font-size: 14px; font-family: var(--f-mono); margin: 8px 0 16px; }
.entry__co span { color: var(--ink-faint); }
.entry__desc { color: var(--ink-dim); font-size: clamp(15px,1.6vw,17px); max-width: 66ch; }
.entry__desc strong { color: var(--ink); font-weight: 500; }
.entry__tags { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.entry__tags li { font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; color: var(--ink-faint); border: 1px solid var(--line); border-radius: 4px; padding: 4px 9px; text-transform: uppercase; }
.entry--muted .entry__role { color: var(--ink-dim); }
@media (max-width: 680px){ .entry{ grid-template-columns: 1fr; gap: 12px; } .entry__year{ padding-top:0; } }

/* ---------- Ventures ---------- */
.ventures__grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.venture {
  border: 1px solid var(--line); border-radius: 16px; padding: clamp(26px,3.2vw,40px);
  background: rgba(11,14,31,0.4); position: relative; overflow: hidden;
  transition: transform .45s var(--ease), border-color .45s, background .45s;
}
.venture--lg { grid-row: span 2; display: flex; flex-direction: column; justify-content: space-between; min-height: 320px; }
.venture:hover { transform: translateY(-4px); border-color: rgba(92,224,224,0.4); background: rgba(11,14,31,0.7); }
.venture__tag { display: inline-block; margin-bottom: 18px; color: var(--accent); }
.venture h3 { font-family: var(--f-display); font-weight: 600; font-size: clamp(22px,2.6vw,34px); letter-spacing: -0.02em; margin-bottom: 14px; }
.venture--lg h3 { font-size: clamp(30px,4vw,52px); }
.venture p { color: var(--ink-dim); font-size: 15px; line-height: 1.55; }
.venture__line { height: 1px; background: var(--grad); margin-top: 30px; opacity: .5; }
@media (max-width: 760px){ .ventures__grid{ grid-template-columns: 1fr; } .venture--lg{ grid-row: auto; min-height: auto; } }

/* ---------- Contact ---------- */
.contact { text-align: left; }
.contact__head { font-family: var(--f-display); font-weight: 500; font-size: clamp(34px,7vw,96px); line-height: 1.02; letter-spacing: -0.04em; margin-bottom: 50px; }
.contact__head em { color: var(--accent); }
.contact__email {
  display: inline-block; font-family: var(--f-display); font-weight: 500;
  font-size: clamp(20px,3.4vw,42px); letter-spacing: -0.02em; position: relative; padding-bottom: 8px;
}
.contact__email::after { content:''; position:absolute; left:0; bottom:0; height:2px; width:100%; background: var(--grad); transform: scaleX(0); transform-origin: left; transition: transform .5s var(--ease); }
.contact__email:hover::after { transform: scaleX(1); }
.contact__links { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 50px; }
.contact__links a { font-family: var(--f-mono); font-size: 13px; letter-spacing: .05em; color: var(--ink-dim); transition: color .3s; }
.contact__links a:hover { color: var(--accent); }

/* ---------- Footer ---------- */
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 14px; padding: 40px var(--gut); max-width: var(--maxw); margin: 0 auto; border-top: 1px solid var(--line-soft); position: relative; z-index: 3; }
.footer .mono { color: var(--ink-faint); font-size: 10px; }

/* ---------- Reveal defaults (JS-driven) ---------- */
.reveal-fade, .reveal-line { will-change: transform, opacity; }

/* ---------- Digital card / QR ---------- */
.card__wrap { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: clamp(18px, 3vw, 38px); align-items: stretch; }
@media (max-width: 820px) { .card__wrap { grid-template-columns: 1fr; } }

.vcard {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 26px;
  min-height: 340px;
  border: 1px solid var(--line); border-radius: 20px;
  padding: clamp(28px, 3.4vw, 44px);
  background:
    radial-gradient(130% 130% at 0% 0%, rgba(92,224,224,0.12), transparent 52%),
    radial-gradient(130% 130% at 100% 100%, rgba(167,139,250,0.12), transparent 52%),
    var(--bg-soft);
  transition: transform .5s var(--ease), border-color .5s;
}
.vcard::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--grad); }
.vcard:hover { transform: translateY(-4px); border-color: rgba(92,224,224,0.4); }

.vcard__top { display: flex; align-items: center; gap: 16px; }
.vcard__mark {
  font-family: var(--f-display); font-weight: 700; font-size: 20px; letter-spacing: -.02em;
  width: 54px; height: 54px; flex: 0 0 auto; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 12px; color: var(--ink);
  background: rgba(127,131,160,0.07);
}
.vcard__name { display: block; font-family: var(--f-display); font-weight: 600; font-size: clamp(22px, 2.6vw, 30px); letter-spacing: -.02em; }
.vcard__title { display: block; font-family: var(--f-mono); font-size: 11.5px; letter-spacing: .12em; color: var(--accent); margin-top: 5px; text-transform: uppercase; }

.vcard__rows { list-style: none; display: flex; flex-direction: column; gap: 15px; }
.vcard__row { display: flex; align-items: center; gap: 13px; color: var(--ink-dim); font-size: 14.5px; word-break: break-word; }
.vcard__row svg { color: var(--accent); flex: 0 0 auto; }
.vcard__row a { transition: color .3s; }
.vcard__row a:hover { color: var(--ink); }

.vcard__foot { color: var(--ink-faint); letter-spacing: .25em; }

.card__qr {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; text-align: center;
  border: 1px solid var(--line); border-radius: 20px; padding: clamp(26px, 3vw, 40px);
  background: var(--bg-soft);
}
.qr-frame {
  background: #fff; border-radius: 16px; padding: 14px; line-height: 0;
  box-shadow: 0 14px 50px rgba(4,6,16,0.35);
}
.qr-frame svg { width: clamp(150px, 42vw, 196px); height: auto; display: block; }
.card__qr p { font-family: var(--f-mono); font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); margin: 0; }
.card__save { cursor: none; }
@media (hover: none) { .card__save { cursor: pointer; } }

/* ============================================================
   Theme — light mode, toggle, transition
   ============================================================ */
:root { color-scheme: dark; }

:root[data-theme="light"] {
  color-scheme: light;
  --bg:        #f4f5fa;
  --bg-soft:   #ffffff;
  --ink:       #0c1020;
  --ink-dim:   #545b73;
  --ink-faint: #9197ad;
  --line:      rgba(12,16,32,0.12);
  --line-soft: rgba(12,16,32,0.06);

  --cyan:   #0c8f99;
  --blue:   #2f4fd0;
  --violet: #6a3fd6;
  --accent: var(--cyan);

  --grad: linear-gradient(110deg, #0c8f99 0%, #2f4fd0 48%, #6a3fd6 100%);
}

/* fallback cross-theme fade when View Transitions are unsupported */
body { transition: background-color .55s var(--ease), color .55s var(--ease); }

/* hand-coded dark surfaces -> light equivalents */
[data-theme="light"] .scrim {
  background:
    linear-gradient(90deg, rgba(244,245,250,0.92) 0%, rgba(244,245,250,0.5) 34%, rgba(244,245,250,0) 64%),
    linear-gradient(180deg, rgba(244,245,250,0.55) 0%, rgba(244,245,250,0) 22%, rgba(244,245,250,0) 70%, rgba(244,245,250,0.88) 100%);
}
@media (max-width: 768px) {
  [data-theme="light"] .scrim {
    background: linear-gradient(180deg, rgba(244,245,250,0.9) 0%, rgba(244,245,250,0.66) 42%, rgba(244,245,250,0.3) 66%, rgba(244,245,250,0.92) 100%);
  }
}
[data-theme="light"] .nav.is-scrolled { background: rgba(244,245,250,0.62); }
[data-theme="light"] .strip { background: rgba(244,245,250,0.5); }
[data-theme="light"] .venture { background: rgba(255,255,255,0.55); }
[data-theme="light"] .venture:hover { background: rgba(255,255,255,0.92); border-color: rgba(12,143,153,0.5); }
[data-theme="light"] .nav__cta:hover { background: rgba(12,143,153,0.08); }
[data-theme="light"] .btn--ghost:hover { background: rgba(12,143,153,0.07); }
[data-theme="light"] .grain { opacity: 0.05; mix-blend-mode: multiply; }
[data-theme="light"] ::selection { color: #ffffff; }

/* ---------- Theme toggle button ---------- */
.theme-toggle {
  position: relative; width: 38px; height: 38px; flex: 0 0 auto;
  border: 1px solid var(--line); border-radius: 50%; background: transparent;
  color: var(--ink); display: grid; place-items: center;
  cursor: none; overflow: hidden;
  transition: border-color .3s, background .3s;
}
@media (hover: none) { .theme-toggle { cursor: pointer; } }
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg {
  position: absolute; width: 17px; height: 17px;
  stroke: currentColor; fill: none;
  transition: transform .55s var(--ease), opacity .45s var(--ease);
}
.theme-toggle .icon-sun  { opacity: 0; transform: rotate(-90deg) scale(.3); }
.theme-toggle .icon-moon { opacity: 1; transform: rotate(0deg) scale(1); }
[data-theme="light"] .theme-toggle .icon-sun  { opacity: 1; transform: rotate(0deg) scale(1); }
[data-theme="light"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(90deg) scale(.3); }

/* ---------- View Transition: circular theme reveal ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root) { z-index: 0; }
::view-transition-new(root) { z-index: 1; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(root), ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
}
