/* ─────────────────────────────────────────────────────────────
   Pol Brun Martí — site styles
   Bold orange page, near-black text.
   Instrument Serif for headlines, Inter for reading.
   ───────────────────────────────────────────────────────────── */

:root {
  --orange: #ff8a1f;      /* top band: header and first view */
  --bg: #ffffff;          /* white for the reading part */
  --surface: #f2f2f2;
  --mt: 72px;             /* space between header and content */
  --text: #0b0a08;        /* near-black text */
  --text-2: #0b0a08;
  --muted: #0b0a08;
  --accent: #0b0a08;      /* labels and arrows: black too */
  --rule: rgba(11,10,8,.22);
  --rule-2: rgba(11,10,8,.38);
  --serif: "Neue Haas Grotesk Display Pro", "Neue Haas Grotesk Text Pro", "Helvetica Neue", "Inter Tight", Helvetica, Arial, sans-serif;
  --sans: "Neue Haas Grotesk Display Pro", "Neue Haas Grotesk Text Pro", "Helvetica Neue", "Inter Tight", Helvetica, Arial, sans-serif;
  --wide: 1120px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16.5px;
  font-weight: 400;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}
body { overflow-x: clip; }

::selection { background: #0b0a08; color: #ff8a1f; }

a { color: var(--text); text-decoration: none; }
a:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; border-radius: 2px; }

/* Links with an underline that draws in from the left on hover */
.ul { position: relative; }
.ul::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: right;
  transition: transform .6s var(--ease);
}
.ul:hover::after, .ul:focus-visible::after { transform: scaleX(1); transform-origin: left; }

.wrap { width: 100%; max-width: var(--wide); margin: 0 auto; padding: 0 40px; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; background: var(--text); color: var(--bg); padding: 8px 12px; z-index: 50; }

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--orange);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .4s ease;
}
.site-header.scrolled { border-bottom-color: var(--rule); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; padding-top: 22px; padding-bottom: 22px;
}
.brand { font-size: 14px; font-weight: 500; letter-spacing: .01em; }
.brand .brk { font-weight: 400; }
.brand .brk:first-child { margin-right: .1em; }
.brand .brk:last-child { margin-left: .1em; }

.nav { display: flex; gap: 34px; font-size: 13.5px; }
.nav a { color: var(--muted); position: relative; padding: 4px 0; transition: color .4s ease; }
.nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: var(--accent); transform: scaleX(0); transform-origin: right;
  transition: transform .6s var(--ease);
}
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--accent); }
.nav a::after { display: none; } /* brackets replace the underline in the menu */
/* Current page shows in brackets, like the name: [About] */
.nav .nb { display: inline-block; font-weight: 400; opacity: 0; transition: opacity .6s ease, transform .6s var(--ease); }
.nav .nb:first-child { margin-right: .1em; transform: translateX(-4px); }
.nav .nb:last-child { margin-left: .1em; transform: translateX(4px); }
.nav a:hover .nb, .nav a:focus-visible .nb { opacity: 1; transform: none; }
.nav a[aria-current="page"] .nb { opacity: 1; transform: none; animation: nb-in .7s var(--ease) both .15s; }
@keyframes nb-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .nav a[aria-current="page"] .nb { animation: none; } }

/* ── Type ───────────────────────────────────────────────── */
main { flex: 1; }
/* main also has .wrap (side padding), so the bottom space needs the extra class to apply */
main.wrap { padding-bottom: 120px; }

.eyebrow {
  font-size: 11.5px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 22px;
}

.display {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(44px, 6.2vw, 84px); line-height: 1.02; letter-spacing: -0.04em; font-weight: 500;
  margin: 0;
}
.display em { font-style: normal; font-weight: 300; color: var(--muted); }
.hero-name { font-size: clamp(38px, 5vw, 68px); }
.nw { white-space: nowrap; }

.lede {
  color: var(--text-2); font-size: clamp(17px, 1.6vw, 19px); font-weight: 400;
  line-height: 1.65; max-width: 44ch; margin: 28px 0 0;
}

.page-head { padding: 24px 0 64px; }
/* Orange band behind the first view, running edge to edge */
.hero, .page-head { position: relative; }
.hero::before, .page-head::before {
  content: ""; position: absolute; z-index: -1; top: calc(-1 * var(--mt)); bottom: 0;
  left: 50%; width: 100vw; transform: translateX(-50%); background: var(--orange);
}
.page-head + * { margin-top: 56px; }
.hero + .section { border-top: 0; }
.js .hero + .section.line::before { display: none; }

/* Masked headline lines that rise into place when the page opens */
.rise { display: block; overflow: hidden; padding-bottom: .06em; margin-bottom: -.06em; }
.rise > span { display: block; }
.js .rise > span { transform: translateY(105%); animation: rise 1.3s var(--ease) forwards; animation-delay: calc(var(--d, 0) * 110ms + 80ms); }
@keyframes rise { to { transform: none; } }

/* ── Scroll / load reveal ───────────────────────────────── */
.js [data-reveal] {
  opacity: 0; transform: translateY(18px);
  transition: opacity 1.1s var(--ease), transform 1.1s var(--ease);
  transition-delay: calc(var(--d, 0) * 90ms);
}
.js [data-reveal].in { opacity: 1; transform: none; }

