/* ============================================================
   Tijo Thomas — portfolio set as a scientific figure.
   Palette: matplotlib default cycle on figure-white paper.
   ============================================================ */

/* metric-tuned fallback while STIX loads — tames the layout flash */
@font-face {
  font-family: "STIX-fallback";
  src: local("Times New Roman");
  size-adjust: 104%;
}

:root {
  --paper: #fafaf6;
  --ink: #16181d;
  --muted: #5d6068;
  --grid: #e2e0d8;
  --grid-soft: #eceae2;
  --c0: #1f77b4;  /* matplotlib blue   */
  --c1: #ff7f0e;  /* matplotlib orange */
  --c1-text: #a85500;  /* orange darkened to 4.5:1 for text use */
  --c2: #2ca02c;  /* matplotlib green  */
  --c3: #d62728;  /* matplotlib red    */
  --c4: #9467bd;  /* matplotlib purple */

  --serif: "STIX Two Text", "STIX-fallback", "Times New Roman", serif;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --text-sm: 0.95rem;
  --maxw: 1080px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.04rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--c0); color: var(--paper); }

a { color: inherit; }
a:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--c0);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------- utility type ---------- */
.eyebrow, .tl-year, .ref-n, .site-nav a {
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* figure furniture stays lowercase — matplotlib never shouts */
.tick, .axis-title, .plot-legend, .fig-label {
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
}

/* ---------- header ---------- */
.site-head {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.1rem 1.5rem;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
}

.site-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.15rem;
  text-decoration: none;
}

.site-nav { display: flex; gap: 1.2rem; }
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color .2s;
  padding: 0.7rem 0.5rem;
  margin: -0.7rem -0.5rem;
}
.site-nav a:hover { color: var(--c0); }

/* ---------- hero / fig. 0 ---------- */
.hero {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1rem 1.5rem 0;
}

/* keep the y-axis labels on-screen before centering margin appears */
@media (min-width: 721px) and (max-width: 1140px) {
  .hero { padding-left: 2.75rem; }
}

.plot-frame { margin: 0; }

.plot {
  position: relative;
  min-height: min(78vh, 640px);
  min-height: min(78svh, 640px);
  border-left: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
  background-image: radial-gradient(var(--grid-soft) 1.1px, transparent 1.1px);
  background-size: 34px 34px;
  padding: 3.5rem 2.5rem 4.5rem 3rem;
  display: flex;
  align-items: center;
}

#loss-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.plot-legend {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  display: flex;
  gap: 1.1rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  padding: .35rem .6rem;
  border: 1px solid var(--grid);
}
.plot-legend .key { display: inline-flex; align-items: center; gap: .45rem; }
.swatch { width: 20px; height: 0; border-top: 2px solid; display: inline-block; }
.swatch.c0 { border-color: var(--c0); }
.swatch.c1 { border-color: var(--c1); }

/* axes */
.y-axis {
  position: absolute;
  left: -0.55rem;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  transform: translateX(-100%);
  color: var(--muted);
  padding: 0.6rem 0 0.2rem;
}
.y-axis .axis-title { writing-mode: vertical-rl; rotate: 180deg; color: var(--ink); }

.x-axis {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.5rem;
  transform: translateY(100%);
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  padding: 0.35rem 0.2rem 0;
}
.x-axis .tick:last-child { color: var(--ink); }

/* hero copy sits inside the plot */
.hero-copy {
  position: relative;
  z-index: 2;
  max-width: 34em;
}

.eyebrow { color: var(--c0); margin-bottom: 1.2rem; }

h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.5rem, 6vw, 4.4rem);
  line-height: 1.06;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
h1 em { font-style: italic; color: var(--c0); }

.hero-sub {
  margin-top: 1.4rem;
  max-width: 36em;
  color: var(--muted);
  font-size: 1.15rem;
  text-shadow: 0 0 14px var(--paper), 0 0 6px var(--paper);
}

.hero-cta { margin-top: 2rem; display: flex; gap: .9rem; flex-wrap: wrap; }

.btn {
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.75rem 1.4rem;
  border: 1.5px solid var(--ink);
  transition: transform .18s ease, background .18s ease, color .18s ease, box-shadow .18s ease;
}
.btn-solid { background: var(--ink); color: var(--paper); }
.btn-solid:hover { background: var(--c0); border-color: var(--c0); transform: translateY(-2px); }
.btn-ghost { background: var(--paper); color: var(--ink); }
.btn-ghost:hover { border-color: var(--c0); color: var(--c0); transform: translateY(-2px); }
.btn-big { display: inline-block; margin-top: 2.2rem; padding: 0.95rem 2rem; }

.fig-caption {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  padding: 2.75rem 0 0 0.2rem;
  text-transform: lowercase;
  letter-spacing: 0.04em;
}

/* ---------- page-load sequence ---------- */
.load-1, .load-2, .load-3, .load-4 {
  opacity: 0;
  transform: translateY(16px);
  animation: rise .8s cubic-bezier(.2,.7,.2,1) forwards;
}
.load-1 { animation-delay: .1s; }
.load-2 { animation-delay: .22s; }
.load-3 { animation-delay: .38s; }
.load-4 { animation-delay: .52s; }

@keyframes rise { to { opacity: 1; transform: none; } }

/* ---------- figure sections ---------- */
.fig {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 6.5rem 1.5rem 1rem;
  scroll-margin-top: 4.5rem;
}

.fig-rule {
  border-top: 1.5px solid var(--ink);
  position: relative;
  margin-bottom: 2.2rem;
}
.fig-rule::before {
  content: "";
  position: absolute;
  left: 0;
  top: -1.5px;
  height: 9px;
  border-left: 1.5px solid var(--ink);
}
.fig-label {
  position: absolute;
  top: 0.55rem;
  left: 0;
  color: var(--c0);
}

