/* ==========================================================================
   andreymakhanov.com — css/style.css
   Light-only academic document design. No dark mode, no toggles: the page
   renders the same in OS light and OS dark mode (color-scheme is pinned to
   light). Two-track layout: a 68rem page shell with a sticky section side
   nav above 1100px, and a 36rem prose measure. No decorative effects, no
   forced overrides, no icon glyphs in link text.
   ========================================================================== */

/* --- Fonts (self-hosted, Latin subset, swap) ------------------------------ */

@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter.woff2') format('woff2');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: 'Source Serif 4';
  src: url('../fonts/sourceserif4.woff2') format('woff2');
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
}

@font-face {
  font-family: 'Source Serif 4';
  src: url('../fonts/sourceserif4-italic.woff2') format('woff2');
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
}

/* --- Design tokens -------------------------------------------------------- */

:root {
  color-scheme: light;

  /* surfaces */
  --bg:          #FCFCFA;   /* warm off-white — the page */
  --bg-subtle:   #F5F4F1;   /* reserved for definition-list zebra; unused */

  /* ink */
  --ink:         #1A1A1A;   /* body text */
  --ink-muted:   #5A5F66;   /* metadata, dates, coauthors */
  --ink-faint:   #62676E;   /* captions, "last updated" — 5.55:1 on --bg */

  /* structural accent — UNC navy */
  --navy:        #13294B;   /* headings, links, section labels */
  --navy-hover:  #0B1A31;

  /* single decorative accent — Carolina blue, used twice on the page:
     the 2px rule under the name and the link hover underline */
  --accent:      #4B9CD3;

  /* rules — these MUST differ in weight */
  --rule-strong: #C9CCD1;   /* section header underline */
  --rule:        #E4E6E9;   /* entry dividers */

  /* typography */
  --font-serif: "Source Serif 4", "Source Serif Pro", Charter, Georgia, serif;
  --font-sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono:  "SF Mono", "IBM Plex Mono", Menlo, Consolas, monospace;

  /* layout */
  --container:   68rem;     /* ~1088px page shell */
  --prose:       36rem;     /* ~576px max running-prose measure */
  --rail:        10rem;     /* left metadata rail */
  --gutter:      2.5rem;
  --pad-inline:  clamp(1rem, 5vw, 3.5rem);   /* 1rem floor keeps the lede within ~85vh on phones */

  /* fluid scale */
  --fs-name:     clamp(1.875rem, 1.3rem + 2.2vw, 2.75rem);
  --fs-role:     clamp(1rem, 0.95rem + 0.3vw, 1.125rem);
  --fs-section:  0.75rem;   /* uppercase, letterspaced, fixed */
  --fs-title:    clamp(1.0625rem, 1rem + 0.4vw, 1.25rem);
  --fs-body:     clamp(1rem, 0.97rem + 0.15vw, 1.0625rem);
  --fs-meta:     0.8125rem;

  /* spacing scale — exactly eight values */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.75rem;
  --space-6: 2.75rem;
  --space-7: 4rem;
  --space-8: 6rem;
}

/* --- Base ------------------------------------------------------------------ */

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

html {
  background: var(--bg);
  color: var(--ink);
  font-size: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font: 400 var(--fs-body)/1.7 var(--font-serif);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

p {
  max-width: var(--prose);
  margin: 0 0 var(--space-4);
  overflow-wrap: break-word;
  hyphens: auto;
  text-wrap: pretty;
  hanging-punctuation: first last;
}

h1, h2, h3 {
  line-height: 1.25;
  font-weight: 600;
  margin: 0 0 var(--space-3);
  text-wrap: balance;
  hyphens: none;
}

h1 {
  font-family: var(--font-serif);
  font-size: var(--fs-name);
  letter-spacing: -0.02em;
  color: var(--navy);
  margin-bottom: var(--space-2);
  overflow-wrap: break-word;
}

h2 {
  position: relative;
  font: 600 var(--fs-section)/1 var(--font-sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--navy);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--rule-strong);
  margin: var(--space-7) 0 var(--space-5);
}

