@font-face {
  font-family: "NJ Title";
  src: url("fonts/title.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "NJ Latin";
  src: url("fonts/latin.woff2") format("woff2");
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "NJ Latin";
  src: url("fonts/latin-upright.woff2") format("woff2");
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "NJ Arabic";
  src: url("fonts/arabic.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "NJ Korean";
  src: url("fonts/korean.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "NJ Japanese";
  src: url("fonts/japanese.woff2") format("woff2");
  font-display: swap;
}

:root {
  --paper: #F6F1E8;
  --ink: #1E1B18;
  --ink-soft: #5A524A;
  --cinnabar: #C83323;
  --teal: #0E6E6B;
  --gold: #C9A15A;
  --cjk: "NJ Title", "Kaiti SC", "STKaiti", "KaiTi", serif;
  --latin: "NJ Latin", "Cormorant Garamond", Georgia, serif;
  /* 舞台按 16:9 铺满视口（等同 background-size: cover），--u 为舞台宽度的 1% */
  --stage-w: max(100vw, 177.78vh);
  --stage-h: max(100vh, 56.25vw);
  --u: calc(var(--stage-w) / 100);
  --px: 0;
  --py: 0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

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

/* 宣纸颗粒 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45  0 0 0 0 .38  0 0 0 0 .3  0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.scene {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--stage-w);
  height: var(--stage-h);
  translate: -50% -50%;
}

/* ---------- 底纹经文 ---------- */
.classic {
  position: absolute;
  inset: 3% 2% 3% 2%;
  writing-mode: vertical-rl;
  font-size: calc(var(--u) * 4.4);
  line-height: 1.68;
  letter-spacing: .08em;
  color: var(--ink);
  opacity: 0;
  overflow: hidden;
  animation: classic-in 3s 0.3s ease forwards;
}
@keyframes classic-in { to { opacity: .024; } }

/* ---------- 图层 ---------- */
.layer {
  position: absolute;
  translate: calc(var(--px) * var(--d, 0) * 1px) calc(var(--py) * var(--d, 0) * 1px);
  transition: translate 1.2s cubic-bezier(.2,.7,.2,1);
}
.layer img { display: block; width: 100%; height: auto; }

.l-flame    { left: 0;   top: 0;   width: 22%; --d: 14; }
.l-sun      { left: 86.5%; top: -25.8%; width: 29%; --d: 6; }
.l-peaks    { left: 53%; top: 14%; width: 47%; --d: 10; }
.l-mountain { left: 48%; top: 54%; width: 52%; --d: 24; }
.l-cloud    { left: 0;   top: 48%; width: 40%; --d: 30; }
.l-scroll   { left: 3%;  top: 52%; width: 81%; --d: 18; }

.l-peaks img, .l-mountain img { scale: -1 1; }

/* 入场 */
.l-sun img      { animation: sun-in 2.4s .2s cubic-bezier(.2,.7,.2,1) both, sun-breathe 9s 2.6s ease-in-out infinite alternate; transform-origin: 50% 50%; }
.l-flame img    { animation: from-left 2s .5s cubic-bezier(.2,.7,.2,1) both, sway 10s 2.5s ease-in-out infinite alternate; transform-origin: 0 100%; }
.l-peaks img    { animation: rise 2.2s .4s cubic-bezier(.2,.7,.2,1) both; }
.l-mountain img { animation: rise 2s .6s cubic-bezier(.2,.7,.2,1) both; }
.l-cloud img    { animation: from-left 2.2s .7s cubic-bezier(.2,.7,.2,1) both, drift 14s 2.9s ease-in-out infinite alternate; }
.l-scroll img   { animation: unroll 2.6s 1s cubic-bezier(.6,.05,.25,1) both, float 8s 3.6s ease-in-out infinite alternate; }

@keyframes sun-in      { from { opacity: 0; translate: 0 -12%; } to { opacity: 1; translate: 0 0; } }
@keyframes sun-breathe { from { scale: 1; filter: saturate(1); } to { scale: 1.035; filter: saturate(1.12) brightness(1.03); } }
@keyframes from-left   { from { opacity: 0; translate: -14% 0; } to { opacity: 1; translate: 0 0; } }
@keyframes rise        { from { opacity: 0; translate: 0 12%; } to { opacity: 1; translate: 0 0; } }
@keyframes sway        { from { rotate: 0deg; } to { rotate: 2.2deg; } }
@keyframes drift       { from { translate: 0 0; } to { translate: 4% -1.5%; } }
@keyframes float       { from { translate: 0 0; } to { translate: 0 -3%; } }
@keyframes unroll {
  from { opacity: 0; clip-path: inset(0 50% 0 50%); }
  15%  { opacity: 1; }
  to   { opacity: 1; clip-path: inset(0 0 0 0); }
}

/* ---------- 标题 ---------- */
.title {
  position: absolute;
  left: 50%;
  top: 15%;
  translate: -50% 0;
  width: min(92vw, 62rem);
  text-align: center;
  --t: min(5.6vw, 9.4vh);
  animation: text-in 2.4s 1.6s ease both;
}
@keyframes text-in {
  from { opacity: 0; filter: blur(10px); }
  to   { opacity: 1; filter: blur(0); }
}

h1 {
  display: inline-flex;
  align-items: flex-start;
  gap: calc(var(--t) * .28);
  font-weight: 400;
}
.name {
  font-size: var(--t);
  letter-spacing: .14em;
  margin-right: -.14em;
  line-height: 1.2;
  white-space: nowrap;
}
.seal {
  flex: none;
  display: grid;
  place-items: center;
  width: calc(var(--t) * .56);
  height: calc(var(--t) * .96);
  margin-top: .1em;
  background: url("img/seal-red-blank.png") center / 100% 100% no-repeat;
  writing-mode: vertical-rl;
  font-size: calc(var(--t) * .28);
  line-height: 1.05;
  letter-spacing: .02em;
  color: #FBF4EA;
  animation: stamp .9s 3.1s cubic-bezier(.3,1.6,.5,1) both;
}
@keyframes stamp {
  from { opacity: 0; scale: 1.6; rotate: -8deg; }
  to   { opacity: 1; scale: 1; rotate: 0deg; }
}

.logo {
  display: block;
  width: calc(var(--t) * 1.25);
  height: auto;
  margin: 0 auto calc(var(--t) * .35);
}

.msgs {
  display: grid;
  margin-top: calc(var(--t) * .55);
  font-size: calc(var(--t) * .42);
  color: var(--ink-soft);
}
.msg {
  grid-area: 1 / 1;
  letter-spacing: .14em;
  opacity: 0;
  visibility: hidden;
}
.msg:lang(en), .msg:lang(fr), .msg:lang(es), .msg:lang(ru), .msg:lang(de) {
  font-family: var(--latin);
  font-style: italic;
  font-size: 1.12em;
  letter-spacing: .06em;
}
.msg:lang(ar) { font-family: "NJ Arabic", "Geeza Pro", serif; letter-spacing: 0; font-size: 1.12em; }
.msg:lang(ko) { font-family: "NJ Korean", "AppleMyungjo", serif; }
.msg:lang(ja) { font-family: "NJ Japanese", var(--cjk); }

.msg.active  { visibility: visible; animation: ink-in 1.6s cubic-bezier(.2,.7,.2,1) both; }
.msg.leaving { visibility: visible; animation: ink-out 1.1s ease both; }

/* 墨晕：由散而聚 / 由聚而散 */
@keyframes ink-in {
  from { opacity: 0; filter: blur(12px); scale: 1.04; }
  45%  { opacity: .9; }
  to   { opacity: 1; filter: blur(0); scale: 1; }
}
@keyframes ink-out {
  from { opacity: 1; filter: blur(0); scale: 1; }
  to   { opacity: 0; filter: blur(9px); scale: .97; }
}

.domain {
  margin-top: calc(var(--t) * .5);
  font-family: var(--latin);
  font-size: calc(var(--t) * .26);
  letter-spacing: .32em;
  color: var(--cinnabar);
  text-transform: uppercase;
}

/* ---------- 语言切换 ---------- */
.langs {
  position: absolute;
  left: 50%;
  bottom: max(2.4vh, env(safe-area-inset-bottom));
  translate: -50% 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .2rem .9rem;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: .45rem 1.1rem;
  border-radius: 999px;
  background: rgba(246, 241, 232, .72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: text-in 2s 2.6s ease both;
}
.langs button {
  appearance: none;
  border: 0;
  background: none;
  font: 400 .78rem/1.6 var(--latin);
  letter-spacing: .06em;
  color: var(--ink-soft);
  cursor: pointer;
  padding: .1rem 0;
  border-bottom: 1px solid transparent;
  transition: color .4s, border-color .4s;
}
.langs button:lang(zh-Hans), .langs button:lang(zh-Hant), .langs button:lang(ja), .langs button:lang(ko) { font-family: system-ui, sans-serif; font-size: .74rem; }
.langs button:hover { color: var(--ink); }
.langs button[aria-current="true"] { color: var(--cinnabar); border-bottom-color: currentColor; }
.langs button:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: 3px; }

/* ---------- 竖屏（手机） ---------- */
@media (max-aspect-ratio: 4/5) {
  :root { --u: 1vw; }
  .stage { width: 100%; height: 100%; }
  .classic { inset: 2% 3%; font-size: 8.4vw; }

  .l-sun      { left: auto; right: -22vw; top: -20vw; width: 56vw; }
  .l-flame    { left: -3vw; top: -2vw;   width: 30vw; }
  .l-peaks    { left: auto; right: -30vw; top: auto; bottom: 22svh; width: 96vw; }
  .l-mountain { left: auto; right: -20vw; top: auto; bottom: -1svh; width: 116vw; }
  .l-cloud    { left: -10vw; top: auto;   bottom: -2svh; width: 88vw; }
  .l-scroll   { left: -26vw; top: auto;   bottom: 17svh; width: 150vw; }

  .title { top: 25svh; --t: 7.4vw; }
  .logo { width: calc(var(--t) * 1.6); }
  .name { letter-spacing: .08em; margin-right: -.08em; }
  .msgs  { font-size: calc(var(--t) * .56); }
  .domain { font-size: calc(var(--t) * .32); }
  .langs { gap: .1rem .75rem; padding: .4rem .9rem; }
}

@media (prefers-reduced-motion: reduce) {
  .layer { transition: none; }
  .layer img, .classic, .title, .langs { animation-duration: .01s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }
  .classic { opacity: .024; animation: none; }
  .msg.active  { animation: fade-in .6s ease both; }
  .msg.leaving { animation: fade-out .4s ease both; }
  @keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
  @keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
}
