/* Farhang Jalali — one-page profile.
   Direction: an engineering title block. Deep blue ink sidebar with a faint
   sheet grid; warm paper content; serif display numerals; mono stationing. */

:root {
  --ink-deep: #0b1d31;
  --ink-blue: #10294a;
  --side-text: #eef3f9;
  --side-muted: #9fb4cc;
  --side-rule: rgba(159, 180, 204, 0.22);
  --side-glow: rgba(94, 160, 255, 0.28);
  --accent: #1f5fbf;
  --accent-soft: rgba(31, 95, 191, 0.12);
  --paper: #f8f6f1;
  --paper-deep: #efece4;
  --ink: #16202b;
  --body-ink: #3a4654;
  --muted: #6f7b89;
  --rule: #ddd8cd;
  --rule-strong: #c8c1b2;

  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p, ul, ol, dl, dd {
  margin: 0;
}

::selection {
  background: var(--accent);
  color: #ffffff;
}

a {
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;
}

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

/* ---------- Page-load reveal (CSS only, one orchestrated moment) ---------- */

.reveal {
  animation: rise 0.9s var(--ease) both;
}

.d1 { animation-delay: 0.08s; }
.d2 { animation-delay: 0.16s; }
.d3 { animation-delay: 0.26s; }
.d4 { animation-delay: 0.36s; }
.d5 { animation-delay: 0.46s; }

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Sidebar: the title block ---------- */

.sidebar {
  position: relative;
  isolation: isolate;
  background: var(--ink-blue);
  color: var(--side-text);
  padding: 44px 24px 40px;
  overflow: hidden;
}

/* Sheet grid: fine lines every 24px, a heavier line every 120px */
.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 24px 24px, 24px 24px, 120px 120px, 120px 120px;
  background-position: -1px -1px;
}

/* Depth: a cool glow from the upper left, darkening toward the foot */
.sidebar::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 70% at 0% 0%, var(--side-glow), transparent 60%),
    linear-gradient(180deg, transparent 40%, var(--ink-deep) 100%);
}

.sidebar-inner {
  position: relative;
}

.kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--side-muted);
}

.kicker-mark {
  width: 28px;
  height: 1px;
  background: var(--side-muted);
}

.sidebar h1 {
  margin-top: 22px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 2.5rem;
  line-height: 1.02;
  letter-spacing: -0.015em;
  font-variation-settings: "opsz" 144;
}

.sidebar h1 .degree {
  color: var(--side-muted);
  font-weight: 400;
  font-style: italic;
}

.sidebar .headline {
  margin-top: 18px;
  max-width: 34ch;
  color: var(--side-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

/* Stats as a title-block table: hairline rules between rows */
.stats {
  list-style: none;
  padding: 0;
  margin-top: 36px;
  border-top: 1px solid var(--side-rule);
}

.stats li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 0;
  border-bottom: 1px solid var(--side-rule);
}

.stats strong {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 2.35rem;
  line-height: 1;
  letter-spacing: -0.02em;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  font-variation-settings: "opsz" 144;
}

.stats .sup {
  font-size: 0.6em;
  vertical-align: 0.5em;
  color: #a9d2ff;
  font-weight: 500;
  margin-left: 0.05em;
}

.stats span:not(.sup) {
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--side-muted);
}

/* Contact links: key / value pairs, mono keys */
.links {
  margin-top: 34px;
  display: grid;
  gap: 12px;
}

.links a {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: baseline;
  gap: 12px;
  color: var(--side-text);
  font-size: 0.925rem;
  transition: color 0.25s var(--ease);
}

.link-key {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--side-muted);
}

.link-val {
  position: relative;
  padding-bottom: 1px;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-size: 0% 1px;
  background-position: 0 100%;
  transition: background-size 0.35s var(--ease);
}

.links a:hover {
  color: #ffffff;
}

.links a:hover .link-val,
.links a:focus-visible .link-val {
  background-size: 100% 1px;
}

.sidebar a:focus-visible {
  outline-color: var(--side-text);
}

/* ---------- Content: the sheet ---------- */

.content {
  position: relative;
  padding: 44px 24px 56px;
  max-width: 780px;
}

.block + .block {
  margin-top: 52px;
}

/* Numbered section heads with a hairline running out to the right */
.block h2 {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 22px;
}

.block h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule-strong);
}

.block h2 .num {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.block p,
.block li,
.block dd {
  color: var(--body-ink);
}

.lede {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.22rem;
  line-height: 1.5;
  color: var(--ink);
  font-variation-settings: "opsz" 24;
}

.lede::first-letter {
  font-size: 1.1em;
}

/* Competencies as a two-column list of short rules */
.grid-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0 32px;
}

.grid-list li {
  position: relative;
  padding: 9px 0 9px 20px;
  border-bottom: 1px solid var(--rule);
  font-size: 0.95rem;
  line-height: 1.5;
}

.grid-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.05em;
  width: 8px;
  height: 1px;
  background: var(--accent);
}

/* Bullets inside roles */
.role ul {
  list-style: none;
  padding: 0;
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.role li {
  position: relative;
  padding-left: 18px;
  font-size: 0.965rem;
}

.role li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.78em;
  width: 7px;
  height: 1px;
  background: var(--rule-strong);
}

/* ---------- Roles: stationed on a timeline ---------- */

.role {
  position: relative;
  padding: 0 0 0 18px;
  border-left: 1px solid var(--rule-strong);
}

.role + .role {
  margin-top: 30px;
}

/* Station tick at the role's start */
.role::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
}

.role.current {
  border-left-color: var(--accent);
}

