/* =========================================================
   Kauntey Acharya: portfolio
   One stylesheet shared by index.html and notes.html
   ========================================================= */

/* ---------- Tokens ---------- */
/* Original portfolio palette: beige paper / pure black, monochrome */
:root {
  --bg:      #F5F5DC;
  --surface: rgba(0, 0, 0, .04);
  --text:    #000000;
  --muted:   rgba(0, 0, 0, .66);
  --line:    rgba(0, 0, 0, .18);
  --accent:  #000000;

  --mono:  monospace;
  --serif: monospace;

  --max: 1040px;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --label-col: 180px;
}

:root[data-ka-theme="dark"] {
  --bg:      #000000;
  --surface: rgba(255, 255, 255, .06);
  --text:    #FFFFFF;
  --muted:   rgba(255, 255, 255, .66);
  --line:    rgba(255, 255, 255, .2);
  --accent:  #FFFFFF;
  color-scheme: dark;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.5;          /* original 1.75 minus .25 */
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}
a { color: inherit; }
img { max-width: 100%; }
::selection { background: var(--text); color: var(--bg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; gap: 1rem;
}
.brand {
  font-family: var(--mono); font-weight: 500; font-size: .95rem;
  text-decoration: none; letter-spacing: .02em;
}
.nav { display: flex; align-items: center; gap: 1.4rem; font-family: var(--mono); font-size: .82rem; }
.nav a { text-decoration: none; color: var(--muted); transition: color .2s; white-space: nowrap; }
.nav a:hover { color: var(--text); }
/* About (main page) and Notes (separate page) are underlined; the one you are on is bold */
.nav a.nav-u { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
.nav a.nav-u[aria-current="page"] { color: var(--text); font-weight: 700; text-decoration-thickness: 2px; }
.theme-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: none; border: 1px solid var(--line); border-radius: 50%;
  color: var(--text); cursor: pointer; transition: border-color .2s;
}
.theme-btn:hover { border-color: var(--text); }
.theme-btn svg { width: 16px; height: 16px; }

/* ---------- Hero ---------- */
.hero { padding: clamp(5rem, 14vh, 9rem) 0 clamp(3.5rem, 8vh, 5rem); }
.status {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--mono); font-size: .78rem; color: var(--muted);
  margin-bottom: 2rem;
}
.status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: #3E9B5A; box-shadow: 0 0 0 3px color-mix(in srgb, #3E9B5A 22%, transparent);
}
.hero h1 {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.1; letter-spacing: 0;
  margin-bottom: 1.2rem;
}
.hero .roles { font-family: var(--mono); font-size: clamp(.85rem, 1.8vw, 1rem); color: var(--muted); margin-bottom: 1.8rem; }
.hero .lede { font-size: clamp(1.1rem, 2.2vw, 1.3rem); max-width: 36em; margin-bottom: 2.2rem; }
.hero .lede em { font-style: italic; }

.links { display: flex; flex-wrap: wrap; gap: .6rem 1.6rem; font-family: var(--mono); font-size: .85rem; }
.links a {
  display: inline-flex; align-items: center; gap: .45rem;
  text-decoration: none; color: var(--text);
  border-bottom: 1px solid var(--line); padding-bottom: 2px;
  transition: border-color .2s, color .2s;
}
.links a:hover { border-color: var(--accent); color: var(--accent); }
.links svg { width: 15px; height: 15px; fill: currentColor; }
.hero .loc { margin-top: 2.2rem; font-family: var(--mono); font-size: .78rem; color: var(--muted); }

/* ---------- Sections ---------- */
.section {
  display: grid; grid-template-columns: var(--label-col) 1fr; gap: 2rem;
  padding: 4rem 0; border-top: 1px solid var(--line);
}
.section-label {
  font-family: var(--mono); font-size: .78rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .1em;
  position: sticky; top: 84px; align-self: start;
}
.section-label span { display: block; color: var(--text); margin-bottom: .2rem; }
.section-body > p { max-width: 38em; margin-bottom: 1.1em; }
.section-body > p:last-child { margin-bottom: 0; }

