/* ==========================================================================
   Legal (Privacy / Terms) + 404 "latent space"
   Scoped with .legal-… and .nf… ; logical properties only (RTL safe).
   ========================================================================== */

/* ---------- Legal hero ---------- */
.legal-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  overflow: clip;
  padding-block: calc(var(--header-h) + clamp(48px, 7vw, 112px)) clamp(48px, 6vw, 88px);
  border-block-end: 1px solid var(--line);
}
.legal-hero__bg { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.legal-hero__bg .grid-lines {
  -webkit-mask-image: radial-gradient(ellipse 70% 80% at 80% 20%, #000 10%, transparent 70%);
  mask-image: radial-gradient(ellipse 70% 80% at 80% 20%, #000 10%, transparent 70%);
  opacity: 0.4;
}
.legal-hero__glow { width: 52vw; height: 52vw; inset-block-start: -24vw; inset-inline-end: -14vw; opacity: 0.32; }
.legal-hero__watermark {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: clamp(-40px, -2vw, 0px);
  translate: 0 -46%;
  font-size: clamp(240px, 34vw, 520px);
  font-weight: 200;
  line-height: 0.8;
  letter-spacing: -0.06em;
  color: transparent;
  -webkit-text-stroke: 1px rgba(207, 226, 255, 0.13);
  user-select: none;
}
.legal-hero__watermark::first-letter { -webkit-text-stroke-color: rgba(255, 201, 90, 0.22); }
.legal-hero__inner { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 22px; }
.legal-hero__title { font-size: clamp(48px, 7.2vw, 108px); }
.legal-hero__lead { max-width: 56ch; }
.legal-hero__updated {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-block-start: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: rgba(207, 226, 255, 0.03);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.legal-hero__date { color: var(--text); }
.legal-hero__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold-2); box-shadow: 0 0 10px var(--gold-2); }
[dir="rtl"] .legal-hero__updated, :lang(zh-Hans) .legal-hero__updated { letter-spacing: 0.02em; }

.legal-switch {
  display: inline-flex;
  gap: 2px;
  margin-block-end: 8px;
  padding: 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border);
  background: rgba(207, 226, 255, 0.04);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.legal-switch__item {
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  color: var(--text-3);
  transition: color var(--dur-fast), background-color var(--dur-fast);
}
.legal-switch__item:hover { color: var(--text); }
.legal-switch__item[aria-current="page"] {
  color: var(--text);
  background: linear-gradient(180deg, rgba(207, 226, 255, 0.14), rgba(207, 226, 255, 0.06));
  box-shadow: 0 0 0 1px rgba(207, 226, 255, 0.16) inset;
}

/* ---------- Legal body ---------- */
.legal-body { padding-block-start: clamp(48px, 6vw, 96px); }
.legal-layout {
  display: grid;
  grid-template-columns: minmax(220px, 290px) minmax(0, 1fr);
  gap: clamp(40px, 6vw, 112px);
  align-items: start;
}
.legal-toc { position: sticky; inset-block-start: calc(var(--header-h) + 36px); }
.legal-toc__inner { max-height: calc(100vh - var(--header-h) - 72px); overflow-y: auto; padding-block-end: 8px; scrollbar-width: thin; }
.legal-toc__title {
  margin-block-end: 16px;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}
.legal-toc__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; border-inline-start: 1px solid var(--line); }
.legal-toc__link {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 6px;
  margin-inline-start: -1px;
  padding-block: 7px;
  padding-inline: 14px 8px;
  border-inline-start: 1px solid transparent;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-3);
  transition: color var(--dur-fast), border-color var(--dur-fast), background-color var(--dur-fast);
}
.legal-toc__link { --toc-glow: linear-gradient(90deg, rgba(240, 169, 30, 0.08), transparent); }
[dir="rtl"] .legal-toc__link { --toc-glow: linear-gradient(270deg, rgba(240, 169, 30, 0.08), transparent); }
.legal-toc__link:hover { color: var(--text); border-inline-start-color: var(--gold-2); background-image: var(--toc-glow); }
.legal-toc__num { font-family: var(--font-mono); font-size: 11px; padding-block-start: 2px; color: var(--text-3); opacity: 0.75; }

.legal-toc-mobile { display: none; }