/* the section rule opens with a short navy segment — a quiet structural
   signature that ties each heading back to the masthead */
h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 3rem;
  height: 2px;
  background: var(--navy);
}

h3 {
  font-family: var(--font-serif);
  font-size: var(--fs-title);
  color: var(--navy);
  margin-bottom: var(--space-3);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.num,
time {
  font-variant-numeric: tabular-nums;
}

::selection {
  background: #D6E6F4;
  color: var(--ink);
}

/* --- Page shell ------------------------------------------------------------- */

.layout {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--pad-inline);
}

.content {
  min-width: 0;
}

main {
  display: block;
}

section[id] {
  scroll-margin-top: var(--space-4);
}

/* --- Links and focus --------------------------------------------------------- */

a {
  color: var(--navy);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  overflow-wrap: anywhere;
  transition: color 100ms ease;
}

a:hover {
  color: var(--navy-hover);
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
}

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

/* --- Skip link ----------------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--navy);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: var(--fs-meta);
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
  top: 0;
}

/* --- Masthead ------------------------------------------------------------------ */

/* The masthead is a centered title block spanning the content shell — the
   classic academic-document header. It must stay aligned with the layout
   container below it (never start at viewport x=0). */
.masthead {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--pad-inline);
  padding-block: var(--space-6) var(--space-5);
  text-align: center;
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--space-4);
}

/* the 2px Carolina accent sits under the name, centered, 4rem wide */
.masthead__name::after {
  content: "";
  display: block;
  width: 4rem;
  height: 2px;
  background: var(--accent);
  margin: var(--space-2) auto 0;
}

/* A bare <p> is a 36rem box flush left; with text-align: center its lines
   center ~200px off the page axis. Center the boxes themselves so every
   header line shares the name's axis. */
.masthead > p {
  max-width: 44rem;
  margin-inline: auto;
}

.masthead__role {
  font: 500 var(--fs-role)/1.35 var(--font-serif);
  color: var(--ink);
  margin-bottom: var(--space-1);
}

.masthead__affil {
  font: 400 var(--fs-meta)/1.5 var(--font-sans);
  color: var(--ink-muted);
  margin-bottom: var(--space-1);
}

.masthead__market {
  font: 400 var(--fs-meta)/1.5 var(--font-sans);
  color: var(--ink-muted);
  margin-bottom: 0;
}

.masthead__market strong {
  color: var(--navy);
  font-weight: 600;
}

/* the document/profile links read as a utility bar: their own hairline,
   centered under the header block */
.masthead__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-4);
  font: 400 var(--fs-meta)/1.5 var(--font-sans);
  max-width: 52rem;
  margin: var(--space-5) auto 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--rule);
}

.masthead__links a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  padding-block: var(--space-1);
}

/* --- Side nav ------------------------------------------------------------------- */

.sidenav {
  display: none;
}

@media (min-width: 68.75em) {
  .layout {
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr);
    gap: 0 var(--space-6);
  }

  .sidenav {
    display: block;
    position: sticky;
    top: var(--space-5);
    align-self: start;
    font: 400 0.875rem/1.6 var(--font-sans);
  }

  .sidenav__label {
    font: 600 0.6875rem/1.5 var(--font-sans);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin: 0 0 var(--space-3);
  }

  /* each item is a segment of a left rail; the visible section's segment
     fills navy — a table of contents that marks where you are */
  .sidenav a {
    color: var(--ink-muted);
    text-decoration: none;
    display: block;
    padding: 0.2rem 0 0.2rem var(--space-3);
    border-left: 2px solid var(--rule);
    transition: color 100ms ease, border-color 100ms ease;
  }

  .sidenav a:hover {
    color: var(--navy);
    border-left-color: var(--rule-strong);
  }

  .sidenav a[aria-current="true"] {
    color: var(--navy);
    font-weight: 600;
    border-left-color: var(--navy);
  }
}

/* --- Lede ------------------------------------------------------------------------ */

