:root {
  color-scheme: dark;
  --page: #050c1d;
  --page-deep: #020713;
  --text: #f5f2e9;
  --muted: #c9d2e2;
  --line: rgb(199 214 240 / 0.18);
  --accent: #ff765d;
  --accent-deep: #8f2e2a;
  --focus: #ffd2a3;
  --nav-height: 64px;
  --map-height: 2800px;
  --parallax-x: 0px;
  --parallax-y: 0px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--page);
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--page);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 30;
  padding: 10px 14px;
  transform: translateY(-160%);
  border: 1px solid var(--focus);
  background: var(--page-deep);
  color: var(--text);
  min-height: 44px;
}

.skip-link:focus { transform: translateY(0); }

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
  padding: 0 clamp(20px, 4vw, 58px);
  border-bottom: 1px solid rgb(158 190 235 / 0.14);
  background: linear-gradient(180deg, rgb(2 7 18 / 0.90), rgb(3 9 23 / 0.68));
  box-shadow: 0 14px 34px rgb(0 3 12 / 0.20);
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
}

.brand,
.nav-links a,
.site-menu summary {
  text-decoration: none;
  font-weight: 750;
  letter-spacing: 0.01em;
}

.brand { font-size: 17px; }

.nav-links {
  display: flex;
  gap: clamp(22px, 4vw, 48px);
  font-size: 14px;
}

.nav-links a,
.brand,
.site-menu summary {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  align-items: center;
  border-radius: 4px;
  outline-offset: 6px;
  transition: color 160ms ease;
}

.nav-links a:hover,
.site-menu summary:hover,
.site-menu[open] > summary { color: var(--focus); }

.nav-links a:focus-visible,
.brand:focus-visible,
.site-menu summary:focus-visible,
.project-action:focus-visible {
  outline: 2px solid var(--focus);
}

.site-menu {
  position: relative;
  align-self: center;
}

.site-menu summary {
  gap: 7px;
  cursor: pointer;
  list-style: none;
  outline-offset: 6px;
}

.site-menu summary::-webkit-details-marker { display: none; }

.site-menu summary::after {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  content: "";
  transform: translateY(-2px) rotate(45deg);
  transition: transform 160ms ease;
}

.site-menu[open] summary::after { transform: translateY(2px) rotate(225deg); }

.site-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: min(310px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid rgb(164 195 237 / 0.24);
  border-radius: 12px;
  background: linear-gradient(155deg, rgb(8 20 45 / 0.97), rgb(2 8 20 / 0.98));
  box-shadow: 0 24px 60px rgb(0 2 12 / 0.58), inset 0 1px 0 rgb(255 255 255 / 0.06);
  backdrop-filter: blur(22px) saturate(1.16);
  -webkit-backdrop-filter: blur(22px) saturate(1.16);
}

.site-menu-panel a,
.site-menu-disabled {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 54px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.site-menu-panel a:hover {
  background: rgb(89 137 205 / 0.14);
  color: #fff3dd;
}

.site-menu-panel small {
  color: rgb(194 210 235 / 0.72);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.site-menu-disabled {
  color: rgb(202 214 234 / 0.58);
  cursor: default;
}

.site-menu-disabled small { color: rgb(202 214 234 / 0.46); }

.world-map {
  position: relative;
  min-height: var(--map-height);
  overflow: hidden;
  isolation: isolate;
  background: #020716;
}

.world-map::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgb(0 3 11 / 0.30), transparent 16% 84%, rgb(0 3 11 / 0.32)),
    linear-gradient(180deg, transparent 0 24%, rgb(5 14 34 / 0.08) 52%, rgb(1 3 12 / 0.30) 100%);
}

.world-map::after {
  display: none;
}

