/* Shared stylesheet for static legal pages (terms, privacy).
   Matches the React app's monochrome liquid-glass design.

   These pages are served straight off Firebase Hosting — they are outside the
   Vite graph entirely, so nothing here is bundled, hashed, or tree-shaken. They
   are also real pages real users open on a phone from the footer, so they get
   the same mobile-GPU budget as the SPA. */

/* ── Fonts ───────────────────────────────────────────────────────────────────
   Self-hosted, same origin, one file. The pages previously pulled Inter from
   fonts.googleapis.com as four discrete static weights (400/500/600/700,
   ~100 kB) behind a render-blocking cross-origin stylesheet. One 48 kB variable
   latin file covers the whole 100–900 range these pages use, over a connection
   the browser already has open.

   No hash in the filename, but firebase.json already has a glob rule that
   serves every .woff2 immutably, and the file only ever changes if the
   typeface itself does. */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  /* format('woff2') — NOT the 'woff2-variations' token fontsource ships. That
     token was dropped from the spec; a UA that does not special-case it must
     skip the whole src entry, which would silently fall back to Arial forever. */
  src: url('/fonts/inter-latin.woff2') format('woff2');
}

/* Metric-matched fallback, identical to the one in src/index.css. With plain
   `font-display: swap` the first paint uses Arial, then reflows the entire
   document when Inter arrives — on a long legal page that is a full-height
   jolt, and the kind of thing that reads as "laggy" even when the frame rate
   is fine. Overriding the fallback's metrics to Inter's makes the swap
   geometrically invisible: same advance widths, same line boxes, zero reflow. */
@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial');
  size-adjust: 107.12%;
  ascent-override: 90.2%;
  descent-override: 22.48%;
  line-gap-override: 0%;
}

:root {
  --color-bg: #FAFAFB;
  --color-surface: #FFFFFF;
  --color-surface-2: #F4F4F5;
  --color-border: #E4E4E7;

  --color-text: #09090B;
  --color-text-muted: #3F3F46;
  --color-text-subtle: #71717A;

  --gradient-brand: linear-gradient(135deg, #2563EB 0%, #4F46E5 50%, #06B6D4 100%);

  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-soft: 0 20px 60px -20px rgba(0, 0, 0, 0.28);

  --glass-bg: rgba(255, 255, 255, 0.45);
  --glass-border: rgba(255, 255, 255, 0.55);

  --glass-shadow:
    0 30px 80px -20px rgba(0, 0, 0, 0.28),
    inset 0 1.5px 0 rgba(255, 255, 255, 1),
    inset 3px 0 6px -3px rgba(255, 255, 255, 0.45),
    inset -3px 0 6px -3px rgba(255, 255, 255, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Inter Variable", "Inter Fallback", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  line-height: 1.65;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
  font-feature-settings: "cv11", "ss01", "ss03";
}

/* ---------- Background layers ---------- */

.bg-layers {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.bg-layers::after {
  /* noise */
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 220px 220px;
}

/* Aurora orbs — STATIC soft glows. All three previously ran `infinite`
   ease-in-out drift keyframes (22s / 26s / 18s). An infinite transform
   animation never lets the compositor go idle: the GPU wakes and recomposites
   three 50–55vw layers at the display's full refresh rate — 60fps, 120fps on a
   modern phone panel — for the entire time the document is open, whether the
   reader is scrolling or has left the tab parked while they read clause 07.
   That is continuous battery and heat for a motion nobody looks at behind a
   wall of body text. The same cost was removed from the SPA in e936dc4 /
   331946e / 063b15e; .cta-orb there got exactly this treatment.

   The blurred radial gradients read as the same soft ambient wash standing
   still, so they are now painted once and never touched again.
   `will-change: transform` goes with them: with nothing animating it only
   pinned three large blurred textures into GPU memory permanently, which is
   real VRAM pressure on a low-end phone and buys nothing. */
.aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
}

.aurora-1 {
  top: -10vh;
  left: -10vw;
  width: 55vw;
  height: 55vw;
  background: radial-gradient(circle, rgba(9, 9, 11, 0.14), transparent 60%);
}

.aurora-2 {
  top: 10vh;
  left: 55vw;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, rgba(63, 63, 70, 0.11), transparent 60%);
}

.aurora-3 {
  top: 60vh;
  left: 20vw;
  width: 55vw;
  height: 55vw;
  background: radial-gradient(circle, rgba(113, 113, 122, 0.1), transparent 60%);
}

/* ---------- Scroll progress bar ---------- */

.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-brand);
  transform-origin: left;
  transform: scaleX(0);
  z-index: 50;
  transition: transform 0.15s linear;
}

