/* Francisco Richter Mendoza — personal site
   A field notebook: graph paper, fountain-pen ink, pencil for what went extinct.
   One bold element: the simulated birth–death tree. Everything else stays quiet. */

:root {
  --unsampled: color-mix(in srgb, var(--living) 38%, var(--paper));
  --paper:   #EEF0E6;
  --ink:     #1B2740;
  --muted:   #5C6478;
  --living:  #1E3A8A;
  --extinct: #8F928A;
  --rule:    #CDD2C2;
  --margin:  #C24B3A;
  --measure: 38rem;
  --wide:    66rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:   #15171C;
    --ink:     #DCE0EA;
    --muted:   #9097A8;
    --living:  #8DA6F0;
    --extinct: #5D6069;
    --rule:    #262A33;
    --margin:  #B5533F;
  }
}

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

html {
  font-family: "Newsreader", Georgia, serif;
  font-size: 112.5%;              /* 18px */
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  -webkit-text-size-adjust: 100%;
}
@media (min-width: 48rem) { html { font-size: 125%; } }  /* 20px */

body { margin: 0; }

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

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

.masthead { padding: 2.5rem 1.25rem 0; }

.tree {
  margin: 0 auto;
  max-width: var(--wide);
}
.tree .plot { position: relative; }
.tree svg {
  display: block;
  width: 100%;
  height: clamp(12rem, 27vw, 19rem);   /* stretches on phones so lineages stay apart */
  overflow: visible;
}