/* Divider lines that draw across as they come into view */
.js .line { position: relative; border-top-color: transparent !important; }
.js .line::before {
  content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1px; background: var(--rule-2);
  transform: scaleX(0); transform-origin: left; transition: transform 1.4s var(--ease);
  transition-delay: calc(var(--d, 0) * 90ms);
}
.js .line.in::before { transform: scaleX(1); }

/* ── About: hero ───────────────────────────────────────── */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 64px; align-items: end; padding: 8px 0 88px;
}
.facts { display: flex; flex-wrap: wrap; gap: 0; margin: 44px 0 0; padding: 0; list-style: none; }
.facts li { padding: 0 26px 0 0; margin: 0 26px 10px 0; border-right: 1px solid var(--rule-2); }
.facts li:last-child { border-right: 0; margin-right: 0; padding-right: 0; }
.facts .k { display: block; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.facts .v { font-size: 15px; color: var(--text); }

.portrait { margin: 0; position: relative; overflow: hidden; border-radius: 2px; background: var(--surface); aspect-ratio: 4 / 5; }
.portrait img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; filter: grayscale(100%) contrast(1.04) brightness(.92); }
.js .portrait { clip-path: inset(100% 0 0 0); animation: unveil 1.6s var(--ease) .35s forwards; }
.js .portrait img { transform: scale(1.12); animation: settle 2.2s var(--ease) .35s forwards; }
@keyframes unveil { to { clip-path: inset(0 0 0 0); } }
@keyframes settle { to { transform: scale(1); } }

/* ── Sections (label on the left, content on the right) ── */
.section {
  display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px;
  padding: 56px 0; border-top: 1px solid var(--rule);
}
.section-label {
  font-size: 11.5px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent); margin: 6px 0 0; position: sticky; top: 100px; align-self: start;
}
.section-body > :first-child { margin-top: 0; }

.item { padding: 0 0 36px; }
.item:last-child { padding-bottom: 0; }
.item-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 24px; flex-wrap: wrap; }
.item-title { font-family: var(--serif); font-weight: 500; font-size: 23px; line-height: 1.2; letter-spacing: -0.02em; margin: 0; }
.item-dates { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-sub { color: var(--text-2); font-size: 15px; margin: 4px 0 0; }
.item-sub span + span::before { content: "·"; margin: 0 10px; color: var(--muted); }

.points { list-style: none; margin: 16px 0 0; padding: 0; color: var(--text-2); font-weight: 400; }
.points li { position: relative; padding-left: 26px; margin: 8px 0; }
.points li::before { content: ""; position: absolute; left: 0; top: .85em; width: 12px; height: 1px; background: var(--accent); opacity: .7; }

.kv { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 14px 32px; margin: 0; }
.kv dt { font-size: 14px; color: var(--muted); }
.kv dd { margin: 0; color: var(--text); }

.prose { color: var(--text-2); font-weight: 400; max-width: 62ch; }
.prose p { margin: 0 0 16px; }

/* Compact one-line rows (About page) */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) 96px; gap: 8px 32px;
  align-items: baseline; padding: 18px 0; border-top: 1px solid var(--rule);
}
.row:first-child { border-top: 0; padding-top: 0; }
.row-name strong { display: block; font-weight: 500; font-size: 18px; letter-spacing: -0.02em; line-height: 1.3; }
.row-name span { display: block; font-size: 14px; }
.row-text { margin: 0; font-size: 15px; line-height: 1.6; }
.row-dates { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.toolkit {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 40px;
  padding: 48px 0 0; border-top: 1px solid var(--rule);
}
.toolkit .section-label { margin: 0 0 8px; }
.toolkit-text { margin: 0; font-size: 15px; line-height: 1.6; }

/* ── Research list ─────────────────────────────────────── */
.entries { list-style: none; margin: 0; padding: 0; }
.entry {
  display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px;
  padding: 52px 0; border-top: 1px solid var(--rule);
}
.entry:first-child { border-top: 0; }
.entry-meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 10px; line-height: 1.8; }
.entry-meta .venue { display: block; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; }
.entry-title { font-family: var(--serif); font-weight: 500; font-size: clamp(28px, 3.3vw, 40px); line-height: 1.1; letter-spacing: -0.03em; margin: 0 0 18px; }
.entry-title a { background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size .7s var(--ease); }
.entry-title a:hover { background-size: 100% 1px; }
.entry-body { color: var(--text-2); font-weight: 400; max-width: 62ch; }
.entry-body p { margin: 0 0 12px; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 0; padding: 0; list-style: none; }
.tag { font-size: 12px; color: var(--text-2); border: 1px solid var(--rule-2); border-radius: 999px; padding: 3px 12px; }

.links { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 26px; font-size: 14px; }
.arrow { display: inline-flex; align-items: center; gap: 10px; }
.arrow svg { color: var(--accent); width: 12px; height: 12px; transition: transform .5s var(--ease); }
.arrow:hover svg { transform: translate(3px, -3px); }

