/* ==========================================================
   Personal academic website — shared styles
   Change the look of the whole site by editing the tokens
   in :root below (colors, fonts, widths).
   ========================================================== */

:root {
  /* Colors (light) */
  --bg: #f7f6f3; /* soft warm stone (earlier: cream #fbfaf7, stone gray #f4f4f2) */
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #5d6470;
  --accent: #1f4277;
  --accent-soft: #e8eef7;
  --rule: #e2e0db;

  /* Always light, even when the device is in dark mode */
  color-scheme: light;

  /* Type */
  --font-serif: "EB Garamond", Garamond, Georgia, "Times New Roman", serif;
  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  /* Layout */
  --measure: 46rem;
  --gutter: 1.25rem;
}

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

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.25rem; /* Garamond runs small, so the body is set a little larger */
  font-variant-numeric: lining-nums;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  transition: text-decoration-color 0.15s ease;
}

a:hover {
  text-decoration-color: var(--accent);
}

h1,
h2,
h3 {
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 2.25rem;
  margin: 0 0 0.25rem;
}

h2 {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 3rem 0 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

h3 {
  font-size: 1.2rem;
  margin: 0 0 0.3rem;
}

p {
  margin: 0 0 1rem;
}

.container {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

main {
  position: relative;
  z-index: 1;
  padding: 4rem 0 4rem;
}

/* Faint dotted world map in the gap between the bio and the papers,
   tilted back like a map lying on a table seen from its bottom-left corner.
   opacity = strength; rotateX = how steeply it leans away;
   rotateZ = how much it turns (negative lifts the right side). */
body {
  overflow-x: clip; /* the map band is full window width; never let it cause sideways scrolling */
}

.map-anchor {
  position: relative;
  height: 0;
  z-index: -1; /* behind the text */
}

.world-map-wrap {
  position: absolute;
  will-change: transform; /* a small script lets it lag slightly as the page scrolls */
  top: -22.5rem; /* moves the whole map up or down; less negative = lower */
  left: calc(50% - 50vw);
  width: 100vw;
  height: 38rem;
  overflow: hidden;
  perspective: 1000px;
  perspective-origin: 50% 0%;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 30%, #000 70%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 30%, #000 70%, transparent 100%);
}

.world-map {
  position: absolute;
  left: 50%;
  bottom: 3rem;
  width: min(80rem, 180%);
  aspect-ratio: 1000 / 383;
  transform: translateX(-50%) rotateX(68deg) rotateZ(-10deg); /* earlier: 58deg, then 36deg, -6deg */
  transform-origin: 50% 100%;
  background: var(--accent);
  opacity: 0.08;
  -webkit-mask: url("../images/world-map.svg?v=4") no-repeat center / 100% 100%;
  mask: url("../images/world-map.svg?v=4") no-repeat center / 100% 100%;
}

/* Very faint even dot grid continuing below the map. It fades in
   under the map, fades out toward the bottom of the page, and is
   lighter behind the text column so reading stays clean. */
.dot-texture {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--accent) 1px, transparent 1.4px);
  background-size: 16px 16px;
  opacity: 0.08;
  -webkit-mask-image:
    linear-gradient(to bottom, transparent 0, transparent 44rem, #000 58rem, #000 calc(100% - 28rem), transparent 100%),
    linear-gradient(to right, #000 calc(50% - 30rem), rgba(0,0,0,0.3) calc(50% - 21rem), rgba(0,0,0,0.3) calc(50% + 21rem), #000 calc(50% + 30rem));
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to bottom, transparent 0, transparent 44rem, #000 58rem, #000 calc(100% - 28rem), transparent 100%),
    linear-gradient(to right, #000 calc(50% - 30rem), rgba(0,0,0,0.3) calc(50% - 21rem), rgba(0,0,0,0.3) calc(50% + 21rem), #000 calc(50% + 30rem));
  mask-composite: intersect;
  pointer-events: none;
  z-index: 0;
}

body {
  position: relative;
}

/* ---------- Home: intro ---------- */

.intro {
  display: grid;
  grid-template-columns: 14rem 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "photo bio"
    "edu   bio";
  gap: 1.25rem 2.25rem;
  align-items: start;
}

/* ---------- Education timeline (under the links) ---------- */

.education {
  grid-area: edu;
  font-family: var(--font-sans);
  margin-top: 0.4rem;
}

.edu-label {
  font-size: 0.8rem; /* same as the section headings (h2) */
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.edu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.edu-list li {
  position: relative;
  padding: 0 0 1rem 1.15rem;
  line-height: 1.35;
}

.edu-list li:last-child {
  padding-bottom: 0;
}

/* Dot for each degree */
.edu-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.38em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* Thin line joining the dots */
.edu-list li::after {
  content: "";
  position: absolute;
  left: 3px;
  top: calc(0.38em + 11px);
  bottom: 2px;
  width: 1px;
  background: var(--rule);
}

.edu-list li:last-child::after {
  display: none;
}
.edu-degree {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.edu-school {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.intro .portrait {
  grid-area: photo;
}

.intro .bio {
  grid-area: bio;
}

/* Bio paragraphs a touch smaller than the page's base size */
.bio p:not(.role) {
  font-size: 1.15rem;
}

/* Contact links: one row under the name and title */
.profile-links {
  list-style: none;
  padding: 0;
  margin: -0.6rem 0 1.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.profile-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.profile-links .icon {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.profile-links a:hover .icon {
  stroke: var(--accent);
}

.portrait {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 10px;
  background: var(--accent-soft);
  display: block;
}

.role {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0 0 1.25rem;
  line-height: 1.5;
}



/* ---------- Papers ---------- */

.paper {
  padding: 0 0 1.75rem;
  margin: 0 0 1.75rem;
  border-bottom: 1px solid var(--rule);
}

.paper:last-child {
  border-bottom: 0;
  margin-bottom: 0;
}

/* Last paper before the next section heading: the heading's own line separates them */
.paper:has(+ h2) {
  border-bottom: 0;
}

.paper-title a {
  color: var(--text);
  text-decoration: none;
}

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

.paper-authorship {
  font-family: var(--font-sans);
  font-size: 0.85rem; /* same as .paper-meta: both are gray details about the paper */
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
}

/* Plain-language story behind each paper (research page) */
.paper-story {
  font-size: 1.15rem; /* same as the bio */
  line-height: 1.6;
  margin: 0.4rem 0 0.75rem;
  padding-left: 1.5rem; /* indent the story under the title */
}

/* Italic cue at the top of each story, marking it as my own explanation (same size as the story) */
.paper-story .story-cue {
  font-style: italic;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.paper-story p {
  margin: 0 0 0.7rem;
}

.paper-story p:last-child {
  margin-bottom: 0;
}

.paper-meta {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.6rem;
  line-height: 1.5;
}


.paper-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  margin: 0 0 0.4rem;
}

.paper details summary {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.paper details summary::-webkit-details-marker {
  display: none;
}

.paper details summary::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.paper details[open] summary::before {
  transform: rotate(45deg);
}

/* PDF link sits below the abstract toggle */
.paper details + .paper-links {
  margin-top: 0.45rem;
}

.paper details[open] + .paper-links {
  margin-top: 1rem;
}

.paper details p {
  font-size: 1rem;
  margin: 0.75rem 0 0;
  color: var(--text);
}


/* ---------- Talk photo (after the papers) ---------- */

.talk-photo {
  max-width: 18.75rem;
  margin: 0 auto 2rem;
}

.talk-photo img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: var(--accent-soft);
}

/* Closing note pointing to the CV */
.cv-note {
  font-size: 1.15rem; /* a sentence, so serif at the same size as the bio */
  color: var(--text);
  text-align: center;
  margin: 0;
}

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

.site-footer {
  border-top: 1px solid var(--rule);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--muted);
}

.site-footer .container {
  padding-top: 1.5rem;
  padding-bottom: 2rem;
  text-align: center;
}

/* ---------- Gentle motion ----------
   On load, the intro rises a few pixels and fades in, piece by piece.
   Everything below it (section heading, papers, talk photo, CV note)
   rises the same way once it scrolls into view; whatever is already on
   screen at load continues the intro's sequence. A script in <head>
   adds .reveal-ready to <html>, so nothing is hidden if scripts are off.
   Visitors who ask their device to reduce motion see no animation. */

@media (prefers-reduced-motion: no-preference) {
  @keyframes rise-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
  }

  /* No "to" step: fades up to each element's own opacity (the map is 0.08) */
  @keyframes fade-in {
    from { opacity: 0; }
  }

  .world-map-wrap .world-map,
  .dot-texture {
    animation: fade-in 1.6s ease-out both;
  }

  .intro .portrait,
  .intro .bio > *,
  .intro .education {
    animation: rise-in 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  .intro .portrait          { animation-delay: 0.05s; }
  .intro .bio > h1          { animation-delay: 0.12s; }
  .intro .bio > .role       { animation-delay: 0.2s; }
  .intro .bio > .profile-links { animation-delay: 0.28s; }
  .intro .bio > p:nth-of-type(2) { animation-delay: 0.36s; }
  .intro .bio > p:nth-of-type(3) { animation-delay: 0.44s; }
  .intro .education         { animation-delay: 0.4s; }

  /* Below the intro: same rise, distance, speed and curve as above */
  .reveal-ready main h2,
  .reveal-ready .paper,
  .reveal-ready .talk-photo,
  .reveal-ready .cv-note {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.7s cubic-bezier(0.2, 0.7, 0.2, 1),
                transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
    transition-delay: var(--reveal-delay, 0s);
  }

  .reveal-ready .is-visible {
    opacity: 1;
    transform: none;
  }
}

/* Printing: always show everything */
@media print {
  .reveal-ready main h2,
  .reveal-ready .paper,
  .reveal-ready .talk-photo,
  .reveal-ready .cv-note {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  body {
    font-size: 1.1875rem;
  }

  h1 {
    font-size: 1.85rem;
  }

  main {
    padding: 2rem 0 3rem;
  }

  .intro {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas:
      "photo"
      "bio"
      "edu";
    gap: 1.5rem;
  }

  .education {
    margin-top: 0;
  }

  .profile-links {
    gap: 0.35rem 1.1rem;
  }

  .portrait {
    width: 12rem;
  }

  .bio p:not(.role) {
    font-size: 1.1rem;
  }

  .paper-story {
    padding-left: 1rem;
    font-size: 1.1rem; /* same as the bio on phones */
  }

  .cv-note {
    font-size: 1.1rem; /* same as the bio on phones */
  }

}