.lede {
  max-width: 39rem;
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  line-height: 1.65;
  margin: var(--space-5) 0 var(--space-4);
}

/* --- Entry grid with left metadata rail --------------------------------------- */

.entry {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: 0 var(--gutter);
  padding-block: var(--space-5);
  border-bottom: 1px solid var(--rule);
}

.entry__meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font: 400 var(--fs-meta)/1.5 var(--font-sans);
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  text-wrap: balance;
  /* dates and statuses sit against the gutter edge: one hard vertical axis
     down the middle of the page */
  text-align: right;
}

.entry__meta .status {
  letter-spacing: 0.06em;
}

.entry__meta .jmp-mark {
  color: var(--navy);
  font-weight: 600;
}

.entry__content {
  min-width: 0;
}

.entry__content > * {
  max-width: var(--prose);
}

.entry__content > :first-child {
  margin-top: 0;
}

@media (max-width: 62em) {
  .entry {
    grid-template-columns: 1fr;
    gap: var(--space-2) 0;
  }

  .entry__meta {
    order: -1;
    text-align: left;
  }
}

/* --- Paper entries ------------------------------------------------------------ */

.paper h3 {
  font-style: italic;
  margin-bottom: var(--space-3);
}

/* the job market paper leads the research list — give its title the extra
   step in the hierarchy a committee sees first */
#jmp-paper h3 {
  font-size: clamp(1.1875rem, 1.05rem + 0.5vw, 1.375rem);
}

.paper-meta {
  font-family: var(--font-sans);
  font-size: var(--fs-meta);
  color: var(--ink-muted);
  margin-bottom: var(--space-3);
}

.paper-abstract {
  margin-bottom: var(--space-4);
}

.paper-result-list {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-5);
  max-width: var(--prose);
}

.paper-result-list li {
  margin-bottom: var(--space-2);
}

.paper-link {
  font-weight: 600;
}

.paper-citation {
  color: var(--ink-muted);
  font-size: var(--fs-meta);
}

.paper-citation a {
  color: var(--ink-muted);
}

.paper-citation a:hover,
.paper-citation a:focus-visible {
  color: var(--navy);
}

/* --- Sub-sections within Research ------------------------------------------------ */

.sub-section {
  margin-top: var(--space-6);
}

/* --- Generic lists ------------------------------------------------------------------ */

.plain-list {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-5);
  max-width: var(--prose);
}

.plain-list li {
  margin-bottom: var(--space-2);
  overflow-wrap: break-word;
}

/* --- Teaching ------------------------------------------------------------------------ */

.teach-block {
  margin-top: var(--space-6);
}

/* --- Education --------------------------------------------------------------- */

.entry-line {
  margin: 0 0 var(--space-1);
  color: var(--navy);
  font-weight: 600;
}

.entry-sub {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-meta);
  color: var(--ink-muted);
}

.edu-coursework {
  font-size: var(--fs-meta);
  color: var(--ink-muted);
  margin-top: var(--space-4);
}

/* --- Skills ----------------------------------------------------------------------------- */

.skills-list {
  margin: 0 0 var(--space-2);
}

.skill-row {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: 0 var(--gutter);
  padding-block: var(--space-2);
}

.skill-row dt {
  font-family: var(--font-sans);
  font-size: var(--fs-meta);
  font-weight: 600;
  color: var(--navy);
  text-align: right;
}

.skill-row dd {
  margin: 0;
  max-width: var(--prose);
}

