/* ==========================================================================
   Ritik Verma — portfolio
   Editorial "lab notebook" system: Fraunces display, IBM Plex text & mono,
   cream paper ground, ink type, one signal-red accent.
   ========================================================================== */

:root {
  --paper: #efe9dc;      /* page ground */
  --paper-2: #e6dfd0;    /* alternate section band */
  --card: #f6f2e9;       /* raised surfaces */
  --ink: #16140f;        /* primary text */
  --ink-2: #3d3a33;      /* body text */
  --muted: #625d52;      /* secondary text, labels */
  --rule: #cfc7b6;       /* dividers */
  --accent: #ff6a47;
  --accent-ink: #16140f;
  --accent-soft: rgba(255, 106, 71, 0.2);
  --live: #1f8a5b;

  /* projects block now shares the page palette */
  --inv-bg: var(--paper);
  --inv-card: var(--card);
  --inv-text: var(--ink);
  --inv-muted: var(--muted);
  --inv-rule: var(--rule);

  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --gutter: clamp(1.25rem, 4vw, 3rem);
  --maxw: 1200px;
  --radius: 4px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  color-scheme: light;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .3s, color .3s;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.mono { font-family: var(--mono); font-size: .78rem; letter-spacing: .02em; text-transform: uppercase; }
.skip { position: absolute; left: -999px; top: .5rem; background: var(--ink); color: var(--paper); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: .5rem; }

.dot {
  display: inline-block; width: .5rem; height: .5rem; border-radius: 50%;
  background: var(--live); box-shadow: 0 0 0 0 var(--live);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 60%, transparent); }
  70% { box-shadow: 0 0 0 .5rem transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 50;
  padding-top: env(safe-area-inset-top, 0px);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s, background-color .3s;
}
.bar.is-scrolled { border-bottom-color: var(--rule); }
.bar__inner {
  max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter);
  height: 4.25rem; display: flex; align-items: center; gap: 2rem;
}
.mark { display: flex; align-items: center; gap: .75rem; text-decoration: none; }
.mark__glyph {
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem;
  background: var(--ink); color: var(--paper);
  font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 1rem;
  border-radius: 50%;
}
.mark__name { font-family: var(--serif); font-size: 1.15rem; font-weight: 500; letter-spacing: -.01em; white-space: nowrap; }
@media (min-width: 901px) and (max-width: 1100px) { .mark__name { display: none; } }

.nav { display: flex; gap: .25rem; margin-left: auto; }
.nav a {
  position: relative; padding: .5rem .8rem; text-decoration: none;
  font-size: .9rem; color: var(--ink-2); border-radius: 999px;
  transition: color .2s, background-color .2s;
}
.nav a span { font-family: var(--mono); font-size: .65rem; color: var(--muted); margin-right: .35rem; vertical-align: .15em; }
.nav a:hover { color: var(--ink); background: var(--paper-2); }
.nav a.is-active { color: var(--ink); background: var(--paper-2); }
.nav a.is-active span { color: var(--accent); }

.bar__tools { display: flex; gap: .5rem; }
.icon-btn {
  width: 2.5rem; height: 2.5rem; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--rule); border-radius: 50%;
  cursor: pointer; transition: border-color .2s, background-color .2s;
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.menu-btn { display: none; }
.menu-btn span { display: block; width: 1rem; height: 1.5px; background: currentColor; transition: transform .3s var(--ease); grid-area: 1 / 1; }
.menu-btn span:first-child { transform: translateY(-3px); }
.menu-btn span:last-child { transform: translateY(3px); }
.menu-btn[aria-expanded="true"] span:first-child { transform: rotate(45deg); }
.menu-btn[aria-expanded="true"] span:last-child { transform: rotate(-45deg); }

