/**
 * Legal docs — Neural Noir (aligned with auth gate).
 * Fonts: load via <link> in legal/document.html (avoid CSS @import render-block).
 */

html.i18n-switching body {
  visibility: hidden;
}

.legal-page {
  --legal-bg: #0b1220;
  --legal-panel: #1b2436;
  --legal-text: #e8edf5;
  --legal-muted: #93a0b5;
  --legal-accent: #b8956c;
  --legal-border: rgba(255, 255, 255, 0.08);
  margin: 0;
  min-height: 100vh;
  font-family: 'Manrope', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  color: var(--legal-text);
  background: var(--legal-bg);
  -webkit-font-smoothing: antialiased;
  position: relative;
  scrollbar-gutter: stable;
}

.legal-atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.legal-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 20%, #000 20%, transparent 75%);
}

.legal-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
}

.legal-glow--1 {
  top: -8%;
  left: 15%;
  width: 320px;
  height: 320px;
  background: rgba(59, 130, 246, 0.16);
}

.legal-glow--2 {
  bottom: 5%;
  right: 10%;
  width: 280px;
  height: 280px;
  background: rgba(184, 149, 108, 0.1);
}

.legal-main,
.legal-footer {
  position: relative;
  z-index: 1;
}

.legal-topbar {
  border-bottom: 1px solid var(--legal-border);
  background: rgba(11, 18, 32, 0.72);
  backdrop-filter: blur(12px);
  /* Above .legal-main — same z-index:1 let the doc card paint over the lang menu. */
  position: sticky;
  top: 0;
  z-index: 40;
}

.legal-topbar-inner {
  max-width: 840px;
  margin: 0 auto;
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Brand block: never shrink beside nav — avoids squashed Syne/Manrope metrics */
.legal-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  flex: 0 0 auto;
  flex-shrink: 0;
  min-width: min(100%, max-content);
  text-decoration: none;
  color: inherit;
}

.legal-brand-mark {
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.65rem;
  color: #7eb6ff;
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(126, 182, 255, 0.22);
}

.legal-brand-text {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  line-height: 1.25;
  min-width: 0;
}

.legal-brand-name {
  /* Manrope — Syne distorts Latin display copy (same as auth/pricing). */
  font-family: 'Manrope', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  white-space: normal;
}

.legal-brand-tagline {
  font-size: 0.72rem;
  color: var(--legal-muted);
}

.legal-topbar-nav {
  display: flex;
  flex-wrap: wrap;
  flex: 1 1 auto;
  justify-content: flex-end;
  gap: 0.65rem 1rem;
  align-items: center;
  min-width: 0;
}

