/* Codex Alliance — two screens: film + glass cards. Apple system fonts, no CDNs. */
:root {
  --ink: #0a121c;
  --ink-soft: #1a2736;
  --muted: #6a7a8c;
  --muted-2: #8a98a8;
  --line: rgba(20, 48, 72, .08);
  --paper: #fff;
  --accent: #0050D7;
  --cyan: #3ec8e8;
  --cyan-deep: #1aa8cc;
  --violet: #7b6cff;
  /* one glass recipe, shared by every surface (mirrors the app's glass cards) */
  --glass-bg: linear-gradient(160deg, rgba(255,255,255,.74), rgba(255,255,255,.46));
  --glass-border: 1px solid rgba(255,255,255,.82);
  --glass-blur: blur(24px) saturate(170%);
  --glass-shadow: inset 0 1px 0 rgba(255,255,255,.92), 0 24px 60px rgba(24,60,96,.10), 0 2px 6px rgba(24,60,96,.04);
  --radius-card: 28px;
  --radius-inner: 18px;
  --header-h: 64px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  letter-spacing: -.01em;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
img, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, select { font: inherit; }
.shell { width: min(1140px, calc(100% - 48px)); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link {
  position: fixed; left: 16px; top: -100px; z-index: 999;
  padding: 12px 18px; border-radius: 999px; background: var(--ink); color: #fff;
}
.skip-link:focus { top: 12px; }

/* Ambient mist */
.mist { display: none; }
.mist-a { width: 520px; height: 520px; left: -180px; top: 120px; background: radial-gradient(circle, rgba(62,200,232,.22), transparent 70%); animation: drift 28s ease-in-out infinite alternate; }
.mist-b { width: 460px; height: 460px; right: -140px; top: 40%; background: radial-gradient(circle, rgba(123,108,255,.18), transparent 70%); animation: drift 34s ease-in-out infinite alternate-reverse; }
.mist-c { width: 380px; height: 380px; left: 40%; bottom: -80px; background: radial-gradient(circle, rgba(232,160,208,.14), transparent 70%); animation: drift 40s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translate(0,0) scale(1); } to { transform: translate(40px,-30px) scale(1.08); } }

/* Header */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  padding-top: env(safe-area-inset-top);
  background: #fff;
  border-bottom: 1px solid var(--line);
  overflow: visible;
}
.nav { height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: 16px; overflow: visible; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; letter-spacing: -.02em; flex-shrink: 0; }
.brand-name { white-space: nowrap; }
.brand strong { font-weight: 700; }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.lang-wrap { display: flex; }
.lang-select {
  appearance: none; -webkit-appearance: none;
  border: var(--glass-border); background-color: rgba(255,255,255,.6);
  border-radius: 999px; padding: 8px 28px 8px 13px;
  font-size: 12px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%236a7a8c' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  max-width: 180px; box-shadow: 0 4px 14px rgba(24,60,96,.05);
}
.x-link {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 999px;
  background: var(--ink); color: #fff;
  font-size: 13px; font-weight: 650;
  box-shadow: 0 10px 28px rgba(10,18,28,.16);
  transition: transform .2s, box-shadow .2s;
}
.x-link:hover { transform: translateY(-1px); box-shadow: 0 14px 32px rgba(10,18,28,.22); }
.x-link svg { width: 14px; height: 14px; fill: currentColor; flex-shrink: 0; }
.soon-pill svg { width: 18px; height: 18px; fill: #fff; flex-shrink: 0; }

.kicker { margin: 0 0 10px; font-size: 11px; letter-spacing: .22em; font-weight: 700; color: var(--muted); text-transform: uppercase; }

/* ===== Screen 1 · Film ===== */
main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.home-film {
  position: relative; z-index: 1;
  flex: 1;
  min-height: 0;
  padding: calc(var(--header-h) + env(safe-area-inset-top) + 16px) 0 16px;
  display: flex; align-items: center;
}
.film-stage {
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 4vw, 48px);
}
.film-visual { display: flex; justify-content: center; flex-shrink: 0; }
.film-copy { display: flex; flex-direction: column; align-items: flex-start; }
/* Hero mascot — living sticker of the Codex cloud icon */
.mascot {
  --mascot-size: min(166px, 12.9vw, calc((100dvh - 280px) * 0.92));
  width: var(--mascot-size);
  height: var(--mascot-size);
  margin: 0 auto;
  color: #0b1220;
  filter: drop-shadow(0 8px 16px rgba(15, 25, 45, .10));
  animation: mascot-float 2.8s ease-in-out infinite;
}
.mascot-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.mascot-body {
  transform-origin: 646px 659px;
  animation: mascot-spin 8s cubic-bezier(.45, .02, .2, 1) infinite;
}
.mascot-face { transform-origin: 646px 680px; }
.mascot-eye {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: mascot-eye 8s ease-in-out infinite;
}
.mascot-mouth {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: mascot-mouth 8s ease-in-out infinite;
}
@keyframes mascot-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes mascot-spin {
  0%   { transform: rotate(0deg) scale(1, 1); }
  8%   { transform: rotate(-22deg) scale(1.08, 0.9); }
  16%  { transform: rotate(20deg) scale(0.9, 1.1); }
  24%  { transform: rotate(-10deg) scale(1.04, 0.96); }
  32%  { transform: rotate(8deg) scale(1, 1); }
  40%  { transform: rotate(0deg) scale(1.12, 1.12); }
  46%  { transform: rotate(0deg) scale(1, 1); }
  58%  { transform: rotate(0deg) scale(1, 1); }
  78%  { transform: rotate(360deg) scale(1, 1); }
  84%  { transform: rotate(378deg) scale(1.1, 0.88); }
  90%  { transform: rotate(352deg) scale(0.94, 1.08); }
  100% { transform: rotate(360deg) scale(1, 1); }
}
@keyframes mascot-eye {
  0%, 7% { transform: scale(1, 1) translate(0, 0) rotate(0deg); }
  9%, 11% { transform: scale(1, 0.08) translate(0, 0) rotate(0deg); }
  13% { transform: scale(1, 1) translate(0, 0) rotate(0deg); }
  22% { transform: scale(1, 1) translate(-55px, 18px) rotate(-16deg); }
  34% { transform: scale(1, 1) translate(60px, 8px) rotate(14deg); }
  40%, 42% { transform: scale(1, 0.08) translate(0, 0) rotate(0deg); }
  44% { transform: scale(1, 1) translate(0, 0) rotate(0deg); }
  52% { transform: scale(1.2, 0.75) rotate(-12deg); }
  60% { transform: scale(1, 1) rotate(0deg); }
  70% { transform: scale(1.15, 0.85) rotate(8deg); }
  78% { transform: scale(1.25, 0.7) rotate(18deg); }
  88%, 100% { transform: scale(1, 1) translate(0, 0) rotate(0deg); }
}
@keyframes mascot-mouth {
  0%, 6% { transform: scale(1, 1) rotate(0deg); }
  10% { transform: scale(0.62, 2.4) rotate(0deg); }
  16% { transform: scale(1.2, 0.65) rotate(-6deg); }
  22% { transform: scale(0.72, 2.8) rotate(0deg); }
  28% { transform: scale(1, 1) rotate(0deg); }
  36% { transform: scale(1.15, 0.55) rotate(10deg); }
  44% { transform: scale(0.55, 3.1) rotate(0deg); }
  52% { transform: scale(1.05, 1) rotate(-8deg); }
  60% { transform: scale(0.8, 2.2) rotate(0deg); }
  68% { transform: scale(1.25, 0.5) rotate(0deg); }
  76% { transform: scale(0.7, 2.6) rotate(0deg); }
  86%, 100% { transform: scale(1, 1) rotate(0deg); }
}

