:root {
  --paper: #f8f5ef;
  --paper-deep: #efe9de;
  --ink: #1a1a1a;
  --ink-soft: #5a5a55;
  --ink-faint: #a8a49b;
  --vermilion: #c1272d;
  --line: rgba(26, 26, 26, 0.1);

  --serif: "Cormorant Garamond", Georgia, serif;
  --script: "Pinyon Script", cursive;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: ui-sans-serif, system-ui, sans-serif;
  --ease: cubic-bezier(0.19, 1, 0.22, 1);

  --grain: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.4'/%3E%3C/svg%3E");
}

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

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; background: none; border: 0; }
button { cursor: pointer; }
ol, ul { list-style: none; }
:focus-visible { outline: 1px solid var(--ink-faint); outline-offset: 4px; }

.defs { position: absolute; }

.mono-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- Views ----------
   Every screen is a fixed, full-viewport layer. main.js reveals the next one
   with an expanding circular clip, so tabs feel like separate pages. */

.view {
  position: fixed;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper);
  padding-top: env(safe-area-inset-top, 0px);
}
.view[hidden] { display: none; }
.view:focus { outline: none; } /* focused programmatically on each switch */
.view.is-top { z-index: 2; }

/* Page content soaks in: blurred and faint, then sharp */
.view.is-in .rise {
  animation: ink-in 1.1s var(--ease) both;
  animation-delay: calc(0.2s + var(--i, 0) * 0.08s);
}
/* Pages uncovered by the ink ring arrive already settled */
.view.is-inked .rise { animation: none; }
@keyframes ink-in {
  from { opacity: 0; filter: blur(6px); transform: translateY(6px); }
  to { opacity: 1; filter: none; transform: none; }
}

