/* Hitesh Devjani: personal site.
   The page is set like a proposal under review. Serif is the document,
   sans is the review layer (navigation, comments, metadata), red is markup. */

@font-face { font-family: "Spectral"; src: url("fonts/spectral-300.woff2") format("woff2"); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: "Spectral"; src: url("fonts/spectral-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Spectral"; src: url("fonts/spectral-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Spectral"; src: url("fonts/spectral-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Mona Sans"; src: url("fonts/mona-sans-200-900.woff2") format("woff2"); font-weight: 200 900; font-stretch: 75% 125%; font-style: normal; font-display: swap; }
@font-face { font-family: "HD Signature"; src: url("fonts/signature.woff2") format("woff2"); font-display: block; }

:root {
  --paper: #ffffff;
  --ink: #000000;
  --ink-2: #555555;
  --rule: #d9d9d9;
  --red: #b3261e;
  --red-wash: rgb(179 38 30 / 0.08);
  --red-wash-strong: rgb(179 38 30 / 0.16);

  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --sans: "Mona Sans", "Helvetica Neue", Arial, sans-serif;

  --measure: 40rem;          /* the document column, about 66 characters of body text */
  --gutter: 3rem;            /* space between the document and the comment margin */
  --rail: 15rem;             /* the comment margin */
  --pad: clamp(1.25rem, 4vw, 3rem);
  --masthead: 3.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1e1e1e;
    --ink: #f2f2f2;
    --ink-2: #b3b3b3;
    --rule: #3d3d3d;
    --red: #ff8077;
    --red-wash: rgb(255 128 119 / 0.13);
    --red-wash-strong: rgb(255 128 119 / 0.24);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--masthead) + 1.5rem);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.65;
  font-variant-numeric: proportional-nums;
  font-kerning: normal;
}

p, ul, ol, dl, h1, h2, h3, table { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p, li, dd { text-wrap: pretty; }

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover { text-decoration-thickness: 2px; }

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  z-index: 20;
  top: -4rem;
  left: var(--pad);
  padding: 0.6rem 0.9rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 0.875rem;
  text-decoration: none;
}

.skip:focus { top: 0.75rem; }

/* Layout: one document column; on wide screens the comment margin sits to its right. */

.masthead-inner,
.hero,
.section,
.colophon {
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--pad));
  margin-inline: auto;
  padding-inline: var(--pad);
}

@media (min-width: 70rem) {
  .masthead-inner,
  .hero,
  .section,
  .colophon {
    max-width: calc(var(--measure) + var(--gutter) + var(--rail) + 2 * var(--pad));
  }

  .hero,
  .section,
  .colophon {
    padding-right: calc(var(--gutter) + var(--rail) + var(--pad));
  }
}

/* Masthead */

.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.masthead-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: var(--masthead);
}

.wordmark {
  margin-right: auto;
  font-size: 1.125rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.masthead nav {
  display: flex;
  gap: 1.5rem;
  font-family: var(--sans);
  font-size: 0.875rem;
}

.masthead nav a {
  color: var(--ink-2);
  text-decoration: none;
}

.masthead nav a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.markup-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  white-space: nowrap;
  cursor: pointer;
}

.markup-toggle input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--red);
  cursor: pointer;
}

@media (max-width: 34rem) {
  .masthead-inner,
  .masthead nav { gap: 1rem; }
  .masthead nav a[href="#experience"] { display: none; }
}

@media (max-width: 22rem) {
  .masthead nav { display: none; }
}

/* Comments: the review layer. Inline notes on narrow screens, the margin on wide ones. */

.has-comment { position: relative; }

.comment {
  display: block;
  margin-top: 0.85rem;
  padding: 0.35rem 0.5rem 0.4rem 0.8rem;
  border-left: 2px solid var(--red);
  font-family: var(--sans);
  font-size: 0.875rem;
  font-style: normal;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0;
  color: var(--ink);
  text-align: left;
  white-space: normal;
  transition: background-color 150ms ease;
}

.comment-author {
  display: block;
  margin-bottom: 0.15rem;
  color: var(--red);
  font-weight: 600;
}

mark {
  background: var(--red-wash);
  color: inherit;
  padding: 0 0.08em;
  margin: 0 -0.08em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-color 150ms ease;
}

.has-comment:has(mark:hover) .comment,
.has-comment:has(.comment:hover) .comment { background: var(--red-wash); }

.has-comment:has(.comment:hover) mark { background: var(--red-wash-strong); }

@media (min-width: 70rem) {
  .comment {
    position: absolute;
    top: 0;
    left: calc(100% + var(--gutter));
    width: var(--rail);
    margin-top: 0;
  }

  .comment::before {
    content: "";
    position: absolute;
    top: 0.95em;
    right: calc(100% + 2px);
    width: calc(var(--gutter) - 0.75rem);
    border-top: 1px dotted var(--red);
  }
}

/* Hero: the one tracked change on the page. */

.hero {
  padding-top: clamp(3rem, 13vh, 8rem);
}

