:root {
  color-scheme: light;
  --scene-rgb: 245, 238, 236;
  --scene: rgb(var(--scene-rgb));
  --glass: rgba(248, 245, 242, .68);
  --glass-strong: rgba(248, 245, 242, .82);
  --bubble-fill: rgba(248, 245, 242, .88);
  --ink: #263329;
  --ink-soft: #657066;
  --moss: #647859;
  --line: rgba(42, 58, 45, .15);
  --shadow: 0 28px 80px rgba(55, 48, 42, .12);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-toggle: cubic-bezier(.65, 0, .35, 1);
  --ease-cinematic-in: cubic-bezier(.42, 0, .72, .72);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--scene);
}

body {
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
a { font: inherit; }

button { color: inherit; }
a { color: inherit; }

.field {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 480px;
  overflow: hidden;
  isolation: isolate;
  background: var(--scene);
}

.scene,
.scene-video,
.scene-wash {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scene {
  z-index: -2;
  overflow: hidden;
  background: var(--scene);
}

.scene-video {
  display: block;
  object-fit: contain;
  object-position: center;
  opacity: 0;
  background: var(--scene);
  transition: opacity 140ms linear, transform 760ms var(--ease-out);
}

#overviewVideo {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(.84);
  transition: opacity 140ms linear, transform 1500ms var(--ease-cinematic-in);
}

#transitionVideo,
#detailVideo {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scale(1.025);
}

.scene-video.is-active { opacity: 1; }
#overviewVideo.is-active { transform: scale(.84); }
.field[data-view="preparing"] #overviewVideo.is-active,
.field[data-view="transition"] #overviewVideo {
  transform: scale(var(--overview-fill-scale, 1.08));
}

.field[data-view="transition"] #overviewVideo {
  transition-delay: 100ms, 0ms;
}

#transitionVideo.is-active,
#detailVideo.is-active { transform: scale(1); }

.scene-wash {
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(var(--scene-rgb), .14), transparent 19%, transparent 78%, rgba(var(--scene-rgb), .2)),
    radial-gradient(circle at 72% 48%, transparent 0 36%, rgba(var(--scene-rgb), .05) 76%);
  transition: background 700ms var(--ease-toggle);
}

.field[data-view="detail"] .scene-wash {
  background:
    linear-gradient(90deg, rgba(var(--scene-rgb), .03) 0 40%, rgba(var(--scene-rgb), .18) 76%, rgba(var(--scene-rgb), .28)),
    linear-gradient(180deg, rgba(var(--scene-rgb), .12), transparent 20%, transparent 80%, rgba(var(--scene-rgb), .2));
}

.site-header {
  position: absolute;
  z-index: 20;
  top: 0;
  right: 0;
  padding: max(22px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 0 0;
}

.view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.toggle-label {
  font-size: .625rem;
  font-weight: 600;
  letter-spacing: .17em;
  text-transform: uppercase;
}

.view-toggle svg {
  width: 38px;
  height: 38px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.1;
  transition: transform 600ms var(--ease-out), color 150ms linear;
}

.view-toggle .orbit-dot {
  fill: var(--scene);
  transform-box: fill-box;
  transform-origin: center;
  transition: fill 150ms linear;
}

.view-toggle:hover svg {
  color: var(--moss);
  transform: rotate(24deg);
}

.view-toggle[aria-pressed="true"] svg { transform: rotate(135deg); }
.view-toggle[aria-pressed="true"] .orbit-dot { fill: currentColor; }

.view-toggle:focus-visible,
.scene-hotspot:focus-visible,
.dialog button:focus-visible,
.dialog a:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 4px;
}

.scene-hotspot {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 52%;
  width: min(40vw, 520px);
  height: min(48vh, 420px);
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: opacity 300ms linear, visibility 300ms linear;
}