/* ---------- Generic list rows ---------- */
.rows { list-style: none; }
.row { padding: 1.6rem 0; border-bottom: 1px solid var(--line); }
.row:first-child { padding-top: 0; }
.row:last-child { border-bottom: 0; padding-bottom: 0; }
.row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.row h3 { font-size: 1.1rem; font-weight: 700; line-height: 1.35; }
.row h3 a { text-decoration: none; }
.row h3 a:hover { color: var(--accent); }
.row .when { font-family: var(--mono); font-size: .78rem; color: var(--muted); white-space: nowrap; }
.row .org { font-family: var(--mono); font-size: .82rem; color: var(--muted); margin: .15rem 0 .6rem; }
.row p { max-width: 40em; }
.row ul.points { margin: .5rem 0 0 1.1rem; max-width: 40em; }
.row ul.points li { margin-bottom: .25rem; }

.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; list-style: none; }
.tags li {
  font-family: var(--mono); font-size: .7rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: .1rem .6rem;
}
.row-links { display: flex; flex-wrap: wrap; gap: 1.2rem; margin-top: .9rem; font-family: var(--mono); font-size: .8rem; }
.row-links a { text-decoration: none; color: var(--text); border-bottom: 1px solid var(--line); }
.row-links a:hover { border-color: var(--text); }
.row-links a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Skills ---------- */
.skill-groups { display: grid; gap: 1.4rem; }
.skill-group h3 { font-family: var(--mono); font-size: .78rem; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: .35rem; }
.skill-group p { font-size: 1.05rem; }

/* ---------- Publications ---------- */
.pub .authors { font-size: .95rem; color: var(--muted); margin: .3rem 0 .15rem; }
.pub .authors strong { color: var(--text); font-weight: 600; }
.pub .venue { font-size: .9rem; }
.pub .venue a { text-decoration: none; border-bottom: 1px solid var(--line); }
.pub .venue a:hover { border-color: var(--text); }
.pub .venue i { font-style: normal; color: var(--text); }
}

/* ---------- Blog teaser + blog page ---------- */
.post-list { list-style: none; }
.post-item { display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem; padding: 1.1rem 0; border-bottom: 1px solid var(--line); }
.post-item:last-child { border-bottom: 0; }
.post-item time { font-family: var(--mono); font-size: .78rem; color: var(--muted); padding-top: .25rem; }
.post-item a { text-decoration: none; font-weight: 600; font-size: 1.08rem; }
.post-item a:hover { color: var(--accent); }
.post-item p { color: var(--muted); font-size: .98rem; margin-top: .15rem; }
.more-link { display: inline-block; margin-top: 1.4rem; font-family: var(--mono); font-size: .82rem; color: var(--accent); text-decoration: none; }
.more-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.empty { color: var(--muted); font-style: italic; }

.page-head { padding: 4.5rem 0 2.5rem; }
.page-head h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); line-height: 1.1; letter-spacing: -.015em; font-weight: 600; }
.page-head p { color: var(--muted); margin-top: .6rem; max-width: 34em; }

