/* ==========================================================================
   Devansh Kumar Tripathi — site styles
   Theme: "notebook at night"
   Edit colours in :root below if you ever want to change the palette.
   ========================================================================== */

:root {
  /* --- palette ------------------------------------------------------- */
  --ink:        #0b0c0e;   /* page background        */
  --ink-soft:   #101216;   /* raised panels          */
  --chalk:      #e9e5dc;   /* primary text (warm)    */
  --dim:        #98938a;   /* secondary text         */
  --faint:      #63605a;   /* metadata, labels       */
  --gold:       #d0a24c;   /* the single accent      */
  --gold-soft:  rgba(208, 162, 76, 0.55);
  --cyan:       #4f9d9d;   /* second accent, used in the Gauss figure */
  --rule:       rgba(233, 229, 220, 0.10);
  --rule-soft:  rgba(233, 229, 220, 0.055);

  /* --- type ---------------------------------------------------------- */
  --serif: "EB Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono:  "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  /* --- measure ------------------------------------------------------- */
  --measure: 40rem;      /* prose column          */
  --wide:    64rem;      /* page container        */
  --gutter:  1.5rem;
}

/* ==========================================================================
   Reset
   ========================================================================== */

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

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

body {
  margin: 0;
  background: var(--ink);
  color: var(--chalk);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.72;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }

figure, blockquote, dl, dd { margin: 0; }

table { border-collapse: collapse; }

/* ==========================================================================
   The lattice — a fixed, very faint dotted ground plane.
   Visible if you look for it; invisible if you are reading.
   Raise --lattice-strength a touch if your screen is dim.
   ========================================================================== */

body::before {
  content: "";
  position: fixed;
  inset: -2px;
  z-index: -2;
  background-image: radial-gradient(circle at center,
                    rgba(233, 229, 220, 0.62) 1.1px, transparent 1.2px);
  background-size: 34px 34px;
  opacity: 0.075;
  pointer-events: none;
}

/* soft vignette so the lattice never reaches the page edges hard */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 30%,
              transparent 40%, rgba(11, 12, 14, 0.82) 100%);
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--wide);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.prose { max-width: var(--measure); }

main { display: block; min-height: 60vh; }

.page-head { padding: 5rem 0 3rem; }
.section    { padding: 3.25rem 0; }
.section + .section { border-top: 1px solid var(--rule-soft); }

/* ==========================================================================
   Header / navigation
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 12, 14, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.75rem;
}

.brand {
  font-family: var(--serif);
  font-size: 1.0625rem;
  letter-spacing: 0.06em;
  color: var(--chalk);
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--gold); }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
}

.nav a {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--dim);
  text-decoration: none;
  padding: 0.35rem 0;
  transition: color 0.25s ease;
}
.nav a:hover { color: var(--chalk); }
.nav a[aria-current="page"] { color: var(--gold); }

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4 {
  font-weight: 400;
  line-height: 1.16;
  margin: 0 0 0.5rem;
  letter-spacing: -0.012em;
}

h1 {
  font-size: clamp(2.6rem, 6.2vw, 4.25rem);
  letter-spacing: -0.025em;
}

h2 { font-size: clamp(1.5rem, 3vw, 1.9rem); }
h3 { font-size: 1.25rem; }

p { margin: 0 0 1.15rem; }
p:last-child { margin-bottom: 0; }

.lede {
  font-style: italic;
  color: var(--dim);
  font-size: 1.16rem;
  margin-bottom: 1.75rem;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 1.75rem;
  display: block;
}

.meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--faint);
}

.dim { color: var(--dim); }

/* ==========================================================================
   Links — underline draws in on hover
   ========================================================================== */

a { color: inherit; }

.link,
.prose a,
.entry-body a {
  color: var(--chalk);
  text-decoration: none;
  background-image: linear-gradient(var(--gold), var(--gold));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  padding-bottom: 1px;
  transition: background-size 0.35s cubic-bezier(0.33, 1, 0.68, 1),
              color 0.25s ease;
}
.link:hover,
.prose a:hover,
.entry-body a:hover {
  background-size: 100% 1px;
  color: var(--gold);
}

/* permanently underlined, for file links */
.link-file {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 2px;
  white-space: nowrap;
  transition: color 0.25s ease, border-color 0.25s ease;
}
.link-file:hover { color: var(--gold); border-bottom-color: var(--gold-soft); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ==========================================================================
   Hero (home page)
   ========================================================================== */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  gap: 3rem;
  align-items: center;
  padding: 5.5rem 0 4.5rem;
}

.hero-name { margin-bottom: 0.75rem; }

.hero-copy p { max-width: 34rem; }

/* the figure panel masks the lattice out behind the circle */
.hero-figure {
  position: relative;
  justify-self: center;
  width: 100%;
  max-width: 22rem;
  aspect-ratio: 1 / 1;
}