.field:not([data-view="overview"]) .scene-hotspot {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.entry-hint {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: clamp(34px, 6vh, 64px);
  transform: translateX(-50%);
  color: #526056;
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: clamp(.875rem, 1.15vw, 1rem);
  font-style: italic;
  letter-spacing: .015em;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 280ms linear, transform 500ms var(--ease-out);
}

.field:not([data-view="overview"]) .entry-hint {
  opacity: 0;
  transform: translate(-50%, 10px);
}

.dialog {
  position: absolute;
  z-index: 10;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateX(28px);
  transition: opacity 380ms linear, visibility 380ms linear, transform 650ms var(--ease-out);
}

.field[data-view="detail"] .dialog {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.dialog-choices {
  position: absolute;
  inset: 0;
  transition: opacity 240ms linear, transform 440ms var(--ease-out), visibility 240ms linear;
}

.choice-bubble {
  position: absolute;
  z-index: 0;
  isolation: isolate;
  width: clamp(180px, 17vw, 270px);
  min-height: 64px;
  display: flex;
  align-items: center;
  padding: 15px 24px;
  border: 0;
  border-radius: 24px;
  background: var(--bubble-fill);
  box-shadow:
    0 12px 34px rgba(51, 51, 44, .075),
    inset 0 1px 0 rgba(255, 255, 255, .78),
    inset 0 0 0 1px rgba(255, 255, 255, .28);
  backdrop-filter: blur(22px) saturate(.88);
  -webkit-backdrop-filter: blur(22px) saturate(.88);
  text-align: left;
  cursor: pointer;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(var(--enter-x, 22px));
  animation: choice-in 520ms var(--ease-out) forwards;
  animation-delay: calc(var(--i) * 65ms + 120ms);
  transition: border-color 180ms linear, background 180ms linear, box-shadow 240ms linear, transform 240ms var(--ease-out);
}

.choice-bubble::after {
  content: "";
  position: absolute;
  top: 50%;
  z-index: -1;
  width: 34px;
  height: 28px;
  background: var(--bubble-fill);
  filter: drop-shadow(4px 5px 5px rgba(51, 51, 44, .035));
  transform: translateY(-50%);
}

.choice-bubble[data-section="about"] {
  --enter-x: -22px;
  top: 23%;
  left: clamp(22px, 7vw, 120px);
}

.choice-bubble[data-section="academic"] {
  top: 25%;
  right: clamp(22px, 7vw, 120px);
}

.choice-bubble[data-section="work"] {
  --enter-x: -22px;
  bottom: 24%;
  left: clamp(28px, 9vw, 155px);
}

.choice-bubble[data-section="contact"] {
  bottom: 21%;
  right: clamp(28px, 8vw, 140px);
}

.choice-bubble[data-section="about"]::after,
.choice-bubble[data-section="work"]::after {
  right: -15px;
  clip-path: polygon(0 0, 0 100%, 100% 50%);
}

.choice-bubble[data-section="academic"]::after,
.choice-bubble[data-section="contact"]::after {
  left: -15px;
  clip-path: polygon(100% 0, 100% 100%, 0 50%);
}

.choice-bubble span {
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  line-height: 1;
}

.choice-bubble:hover {
  background: rgba(248, 245, 242, .96);
  box-shadow: 0 18px 45px rgba(51, 51, 44, .11);
  transform: translateY(-3px) scale(1.015);
}

.choice-bubble:hover::after { background: rgba(248, 245, 242, .96); }

.dialog[data-mode="panel"] .dialog-choices {
  opacity: 0;
  visibility: hidden;
  transform: scale(.97);
  pointer-events: none;
}

.dialog-detail {
  position: absolute;
  z-index: 0;
  isolation: isolate;
  top: auto;
  right: auto;
  bottom: clamp(22px, 4vh, 42px);
  left: 50%;
  width: min(900px, calc(100vw - 48px));
  height: min(44vh, 420px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: clamp(20px, 2.7vw, 34px);
  border: 0;
  border-radius: 34px;
  background: rgba(248, 245, 242, .9);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, .82),
    inset 0 0 0 1px rgba(255, 255, 255, .28);
  backdrop-filter: blur(28px) saturate(.86);
  -webkit-backdrop-filter: blur(28px) saturate(.86);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 28px) scale(.94);
  transform-origin: center bottom;
  pointer-events: none;
  transition: opacity 320ms linear, visibility 320ms linear, transform 620ms var(--ease-out);
}

.dialog-detail::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: -16px;
  left: 50%;
  width: 38px;
  height: 32px;
  border: 0;
  background: rgba(248, 245, 242, .9);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  transform: translateX(-50%);
}

.dialog[data-mode="panel"] .dialog-detail {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0) scale(1);
  pointer-events: auto;
}

.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.back-to-choices {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: .625rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
}

.back-to-choices svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
}

.detail-counter {
  color: var(--ink-soft);
  font-size: .5625rem;
  letter-spacing: .14em;
}