.fig h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.fig-note {
  color: var(--muted);
  margin-top: .6rem;
  max-width: 34em;
  text-wrap: pretty;
}

/* ---------- work grid ---------- */
.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.4rem;
  margin-top: 2.6rem;
}

.card {
  border: 1px solid var(--grid);
  background: #fff;
  padding: 1.6rem 1.6rem 1.4rem;
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--ink);
  box-shadow: 0 12px 30px -18px rgba(22,24,29,.35);
}

.spark { width: 100%; height: 34px; margin-bottom: 1rem; overflow: visible; }
.spark path {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 1.1s cubic-bezier(.4,0,.2,1) .15s;
}
.card.in .spark path, .card:hover .spark path { stroke-dashoffset: 0; }

.card h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1.25;
}
.card h3 a { text-decoration: none; }
.card h3 a:hover { color: var(--c0); }
.card h3 a::after { content: " ↗"; font-size: .8em; color: var(--muted); }

.card p {
  margin-top: .7rem;
  color: var(--muted);
  font-size: var(--text-sm);
  text-wrap: pretty;
}
.card .tags {
  font-family: var(--mono);
  font-size: 0.8rem;
  margin-top: 1.1rem;
  color: var(--ink);
  letter-spacing: .04em;
}

/* ---------- skills legend ---------- */
.legend {
  list-style: none;
  margin-top: 2.6rem;
  display: grid;
  gap: 0;
}
.legend li {
  display: flex;
  align-items: baseline;
  gap: 1.3rem;
  padding: 1.15rem 0.2rem;
  border-bottom: 1px dashed var(--grid);
}
.legend li:first-child { border-top: 1px dashed var(--grid); }

.legend-swatch {
  flex: 0 0 44px;
  height: 0;
  border-top: 2.5px solid;
  position: relative;
  top: -4px;
}
.legend-swatch::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: currentColor;
}
.legend-swatch.c0 { border-color: var(--c0); color: var(--c0); }
.legend-swatch.c1 { border-color: var(--c1); color: var(--c1); }
.legend-swatch.c2 { border-color: var(--c2); color: var(--c2); }
.legend-swatch.c3 { border-color: var(--c3); color: var(--c3); }
.legend-swatch.c4 { border-color: var(--c4); color: var(--c4); }

.legend strong {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.15rem;
  display: block;
}
.legend div span { color: var(--muted); font-size: var(--text-sm); }

/* ---------- timeline / fig. 3 ---------- */
.timeline {
  list-style: none;
  margin-top: 3.2rem;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1.5px solid var(--ink);
}
.timeline li {
  position: relative;
  padding: 1.6rem 1.2rem 0 0;
}
.timeline li::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c0);
}
.timeline li:last-child::before { background: var(--c1); }

.tl-year { color: var(--c0); }
.timeline li:last-child .tl-year { color: var(--c1-text); }
.timeline p { margin-top: .5rem; color: var(--muted); font-size: var(--text-sm); }

/* ---------- references / fig. 4 ---------- */
.refs {
  list-style: none;
  margin-top: 2.4rem;
  display: grid;
  gap: .9rem;
}
.ref-n { color: var(--c0); margin-right: .6rem; }
.refs em { font-family: var(--serif); }
.refs a {
  text-decoration-color: var(--muted);
  text-underline-offset: 4px;
  transition: color .2s, text-decoration-color .2s;
}
.refs a:hover { color: var(--c0); text-decoration-color: var(--c0); }

/* ---------- footer ---------- */
.site-foot {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 6rem 1.5rem 2.5rem;
}
.site-foot p {
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .05em;
  color: var(--muted);
  border-top: 1px solid var(--grid);
  padding-top: 1.4rem;
}

/* ---------- scroll reveal ---------- */
/* hidden state only when JS is running (html.js) — no-JS visitors see everything */
.reveal {
  transition: opacity .75s cubic-bezier(.2,.7,.2,1) var(--d, 0s),
              transform .75s cubic-bezier(.2,.7,.2,1) var(--d, 0s);
}
html.js .reveal:not(.in) {
  opacity: 0;
  transform: translateY(20px);
}
/* keyboard focus must never land inside an invisible block */
html.js .reveal:focus-within {
  opacity: 1;
  transform: none;
  transition: none;
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .site-head { flex-wrap: wrap; }
  .site-nav { flex-wrap: wrap; gap: .9rem; }

  .plot {
    padding: 2.5rem 1.2rem 3rem 1.4rem;
    min-height: 70vh;
    min-height: 70svh;
    border-left-width: 1px;
  }
  .y-axis { display: none; }
  .plot-legend { top: .5rem; right: .75rem; padding: .2rem .45rem; gap: .7rem; }
  .hero-copy { margin-top: 2.2rem; }
  .hero-sub { font-size: 1rem; }

  .fig { padding-top: 4.5rem; }

  .timeline {
    grid-template-columns: 1fr;
    border-top: 0;
    border-left: 1.5px solid var(--ink);
  }
  .timeline li { padding: 0 0 1.8rem 1.4rem; }
  .timeline li::before { top: 4px; left: -5px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .load-1, .load-2, .load-3, .load-4 { animation: none; opacity: 1; transform: none; }
  .reveal { transition: none; }
  html.js .reveal:not(.in) { opacity: 1; transform: none; }
  .spark path { transition: none; stroke-dashoffset: 0; }
  .btn, .card { transition: none; }
}
