/* ════════════════════════════════════════════════════════════════
   Psyverse · Worlds — shared design system for the 16 standalone worlds
   (cohesive with psyverse.fun manifesto: deep-navy/near-black + gold,
    Fraunces / Cormorant Garamond / Noto Serif SC)
   ════════════════════════════════════════════════════════════════ */

:root {
  --bg: #f6f1e6;
  --bg-2: #efe8d8;
  --bg-3: #e9e1cd;
  --gold: #a8801f;
  --gold-bright: #b8860b;
  --gold-deep: #6e5518;
  --ivory: #241e13;
  --ivory-dim: rgba(36, 30, 19, 0.72);
  --ivory-faint: rgba(36, 30, 19, 0.50);
  --jade: #5a8f73;
  --rouge: #b14d42;
  --rouge-deep: #7a2f26;
  --line: rgba(143, 111, 43, 0.2);
  --line-soft: rgba(36, 30, 19, 0.10);
  --serif: "Cormorant Garamond", "Noto Serif SC", serif;
  --display: "Fraunces", "Noto Serif SC", serif;
  --cjk: "Noto Serif SC", "Cormorant Garamond", serif;
  --mono: "JetBrains Mono", monospace;
  /* per-world accent — override on <body data-accent> via inline style or below */
  --accent: var(--gold);
  --accent-soft: rgba(143, 111, 43, 0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ivory);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at 50% 0%, var(--accent-soft), transparent 60%),
    radial-gradient(ellipse at 20% 90%, rgba(90, 143, 115, 0.04), transparent 50%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.82  0 0 0 0 0.64  0 0 0 0 0.29  0 0 0 0.04 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-attachment: fixed;
}
::selection { background: var(--accent); color: var(--bg); }

/* — Light-scheme polish: native controls, themed scrollbar, anchor clearance — */
html { color-scheme: light; overflow-x: clip; }
html { scrollbar-width: thin; scrollbar-color: #cfc5ad transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cfc5ad; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }
section[id], [id^="w-"] { scroll-margin-top: 76px; }

img { max-width: 100%; display: block; }
a { color: inherit; }

/* ── language toggle visibility ── */
html[data-lang="en"] .cn { display: none !important; }
html[data-lang="zh"] .en { display: none !important; }

/* ════════ TOP BAR ════════ */
.w-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px; padding: 13px 26px;
  background: rgba(246, 241, 230, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.w-bar .home {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--display); font-style: italic; font-weight: 300;
  font-size: 16px; letter-spacing: 0.02em; color: var(--accent);
  text-decoration: none; flex-shrink: 0; transition: opacity .2s;
}
.w-bar .home:hover { opacity: .75; }
.w-bar .home .mark {
  width: 26px; height: 26px; flex-shrink: 0; font-size: 0;
  border: none; border-radius: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Ccircle cx='32' cy='32' r='26' fill='none' stroke='%23a8801f' stroke-width='2' opacity='0.4'/%3E%3Ccircle cx='32' cy='32' r='16.5' fill='none' stroke='%23a8801f' stroke-width='2.6' opacity='0.9'/%3E%3Ccircle cx='50.4' cy='13.6' r='3' fill='%23c9a24b'/%3E%3Ccircle cx='32' cy='32' r='5' fill='%23c9a24b'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform .3s cubic-bezier(.2,.7,.2,1);
}
.w-bar .home:hover .mark { transform: rotate(20deg) scale(1.06); }
.w-bar .bar-mid {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--ivory-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.w-bar .bar-right { display: flex; align-items: center; gap: 14px; flex-shrink: 1; min-width: 0; }
.w-bar .to-worlds {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--ivory-dim); text-decoration: none;
  transition: color .2s;
}
.w-bar .to-worlds:hover { color: var(--accent); }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.lang-switch button {
  background: transparent; color: var(--ivory-faint); border: none; cursor: pointer;
  font-family: var(--cjk); font-size: 11px; padding: 4px 9px;
  transition: background .25s, color .25s, transform .12s;
}
.lang-switch button.active { background: var(--accent); color: var(--bg); }
.lang-switch button:not(.active):hover { color: var(--ivory); }
.lang-switch button:active { transform: scale(.93); }

/* ════════ HERO ════════ */
.w-hero {
  position: relative; max-width: 1180px; margin: 0 auto;
  padding: 200px 48px 90px;
  border-bottom: 1px solid var(--line);
}
.w-hero .eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.32em;
  text-transform: uppercase; color: var(--gold-deep); margin-bottom: 28px;
}
.w-hero .w-num {
  font-family: var(--display); font-style: italic; font-weight: 200;
  font-size: clamp(96px, 16vw, 220px); line-height: 0.82;
  letter-spacing: -0.04em; font-variation-settings: "opsz" 144;
  color: var(--accent); margin-bottom: 8px;
}
.w-hero h1 {
  font-family: var(--display); font-weight: 300;
  font-size: clamp(40px, 6.5vw, 92px); line-height: 1.02;
  letter-spacing: -0.025em; color: var(--ivory); text-wrap: balance;
}
.w-hero h1 em { font-style: italic; color: var(--gold-bright); font-weight: 400; }
.w-hero h1 .cn {
  display: block; font-family: var(--cjk); font-weight: 500;
  font-size: 0.5em; letter-spacing: 0.16em; color: var(--accent); margin-top: 14px;
}
.w-hero .tagline {
  font-family: var(--display); font-style: italic; font-weight: 300;
  font-size: clamp(18px, 2.1vw, 27px); line-height: 1.5;
  color: var(--ivory-dim); max-width: 760px; margin-top: 34px; text-wrap: pretty;
}
.w-hero .tagline .cn {
  display: block; font-family: var(--cjk); font-style: normal;
  font-size: 0.86em; color: var(--ivory-dim); margin-top: 12px; letter-spacing: 0.05em;
}