/* A brushstroke drawn under each page heading */
/* The wrapper shrinks to the heading's widest line, so each stroke scales with its title */
.heading { display: inline-block; max-width: 100%; }
.brush {
  display: block;
  width: 72%;
  min-width: 110px;
  height: 14px;
  margin-top: 18px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.6;
  stroke-linecap: round;
  opacity: 0.5;
  filter: url(#enso-rough);
  stroke-dasharray: 1 2;
}
.view.is-in .brush { animation: draw 1.1s cubic-bezier(0.6, 0, 0.3, 1) 0.55s both; }
@keyframes draw {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

/* ---------- Opening: the home screen paints itself in ---------- */

.is-painting .hero__art {
  -webkit-mask-image: linear-gradient(90deg, #000 42%, transparent 58%);
          mask-image: linear-gradient(90deg, #000 42%, transparent 58%);
  -webkit-mask-size: 300% 100%;
          mask-size: 300% 100%;
  animation: wipe 2.8s cubic-bezier(0.45, 0, 0.2, 1) 0.15s both, bleed 2.8s var(--ease) 0.15s both;
}
@keyframes wipe {
  from { -webkit-mask-position: 100% 0; mask-position: 100% 0; }
  to { -webkit-mask-position: 0 0; mask-position: 0 0; }
}
@keyframes bleed {
  from { filter: blur(10px); transform: scale(1.03); }
  to { filter: none; transform: none; }
}

.is-painting .enso__stroke {
  stroke-dasharray: 1 2;
  animation: draw 1.9s cubic-bezier(0.55, 0, 0.25, 1) 0.9s both;
}
.is-painting .enso__trace { animation: fade 1.2s ease 2.4s both; }

/* The wipe runs over the whole name with generous padding, because the italic
   "j" and the script "shi" swash past their own boxes and a mask clips at the box. */
.is-painting .name {
  padding: 40px 64px;
  margin: -40px -64px;
  -webkit-mask-image: linear-gradient(90deg, #000 45%, transparent 55%);
          mask-image: linear-gradient(90deg, #000 45%, transparent 55%);
  -webkit-mask-size: 300% 100%;
          mask-size: 300% 100%;
  animation: wipe 1.6s cubic-bezier(0.45, 0, 0.3, 1) 1.6s both;
}

.is-painting .tagline__rule { animation: grow 0.9s var(--ease) 2.9s both; }
.is-painting .tagline p { animation: ink-in 1.1s var(--ease) 3.05s both; }
.is-painting .nav__item { animation: ink-in 1.1s var(--ease) both; }
.is-painting .nav__item:nth-child(1) { animation-delay: 3.25s; }
.is-painting .nav__item:nth-child(2) { animation-delay: 3.35s; }
.is-painting .nav__item:nth-child(3) { animation-delay: 3.45s; }
.is-painting .nav__item:nth-child(4) { animation-delay: 3.55s; }
.is-painting .topbar { animation: fade 1.4s ease 3.4s both; }

@keyframes fade { from { opacity: 0; } }
@keyframes grow { from { transform: scaleX(0); } }

/* ---------- Home ---------- */

.hero {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.hero__layer { position: absolute; inset: 0; }
.hero__scene { overflow: hidden; }
.hero__paper { background: var(--paper); }
.hero__grain {
  pointer-events: none;
  opacity: 0.12;
  mix-blend-mode: multiply;
  background-image: var(--grain);
}
.hero__art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 52%;
  opacity: 0.92;
  mix-blend-mode: multiply;
}
.hero__wash { background: rgba(248, 245, 239, 0.22); }
.hero__vignette {
  pointer-events: none;
  background: radial-gradient(ellipse 65% 70% at 50% 50%, transparent 55%, rgba(248, 245, 239, 0.25) 82%, rgba(248, 245, 239, 0.55) 100%);
}

.topbar { position: relative; z-index: 2; padding: 32px 24px 0; }

.hero__center {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 24px 96px;
}

.name-block { position: relative; display: flex; flex-direction: column; align-items: center; }

.enso {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 300px;
  height: 300px;
  transform: translate(-50%, -52%);
  pointer-events: none;
}

.name {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0 12px;
  line-height: 1;
  font-weight: 400;
}
.name__first {
  font-family: var(--serif);
  font-size: 56px;
  font-weight: 300;
  font-style: italic;
  letter-spacing: -0.03em;
}
.name__last {
  font-family: var(--script);
  font-size: 58px;
  letter-spacing: -0.02em;
  margin-left: 4px;
  transform: translateY(2px);
}

.tagline {
  position: relative;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.tagline__rule { height: 1px; width: 48px; background: rgba(26, 26, 26, 0.15); }
.tagline p {
  font-family: var(--mono);
  font-weight: 300;
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.tagline .sep { color: var(--ink-faint); margin: 0 0.3em; }

.nav {
  position: relative;
  margin-top: 56px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 24px;
}
.nav__item {
  position: relative;
  padding: 8px 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  transition: color 0.3s;
}
.nav__item::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 1.2px;
  width: 0;
  opacity: 0;
  background: var(--ink);
  transition: width 0.5s var(--ease), opacity 0.5s var(--ease);
}
.nav__item:hover { color: var(--ink); }
.nav__item:hover::before { width: 100%; opacity: 0.6; }

/* ---------- Inner pages ---------- */

.page {
  background-color: var(--paper);
  background-image: var(--grain);
  background-blend-mode: multiply;
  background-size: 256px;
}
/* Tone the grain down to match the home paper, with the same soft vignette */
.page::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 75% at 50% 45%, transparent 50%, rgba(232, 226, 214, 0.45) 100%),
    rgba(248, 245, 239, 0.84);
  pointer-events: none;
}
.page > * { position: relative; }

/* Faint crops of the home painting, one per page, so each page reads as
   another corner of the same scroll. Background sizes and positions crop
   the 2048×1152 source to the named figure. */
.page > .ink {
  position: fixed;
  z-index: 0;
  background-image: url("../assets/koi-enso.webp");
  background-repeat: no-repeat;
  mix-blend-mode: multiply;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(closest-side, #000 55%, transparent);
          mask-image: radial-gradient(closest-side, #000 55%, transparent);
}
.page > .page__body, .page > .masthead { z-index: 1; }

.ink--koi-left {
  width: min(680px, 90vw);
  aspect-ratio: 4 / 3;
  left: -6%;
  bottom: -14%;
  background-size: 320% auto;
  background-position: 0 53%;
  opacity: 0.24;
}
.ink--koi-right {
  width: min(660px, 90vw);
  aspect-ratio: 1.38;
  right: -5%;
  bottom: -10%;
  background-size: 337% auto;
  background-position: 100% 79%;
  opacity: 0.15;
}
.ink--enso {
  width: min(600px, 80vw);
  aspect-ratio: 1.04;
  right: -4%;
  top: 50%;
  transform: translateY(-45%);
  background-size: 379% auto;
  background-position: 49% 47%;
  opacity: 0.5;
}
.ink--contact { bottom: 6%; right: -3%; opacity: 0.26; }

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 0;
}
.masthead__mark { display: flex; align-items: baseline; gap: 8px; line-height: 1; }
.masthead__first { font-family: var(--serif); font-style: italic; font-weight: 300; font-size: 26px; letter-spacing: -0.03em; }
.masthead__last { font-family: var(--script); font-size: 27px; }
.masthead__nav { display: flex; gap: 18px; }
.masthead__nav button {
  position: relative;
  padding: 6px 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  transition: color 0.3s;
}
.masthead__nav button:hover,
.masthead__nav button[aria-current="page"] { color: var(--ink); }
.masthead__nav button::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--vermilion);
  transform: translateX(-50%) scale(0);
  transition: transform 0.3s var(--ease);
}
.masthead__nav button[aria-current="page"]::after { transform: translateX(-50%) scale(1); }

.page__body {
  max-width: 1120px;
  margin: 0 auto;
  padding: 72px 24px 96px;
}

.display {
  font-family: var(--serif);
  font-weight: 300;
  font-style: italic;
  font-size: 48px;
  line-height: 1;
  letter-spacing: -0.025em;
}

.lede { font-family: var(--serif); font-size: 21px; line-height: 1.5; letter-spacing: -0.01em; }
.body { font-size: 14px; line-height: 1.8; color: var(--ink-soft); max-width: 52ch; }

/* About */
.about { display: grid; gap: 48px; }

/* Portrait: a soft-edged circle inside a brushed enso that draws in with the page */
.portrait { position: relative; width: min(260px, 70vw); aspect-ratio: 1; }
.portrait__frame {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  overflow: hidden;
  -webkit-mask-image: radial-gradient(closest-side, #000 94%, transparent);
          mask-image: radial-gradient(closest-side, #000 94%, transparent);
}
.portrait__frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.15);
  transform-origin: 50% 30%;
}
.portrait__enso {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke-linecap: round;
  overflow: visible;
}
/* Same two-stroke recipe as the home enso, a shade darker to read on the page paper */
.portrait__stroke { stroke: #c4bdaf; stroke-width: 7; opacity: 0.75; filter: url(#enso-rough); }
.portrait__wash { stroke: #ddd7cb; stroke-width: 15; opacity: 0.45; }
.view.is-in .portrait__enso path {
  stroke-dasharray: 1 2;
  animation: draw 1.8s cubic-bezier(0.55, 0, 0.25, 1) 0.4s both;
}
.about__text > * + * { margin-top: 24px; }
.facts { margin-top: 40px !important; border-top: 1px solid var(--line); }
.facts > div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.6;
}
.facts dt {
  padding-top: 3px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.facts a { text-decoration: underline; text-decoration-color: rgba(26, 26, 26, 0.25); text-underline-offset: 4px; }
.facts a:hover { text-decoration-color: var(--ink); }

/* Work: an editorial index instead of cards */
.index { margin-top: 48px; border-top: 1px solid var(--line); }
.index__row {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 6px 16px;
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
}
.index__row::after { /* ink line drawn under the row on hover */
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 1px;
  width: 0;
  background: var(--ink);
  transition: width 0.7s var(--ease);
}
.index__row:hover::after { width: 100%; }
.index__dot {
  width: 9px;
  height: 9px;
  margin-top: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, rgba(26, 26, 26, 0.75), rgba(26, 26, 26, 0.35) 70%, transparent 72%);
  filter: url(#enso-rough);
  transition: background 0.3s, transform 0.5s var(--ease);
}
.index__row:hover .index__dot {
  background: radial-gradient(circle at 40% 40%, var(--vermilion), rgba(193, 39, 45, 0.5) 70%, transparent 72%);
  transform: scale(1.3);
}
.index__title {
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  transition: transform 0.5s var(--ease);
}
.index__row:hover .index__title { transform: translateX(6px); }
.cjk { font-family: "Songti SC", "Noto Serif SC", serif; font-size: 0.85em; }
.index__meta, .index__desc { grid-column: 2; }
.index__meta {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--ink-faint);
}
.index__desc { max-width: 60ch; font-size: 14px; line-height: 1.7; color: var(--ink-soft); }
.index__arrow {
  position: absolute;
  right: 0;
  top: 32px;
  font-size: 16px;
  color: var(--ink-faint);
  transition: color 0.3s, transform 0.5s var(--ease);
}
.index__row:hover .index__arrow { color: var(--ink); transform: translate(3px, -3px); }

/* Themes & retextures, below the project index */
.themes { margin-top: 88px; }
.themes__title {
  font-family: var(--serif);
  font-weight: 300;
  font-style: italic;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.themes__lede { margin-top: 10px; font-size: 14px; color: var(--ink-soft); }
.themes__grid { display: grid; gap: 28px; margin-top: 32px; }
.theme { display: block; }
.theme__swatch {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--line);
  margin-bottom: 16px;
  transition: transform 0.6s var(--ease), box-shadow 0.6s var(--ease);
}
.theme:hover .theme__swatch { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(26, 26, 26, 0.08); }
.theme__name { font-family: var(--serif); font-weight: 500; font-size: 22px; line-height: 1.2; }
.theme__for { margin-top: 4px; font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }
.theme__desc { margin-top: 8px; font-size: 13px; line-height: 1.65; color: var(--ink-soft); }

.theme__swatch img { width: 100%; height: 100%; object-fit: cover; object-position: top; }

/* Research: set like the title page of a paper */
.paper { max-width: 760px; }
.paper__venue {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
}
.paper__title {
  margin-top: 16px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 40px;
  line-height: 1.08;
  letter-spacing: -0.02em;
}
.paper__byline { margin-top: 16px; font-family: var(--serif); font-style: italic; font-size: 18px; color: var(--ink-soft); }
.paper__abstract { margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--line); }
.paper__label {
  margin-bottom: 12px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.paper__abstract p:last-child { font-family: var(--serif); font-size: 19px; line-height: 1.6; }
.theorem {
  margin-top: 36px;
  padding: 24px 28px;
  border-left: 2px solid var(--vermilion);
  background: rgba(255, 255, 255, 0.5);
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
  line-height: 1.6;
}
.theorem__head { font-style: normal; font-weight: 500; font-variant: small-caps; letter-spacing: 0.04em; }
.paper__links { display: flex; flex-wrap: wrap; gap: 16px 32px; margin-top: 40px; }
.paper__link {
  display: inline-block;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(26, 26, 26, 0.25);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: border-color 0.3s;
}
.paper__link:hover { border-color: var(--ink); }

/* Contact */
.contact { display: flex; flex-direction: column; align-items: flex-start; }
.contact__email {
  margin-top: 36px;
  font-family: var(--serif);
  font-weight: 300;
  font-size: 30px;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  background: linear-gradient(var(--ink), var(--ink)) 0 100% / 0 1px no-repeat;
  transition: background-size 0.7s var(--ease);
}
.contact__email:hover { background-size: 100% 1px; }
.contact__links { margin-top: 16px; font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; color: var(--ink-soft); }
.contact__links a { text-decoration: underline; text-decoration-color: rgba(26, 26, 26, 0.25); text-underline-offset: 4px; }

.note { width: 100%; max-width: 520px; margin-top: 64px; font-family: var(--mono); font-size: 13px; }
.note > * + * { margin-top: 16px; }
.note__label { font-size: 10px; letter-spacing: 0.28em; text-transform: uppercase; color: var(--ink-faint); }
.note label { display: flex; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); transition: border-color 0.3s; }
.note label:focus-within { border-color: var(--ink); }
.note label span { width: 40px; color: var(--ink-faint); }
.note input { flex: 1; min-width: 0; outline: none; }
.note input::placeholder { color: var(--ink-faint); opacity: 0.6; }
.note button {
  margin-top: 24px;
  padding: 12px 20px;
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transition: background 0.3s;
}
.note button:hover { background: var(--vermilion); }
.note__fine { font-size: 11px; color: var(--ink-faint); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* On phones the text spans the full width, so the painting stays a whisper */
@media (max-width: 767px) {
  .page > .ink { width: 80vw; opacity: 0.11; }
}

/* ---------- Tablet and up ---------- */

@media (min-width: 768px) {
  .topbar { padding: 40px 40px 0; }

  .hero__center { padding-bottom: 112px; }
  .enso { width: 420px; height: 420px; }
  .name { gap: 0 16px; }
  .name__first { font-size: 84px; }
  .name__last { font-size: 86px; margin-left: 6px; }
  .tagline { margin-top: 16px; }
  .tagline p { font-size: 12px; }
  .nav { margin-top: 64px; gap: 8px 40px; }
  .nav__item { font-size: 14px; }

  .masthead { padding: 36px 40px 0; }
  .masthead__nav { gap: 32px; }
  .masthead__nav button { font-size: 13px; }
  .page__body { padding: 112px 40px 120px; }
  .display { font-size: 76px; }
  .lede { font-size: 23px; }

  .about { grid-template-columns: 1fr 1fr; gap: 80px; align-items: start; }
  .about__intro { position: sticky; top: 112px; }
  .portrait { width: min(380px, 100%); margin-top: -24px; }

  .index__row { grid-template-columns: 48px 1.3fr 1fr; padding: 36px 48px 36px 0; }
  .index__title { font-size: 36px; }
  .index__meta { grid-column: 3; grid-row: 1; padding-top: 8px; text-align: right; }
  .index__desc { grid-column: 2 / 4; }
  .index__arrow { top: 46px; }

  .themes__grid { grid-template-columns: repeat(3, 1fr); }
  .paper__title { font-size: 60px; }
  .contact__email { font-size: 56px; }
}

@media (min-width: 1024px) {
  .topbar { padding: 40px 56px 0; }
  .enso { width: 480px; height: 480px; }
  .name__first { font-size: 92px; }
  .name__last { font-size: 94px; }
  .masthead { padding-left: 56px; padding-right: 56px; }
  .page__body { padding-left: 56px; padding-right: 56px; }
  .contact__email { font-size: 72px; }
}