.cavern-backdrop,
.cavern-light,
.cavern-midground,
.cavern-foreground {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cavern-backdrop {
  z-index: 0;
  inset: 0;
  background: url("world-cavern-backdrop-v9-4k.png") center top / cover no-repeat;
  background-image: image-set(
    url("world-cavern-backdrop-v9-4k.avif") type("image/avif"),
    url("world-cavern-backdrop-v9-4k.webp") type("image/webp"),
    url("world-cavern-backdrop-v9-4k.png") type("image/png")
  );
  filter: saturate(0.88) brightness(0.80) contrast(1.08);
}

.cavern-light {
  z-index: 1;
  opacity: 0.34;
  background:
    radial-gradient(ellipse at 52% 0%, rgb(105 181 255 / 0.30) 0, rgb(35 104 190 / 0.15) 18%, transparent 43%),
    linear-gradient(104deg, transparent 38%, rgb(116 190 255 / 0.09) 49%, transparent 62%),
    radial-gradient(ellipse at 27% 34%, rgb(28 93 154 / 0.15), transparent 30%),
    radial-gradient(ellipse at 75% 61%, rgb(104 58 148 / 0.10), transparent 25%),
    radial-gradient(ellipse at 28% 86%, rgb(167 71 42 / 0.09), transparent 22%);
  mix-blend-mode: screen;
}

.cavern-midground { display: none; }

.cavern-foreground {
  overflow: hidden;
  opacity: 0;
  transition: opacity 260ms ease;
}

.cavern-midground {
  z-index: 1;
}

.cavern-foreground {
  z-index: 4;
}

.cavern-midground.is-ready { opacity: 0.25; }
.cavern-foreground.is-ready { opacity: 0.42; }

.cavern-midground img,
.cavern-foreground img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  transform-origin: center top;
  will-change: transform;
}

.cavern-midground img {
  filter: saturate(0.68) brightness(0.72) contrast(1.13) hue-rotate(-7deg);
  transform: translate3d(calc(var(--parallax-x) * 0.15), calc(var(--parallax-y) * 0.12), 0) scale(1.005);
}

.cavern-foreground img {
  filter: saturate(0.88) brightness(0.80) contrast(1.12) sepia(0.04) hue-rotate(-5deg);
  transform: translate3d(calc(var(--parallax-x) * 0.28), calc(var(--parallax-y) * 0.22), 0) scale(1.008);
}

@media (min-width: 1120px) {
  .cavern-foreground {
    inset: 0 -2vw;
  }

  .cavern-foreground.is-ready {
    opacity: 0.58;
  }

  .cavern-foreground img {
    filter: saturate(0.90) brightness(0.82) contrast(1.14) sepia(0.04) hue-rotate(-5deg);
  }
}

.world-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
}

.world-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hero-copy,
.project-copy,
.map-fallback,
.noscript-note {
  position: absolute;
  z-index: 7;
}

.hero-copy {
  top: 450px;
  left: clamp(30px, 7vw, 104px);
  width: min(620px, 43vw);
  transform: translateY(-50%);
}

.hero-copy h1,
.project-copy h2 {
  margin: 0;
  text-wrap: balance;
  letter-spacing: -0.012em;
}

.hero-copy h1 {
  max-width: 10em;
  font-size: 36px;
  line-height: 1.12;
}

.hero-copy h1 span { display: block; }

.hero-copy h1,
.project-copy h2 {
  color: #fff2dc;
  text-shadow: 0 4px 24px rgb(0 4 16 / 0.68), 0 1px 0 rgb(255 255 255 / 0.08);
}

.hero-copy p,
.project-copy p {
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.68;
  text-wrap: pretty;
}

.hero-copy p { font-size: clamp(15px, 1.45vw, 19px); }

.project-copy {
  isolation: isolate;
  width: min(430px, 32vw);
  padding: 22px 0 24px;
  transform: translateY(-50%);
}

.project-copy::before {
  content: "";
  position: absolute;
  inset: -28px -42px;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgb(2 8 22 / 0.68), rgb(2 8 22 / 0.30) 48%, transparent 74%);
}

.project-copy[data-side="left"] {
  left: clamp(30px, 7vw, 104px);
}

.project-copy[data-side="right"] {
  right: clamp(30px, 7vw, 104px);
}

.project-copy h2 {
  max-width: 13em;
  font-size: 36px;
  line-height: 1.12;
}

@media (min-width: 1120px) {
  .hero-copy { transform: translate(clamp(70px, 8vw, 110px), -50%); }
  #botc { transform: translate(-36px, -50%); }
  #personal { transform: translate(clamp(55px, 7vw, 90px), -50%); }
  #about { transform: translate(-36px, -50%); }
}

.project-copy p {
  max-width: 29em;
  font-size: clamp(15px, 1.15vw, 17px);
}