/* ════════ CONTENT LAYOUT ════════ */
.w-wrap { max-width: 1180px; margin: 0 auto; padding: 0 48px; }
.w-section { position: relative; padding: 90px 0; border-bottom: 1px solid var(--line-soft); }
.w-section:last-of-type { border-bottom: none; }
.w-eyebrow {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--gold-deep); margin-bottom: 22px;
}
.w-h2 {
  font-family: var(--display); font-weight: 300;
  font-size: clamp(28px, 3.6vw, 46px); line-height: 1.08;
  letter-spacing: -0.02em; color: var(--ivory); text-wrap: balance;
}
.w-h2 .cn { display: block; font-family: var(--cjk); font-weight: 500; font-size: 0.5em; color: var(--accent); margin-top: 8px; letter-spacing: 0.14em; }
.w-h3 { font-family: var(--display); font-weight: 400; font-size: clamp(20px, 2vw, 27px); color: var(--gold-bright); letter-spacing: -0.01em; }
.w-h3 .cn { font-family: var(--cjk); font-weight: 500; font-size: 0.7em; color: var(--accent); margin-left: 10px; }
.w-lead {
  font-family: var(--display); font-style: italic; font-weight: 300;
  font-size: clamp(19px, 2.2vw, 28px); line-height: 1.5; color: var(--ivory-dim);
  max-width: 820px; text-wrap: pretty;
}
.w-lead .cn { display: block; font-family: var(--cjk); font-style: normal; font-size: 0.82em; margin-top: 10px; color: var(--ivory-dim); }
.w-p { font-size: 17px; line-height: 1.85; color: var(--ivory-dim); max-width: 720px; margin-top: 18px; text-wrap: pretty; }
.w-p .cn { display: block; font-family: var(--cjk); font-size: 0.92em; line-height: 1.95; color: var(--ivory-dim); margin-top: 10px; }
.w-p + .w-p { margin-top: 24px; }

.w-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px; margin-top: 44px; }
.w-grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.w-grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.w-card {
  position: relative; padding: 30px 28px;
  background: rgba(255,255,255,0.012);
  border: 1px solid var(--line); border-radius: 4px;
  transition: background .3s, box-shadow .35s, transform .35s cubic-bezier(.2,.7,.2,1), border-color .35s;
}
.w-card:hover {
  transform: translateY(-3px);
  background: var(--bg-2);
  box-shadow: 0 16px 42px -14px rgba(62, 48, 20, 0.20), 0 0 0 1px rgba(143, 111, 43,0.28), 0 0 32px -8px rgba(143, 111, 43,0.2);
}
.w-card .idx { font-family: var(--mono); font-size: 10px; letter-spacing: 0.22em; color: var(--gold-deep); }
.w-card .ttl { font-family: var(--display); font-size: 23px; font-weight: 400; color: var(--ivory); margin-top: 12px; }
.w-card .ttl .cn { display: block; font-family: var(--cjk); font-size: 0.7em; color: var(--accent); margin-top: 5px; }
.w-card .body { font-size: 14.5px; line-height: 1.75; color: var(--ivory-dim); margin-top: 14px; }
.w-card .body .cn { display: block; font-family: var(--cjk); font-size: 0.92em; margin-top: 8px; color: var(--ivory-dim); }