/* ---------- hero ---------- */
.hero { position: relative; padding-block: clamp(2.5rem, 6vw, 5rem) 0; }
.hero__grid {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: clamp(2rem, 6vw, 5rem); align-items: center;
}
.kicker {
  display: inline-flex; align-items: center; gap: .6rem;
  font-family: var(--mono); font-size: .75rem; letter-spacing: .03em; text-transform: uppercase;
  color: var(--ink-2); padding: .45rem .85rem; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--card);
}
.hero__title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(3.6rem, 11vw, 8.75rem);
  line-height: .9; letter-spacing: -.045em;
  margin-block: 1.75rem 1.75rem;
  font-variation-settings: "opsz" 144;
}
.hero__title em { font-style: italic; font-weight: 300; color: var(--accent); padding-left: .12em; }
.hero__lede { max-width: 34rem; font-size: clamp(1.05rem, 1.6vw, 1.25rem); color: var(--ink-2); line-height: 1.6; }
.hero__lede strong { font-weight: 500; color: var(--ink); background: linear-gradient(transparent 62%, var(--accent-soft) 62%); }
.hero__cta { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2.25rem; }
.hero__roles {
  display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin-top: 2.5rem;
  font-family: var(--mono); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
.hero__roles li::before { content: "/ "; color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: .6rem;
  padding: .9rem 1.4rem; border-radius: 999px; text-decoration: none;
  font-size: .95rem; font-weight: 500; border: 1px solid var(--ink);
  transition: transform .25s var(--ease), background-color .25s, color .25s, border-color .25s;
}
.btn span { transition: transform .25s var(--ease); }
.btn:hover span { transform: translateX(3px); }
.btn--solid { background: var(--ink); color: var(--paper); }
.btn--solid:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--line { background: transparent; color: var(--ink); }
.btn--line:hover { background: var(--ink); color: var(--paper); }

/* portrait: a mounted print — the photo sits on a paper mat with its caption,
   so the photo's blue backdrop reads as a deliberate plate rather than a clash */
.portrait {
  position: relative; margin: 0; justify-self: end; width: 100%; max-width: 25rem;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: .75rem .75rem 0;
  box-shadow: 0 1px 0 var(--rule), 0 30px 60px -30px rgba(22, 20, 15, .3);
}
.portrait__frame {
  position: relative; aspect-ratio: 4 / 5; overflow: hidden;
  border-radius: 2px; background: var(--paper-2);
}
.portrait__frame img {
  width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%;
  filter: saturate(.7) contrast(1.03);
  transition: transform 1.2s var(--ease), filter .6s var(--ease);
}
/* warm wash ties the cool backdrop into the paper palette */
.portrait__frame::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(243, 222, 200, .16), rgba(22, 20, 15, .12));
  mix-blend-mode: multiply;
}
.portrait:hover .portrait__frame img { transform: scale(1.025); filter: saturate(.95) contrast(1.03); }
.portrait figcaption {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap;
  padding: .9rem .1rem 1rem;
  font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}

/* ---------- metrics: three equal boxed cells ---------- */
.metrics { margin-top: clamp(3rem, 7vw, 5rem); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.metrics__row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric { padding: 2.25rem 1.75rem; display: flex; flex-direction: column; gap: .5rem; border-left: 1px solid var(--rule); }
.metric:last-child { border-right: 1px solid var(--rule); }
.metric__n { font-family: var(--serif); font-size: clamp(2.75rem, 5vw, 4rem); line-height: 1; letter-spacing: -.03em; font-weight: 400; }
.metric__l { font-size: .9rem; color: var(--muted); line-height: 1.4; }

/* ---------- sections ---------- */
.section { padding-block: clamp(4.5rem, 10vw, 8rem); }
.section--tint { background: var(--paper-2); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr); gap: clamp(2rem, 5vw, 5rem); }
.section__head { align-self: start; position: sticky; top: 6rem; }
.section__head h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(2.25rem, 4vw, 3.25rem); line-height: 1.02; letter-spacing: -.03em; margin-top: .75rem; }
.section__note { margin-top: 1rem; color: var(--muted); font-size: .95rem; max-width: 16rem; }
.idx { font-family: var(--mono); font-size: .75rem; color: var(--accent); letter-spacing: .05em; }

.lead { font-family: var(--serif); font-size: clamp(1.5rem, 2.6vw, 2.1rem); line-height: 1.3; letter-spacing: -.015em; font-weight: 300; }
.lead em { font-style: italic; color: var(--accent); }
.prose { margin-top: 2rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem 2.5rem; color: var(--ink-2); }