/* ---------- Navbar ---------- */

.navbar {
  position: sticky;
  top: 20px;
  z-index: 40;
  margin: 20px auto 0;
  max-width: 1100px;
  padding: 0 16px;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 10px 20px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(22px) saturate(200%) brightness(1.05);
  -webkit-backdrop-filter: blur(22px) saturate(200%) brightness(1.05);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow:
    0 18px 50px -15px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 0 0 1px rgba(255, 255, 255, 0.32);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-text);
}

.logo-chip {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--gradient-brand);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.logo-text {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  text-decoration: none;
  border-radius: 9999px;
  background: var(--gradient-brand);
  box-shadow:
    0 12px 28px -10px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  transition: transform 0.2s ease;
}

.back-link:hover {
  transform: translateY(-1px);
}

.back-link:active {
  transform: scale(0.98);
}

.back-link svg {
  width: 14px;
  height: 14px;
  transition: transform 0.3s ease;
}

.back-link:hover svg {
  transform: translateX(-2px);
}

/* ---------- Hero ---------- */

.hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 80px 16px 40px;
  text-align: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 9999px;
  backdrop-filter: blur(12px) saturate(180%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gradient-brand);
}

.hero h1 {
  margin-top: 24px;
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.02;
  color: var(--color-text);
}

.hero .grad {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero .subtitle {
  max-width: 620px;
  margin: 20px auto 0;
  color: var(--color-text-muted);
  font-size: 1.125rem;
  line-height: 1.55;
}

.hero-meta {
  margin-top: 28px;
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--color-text-muted);
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 9999px;
  backdrop-filter: blur(12px) saturate(180%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.meta-chip svg {
  width: 14px;
  height: 14px;
  color: var(--color-text);
}

.meta-chip strong {
  color: var(--color-text);
  font-weight: 600;
}

/* ---------- Layout ---------- */

.layout {
  position: relative;
  max-width: 1100px;
  margin: 40px auto 0;
  padding: 0 16px 80px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
}

@media (min-width: 960px) {
  .layout {
    grid-template-columns: 240px 1fr;
    gap: 56px;
  }
}

/* ---------- Table of contents (sidebar) ---------- */

.toc {
  display: none;
}

@media (min-width: 960px) {
  .toc {
    display: block;
    position: sticky;
    top: 110px;
    align-self: start;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
  }
}

.toc-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
  padding: 0 14px 12px;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--color-text-muted);
  text-decoration: none;
  border-radius: 10px;
  transition: color 0.2s ease, background 0.2s ease;
  line-height: 1.3;
}

.toc-link::before {
  content: attr(data-num);
  display: inline-block;
  width: 24px;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--color-text-subtle);
  transition: color 0.2s ease;
}

.toc-link:hover {
  color: var(--color-text);
  background: rgba(0, 0, 0, 0.04);
}

.toc-link.active {
  color: var(--color-text);
  background: rgba(0, 0, 0, 0.05);
  font-weight: 600;
}

.toc-link.active::before {
  color: var(--color-text);
}

/* ---------- Content sections ---------- */

.content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.intro {
  padding: 28px 32px;
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(200%) brightness(1.05);
  -webkit-backdrop-filter: blur(22px) saturate(200%) brightness(1.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--glass-shadow);
  color: var(--color-text-muted);
  font-size: 15.5px;
}

.intro p + p {
  margin-top: 12px;
}

