/* Corentin Ravoux, personal research site.
   Palette sampled from the dark-matter field image used in the hero.

   Two colour roles, one rule each:
     mint   (#86e0b4)  interactive ink: links, tool names
     signal (#f77f00)  emphasis: primary button, "major contribution" mark
   Redshift labels interpolate between the two (mint at z = 0, signal at z ~ 4),
   so the page literally redshifts as you scroll through it.

   Shape rule: interactive elements are pills, containers use --radius.
   z-index scale: grain 5, rail 20, mobile redshift bar 30, skip link 40.      */

:root {
  --void:      #060d18;   /* page ground, the empty regions of the sim       */
  --deep:      #0b1c2e;   /* panels                                          */
  --filament:  #2f8f8a;   /* the teal of the cosmic web                      */
  --mint:      #86e0b4;   /* the brightest halos                             */
  --paper:     #e6edf3;
  --muted:     #8aa2b2;
  --signal:    #f77f00;   /* the f(R) curve of my own plots                  */
  --plate:     #eef2f6;   /* mat behind the white-background figures       */
  --rule:      rgba(134, 224, 180, .16);
  --rule-soft: rgba(134, 224, 180, .09);

  --display: "Newsreader", Georgia, serif;
  --body:    "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --rail:    116px;         /* width reserved for the redshift axis            */
  --measure: 64ch;
  --radius:  10px;
  --ease:    cubic-bezier(.16, 1, .3, 1);

  --zmix: 0%;               /* position on the redshift colour scale          */
  --zc:   var(--mint);
}

@supports (color: color-mix(in oklab, red, blue)) {
  :root, .sec, .tick { --zc: color-mix(in oklab, var(--mint), var(--signal) var(--zmix)); }
}

/* redshift of each stop, as log(1 + z) / log(5.2): z = 0 -> 0%, z = 4.2 -> 100% */
#velocities, .tick[href="#velocities"] { --zmix: 4%; }
#anisotropy, .tick[href="#anisotropy"] { --zmix: 8%; }
#bao,        .tick[href="#bao"]        { --zmix: 50%; }
#tomography, .tick[href="#tomography"] { --zmix: 76%; }
#lya,        .tick[href="#lya"]        { --zmix: 92%; }

* { 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(--void);
  color: var(--paper);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* film grain: fixed, never repainted on scroll */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 5; pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: var(--mint); text-decoration: none; transition: color .2s var(--ease); }
a:hover { color: var(--signal); }
a:focus-visible,
button:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; border-radius: 4px; }

h1, h2, h3 { font-family: var(--display); font-weight: 400; letter-spacing: -.012em; text-wrap: balance; }
h2 { font-size: clamp(2rem, 3.6vw, 3rem); line-height: 1.1; margin: 0 0 1.3rem; }
h3 { font-size: 1.32rem; line-height: 1.25; margin: 0 0 .6rem; }
p  { max-width: var(--measure); text-wrap: pretty; }
.lede { font-size: 1.18rem; line-height: 1.6; color: #cfdae4; margin-top: 0; }
sub, sup { line-height: 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 40;
  background: var(--signal); color: var(--void); padding: .6rem 1rem;
  border-radius: 999px; font-family: var(--mono); font-size: .8rem;
  transition: top .2s var(--ease);
}
.skip:focus { top: 1rem; color: var(--void); }

/* ---------------------------------------------------------------- redshift rail */
.rail {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--rail);
  padding: 4rem 0; z-index: 20;
  display: flex; flex-direction: column; justify-content: space-evenly;
  font-family: var(--mono); font-size: .72rem;
  border-right: 1px solid var(--rule);
  background: linear-gradient(180deg, rgba(6,13,24,.92), rgba(6,13,24,.78));
  backdrop-filter: blur(6px);
}
.rail::before,                      /* the axis itself */
.rail__fill {
  content: ""; position: absolute; left: 26px; top: 5rem; bottom: 5rem; width: 1px;
}
.rail::before { background: linear-gradient(180deg, var(--rule), var(--filament), var(--rule)); }
.rail__fill {                       /* how far back you have read, light redshifting */
  width: 2px; left: 25.5px; clip-path: inset(0 0 100% 0); opacity: 0;
  background: linear-gradient(180deg, var(--mint), var(--signal));   /* fixed, revealed by clipping */
}
.rail__label {
  position: absolute; left: 18px; font-size: .62rem; letter-spacing: .14em;
  color: var(--muted); text-transform: uppercase;
}
.rail__label--top { top: 3.4rem; }
.rail__label--bottom { bottom: 3.4rem; }