.hero-figure::before {
  content: "";
  position: absolute;
  inset: -14%;
  background: radial-gradient(circle at center,
              var(--ink) 0%, var(--ink) 62%, rgba(11, 12, 14, 0) 86%);
  pointer-events: none;
}

#residue-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.figure-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1.9rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  color: var(--faint);
  transition: opacity 0.6s ease;
}

/* ==========================================================================
   Lists — interests
   ========================================================================== */

.interests {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}
.interests li { color: var(--dim); }
.interests li::before {
  content: "·";
  color: var(--gold);
  margin-right: 0.6rem;
}

/* ==========================================================================
   Entry lists (writing, explorations)
   ========================================================================== */

.entries { display: grid; gap: 2.5rem; }

.entry { max-width: var(--measure); }

.entry-kicker {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
  display: block;
  margin-bottom: 0.5rem;
}

.entry-title {
  font-size: 1.4rem;
  margin-bottom: 0.4rem;
}

.entry-title a {
  text-decoration: none;
  background-image: linear-gradient(var(--gold), var(--gold));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  transition: background-size 0.35s cubic-bezier(0.33, 1, 0.68, 1), color 0.25s;
}
.entry-title a:hover { background-size: 100% 1px; color: var(--gold); }

.entry-summary {
  color: var(--dim);
  font-size: 1.02rem;
  line-height: 1.66;
  margin-bottom: 0.5rem;
}

.entries--ruled .entry + .entry,
.entry-rule { border-top: 1px solid var(--rule-soft); padding-top: 2.5rem; }

/* short exploration notes */
.note { max-width: var(--measure); }
.note h3 { font-size: 1.12rem; color: var(--chalk); margin-bottom: 0.65rem; }
.note p  { color: var(--dim); font-size: 1.02rem; line-height: 1.68; }

/* ==========================================================================
   Tables — handouts, mock tests
   ========================================================================== */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.file-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

.file-table caption {
  text-align: left;
  color: var(--dim);
  font-size: 0.98rem;
  padding-bottom: 1rem;
  line-height: 1.6;
}

.file-table th {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
  text-align: left;
  padding: 0 0 0.7rem;
  border-bottom: 1px solid var(--rule);
}

.file-table td {
  padding: 0.85rem 1rem 0.85rem 0;
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: top;
}
.file-table td:last-child, .file-table th:last-child { padding-right: 0; }

.file-table tr:hover td { background: rgba(233, 229, 220, 0.018); }

.col-date { color: var(--dim); font-family: var(--mono); font-size: 0.76rem; white-space: nowrap; }
.col-file { text-align: right; white-space: nowrap; }

.file-note {
  display: block;
  color: var(--faint);
  font-size: 0.9rem;
  font-style: italic;
  margin-top: 0.2rem;
  line-height: 1.5;
}

/* ==========================================================================
   Reading list
   ========================================================================== */

.books { display: grid; gap: 2.25rem; max-width: var(--measure); }

.book-title {
  font-style: italic;
  font-size: 1.2rem;
  margin-bottom: 0.15rem;
}

.book-author {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--faint);
  margin-bottom: 0.6rem;
}

.book p { color: var(--dim); font-size: 1.02rem; line-height: 1.68; margin: 0; }

/* ==========================================================================
   About page
   ========================================================================== */

.about-grid {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: 3rem;
  align-items: start;
}

.portrait {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  border: 1px solid var(--rule);
  background: var(--ink-soft);
  overflow: hidden;
  filter: grayscale(100%) contrast(1.02);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; }

.portrait-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  line-height: 1.8;
  color: var(--faint);
}

.subhead {
  font-style: italic;
  font-size: 1.22rem;
  color: var(--chalk);
  margin: 2.5rem 0 0.75rem;
}

/* document / download rows */
.docs { display: grid; gap: 0; max-width: var(--measure); }

.doc-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--rule-soft);
}
.doc-row:first-child { border-top: 1px solid var(--rule); }

.doc-name { font-size: 1.04rem; }
.doc-desc { display: block; color: var(--faint); font-size: 0.9rem; font-style: italic; line-height: 1.5; margin-top: 0.15rem; }

/* ==========================================================================
   Long-form post body + mathematics
   ========================================================================== */

.entry-body { max-width: var(--measure); font-size: 1.14rem; }

.entry-body h2 {
  font-size: 1.5rem;
  margin-top: 2.75rem;
  margin-bottom: 0.9rem;
}

.entry-body h3 { margin-top: 2rem; font-size: 1.2rem; }

.entry-body blockquote {
  margin: 1.75rem 0;
  padding-left: 1.25rem;
  border-left: 1px solid var(--gold-soft);
  color: var(--dim);
  font-style: italic;
}

.entry-body ul, .entry-body ol { padding-left: 1.3rem; color: var(--chalk); }
.entry-body li { margin-bottom: 0.5rem; }

.entry-body hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 3rem 0;
}