/* Scroll-spy without JS: each section is a view timeline; its TOC link lights up while the section
   crosses a reading line ~28% down the viewport. Browsers without scroll-driven animations keep the plain list. */
@supports (view-timeline-name: --a) and (timeline-scope: --a) {
  .legal-layout { timeline-scope: var(--legal-scope); }
  .legal-section { view-timeline-name: var(--legal-tl); view-timeline-inset: 28% 71%; }
  .legal-toc__link {
    animation: legal-toc-on linear both;
    animation-fill-mode: none;
    animation-timeline: var(--legal-tl);
    animation-range: cover 0% cover 100%;
  }
  .legal-toc__num {
    animation: legal-toc-num linear;
    animation-fill-mode: none;
    animation-timeline: var(--legal-tl);
    animation-range: cover 0% cover 100%;
  }
}
@keyframes legal-toc-on {
  0%, 100% { color: var(--text); border-inline-start-color: var(--gold-2); background-image: var(--toc-glow); }
}
@keyframes legal-toc-num {
  0%, 100% { color: var(--gold-2); opacity: 1; }
}

.legal-article { max-width: 72ch; min-width: 0; }
.legal-section {
  padding-block: clamp(30px, 3.4vw, 44px);
  border-block-start: 1px solid var(--line);
  scroll-margin-block-start: calc(var(--header-h) + 28px);
}
.legal-section:first-child { padding-block-start: 0; border-block-start: 0; }
.legal-section__title {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-block-end: 18px;
  font-size: clamp(22px, 2.2vw, 29px);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
}
.legal-section__num { flex-shrink: 0; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em; color: var(--gold-2); }
.legal-section:target .legal-section__title { color: var(--gold-3); }
.legal-prose { display: flex; flex-direction: column; gap: 14px; font-size: 16.5px; line-height: 1.75; color: var(--text-2); }
.legal-prose ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.legal-prose li { position: relative; padding-inline-start: 24px; }
.legal-prose li::before {
  content: "";
  position: absolute;
  inset-inline-start: 4px;
  inset-block-start: 0.85em;
  width: 8px;
  height: 1px;
  background: var(--gold-2);
}
.legal-prose a { color: var(--text); text-decoration: underline; text-decoration-color: rgba(255, 201, 90, 0.5); text-underline-offset: 3px; }
.legal-prose a:hover { color: var(--gold-2); }
.legal-prose strong { font-weight: 500; }

.legal-questions {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px 32px;
  margin-block-start: clamp(36px, 5vw, 64px);
  padding: clamp(24px, 3vw, 38px);
  border-radius: var(--radius-l);
  border: 1px solid var(--glass-border);
  background:
    radial-gradient(80% 120% at 100% 0%, rgba(31, 111, 209, 0.2), transparent 60%),
    linear-gradient(180deg, rgba(207, 226, 255, 0.05), rgba(207, 226, 255, 0.015)),
    var(--glass);
}
.legal-questions__text { display: flex; flex-direction: column; gap: 8px; max-width: 44ch; }
.legal-questions__title { font-size: var(--fs-h3); font-weight: 300; letter-spacing: -0.02em; color: var(--text); }
.legal-questions__up { rotate: -90deg; }
.legal-questions .btn:hover .legal-questions__up { transform: none; }

