:root {
  --bg: #e7ebe2;
  --bg-deep: #1f211d;
  --ink: #20211e;
  --ink-soft: rgba(32, 33, 30, 0.68);
  --line: rgba(32, 33, 30, 0.2);
  --paper: rgba(250, 249, 244, 0.72);
  --accent: #b65435;
  --nav-h: 84px;
  --serif: "Times New Roman", "Songti SC", "SimSun", serif;
  --sans: "Inter", "Arial", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(246, 242, 231, 0.52), transparent 38%),
    linear-gradient(315deg, rgba(176, 199, 184, 0.5), transparent 42%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  transition: background-color 700ms ease, color 500ms ease;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  opacity: 0.13;
  mix-blend-mode: multiply;
  background-image:
    linear-gradient(rgba(32, 33, 30, 0.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 33, 30, 0.08) 1px, transparent 1px);
  background-size: 27px 27px, 27px 27px;
}

.cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(32, 33, 30, 0.45);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(-100px, -100px, 0);
  transition: opacity 200ms ease, width 220ms ease, height 220ms ease, border-color 300ms ease;
  mix-blend-mode: difference;
}

.cursor.is-dragging {
  width: 54px;
  height: 54px;
}

.site-nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 25;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: var(--nav-h);
  padding: 28px 42px;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  line-height: 1;
  transition: color 500ms ease;
}

.brand {
  max-width: min(56vw, 620px);
  font-family: var(--serif);
  font-size: clamp(20px, 2.1vw, 32px);
  font-weight: 400;
  letter-spacing: 0.13em;
  text-align: center;
  text-transform: none;
  white-space: nowrap;
}

.nav-work {
  justify-self: start;
}

.nav-group {
  justify-self: end;
  display: flex;
  gap: 28px;
  align-items: center;
}

.nav-link {
  position: relative;
  padding-block: 8px;
}

.nav-link::after {
  position: absolute;
  left: 0;
  bottom: 2px;
  width: 100%;
  height: 1px;
  content: "";
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 280ms ease;
}

.nav-link:hover::after,
.nav-link:focus-visible::after {
  transform: scaleX(1);
  transform-origin: left;
}

.menu-button {
  display: none;
  justify-self: end;
  width: 38px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: currentColor;
  cursor: pointer;
}

.menu-button span {
  display: block;
  width: 100%;
  height: 1px;
  margin: 8px 0;
  background: currentColor;
  transition: transform 250ms ease;
}

.menu-button.is-open span:first-child {
  transform: translateY(4px) rotate(16deg);
}

.menu-button.is-open span:last-child {
  transform: translateY(-5px) rotate(-16deg);
}

.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 22;
  display: grid;
  place-content: center;
  gap: 26px;
  background: rgba(231, 235, 226, 0.96);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(32px, 12vw, 86px);
  letter-spacing: 0.06em;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-18px);
  transition: opacity 260ms ease, transform 260ms ease, background-color 500ms ease;
}

.mobile-menu.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: transparent;
  touch-action: none;
  user-select: none;
}

.canvas-shell {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
}

.photo-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5400px;
  height: 1420px;
  transform: translate3d(-50%, -50%, 0);
  will-change: transform;
  touch-action: none;
}

.photo-card {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  aspect-ratio: var(--ratio);
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(250, 249, 244, 0.42);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 18px 54px rgba(28, 29, 25, 0.16);
  transform: rotate(var(--r)) scale(1.1);
  opacity: 0;
  animation: imageIn 850ms cubic-bezier(0.19, 1, 0.22, 1) forwards;
  animation-delay: var(--d);
}

.photo-card:nth-child(3n) {
  z-index: 2;
}

.photo-card:nth-child(7n) {
  z-index: 4;
}

.photo-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.02) contrast(0.98);
  transition: filter 600ms ease, transform 900ms ease;
}

.photo-card:hover img {
  transform: scale(1.045);
}

.photo-card span {
  position: absolute;
  left: 12px;
  bottom: 10px;
  max-width: calc(100% - 24px);
  padding: 5px 7px;
  overflow: hidden;
  background: rgba(247, 246, 239, 0.78);
  color: rgba(32, 33, 30, 0.9);
  font-size: 9px;
  letter-spacing: 0.13em;
  line-height: 1.1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 260ms ease, transform 260ms ease;
}

.photo-card:hover span,
.mode-mono .photo-card span {
  opacity: 1;
  transform: translateY(0);
}

.mode-mono {
  background:
    linear-gradient(135deg, rgba(91, 99, 82, 0.36), transparent 40%),
    linear-gradient(315deg, rgba(20, 20, 18, 0.35), transparent 45%),
    var(--bg-deep);
  color: #f0eee6;
}

.mode-mono .site-nav,
.mode-mono .hero-copy,
.mode-mono .category {
  color: #f0eee6;
}

.mode-mono .mobile-menu {
  background: rgba(31, 33, 29, 0.96);
  color: #f0eee6;
}

.mode-mono .cursor {
  border-color: rgba(240, 238, 230, 0.58);
}

.mode-mono .photo-card {
  border-color: rgba(240, 238, 230, 0.2);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.24);
}

.mode-mono .photo-card img {
  filter: grayscale(1) contrast(1.04) brightness(0.9);
}

.mode-mono .photo-card span {
  background: rgba(31, 33, 29, 0.72);
  color: #f0eee6;
}

@keyframes imageIn {
  to {
    opacity: 1;
    transform: rotate(var(--r)) scale(1);
  }
}

.line-map {
  position: absolute;
  z-index: 1;
  width: min(42vw, 520px);
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  opacity: 0.18;
  pointer-events: none;
}

.line-map-left {
  left: -7vw;
  top: 14vh;
}