.project-action {
  display: inline-flex;
  min-width: 152px;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  margin-top: 22px;
  padding: 12px 22px;
  border: 2px solid #ff927b;
  border-radius: 5px;
  background: linear-gradient(#b53b35, #84251f);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.28), 0 0 0 1px rgb(255 115 86 / 0.14), 0 13px 34px rgb(111 22 20 / 0.34);
  color: #fff7eb;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

.project-action:not(.is-status):hover { filter: brightness(1.12); transform: translateY(-2px); }
.project-action:not(.is-status):active { transform: scale(0.98); }

.project-copy[data-status="draft"] h2,
.project-copy[data-status="draft"] p {
  color: rgb(208 221 244 / 0.88);
}

.project-copy[data-status="draft"] h2 { color: #dce8ff; }

.project-action.is-draft {
  border-color: rgb(137 163 207 / 0.58);
  background: rgb(25 42 73 / 0.62);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.10), 0 8px 24px rgb(3 12 31 / 0.20);
  color: #d9e2f0;
}

.project-action.is-status { cursor: default; }

.project-copy { scroll-margin-top: calc(var(--nav-height) + 300px); }

.map-fallback {
  top: 86px;
  left: 50%;
  display: none;
  width: min(440px, calc(100% - 40px));
  padding: 12px 16px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  background: rgb(5 12 29 / 0.92);
  color: var(--muted);
  text-align: center;
}

.map-fallback p { margin: 0; }
.world-map[data-render-status="failed"] .map-fallback { display: block; }

.noscript-note {
  top: 86px;
  left: 20px;
  right: 20px;
  padding: 12px;
  background: var(--page-deep);
  text-align: center;
}

@media (max-width: 1119px) {
  :root { --map-height: 2300px; }
  .hero-copy { top: 380px; width: min(430px, 52vw); }
  .hero-copy h1 { font-size: clamp(29px, 8.2vw, 39px); }
  .project-copy { width: min(390px, 39vw); }
  .cavern-midground img,
  .cavern-foreground img { object-position: center top; }
}

@media (max-width: 1119px) {
  :root {
    --nav-height: 58px;
    --map-height: 3100px;
  }

  .topbar { padding: 0 16px; }
  .brand { font-size: 13px; letter-spacing: 0; }
  .nav-links { gap: 12px; font-size: 13px; }
  .site-menu-panel { right: -4px; }

  .hero-copy {
    top: 94px;
    left: 20px;
    width: calc(100% - 40px);
    transform: none;
    text-align: center;
  }

  .cavern-backdrop {
    inset: -30px -220px;
    background-position: 52% top;
  }

  .cavern-midground.is-ready { opacity: 0.25; }
  .cavern-foreground { display: none; }
  .cavern-midground img {
    width: auto;
    min-width: 100%;
    left: 50%;
    transform: translate3d(calc(-50% + var(--parallax-x) * 0.08), calc(var(--parallax-y) * 0.08), 0);
    object-fit: cover;
  }

  .hero-copy h1 {
    max-width: 9em;
    font-size: clamp(29px, 8.2vw, 39px);
    line-height: 1.12;
  }

  .hero-copy p { max-width: 19em; margin-top: 14px; font-size: 15px; }

  .hero-copy h1,
  .hero-copy p { margin-right: auto; margin-left: auto; }

  .project-copy,
  .project-copy[data-side="left"],
  .project-copy[data-side="right"] {
    right: 20px;
    left: 20px;
    width: auto;
    transform: none;
    text-align: center;
    scroll-margin-top: calc(var(--nav-height) + 500px);
  }

  .project-copy::before {
    inset: -18px -12px;
    background: radial-gradient(ellipse at center, rgb(2 8 22 / 0.58), rgb(2 8 22 / 0.18) 55%, transparent 76%);
  }

  .project-copy h2 { max-width: 13em; margin-right: auto; margin-left: auto; font-size: clamp(29px, 8.2vw, 39px); }
  .project-copy p { max-width: 26em; margin: 12px auto 0; font-size: 16px; line-height: 1.62; }
  .project-action { min-width: 152px; min-height: 48px; margin-top: 18px; }
}

@media (max-width: 390px) {
  .topbar { padding-inline: 12px; }
  .brand { font-size: 12px; }
  .nav-links { gap: 9px; font-size: 12px; }
}

@media (max-width: 350px) {
  .topbar { padding-inline: 8px; }
  .brand { font-size: 11px; }
  .nav-links { gap: 6px; font-size: 11px; }
  .nav-links > a:first-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
  .cavern-backdrop,
  .cavern-midground img,
  .cavern-foreground img { transform: none !important; }
}

@media (prefers-reduced-transparency: reduce) {
  .topbar { background: #030814; backdrop-filter: none; -webkit-backdrop-filter: none; }
}
