/* ============================================================
   Nishad Singhi — notebook
   Warm paper · Spectral + Caveat · light + dark
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,300..600;1,300..600&family=Kalam:wght@300;400;700&family=EB+Garamond:ital,wght@0,400..700;1,400..700&family=Fraunces:opsz,wght,SOFT@9..144,300..700,0..100&display=swap');

/* -------- tokens -------- */
:root {
  --paper:     #efe7d2;
  --paper-2:   #e5dcc1;
  --ink:       #181a25;
  --ink-soft:  #2e3349;
  --ink-mute:  #5a607b;
  --rule:      #181a2522;
  --accent:    #2d3a78;          /* indigo */
  --accent-soft:#2d3a781f;
  --highlight: #ffe19a;
  --sticky-bg: #fff0a8;
  --tape:      #d6cfb4;
  --polaroid:  #fbf6ea;
  --selection: #ffe19a88;

  --serif:     'Spectral', Georgia, 'Times New Roman', serif;
  --hand:      'Kalam', 'Bradley Hand', cursive;
  --pad-x:     clamp(1.25rem, 4vw, 2.5rem);
}

/* font pairings (switchable) */
:root[data-font="spectral"] { --serif: 'Spectral', Georgia, serif; }
:root[data-font="garamond"] { --serif: 'EB Garamond', Georgia, serif; }
:root[data-font="fraunces"] { --serif: 'Fraunces', Georgia, serif; }

/* dark mode — midnight notebook */
:root[data-theme="dark"] {
  --paper:     #0c0e18;
  --paper-2:   #141729;
  --ink:       #e2e4ef;
  --ink-soft:  #c5cae0;
  --ink-mute:  #8b91ab;
  --rule:      #e2e4ef2a;
  --accent:    #8d9bd6;
  --accent-soft:#8d9bd620;
  --highlight: #8d9bd640;
  --sticky-bg: #b8c2e0;
  --tape:      #3a4060;
  --polaroid:  #181c2e;
  --selection: #8d9bd633;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  background-image:
    radial-gradient(circle at 0% 0%, #fff7e640 0%, transparent 40%),
    radial-gradient(circle at 100% 100%, #c9b78a30 0%, transparent 45%);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.15rem, 1.05rem + 0.45vw, 1.35rem);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 240ms ease, color 240ms ease;
}
:root[data-theme="dark"] body {
  background-image:
    radial-gradient(circle at 0% 0%, #8d9bd610 0%, transparent 35%),
    radial-gradient(circle at 100% 100%, #4a5a9010 0%, transparent 40%);
}

::selection { background: var(--selection); color: var(--ink); }
img { max-width: 100%; height: auto; display: block; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-soft);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  transition: text-decoration-color 200ms ease, color 160ms ease;
}
a:hover { text-decoration-color: var(--accent); }

p { margin: 0 0 1.05em; }
em { font-style: italic; }
strong { font-weight: 600; }

/* -------- shells -------- */
.shell {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 var(--pad-x);
}
.shell-wide {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 var(--pad-x);
}

/* -------- top bar -------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.75rem 0 0;
  gap: 2.5rem;
  font-family: var(--serif);
  font-size: 1.2rem;
  color: var(--ink-mute);
}
.topbar .mark {
  font-family: var(--hand);
  font-size: 1.85rem;
  color: var(--ink);
  text-decoration: none;
  line-height: 1;
}
.topbar .mark:hover { color: var(--accent); }
.topbar nav {
  display: flex;
  align-items: center;
  gap: 1.7rem;
  font-size: 1.18rem;
  letter-spacing: 0.01em;
}
.topbar nav a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px dashed transparent;
  padding-bottom: 2px;
  transition: color 160ms ease, border-color 160ms ease;
}
.topbar nav a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.topbar nav a.active { color: var(--accent); border-bottom-color: var(--accent); }

.toggle, .font-switch {
  background: transparent;
  border: 1px dashed var(--rule);
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink-soft);
  font-family: var(--hand);
  transition: border-color 160ms ease, color 160ms ease, transform 200ms ease;
}
.toggle {
  width: 2.4rem; height: 2.4rem;
  display: inline-grid; place-items: center;
  margin-left: 0.4rem;
}
.toggle:hover { color: var(--accent); border-color: var(--accent); transform: rotate(-10deg); }
.toggle svg { width: 1.2rem; height: 1.2rem; }
.font-switch {
  padding: 0.3rem 0.95rem;
  font-size: 1.4rem;
  line-height: 1;
  display: none;          /* hidden in production — JS/markup still present */
}
.font-switch:hover { color: var(--accent); border-color: var(--accent); }

/* -------- hero -------- */
.hero { padding: 4rem 0 1.5rem; }
.name {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(3rem, 6vw + 1rem, 5rem);
  line-height: 1;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
  position: relative;
  display: inline-block;
  cursor: pointer;
}
.name .underline {
  position: absolute;
  left: 0;
  bottom: -0.15em;
  width: 100%;
  height: 0.45em;
  pointer-events: none;
  overflow: visible;
}
.name .underline path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 600;
  stroke-dashoffset: 600;
  animation: draw 1500ms cubic-bezier(.7,.05,.25,1) 300ms forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.hand {
  font-family: var(--hand);
  font-size: 1.7rem;
  color: var(--accent);
  line-height: 1.2;
  display: inline-block;
  transform: rotate(-1.5deg);
  margin: 0.4rem 0 2rem;
}

/* -------- about -------- */
.about {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  padding: 1rem 0 2rem;
}
@media (min-width: 760px) {
  .about { grid-template-columns: 1fr 15rem; gap: 3rem; }
}
.portrait { order: -1; }
@media (min-width: 760px) { .portrait { order: 1; } }

.prose {
  font-size: clamp(1.05rem, 0.95rem + 0.3vw, 1.18rem);
  line-height: 1.7;
}
.prose p { margin: 0 0 1.05em; }
.prose a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--rule);
}
.prose a:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* polaroid */
.polaroid {
  background: var(--polaroid);
  padding: 0.7rem 0.7rem 2.6rem;
  box-shadow: 0 1px 0 #00000010, 0 18px 28px -18px #00000060;
  transform: rotate(2.4deg);
  width: 13rem;
  margin: 0 auto;
  position: relative;
  transition: transform 320ms cubic-bezier(.34,1.56,.64,1), box-shadow 320ms ease;
}
.polaroid::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  width: 64px;
  height: 16px;
  background: var(--tape);
  opacity: 0.7;
  border: 1px solid #b5a47540;
}
.polaroid:hover { transform: rotate(0deg) scale(1.02); }
.polaroid img {
  width: 100%;
  display: block;
  border-radius: 1px;
  filter: sepia(8%) saturate(0.95) contrast(0.98);
}
:root[data-theme="dark"] .polaroid img { filter: sepia(15%) saturate(0.85) contrast(0.95) brightness(0.92); }
.polaroid figcaption {
  position: absolute;
  bottom: 0.5rem;
  left: 0; right: 0;
  text-align: center;
  font-family: var(--hand);
  font-size: 1.3rem;
  color: var(--ink);
  line-height: 1;
}

