:root {
  --paper: var(--ici-field);
  --paper-soft: var(--ici-field-raised);
  --ink: var(--ici-ink);
  --body: var(--ici-body);
  --muted: var(--ici-muted);
  --faint: var(--ici-faint);
  --sand: var(--ici-accent);
  --sand-soft: var(--ici-accent-soft);
  --line: var(--ici-line);
  --line-strong: var(--ici-line-strong);
  --focus: var(--ici-focus);
  --sans: var(--ici-sans);
  --serif: var(--ici-serif);
  --ease-out: var(--ici-ease-out);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
button { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }

.skip {
  position: fixed;
  top: -5rem;
  left: 1rem;
  z-index: 20;
  padding: .75rem 1rem;
  background: var(--ink);
  color: var(--paper);
}
.skip:focus { top: 1rem; }

.site-head {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 50%;
  width: min(76rem, calc(100% - 2rem));
  min-height: 4.5rem;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .17);
}
.site-head-start {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.page-back {
  flex: 0 0 auto;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0 .55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  border-radius: 999px;
  color: rgba(255, 255, 255, .7);
  font-size: .72rem;
  text-decoration: none;
}
.page-back svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  text-decoration: none;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .1em;
}
.site-brand-mark {
  width: 18px;
  flex: 0 0 18px;
  display: grid;
  gap: 1.5px;
}
.site-brand-mark i {
  display: block;
  height: 1.5px;
  border-radius: 2px;
  background: currentColor;
}
.site-brand-mark i.is-yin {
  background: linear-gradient(90deg, currentColor 0 42%, transparent 42% 58%, currentColor 58%);
}
.site-brand-name { white-space: nowrap; }
.brand small {
  color: rgba(255, 255, 255, .58);
  font: .7rem/1 var(--sans);
  letter-spacing: .08em;
}
.lang-toggle, .return-link {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 999px;
  background: rgba(7, 10, 8, .24);
  color: rgba(255, 255, 255, .84);
  text-decoration: none;
  backdrop-filter: blur(8px);
}
.lang-toggle {
  min-width: 3.1rem;
  padding: 0 .85rem;
  cursor: pointer;
}
.return-link { padding: 0 1rem; font-size: .78rem; }