.facts { margin: 3rem 0 0; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--ink); }
.facts div { padding: 1.1rem 1rem 1.1rem 0; border-bottom: 1px solid var(--rule); }
.facts dt { font-family: var(--mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.facts dd { margin: .3rem 0 0; font-size: .98rem; word-break: break-word; }
.facts a { text-decoration: none; background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat; transition: background-size .3s var(--ease); }
.facts a:hover { background-size: 100% 1px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips span {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .02em;
  padding: .3rem .6rem; border: 1px solid var(--rule); border-radius: 999px; color: var(--ink-2);
  background: var(--card);
}
.chips--lg span { font-size: .8rem; padding: .5rem .9rem; transition: border-color .2s, color .2s; }
.chips--lg span:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- experience log ---------- */
.log { border-top: 1px solid var(--ink); }
.log__item { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 2rem; padding-block: 2.25rem; border-bottom: 1px solid var(--rule); }
.log__when { color: var(--muted); padding-top: .45rem; }
.log__what h3 { font-family: var(--serif); font-size: 1.6rem; line-height: 1.2; letter-spacing: -.015em; font-weight: 400; }
.log__what .at { display: block; font-family: var(--sans); font-size: .95rem; color: var(--accent); margin-top: .3rem; letter-spacing: 0; }
.log__what ul { margin-block: 1.1rem 1.25rem; display: grid; gap: .7rem; }
.log__what li { position: relative; padding-left: 1.4rem; color: var(--ink-2); font-size: 1rem; }
.log__what li::before { content: ""; position: absolute; left: 0; top: .78em; width: .7rem; height: 1px; background: var(--accent); }
.log__what li strong { color: var(--ink); font-weight: 600; }
.log__item .chips span { background: transparent; }

.log__note { margin-top: 1rem; color: var(--ink-2); font-size: 1rem; }
.log__note + .chips { margin-top: 1.25rem; }
.log__what h3 + .chips { margin-top: 1.25rem; }
.section--ruled { border-top: 1px solid var(--rule); }

/* ---------- references ---------- */
.refs { border-top: 1px solid var(--ink); counter-reset: ref; }
.ref { display: grid; grid-template-columns: 3.5rem minmax(0, 1fr); gap: 1rem; padding-block: 2.25rem; border-bottom: 1px solid var(--rule); transition: background-color .3s; }
.ref__n { color: var(--accent); font-size: .9rem; padding-top: .2rem; }
.ref__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: .75rem; color: var(--muted); }
.ref h3 { font-family: var(--serif); font-size: clamp(1.3rem, 2.2vw, 1.65rem); line-height: 1.25; font-weight: 400; letter-spacing: -.015em; }
.ref p { margin-top: .85rem; color: var(--ink-2); max-width: 46rem; }
.ref b { font-weight: 600; color: var(--ink); }
.tag {
  font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .04em;
  padding: .25rem .55rem; border-radius: 2px; border: 1px solid var(--ink); color: var(--ink);
}
.tag--hot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- projects (inverted block) ---------- */
.section--ink { background: var(--inv-bg); color: var(--inv-text); border-top: 1px solid var(--rule); }
.section__head--row { position: static; display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem; flex-wrap: wrap; margin-bottom: 3rem; }
.section--ink .chips span { background: transparent; border-color: var(--inv-rule); color: var(--inv-muted); }

.filters { display: inline-flex; padding: .3rem; border: 1px solid var(--inv-rule); border-radius: 999px; gap: .2rem; flex-wrap: wrap; }
.filters button {
  background: transparent; border: 0; cursor: pointer; color: var(--inv-muted);
  font-family: var(--mono); font-size: .75rem; text-transform: uppercase; letter-spacing: .03em;
  padding: .55rem 1rem; border-radius: 999px; transition: background-color .2s, color .2s;
}
.filters button:hover { color: var(--inv-text); }
.filters button.is-on { background: var(--inv-text); color: var(--inv-bg); }

.projects { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--inv-rule); border-left: 1px solid var(--inv-rule); }
.projects > .proj { border-right: 1px solid var(--inv-rule); border-bottom: 1px solid var(--inv-rule); }
.proj--wide { grid-column: span 2; }
.proj--wide p { max-width: 40rem; }
.proj {
  position: relative; background: var(--inv-bg); padding: 2rem 1.75rem;
  display: flex; flex-direction: column; gap: 1rem; min-height: 22rem;
  transition: background-color .35s var(--ease), opacity .35s, transform .35s var(--ease);
}
.proj:hover { background: var(--inv-card); }
.proj::after {
  content: ""; position: absolute; left: 0; top: 0; height: 2px; width: 0; background: var(--accent);
  transition: width .5s var(--ease);
}
.proj:hover::after { width: 100%; }
.proj__top { display: flex; justify-content: space-between; color: var(--inv-muted); font-size: .7rem; }
.proj h3 { font-family: var(--serif); font-size: 2rem; font-weight: 400; letter-spacing: -.02em; line-height: 1.1; margin-top: .5rem; }
.proj p { color: var(--inv-muted); font-size: .95rem; line-height: 1.6; }
.proj__stat { margin-top: auto; font-size: .9rem; color: var(--inv-muted); padding-top: 1rem; border-top: 1px dashed var(--inv-rule); }
.proj__stat b { color: var(--accent); font-weight: 600; }
.proj.is-hidden { display: none; }
.proj--link { text-decoration: none; color: var(--inv-text); }
.proj__go { color: var(--accent); transition: transform .3s var(--ease); }
.proj--link:hover .proj__go { transform: translate(2px, -2px); }
.proj--more { text-decoration: none; justify-content: flex-end; color: var(--inv-text); }
.proj--more .mono { color: var(--accent); }
.proj--more h3 { font-style: italic; }

/* ---------- toolkit ---------- */
.stack { display: grid; gap: 0; border-top: 1px solid var(--ink); }
.stack__row { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 2rem; align-items: center; padding-block: 1.5rem; border-bottom: 1px solid var(--rule); }
.stack__row h3 { color: var(--muted); font-weight: 400; }

/* ---------- contact ---------- */
.contact { padding-block: clamp(5rem, 12vw, 9rem); background: var(--paper-2); border-top: 1px solid var(--rule); }
.contact__title { font-family: var(--serif); font-weight: 400; font-size: clamp(2.75rem, 8vw, 6.5rem); line-height: .98; letter-spacing: -.04em; margin-top: 1.5rem; }
.contact__title em { font-style: italic; font-weight: 300; color: var(--accent); }
.contact__lede { margin-top: 1.75rem; color: var(--ink-2); max-width: 32rem; font-size: 1.1rem; }
.contact__mail {
  display: inline-flex; align-items: center; gap: 1rem; margin-top: 2.5rem;
  font-family: var(--serif); font-size: clamp(1.4rem, 4vw, 2.6rem); letter-spacing: -.02em;
  text-decoration: none; padding-bottom: .35rem; border-bottom: 2px solid var(--ink);
  transition: color .25s, border-color .25s; word-break: break-all;
}
.contact__mail span { transition: transform .3s var(--ease); }
.contact__mail:hover { color: var(--accent); border-color: var(--accent); }
.contact__mail:hover span { transform: translateX(6px); }
.contact__links { margin-top: 4rem; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--ink); }
.contact__links li { display: flex; flex-direction: column; gap: .35rem; padding: 1.25rem 1rem 1.25rem 0; }
.contact__links li + li { padding-left: 1rem; border-left: 1px solid var(--rule); }
.contact__links .mono { color: var(--muted); font-size: .7rem; }
.contact__links a { text-decoration: none; }
.contact__links a:hover { color: var(--accent); }