.filter-bar { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.5rem; }
.filter-bar button {
  font-family: var(--mono); font-size: .75rem; color: var(--muted);
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: .2rem .75rem; cursor: pointer;
}
.filter-bar button:hover { color: var(--text); border-color: var(--text); }
.filter-bar button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* article */
.article { max-width: 42rem; margin: 0 auto; padding: 3.5rem 0 4rem; }
.article .back { font-family: var(--mono); font-size: .8rem; color: var(--muted); text-decoration: none; }
.article .back:hover { color: var(--text); }
.article header { margin: 2rem 0 2.5rem; }
.article h1 { font-size: clamp(2rem, 5vw, 2.8rem); line-height: 1.15; letter-spacing: -.015em; font-weight: 600; }
.article .meta { font-family: var(--mono); font-size: .8rem; color: var(--muted); margin-top: .8rem; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { font-size: 1.5rem; margin-top: 2.2em; line-height: 1.3; }
.prose h3 { font-size: 1.2rem; margin-top: 1.8em; }
.prose a { color: var(--accent); text-underline-offset: 3px; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li + li { margin-top: .3em; }
.prose blockquote { border-left: 2px solid var(--accent); padding-left: 1rem; color: var(--muted); font-style: italic; }
.prose code { font-family: var(--mono); font-size: .86em; background: var(--surface); padding: .1em .35em; border-radius: 3px; }
.prose pre { background: var(--surface); border: 1px solid var(--line); padding: 1rem 1.1rem; overflow-x: auto; border-radius: 4px; line-height: 1.5; }
.prose pre code { background: none; padding: 0; font-size: .85rem; }
.prose img { display: block; margin: 1.6em auto; border-radius: 4px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: .45rem .6rem; text-align: left; }
.prose .katex-display { overflow-x: auto; overflow-y: hidden; padding: .3rem 0; }

/* ---------- Contact ---------- */
.contact-big { font-size: 1.1rem; max-width: 34em; margin-bottom: 1.2rem; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 2rem 0 5.5rem; font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.footer .wrap { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.footer a { text-decoration: none; }
.footer a:hover { color: var(--text); }

/* ---------- Reveal ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---------- Chat widget ---------- */
.chat-toggle {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  height: 44px; padding: 0 1rem 0 .85rem; border-radius: 999px;
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--text); color: var(--bg); border: 0; cursor: pointer;
  font-family: var(--mono); font-size: .8rem;
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
  transition: transform .2s ease;
}
.chat-toggle:hover { transform: translateY(-2px); }
.chat-toggle svg { width: 17px; height: 17px; }
.chat-toggle[hidden] { display: none; }

.chat {
  position: fixed; right: 20px; bottom: 20px; z-index: 61;
  width: 370px; height: min(540px, calc(100vh - 40px));
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,.18);
  opacity: 0; transform: translateY(12px) scale(.98); pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.chat.open { opacity: 1; transform: none; pointer-events: auto; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.chat-head strong { font-family: var(--mono); font-size: .85rem; font-weight: 500; }
.chat-close { background: none; border: 0; color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer; padding: .2rem .4rem; }
.chat-close:hover { color: var(--text); }
.chat-log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.msg { max-width: 88%; padding: .6rem .8rem; border-radius: 10px; font-size: .92rem; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 2px; }
.msg.user { align-self: flex-end; background: var(--text); color: var(--bg); border-bottom-right-radius: 2px; font-family: var(--mono); font-size: .82rem; }
.msg a { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chips button {
  font-family: var(--mono); font-size: .72rem; color: var(--text);
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: .25rem .65rem; cursor: pointer;
}
.chips button:hover { border-color: var(--text); }
.chat-form { display: flex; gap: .4rem; padding: .7rem; border-top: 1px solid var(--line); }
.chat-form input {
  flex: 1; min-width: 0; font: inherit; font-family: var(--mono); font-size: .82rem;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: .55rem .7rem; outline: none;
}
.chat-form input:focus { border-color: var(--text); }
.chat-form button { background: var(--text); color: var(--bg); border: 0; border-radius: 6px; padding: 0 .8rem; cursor: pointer; font-family: var(--mono); font-size: .8rem; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  body { font-size: 15px; }
  .section { grid-template-columns: 1fr; gap: 1.2rem; padding: 3rem 0; }
  .section-label { position: static; }
  .nav .hide-sm { display: none; }
  .post-item { grid-template-columns: 1fr; gap: .1rem; }
}
@media (max-width: 480px) {
  .nav { gap: 1rem; }
  .chat { right: 10px; left: 10px; bottom: 10px; width: auto; height: min(78vh, 560px); }
  .chat-toggle span { display: none; }
  .chat-toggle { padding: 0; width: 44px; justify-content: center; }
}