.tree .alive {
  fill: none;
  stroke: var(--living);
  stroke-width: calc(var(--lw, 1.7) * 1px);
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.tree .dead {
  fill: none;
  stroke: var(--extinct);
  stroke-width: calc(var(--lw, 1.5) * 0.8px);
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  opacity: 0.7;
  transition: opacity 1.1s ease;
}
.tree .unsampled {
  fill: none;
  stroke: var(--unsampled);
  stroke-width: calc(var(--lw, 1.7) * 1px);
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.tree .rings {
  fill: none;
  stroke: var(--unsampled);
  stroke-width: 5;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.tree .tips {
  fill: none;
  stroke: var(--living);
  stroke-width: 5;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.tree .present {
  stroke: var(--rule);
  stroke-width: 1;
  stroke-dasharray: 3 4;
  vector-effect: non-scaling-stroke;
}
#tree-open {
  display: none;
  position: absolute;
  right: -0.3rem;
  bottom: -2.4rem;
  width: 2rem;
  height: 2rem;
  padding: 0.25rem;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.js #tree-open { display: block; }
#tree-open:hover, #tree-open[aria-expanded="true"] { color: var(--living); }
#tree-open svg { width: 100%; height: 100%; fill: var(--paper); stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.tree figcaption[hidden] { display: none; }
.tree .present-label {
  position: absolute;
  left: calc(93% + 0.5rem);
  bottom: -0.3rem;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--muted);
}
@media (max-width: 40rem) {
  .tree .present-label { left: auto; right: 0; bottom: -1.3rem; }
}

/* The one orchestrated moment: the tree grows through time, then the dead fade. */
.js .tree .dead { opacity: 1; }
.js .tree.faded .dead { opacity: 0.7; }

.js .tree svg {
  clip-path: inset(0 100% 0 0);
  animation: grow 2.8s cubic-bezier(0.35, 0.05, 0.25, 1) 0.2s forwards;
}
@keyframes grow { to { clip-path: inset(0 0 0 0); } }

@media (prefers-reduced-motion: reduce) {
  .js .tree svg { animation: none; clip-path: none; }
  .tree .dead { transition: none; }
}

.tree figcaption {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 1.2rem 3rem;
  max-width: var(--wide);
  margin: 3rem auto 0;
  font-size: 0.88rem;
  color: var(--muted);
}
.tree .caption { margin: 0 0 0.9rem; font-style: italic; line-height: 1.5; }

.tree .views { display: flex; flex-wrap: wrap; }
.tree .views button {
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  margin-right: -1px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}
.tree .views button:first-child { border-radius: 3px 0 0 3px; }
.tree .views button:last-child  { border-radius: 0 3px 3px 0; }
.tree .views button[aria-pressed="true"] {
  background: var(--living);
  border-color: var(--living);
  color: var(--paper);
  position: relative;
}

.tree .controls { display: none; }
.js .tree .controls { display: block; }
.js .tree .views { display: flex; }
.tree .views { display: none; }

.tree .sliders {
  display: grid;
  grid-template-columns: auto minmax(6rem, 1fr) 3.2rem;
  align-items: center;
  gap: 0.25rem 0.9rem;
}
.tree .sliders label { color: var(--ink); white-space: nowrap; }
.tree .sliders input[type="range"] { width: 100%; margin: 0; accent-color: var(--living); }
.tree .sliders output {
  font-variant-numeric: tabular-nums lining-nums;
  text-align: right;
  color: var(--ink);
}
.tree .tree-foot { margin: 0.7rem 0 0; min-height: 1.4em; }
.tree .tree-actions { margin: 0.3rem 0 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; align-items: baseline; }
#tree-new {
  font: inherit;
  font-size: 0.85rem;
  color: var(--living);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
}
#tree-new:hover { border-color: var(--living); }

@media (max-width: 48rem) {
  .tree figcaption { grid-template-columns: 1fr; margin-top: 3rem; }
  .tree .views { flex-wrap: nowrap; }
  .tree .views button { flex: 1 1 0; font-size: 0.78rem; padding: 0.35rem 0.4rem; line-height: 1.25; }
}

.intro {
  max-width: var(--measure);
  margin: 3rem auto 0;
}
h1 {
  margin: 0;
  font-weight: 500;
  font-size: 2.4rem;
  line-height: 1.1;
  letter-spacing: -0.005em;
}
@media (min-width: 48rem) { h1 { font-size: 2.9rem; } }

.question {
  margin: 0.6rem 0 0;
  font-size: 1.35rem;
  font-style: italic;
  line-height: 1.35;
  color: var(--muted);
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1.4rem;
  margin-top: 1.6rem;
}
nav a { color: var(--ink); text-decoration: none; }
nav a:hover { color: var(--living); text-decoration: underline; }
nav.tabs a { padding-bottom: 0.15rem; border-bottom: 2px solid transparent; }
nav.tabs a[aria-current="page"] { color: var(--living); border-bottom-color: var(--living); }
nav.tabs a[aria-current="page"]:hover { text-decoration: none; }
.who {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name photo" "bio photo";
  column-gap: 1.8rem;
  align-items: start;
}
.who h1 { grid-area: name; }
.who .bio { grid-area: bio; }
.portrait {
  grid-area: photo;
  width: 8.5rem;
  height: 8.5rem;
  object-fit: cover;
  border-radius: 50%;
  margin-top: 0.3rem;
}
@media (max-width: 36rem) {
  .who { grid-template-columns: 1fr; grid-template-areas: "photo" "name" "bio"; }
  .portrait { width: 6rem; height: 6rem; margin: 0 0 1.2rem; }
}
.bio { margin-top: 1.2rem; }
.bio p { margin: 0 0 0.5rem; }
.bio .lede { font-size: 1.05rem; }
.panel[hidden] { display: none; }
.js .panel { margin-top: 2.6rem; }
/* the active tab already names the panel; keep the heading for screen readers */
.js .panel > h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.js .panel > h2 + h3 { margin-top: 0; }

/* ---------- Content ---------- */

main {
  max-width: calc(var(--measure) + 2.5rem);
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

section, footer { margin-top: 3.8rem; }
#about { margin-top: 2.6rem; }

h2 {
  margin: 0 0 1rem;
  font-weight: 500;
  font-size: 1.7rem;
  line-height: 1.2;
}
h3 {
  margin: 2rem 0 0.4rem;
  font-weight: 500;
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.3;
}
h2 + h3 { margin-top: 0.4rem; }
h3.list-head { margin-top: 3rem; font-style: normal; font-size: 1.35rem; }
h4 { margin: 2rem 0 0.4rem; font-weight: 500; font-size: 1.05rem; }

p { margin: 0 0 1rem; hyphens: auto; }
.lede { font-size: 1.12rem; }

/* Year gutter: publications and talks are genuinely a timeline. */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.timeline li {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 0 1rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--rule);
}
.timeline li:first-child { border-top: 0; padding-top: 0.2rem; }
.timeline .year {
  color: var(--muted);
  font-variant-numeric: lining-nums tabular-nums;
  font-size: 0.95rem;
  padding-top: 0.08rem;
}
.timeline .title { display: block; line-height: 1.35; }
.timeline a.title { text-decoration: none; }
.timeline a.title:hover { text-decoration: underline; }
.timeline .authors,
.timeline .venue {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.4;
}
.timeline .venue { font-style: italic; }

.more { margin-top: 1rem; font-size: 0.95rem; }

.courses {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.3rem 1rem;
  margin: 0 0 1.2rem;
}
.courses dt { color: var(--muted); }
.courses dd { margin: 0; }

.video { margin: 1.2rem 0 0; }
.video video {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--paper);
}
.video figcaption { margin-top: 0.4rem; font-size: 0.9rem; color: var(--muted); }

@media (max-width: 30rem) {
  .timeline li { grid-template-columns: 1fr; }
  .timeline .year { padding: 0 0 0.1rem; }
  .courses { grid-template-columns: 1fr; gap: 0; }
  .courses dd { margin-bottom: 0.6rem; }
}

/* ---------- Notebook ---------- */

body {
  background-image:
    linear-gradient(color-mix(in srgb, var(--rule) 60%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--rule) 60%, transparent) 1px, transparent 1px);
  background-size: 24px 24px;
}
.intro, main > section { border-left: 2px solid var(--margin); padding-left: 1.4rem; }
h2 { font-weight: 600; }
.timeline .year, nav a, .tree figcaption, .tree button, .courses dt {
  font-family: "Courier Prime", ui-monospace, monospace;
  font-style: normal;
}
.tree .alive { stroke-width: 2.1; }
.tree .dead  { stroke-width: 1.3; stroke-dasharray: 2 3; }
.timeline li { border-top: 1px dashed var(--rule); }
.timeline .year { color: var(--margin); font-size: 0.85rem; }
.tree .views button, #tree-new { background: var(--paper); }
.tree .views button[aria-pressed="true"] { background: var(--living); }

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

.write {
  display: grid;
  gap: 0.35rem;
  margin-top: 2rem;
  max-width: 32rem;
}
.write label {
  font-family: "Courier Prime", ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.6rem;
}
.write input, .write textarea {
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.45rem 0.6rem;
  width: 100%;
}
.write textarea { resize: vertical; line-height: 1.5; }
.write input:focus-visible, .write textarea:focus-visible {
  outline: 2px solid var(--living);
  outline-offset: 1px;
  border-color: var(--living);
}
.write button {
  justify-self: start;
  margin-top: 1rem;
  font-family: "Courier Prime", ui-monospace, monospace;
  font-size: 0.9rem;
  color: var(--paper);
  background: var(--living);
  border: 1px solid var(--living);
  border-radius: 3px;
  padding: 0.45rem 1rem;
  cursor: pointer;
}
.write button:hover { filter: brightness(1.1); }

/* an address must be copyable as written */
a[href^="mailto:"] { hyphens: manual; white-space: nowrap; }
.write .trap { position: absolute; left: -9999px; }
.write button:disabled { opacity: 0.6; cursor: default; }
.write-status { margin: 0.4rem 0 0; min-height: 1.4em; font-size: 0.95rem; color: var(--muted); }