.tick {
  position: relative; display: flex; align-items: center; gap: .55rem;
  padding: .5rem 0 .5rem 12px; color: var(--muted); white-space: nowrap;
}
.tick::before {                     /* tick mark on the axis */
  content: ""; width: 15px; height: 1px; background: currentColor; flex: none;
  transition: height .3s var(--ease);
}
.tick:hover { color: var(--paper); }
.tick[aria-current="true"] { color: var(--zc); }
.tick[aria-current="true"]::before { height: 3px; border-radius: 2px; }

/* the same reading progress, as a hairline across the top on narrow screens */
.zbar {
  display: none; position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 30;
  clip-path: inset(0 100% 0 0);
  background: linear-gradient(90deg, var(--mint), var(--signal));
}

@supports (color: color-mix(in oklab, red, blue)) {
  /* the rail fill takes each tick's own colour where it passes that tick
     (tick positions measured along the fill: 7, 20, 32, 44, 56, 68 %) */
  .rail__fill { background: linear-gradient(180deg,
      var(--mint) 7%,
      color-mix(in oklab, var(--mint), var(--signal) 4%) 20%,
      color-mix(in oklab, var(--mint), var(--signal) 8%) 32%,
      color-mix(in oklab, var(--mint), var(--signal) 50%) 44%,
      color-mix(in oklab, var(--mint), var(--signal) 76%) 56%,
      color-mix(in oklab, var(--mint), var(--signal) 92%) 68%,
      var(--signal) 80%); }
}