/* ---------- 404: latent space ---------- */
.nf {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  overflow: clip;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: calc(var(--header-h) + clamp(24px, 4vw, 48px)) clamp(48px, 6vw, 88px);
}
.nf__bg { position: absolute; inset: 0; z-index: -2; pointer-events: none; }
.nf__bg .grid-lines {
  -webkit-mask-image: radial-gradient(ellipse 60% 55% at 50% 38%, #000 10%, transparent 72%);
  mask-image: radial-gradient(ellipse 60% 55% at 50% 38%, #000 10%, transparent 72%);
}
.nf__glow--a { width: 56vw; height: 56vw; inset-block-start: -18vw; inset-inline-start: -10vw; opacity: 0.3; }
.nf__glow--b { width: 40vw; height: 40vw; inset-block-end: -16vw; inset-inline-end: -6vw; opacity: 0.22; }

.nf__stage {
  position: relative;
  z-index: 0;
  width: min(760px, 86vw);
  aspect-ratio: 1200 / 420;
  margin-inline: auto;
  margin-block-end: clamp(-36px, -2vw, -8px);
  pointer-events: none;
}
.nf__stage .nf__fx { inset: -18% -4%; }
.nf__dust {
  position: absolute;
  inset: -22% -6%;
  background-image:
    radial-gradient(1.6px 1.6px at 8% 22%, rgba(207, 226, 255, 0.85), transparent 60%),
    radial-gradient(1.2px 1.2px at 17% 71%, rgba(255, 201, 90, 0.8), transparent 60%),
    radial-gradient(1.4px 1.4px at 26% 12%, rgba(207, 226, 255, 0.6), transparent 60%),
    radial-gradient(1px 1px at 33% 58%, rgba(207, 226, 255, 0.7), transparent 60%),
    radial-gradient(1.8px 1.8px at 41% 86%, rgba(61, 139, 255, 0.9), transparent 60%),
    radial-gradient(1.2px 1.2px at 49% 8%, rgba(255, 201, 90, 0.7), transparent 60%),
    radial-gradient(1.4px 1.4px at 57% 44%, rgba(207, 226, 255, 0.6), transparent 60%),
    radial-gradient(1px 1px at 64% 77%, rgba(207, 226, 255, 0.8), transparent 60%),
    radial-gradient(1.6px 1.6px at 72% 18%, rgba(61, 139, 255, 0.85), transparent 60%),
    radial-gradient(1.2px 1.2px at 79% 62%, rgba(255, 201, 90, 0.75), transparent 60%),
    radial-gradient(1.4px 1.4px at 86% 34%, rgba(207, 226, 255, 0.7), transparent 60%),
    radial-gradient(1px 1px at 93% 81%, rgba(207, 226, 255, 0.6), transparent 60%),
    radial-gradient(1.3px 1.3px at 4% 52%, rgba(61, 139, 255, 0.7), transparent 60%),
    radial-gradient(1.1px 1.1px at 96% 10%, rgba(255, 201, 90, 0.6), transparent 60%);
  -webkit-mask-image: radial-gradient(ellipse 60% 60% at 50% 50%, #000 20%, transparent 80%);
  mask-image: radial-gradient(ellipse 60% 60% at 50% 50%, #000 20%, transparent 80%);
  animation: nf-twinkle 6s var(--ease-in-out) infinite;
  transition: opacity 1.2s var(--ease-out);
}
.nf__stage:has(.fx.is-live) .nf__dust { opacity: 0.35; }
.nf__code { position: relative; display: block; width: 100%; height: auto; overflow: visible; }

.nf__echo--1 { fill: none; stroke: var(--blue-2); stroke-opacity: 0.22; stroke-width: 1; }
.nf__echo--2 { fill: none; stroke: var(--gold-2); stroke-opacity: 0.16; stroke-width: 1; }
.nf__glyphs { fill: url(#nf-fill); stroke: url(#nf-stroke); stroke-width: 1.3; }
.nf__mask-glyphs { fill: white; fill-opacity: 0.28; stroke: white; stroke-width: 1.5; }
.nf__stop--fill-a { stop-color: var(--ice-2); stop-opacity: 0.13; }
.nf__stop--fill-b { stop-color: var(--blue-2); stop-opacity: 0.05; }
.nf__stop--fill-c { stop-color: var(--blue-2); stop-opacity: 0; }
.nf__stop--stroke-a { stop-color: var(--ice); stop-opacity: 0.75; }
.nf__stop--stroke-b { stop-color: var(--blue-2); stop-opacity: 0.55; }
.nf__stop--stroke-c { stop-color: var(--gold-2); stop-opacity: 0.8; }
.nf__stop--stroke-d { stop-color: var(--gold); stop-opacity: 0.35; }
.nf__stop--clear { stop-color: var(--ice-2); stop-opacity: 0; }
.nf__stop--shine { stop-color: var(--ice-2); stop-opacity: 0.85; }
.nf__stop--warm { stop-color: var(--gold-3); stop-opacity: 0.5; }
.nf__echo--1 { animation: nf-drift-a 10s var(--ease-in-out) infinite; }
.nf__echo--2 { animation: nf-drift-b 13s var(--ease-in-out) infinite; }
.nf__sheen { animation: nf-sheen 7.5s var(--ease-in-out) infinite; }

.nf__inner { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.nf__eyebrow {
  justify-content: center;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 201, 90, 0.22);
  background: rgba(3, 6, 13, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.nf__title { max-width: 17ch; font-size: clamp(36px, 4.7vw, 70px); }
.nf__lead { max-width: 50ch; margin-inline: auto; }
.nf__path {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding-block: 5px;
  padding-inline: 14px 5px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.nf__path-value {
  overflow: hidden;
  max-width: min(52ch, 60vw);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(207, 226, 255, 0.07);
  color: var(--ice);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nf__nav { width: 100%; margin-block-start: clamp(12px, 2vw, 28px); }
.nf__nav-title { margin-block-end: 14px; font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.1em; color: var(--text-3); }
.nf__links { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; text-align: start; }
.nf__links > li { display: flex; min-width: 0; }
.nf-link {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding-block: 14px;
  padding-inline: 14px 16px;
  border-radius: var(--radius-m);
  border: 1px solid var(--glass-border);
  background: linear-gradient(180deg, rgba(207, 226, 255, 0.06), rgba(207, 226, 255, 0.015)), rgba(6, 12, 24, 0.5);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition: border-color var(--dur) var(--ease-out), translate var(--dur-slow) var(--ease-out);
}
.nf-link:hover { border-color: rgba(255, 201, 90, 0.36); translate: 0 -3px; }
.nf-link__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 201, 90, 0.24);
  background: linear-gradient(180deg, rgba(240, 169, 30, 0.15), rgba(240, 169, 30, 0.03));
  color: var(--gold-2);
}
.nf-link__icon .icon { width: 19px; height: 19px; }
.nf-link__body { display: flex; flex-direction: column; min-width: 0; }
.nf-link__title { font-size: 15.5px; font-weight: 500; color: var(--text); }
.nf-link__desc { font-size: 13px; line-height: 1.4; color: var(--text-3); }
.nf-link__arrow { width: 17px; height: 17px; color: var(--text-3); transition: color var(--dur); }
.nf-link:hover .nf-link__arrow { color: var(--gold-2); }

@keyframes nf-sheen { 0% { transform: translateX(0); } 62%, 100% { transform: translateX(2400px); } }
@keyframes nf-drift-a { 0%, 100% { transform: translate(-16px, 10px); } 50% { transform: translate(12px, -8px); } }
@keyframes nf-drift-b { 0%, 100% { transform: translate(18px, -12px); } 50% { transform: translate(-10px, 9px); } }
@keyframes nf-twinkle { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ---------- Responsive ---------- */
@media (max-width: 1040px) {
  .legal-layout { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .legal-toc { display: none; }
  .legal-toc-mobile {
    display: block;
    border-radius: var(--radius-m);
    border: 1px solid var(--glass-border);
    background: rgba(207, 226, 255, 0.035);
  }
  .legal-toc-mobile__summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-2);
  }
  .legal-toc-mobile__summary::-webkit-details-marker { display: none; }
  .legal-toc-mobile__summary .icon { width: 18px; height: 18px; transition: rotate var(--dur) var(--ease-out); }
  .legal-toc-mobile[open] .legal-toc-mobile__summary .icon { rotate: 180deg; }
  .legal-toc-mobile .legal-toc__list { margin: 0 18px 16px; }
  .legal-toc-mobile, .legal-article { width: 100%; max-width: 72ch; }

  .nf__links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .legal-hero { padding-block-start: calc(var(--header-h) + 40px); }
  .legal-hero__watermark { font-size: 68vw; inset-block-start: 38%; }
  .legal-prose { font-size: 16px; }
  .legal-section__title { gap: 12px; }
  .legal-questions__actions { width: 100%; }

  .nf { justify-content: flex-start; }
  .nf__stage { width: 108vw; margin-inline-start: -4vw; margin-block-end: -4px; }
  .nf__links { grid-template-columns: minmax(0, 1fr); }
  .nf__path-value { max-width: 52vw; }
}

@media (prefers-reduced-motion: reduce) {
  .nf__echo--1, .nf__echo--2, .nf__sheen, .nf__dust { animation: none; }
  .nf-link:hover { translate: none; }
}
.legal-hero__operator { margin-block-start: 14px; font-size: 14px; color: var(--text-3); }