.below-portrait {
  margin-top: 1rem;
  text-align: center;
  font-family: var(--hand);
  font-size: 1.25rem;
  color: var(--ink-mute);
  transform: rotate(-1deg);
}

/* socials under portrait */
.socials {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  margin-top: 1.2rem;
  font-family: var(--hand);
  font-size: 1.2rem;
  justify-content: center;
}
.socials a {
  color: var(--ink-soft);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-bottom: 1px dashed transparent;
}
.socials a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.socials svg { width: 0.95rem; height: 0.95rem; opacity: 0.85; }

/* notebook primitives */
.margin-note {
  font-family: var(--hand);
  font-size: 1.3rem;
  color: var(--accent);
  line-height: 1.25;
  padding: 0.45rem 0 0.45rem 1rem;
  border-left: 2px solid var(--accent);
  transform: rotate(-0.8deg);
  margin: 1.2rem 0;
  max-width: 30rem;
}
.sticky {
  display: inline-block;
  background: var(--sticky-bg);
  color: #2a2419;
  padding: 0.5rem 0.95rem;
  transform: rotate(-1.8deg);
  box-shadow: 1px 2px 5px #00000026, 0 0 0 1px #00000008;
  font-family: var(--hand);
  font-size: 1.3rem;
  line-height: 1.25;
  margin: 0.6rem 0;
}
.hl {
  background: linear-gradient(transparent 60%, var(--highlight) 60%, var(--highlight) 92%, transparent 92%);
  padding: 0 0.05em;
}
.apple-mark {
  width: 0.85em;
  height: 0.85em;
  vertical-align: -0.08em;
  margin-right: 0.22em;
  color: var(--ink);
}

/* dashed divider */
hr.dashed {
  border: 0;
  border-top: 1.6px dashed var(--rule);
  margin: 3rem 0;
}

/* -------- sections -------- */
section.block { padding: 1.8rem 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 1.4rem;
  gap: 1rem;
}
.section-head h2 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.8rem, 1.4rem + 1.1vw, 2.4rem);
  letter-spacing: -0.01em;
  margin: 0;
}
.section-head h2::before {
  content: '§ ';
  color: var(--accent);
  font-style: normal;
}
.section-head .num {
  font-family: var(--hand);
  font-size: 1.5rem;
  color: var(--accent);
}