.line-map-right {
  right: -6vw;
  top: 8vh;
}

.category {
  position: absolute;
  z-index: 7;
  color: rgba(32, 33, 30, 0.72);
  font-size: clamp(10px, 1vw, 13px);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  pointer-events: none;
  transition: color 700ms ease, transform 700ms ease;
}

.c1 {
  left: 12vw;
  top: 25vh;
}

.c2 {
  left: 28vw;
  top: 15vh;
}

.c3 {
  right: 24vw;
  top: 22vh;
}

.c4 {
  right: 10vw;
  top: 39vh;
}

.c5 {
  left: 8vw;
  bottom: 28vh;
}

.c6 {
  left: 39vw;
  bottom: 19vh;
}

.c7 {
  right: 31vw;
  bottom: 28vh;
}

.c8 {
  right: 8vw;
  bottom: 18vh;
}

.hero-copy {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 18;
  width: min(780px, calc(100vw - 36px));
  color: var(--ink);
  text-align: center;
  text-shadow: 0 1px 18px rgba(231, 235, 226, 0.95);
  transform: translateX(-50%);
  isolation: isolate;
  pointer-events: none;
  transition: color 500ms ease, text-shadow 500ms ease;
}

.hero-copy::before {
  position: absolute;
  left: 50%;
  bottom: -34px;
  z-index: -1;
  width: 100vw;
  height: 330px;
  content: "";
  background: linear-gradient(
    to top,
    rgba(231, 235, 226, 0.96) 0%,
    rgba(231, 235, 226, 0.82) 48%,
    rgba(231, 235, 226, 0) 100%
  );
  transform: translateX(-50%);
  pointer-events: none;
}

.mode-mono .hero-copy {
  text-shadow: 0 1px 18px rgba(31, 33, 29, 0.95);
}

.mode-mono .hero-copy::before {
  background: linear-gradient(
    to top,
    rgba(31, 33, 29, 0.96) 0%,
    rgba(31, 33, 29, 0.78) 48%,
    rgba(31, 33, 29, 0) 100%
  );
}

.hero-copy .eyebrow {
  margin: 0 0 8px;
  color: currentColor;
  font-size: 10px;
  letter-spacing: 0.22em;
  opacity: 0.7;
}

.hero-copy h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(42px, 6vw, 94px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.05em;
}

.hero-copy p {
  width: min(660px, 100%);
  margin: 13px auto 12px;
  color: currentColor;
  font-family: var(--serif);
  font-size: clamp(18px, 2vw, 28px);
  line-height: 1.34;
  opacity: 0.78;
}

.archive-meta {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 15px;
  color: currentColor;
  font-size: 11px;
  letter-spacing: 0.16em;
  line-height: 1.4;
  text-transform: uppercase;
  opacity: 0.72;
}

.archive-meta span {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.archive-meta span + span::before {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  content: "";
  background: currentColor;
  opacity: 0.48;
}

.mode-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, 78px);
  align-items: center;
  border: 1px solid currentColor;
  background: rgba(247, 246, 239, 0.5);
  color: currentColor;
  backdrop-filter: blur(14px);
  pointer-events: auto;
}

.mode-mono .mode-toggle {
  background: rgba(31, 33, 29, 0.42);
}

.mode-toggle button {
  min-height: 34px;
  border: 0;
  border-right: 1px solid currentColor;
  background: transparent;
  color: currentColor;
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 0.12em;
  transition: background-color 220ms ease, color 220ms ease;
}

.mode-toggle button:last-child {
  border-right: 0;
}

.mode-toggle button.active {
  background: var(--ink);
  color: #f4f1e8;
}

.mode-mono .mode-toggle button.active {
  background: #f0eee6;
  color: #1f211d;
}

.mode-toggle button:focus-visible,
.menu-button:focus-visible,
.nav-link:focus-visible,
.brand:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 5px;
}

@media (max-width: 860px) {
  :root {
    --nav-h: 74px;
  }

  .site-nav {
    grid-template-columns: 1fr auto;
    padding: 22px 20px;
  }

  .brand {
    justify-self: start;
    max-width: calc(100vw - 92px);
    font-size: 20px;
    letter-spacing: 0.08em;
    overflow-wrap: anywhere;
    white-space: normal;
    text-align: left;
  }

  .nav-work,
  .nav-group {
    display: none;
  }

  .menu-button {
    display: block;
  }

  .photo-card {
    box-shadow: 0 13px 34px rgba(28, 29, 25, 0.16);
  }

  .category {
    font-size: 10px;
  }

  .c2,
  .c4,
  .c6,
  .c8 {
    display: none;
  }

  .hero-copy {
    bottom: 22px;
  }

  .hero-copy .eyebrow {
    font-size: 9px;
  }

  .hero-copy h1 {
    font-size: clamp(38px, 12vw, 62px);
  }

  .hero-copy p {
    margin-top: 10px;
    font-size: 18px;
  }

  .archive-meta {
    flex-wrap: wrap;
    gap: 8px 12px;
    font-size: 10px;
  }

  .mode-toggle {
    grid-template-columns: repeat(2, 72px);
  }
}

@media (max-width: 560px) {
  .line-map {
    width: 72vw;
  }

  .category {
    opacity: 0.72;
  }

  .c1 {
    left: 8vw;
    top: 18vh;
  }

  .c3 {
    right: 7vw;
    top: 25vh;
  }

  .c5 {
    left: 7vw;
    bottom: 32vh;
  }

  .c7 {
    right: 8vw;
    bottom: 30vh;
  }

  .hero-copy {
    width: min(360px, calc(100vw - 28px));
  }

  .hero-copy h1 {
    letter-spacing: 0.02em;
  }
}

@media (pointer: coarse) {
  .cursor {
    display: none;
  }
}

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