.legal-topbar-nav a {
  color: var(--legal-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.legal-topbar-nav a:hover,
.legal-topbar-nav a.is-active {
  color: var(--legal-accent);
}

.legal-lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-inline-start: 0.15rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.45rem;
  background: rgba(30, 41, 59, 0.45);
  color: var(--legal-muted);
  font-size: 0.75rem;
  font-weight: 650;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.legal-lang-switch svg {
  width: 0.95rem;
  height: 0.95rem;
  pointer-events: none;
}

.legal-lang-switch:hover,
.legal-lang-switch[aria-expanded="true"] {
  border-color: rgba(184, 149, 108, 0.45);
  background: rgba(39, 48, 65, 0.92);
  color: #f1f5f9;
}

.legal-page .lang-switch-wrap--auth {
  position: relative;
  z-index: 50;
  display: inline-flex;
  align-items: center;
}

.legal-page .lang-switch-wrap--auth .lang-switch-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  inset-inline-end: 0;
  inset-inline-start: auto;
  bottom: auto;
  z-index: 60;
  direction: ltr;
  text-align: left;
  display: grid;
  grid-auto-flow: row;
  grid-auto-rows: minmax(2.35rem, max-content);
  align-content: start;
  gap: 0.15rem;
  width: 12.75rem;
  min-width: 12.75rem;
  max-width: min(14rem, calc(100vw - 1.5rem));
  max-height: min(18rem, 55vh);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.75rem;
  background: #273041;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
}

.legal-page .lang-switch-wrap--auth .lang-switch-menu[hidden],
.legal-page .lang-switch-wrap--auth .lang-switch-menu:not(.is-open) {
  display: none !important;
}

.legal-page .lang-switch-wrap--auth .lang-switch-menu-item {
  display: flex;
  align-items: center;
  justify-content: left;
  width: 100%;
  min-height: 2.35rem;
  padding: 0.55rem 0.85rem;
  border: 0;
  border-radius: 0.4rem;
  background: transparent;
  color: #e2e8f0;
  font-size: 0.8125rem;
  font-weight: 500;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.legal-page .lang-switch-wrap--auth .lang-switch-menu-item-label {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
}

.legal-page .lang-switch-wrap--auth .lang-switch-menu-item:hover,
.legal-page .lang-switch-wrap--auth .lang-switch-menu-item:focus-visible {
  background: rgba(255, 255, 255, 0.045);
  color: #fff;
  outline: none;
}

.legal-page .lang-switch-wrap--auth .lang-switch-menu-item[aria-selected="true"] {
  background: rgba(184, 149, 108, 0.07);
  color: #d4c0a5;
  font-weight: 600;
}

.legal-main {
  max-width: 840px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3.5rem;
}

.legal-doc {
  background: var(--legal-panel);
  border: 1px solid var(--legal-border);
  border-radius: 1.1rem;
  padding: 2rem 1.75rem 2.25rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

.legal-doc-eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--legal-accent);
  font-weight: 600;
}

.legal-doc-header {
  /* Content card header — separate from sticky topbar brand */
  min-width: 0;
}

.legal-doc-title {
  margin: 0;
  font-family: 'Manrope', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  font-weight: 800;
  font-size: clamp(1.6rem, 3vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: break-word;
  text-wrap: balance;
}

/* Latin locales (default EN on /legal/*) — extra guard against condensed metrics */
html.ui-script-latin .legal-page .legal-brand-name,
html.ui-script-latin .legal-page .legal-doc-title {
  font-family: 'Manrope', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  letter-spacing: -0.02em;
}

html.ui-script-latin .legal-page .legal-doc-title {
  line-height: 1.18;
  hyphens: auto;
}

.legal-doc-meta {
  margin: 0.65rem 0 0;
  color: var(--legal-muted);
  font-size: 0.9rem;
}

.legal-doc-lang-notice {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.85rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(184, 149, 108, 0.25);
  background: rgba(184, 149, 108, 0.08);
  color: var(--legal-accent);
  font-size: 0.875rem;
}

html[lang='zh-CN'] .legal-doc-lang-notice {
  display: none;
}

.legal-locale-en[hidden],
.legal-locale-zh[hidden] {
  display: none !important;
}

.legal-doc-body {
  margin-top: 1.75rem;
  font-size: 0.98rem;
  line-height: 1.75;
  color: #d5dce8;
}

.legal-doc-body h2 {
  margin: 1.75rem 0 0.7rem;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--legal-text);
}

.legal-doc-body p,
.legal-doc-body ul {
  margin: 0 0 0.85rem;
}

.legal-doc-body ul {
  padding-left: 1.25rem;
}

.legal-doc-body li {
  margin-bottom: 0.4rem;
}

.legal-doc-body strong {
  color: var(--legal-text);
  font-weight: 600;
}

.legal-footer {
  border-top: 1px solid var(--legal-border);
  padding: 1.25rem;
}

.legal-footer-inner {
  max-width: 840px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  justify-content: space-between;
  align-items: center;
  color: var(--legal-muted);
  font-size: 0.85rem;
}

.legal-footer-inner p {
  margin: 0;
}

.legal-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.legal-footer-links a {
  color: var(--legal-muted);
  text-decoration: none;
}

.legal-footer-links a:hover {
  color: var(--legal-accent);
}

@media (max-width: 640px) {
  .legal-topbar-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .legal-doc {
    padding: 1.4rem 1.1rem 1.75rem;
  }
}