.film-copy { max-width: 100%; margin-inline: auto; }
.film-copy h1 { margin: 0; }
.film-copy .title-visual {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: max-content;
  max-width: 100%;
}
.film-copy .title-lead {
  display: block;
  font-size: clamp(26px, 3.5vw, 48px);
  font-weight: 800;
  letter-spacing: -.035em;
  line-height: 1;
  color: #000;
  white-space: nowrap;
}
.film-copy .title-community {
  display: block;
  margin-top: .19em;
  font-size: clamp(46px, 6.84vw, 91px);
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: .9;
  color: #0050D7;
  white-space: nowrap;
}
.film-subtitle {
  margin: 16px 0 28px; font-size: 17px; line-height: 1.45;
  color: #6b7280; letter-spacing: -.01em;
}
.brand-desc {
  margin: 16px 0 0;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -.01em;
  line-height: 1.4;
  color: #6a7c94;
}
.soon-pill {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 22px 0 0; padding: 10px 18px 10px 14px;
  border-radius: 14px;
  background: #000; border: 0; box-shadow: none;
  -webkit-backdrop-filter: none; backdrop-filter: none;
  font-size: 13px; font-weight: 600; letter-spacing: -.01em;
  color: #fff; line-height: 1.15;
  transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.soon-pill:hover {
  transform: translateY(-1px);
  background: #161616;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .18);
}
.soon-pill svg { display: block; width: 18px; height: 18px; fill: #fff; flex-shrink: 0; }
/* legacy unused */
.soon-dot { display: none; }

/* Footer */
.footer { position: relative; z-index: 1; flex-shrink: 0; padding: 16px 0 calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff; }
.footer-inner { display: grid; grid-template-columns: 1fr auto; gap: 12px 28px; align-items: center; }
.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-brand img { border-radius: 7px; }
.footer-brand strong { display: block; font-size: 14px; }
.footer-brand span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.footer-links { display: flex; gap: 18px; font-size: 13px; color: var(--muted); }
.footer-links a:hover { color: var(--ink); }
.footer-inner small { grid-column: 1 / -1; color: var(--muted-2); font-size: 11px; }

.reveal { opacity: 0; transform: translateY(16px); transition: opacity .8s ease, transform .8s cubic-bezier(.2,.8,.2,1); }
.reveal.is-visible { opacity: 1; transform: none; }

/* RTL */
html[dir="rtl"] .footer-links { flex-direction: row-reverse; }
html[dir="rtl"] .lang-select { background-position: left 12px center; padding: 8px 13px 8px 28px; }

/* Tablet */
@media (max-width: 960px) {
  .home-film { min-height: 0; padding-bottom: 12px; }
  .film-stage { flex-direction: column; gap: 16px; text-align: center; }
  .film-copy { align-items: center; margin-inline: auto; }
  .mascot { --mascot-size: min(129px, 21.2vw, calc((100dvh - 380px) * 0.92)); }
}
/* Phone */
@media (max-width: 640px) {
  :root { --header-h: 58px; --radius-card: 24px; --radius-inner: 15px; }
  .shell { width: min(100% - 28px, 1140px); }
  .brand-name { font-size: 15px; }
  .lang-select { max-width: 132px; font-size: 11px; }
  .x-link { padding: 9px 12px; }
  .x-link span { display: none; }
  .home-film { padding-top: calc(var(--header-h) + env(safe-area-inset-top) + 10px); padding-bottom: 8px; }
  .mascot { --mascot-size: min(110px, 26.7vw, calc((100dvh - 420px) * 0.92)); }
  .film-stage { gap: 12px; }
  .soon-pill { margin-top: 18px; }
  .film-copy .title-lead { font-size: clamp(22px, 6.4vw, 28px); }
  .footer { padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); }
  .footer-inner { grid-template-columns: 1fr; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .mist, .mascot, .mascot-body, .mascot-eye, .mascot-mouth { animation: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .x-link { transition: none; }
  .soon-pill { transition: none; }
  .soon-pill:hover { transform: none; box-shadow: none; }
}

/* Legal / support pages */
.legal-main {
  position: relative; z-index: 1;
  padding: calc(var(--header-h) + 36px) 0 48px;
}
.legal-card {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(28px, 4vw, 40px);
  border-radius: var(--radius-card);
  background: var(--glass-bg);
  border: var(--glass-border);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
}
.legal-card h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 3.2vw, 36px);
  letter-spacing: -.03em;
  font-weight: 750;
}
.legal-meta {
  margin: 0 0 28px;
  font-size: 13px;
  color: var(--muted);
}
.legal-card h2 {
  margin: 28px 0 10px;
  font-size: 17px;
  letter-spacing: -.02em;
  font-weight: 700;
}
.legal-card p, .legal-card li {
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.legal-card p { margin: 0 0 12px; }
.legal-card ul { margin: 0 0 12px; padding-left: 1.2em; }
.legal-card li { margin: 0 0 6px; }
.legal-card a { color: var(--cyan-deep); text-decoration: underline; text-underline-offset: 3px; }
.legal-card a:hover { color: var(--ink); }
