/* Organic design system tokens, applied to Vishnu's site. */
:root {
  --ink: #201e1d;
  --cream: #f5ead8;
  --paper: #f9f4ed;
  --peach: #ffc6a5;
  --peach-deep: #f6a06b;
  --accent: #c67139;
  --accent-700: #8c491a;
  --sage: #ccdbb2;
  --olive: #7a8a5e;
  --olive-700: #56633f;

  --ink-80: rgba(32, 30, 29, .8);
  --ink-50: rgba(32, 30, 29, .5);
  --ink-18: rgba(32, 30, 29, .18);
  --ink-14: rgba(32, 30, 29, .14);

  --font-heading: "Caprasimo", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, sans-serif;
  --font-mono: ui-monospace, Menlo, monospace;

  --ease: cubic-bezier(.22, 1, .36, 1);
  --rail-w: 236px;
  --gutter: 70px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-heading); font-weight: 400; letter-spacing: -.015em; margin: 0; }
p { margin: 0; }
a { color: var(--accent-700); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
button { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: rgba(198, 113, 57, .3); }

.layout { display: flex; align-items: stretch; min-height: 100vh; }

/* ── dots ───────────────────────────────────────────── */
.dot {
  width: 26px; height: 26px; flex: none; border-radius: 999px;
  border: 2px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
  font: 600 10px var(--font-mono);
}
.dot-peach { background: var(--peach); }
.dot-sage { background: var(--sage); }
.dot-paper { background: var(--paper); }
.dot-ink { background: var(--ink); color: var(--paper); border: 0; }
.dot-accent { background: var(--accent); color: var(--paper); border: 0; }
/* Icon dots keep the 26px slot so the rail stays aligned, minus the circle. */
/* 24px = the icons' own viewBox, so edges land on whole pixels and stay crisp. */
.dot-brand, .dot-icon { background: transparent; border: 0; color: currentColor; }
.dot-brand svg, .dot-icon svg { width: 24px; height: 24px; display: block; }
.dot-brand { color: var(--ink); }
.nav-item:hover .dot-brand, .menu-item:hover .dot-brand { color: var(--accent-700); }

.sound-dot { background: transparent; border: 0; color: rgba(32, 30, 29, .55); transition: color .2s; }
.sound-dot svg { width: 23px; height: 23px; }
.sound-dot .sound-wave { opacity: 0; transition: opacity .2s; }
.sound-dot .sound-x { opacity: 1; transition: opacity .2s; }
.sound-on .sound-dot { color: var(--accent); }
.sound-on .sound-dot .sound-wave { opacity: 1; }
.sound-on .sound-dot .sound-x { opacity: 0; }

.rule { height: 2px; background: var(--ink-14); border-radius: 999px; }

/* ── rail (desktop) ─────────────────────────────────── */
.rail {
  position: sticky; top: 0; align-self: flex-start;
  height: 100vh; flex: 0 0 var(--rail-w); min-width: 0;
  background: var(--cream);
  border-right: 2px dashed var(--ink-18);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 6px;
  overflow: hidden;
  transition: flex-basis .42s var(--ease);
  z-index: 10;
}
.rail.collapsed { flex-basis: 70px; }
.rail .lbl { white-space: nowrap; transition: opacity .22s; }
.rail.collapsed .lbl { opacity: 0; pointer-events: none; }

.rail-toggle {
  width: 40px; height: 40px; flex: none;
  border: 2px solid var(--ink); background: var(--paper); border-radius: 999px;
  cursor: pointer; font: 600 15px var(--font-body);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
  transition: transform .3s, background .3s;
}
.rail-toggle:hover { background: var(--peach); transform: rotate(10deg); }
.rail-group { display: flex; flex-direction: column; gap: 4px; }
.rail .rule { margin: 16px 2px; }

.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 8px;
  border: 2px solid transparent; border-radius: 999px;
  font: 600 13.5px var(--font-body); color: var(--ink); text-decoration: none;
  transition: border-color .2s, transform .2s;
}
.nav-item:hover { color: var(--ink); border-color: var(--ink); transform: translateX(3px) rotate(-1deg); }
.nav-item.tilt-r:hover { transform: translateX(3px) rotate(1deg); }
.nav-accent, .nav-accent:hover { color: var(--accent-700); }
.nav-item.nav-accent:hover { border-color: var(--accent); }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.sound-toggle {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: 0; background: transparent; cursor: pointer;
  padding: 8px; border-radius: 999px; text-align: left;
  font: 600 12px var(--font-body); color: rgba(32, 30, 29, .6);
}
.sound-toggle:hover { background: rgba(32, 30, 29, .07); }
.konami { font: 400 10px/1.4 var(--font-mono); color: rgba(32, 30, 29, .42); padding-left: 8px; }

