:root {
  --paper: #f2e9d7;
  --ink: #30251d;
  --muted: #7d664b;
  --gold: #9b6c22;
  --red: #a9231c;
  --line: rgba(91, 68, 41, 0.23);
  --page-x: clamp(28px, 3.05vw, 52px);
  --song: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", serif;
  --kai: "Kaiti SC", "STKaiti", "KaiTi", var(--song);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--song);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.page {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 640px;
  overflow: hidden;
  isolation: isolate;
  background-color: rgba(244, 236, 220, 0.82);
}

.page::before {
  position: absolute;
  z-index: -2;
  inset: 0;
  content: "";
  background: url("./bg.png") center / cover no-repeat;
  opacity: 0.24;
  filter: contrast(0.72) brightness(1.16) saturate(0.56);
}

.page::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background-color: rgba(227, 211, 187, 0.42);
  pointer-events: none;
}

.site-header {
  position: absolute;
  z-index: 20;
  top: 29px;
  left: var(--page-x);
  right: var(--page-x);
  height: 47px;
  border-bottom: 1px solid var(--line);
}

.brand {
  position: absolute;
  top: 7px;
  left: 0;
  color: #8e211c;
  font-family: var(--kai);
  font-size: 16px;
  letter-spacing: 0.13em;
  text-decoration: none;
}

.brand:focus-visible,
.city-tab:focus-visible,
.wind-toggle:focus-visible,
#cityRange:focus-visible {
  outline: 1px solid var(--red);
  outline-offset: 5px;
}

.city-nav {
  position: absolute;
  top: 0;
  left: 50%;
  display: flex;
  align-items: flex-start;
  gap: clamp(40px, 4.7vw, 79px);
  height: 47px;
  transform: translateX(-50%);
}

.city-tab {
  position: relative;
  appearance: none;
  height: 36px;
  padding: 4px 0 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: var(--song);
  font-size: 16px;
  letter-spacing: 0.12em;
  white-space: nowrap;
  transition: color 180ms ease, transform 180ms ease;
}

.city-tab:hover {
  color: var(--red);
  transform: translateY(-1px);
}

.city-tab::after {
  position: absolute;
  bottom: -1px;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
  content: "";
  opacity: 0;
  transform: translate(-50%, 0) scale(0.5);
  transition: opacity 180ms ease, transform 180ms ease;
}

.city-tab.is-active {
  color: #7f1e18;
}

.city-tab.is-active::after {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.city-copy {
  position: absolute;
  z-index: 7;
  top: 30.5vh;
  left: clamp(60px, 7.2vw, 121px);
  width: 244px;
  transition: opacity 220ms ease, transform 300ms ease;
}

.city-copy h1 {
  margin: 0;
  font-family: var(--song);
  font-size: clamp(68px, 6.46vw, 108px);
  font-weight: 400;
  letter-spacing: 0.1em;
  line-height: 1;
  white-space: nowrap;
}

.title-rule {
  position: relative;
  width: 100%;
  height: 1px;
  margin-top: 59px;
  background-color: rgba(149, 35, 27, 0.45);
}

.title-rule__dot {
  position: absolute;
  top: 50%;
  left: 0;
  width: 10px;
  height: 10px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 1px rgba(160, 35, 28, 0.08);
  transform: translate(-1px, -50%);
}

.city-subtitle {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 30px;
}

.city-subtitle p {
  margin: 0;
  font-family: var(--song);
  font-size: clamp(36px, 3.18vw, 54px);
  font-weight: 400;
  letter-spacing: 0.18em;
  line-height: 1;
  white-space: nowrap;
}

.seal {
  display: inline-grid;
  width: 14px;
  height: 26px;
  place-items: center;
  border: 1px solid rgba(151, 41, 32, 0.68);
  border-radius: 2px;
  color: rgba(151, 41, 32, 0.72);
  font-family: var(--kai);
  font-size: 9px;
  line-height: 1;
}

.installation {
  position: absolute;
  z-index: 3;
  top: clamp(96px, 12.8vh, 124px);
  right: clamp(48px, 4.75vw, 80px);
  width: min(63.6vw, 1064px);
  height: min(75vh, 706px);
  transition: opacity 220ms ease, transform 300ms ease;
}

.page[data-city="beijing"] .installation {
  width: min(58vw, 970px);
}

.suzhou-scene {
  position: absolute;
  z-index: 4;
  inset: 0;
  overflow: hidden;
  background: #ded9ce url("./suzhou.png?v=clean-1") center / cover no-repeat;
  cursor: crosshair;
  opacity: 0;
  pointer-events: none;
  touch-action: none;
  transform: scale(1.008);
  transition: opacity 360ms ease, transform 760ms ease;
}

#suzhouCanvas {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.suzhou-instruction {
  position: absolute;
  z-index: 3;
  right: 3.2vw;
  bottom: 3.6vh;
  margin: 0;
  color: rgba(58, 55, 45, 0.72);
  font-family: var(--song);
  font-size: 13px;
  letter-spacing: 0.32em;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 600ms ease 480ms, transform 600ms ease 480ms;
  writing-mode: vertical-rl;
}

.page[data-city="suzhou"]::before,
.page[data-city="suzhou"]::after {
  opacity: 0;
}

.page[data-city="suzhou"] .suzhou-scene {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.page[data-city="suzhou"] .suzhou-instruction {
  opacity: 1;
  transform: translateY(0);
}

.page[data-city="suzhou"] .city-copy,
.page[data-city="suzhou"] .installation,
.page[data-city="suzhou"] .progress {
  opacity: 0;
  pointer-events: none;
}

.page[data-city="suzhou"] .site-header {
  top: 12px;
  border-bottom-color: rgba(236, 225, 198, 0.22);
}

.page[data-city="suzhou"] .brand,
.page[data-city="suzhou"] .city-tab {
  color: rgba(241, 232, 207, 0.84);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.52);
}