@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .rail__fill { opacity: 1; animation: fill-y linear both; animation-timeline: scroll(root); }
    .zbar { animation: fill-x linear both; animation-timeline: scroll(root); }
  }
}
/* clipping, not scaling: each point of the gradient keeps its own redshift colour */
@keyframes fill-y { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes fill-x { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

/* --------------------------------------------------------------------- layout */
.page { margin-left: var(--rail); }
.wrap { width: 100%; max-width: 1180px; margin-inline: auto; padding-inline: clamp(1.25rem, 4vw, 3rem); }

section { padding-block: 7.5rem 8rem; border-top: 1px solid var(--rule-soft); }

/* research sections: redshift label in the left column, content in the right */
.sec__grid { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); column-gap: 3rem; }
.sec__body { min-width: 0; }

.zmark {
  margin: .55rem 0 0; display: flex; flex-direction: column; gap: .35rem;
  position: sticky; top: 2.5rem; align-self: start;
}
.zmark__z {
  font-family: var(--mono); font-size: 1.28rem; letter-spacing: -.01em;
  color: var(--zc); white-space: nowrap;
}
.zmark__z::before {                 /* a short stroke in the redshift colour */
  content: ""; display: block; width: 2.2rem; height: 2px; margin-bottom: .7rem;
  background: var(--zc);
}
.zmark__what { font-family: var(--mono); font-size: .74rem; color: var(--muted); line-height: 1.45; }

/* ----------------------------------------------------------------------- hero */
.hero {
  position: relative; min-height: min(92dvh, 900px); display: flex; align-items: center;
  padding-block: 6rem; overflow: hidden; border-top: 0;
}
.hero__bg { position: absolute; inset: 0; z-index: 0;
  background: radial-gradient(120% 90% at 30% 40%, #10314a 0%, #071324 55%, var(--void) 100%); }
.hero__bg picture { display: block; width: 100%; height: 100%; }
.hero__bg img { width: 100%; height: 100%; object-fit: cover; opacity: .55; mix-blend-mode: screen; }
.hero__bg::after {                  /* fade the field into the page */
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(6,13,24,.55) 0%, rgba(6,13,24,0) 60%),
    linear-gradient(180deg, rgba(6,13,24,.3) 0%, rgba(6,13,24,.7) 64%, var(--void) 100%);
}
.hero .wrap { position: relative; z-index: 1; }

.hero h1 {
  font-size: clamp(3.4rem, 9vw, 7rem); line-height: .94; letter-spacing: -.025em;
  font-weight: 300; margin: 0 0 1.6rem;
}
.hero__thesis {
  font-size: clamp(1.15rem, 2vw, 1.45rem); line-height: 1.5; color: #d9e4ee;
  max-width: 34ch; margin: 0 0 2rem;
}
.hero__thesis em { font-family: var(--display); font-size: 1.08em; line-height: 1; color: var(--mint); }

.meta {
  display: flex; flex-wrap: wrap; gap: .5rem 0; margin: 0 0 2.4rem; padding: 0; list-style: none;
  font-family: var(--mono); font-size: .78rem; color: var(--muted); letter-spacing: .03em;
}
.meta li { padding-inline: 1rem; border-left: 1px solid var(--rule); }
.meta li:first-child { padding-left: 0; border-left: 0; }
.meta b { color: var(--paper); font-weight: 400; }

@media (prefers-reduced-motion: no-preference) {
  .hero h1, .hero__thesis, .meta, .hero .actions { animation: rise 1s var(--ease) both; }
  .hero__thesis { animation-delay: .12s; }
  .meta         { animation-delay: .24s; }
  .hero .actions { animation-delay: .36s; }
  .hero__bg img { animation: settle 2.4s var(--ease) both; }
}
@keyframes rise   { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes settle { from { opacity: 0; transform: scale(1.04); } to { opacity: .55; transform: none; } }

/* -------------------------------------------------------------------- buttons */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .9rem 1.4rem; margin-top: 2.6rem; }
.hero .actions { margin-top: 0; }
.btn {
  display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap;
  font-family: var(--mono); font-size: .8rem; letter-spacing: .04em;
  border: 1px solid var(--rule); border-radius: 999px; padding: .72rem 1.25rem;
  color: var(--paper);
  transition: border-color .2s var(--ease), color .2s var(--ease), background .2s var(--ease), transform .15s var(--ease);
}
.btn:hover { border-color: var(--mint); color: var(--mint); background: rgba(134,224,180,.06); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn--primary { background: var(--signal); border-color: var(--signal); color: var(--void); font-weight: 500; }
.btn--primary:hover { background: #ff9426; border-color: #ff9426; color: var(--void); }
.link-quiet {
  font-family: var(--mono); font-size: .8rem; color: var(--paper);
  border-bottom: 1px solid var(--rule); padding-bottom: 2px;
}
.link-quiet:hover { color: var(--mint); border-bottom-color: var(--mint); }

/* ---------------------------------------------------------------------- about */
.about { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 3.5rem; align-items: start; }
.portrait {
  width: 100%; height: auto; aspect-ratio: 1 / 1.08; object-fit: cover; display: block;
  border-radius: var(--radius); filter: grayscale(.15) contrast(1.03);
  box-shadow: 0 30px 60px -30px rgba(2, 8, 18, .9);
}
.portrait--empty { display: grid; place-items: center; background: var(--deep);
  font-family: var(--mono); font-size: .7rem; color: var(--muted); }

.facts {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.6rem 2.6rem;
  margin: 2.6rem 0 0; padding-top: 2rem; border-top: 1px solid var(--rule);
  font-size: .93rem; line-height: 1.55;
}
.facts div { min-width: 0; }
.facts div:last-child:nth-child(odd) { grid-column: 1 / -1; }
.facts dt { font-family: var(--mono); font-size: .76rem; color: var(--filament); margin-bottom: .3rem; }
.facts dd { margin: 0; color: var(--muted); }
.facts dd b { color: var(--paper); font-weight: 500; }

/* -------------------------------------------------------------------- figures */
figure { margin: 0; }
.plate {
  background: var(--plate); border-radius: var(--radius); padding: clamp(8px, 1.1vw, 14px);
  box-shadow: 0 34px 70px -36px rgba(2, 8, 18, .95);
}
.plate img, .band img { display: block; width: 100%; height: auto; }
.plate img { border-radius: calc(var(--radius) - 4px); }
figcaption {
  font-family: var(--mono); font-size: .76rem; line-height: 1.6; color: var(--muted);
  margin-top: .9rem; max-width: var(--measure);
}

/* growth: text beside a figure that stays in view while you read */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 3.2rem; align-items: start; margin-top: 2.6rem; }
.split p:first-child { margin-top: 0; }
.split > figure { position: sticky; top: 3rem; }

/* anisotropy: three recovered numbers, then the method */
.results {
  display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr) minmax(0, 1fr);
  margin: 2.8rem 0 0; border-block: 1px solid var(--rule);
}
.result { padding: 1.7rem 1.6rem 1.5rem 0; display: flex; flex-direction: column-reverse; justify-content: flex-end; }
.result dd { margin: 0; }
.result + .result { padding-left: 1.6rem; border-left: 1px solid var(--rule-soft); }
.result__value {
  display: block; font-family: var(--display); font-weight: 300; line-height: 1;
  font-size: clamp(2.6rem, 4.6vw, 3.8rem); letter-spacing: -.02em; color: var(--paper);
  font-variant-numeric: tabular-nums;
}
.result__unit { font-family: var(--mono); font-size: .8rem; color: var(--zc); margin-left: .35rem; letter-spacing: 0; }
.result__what { display: block; margin-top: .7rem; margin-bottom: 0; font-family: var(--mono); font-size: .76rem; color: var(--muted); }
.results-note { font-family: var(--mono); font-size: .76rem; color: var(--muted); margin: .9rem 0 0; max-width: none; }

.after-results { margin-top: 3rem; }
.after-results p { margin: 0; }

/* BAO: wide figure with its caption alongside, then two text columns */
.figure--side {
  display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 1.8rem;
  align-items: end; margin-top: 2.8rem;
}
.figure--side figcaption { margin: 0 0 .4rem; }
.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3rem; margin-top: 2.8rem; }
.columns p { margin: 0; }

/* tomography: the map runs the full width of the page */
.band {
  margin: 3.4rem auto 0; max-width: 1480px; padding-inline: clamp(.5rem, 2vw, 2rem);
  position: relative;
}
.band::before {                     /* a faint glow so the iso-surfaces read on the dark */
  content: ""; position: absolute; inset: 10% 8%; z-index: -1;
  background: radial-gradient(ellipse at center, rgba(47,143,138,.16), transparent 70%);
}
.band figcaption { margin: .6rem auto 0; text-align: center; }
.split--plate { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); margin-top: 3.4rem; }
.split--plate > figure { position: static; }
.split--plate p + p { margin-top: 1.2rem; }

