:root {
  --sky-top: #6aa5d8;
  --sky-bottom: #ecdfcc;
  --ink: #2a1712;
  --ink-soft: rgba(42, 23, 18, .74);
  --ink-faint: rgba(42, 23, 18, .52);
  --rule: rgba(42, 23, 18, .16);
  --accent: #c2410c;
  --accent-ink: #fff7ef;
  --card: rgba(255, 249, 243, .94);
  --card-edge: rgba(255, 255, 255, .7);
  --chip: rgba(255, 248, 240, .6);
  --shadow: 0 1px 2px rgba(60, 25, 10, .08), 0 12px 32px -12px rgba(60, 25, 10, .28);
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Manrope', -apple-system, system-ui, 'Segoe UI', sans-serif;
  --radius: 20px;
  color-scheme: light;
}

:root[data-daypart="night"] {
  --ink: #f8ece0;
  --ink-soft: rgba(248, 236, 224, .78);
  --ink-faint: rgba(248, 236, 224, .55);
  --rule: rgba(248, 236, 224, .16);
  --accent: #ffad72;
  --accent-ink: #2a1210;
  --card: rgba(30, 18, 40, .92);
  --card-edge: rgba(255, 255, 255, .09);
  --chip: rgba(30, 18, 40, .55);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 40px -16px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

@view-transition { navigation: auto; }

* { box-sizing: border-box; }

html {
  background: linear-gradient(var(--sky-top), var(--sky-bottom)) fixed;
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  transition: color .6s ease;
  -webkit-font-smoothing: antialiased;
}

img, video { display: block; max-width: 100%; }

/* ---------- scene ---------- */

.scene {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: linear-gradient(var(--sky-top) 0%, var(--sky-bottom) 62%);
  overflow: hidden;
  view-transition-name: scene;
}
.scene svg { width: 100%; height: 100%; display: block; }
.scene .sun, .scene .moon, .scene .stars, .scene .birds { transition: opacity 1s ease; }
.scene .stars circle { animation: twinkle 6s ease-in-out infinite; }
.scene .cloud { animation: drift linear infinite; }
.scene .bird { animation: fly linear infinite; }
.scene .birds path { fill: none; stroke-width: 2; stroke-linecap: round; }
.scene .meteor {
  stroke: #fff6ea; stroke-width: 2; stroke-linecap: round;
  stroke-dasharray: 0 400; animation: meteor 1.4s ease-out forwards;
}

@keyframes twinkle { 50% { opacity: .3; } }
@keyframes drift { from { transform: translateX(-700px); } to { transform: translateX(1800px); } }
@keyframes fly { from { transform: translateX(1700px); } to { transform: translateX(-200px); } }
@keyframes meteor {
  0%   { stroke-dasharray: 0 400; stroke-dashoffset: 0; opacity: 1; }
  40%  { stroke-dasharray: 90 400; }
  100% { stroke-dasharray: 0 400; stroke-dashoffset: -300; opacity: 0; }
}

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

@media (prefers-reduced-motion: reduce) {
  .scene .stars circle, .scene .cloud, .scene .bird { animation: none; }
  @view-transition { navigation: none; }
  html { scroll-behavior: auto; }
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px);
}
.glass {
  background: var(--chip);
  border: 1px solid var(--card-edge);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.mark {
  display: inline-grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  text-decoration: none;
  color: var(--ink);
}
.menu {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  margin: 0;
  list-style: none;
  border-radius: 99px;
}
.menu a {
  display: block;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink-soft);
  transition: background .2s, color .2s;
}
.menu a:hover { color: var(--ink); background: var(--rule); }
.menu a[aria-current="page"] { background: var(--ink); color: var(--card); }
.clock {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink-soft);
  padding: 7px 12px;
  border-radius: 99px;
  white-space: nowrap;
}
.topbar-right { display: flex; gap: 10px; align-items: center; }

/* ---------- type ---------- */

a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; text-decoration-color: var(--ink-faint); }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 14px;
}
.kicker .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-right: 8px; vertical-align: 1px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
}

h1 {
  font-family: var(--serif);
  font-weight: 300;
  font-variation-settings: 'opsz' 144, 'SOFT' 50;
  font-size: clamp(52px, 10vw, 128px);
  line-height: .92;
  letter-spacing: -.025em;
  margin: 0 0 22px;
}
h1 em { font-style: italic; font-weight: 300; color: var(--accent); }