.w-quote {
  font-family: var(--display); font-style: italic; font-weight: 300;
  font-size: clamp(24px, 3.4vw, 42px); line-height: 1.35; color: var(--ivory);
  max-width: 900px; margin: 0 auto; text-align: center; text-wrap: balance;
}
.w-quote .cn { display: block; font-family: var(--cjk); font-style: normal; font-size: 0.6em; color: var(--accent); margin-top: 18px; }
.w-quote-attr { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold-deep); margin-top: 28px; }

.w-rule { height: 1px; background: linear-gradient(90deg, var(--accent), transparent 80%); margin: 0; border: none; }

/* ════════ WORLD NAVIGATION (prev/next + grid of all 16) ════════ */
.w-nav { max-width: 1180px; margin: 0 auto; padding: 80px 48px 40px; border-top: 1px solid var(--line); }
.w-nav-pn { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 64px; }
.w-nav-pn a {
  text-decoration: none; max-width: 46%;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ivory-dim);
  transition: color .2s; display: flex; flex-direction: column; gap: 6px;
}
.w-nav-pn a:hover { color: var(--accent); }
.w-nav-pn a.next { text-align: right; align-items: flex-end; }
.w-nav-pn a .big { font-family: var(--display); font-style: italic; font-size: 22px; letter-spacing: 0; text-transform: none; color: var(--ivory); }
.w-nav-pn a:hover .big { color: var(--accent); }
.w-allgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); }
.w-allgrid a {
  display: block; padding: 16px 16px; background: var(--bg); text-decoration: none;
  transition: background .25s; min-height: 78px;
}
.w-allgrid a:hover { background: var(--bg-2); }
.w-allgrid a.cur { background: var(--bg-3); }
.w-allgrid .gi-num { font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em; color: var(--gold-deep); }
.w-allgrid .gi-en { font-family: var(--display); font-size: 15px; color: var(--ivory); margin-top: 8px; line-height: 1.15; }
.w-allgrid a:hover .gi-en { color: var(--accent); }
.w-allgrid .gi-cn { font-family: var(--cjk); font-size: 11px; color: var(--ivory-faint); margin-top: 3px; }

/* ════════ FOOTER ════════ */
.w-foot { max-width: 1180px; margin: 0 auto; padding: 50px 48px 70px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 18px; align-items: center; }
.w-foot .sig { font-family: var(--display); font-style: italic; font-size: 15px; color: var(--ivory-faint); }
.w-foot .links { display: flex; gap: 22px; flex-wrap: wrap; }
.w-foot a { position: relative; font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-deep); text-decoration: none; transition: color .2s; }
.w-foot a::after { content: ""; position: absolute; left: 0; bottom: -3px; height: 1px; width: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .3s; }
.w-foot a:hover { color: var(--accent); }
.w-foot a:hover::after { transform: scaleX(1); }

/* ════════ MOTION (gated) ════════ */
@media (prefers-reduced-motion: no-preference) {
  html.js-anim [data-rv] { opacity: 0; transform: translateY(22px); transition: opacity .7s ease, transform .85s cubic-bezier(.2,.7,.2,1); transition-delay: var(--rv, 0ms); }
  html.js-anim [data-rv].in { opacity: 1; transform: none; }
}

/* per-section atmosphere glow */
.w-section::after {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  top: 6%; bottom: 6%; width: 64vw;
  background: radial-gradient(ellipse at center, var(--accent-soft), transparent 70%);
}
.w-section:nth-of-type(odd)::after { left: -16vw; }
.w-section:nth-of-type(even)::after { left: auto; right: -16vw; background: radial-gradient(ellipse at center, rgba(90,143,115,0.04), transparent 70%); }
body::after { content: ""; position: fixed; inset: 0; z-index: 2; pointer-events: none; background: radial-gradient(ellipse at 50% 42%, transparent 58%, rgba(0,0,0,0.42) 100%); }