/* ── top bar (mobile) ───────────────────────────────── */
.topbar { display: none; }

/* ── main ───────────────────────────────────────────── */
.main { flex: 1; min-width: 0; padding: 0 0 64px; position: relative; }

/* ── avatar buddy ───────────────────────────────────── */
.buddy {
  position: fixed; left: 0; top: 0; z-index: 25;
  pointer-events: none; will-change: transform;
  opacity: 0; transition: opacity .3s;
}
.buddy.ready { opacity: 1; }
.buddy-sprite {
  display: block; pointer-events: auto; cursor: grab;
  touch-action: none; user-select: none; -webkit-user-select: none;
  overflow: visible;
  transform-origin: 50% 100%;
}
/* avatar faces — used by the buddy and the runner game's player */
.b-m { display: none; }
[data-face="smile"] .b-m-smile,
[data-face="shock"] .b-m-shock,
[data-face="dazed"] .b-m-dazed { display: inline; }
.b-eye { transform-box: fill-box; transform-origin: center; transition: transform .07s; }
.blink .b-eye,
[data-face="dazed"] .b-eye { transform: scaleY(.14); }
[data-face="shock"] .b-eye { transform: scale(1.15); }
.buddy.away { opacity: 0; visibility: hidden; }
.buddy.held .buddy-sprite { cursor: grabbing; }
.buddy-sprite.squash { animation: squash .38s ease-out; }
@keyframes squash {
  0% { transform: scale(1.28, .7); }
  55% { transform: scale(.94, 1.07); }
  100% { transform: none; }
}
.buddy-shadow {
  position: absolute; left: 50%; bottom: -3px; z-index: -1;
  width: 70%; height: 7px; border-radius: 50%;
  background: rgba(32, 30, 29, .18);
  transform: translateX(-50%);
  transition: opacity .15s;
}
.buddy.airborne .buddy-shadow { opacity: 0; }

.buddy-bubble {
  --shift: 0px;
  --pop: .6;
  position: absolute; left: 50%; bottom: calc(100% + 12px);
  width: max-content; max-width: 230px;
  padding: 8px 12px; border-radius: 12px;
  background: var(--ink); color: var(--paper);
  font: 500 12px/1.4 var(--font-mono); text-align: center;
  box-shadow: 0 6px 18px rgba(32, 30, 29, .22);
  transform-origin: 50% 100%;
  transform: translateX(calc(-50% + var(--shift))) scale(var(--pop));
  opacity: 0;
  transition: opacity .14s, transform .2s cubic-bezier(.34, 1.56, .64, 1);
}
.buddy-bubble.show { opacity: 1; --pop: 1; }
.buddy-bubble.loud { font-weight: 700; font-size: 14px; letter-spacing: .02em; }
.buddy-bubble::after {
  content: ""; position: absolute; top: 100%;
  left: clamp(14px, calc(50% - var(--shift)), calc(100% - 14px));
  transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--ink);
}
.buddy-bubble.below { bottom: auto; top: calc(100% + 12px); transform-origin: 50% 0; }
.buddy-bubble.below::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--ink); }

.buddy-stars {
  position: absolute; left: 50%; top: -14px;
  font-size: 12px; letter-spacing: 3px; color: var(--accent);
  transform: translateX(-50%); opacity: 0; white-space: nowrap;
}
.buddy.dazed .buddy-stars { opacity: 1; animation: daze .6s ease-in-out infinite alternate; }
@keyframes daze {
  from { transform: translateX(-50%) rotate(-14deg); }
  to { transform: translateX(-50%) rotate(14deg); }
}

