:root {
  --font-size: 18px;
  --ink: #ffffffeb;
  --gentle-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fade: 0.28s;
  --fade-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dissolve: 1.2s;
  --safe-left: max(22px, calc(env(safe-area-inset-left) + 8px));
  --safe-right: max(22px, calc(env(safe-area-inset-right) + 8px));
  --pair: 28px;
  --gap: 12px;
  --halo: 0 0 0.22em rgb(7 17 19 / 0.18), 0 0 0.6em rgb(7 17 19 / 0.3), 0 0 1.1em rgb(7 17 19 / 0.18);
}
@media (max-width: 700px) {
  :root { --font-size: 16px; --safe-left: max(16px, calc(env(safe-area-inset-left) + 8px)); --safe-right: max(16px, calc(env(safe-area-inset-right) + 8px)); }
}
@media (prefers-reduced-motion: reduce) {
  :root { --fade: 0.112s; }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--ink);
  font-family: "Newsreader", Georgia, serif;
  font-weight: 350;
  font-size: var(--font-size);
  font-optical-sizing: auto;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
body { position: fixed; inset: 0; }
button, a, output, input { font: inherit; color: inherit; }
button { border: 0; padding: 0; margin: 0; background: none; cursor: pointer; outline: none; }
:focus { outline: none; }