h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-variation-settings: 'opsz' 72;
  font-size: clamp(28px, 4vw, 40px);
  letter-spacing: -.01em;
  line-height: 1.05;
  margin: 0 0 18px;
}
h3 { font-size: 16px; font-weight: 700; line-height: 1.35; margin: 0; }

.lede { font-size: clamp(16px, 1.6vw, 19px); color: var(--ink-soft); max-width: 36em; margin: 0 0 28px; }

/* ---------- layout ---------- */

.wrap { width: min(1180px, 100%); margin: 0 auto; padding: 0 clamp(16px, 4vw, 48px); }
.hero { min-height: calc(100svh - 70px); display: flex; flex-direction: column; justify-content: center; padding: 40px 0 18vh; }
.page-head { padding: clamp(40px, 8vh, 90px) 0 32px; }
.section { padding: 32px 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2 { margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background .6s ease, transform .35s cubic-bezier(.2, .8, .2, 1), box-shadow .35s;
}
.pad { padding: clamp(20px, 3vw, 32px); }

.btns { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px;
  border-radius: 99px;
  font-weight: 700; font-size: 15px;
  text-decoration: none;
  color: var(--ink);
  transition: transform .2s, background .2s;
}
.btn:hover { transform: translateY(-2px); color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { color: var(--accent-ink); }

/* reveal on scroll (only when JS is running) */
.js .reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .8, .2, 1); }
.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .js .reveal { opacity: 1; transform: none; transition: none; } }

/* ---------- media ---------- */

.media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: calc(var(--radius) - 8px);
  background: #fff;
}
.media img, .media video { width: 100%; height: 100%; object-fit: cover; transition: transform .6s cubic-bezier(.2, .8, .2, 1); }
.media.contain img { object-fit: contain; padding: 8px; }
.media .play {
  position: absolute; left: 12px; bottom: 12px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 99px;
  background: rgba(20, 10, 10, .55); color: #fff;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.media.placeholder {
  display: grid; place-items: center;
  background: linear-gradient(135deg, #f6c79d, #c86a4a 55%, #5b2a3d);
  color: #fff7ef;
  font-family: var(--serif); font-style: italic; font-size: 24px; line-height: 1.15; text-align: center; padding: 20px;
}

/* ---------- featured ---------- */

.featured { display: grid; grid-template-columns: repeat(6, 1fr); gap: 18px; }
.feat { grid-column: span 2; display: flex; flex-direction: column; padding: 10px; text-decoration: none; color: inherit; }
.feat.big { grid-column: span 3; }
.featured.filtered .feat.big { grid-column: span 2; }
.feat:hover { transform: translateY(-4px); box-shadow: 0 2px 4px rgba(0,0,0,.08), 0 24px 48px -16px rgba(60, 25, 10, .45); color: inherit; }
.feat:hover .media img, .feat:hover .media video { transform: scale(1.03); }
.feat .body { padding: 14px 10px 8px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.feat .note { font-size: 14px; color: var(--ink-soft); margin: 0; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; font-weight: 700; color: var(--ink-faint); }
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  background: var(--rule); color: var(--ink-soft);
}
.tag.hot { background: var(--accent); color: var(--accent-ink); }

@media (max-width: 960px) {
  .featured { grid-template-columns: repeat(2, 1fr); }
  .feat, .feat.big { grid-column: span 1; }
}
@media (max-width: 600px) {
  .featured { grid-template-columns: 1fr; }
}

/* ---------- filters ---------- */

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.filters button {
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 7px 14px; border-radius: 99px; cursor: pointer;
  color: var(--ink-soft);
  transition: background .2s, color .2s, transform .2s;
}
.filters button:hover { color: var(--ink); transform: translateY(-1px); }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--card); border-color: transparent; }
.filters .count { opacity: .6; margin-left: 4px; font-weight: 500; }

/* ---------- paper list ---------- */

