/* Gilad Ravid — personal academic site */

:root {
  --paper: #f6f7f3;
  --ink: #1c2530;
  --muted: #5d6773;
  --rule: #d8ddd4;
  --green: #3d6a4a;
  --green-soft: #e3ebe2;
  --sand: #b98a2e;
  --edge: rgb(61 106 74 / 0.22);
  --spoke: rgb(61 106 74 / 0.07);

  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --rail: 12.5rem;
  --measure: 46rem;
  --gutter: clamp(1.25rem, 4vw, 3.5rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131916;
    --ink: #e3e7e0;
    --muted: #9ba59d;
    --rule: #2c3631;
    --green: #8fc29c;
    --green-soft: #1f2b24;
    --sand: #ddb35c;
    --edge: rgb(143 194 156 / 0.25);
    --spoke: rgb(143 194 156 / 0.08);
  }
}

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

html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--serif);
  font-optical-sizing: auto;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--sand); outline-offset: 3px; border-radius: 2px; }

.skip { position: absolute; left: -999px; top: 0.5rem; background: var(--ink); color: var(--paper); padding: 0.5rem 1rem; z-index: 10; font-family: var(--sans); }
.skip:focus { left: 0.5rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Side rail ---------- */
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail);
  padding: 2.25rem 1.5rem; border-right: 1px solid var(--rule);
  font-family: var(--sans);
  display: flex; flex-direction: column; gap: 2rem;
}
.mark { font: 600 1.05rem/1.2 var(--serif); color: var(--ink); text-decoration: none; }
.rail ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.2rem; }
.rail nav a {
  display: block; padding: 0.3rem 0 0.3rem 0.75rem; margin-left: -0.75rem;
  border-left: 2px solid transparent;
  color: var(--muted); text-decoration: none; font-size: 0.95rem;
}
.rail nav a:hover { color: var(--ink); }
.rail nav a[aria-current="true"] { color: var(--ink); border-left-color: var(--green); }

main, footer { margin-left: var(--rail); padding: 0 var(--gutter); }

/* ---------- Intro ---------- */
.intro {
  display: grid; grid-template-columns: minmax(0, 32rem) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 4rem); align-items: center;
  min-height: min(100vh, 58rem); padding: 3rem 0 2.5rem;
  max-width: 82rem;
}
/* Portrait beside the name */
.masthead { display: flex; align-items: center; gap: clamp(1.25rem, 3vw, 2.25rem); margin-bottom: 1.75rem; }
.masthead h1 { margin-bottom: 0.9rem; font-size: clamp(2.4rem, 3.5vw, 3.4rem); }
.masthead .role { margin: 0; }
.portrait {
  width: clamp(7rem, 11vw, 9.5rem); height: auto; aspect-ratio: 1; object-fit: cover; object-position: 50% 30%;
  border-radius: 50%; flex: none;
  box-shadow: 0 0 0 4px var(--paper), 0 0 0 5px var(--sand);
}
h1 {
  font: 500 clamp(3rem, 7vw, 5.25rem)/0.95 var(--serif);
  letter-spacing: -0.025em; margin: 0 0 1.25rem;
  font-variation-settings: "opsz" 72;
}
.role { font-family: var(--sans); font-size: 1.05rem; line-height: 1.5; color: var(--muted); margin: 0 0 1.75rem; }
.intro-text > p { max-width: 34em; }
.profiles { list-style: none; padding: 0; margin: 1.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; font: 500 0.95rem var(--sans); }

.details { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.25rem; margin: 1.75rem 0 0; font-size: 0.97rem; }
.details dt { font: 500 0.88rem/1.75 var(--sans); color: var(--muted); }
.details dd { margin: 0; }
.rail-links { list-style: none; margin: auto 0 0; padding: 0; display: grid; gap: 0.3rem; font-size: 0.88rem; }
.rail-links a { color: var(--muted); text-decoration: none; }
.rail-links a:hover { color: var(--green); }
.intro-net { margin: 0; }
.net { width: 100%; height: auto; display: block; overflow: visible; }
.net .spokes line { stroke: var(--spoke); stroke-width: 1; }
.net .ties path { stroke: var(--edge); fill: none; }
.net .node circle { fill: var(--paper); stroke: var(--green); stroke-width: 1.4; transition: fill 0.15s; }
.net .node.is-labelled circle { fill: var(--green); }
.net .node.student circle { fill: var(--sand); stroke: var(--sand); }
.net .node.self circle { fill: var(--ink); stroke: var(--ink); }
.net text { font: 500 11px var(--sans); fill: var(--ink); paint-order: stroke; stroke: var(--paper); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.net .node { cursor: default; }
/* hover: highlight one co-author and their ties */
.net.is-focused .ties path, .net.is-focused .spokes line { opacity: 0.25; }
.net.is-focused .node:not(.is-near) { opacity: 0.35; }
.net .ties path.is-near { stroke: var(--green); opacity: 1; }
.net .node.is-near circle { fill: var(--green); }
.net .node.is-near text { opacity: 1; }
.legend { display: inline-flex; align-items: center; gap: 0.4rem; margin-right: 1.1rem; color: var(--ink); font-weight: 500; }
.key { width: 0.7rem; height: 0.7rem; border-radius: 50%; display: inline-block; }
.key-student { background: var(--sand); }
.key-coauthor { background: var(--green); }
figcaption { font: 0.85rem/1.5 var(--sans); color: var(--muted); max-width: 36rem; margin-top: 0.75rem; }

/* ---------- Content blocks ---------- */
.block { max-width: var(--measure); padding: 4rem 0 1rem; border-top: 1px solid var(--rule); }
.block + .block { margin-top: 1rem; }
h2 .count { font: 500 1rem var(--sans); color: var(--muted); margin-left: 0.4rem; vertical-align: middle; }
h2 { font: 500 2rem/1.15 var(--serif); letter-spacing: -0.01em; margin: 0 0 1.5rem; }
h3 { font: 600 1rem/1.3 var(--sans); margin: 2.25rem 0 0.75rem; }
h2 + h3 { margin-top: 0; }

/* Timelines: dates hang in the left column */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem; padding: 0.45rem 0; }
.when { font: 0.9rem/1.85 var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; }
.what, .org, .sub { margin: 0; }
.what { font-weight: 500; }
.org { font-size: 0.97rem; }
.sub { font-size: 0.93rem; color: var(--muted); }