.dialog-content {
  flex: 1;
  min-height: 0;
  padding-top: clamp(20px, 3vh, 32px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(38, 51, 41, .2) transparent;
}

.content-panel { animation: panel-in 440ms var(--ease-out) both; }

.eyebrow {
  color: var(--moss) !important;
  font-size: .5625rem !important;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.content-panel h1,
.content-panel h2 {
  max-width: 14em;
  margin: 10px 0 20px;
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: clamp(2rem, 3.15vw, 3rem);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -.035em;
}

.content-panel h3 {
  margin: 30px 0 8px;
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 1.125rem;
  font-weight: 400;
}

.content-panel p {
  max-width: 48em;
  margin: 0 0 15px;
  color: #536056;
  font-size: .8125rem;
  line-height: 1.72;
}

.content-panel .lead {
  color: var(--ink);
  font-size: .9375rem;
  line-height: 1.65;
}

.content-panel .compact { font-size: .75rem; }

.topic-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 26px;
}

.topic-row span {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: .5625rem;
  letter-spacing: .1em;
}

.publication-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.publication-list li {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.publication-list .year {
  padding-top: 3px;
  color: var(--moss);
  font-size: .625rem;
}

.publication-list strong {
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: .9375rem;
  font-weight: 400;
  line-height: 1.3;
}

.publication-list small {
  display: block;
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: .625rem;
}

.publication-list a {
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.work-card {
  position: relative;
  min-height: 126px;
  overflow: hidden;
  border: 1px solid rgba(38, 51, 41, .08);
  border-radius: 12px;
  background: rgba(255, 255, 255, .4);
}

.work-card img {
  width: 100%;
  height: 126px;
  display: block;
  object-fit: contain;
  padding: 17px;
  filter: saturate(.72);
  transition: transform 500ms var(--ease-out), filter 180ms linear;
}

.work-card:hover img {
  transform: scale(1.045);
  filter: saturate(1);
}

.work-card span {
  position: absolute;
  left: 10px;
  bottom: 8px;
  padding: 4px 6px;
  border-radius: 4px;
  background: rgba(242, 236, 234, .86);
  font-size: .5625rem;
  letter-spacing: .05em;
}

.contact-links {
  margin-top: 30px;
  border-top: 1px solid var(--line);
}

.contact-links a {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.contact-links span {
  color: var(--ink-soft);
  font-size: .625rem;
}

.contact-links strong {
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: .9375rem;
  font-weight: 400;
}

.wechat {
  margin-top: 18px !important;
  font-size: .625rem !important;
  letter-spacing: .08em;
}

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

@keyframes choice-in {
  to { opacity: 1; transform: translateX(0); }
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 980px) {
  .dialog {
    inset: 0;
  }

  .dialog-choices {
    inset: 0;
  }

  .choice-bubble {
    width: min(40vw, 230px);
    min-height: 58px;
  }

  .choice-bubble[data-section="about"] { top: 20%; left: 3.5vw; }
  .choice-bubble[data-section="academic"] { top: 25%; right: 3.5vw; }
  .choice-bubble[data-section="work"] { bottom: 27%; left: 4.5vw; }
  .choice-bubble[data-section="contact"] { bottom: 20%; right: 4.5vw; }

  .dialog-detail {
    top: auto;
    right: auto;
    bottom: max(18px, env(safe-area-inset-bottom));
    left: 50%;
    width: min(760px, calc(100vw - 32px));
    height: min(52vh, 460px);
    margin: 0;
    transform-origin: center bottom;
  }

  .field[data-view="detail"] .scene-wash {
    background: linear-gradient(180deg, transparent 35%, rgba(var(--scene-rgb), .17) 64%, rgba(var(--scene-rgb), .32));
  }
}

@media (max-width: 640px) {
  .field { min-height: 440px; }
  .site-header { padding-top: max(15px, env(safe-area-inset-top)); padding-right: max(14px, env(safe-area-inset-right)); }
  .view-toggle svg { width: 34px; height: 34px; }
  .scene-hotspot { width: 70vw; height: 44vh; }
  .entry-hint { bottom: max(25px, calc(env(safe-area-inset-bottom) + 15px)); }

  .dialog {
    inset: 0;
  }

  .choice-bubble {
    width: min(36vw, 150px);
    min-height: 54px;
    padding: 12px 17px;
    border-radius: 18px;
  }
  .choice-bubble span { font-size: 1.05rem; }

  .choice-bubble[data-section="about"] { top: 13%; left: 2.5vw; }
  .choice-bubble[data-section="academic"] { top: 13%; right: 2.5vw; }
  .choice-bubble[data-section="work"] { bottom: 29%; left: 3.5vw; }
  .choice-bubble[data-section="contact"] { bottom: 21%; right: 3.5vw; }

  .dialog-detail {
    right: auto;
    bottom: max(14px, env(safe-area-inset-bottom));
    left: 50%;
    width: calc(100vw - 20px);
    height: min(60vh, 500px);
    padding: 17px;
    border-radius: 24px;
  }

  .dialog-content { padding-top: 17px; }
  .content-panel h1,
  .content-panel h2 { margin-bottom: 15px; font-size: clamp(1.75rem, 8vw, 2.25rem); }
  .content-panel .lead { font-size: .8125rem; }
  .work-card,
  .work-card img { min-height: 98px; height: 98px; }
  .contact-links a { grid-template-columns: 76px 1fr; }
}

@media (max-height: 630px) and (orientation: landscape) {
  .choice-bubble { width: min(22vw, 210px); min-height: 48px; padding-block: 9px; }
  .choice-bubble[data-section="about"] { top: 22%; left: max(4vw, calc(50% - 650px)); }
  .choice-bubble[data-section="academic"] { top: 23%; right: max(4vw, calc(50% - 650px)); }
  .choice-bubble[data-section="work"] { bottom: 20%; left: max(6vw, calc(50% - 610px)); }
  .choice-bubble[data-section="contact"] { bottom: 19%; right: max(6vw, calc(50% - 610px)); }

  .dialog-detail {
    top: auto;
    right: auto;
    bottom: 18px;
    left: 50%;
    width: min(820px, calc(100vw - 36px));
    height: min(56vh, 320px);
  }
  .content-panel h1,
  .content-panel h2 { font-size: 1.75rem; }
}

@media (min-aspect-ratio: 7 / 3) {
  #transitionVideo,
  #detailVideo { object-position: center 10%; }
}

@media (min-width: 981px) {
  .dialog-detail .work-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dialog-detail .work-card,
  .dialog-detail .work-card img { min-height: 108px; height: 108px; }
}

@media (hover: none) {
  .choice-bubble:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