/* draft notice — delete the markup from the post once you have written it */
.editor-note {
  margin: 0 0 2.25rem;
  padding: 0.9rem 1.1rem;
  border: 1px dashed var(--gold-soft);
  border-radius: 2px;
  background: rgba(208, 162, 76, 0.045);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--dim);
}
.editor-note strong { color: var(--gold); font-weight: 400; letter-spacing: 0.08em; }

/* theorem environments */
.thm, .defn, .proof {
  margin: 1.75rem 0;
  padding: 0.15rem 0 0.15rem 1.25rem;
  border-left: 1px solid var(--rule);
}
.thm, .defn { border-left-color: var(--gold-soft); }

.thm-label, .defn-label, .proof-label {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  display: block;
  margin-bottom: 0.45rem;
}
.proof-label { color: var(--faint); }
.thm p, .defn p { font-style: italic; }
.proof p { color: var(--dim); }
.proof::after {
  content: "\25A1";
  display: block;
  color: var(--faint);
  margin-top: -0.6rem;
  text-align: right;
}

/* KaTeX tuning for a dark page */
.katex { font-size: 1.04em; }
.katex-display {
  margin: 1.75rem 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.25rem 0;
}

code, kbd, samp {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(233, 229, 220, 0.05);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  margin-top: 5rem;
  border-top: 1px solid var(--rule);
  padding: 2rem 0 3rem;
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
  justify-content: space-between;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}
.footer-links a { color: var(--dim); text-decoration: none; transition: color 0.25s ease; }
.footer-links a:hover { color: var(--gold); }

.copyright {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--faint);
}

/* ==========================================================================
   Scroll reveal
   ========================================================================== */

[data-reveal] {
  opacity: 0;
  transform: translateY(9px);
  transition: opacity 0.62s cubic-bezier(0.33, 1, 0.68, 1),
              transform 0.62s cubic-bezier(0.33, 1, 0.68, 1);
  will-change: opacity, transform;
}
[data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 62rem) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 3.5rem;
    padding: 3.5rem 0 3rem;
  }
  .hero-figure { order: -1; max-width: 17rem; }
  .about-grid { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
  .portrait { max-width: 12rem; }
}

@media (max-width: 44rem) {
  :root { --gutter: 1.25rem; }
  body { font-size: 1.0625rem; }
  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-height: 0;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    gap: 0.35rem;
  }
  .brand { font-size: 0.95rem; letter-spacing: 0.04em; }
  .nav { gap: 1.05rem; }
  .nav a { font-size: 0.66rem; padding: 0.15rem 0; }
  .page-head { padding: 3rem 0 2rem; }
  .section { padding: 2.5rem 0; }
  .file-table { font-size: 0.95rem; }
  .file-table td { padding-right: 0.6rem; }
  .col-date { font-size: 0.7rem; }
  .site-footer .container { flex-direction: column; align-items: flex-start; }
}

/* ==========================================================================
   Reduced motion — everything settles, nothing moves
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
}

/* ==========================================================================
   Print
   ========================================================================== */

@media print {
  body { background: #fff; color: #000; }
  body::before, body::after, .hero-figure, .site-header { display: none; }
  a { color: #000; }
}


/* ==========================================================================
   About page — sidebar column: portrait, then the Gauss sum figure
   ========================================================================== */

.about-side { align-self: start; }

.gauss-figure {
  margin-top: 2.25rem;
  display: block;
}

#gauss-canvas {
  display: block;
  width: 100%;
  height: 26rem;
}

.gauss-caption {
  display: block;
  margin-top: 1rem;
  font-family: var(--mono);
  font-size: 0.64rem;
  line-height: 1.85;
  letter-spacing: 0.02em;
  color: var(--faint);
}
.gauss-caption .katex { font-size: 0.95em; }

/* ==========================================================================
   Answer key grid
   ========================================================================== */

.key-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
  gap: 0;
  max-width: 46rem;
  border-top: 1px solid var(--rule);
}

.key-cell {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.7rem 0.5rem 0.7rem 0;
  border-bottom: 1px solid var(--rule-soft);
}

.key-n {
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--faint);
  min-width: 1.6rem;
  letter-spacing: 0.06em;
}

.key-v {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--chalk);
}
.key-cell .key-v:not(:empty) { letter-spacing: 0.02em; }

/* a file that exists but has no link yet */
.link-none {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  opacity: 0.55;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Below 62rem (tablets and phones) the Gauss sum figure is hidden entirely.
   The animation needs a tall, narrow column to read properly, and a phone
   does not have one to spare. The portrait stays.

   To bring the figure back on small screens, delete this whole block.
   -------------------------------------------------------------------------- */

@media (max-width: 62rem) {
  .gauss-figure { display: none; }

  /* the portrait no longer sits in its own column, so cap its width and let
     the biography run underneath it */
  .about-side { margin-bottom: 0.5rem; }
  .portrait { max-width: 11rem; }
}