.role.current::before {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.role .dates {
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.role.current .dates {
  color: var(--accent);
}

.role h3 {
  margin-top: 4px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.28rem;
  line-height: 1.25;
  letter-spacing: -0.005em;
  color: var(--ink);
  font-variation-settings: "opsz" 48;
}

.role .employer {
  margin-top: 3px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--muted);
}

.role .note {
  margin-top: 8px;
  font-size: 0.95rem;
}

/* Publications: numbered references */
.pubs {
  list-style: none;
  padding: 0;
  counter-reset: pub;
  display: grid;
  gap: 10px;
}

.pubs li {
  counter-increment: pub;
  position: relative;
  padding-left: 40px;
  font-size: 0.95rem;
}

.pubs li::before {
  content: "[" counter(pub) "]";
  position: absolute;
  left: 0;
  top: 0.15em;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.pubs em {
  font-style: italic;
}

/* Skills: label / value rows */
.skills {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--rule);
}

.skills dt {
  padding-top: 10px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
}

.skills dd {
  padding: 4px 0 10px;
  border-bottom: 1px solid var(--rule);
  font-size: 0.95rem;
}

/* Colophon: a closing title strip */
.colophon {
  margin-top: 64px;
  padding-top: 14px;
  border-top: 1px solid var(--rule-strong);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.colophon a {
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0.02em;
}

.colophon a:hover {
  color: var(--accent);
}

/* ---------- 404 page ---------- */

.notfound {
  min-height: 100vh;
  display: grid;
  place-content: center;
  padding: 40px 24px;
  text-align: center;
}

.notfound .code {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.notfound h1 {
  margin-top: 10px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 2.4rem;
  letter-spacing: -0.01em;
  color: var(--ink-blue);
}

.notfound p {
  margin-top: 16px;
}

/* ---------- Desktop: the split sheet ---------- */

@media (min-width: 900px) {
  .site {
    display: grid;
    grid-template-columns: minmax(360px, 39%) 1fr;
    min-height: 100vh;
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 72px 48px 56px;
    display: flex;
  }

  .sidebar-inner {
    margin-left: auto;
    width: 100%;
    max-width: 400px;
  }

  .sidebar h1 {
    font-size: 3rem;
  }

  /* Stats as a title-block table: numeral column, label column */
  .stats li {
    display: grid;
    grid-template-columns: minmax(104px, auto) 1fr;
    align-items: baseline;
    gap: 0 18px;
  }

  .content {
    padding: 72px 64px 72px;
  }

  .grid-list {
    grid-template-columns: 1fr 1fr;
  }

  /* Dates move into a left margin column, stationed beside the rule */
  .role {
    display: grid;
    grid-template-columns: 124px 1fr;
    gap: 0 20px;
    padding-left: 0;
    border-left: 0;
  }

  /* Centre the station tick on the role-body rule (column 2 start − 8px margin) */
  .role::before {
    left: 133px;
    top: 0.5em;
  }

  .role-body {
    border-left: 1px solid var(--rule-strong);
    padding-left: 22px;
    margin-left: -8px;
  }

  .role.current .role-body {
    border-left-color: var(--accent);
  }

  .role .dates {
    padding-top: 0.18em;
    text-align: right;
  }

  .role h3 {
    margin-top: 0;
  }

  .skills {
    grid-template-columns: max-content 1fr;
    gap: 0 28px;
  }

  .skills dt {
    padding: 10px 0;
    border-bottom: 1px solid var(--rule);
  }

  .skills dd {
    padding: 10px 0;
  }
}

@media (min-width: 1280px) {
  .content {
    padding: 88px 96px 88px 80px;
    max-width: 860px;
  }
}

/* ---------- Print ---------- */

@media print {
  @page {
    margin: 14mm 14mm;
  }

  body {
    font-size: 10.5pt;
    line-height: 1.45;
    color: #000000;
    background: #ffffff;
  }

  .reveal {
    animation: none;
  }

  .site {
    display: block;
    min-height: 0;
  }

  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
    background: #ffffff;
    color: #000000;
    padding: 0 0 12pt;
    border-bottom: 1px solid var(--rule-strong);
    display: block;
  }

  .sidebar::before,
  .sidebar::after {
    display: none;
  }

  .sidebar-inner {
    max-width: none;
    margin: 0;
  }

  .kicker,
  .kicker-mark,
  .sidebar h1,
  .sidebar h1 .degree,
  .sidebar .headline,
  .stats span,
  .stats strong,
  .stats .sup,
  .links a,
  .link-key {
    color: #000000;
    background: none;
  }

  .kicker-mark {
    background: #000000;
  }

  .stats {
    display: grid;
    grid-template-columns: repeat(3, auto);
    justify-content: start;
    gap: 0 28pt;
    margin-top: 12pt;
    border-top: 0;
  }

  .stats li {
    display: block;
    border-bottom: 0;
    padding: 0;
  }

  .stats strong {
    font-size: 16pt;
  }

  .links {
    margin-top: 10pt;
    display: flex;
    flex-wrap: wrap;
    gap: 0 18pt;
  }

  .links a {
    display: inline;
  }

  .link-key {
    display: none;
  }

  /* Print the target of external links */
  .links a[href^="http"] .link-val::after {
    content: " (" attr(href) ")";
  }

  .links a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 8.5pt;
    color: #333333;
  }

  .content {
    max-width: none;
    padding: 12pt 0 0;
  }

  .block + .block {
    margin-top: 16pt;
  }

  .block p,
  .block li,
  .block dd,
  .role h3,
  .lede {
    color: #000000;
  }

  .lede {
    font-size: 11.5pt;
  }

  .role h3,
  .role .employer,
  .block h2,
  .skills dt {
    break-after: avoid;
  }

  .role li,
  .skills dd,
  .pubs li {
    break-inside: avoid;
  }

  .colophon {
    display: none;
  }

  a {
    text-decoration: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