.year-group { display: grid; grid-template-columns: 110px 1fr; gap: 18px; padding: 10px 0; }
.year-label {
  font-family: var(--serif); font-size: 34px; font-weight: 300; line-height: 1;
  position: sticky; top: 84px; align-self: start; padding-top: 18px;
  color: var(--ink);
}
.papers { display: grid; gap: 12px; }
.paper { display: grid; grid-template-columns: 200px 1fr; gap: 18px; padding: 12px; align-items: center; }
.paper:hover { transform: translateX(4px); }
.paper h3 a { text-decoration: none; }
.paper h3 a:hover { text-decoration: underline; }
.paper .authors { font-size: 13.5px; color: var(--ink-soft); margin: 4px 0 0; }
.paper .authors b { color: var(--ink); font-weight: 700; }
.paper .note { font-size: 14px; color: var(--ink-soft); margin: 6px 0 0; }
.links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.links a {
  font-size: 12.5px; font-weight: 700; text-decoration: none;
  padding: 4px 11px; border-radius: 99px;
  border: 1px solid var(--rule); color: var(--ink-soft);
  transition: background .2s, color .2s, border-color .2s;
}
.links a:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.paper[hidden], .year-group[hidden], .feat[hidden] { display: none; }

@media (max-width: 760px) {
  .year-group { grid-template-columns: 1fr; gap: 6px; }
  .year-label { position: static; padding-top: 8px; font-size: 28px; }
  .paper { grid-template-columns: 1fr; }
  .paper:hover { transform: none; }
}

/* ---------- about ---------- */

.about-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; align-items: start; }
.about-grid .card p { margin: 0 0 14px; }
.about-grid .card p:last-child { margin-bottom: 0; }
.stack { display: grid; gap: 18px; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 2px; background: var(--rule); border-radius: 2px; }
.timeline li { position: relative; padding: 0 0 18px 28px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ''; position: absolute; left: 0; top: 6px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--card); border: 3px solid var(--accent);
}
.timeline .when { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); }
.timeline .what { font-weight: 700; }
.timeline .where { font-size: 14px; color: var(--ink-soft); }
.sub { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 26px 0 12px; }
.sub:first-child { margin-top: 0; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: 4px 0; font-size: 15px; color: var(--ink-soft); }
.plain li b { color: var(--ink); }

@media (max-width: 860px) { .about-grid { grid-template-columns: 1fr; } }

/* ---------- links ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; gap: 22px; padding: 22px; text-decoration: none; color: inherit; min-height: 160px; }
.tile:hover { transform: translateY(-4px) rotate(-.4deg); color: inherit; }
.tile svg { width: 26px; height: 26px; color: var(--accent); }
.tile .label { font-family: var(--serif); font-size: 28px; line-height: 1; margin-top: auto; }
.tile .hint { font-size: 13.5px; color: var(--ink-soft); margin-top: -12px; }

/* ---------- footer ---------- */

.foot { padding: 60px 0 40px; font-size: 13px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; color: rgba(255, 245, 235, .82); }
.foot a { color: #fff6ec; }

.built { display: inline-flex; align-items: center; gap: 10px; }
.walk { position: relative; width: 120px; height: 26px; }
.clawd { position: absolute; left: 0; bottom: 0; width: 34px; animation: pace 8s linear infinite; filter: drop-shadow(0 0 1px rgba(255, 245, 235, .9)) drop-shadow(0 2px 3px rgba(0, 0, 0, .35)); }
.clawd svg { display: block; width: 34px; height: 26px; animation: bob .5s steps(2) infinite; }
.clawd .legs-a { animation: step .5s steps(1) infinite; }
.clawd .legs-b { animation: step .5s steps(1) infinite reverse; }
@keyframes pace {
  0%     { transform: translateX(0) scaleX(1); }
  46%    { transform: translateX(86px) scaleX(1); }
  50%    { transform: translateX(86px) scaleX(-1); }
  96%    { transform: translateX(0) scaleX(-1); }
  100%   { transform: translateX(0) scaleX(1); }
}
@keyframes step { 0% { transform: translateY(0); } 50% { transform: translateY(-1px); } }
@keyframes bob  { 0% { transform: translateY(0); } 100% { transform: translateY(-1px); } }
@media (prefers-reduced-motion: reduce) {
  .clawd, .clawd svg, .clawd .legs-a, .clawd .legs-b { animation: none; }
}

@media (max-width: 600px) {
  .clock { display: none; }
  .menu a { padding: 6px 10px; }
  .hero { padding-bottom: 28vh; }
}