/* ---------------------------------------------------------------- loader */
#traveling { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
#traveling-word { position: absolute; left: 50%; top: calc(50% - 28px); transform: translateX(-50%); height: 28px; line-height: 28px; font-style: italic; }
#traveling-dots { position: absolute; left: 100%; top: 0; white-space: nowrap; }
#traveling-dots::after { content: ""; animation: traveling-dots 2s steps(1, end) infinite; }
@keyframes traveling-dots { 0%, 100% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "…"; } }
@media (prefers-reduced-motion: reduce) { #traveling-dots::after { animation: none; content: "…"; } }
.water-ready #traveling, .webgl-unavailable #traveling { visibility: hidden; }

/* ---------------------------------------------------------------- lake */
.lake { position: fixed; inset: 0; overflow: hidden; touch-action: none; overscroll-behavior: none; }
@media (pointer: fine) { .lake { cursor: none; } .lake.is-near-text, .lake.is-context-menu-open { cursor: default; } }
.lake.is-context-menu-open { cursor: default; }
#water, #fallback-water { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity var(--dissolve) ease-out; }
#fallback-water { display: none; }
.water-ready #water { opacity: 1; }
.webgl-unavailable #water { display: none; }
.webgl-unavailable #fallback-water { display: block; opacity: 1; }
.is-arriving .lake > :not(canvas) { opacity: 0 !important; visibility: hidden !important; }
.arrival-revealing .interface { transition: opacity var(--dissolve) ease-out !important; }

/* ---------------------------------------------------------------- cursor: a ring lying on the water */
.cursor-ring { position: fixed; left: 0; top: 0; width: 0; height: 0; z-index: 8; pointer-events: none; opacity: 0; transition: opacity 0.12s linear; }
.cursor-ring.is-visible, .cursor-ring.is-pressed { opacity: 1; }
.cursor-ring svg { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; }
.cursor-ring path {
  fill: transparent;
  stroke: #fff;
  stroke-width: 1.5px;
  stroke-linejoin: round;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.18s var(--gentle-ease), fill 0.18s var(--gentle-ease);
}
.cursor-ring.is-pressed path { fill: #fff; transform: scale(0.9); }
.cursor-ring.is-tap-pulsing path { animation: ring-tap 0.3s var(--gentle-ease); }
@keyframes ring-tap { 0% { fill: #fff; transform: scale(0.9); } 100% { fill: transparent; transform: scale(1); } }
.lake.is-context-menu-open .cursor-ring { opacity: 0 !important; }

/* ---------------------------------------------------------------- interface */
.interface { position: absolute; inset: 0; z-index: 4; pointer-events: none; transition: opacity var(--fade) var(--fade-ease); }
.lake.is-context-menu-open .interface { opacity: 0; }
.control { pointer-events: auto; text-shadow: var(--halo); }
.control, .about-panel, .works-card { transition: opacity var(--fade) var(--fade-ease); }

/* small signature, top left */
.brand {
  position: absolute;
  left: var(--safe-left);
  top: 1.1em;
  margin: 0;
  height: var(--pair);
  display: flex;
  align-items: center;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

/* vertical Chinese nav: 湖面 / 作品 / 关于, left centre; the selected item gets a white dot */
.side-nav {
  position: absolute;
  left: var(--safe-left);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.05em;
}
.side-link { height: var(--pair); display: flex; align-items: center; white-space: nowrap; letter-spacing: 0.06em; }
.side-link::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 9px;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.36s var(--gentle-ease), transform 0.36s var(--gentle-ease), margin 0.36s var(--gentle-ease);
  margin-left: -16px;
}
.side-link.is-active::before { opacity: 1; transform: scale(1); margin-left: 0; }

/* lake sound: user-initiated ambience, bottom right */
.sound-button {
  position: absolute;
  right: var(--safe-right);
  bottom: 7%;
  height: var(--pair);
  display: flex;
  align-items: center;
  white-space: nowrap;
  font-style: italic;
}

.control:focus-visible, .works-detail:focus-visible, .works-close:focus-visible, .context-link:focus-visible {
  outline: 1.5px solid rgb(255 255 255 / 0.85);
  outline-offset: 3px;
  border-radius: 3px;
}
.works-detail:focus-visible, .works-close:focus-visible { outline-color: #322d24; }

/* ---------------------------------------------------------------- overlays */
.about-panel, .works-card { position: absolute; opacity: 0; pointer-events: none; }

.interface.is-works-open .works-card, .interface.is-about-open .about-panel { opacity: 1; pointer-events: auto; user-select: text; -webkit-user-select: text; }

/* works card: matches the reference placement (247,168,350,482 at 1440×922), cream on the water */
.works-card {
  left: 17.1%;
  top: 18.2%;
  width: 24.3%;
  min-height: 52.3%;
  padding: 1em 1.15em 1.15em;
  border-radius: 12px;
  background: #f6f2ef;
  color: #322d24;
  box-shadow: 0 18px 50px rgb(10 18 20 / 0.35);
  line-height: 1.42;
  text-shadow: none;
  overflow: hidden;
}
.works-close {
  position: absolute;
  right: 0.6em;
  top: 0.6em;
  width: 1.7em;
  height: 1.7em;
  border-radius: 50%;
  color: #6b6350;
  font-size: 0.9em;
  line-height: 1.7em;
  text-align: center;
  z-index: 1;
}
.works-close:hover, .works-close:focus-visible { background: rgb(50 45 36 / 0.1); color: #322d24; }

/* static thumbnail of the tax tool, redrawn after the reference card */
.works-art {
  background: #fff;
  border: 1px solid #e4ddd4;
  border-radius: 8px;
  padding: 0.55em 0.6em 0.65em;
  font-family: "Songti SC", "Newsreader", serif;
  font-size: 0.66em;
  line-height: 1.5;
  color: #55503f;
}
.wa-tabs { display: flex; border-bottom: 1px solid #e4ddd4; margin-bottom: 0.7em; }
.wa-tab { flex: 1; text-align: center; padding: 0.35em 0; color: #8a8371; position: relative; }
.wa-tab.is-active { color: #3a6ea5; font-weight: 450; }
.wa-tab.is-active::after { content: ""; position: absolute; left: 18%; right: 18%; bottom: -1px; height: 2px; background: #3a6ea5; }
.wa-group { margin-bottom: 0.75em; }
.wa-label { margin: 0 0 0.3em; font-size: 0.95em; color: #55503f; }
.wa-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f5f3ef;
  border-radius: 5px;
  padding: 0.4em 0.7em;
  color: #b3ac9c;
  font-size: 0.92em;
}
.wa-field b { font-weight: 400; color: #55503f; }
.wa-result {
  margin: 0.4em -0.35em 0;
  padding: 0.55em 0.85em 0.6em;
  background: #f8f6f2;
  border-radius: 6px;
}
.wa-result .wa-label { margin-bottom: 0.15em; }
.wa-num { margin: 0; font-size: 1.85em; color: #3a6ea5; text-align: right; line-height: 1.15; }
.wa-fine { margin: 0; text-align: right; font-size: 0.85em; color: #9a9384; }

.works-title { margin: 0.85em 0 0.25em; font-size: 1.16em; font-weight: 450; letter-spacing: 0.02em; }
.works-desc { margin: 0 0 0.9em; font-size: 0.92em; color: #4a4638; }
.works-detail {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  color: #3a6ea5;
  text-decoration: none;
  font-size: 0.98em;
}
.works-detail .arrow { transition: transform 0.3s var(--gentle-ease); }
.works-detail:hover .arrow, .works-detail:focus-visible .arrow { transform: translateX(3px); }
.works-detail:hover, .works-detail:focus-visible { text-decoration: underline; text-underline-offset: 3px; }

/* narrow screens: card keeps 12 px on each side and never clips */
@media (max-width: 700px) {
  .works-card {
    left: 12px;
    right: 12px;
    top: 14%;
    width: auto;
    min-height: 0;
    max-height: none;
    line-height: 1.38;
  }
}

/* about: a short brand note, centred on the water */
.about-panel {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(22.5em, calc(100vw - 24px));
  text-align: center;
  line-height: 1.28;
  text-wrap: pretty;
  text-shadow: 0 0 0.25em rgb(7 17 19 / 0.22), 0 0 0.65em rgb(7 17 19 / 0.38), 0 0 1.2em rgb(7 17 19 / 0.22);
}
.about-panel p { margin: 0 0 1.28em; }
.about-panel p:last-child { margin: 0; }
.about-name { font-style: italic; }

/* ---------------------------------------------------------------- context menu */
.context-links {
  position: fixed;
  z-index: 20;
  left: var(--context-x, -200px);
  top: var(--context-y, -200px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: min(320px, calc(100vw - 36px));
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--fade) var(--gentle-ease);
}
.context-links.is-open { opacity: 1; pointer-events: auto; }
.context-link {
  display: flex;
  width: 150px;
  height: 25px;
  margin-right: -30px;
  padding: 0 30px;
  align-items: center;
  justify-content: flex-end;
  color: #ffffff7f;
  text-decoration: none;
  white-space: nowrap;
  text-shadow: var(--halo);
  transition: color 0.36s var(--gentle-ease);
}
.context-link::after {
  content: "";
  display: block;
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-left: 7px;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  transition: opacity 0.36s var(--gentle-ease);
}
.context-link:hover, .context-link:focus-visible { color: #fff; }
.context-link:hover::after, .context-link:focus-visible::after { opacity: 1; }