/* hero */
.hero { padding: 66px var(--gutter) 44px; position: relative; }
.eyebrow {
  font: 600 11px var(--font-mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent-700); margin-bottom: 18px;
}
.hero-name {
  font-size: clamp(56px, 6.4vw, 82px); line-height: .95; margin: 0 0 6px;
  cursor: pointer; user-select: none;
}
/* "Bala Bhaskaran" is one surname — it gets its own line and never splits. */
.hero-name .name-line { display: block; }
.role-pill {
  display: inline-block; background: var(--ink); color: var(--paper);
  border-radius: 999px; padding: 9px 20px;
  font: 600 17px var(--font-body);
  transform: rotate(-1.5deg); margin: 12px 0 22px;
}
.lede { font: 400 17px/1.65 var(--font-body); color: rgba(32, 30, 29, .78); max-width: 48ch; margin-bottom: 26px; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.pill-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 14px 26px; border-radius: 999px; border: 2px solid var(--ink);
  font: 600 15px var(--font-body); text-decoration: none;
  transition: transform .2s;
}
.pill-primary, .pill-primary:hover { background: var(--accent); color: var(--paper); }
.pill-secondary, .pill-secondary:hover { background: var(--paper); color: var(--ink); }
.pill-primary:hover { transform: translateY(-3px) rotate(-1.5deg); }
.pill-secondary:hover { transform: translateY(-3px) rotate(1.5deg); }
.secret-text { font: 600 13px var(--font-mono); color: var(--olive-700); min-height: 20px; }

/* sections */
.section { padding: 56px var(--gutter) 0; scroll-margin-top: 18px; }
#work { padding-top: 16px; }
.section-title {
  font-size: 15px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-50); margin: 0 0 26px;
}

/* cards */
.stack { display: flex; flex-direction: column; gap: 20px; }
.card {
  display: block; background: var(--cream);
  border: 2px solid var(--ink); border-radius: 28px;
  padding: 28px 32px;
  transform: rotate(var(--tilt, 0deg));
  box-shadow: 6px 6px 0 rgba(32, 30, 29, .16);
  transition: transform .32s var(--ease), box-shadow .32s, opacity .5s ease-out;
}
.card:hover {
  transform: rotate(0deg) translateY(-5px) scale(1.012);
  box-shadow: 10px 10px 0 var(--glow, rgba(32, 30, 29, .3));
}
.js .reveal { opacity: 0; }
.js .reveal.shown { opacity: 1; }

.card-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h3 { font-size: 32px; line-height: 1.1; }
.card-head h3.h3-long { font-size: 30px; }
.role {
  border-radius: 999px; padding: 4px 13px;
  font: 600 12px var(--font-body); color: var(--paper);
}
.role-accent { background: var(--accent); }
.role-olive { background: var(--olive); }
.role-ink { background: var(--ink); }
.date { font: 400 12px var(--font-mono); color: var(--ink-50); margin-left: auto; }
.card p { font: 400 15.5px/1.65 var(--font-body); color: var(--ink-80); margin: 0 0 14px; max-width: 70ch; }
.card p.last { margin: 0; }

.tags { display: flex; gap: 10px; flex-wrap: wrap; }
.tag {
  border: 2px solid var(--ink); border-radius: 999px;
  padding: 5px 13px; font: 600 12px var(--font-body);
}
.tag-peach { background: var(--peach); }
.tag-sage { background: var(--sage); }
.tag-paper { background: var(--paper); }

/* projects */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.project {
  display: flex; flex-direction: column; gap: 12px;
  padding: 26px 26px 22px; text-decoration: none; color: var(--ink);
}
.project:hover { color: var(--ink); transform: rotate(0deg) translateY(-6px); }
.project { container-type: inline-size; }
.project-head { display: flex; align-items: center; gap: 10px; }
/* Shrink titles just enough that the longest ("OfflineClub") plus its chip fits the card. */
.project-head h3 { font-size: clamp(15px, calc((100cqi - 108px) / 5.9), 26px); white-space: nowrap; }
.dot-lg { width: 34px; height: 34px; flex: none; border-radius: 999px; border: 2px solid var(--ink); }
.chip {
  margin-left: auto; background: var(--sage); border: 2px solid var(--ink);
  border-radius: 999px; padding: 3px 10px; font: 600 10.5px var(--font-mono);
}
.project p { font-size: 14.5px; line-height: 1.6; margin: 0; flex: 1; }
.link { font: 600 12.5px var(--font-mono); color: var(--accent-700); }