.hero {
  position: relative;
  min-height: min(56rem, 100svh);
  display: grid;
  align-items: end;
  overflow: hidden;
  background: #1a211c;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("/assets/scene64_web/g01_qian.webp") center 42% / cover no-repeat;
  filter: saturate(.68) contrast(1.04);
  transform: scale(1.015);
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(6, 9, 7, .28) 0%, rgba(6, 9, 7, .06) 32%, rgba(6, 9, 7, .76) 73%, var(--paper) 100%),
    linear-gradient(90deg, rgba(6, 9, 7, .72) 0%, rgba(6, 9, 7, .22) 58%, rgba(6, 9, 7, .08) 100%);
}
.hero-inner {
  position: relative;
  z-index: 2;
  width: min(76rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(9rem, 20vh, 14rem) 0 clamp(4rem, 9vh, 7rem);
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(18rem, .58fr);
  align-items: end;
  gap: clamp(3rem, 8vw, 8rem);
}
.hero-copy { max-width: 47rem; }
h1, h2, h3, p { margin-top: 0; }
h1 {
  max-width: 12em;
  margin-bottom: 1.5rem;
  font: 520 clamp(3rem, 7vw, 6rem)/1.03 var(--sans);
  letter-spacing: -.04em;
  text-wrap: balance;
}
.hero-lead {
  max-width: 40rem;
  margin-bottom: 2rem;
  color: rgba(255, 255, 255, .76);
  font-size: clamp(1rem, 1.8vw, 1.18rem);
  line-height: 1.8;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.primary-action, .secondary-action {
  min-height: 3rem;
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  padding: .75rem 1.1rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: .88rem;
}
.primary-action { background: var(--ink); color: #121512; }
.secondary-action { border: 1px solid rgba(255, 255, 255, .28); color: rgba(255, 255, 255, .88); }
.arrow-icon { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.6; }

.hero-figure {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.4rem;
  align-items: end;
  padding: 1.5rem 0 0 1.5rem;
  border-left: 1px solid rgba(255, 255, 255, .22);
}
.hexagram { width: 7.4rem; display: flex; flex-direction: column-reverse; gap: .65rem; }
.line { height: .65rem; display: flex; gap: .75rem; }
.line > i { display: block; flex: 1; border-radius: 1px; background: rgba(255, 255, 255, .92); }
.line.broken > i { flex: 1 1 0; }
.hero-formula strong {
  display: block;
  margin-bottom: .25rem;
  font: 500 clamp(1.6rem, 3vw, 2.5rem)/1.1 var(--sans);
  letter-spacing: -.03em;
}
.hero-formula span { color: rgba(255, 255, 255, .64); font-size: .78rem; line-height: 1.5; }

main { overflow: hidden; }
.tour {
  width: min(76rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(5rem, 10vw, 9rem) 0;
}
.tour-intro {
  max-width: 48rem;
  margin-bottom: clamp(4rem, 8vw, 7rem);
}
.tour-intro h2, .human-copy h2, .routes h2, .library h2 {
  margin-bottom: 1.25rem;
  font-size: clamp(2rem, 4.5vw, 4rem);
  font-weight: 520;
  line-height: 1.1;
  letter-spacing: -.035em;
  text-wrap: balance;
}
.tour-intro p, .human-copy p {
  max-width: 43rem;
  color: var(--body);
  font-size: 1rem;
  line-height: 1.85;
}

.steps { border-top: 1px solid var(--line-strong); }
.step {
  min-height: 31rem;
  display: grid;
  grid-template-columns: 5rem minmax(16rem, .72fr) minmax(19rem, 1fr);
  align-items: center;
  gap: clamp(2rem, 5vw, 5rem);
  padding: clamp(4rem, 8vw, 7rem) 0;
  border-bottom: 1px solid var(--line);
}
.step-number {
  align-self: start;
  padding-top: .4rem;
  color: var(--sand);
  font: 500 .8rem/1 var(--sans);
  letter-spacing: .1em;
}
.step-copy h3 {
  margin-bottom: 1rem;
  font-size: clamp(1.7rem, 3vw, 2.8rem);
  font-weight: 520;
  line-height: 1.14;
  letter-spacing: -.03em;
}
.step-copy p { color: var(--body); line-height: 1.85; }
.equation {
  margin-top: 1.75rem;
  color: var(--sand);
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  letter-spacing: -.02em;
}
.term {
  min-width: 1.5rem;
  min-height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-bottom: 1px dotted var(--sand);
  padding: 0;
  background: none;
  color: var(--sand);
  cursor: help;
}

.line-pair { display: grid; gap: 2rem; }
.line-sample { display: grid; grid-template-columns: 9rem 1fr; align-items: center; gap: 1.5rem; }
.line-sample .line { height: 1rem; }
.line-label strong { display: block; margin-bottom: .3rem; font-size: 1rem; font-weight: 550; }
.line-label span { color: var(--muted); font-size: .82rem; }

.trigram-field {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.5rem 1rem;
}
.trigram { min-width: 0; }
.trigram-lines { width: 4.2rem; display: flex; flex-direction: column-reverse; gap: .32rem; margin-bottom: .65rem; }
.trigram-lines .line { height: .38rem; gap: .4rem; }
.trigram-name { display: block; font-size: .88rem; }
.trigram-motion { display: block; margin-top: .16rem; color: var(--muted); font-size: .72rem; }

.stack-demo { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1.2rem; }
.source-gua { display: grid; gap: 1.75rem; }
.small-gua { display: grid; justify-items: center; gap: .75rem; }
.small-gua .trigram-lines { margin: 0; width: 5.4rem; }
.small-gua span { color: var(--muted); font-size: .8rem; text-align: center; }
.stack-plus { color: var(--sand); font-size: 1.4rem; }
.combined { padding-left: 1.4rem; border-left: 1px solid var(--line-strong); }
.combined .hexagram { width: 6.4rem; gap: .48rem; }
.combined .line { height: .55rem; gap: .6rem; }

.positions { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2rem; }
.positions .hexagram { width: 7rem; gap: .55rem; }
.positions .line { height: .62rem; gap: .65rem; }
.position-list { margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: .8rem; line-height: 2.08; }
.position-list strong { color: var(--body); font-weight: 520; }

.human {
  position: relative;
  min-height: 43rem;
  display: grid;
  align-items: end;
  background: url("/assets/scene64_web/g11_tai.webp") center / cover no-repeat;
}
.human::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(7, 10, 8, .9) 0%, rgba(7, 10, 8, .6) 54%, rgba(7, 10, 8, .12) 100%),
              linear-gradient(0deg, var(--paper) 0%, transparent 34%, rgba(7, 10, 8, .18) 100%);
}
.human-copy {
  position: relative;
  z-index: 2;
  width: min(76rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(5rem, 12vw, 9rem) 0;
}
.human-copy p { color: rgba(255, 255, 255, .79); }
.human-copy .thesis {
  max-width: 25em;
  margin-bottom: 1.5rem;
  color: var(--ink);
  font: 500 clamp(1.6rem, 3.2vw, 2.7rem)/1.45 var(--serif);
  letter-spacing: .01em;
}

.routes, .library {
  width: min(76rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(5rem, 10vw, 9rem) 0;
}
.routes > p, .library > p { max-width: 42rem; color: var(--muted); line-height: 1.75; }
.route-list { margin-top: 3.5rem; border-top: 1px solid var(--line-strong); }
.route {
  min-height: 8.5rem;
  display: grid;
  grid-template-columns: minmax(12rem, .55fr) minmax(16rem, 1fr) auto;
  align-items: center;
  gap: 2rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.route strong { font-size: clamp(1.25rem, 2.4vw, 2rem); font-weight: 520; letter-spacing: -.02em; }
.route span { max-width: 34rem; color: var(--muted); line-height: 1.65; }
.route .route-arrow {
  width: 2.7rem;
  height: 2.7rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--sand);
}

.library { border-top: 1px solid var(--line); }
.shelves {
  margin-top: 3.5rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4rem 6rem;
}
.shelf { padding-top: 1.25rem; border-top: 1px solid var(--line-strong); }
.shelf h3 { margin-bottom: 1.2rem; font-size: 1.2rem; font-weight: 550; }
.shelf ul { margin: 0; padding: 0; list-style: none; }
.shelf li + li { border-top: 1px solid rgba(239, 233, 218, .08); }
.shelf a {
  min-height: 3.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--body);
  font-size: .9rem;
  line-height: 1.45;
  text-decoration: none;
}
.shelf a::after { content: "↗"; color: var(--faint); }

footer {
  width: min(76rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: .75rem;
  line-height: 1.65;
}

.term-panel {
  position: fixed;
  z-index: 30;
  width: min(22rem, calc(100vw - 2rem));
  padding: 1.1rem 3rem 1.1rem 1.1rem;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #1b201c;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .34);
  color: var(--body);
}
.term-panel[hidden] { display: none; }
.term-panel h2 { margin: 0 0 .5rem; color: var(--ink); font-size: 1rem; font-weight: 600; }
.term-panel p { margin: 0; font-size: .86rem; line-height: 1.65; }
.term-panel a {
  min-height: 1.5rem;
  display: inline-flex;
  align-items: center;
  margin-top: .65rem;
  color: var(--sand);
  font-size: .8rem;
}
.term-close {
  position: absolute;
  top: .65rem;
  right: .65rem;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.term-close svg { width: .9rem; height: .9rem; stroke: currentColor; stroke-width: 1.8; }

@media (hover: hover) {
  .primary-action, .secondary-action, .lang-toggle, .return-link, .page-back, .route, .shelf a, .term-close {
    transition: color .2s ease, background-color .2s ease, border-color .2s ease;
  }
  .secondary-action:hover, .lang-toggle:hover, .return-link:hover, .page-back:hover { border-color: rgba(255, 255, 255, .56); color: #fff; }
  .route:hover strong, .shelf a:hover { color: var(--sand); }
  .route:hover .route-arrow { background: var(--sand-soft); border-color: var(--sand); }
  .term-close:hover { background: rgba(255, 255, 255, .08); color: var(--ink); }
}

@media (max-width: 50rem) {
  .site-head { grid-template-columns: 1fr auto; }
  .return-link { display: none; }
  .hero-inner { grid-template-columns: 1fr; gap: 3rem; }
  .hero-figure { max-width: 26rem; }
  .step { grid-template-columns: 3rem 1fr; min-height: 0; }
  .step-visual { grid-column: 2; }
  .trigram-field { grid-template-columns: repeat(4, minmax(3.6rem, 1fr)); }
  .route { grid-template-columns: 1fr auto; gap: .8rem 1.5rem; }
  .route span { grid-column: 1; }
  .route .route-arrow { grid-column: 2; grid-row: 1 / span 2; }
  .shelves { gap: 3rem 2rem; }
}

@media (max-width: 36rem) {
    .site-head { min-height: 4rem; }
  .page-back { width: 2.75rem; padding: 0; }
  .page-back span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .brand small { display: none; }
  .hero { min-height: 51rem; }
  .hero::before { background-position: 62% 42%; }
  .hero-inner { padding-top: 8rem; padding-bottom: 3.5rem; }
  h1 { font-size: clamp(2.7rem, 14vw, 4.2rem); }
  .hero-lead { font-size: .96rem; line-height: 1.72; }
  .hero-figure { grid-template-columns: auto 1fr; padding-left: 1rem; }
  .hexagram { width: 5.7rem; gap: .5rem; }
  .line { height: .5rem; gap: .55rem; }
  .tour { padding-top: 4.5rem; }
  .step { display: block; padding: 4rem 0; }
  .step-number { margin-bottom: 1.2rem; }
  .step-visual { margin-top: 2.5rem; }
  .line-sample { grid-template-columns: 7rem 1fr; }
  .trigram-field { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
  .stack-demo { grid-template-columns: 1fr auto 1fr; gap: .6rem; }
  .combined { padding-left: .8rem; }
  .human { min-height: 38rem; background-position: 62% center; }
  .human::after { background: linear-gradient(90deg, rgba(7, 10, 8, .88), rgba(7, 10, 8, .5)), linear-gradient(0deg, var(--paper), transparent 45%); }
  .route { min-height: 9.5rem; }
  .shelves { grid-template-columns: 1fr; }
  .term-panel { left: 1rem !important; right: 1rem; bottom: 1rem; top: auto !important; width: auto; }
}

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