/* ════════ IN-PAGE CHROME · progress · section rail · back-to-top ════════ */
.w-progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0; z-index: 60;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold), var(--gold-bright));
  box-shadow: 0 0 10px rgba(143, 111, 43,0.5); will-change: width;
}
.w-secrail {
  position: fixed; right: 18px; top: 50%; transform: translateY(-50%); z-index: 45;
  display: flex; flex-direction: column; gap: 12px; align-items: flex-end;
}
.w-secrail a { position: relative; width: 9px; height: 9px; display: block; }
.w-secrail a::after {
  content: ""; position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--accent);
  opacity: 0.35; transition: opacity .3s, background .3s, box-shadow .3s, width .3s, height .3s;
}
.w-secrail a:hover::after { opacity: 1; }
.w-secrail a.active::after { opacity: 1; width: 9px; height: 9px; background: var(--accent); box-shadow: 0 0 9px var(--accent); }
.w-secrail .lbl {
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%) translateX(6px);
  white-space: nowrap; font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--gold); background: rgba(246, 241, 230,0.85);
  border: 1px solid var(--line); border-radius: 3px; padding: 3px 9px;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; backdrop-filter: blur(6px);
}
.w-secrail a:hover .lbl { opacity: 1; transform: translateY(-50%) translateX(0); }
@media (max-width: 1100px) { .w-secrail { display: none; } }
.w-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 46;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(246, 241, 230,0.7); backdrop-filter: blur(8px);
  color: var(--accent); cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .3s, transform .3s, background .25s, color .25s;
}
.w-top.show { opacity: 1; transform: none; pointer-events: auto; }
.w-top:hover { background: var(--accent); color: var(--bg); }

/* ════════ INTERACTIVE KIT (shared widgets for per-world functionality) ════════ */
.w-interactive {
  border: 1px solid var(--line); border-radius: 6px; background: rgba(255,255,255,0.012);
  padding: 26px 26px 30px; margin-top: 38px;
}
.w-interactive .ix-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.w-interactive .ix-title { font-family: var(--display); font-size: 21px; font-weight: 400; color: var(--gold-bright); }
.w-interactive .ix-title .cn { font-family: var(--cjk); font-size: 0.7em; color: var(--accent); margin-left: 8px; }
.w-interactive .ix-hint { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-deep); }
.w-tabs, .w-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.w-tab, .w-chip {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ivory-dim); background: transparent; border: 1px solid var(--line);
  border-radius: 20px; padding: 7px 15px; cursor: pointer;
  transition: background .25s, color .25s, border-color .25s, transform .1s;
}
.w-tab:hover, .w-chip:hover { color: var(--ivory); border-color: var(--accent); }
.w-tab.active, .w-chip.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.w-tab:active, .w-chip:active { transform: scale(0.96); }
.w-panel[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .w-panel:not([hidden]) { animation: wfade .4s ease; }
  @keyframes wfade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}
.w-range { -webkit-appearance: none; appearance: none; width: 100%; height: 2px; background: var(--line); border-radius: 2px; outline: none; margin: 20px 0; }
.w-range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--gold-bright); cursor: pointer; box-shadow: 0 0 10px var(--gold); }
.w-range::-moz-range-thumb { width: 16px; height: 16px; border: none; border-radius: 50%; background: var(--gold-bright); cursor: pointer; box-shadow: 0 0 10px var(--gold); }
.w-readout { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; color: var(--gold); }
.w-search {
  width: 100%; background: rgba(246, 241, 230,0.5); border: 1px solid var(--line); border-radius: 4px;
  color: var(--ivory); font-family: var(--serif); font-size: 16px; padding: 11px 14px; outline: none;
  transition: border-color .25s;
}
.w-search:focus { border-color: var(--accent); }
.w-search::placeholder { color: var(--ivory-faint); }
.w-stepper { display: flex; align-items: center; gap: 16px; }
.w-stepper button {
  font-family: var(--mono); font-size: 14px; color: var(--accent); background: transparent;
  border: 1px solid var(--line); border-radius: 50%; width: 38px; height: 38px; cursor: pointer;
  transition: background .25s, color .25s;
}
.w-stepper button:hover { background: var(--accent); color: var(--bg); }
.w-fade-out { opacity: 0.18 !important; filter: grayscale(0.6); }
.w-fade-out, .w-card, .world-tile { transition: opacity .3s, filter .3s, background .3s, box-shadow .35s, transform .35s cubic-bezier(.2,.7,.2,1), border-color .35s; }

/* ════════ ACCESSIBILITY ════════ */
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* ════════ RESPONSIVE ════════ */
@media (max-width: 760px) {
  .w-hero { padding: 150px 22px 60px; }
  .w-wrap, .w-nav, .w-foot { padding-left: 22px; padding-right: 22px; }
  .w-bar { padding: 11px 16px; }
  .w-bar .bar-mid { display: none; }
  .w-section { padding: 64px 0; }
  .w-nav-pn a .big { font-size: 18px; }
}
