/* ------------------------------------------------------------------
   rushilsaraf — site stylesheet

   One file for every page. Newsreader (self-hosted, variable, with
   optical sizes) sets the text; the system sans is used for controls
   and the system mono for code, so each reads as what it is.
   ------------------------------------------------------------------ */

@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/assets/fonts/newsreader-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url("/assets/fonts/newsreader-italic-latin.woff2") format("woff2");
}

:root {
  color-scheme: light dark;

  --paper:  #f7f5ef;
  --ink:    #1a1815;
  --text:   #2b2824;
  --muted:  #6e685f;
  --faint:  #776f65;
  --line:   #e1dcd2;
  --rule:   #cdc7bb;
  --well:   #efece5;
  --accent: #2c4e8f;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans:  system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:  ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --measure: 42rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:  #171614;
    --ink:    #ece8e0;
    --text:   #d5d0c7;
    --muted:  #a39d93;
    --faint:  #8a847a;
    --line:   #2c2a27;
    --rule:   #403d38;
    --well:   #211f1c;
    --accent: #9db8ea;
  }
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font: 400 1.125rem/1.55 var(--serif);
  font-optical-sizing: auto;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

img, video, iframe { max-width: 100%; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
a:hover { color: var(--accent); text-decoration-color: currentColor; }

h1, h2, h3 {
  margin: 0;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.005em;
  text-wrap: balance;
}
p { margin: 0 0 1.1em; text-wrap: pretty; }

::selection { background: rgba(44, 78, 143, 0.18); }

/* ---------- page frame ---------- */

/* The character field (ascii.js) sits on a fixed canvas under everything;
   page content is lifted above it. */
.ascii-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.ascii-bg.on { opacity: 1; }

.page {
  position: relative;
  z-index: 1;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.25rem;
}
.page--wide { max-width: 60rem; }

/* ---------- header ---------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-top: 2rem;
}
.wordmark {
  font-weight: 500;
  font-size: 1.125rem;
  color: var(--ink);
  text-decoration: none;
}
a.wordmark:hover { color: var(--accent); }

.site-nav {
  display: flex;
  gap: 1.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 1rem;
}
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--accent); }

/* The home page's header is the masthead: the name is set large. */
.masthead { padding-top: 3.25rem; }
.masthead .wordmark {
  font-size: clamp(2.6rem, 6.5vw, 3.5rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* ---------- home: intro ---------- */

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem 3rem;
  align-items: start;
  margin-top: 2.75rem;
}
.lede {
  font-size: 1.3rem;
  line-height: 1.45;
  color: var(--ink);
  margin-bottom: 1.1rem;
}
.contact { color: var(--muted); font-size: 1.05rem; }

.portrait {
  display: block;
  width: clamp(7rem, 20vw, 8.75rem);
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 4px;
}

@media (max-width: 40rem) {
  .intro { grid-template-columns: 1fr; gap: 1.5rem; margin-top: 2.25rem; }
  .portrait { order: -1; width: 6.5rem; }
}

/* ---------- sections ---------- */

.section { margin-top: 3.75rem; }
.section > h2 { font-size: 1.5rem; margin-bottom: 1rem; }

/* ---------- home: project list ---------- */

.projects {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.project {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
  padding: 1.6rem 0;
  border-bottom: 1px solid var(--line);
}
.project__thumb { display: block; }
.project__thumb img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: 3px;
  background: var(--well);
}
.project__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.project h3 { font-size: 1.3rem; }
.project h3 a { text-decoration: none; }
.project h3 a:hover { color: var(--accent); }
.project__year {
  flex: none;
  font-size: 0.95rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.project p { margin: 0.3rem 0 0; font-size: 1.05rem; line-height: 1.5; }
.project__links { margin-top: 0.55rem; font-size: 0.95rem; }
.project__links a { color: var(--muted); text-decoration-color: var(--line); }
.project__links a:hover { color: var(--accent); }
.sep { margin: 0 0.5rem; color: var(--faint); }

@media (max-width: 40rem) {
  .project { grid-template-columns: 1fr; gap: 0.9rem; }
  .project__thumb { max-width: 12rem; }
}

/* ---------- articles ---------- */

.article-header { margin: 3.25rem 0 2.25rem; }
.article-header h1 {
  font-size: clamp(2.2rem, 6vw, 3rem);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.05;
  margin-bottom: 0.6rem;
}
.subtitle {
  margin: 0;
  font-size: 1.25rem;
  font-style: italic;
  line-height: 1.4;
  color: var(--muted);
}
.meta { margin: 0.8rem 0 0; font-size: 0.95rem; color: var(--faint); }
.meta a { color: var(--faint); }
.meta a:hover { color: var(--accent); }

.prose h2 { font-size: 1.55rem; margin: 2.6rem 0 0.8rem; }
.prose h2:first-child { margin-top: 0; }
.prose p { margin: 0 0 1.15em; }
.prose strong { font-weight: 600; color: var(--ink); }

.prose figure { margin: 2rem 0; }
.prose figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--line);
}
.prose figcaption { margin-top: 0.65rem; font-size: 0.95rem; color: var(--muted); }
.video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 4px;
  background: #000;
}

.prose pre {
  margin: 1.4rem 0;
  padding: 0.9rem 1.1rem;
  font: 0.85rem/1.55 var(--mono);
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--well);
  border-radius: 3px;
  padding: 0.08em 0.35em;
}
.prose pre code { font-size: inherit; background: none; padding: 0; }

.prose ul { margin: 0 0 1.15em; padding-left: 1.15rem; }
.prose li { margin-bottom: 0.7em; padding-left: 0.15rem; }
.prose li::marker { color: var(--faint); }

/* ---------- footer ---------- */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-top: 5rem;
  padding: 1.4rem 0 3rem;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  color: var(--faint);
}
.site-footer a { color: var(--faint); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* ---------- placeholder page ---------- */

.placeholder {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  max-width: 34rem;
  margin: 0 auto;
  padding: 3rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}
.placeholder h1 {
  font-size: clamp(2.2rem, 6vw, 3rem);
  font-weight: 400;
  letter-spacing: -0.015em;
  margin-bottom: 0.5rem;
}
.placeholder .subtitle { margin-bottom: 1.5rem; }
.placeholder p:last-child { margin: 0; color: var(--muted); }