.page[data-city="suzhou"] .city-tab:hover,
.page[data-city="suzhou"] .city-tab.is-active {
  color: #fff8e7;
}

.page[data-city="suzhou"] .city-tab::after {
  box-shadow: 0 0 0 2px rgba(24, 24, 19, 0.48);
}

.roof-crop {
  position: absolute;
  z-index: 3;
  top: 5px;
  left: -29px;
  width: calc(100% + 16px);
  height: 385px;
  overflow: hidden;
  pointer-events: none;
}

.roof-crop img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  max-width: none;
  height: auto;
}

.cloth {
  position: absolute;
  z-index: 2;
  top: 344px;
  right: 0;
  width: 91.5%;
  height: 346px;
  cursor: crosshair;
  touch-action: none;
}

#clothCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.wind-guide {
  position: absolute;
  z-index: 8;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  color: #5d4b37;
  font-family: var(--song);
  font-size: clamp(13px, 1.05vw, 18px);
  letter-spacing: 0.29em;
  white-space: nowrap;
}

.wind-guide__line {
  width: clamp(42px, 4.8vw, 78px);
  height: 1px;
  margin: 0 7px 0 18px;
  background-color: rgba(151, 36, 29, 0.55);
}

.wind-toggle {
  position: relative;
  display: inline-grid;
  width: 31px;
  height: 23px;
  place-items: center;
  appearance: none;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: #8a735a;
  font-size: 17px;
}

.wind-toggle__dot {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 7px;
  height: 7px;
  border: 1px solid var(--paper);
  border-radius: 50%;
  background: #968b79;
  transition: background-color 180ms ease;
}

.wind-toggle.is-active .wind-toggle__dot {
  background: var(--red);
}

.installation.is-shifting,
.page.is-shifting .city-copy,
.page.is-shifting .suzhou-scene {
  opacity: 0;
  transform: translateY(8px);
}

.progress {
  position: absolute;
  z-index: 15;
  right: var(--page-x);
  bottom: clamp(31px, 6.25vh, 59px);
  left: var(--page-x);
  display: flex;
  align-items: baseline;
  gap: clamp(28px, 3.6vw, 60px);
  height: 42px;
}

.progress-count {
  display: flex;
  align-items: baseline;
  min-width: 101px;
  color: #322920;
  font-family: var(--song);
  line-height: 1;
}

#currentIndex {
  color: #9d241d;
  font-size: 38px;
  letter-spacing: 0.03em;
}

.progress-count__slash {
  margin: 0 12px;
  color: #5e4b38;
  font-size: 18px;
}

.progress-count__total {
  font-size: 15px;
  letter-spacing: 0.18em;
}

.progress-control {
  position: relative;
  flex: 1;
  height: 22px;
  border-bottom: 1px solid var(--line);
}

.progress-control__fill {
  position: absolute;
  z-index: 1;
  bottom: -1px;
  left: 0;
  width: 8%;
  height: 2px;
  background-color: rgba(160, 37, 29, 0.78);
  transition: width 320ms ease;
}

#cityRange {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 22px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
  opacity: 0.001;
}

#cityRange::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  appearance: none;
}

#cityRange::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 0;
}

@media (max-width: 1180px) {
  .site-header {
    top: 22px;
  }

  .city-nav {
    gap: 38px;
  }

  .city-copy {
    top: 31vh;
    left: 6vw;
    width: 230px;
  }

  .installation {
    top: 13vh;
    right: 2.5vw;
    width: 68vw;
  }

  .page[data-city="beijing"] .installation {
    width: 62vw;
  }

  .roof-crop {
    height: 306px;
  }

  .cloth {
    top: 306px;
    height: 320px;
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .page {
    min-height: 820px;
    overflow: hidden;
  }

  .page[data-city="suzhou"] {
    height: 100svh;
    min-height: 0;
  }

  .site-header {
    top: 18px;
    left: 22px;
    right: 22px;
    height: 74px;
  }

  .brand {
    top: 0;
  }

  .city-nav {
    top: 34px;
    left: 0;
    width: 100%;
    justify-content: space-between;
    gap: 0;
    transform: none;
  }

  .city-tab {
    font-size: 14px;
  }

  .city-copy {
    top: 126px;
    left: 28px;
    width: 200px;
  }

  .city-copy h1 {
    font-size: 60px;
  }

  .title-rule {
    margin-top: 24px;
  }

  .city-subtitle {
    margin-top: 21px;
  }

  .city-subtitle p {
    font-size: 31px;
  }

  .installation {
    top: 266px;
    right: -22vw;
    width: 116vw;
    height: 472px;
  }

  .page[data-city="beijing"] .installation {
    right: -17vw;
    width: 106vw;
  }

  .suzhou-scene {
    background-position: 61% center;
  }

  .suzhou-instruction {
    right: 18px;
    bottom: 26px;
    font-size: 11px;
  }

  .page[data-city="suzhou"] .site-header {
    top: 10px;
    height: 72px;
    border-bottom-color: rgba(236, 225, 198, 0.18);
  }

  .roof-crop {
    top: 0;
    height: 260px;
  }

  .cloth {
    top: 255px;
    width: 86%;
    height: 266px;
  }

  .wind-guide {
    right: 23vw;
    bottom: -34px;
    font-size: 12px;
  }

  .progress {
    right: 24px;
    bottom: 28px;
    left: 24px;
  }

  #currentIndex {
    font-size: 31px;
  }
}

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