.section {
  position: relative;
  padding: 36px 36px 32px;
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(200%) brightness(1.05);
  -webkit-backdrop-filter: blur(22px) saturate(200%) brightness(1.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--glass-shadow);
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.7s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.section.in-view {
  opacity: 1;
  transform: translateY(0);
}

.section-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: white;
  border-radius: 12px;
  background: var(--gradient-brand);
  box-shadow:
    0 10px 24px -10px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.section h2 {
  font-size: clamp(1.25rem, 2.8vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--color-text);
}

.section p {
  margin-bottom: 14px;
  color: var(--color-text-muted);
  font-size: 15.5px;
}

.section p:last-child {
  margin-bottom: 0;
}

.section ul {
  margin: 12px 0 18px;
  padding-left: 24px;
  list-style: none;
}

.section ul li {
  position: relative;
  margin-bottom: 8px;
  color: var(--color-text-muted);
  font-size: 15.5px;
  padding-left: 4px;
}

.section ul li::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 0.65em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gradient-brand);
}

.section strong {
  color: var(--color-text);
  font-weight: 600;
}

.section a {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(9, 9, 11, 0.35);
  transition: text-decoration-color 0.2s ease;
}

.section a:hover {
  text-decoration-color: rgba(9, 9, 11, 1);
}

/* ---------- Contact card ---------- */

.contact-card {
  position: relative;
  margin-top: 24px;
  padding: 44px 40px;
  text-align: center;
  border-radius: var(--radius-xl);
  background: var(--gradient-brand);
  color: white;
  overflow: hidden;
  box-shadow:
    0 30px 80px -20px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.7s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.contact-card.in-view {
  opacity: 1;
  transform: translateY(0);
}

.contact-card::before {
  /* Top inner light line */
  content: "";
  position: absolute;
  top: 0;
  left: 40px;
  right: 40px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
}

.contact-card::after {
  /* Soft radial glow */
  content: "";
  position: absolute;
  top: -60%;
  left: 50%;
  width: 80%;
  height: 160%;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.12), transparent 70%);
  pointer-events: none;
}

.contact-card h3 {
  position: relative;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.contact-card p {
  position: relative;
  color: rgba(255, 255, 255, 0.75);
  font-size: 15px;
  max-width: 440px;
  margin: 0 auto 24px;
}

/* The email link. `.section a` only reaches anchors inside the article body, so
   the one in here fell through to the UA's default link blue — #0000EE on a
   blue gradient card, which is both ugly and close to unreadable. White with a
   translucent underline matches the card's own text treatment and lands well
   clear of the contrast floor against every stop in the gradient. */
.contact-card a {
  color: #fff;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(255, 255, 255, 0.5);
  transition: text-decoration-color 0.2s ease;
}

.contact-card a:hover {
  text-decoration-color: rgba(255, 255, 255, 1);
}

.contact-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
  background: white;
  border-radius: 9999px;
  box-shadow:
    0 10px 24px -10px rgba(0, 0, 0, 0.5),
    inset 0 -1px 0 rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease;
}

.contact-btn:hover {
  transform: translateY(-1px);
}

.contact-btn:active {
  transform: scale(0.98);
}

.contact-btn svg {
  width: 16px;
  height: 16px;
}

/* ---------- Back-to-top button ---------- */

.to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--gradient-brand);
  color: white;
  border: none;
  border-radius: 50%;
  box-shadow:
    0 14px 32px -10px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px) scale(0.9);
  pointer-events: none;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

.to-top.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.to-top:hover {
  transform: translateY(-2px) scale(1.03);
}

.to-top svg {
  width: 18px;
  height: 18px;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .navbar {
    margin-top: 12px;
    padding: 0 12px;
  }

  .nav-inner {
    padding: 8px 8px 8px 16px;
  }

  .hero {
    padding: 60px 16px 32px;
  }

  .hero h1 {
    font-size: clamp(2.25rem, 10vw, 3rem);
  }

  .layout {
    margin-top: 24px;
    padding: 0 12px 56px;
  }

  .section {
    padding: 28px 22px 24px;
  }

  .section-head {
    gap: 12px;
  }

  .section-num {
    min-width: 40px;
    height: 40px;
  }

  .contact-card {
    padding: 32px 24px;
  }

  .back-link {
    padding: 8px 14px;
    font-size: 13px;
  }
}

