:root {
  --paper: #f4f0e6;
  --paper-deep: #ebe5d6;
  --ink: #1f1e1a;
  --ink-soft: rgba(31, 30, 26, 0.66);
  --ink-faint: rgba(31, 30, 26, 0.2);
  --accent: #b4442e;

  --hand: "Kalam", "Bradley Hand", cursive;
  --body: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --gutter: clamp(16px, 5vw, 72px);
  --measure: 1120px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* paper texture */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .4 0 0 0 0 .32 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

header, main, footer { position: relative; z-index: 1; }

a { color: inherit; }

::selection { background: rgba(180, 68, 46, 0.18); }

/* ---------- rough overlays ---------- */
[data-rough] { position: relative; }
svg.rough {
  position: absolute;
  pointer-events: none;
  overflow: visible;
}

/* ---------- tabs ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  width: 100%;
  padding: 22px max(var(--gutter), calc((100% - var(--measure)) / 2 + var(--gutter))) 16px;
  background: var(--paper);
}
/* soft fade so content slides under the tabs */
.top::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 100%;
  height: 22px;
  background: linear-gradient(var(--paper), rgba(244, 240, 230, 0));
  pointer-events: none;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.tab {
  font-family: var(--hand);
  font-size: 19px;
  line-height: 1;
  padding: 10px 14px 8px;
  text-decoration: none;
  color: var(--ink-soft);
  transition: color 0.2s ease;
}
.tab svg.rough { opacity: 0.32; transition: opacity 0.2s ease; }
.tab:hover { color: var(--ink); }
.tab:hover svg.rough { opacity: 0.75; }
.tab[aria-current] { color: var(--ink); }
.tab[aria-current] svg.rough { opacity: 1; }
.tab:focus-visible { outline: 2px dashed var(--accent); outline-offset: 6px; }

/* ---------- pages ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(40px, 7vw, 84px) var(--gutter) 64px;
}

.page + .page { margin-top: clamp(110px, 16vw, 180px); }

/* sections wait offscreen until scrolled to */
.page.is-pending .name span,
.page.is-pending .degree,
.page.is-pending .stats,
.page.is-pending .portrait,
.page.is-pending .timeline > li,
.page.is-pending .entry,
.page.is-pending .empty,
.page.is-pending .project,
.page.is-pending .prose p,
.page.is-pending .squash-photo,
.page.is-pending .title { opacity: 0; }

.title {
  font-family: var(--hand);
  font-weight: 400;
  font-size: clamp(40px, 6vw, 56px);
  line-height: 1.1;
  margin: 0 0 clamp(32px, 5vw, 52px);
}
.title span { display: inline-block; padding-bottom: 4px; }

.empty {
  font-style: italic;
  color: var(--ink-soft);
  margin: 0;
}

/* ---------- about ---------- */
.about {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: clamp(40px, 8vw, 120px);
  align-items: start;
}

.name {
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(54px, 7.4vw, 82px);
  line-height: 0.95;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
}
.name span { display: block; }

.degree {
  margin: 0;
  font-style: italic;
  color: var(--ink-soft);
}

.stats {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.portrait {
  margin: 34px 0 0;
  width: 100%;
  max-width: 340px;
}

.portrait-stage {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}
.portrait-stage:focus-visible { outline: 2px dashed var(--accent); outline-offset: 10px; }

.portrait-stage picture,
.portrait-stage .photo,
.portrait-stage .sketch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.portrait-stage .photo {
  object-fit: cover;
  display: block;
}

.sketch path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* states driven by main.js */
.portrait.is-drawing .photo { opacity: 0; }
/* The photo fades in evenly over the whole frame as the pencil lines lift. */
.portrait.is-developing .photo {
  animation: develop 1.3s ease-out forwards;
}
.portrait.is-developing .sketch {
  animation: fade-out 0.45s 0.1s ease-out forwards;
}
.portrait.is-done .sketch { opacity: 0; }

@keyframes develop {
  0%   { opacity: 0; filter: sepia(0.3) saturate(0.8) brightness(1.06); }
  55%  { opacity: 0.95; filter: sepia(0.1) saturate(0.94) brightness(1.02); }
  100% { opacity: 1; filter: none; }
}
@keyframes fade-out { to { opacity: 0; } }

/* timeline */
.timeline {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
}
.timeline > li + li { margin-top: 30px; }

.year {
  font-family: var(--hand);
  font-weight: 400;
  font-size: 26px;
  line-height: 1;
  margin: 0 0 12px;
  padding-bottom: 10px;
}

.timeline > li.has-resume { position: relative; }
.resume {
  position: absolute;
  top: -10px;
  right: 0;
}

.timeline ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.timeline ul li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 24px;
  padding: 3px 0;
}
.timeline ul li span {
  color: var(--ink-soft);
  font-style: italic;
}

/* ---------- entries (presentations, publications) ---------- */
.entries {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 820px;
}

.entry {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 32px;
  padding: 26px 0 28px;
}

.entry time {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-top: 6px;
}

.entry h2 {
  font-weight: 500;
  font-size: 21px;
  line-height: 1.3;
  margin: 0 0 6px;
}

.entry h2 a {
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.35s ease;
}
.entry h2 a:hover,
.entry h2 a:focus-visible { background-size: 100% 1px; outline: none; }

.entries.with-figs { max-width: 1000px; }
.with-figs .entry {
  grid-template-columns: 180px 1fr 116px;
  grid-template-areas: "fig text date";
  gap: 8px 36px;
  align-items: start;
}
.with-figs .entry > time { grid-area: date; text-align: right; }
.with-figs .entry > div { grid-area: text; }
.with-figs .entry > .entry-fig { grid-area: fig; }
.entry-fig {
  margin: 6px 0 0;
  background: #fff;
  padding: 6px;
}
.entry-fig img {
  display: block;
  width: 100%;
  height: auto;
}

.entry p { margin: 0 0 4px; }
.entry .authors { color: var(--ink-soft); font-size: 16px; }
.entry .authors b { color: var(--ink); font-weight: 500; }
.entry .venue { font-size: 16px; }

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 16px !important;
}