/* education + facts */
.split {
  display: grid; grid-template-columns: 380px 1fr; column-gap: 24px;
  grid-template-areas: "edu-title title" "edu fact";
}
.split .section-title { grid-area: title; margin-bottom: 20px; }
.split .fact-box { grid-area: fact; }
.split .edu { grid-area: edu; }
.split .edu-heading { grid-area: edu-title; }
.fact-box {
  background: var(--ink); color: var(--paper); border-radius: 28px;
  padding: 32px 34px; min-height: 186px;
  display: flex; flex-direction: column; gap: 20px;
}
.fact-text { font: 400 20px/1.5 var(--font-body); flex: 1; }
.fact-row { display: flex; align-items: center; gap: 14px; }
.fact-btn {
  border: 0; background: var(--peach); color: var(--ink);
  border-radius: 999px; padding: 12px 24px;
  font: 600 14px var(--font-body); cursor: pointer;
  transition: transform .18s, background .18s;
}
.fact-btn:hover { background: var(--peach-deep); transform: translateY(-2px); }
.fact-count { font: 400 11.5px var(--font-mono); color: rgba(249, 244, 237, .5); }
.edu {
  display: flex; flex-direction: column; justify-content: center;
  background: var(--sage); border: 2px solid var(--ink); border-radius: 28px; padding: 22px 24px;
}
.edu-title { font-family: var(--font-heading); font-size: 20px; line-height: 1.2; }
.edu-meta { font: 400 12.5px var(--font-body); margin-top: 6px; color: rgba(32, 30, 29, .7); }