/* ---------- Mobile: no backdrop-filter at all ---------- */

/* A live backdrop blur is the single most expensive thing a phone GPU can be
   asked to do per frame: for every frame the backdrop moves it re-samples the
   region behind the element, downsamples it, blurs it, and recomposites. On a
   scrolling document the backdrop moves on EVERY frame, and these pages stack
   the effect on one surface per section — so the cost scales with how much of
   the policy is on screen.

   Same fix as src/index.css: on coarse pointers drop backdrop-filter entirely
   and render "blur-free glass" instead — a static frosted rgba fill plus the
   borders and inset highlights the base rules already provide. The fill is
   opaque enough to stand in for the blurred backdrop, and at phone size and DPR
   it reads the same while costing the compositor nothing per frame. Tints match
   the SPA's coarse-pointer values so both look identical side by side. */
@media (pointer: coarse), (max-width: 767.98px) {
  .nav-inner,
  .eyebrow,
  .meta-chip,
  .intro,
  .section {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .nav-inner { background-color: rgba(255, 255, 255, 0.82); }
  .eyebrow { background-color: rgba(255, 255, 255, 0.85); }
  .meta-chip { background-color: rgba(255, 255, 255, 0.8); }
  .intro,
  .section { background-color: rgba(255, 255, 255, 0.72); }

  /* Large decorative filter: blur() is GPU-heavy to rasterize too — a 110px
     blur over a 55vw box is a big texture on a phone. The aurora orbs are
     radial gradients that already fade to transparent by 60%, so dropping the
     blur keeps essentially the same soft glow for free. Mirrors .cta-orb. */
  .aurora {
    filter: none;
  }
}

/* ── Suspend backdrop blur while scrolling (the desktop smoothness fix) ──────
   The coarse-pointer block above solves this for phones. Desktop still had 27
   `.section` panels, plus the nav, eyebrow, meta chips and intro, each holding
   a live `backdrop-filter: blur(22px) saturate(200%)`. backdrop-filter re-reads
   and re-blurs everything behind the element on EVERY frame its backdrop moves
   — and while the page scrolls, the backdrop is the whole viewport, moving at
   up to 120 fps. Behind these panels sits a `filter: blur(110px)` aurora, so
   each panel is re-blurring an already-expensive layer. That is what made this
   page feel like it was dragging even on a fast machine.

   So while the page is actually moving, swap every blurred surface to the flat
   frosted tint the coarse-pointer path already uses, with no filter at all;
   legal.js toggles `.is-scrolling` on <html>. The tints are the ones tuned to
   match each surface's blurred brightness, so a mid-scroll glimpse still reads
   as frosted glass — and the eye cannot resolve a 22px blur on a moving
   surface anyway. The instant scrolling stops, the real blur returns and every
   panel is pixel-identical to before. Entry is instant (transition: none) to
   avoid a flash of clear content at the start of a gesture. */
html.is-scrolling .nav-inner,
html.is-scrolling .eyebrow,
html.is-scrolling .meta-chip,
html.is-scrolling .intro,
html.is-scrolling .section {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: none;
}

html.is-scrolling .nav-inner { background-color: rgba(255, 255, 255, 0.82); }
html.is-scrolling .eyebrow { background-color: rgba(255, 255, 255, 0.85); }
html.is-scrolling .meta-chip { background-color: rgba(255, 255, 255, 0.8); }
html.is-scrolling .intro,
html.is-scrolling .section { background-color: rgba(255, 255, 255, 0.72); }

@media (prefers-reduced-motion: reduce) {
  .section, .contact-card {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  html { scroll-behavior: auto; }
}

/* Document title inside the intro card — "ChatOne Privacy Policy" /
   "ChatOne Terms and Conditions". The flat pages this replaced opened with
   exactly this heading, naming the app before the first clause; the redesign
   had dropped it, which left the documents never stating which app they govern
   anywhere in the body. Sized below the page's own <h1> so it reads as the
   document's formal title rather than competing with it. */
.intro-title {
  margin: 0 0 14px;
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--color-text);
}