button.button {
  background: none;
  border: 0;
  cursor: pointer;
}
.abstract p {
  margin-top: 16px !important;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-soft);
}

/* ---------- projects ---------- */
.projects {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 1000px;
}
.project {
  display: grid;
  grid-template-columns: minmax(0, 480px) minmax(0, 1fr);
  gap: clamp(28px, 5vw, 56px);
  align-items: center;
}
.project + .project { margin-top: 72px; }
.project-media {
  margin: 0;
  background: #fff;
  padding: 6px;
}
.project-media video {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
}
.project h2 {
  font-weight: 500;
  font-size: 24px;
  line-height: 1.3;
  margin: 0 0 10px;
}
.project p { margin: 0 0 12px; color: var(--ink-soft); }

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 20px !important;
}
.button {
  font-family: var(--hand);
  font-size: 18px;
  line-height: 1;
  padding: 10px 16px 8px;
  color: var(--ink);
  text-decoration: none;
}
.button svg.rough { transition: transform 0.2s ease; }
.button:hover svg.rough { transform: translate(-1px, -2px); }
.button:hover { color: var(--accent); }
.button:focus-visible { outline: 2px dashed var(--accent); outline-offset: 6px; }

@media (max-width: 720px) {
  .project { grid-template-columns: 1fr; gap: 22px; }
  .project-media { max-width: 420px; }
}

/* ---------- squash ---------- */
.squash-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 220px;
  gap: clamp(32px, 5vw, 72px);
  align-items: center;
}
.prose p { margin: 0 0 1.1em; max-width: 62ch; }
.prose p:last-child { margin-bottom: 0; }

/* photos taped to the page */
.squash-photo {
  position: relative;
  margin: 0;
  width: 220px;
  aspect-ratio: 660 / 1010;
  transform: rotate(-1.5deg);
}
.squash-photo:last-child { transform: rotate(1.5deg); }
.squash-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #fff;
  border: 6px solid #fff;
  box-shadow: 0 1px 2px rgba(31, 30, 26, 0.18), 0 6px 14px rgba(31, 30, 26, 0.1);
}
.squash-photo .tape {
  position: absolute;
  inset: -30px;
  width: calc(100% + 60px);
  height: calc(100% + 60px);
  overflow: visible;
  pointer-events: none;
}

@media (max-width: 720px) {
  .squash-body {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "text text" "photo photo2";
    gap: 40px 24px;
    align-items: start;
  }
  .squash-body .prose { grid-area: text; }
  .squash-photo { grid-area: photo; width: min(200px, calc(100% - 24px)); justify-self: center; }
  .squash-photo:last-child { grid-area: photo2; }
}

/* ---------- footer ---------- */
.foot {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter) 28px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

/* ---------- entrance motion ---------- */
.page.is-entering .name span,
.page.is-entering .degree,
.page.is-entering .stats,
.page.is-entering .timeline > li,
.page.is-entering .entry,
.page.is-entering .empty,
.page.is-entering .project,
.page.is-entering .prose p,
.page.is-entering .squash-photo,
.page.is-entering .portrait,
.page.is-entering .title {
  animation: rise 0.7s cubic-bezier(.2, .7, .2, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- small screens ---------- */
@media (max-width: 820px) {
  .with-figs .entry { grid-template-columns: 150px 1fr 100px; gap: 6px 24px; }
  .about { grid-template-columns: 1fr; gap: 48px; }
  .portrait { max-width: 300px; }
}

@media (max-width: 560px) {
  body { font-size: 17px; }
  .top { padding-top: 20px; }
  .tabs { gap: 8px 8px; }
  .tab { font-size: 17px; padding: 9px 10px 7px; }
  .entry, .with-figs .entry { grid-template-columns: 1fr; gap: 6px; }
  .with-figs .entry {
    grid-template-columns: 1fr;
    grid-template-areas: "fig" "date" "text";
    gap: 6px;
  }
  .with-figs .entry > .entry-fig { width: min(260px, calc(100% - 20px)); margin: 10px 0 18px 9px; }
  .with-figs .entry > time { padding-top: 0; text-align: left; }
  .entry-fig { padding: 4px; }
  .entry time { padding-top: 0; }
  .timeline ul li { display: block; }
  .timeline ul li span { display: block; font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .portrait .photo { opacity: 1 !important; }
  .portrait .sketch { display: none; }
}