/* Lyman-alpha: wide figure, then text beside the simulation aside */
.figure--wide { margin-top: 2.8rem; }
.figure--wide .plate { max-width: 860px; }
.with-aside { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 3rem; margin-top: 3rem; align-items: start; }
.with-aside p:first-child { margin-top: 0; }
.aside {
  background: linear-gradient(160deg, rgba(47,143,138,.14), rgba(11,28,46,.6));
  border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.8rem 1.8rem 1.6rem;
}
.aside p { font-size: .95rem; color: #c2d0db; margin: 0; }

/* ------------------------------------------------------------------- software */
.tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3rem 3.4rem; margin-top: 3rem; }
.tools__group--wide { grid-column: 1 / -1; }
.tools ul { list-style: none; margin: 1rem 0 0; padding: 0; border-top: 1px solid var(--rule); }
.tool {
  display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 1.2rem;
  padding: 1rem .4rem; border-bottom: 1px solid var(--rule-soft); color: var(--muted);
  font-size: .93rem; line-height: 1.55;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.tool:hover { background: rgba(134,224,180,.04); color: #b9c8d4; }
.tool__name { font-family: var(--mono); font-size: .9rem; color: var(--mint); transition: transform .25s var(--ease), color .2s var(--ease); }
.tool:hover .tool__name { color: var(--signal); transform: translateX(4px); }

/* -------------------------------------------------------------- publications */
.pubs { list-style: none; margin: 2.4rem 0 0; padding: 0; }
.pub { display: grid; grid-template-columns: 5.4rem minmax(0, 1fr); gap: 1.4rem;
  padding: 1.1rem 0; border-top: 1px solid var(--rule-soft); }
.pub:last-child { border-bottom: 1px solid var(--rule-soft); }
.pub__year { font-family: var(--mono); font-size: .82rem; color: var(--filament); padding-top: .2rem;
  font-variant-numeric: tabular-nums; }
.pub__title { display: block; color: var(--paper); line-height: 1.45; }
.pub__title:hover { color: var(--signal); }
.pub__meta { display: block; font-family: var(--mono); font-size: .76rem; color: var(--muted); margin-top: .35rem; }
.mark-lead { color: var(--signal); }
.pub__year--repeat { color: rgba(47, 143, 138, .35); }
.pubs--lead-only .pub__year--repeat { color: var(--filament); }
.pub--lead .pub__year::after { content: " ●"; color: var(--signal); font-size: .62rem; vertical-align: .18em; }

.filter { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 2.4rem; }
.filter button {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .03em; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid var(--rule);
  border-radius: 999px; padding: .55rem 1.1rem;
  transition: color .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease);
}
.filter button:hover { color: var(--paper); border-color: var(--mint); }
.filter button[aria-pressed="true"] { color: var(--void); background: var(--mint); border-color: var(--mint); }
.pubs--lead-only .pub:not(.pub--lead) { display: none; }

.page--plain { margin-left: 0; }
.page--plain section { border-top: 0; padding-top: 5rem; }
.page--plain h1 { font-size: clamp(2.6rem, 6vw, 4.4rem); line-height: 1; margin: 1.6rem 0 1rem; font-weight: 300; }

/* -------------------------------------------------------------------- footer */
footer { padding: 5rem 0 6rem; border-top: 1px solid var(--rule-soft); }
.footer__links { display: flex; flex-wrap: wrap; gap: 1.2rem 2.4rem; align-items: baseline; }
footer a { font-family: var(--mono); font-size: .85rem; }
.colophon { font-family: var(--mono); font-size: .72rem; color: var(--muted); margin: 2.6rem 0 0; line-height: 1.7; }

/* --------------------------------------------------------------- scroll reveal */
@media (prefers-reduced-motion: no-preference) {
  .js .reveal { opacity: 0; transform: translateY(20px);
    transition: opacity .9s var(--ease), transform .9s var(--ease); }
  .js .reveal.is-in { opacity: 1; transform: none; }
}

/* ----------------------------------------------------------- medium screens */
@media (max-width: 1100px) {
  .sec__grid { grid-template-columns: minmax(0, 1fr); }
  .zmark { position: static; flex-direction: row; align-items: baseline; gap: 1rem; margin: 0 0 1.4rem; }
  .zmark__z { font-size: 1.05rem; }
  .zmark__z::before { display: inline-block; vertical-align: middle; width: 1.4rem; margin: 0 .7rem .2rem 0; }
  .figure--side { grid-template-columns: minmax(0, 1fr); }
}

/* -------------------------------------------------------------------- mobile */
@media (max-width: 900px) {
  .rail { display: none; }
  .zbar { display: block; }
  .page { margin-left: 0; }
  section { padding-block: 4.8rem 5.2rem; }
  .hero { min-height: 86dvh; padding-block: 5rem 4rem; }
  .about { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
  .portrait { max-width: 11rem; }
  .facts, .split, .split--plate, .columns, .with-aside, .tools { grid-template-columns: minmax(0, 1fr); }
  .split { gap: 2.2rem; }
  .split > figure { position: static; }
  .results { grid-template-columns: minmax(0, 1fr); }
  .result, .result + .result { padding: 1.3rem 0; border-left: 0; }
  .result + .result { border-top: 1px solid var(--rule-soft); }
  .columns { gap: 1.6rem; }
  .tool { grid-template-columns: minmax(0, 1fr); gap: .25rem; }
  .meta { flex-direction: column; }
  .meta li { padding-inline: 0; border-left: 0; }
}