/* ---------- Publications ---------- */
.pub-tools { position: sticky; top: 0; z-index: 2; background: var(--paper); padding: 0.5rem 0; margin-bottom: 0.5rem; font-family: var(--sans); }
.search input {
  width: 100%; font: 1rem var(--sans); color: var(--ink); background: transparent;
  border: 0; border-bottom: 1px solid var(--rule); padding: 0.5rem 0; border-radius: 0;
}
.search input:focus { outline: none; border-bottom-color: var(--green); }
.result-count { font-size: 0.85rem; color: var(--muted); margin: 0.4rem 0 0; min-height: 1.2em; }

.year-group { display: grid; grid-template-columns: 4.5rem 1fr; gap: 1rem; padding: 1.1rem 0; border-top: 1px solid var(--rule); }
.year-group:first-child { border-top: 0; }
.year { font: 500 1.15rem/1.5 var(--serif); color: var(--green); margin: 0; font-variant-numeric: oldstyle-nums; }
.pubs { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.1rem; }
.cite { margin: 0; }
.cite i { font-style: italic; }
.cite strong { font-weight: 600; }
.lang { color: var(--muted); }
.meta { margin: 0.25rem 0 0; font: 0.82rem/1.4 var(--sans); color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; }
.meta a { font-weight: 600; }
.meta:empty { display: none; }
.award { color: var(--sand); font-weight: 600; }
details { margin-top: 0.35rem; font-size: 0.95rem; }
summary { font: 600 0.82rem var(--sans); color: var(--green); cursor: pointer; width: max-content; }
details p { margin: 0.6rem 0 0; color: var(--ink); line-height: 1.6; max-width: 40em; }
details[open] { border-left: 2px solid var(--green-soft); padding-left: 0.9rem; margin-left: -0.9rem; }
.pub[hidden], .year-group[hidden] { display: none; }
.empty { color: var(--muted); font-family: var(--sans); }

/* ---------- Students ---------- */
.people { list-style: none; margin: 0; padding: 0; columns: 2 18rem; column-gap: 2.5rem; }
.people li { break-inside: avoid; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.6rem; padding: 0.3rem 0; border-bottom: 1px solid var(--rule); }
.people .name { font-weight: 600; }
.people .with { font-size: 0.93rem; color: var(--muted); font-style: italic; }
.people .when { margin-left: auto; font-size: 0.85rem; }

/* ---------- Projects ---------- */
.projects { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.75rem; }
.projects h3 { font: 500 1.3rem/1.3 var(--serif); margin: 0; }
.projects h3 a { text-decoration: none; }
.projects h3 a:hover { text-decoration: underline; }
.projects .url { font: 0.85rem var(--sans); color: var(--muted); margin: 0.1rem 0 0.4rem; }
.projects p { margin: 0; }

/* ---------- Contact ---------- */
.contact { padding-bottom: 3rem; }
.contact h2 { grid-column: 1 / -1; }
.contact p, address { margin: 0 0 0.6rem; font-style: normal; }
.contact .profiles { margin-top: 1rem; }

footer { padding-top: 1.5rem; padding-bottom: 3rem; font: 0.85rem var(--sans); color: var(--muted); }

/* ---------- Smaller screens ---------- */
@media (max-width: 64rem) {
  .intro { grid-template-columns: 1fr; min-height: 0; }
  .intro-net { max-width: 40rem; }
}
@media (max-width: 52rem) {
  .rail {
    position: sticky; top: 0; inset: auto; width: auto; z-index: 5;
    flex-direction: row; align-items: center; gap: 1rem;
    padding: 0.6rem var(--gutter); border-right: 0; border-bottom: 1px solid var(--rule);
    background: var(--paper);
  }
  .mark { white-space: nowrap; }
  .rail nav { overflow-x: auto; scrollbar-width: none; }
  .rail .rail-links { display: none; }
  .rail nav ul { display: flex; gap: 1.1rem; }
  .rail nav a { padding: 0.3rem 0; margin: 0; border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; }
  .rail nav a[aria-current="true"] { border-bottom-color: var(--green); }
  main, footer { margin-left: 0; }
  html { scroll-padding-top: 4rem; }
  .pub-tools { top: 3.1rem; }
  .intro { padding-top: 2rem; }
}
@media (max-width: 36rem) {
  body { font-size: 1rem; }
  .year-group, .timeline li { grid-template-columns: 1fr; gap: 0.2rem; }
  .contact { grid-template-columns: 1fr; }
  .details { grid-template-columns: 1fr; gap: 0; }
  .details dd { margin-bottom: 0.5rem; }
  .masthead { flex-direction: column; align-items: flex-start; }
}

@media print {
  .rail, .pub-tools, .intro-net, details:not([open]) { display: none; }
  main, footer { margin: 0; }
  .pub[hidden] { display: block; }
  .year-group[hidden] { display: grid; }
  a { color: inherit; }
}