.display {
  font-weight: 300;
  font-size: clamp(2.75rem, 1.6rem + 4.6vw, 5.25rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  font-variant-numeric: lining-nums;
}

/* Word's change bar: a rule in the margin beside any line that carries a change. */
.changed { position: relative; }

.changed::before {
  content: "";
  position: absolute;
  top: 0.1em;
  bottom: 0.06em;
  left: calc(-1 * min(1.5rem, var(--pad) - 0.4rem));
  width: 2px;
  background: var(--red);
}

.redline del {
  position: relative;
  color: var(--red);
  text-decoration: none;
}

.redline del::after {
  content: "";
  position: absolute;
  left: -0.03em;
  right: -0.03em;
  top: 0.8em;
  height: max(2px, 0.045em);
  background: currentColor;
  transform-origin: 0 50%;
}

.redline ins {
  color: var(--red);
  text-decoration: underline;
  text-decoration-thickness: max(2px, 0.045em);
  text-underline-offset: 0.11em;
  text-decoration-skip-ink: none;
}

/* Runs once on load, only if the page was visible then (html.animate, set in the head).
   Without it, the finished change shows. */
@media (prefers-reduced-motion: no-preference) {
  .animate .redline del::after { animation: strike 560ms cubic-bezier(0.65, 0, 0.25, 1) 450ms both; }
  .animate .redline ins {
    display: inline-block;
    animation: insert 640ms cubic-bezier(0.65, 0, 0.25, 1) 900ms both;
  }
  .animate .changed::before { animation: appear 240ms ease-out 900ms both; }
}

@keyframes strike {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes insert {
  from { clip-path: inset(-0.25em 100% -0.35em 0); }
  to { clip-path: inset(-0.25em -0.1em -0.35em 0); }
}

@keyframes appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lede {
  margin-top: 2.25rem;
  font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  line-height: 1.5;
}

.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2.25rem;
}

.button {
  display: inline-block;
  padding: 0.85rem 1.15rem;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
}

.button:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}

.button-primary {
  background: var(--ink);
  color: var(--paper);
}

/* Markup off: the clean copy. */

[data-markup="off"] .redline del,
[data-markup="off"] .comment,
[data-markup="off"] .changed::before { display: none; }

[data-markup="off"] .redline ins {
  color: inherit;
  text-decoration: none;
  animation: none;
  clip-path: none;
}

[data-markup="off"] mark { background: none; }

/* Sections */

.section {
  padding-top: clamp(4rem, 9vw, 7rem);
}

.section h2 {
  margin-bottom: 1.75rem;
  font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.25rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.section-intro {
  margin-bottom: 1.25rem;
  color: var(--ink-2);
}

/* What I price: a schedule of terms. */

.schedule > div {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: 0.25rem 1.5rem;
  padding-block: 1rem;
  border-top: 1px solid var(--rule);
}

.schedule > div:last-child { border-bottom: 1px solid var(--rule); }

.schedule dt {
  padding-top: 0.3rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink-2);
}

.schedule dd { margin: 0; }

@media (max-width: 34rem) {
  .schedule > div { grid-template-columns: minmax(0, 1fr); }
  .schedule dt { padding-top: 0; }
}

/* Track record */

.figures {
  width: 100%;
  border-collapse: collapse;
}

.figures th,
.figures td {
  padding-block: 0.85rem;
  border-top: 1px solid var(--rule);
  text-align: left;
  vertical-align: baseline;
}

.figures tr:last-child > * { border-bottom: 1px solid var(--rule); }

.figures th {
  width: 12rem;
  padding-right: 1.5rem;
  font-size: 1.625rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
  font-variant-numeric: lining-nums tabular-nums;
}

@media (max-width: 34rem) {
  .figures th,
  .figures td { display: block; }
  .figures th {
    width: auto;
    padding-bottom: 0.1rem;
  }
  .figures td {
    padding-top: 0;
    border-top: 0;
  }
  .figures tr:last-child > th { border-bottom: 0; }
}

/* Experience */

.role + .role { margin-top: 3.25rem; }

.role-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
}

.role h3 {
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.3;
}

.role-dates {
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--ink-2);
}

.role-title {
  margin-top: 0.1rem;
  font-style: italic;
}

.role ul {
  margin-top: 1rem;
  padding-left: 1.25em;
  list-style-type: "–";
}

.role li { padding-left: 0.6em; }
.role li + li { margin-top: 0.55rem; }
.role li::marker { color: var(--ink-2); }

/* Education and recognition */

.credits {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 2.5rem 3rem;
}

.credits h3 {
  margin-bottom: 0.75rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-2);
}

.credits h3:not(:first-child) { margin-top: 2rem; }

.plain {
  padding: 0;
  list-style: none;
}

.plain li + li { margin-top: 0.9rem; }

.item-title {
  display: block;
  line-height: 1.45;
}

.item-meta {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--ink-2);
}

/* Contact: the signature page. */

.contact-list {
  margin-top: 1.75rem;
  padding: 0;
  list-style: none;
}

.contact-list li {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 1rem;
  padding-block: 0.7rem;
  border-top: 1px solid var(--rule);
  overflow-wrap: anywhere;
}

.contact-list li:last-child { border-bottom: 1px solid var(--rule); }

.contact-label {
  padding-top: 0.3rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--ink-2);
}

.signature {
  width: min(20rem, 100%);
  margin-top: 4rem;
}

.signature-mark {
  display: block;
  padding: 0 0 0.1rem 0.4rem;
  border-bottom: 1px solid var(--ink);
  font-family: "HD Signature", cursive;
  font-size: 3.5rem;
  font-weight: 400;
  line-height: 1.15;
}

.signature-name {
  margin-top: 0.6rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink-2);
}

.colophon {
  padding-block: clamp(4rem, 9vw, 6rem) 3rem;
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--ink-2);
}

@media (max-width: 34rem) {
  body { font-size: 1.125rem; }
  .contact-list li { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .contact-label { padding-top: 0; }
}

@media print {
  .masthead, .skip, .cta { display: none !important; }
  body { font-size: 10.5pt; color: #000; background: #fff; }
  .hero { padding-top: 0; }
  .section { padding-top: 2rem; }
  .comment { position: static; width: auto; margin-top: 0.4rem; }
  .comment::before { display: none; }
  .role { break-inside: avoid; }
  .contact-list a[href^="http"]::after { content: " (" attr(href) ")"; }
}