/* selected work */
.selected-list { list-style: none; padding: 0; margin: 0; }
.selected-list li {
  padding: 1rem 0;
  border-bottom: 1px dashed var(--rule);
}
.selected-list li:first-child { border-top: 1px dashed var(--rule); }
.selected-list a {
  text-decoration: none;
  color: inherit;
  display: block;
  border: 0;
}
.selected-list .stitle {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.18rem;
  line-height: 1.3;
  transition: color 160ms ease;
}
.selected-list a:hover .stitle { color: var(--accent); }
.selected-list .smeta {
  font-family: var(--hand);
  font-size: 1.2rem;
  color: var(--ink-mute);
  margin-top: 0.2rem;
}

/* news */
.news-list { list-style: none; padding: 0; margin: 0; }
.news-item {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 1.2rem;
  align-items: baseline;
  padding: 1rem 0;
  border-bottom: 1px dashed var(--rule);
}
.news-item:last-child { border-bottom: 0; }
.news-item time {
  font-family: var(--hand);
  color: var(--accent);
  font-size: 1.35rem;
  white-space: nowrap;
  line-height: 1;
}
.news-item .body {
  font-size: 1.02rem;
  line-height: 1.55;
}

/* -------- publications -------- */
.page-head { padding: 4rem 0 1.5rem; }
.page-head h1 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(2.6rem, 4vw + 1rem, 4rem);
  line-height: 1;
  letter-spacing: -0.015em;
  margin: 0 0 0.5rem;
}
.page-head .sub {
  font-family: var(--hand);
  font-size: 1.4rem;
  color: var(--ink-mute);
  margin: 0;
}

.elsewhere {
  margin: 0 0 2.5rem;
  padding: 0.65rem 1rem;
  background: var(--paper-2);
  border: 1.5px dashed var(--rule);
  border-radius: 4px;
  font-family: var(--hand);
  font-size: 1.3rem;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  width: auto;
}
.elsewhere a { color: var(--accent); text-decoration: none; border-bottom: 1.5px solid var(--accent); padding-bottom: 1px; }

.pubs { display: grid; gap: 2.2rem; }
.year-group h3 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 2rem;
  color: var(--ink-mute);
  margin: 0 0 1rem;
}
.year-group h3::before {
  content: '— ';
  color: var(--accent);
}
.pub {
  display: grid;
  grid-template-columns: 5rem 1fr;
  gap: 1.2rem;
  padding: 1.3rem 0;
  border-top: 1px dashed var(--rule);
  transition: background-color 220ms ease;
}
.pub.featured {
  background: var(--paper-2);
  padding: 1.3rem 1.2rem;
  margin: 0 -1.2rem;
  border-top-color: var(--accent-soft);
  border-radius: 4px;
  position: relative;
}
.pub.featured::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 4px 0 0 4px;
}
:root[data-theme="dark"] .pub.featured { background: #1a1f3a; }
.pub-venue {
  font-family: var(--hand);
  font-size: 1.4rem;
  color: var(--accent);
  padding-top: 0.15rem;
}
.pub-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.22rem;
  line-height: 1.3;
  margin: 0 0 0.4rem;
  transition: color 160ms ease;
}
.pub:hover .pub-title { color: var(--accent); }
.pub-authors {
  font-family: var(--serif);
  font-size: 0.98rem;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0 0 0.5rem;
}
.pub-authors .me {
  font-weight: 600;
  color: var(--accent);
  background: linear-gradient(transparent 60%, var(--highlight) 60%, var(--highlight) 92%, transparent 92%);
  padding: 0 0.1em;
}
.pub-meta {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.92rem;
  color: var(--ink-mute);
  margin: 0 0 0.5rem;
}
.pub-tldr {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 0.6rem 0 0;
  position: relative;
}
.pub-tldr .lbl {
  font-family: var(--hand);
  color: var(--accent);
  margin-right: 0.5rem;
  font-size: 1.15rem;
  vertical-align: -0.05em;
}
.pub-links {
  margin-top: 0.7rem;
  font-family: var(--hand);
  font-size: 1.2rem;
  color: var(--ink-mute);
}
.pub-links a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1.5px solid transparent;
  padding-bottom: 1px;
}
.pub-links a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.pub-links .sep { color: var(--ink-mute); margin: 0 0.45rem; opacity: 0.55; }
.pub-award {
  font-family: var(--hand);
  font-size: 1.25rem;
  color: var(--accent);
  margin-top: 0.5rem;
  transform: rotate(-0.6deg);
  display: inline-block;
}

/* reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .name .underline path { stroke-dashoffset: 0; }
}