/* ---------- footer ---------- */
.foot { padding-block: 1.75rem calc(1.75rem + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--rule); color: var(--muted); font-size: .9rem; }
.foot__row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.foot a { text-decoration: none; }
.foot a:hover { color: var(--accent); }

/* ---------- reveal ---------- */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }

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

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .projects { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .menu-btn { display: grid; }
  .nav {
    position: fixed; inset: calc(4.25rem + env(safe-area-inset-top, 0px)) 0 auto 0;
    flex-direction: column; gap: 0; margin: 0;
    background: var(--paper); border-bottom: 1px solid var(--rule);
    padding: .5rem var(--gutter) 1.25rem;
    transform: translateY(-.5rem); opacity: 0; visibility: hidden;
    transition: opacity .25s, transform .25s var(--ease), visibility .25s;
  }
  .nav.is-open { opacity: 1; transform: none; visibility: visible; }
  .nav a { font-family: var(--serif); font-size: 1.6rem; padding: .75rem 0; border-radius: 0; border-bottom: 1px solid var(--rule); background: none !important; }
  .nav a span { font-size: .7rem; }
  .bar__tools { margin-left: auto; }

  .hero__grid { grid-template-columns: 1fr; }
  .portrait { justify-self: start; max-width: 20rem; }

  .split { grid-template-columns: 1fr; }
  .section__head { position: static; }
  .prose { grid-template-columns: 1fr; }
  .contact__links { grid-template-columns: repeat(2, 1fr); }
  .contact__links li:nth-child(3) { padding-left: 0; border-left: 0; }
  .contact__links li:nth-child(n+3) { border-top: 1px solid var(--rule); }
}

@media (max-width: 640px) {
  .mark__name { display: none; }
  .projects { grid-template-columns: 1fr; }
  .proj { min-height: 0; }
  .proj--wide { grid-column: auto; }
  .log__item, .stack__row { grid-template-columns: 1fr; gap: .75rem; }
  .log__when { padding-top: 0; }
  .facts { grid-template-columns: 1fr; }
  .ref { grid-template-columns: 1fr; gap: .5rem; }
  .portrait { max-width: 17rem; }
  .metric { padding: 1.5rem .85rem; }
  .metric__l { font-size: .8rem; }
}