/* runner game (Konami code) */
.runner-open { overflow: hidden; }
.runner {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center; padding: 24px;
  background: rgba(32, 30, 29, .45);
}
.runner[hidden] { display: none; }
.runner-panel {
  width: min(880px, 100%);
  background: var(--cream); border: 2px solid var(--ink); border-radius: 28px;
  box-shadow: 10px 10px 0 rgba(32, 30, 29, .25);
  padding: 20px 24px 14px;
  animation: runner-in .35s var(--ease);
}
.runner-panel:focus { outline: none; }
@keyframes runner-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.runner-head { display: flex; align-items: center; gap: 18px; margin-bottom: 14px; }
.runner-head h2 { font-size: 24px; margin-right: auto; }
.runner-scores { display: flex; gap: 16px; font: 600 13px var(--font-mono); color: var(--ink-50); }
.runner-scores b { color: var(--ink); }
.runner-scores b.flash { color: var(--accent); }
.runner-close {
  width: 36px; height: 36px; flex: none; border-radius: 999px;
  border: 2px solid var(--ink); background: var(--paper);
  font: 600 20px/1 var(--font-body); cursor: pointer;
  transition: background .2s, transform .2s;
}
.runner-close:hover { background: var(--peach); transform: rotate(90deg); }
.runner-stage {
  position: relative; aspect-ratio: 800 / 260; overflow: hidden;
  border: 2px solid var(--ink); border-radius: 20px; background: var(--paper);
  cursor: pointer; touch-action: none; user-select: none;
}
.runner-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.runner-player { position: absolute; left: 0; top: 0; transform-origin: 50% 100%; will-change: transform; pointer-events: none; }
.runner-player svg { display: block; width: 100%; height: auto; overflow: visible; }
.runner-msg { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.runner-msg > div {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: var(--paper); text-align: center;
  box-shadow: 0 6px 18px rgba(32, 30, 29, .22);
}
.runner-msg strong { font: 400 20px var(--font-heading); }
.runner-msg small { font: 500 11.5px var(--font-mono); opacity: .75; }
.runner-help { margin: 10px 0 0; text-align: center; font: 400 11.5px var(--font-mono); color: var(--ink-50); }

/* ── medium widths ──────────────────────────────────── */
@media (max-width: 1180px) {
  :root { --gutter: 48px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; grid-template-areas: "edu-title" "edu" "title" "fact"; }
  .split .section-title:not(.edu-heading) { margin-top: 56px; }
}

/* ── mobile ─────────────────────────────────────────── */
@media (max-width: 860px) {
  :root { --gutter: 20px; }
  .layout { display: block; }
  .rail { display: none; }

  .topbar {
    display: block; position: sticky; top: 0; z-index: 20;
    background: var(--cream); border-bottom: 2px dashed rgba(32, 30, 29, .2);
  }
  .topbar-row { display: flex; align-items: center; justify-content: flex-end; padding: 14px 18px; }
  .burger {
    width: 44px; height: 44px; flex: none;
    border: 2px solid var(--ink); background: var(--paper); border-radius: 999px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    transition: background .25s;
  }
  .burger:hover { background: var(--peach); }
  .burger span { width: 18px; height: 2.5px; background: var(--ink); border-radius: 999px; transition: transform .25s, opacity .2s; }
  .menu-open .burger span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
  .menu-open .burger span:nth-child(2) { opacity: 0; }
  .menu-open .burger span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

  .menu {
    overflow: hidden; max-height: 0; visibility: hidden;
    transition: max-height .38s var(--ease), visibility 0s linear .38s;
  }
  .menu-open .menu { max-height: 420px; visibility: visible; transition: max-height .38s var(--ease), visibility 0s; }
  .menu-instant .menu { transition: none; }
  .menu-inner { padding: 4px 14px 16px; display: flex; flex-direction: column; gap: 6px; }
  .menu .rule { margin: 6px 4px; }
  .menu-item {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px;
    padding: 10px 14px; border-radius: 999px; border: 2px solid transparent;
    background: var(--paper); color: var(--ink); text-decoration: none; text-align: left;
    font: 600 15px var(--font-body); cursor: pointer;
  }
  .menu-item:hover { color: var(--ink); border-color: var(--ink); }
  .menu-item.nav-accent { color: var(--accent-700); }
  .menu-item.nav-accent:hover { border-color: var(--accent); }
  .menu-item.sound-toggle { background: transparent; border: 0; font-size: 13px; color: rgba(32, 30, 29, .6); }

  .hero { padding: 30px var(--gutter) 26px; overflow: hidden; }
  .eyebrow { font-size: 10.5px; margin-bottom: 14px; }
  /* Shrink with the viewport so the surname still fits one line on small phones. */
  .hero-name { font-size: clamp(34px, 11vw, 42px); line-height: 1; margin: 0; position: relative; max-width: none; }
  .role-pill { padding: 8px 16px; font-size: 14px; margin: 16px 0; }
  .lede { font-size: 15.5px; margin-bottom: 20px; }
  .cta { flex-direction: column; align-items: stretch; gap: 10px; }
  .pill-btn { min-height: 50px; padding: 0 20px; }
  .pill-btn:hover { transform: none; }
  .secret-text { font-size: 12px; min-height: 18px; margin-top: 4px; }

  .section { padding-top: 44px; scroll-margin-top: 90px; }
  #work { padding-top: 8px; }
  .section-title { font-size: 13px; margin-bottom: 18px; }
  .split .section-title { margin-bottom: 18px; }
  .split .section-title:not(.edu-heading) { margin-top: 44px; }

  .stack, .grid { gap: 16px; }
  .grid { grid-template-columns: 1fr; }
  .card { border-radius: 24px; padding: 20px 22px; box-shadow: 5px 5px 0 rgba(32, 30, 29, .16); }
  .card:hover, .project:hover { transform: rotate(var(--tilt, 0deg)); box-shadow: 5px 5px 0 rgba(32, 30, 29, .16); }
  .card-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .card-head h3 { font-size: 25px; }
  .card-head h3.h3-long { font-size: 21px; }
  .role { padding: 3px 11px; font-size: 11.5px; }
  .date { margin-left: 0; font-size: 11px; margin-bottom: 2px; }
  .card p { font-size: 14.5px; line-height: 1.6; margin-bottom: 12px; }
  .tags { gap: 8px; }
  .tag { padding: 4px 11px; font-size: 11.5px; }
  .project { gap: 10px; }
  .project-head h3 { font-size: 23px; }
  .dot-lg { width: 30px; height: 30px; }

  .fact-box { border-radius: 24px; padding: 24px 22px; min-height: 0; gap: 18px; }
  .fact-text { font-size: 16.5px; line-height: 1.55; }
  .fact-btn { min-height: 46px; padding: 0 22px; }
  .edu { border-radius: 24px; padding: 20px 22px; }
  .edu-title { font-size: 19px; }
  .main { padding-bottom: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