@media (max-width: 37.5em) {
  /* compact masthead + wider phone column so identity + lede stay within ~85vh */
  .layout {
    padding-inline: var(--space-3);
  }

  .masthead {
    padding-block: var(--space-2) var(--space-1);
    margin-bottom: 0;
  }

  .masthead__name {
    margin-bottom: var(--space-1);
    line-height: 1.15;
  }

  .masthead__role {
    font-size: var(--fs-body);
    margin-bottom: 0;
  }

  .masthead__affil {
    line-height: 1.4;
    margin-bottom: 0;
  }

  .masthead__market {
    line-height: 1.4;
    margin-bottom: 0;
  }

  .masthead__links {
    margin-top: var(--space-3);
    padding-top: var(--space-2);
    gap: var(--space-1) var(--space-4);
    line-height: 1.4;
  }

  h2 {
    margin-block-start: var(--space-6);
  }

  .doc-date {
    margin-left: 0;
    width: 100%;
  }

  .lede {
    margin-top: var(--space-1);
  }

  .skill-row {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .skill-row dt {
    text-align: left;
  }
}

/* --- Documents ---------------------------------------------------------------------------- */

.doc-list {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
}

.doc-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-4);
  padding-block: var(--space-3);
  border-bottom: 1px solid var(--rule);
}

.doc-name {
  font-family: var(--font-sans);
  font-weight: 600;
  min-width: min(11rem, 100%);
}

.doc-date {
  font-family: var(--font-sans);
  font-size: var(--fs-meta);
  color: var(--ink-faint);
  margin-left: auto;
}

/* --- Contact -------------------------------------------------------------------------------- */

.contact-line {
  margin-bottom: var(--space-2);
}

.contact-links h3 {
  margin-top: var(--space-6);
}

/* --- Footer --------------------------------------------------------------------------------- */

.site-footer {
  max-width: var(--container);
  margin: var(--space-8) auto 0;
  padding-block: var(--space-4) var(--space-6);
  padding-inline: var(--pad-inline);
  border-top: 1px solid var(--rule);
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: var(--fs-meta);
}

.site-footer p {
  margin: 0 auto;
  text-align: center;
}

/* --- Reduced motion ------------------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none;
    transition: none;
  }
}

/* --- Print: legible paper copy for committee members --------------------------------------------- */

@media print {
  :root {
    --bg: #FFFFFF;
    --rail: 8rem;
    --gutter: 1.5rem;
    --space-1: 2pt;
    --space-2: 3pt;
    --space-3: 5pt;
    --space-4: 7pt;
    --space-5: 9pt;
    --space-6: 12pt;
    --space-7: 16pt;
    --space-8: 22pt;
  }

  @page {
    margin: 0.75in;
  }

  html,
  body {
    background: var(--bg);
    color: #000000;
    font-size: 10.5pt;
    line-height: 1.45;
  }

  h1, h2, h3 {
    color: #000000;
  }

  h1 {
    font-size: 16pt;
  }

  h2 {
    font-size: 8.5pt;
    letter-spacing: 0.1em;
    border-bottom-color: #999999;
    margin: var(--space-6) 0 var(--space-3);
    break-after: avoid;
    page-break-after: avoid;
  }

  h2::after {
    background: #000000;
    width: 2rem;
  }

  h3 {
    font-size: 10.5pt;
    break-after: avoid;
    page-break-after: avoid;
  }

  .skip-link,
  .sidenav,
  .masthead__links {
    display: none;
  }

  .masthead {
    max-width: none;
    padding-block: var(--space-2) var(--space-4);
    border-bottom: none;
    margin-bottom: var(--space-3);
  }

  .masthead__market,
  .masthead__affil {
    color: #333333;
  }

  .layout,
  .content {
    max-width: none;
    padding-inline: 0;
    display: block;
  }

  .entry__content > *,
  p,
  .paper-result-list,
  .plain-list,
  .skill-row dd {
    max-width: none;
  }

  .entry {
    grid-template-columns: var(--rail) 1fr;
  }

  /* keep the substantive blocks whole; small entries may flow */
  .paper {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .paper-meta,
  .entry__meta,
  .entry-sub,
  .masthead__market,
  .masthead__affil,
  .doc-date,
  .edu-coursework,
  .skill-row dt,
  .paper-citation,
  .site-footer {
    font-size: 8.5pt;
  }

  a {
    color: #000000;
    text-decoration: none;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #444444;
    word-break: break-all;
  }

  a[href^="#"]::after,
  a[href^="mailto"]::after {
    content: none;
  }

  .site-footer {
    max-width: none;
    margin-top: var(--space-6);
    border-top: 1px solid #999999;
  }
}