/* ── Projects ──────────────────────────────────────────── */
.project { padding: 56px 0; border-top: 1px solid var(--rule); }
.project:first-child { border-top: 0; }
.project .entry-title { margin-bottom: 8px; }
.label { font-size: 11px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); margin: 32px 0 12px; }
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.result { padding: 20px 22px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.result-value { font-family: var(--serif); font-weight: 400; letter-spacing: -0.03em; font-size: 36px; line-height: 1; font-variant-numeric: tabular-nums; }
.result-label { font-size: 13px; color: var(--muted); margin-top: 10px; }
.project figure { margin: 24px 0 0; }
.project figure img { width: 100%; height: auto; border: 1px solid var(--rule); display: block; }
.project figcaption { font-size: 13px; color: var(--muted); margin-top: 10px; }

.empty {
  margin-top: 64px; border: 1px solid var(--rule); padding: 72px 48px;
  position: relative; overflow: hidden; text-align: center;
}
.empty::after { /* a slow light that drifts across the panel */
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -40%;
  background: linear-gradient(90deg, transparent, rgba(11,10,8,.05), transparent);
  animation: drift 7s ease-in-out infinite;
}
@keyframes drift { to { left: 100%; } }
.empty .display-sm { font-family: var(--serif); font-style: normal; font-weight: 500; letter-spacing: -0.035em; font-size: clamp(34px, 4.4vw, 52px); line-height: 1.05; margin: 0 0 18px; }
.empty p { margin: 0 auto; color: var(--text-2); font-weight: 400; max-width: 46ch; }

/* ── Contact ───────────────────────────────────────────── */
.contact-list { list-style: none; margin: 0; padding: 0; }
.contact-list li { border-bottom: 1px solid var(--rule); }
.contact-row {
  display: grid; grid-template-columns: 220px minmax(0, 1fr) auto; gap: 40px; align-items: baseline;
  padding: 30px 0; transition: padding .6s var(--ease);
}
.contact-row .k { font-size: 11.5px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); }
.contact-row .v { font-family: var(--serif); font-weight: 400; letter-spacing: -0.025em; font-size: clamp(24px, 3vw, 34px); line-height: 1.15; overflow-wrap: anywhere; transition: color .4s ease; }
.contact-row .go { color: var(--accent); transition: color .4s ease; }
.contact-row .go svg { width: 18px; height: 18px; transition: transform .6s var(--ease); }
a.contact-row:hover { padding-left: 14px; }
a.contact-row:hover .go { color: var(--accent); }
a.contact-row:hover .go svg { transform: translate(4px, -4px); }
.contact-row .v.sans { font-family: var(--sans); font-weight: 300; letter-spacing: -0.02em; font-size: clamp(22px, 2.9vw, 34px); }
.contact-row.off .v { color: var(--muted); }

/* ── Maths ─────────────────────────────────────────────── */
.katex { font-size: 1.05em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 6px 0; }

/* ── Footer ────────────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--rule); }
.footer-inner.wrap {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px 24px;
  padding-top: 28px; padding-bottom: calc(32px + env(safe-area-inset-bottom)); font-size: 13px; color: var(--muted);
}
.footer-links { display: flex; gap: 24px; flex-wrap: wrap; }
.footer-links a { color: var(--text-2); }
.footer-links a:hover { color: var(--text); }

/* ── Smooth fade between pages (supported browsers) ────── */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .45s; }

/* ── Tablets and phones ────────────────────────────────── */
@media (max-width: 860px) {
  .wrap { padding: 0 24px; }
  .hero { grid-template-columns: 1fr; gap: 44px; padding-bottom: 64px; }
  .portrait { max-width: 340px; order: -1; }
  .section, .entry { grid-template-columns: 1fr; gap: 18px; }
  .section-label { position: static; margin: 0; }
  .entry-meta { padding-top: 0; }
  .contact-row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 20px; }
  .contact-row .k { grid-column: 1 / -1; }
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .row-text { grid-column: 1 / -1; grid-row: 2; }
  .toolkit { grid-template-columns: 1fr; gap: 22px; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .wrap { padding: 0 20px; }
  .header-inner { padding-top: 16px; padding-bottom: 14px; gap: 8px; }
  .nav { gap: 22px; font-size: 13px; width: 100%; }
  :root { --mt: 40px; }
  main.wrap { padding-bottom: 88px; }
  .page-head { padding-bottom: 44px; }
  .portrait { max-width: 100%; aspect-ratio: 1 / 1; }
  .section { padding: 44px 0; }
  .entry, .project { padding: 40px 0; }
  .item-title { font-size: 25px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 12px; }
  .facts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
  .facts li { border-right: 0; margin: 0; padding: 0; }
  .empty { padding: 52px 24px; }
  .contact-row { padding: 24px 0; }
}

/* ── Respect visitors who prefer less motion ───────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
  .js [data-reveal] { opacity: 1; transform: none; }
  .js .rise > span { transform: none; }
  .js .portrait { clip-path: none; }
  .js .portrait img { transform: none; }
  .js .line::before { transform: scaleX(1); }
  @view-transition { navigation: none; }
}
