/* ═════════════════════════════════════════════════════════════════════
   PULSE — Shared Styles
   Dark/Light theme with CSS variables
   ═════════════════════════════════════════════════════════════════════ */

:root {
  /* Brand — Ion Cyan */
  --accent: #00D4C8;
  --accent-hover: #2DD4BF;
  --accent-secondary: #7FFFD4;
  --accent-fg: #0a0a0a;

  /* Dark theme (default) */
  --bg: #030306;
  --bg-elev: #0a0a0f;
  --bg-elev-2: #0f0f15;
  --bg-hover: #161620;
  --fg: #f5f5f5;
  --fg-dim: #888;
  --fg-dimmer: #555;
  --border: var(--on-fg-08);
  --border-strong: var(--on-fg-15);
  --card-bg: var(--on-fg-02);
  --card-bg-hover: var(--on-fg-04);
  --nav-bg: rgba(3, 3, 6, 0.7);
  --nav-bg-scrolled: rgba(3, 3, 6, 0.88);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  --grid-line: var(--on-fg-02);
  --glow: rgba(0, 212, 200, 0.1);

  /* Legacy aliases used by pricing.html / changelog.html inline styles.
   * These page-scoped stylesheets predate the shared token system and use
   * --white/--black/--grey/--dim. Aliasing keeps them theme-aware via the
   * single source of truth in shared.css. */
  --white: var(--fg);
  --black: var(--bg);
  --grey: var(--fg-dim);
  --dim: var(--fg-dimmer);

  /* Theme-aware opacity tokens. Many inline page styles previously hardcoded
   * `rgba(255,255,255,N)` which is invisible in light mode. These tokens give
   * us "fg color at N% strength" with light-mode equivalents that have slightly
   * higher contrast (dark ink on light background needs more coverage to
   * remain legible than light ink on dark). Use everywhere instead of raw rgba. */
  --on-fg-60: rgba(255, 255, 255, 0.60);
  --on-fg-55: rgba(255, 255, 255, 0.55);
  --on-fg-30: rgba(255, 255, 255, 0.30);
  --on-fg-20: rgba(255, 255, 255, 0.20);
  --on-fg-15: rgba(255, 255, 255, 0.15);
  --on-fg-10: rgba(255, 255, 255, 0.10);
  --on-fg-08: rgba(255, 255, 255, 0.08);
  --on-fg-06: rgba(255, 255, 255, 0.06);
  --on-fg-05: rgba(255, 255, 255, 0.05);
  --on-fg-04: rgba(255, 255, 255, 0.04);
  --on-fg-02: rgba(255, 255, 255, 0.02);
}

/* Light theme */
[data-theme="light"] {
  --bg: #f8f9fa;
  --bg-elev: #ffffff;
  --bg-elev-2: #f1f3f5;
  --bg-hover: #e9ecef;
  --fg: #0a0a0a;
  --fg-dim: #6c757d;
  --fg-dimmer: #adb5bd;
  --border: rgba(0, 0, 0, 0.10);
  --border-strong: rgba(0, 0, 0, 0.18);
  --card-bg: rgba(0, 0, 0, 0.02);
  --card-bg-hover: rgba(0, 0, 0, 0.04);
  --nav-bg: rgba(255, 255, 255, 0.85);
  --nav-bg-scrolled: rgba(255, 255, 255, 0.95);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
  --grid-line: rgba(0, 0, 0, 0.03);
  --glow: rgba(0, 212, 200, 0.14);

  /* Light-mode opacity overrides — higher contrast required for dark ink */
  --on-fg-60: rgba(0, 0, 0, 0.66);
  --on-fg-55: rgba(0, 0, 0, 0.62);
  --on-fg-30: rgba(0, 0, 0, 0.50);
  --on-fg-20: rgba(0, 0, 0, 0.40);
  --on-fg-15: rgba(0, 0, 0, 0.18);
  --on-fg-10: rgba(0, 0, 0, 0.12);
  --on-fg-08: rgba(0, 0, 0, 0.10);
  --on-fg-06: rgba(0, 0, 0, 0.08);
  --on-fg-05: rgba(0, 0, 0, 0.06);
  --on-fg-04: rgba(0, 0, 0, 0.06);
  --on-fg-02: rgba(0, 0, 0, 0.04);
}

/* Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  font-family: 'Instrument Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

::selection { background: var(--accent); color: var(--bg); }

/* ── Typography ── */
.display { font-size: clamp(3rem, 7vw, 6rem); font-weight: 700; letter-spacing: -0.04em; line-height: 1.1; padding-bottom: 0.1em; }
.headline { font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.subhead { font-size: clamp(1.25rem, 2vw, 1.5rem); font-weight: 500; color: var(--fg-dim); line-height: 1.5; }
.body-text { font-size: 1rem; color: var(--fg-dim); line-height: 1.7; }
.eyebrow { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--fg-dim); }

/* ── Navigation ── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 14px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s, border-color 0.3s;
}
.nav.scrolled { background: var(--nav-bg-scrolled); }

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--fg);
  font-family: 'Instrument Sans', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.nav-brand-logo {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-brand-logo img { width: 32px; height: 32px; display: block; }
.nav-brand-logo .brand-svg {
  width: 32px; height: 32px; color: var(--accent); display: block;
  filter: drop-shadow(0 0 6px rgba(0, 212, 200, 0.4));
  animation: logoPulse 3s ease-in-out infinite;
}
.nav-brand:hover .brand-svg {
  animation: logoHeartbeat 0.6s ease-in-out;
  filter: drop-shadow(0 0 12px rgba(0, 212, 200, 0.6));
}
@keyframes logoPulse {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(0, 212, 200, 0.3)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 10px rgba(0, 212, 200, 0.5)); transform: scale(1.03); }
}
@keyframes logoHeartbeat {
  0% { transform: scale(1); }
  15% { transform: scale(1.15); }
  30% { transform: scale(0.95); }
  45% { transform: scale(1.1); }
  60% { transform: scale(1); }
  100% { transform: scale(1); }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}
/* Optically center the link group across the viewport when there's a separate
 * nav-actions cluster (index.html). Plain space-between drifts the middle group
 * toward whichever side is wider, and actions (lang/theme/login/download) is
 * much wider than the brand, so the links visually skew left.
 * The :not(:last-child) guard skips pricing/changelog where nav-links is the
 * only flex child after the brand — those pages don't need absolute centering. */
.nav .nav-links:not(:last-child) {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.nav-link {
  padding: 8px 14px;
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.nav-link:hover { color: var(--fg); background: var(--card-bg-hover); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg-dim);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.icon-btn:hover { color: var(--fg); border-color: var(--border-strong); background: var(--card-bg-hover); }
.icon-btn svg { width: 16px; height: 16px; }

.nav-dl {
  padding: 9px 20px;
  background: var(--accent);
  color: #0a0a0a;
  text-decoration: none;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-dl:hover { background: var(--accent-hover); transform: translateY(-1px); }

.nav-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(0, 212, 200, 0.08);
  border: 1px solid rgba(0, 212, 200, 0.15);
  border-radius: 20px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2px;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  transition: background 0.2s;
}
.nav-user-pill:hover { background: rgba(0, 212, 200, 0.14); }

/* Mobile nav */
.nav-toggle {
  display: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 8px;
  color: var(--fg);
  cursor: pointer;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 32px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: var(--accent);
  color: #0a0a0a;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-2px); }
.btn-secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover { border-color: var(--fg); }
.btn-ghost {
  background: var(--card-bg);
  color: var(--fg);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--card-bg-hover); border-color: var(--border-strong); }
.btn-lg { padding: 18px 44px; font-size: 15px; }
.btn-sm { padding: 8px 16px; font-size: 12px; }

/* ── Sections ── */
.section {
  padding: 120px 32px;
  position: relative;
}
.section-tight { padding: 80px 32px; }
.container { max-width: 1200px; margin: 0 auto; position: relative; }
.container-narrow { max-width: 800px; margin: 0 auto; position: relative; }

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  transition: all 0.3s;
}
.card:hover {
  background: var(--card-bg-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

/* ── Reveal animations ── */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal.vis { opacity: 1; transform: translateY(0); }
.reveal-d1 { transition-delay: 0.1s; }
.reveal-d2 { transition-delay: 0.2s; }
.reveal-d3 { transition-delay: 0.3s; }
.reveal-d4 { transition-delay: 0.4s; }

/* ── Footer ── */
.footer {
  padding: 60px 32px 40px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  text-align: center;
}
.footer-top {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  text-align: left;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}
.footer-col h4 {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg);
  margin-bottom: 16px;
}
.footer-col a {
  display: block;
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 10px;
  transition: color 0.2s;
}
.footer-col a:hover { color: var(--fg); }
.footer-brand { font-size: 14px; color: var(--fg-dim); line-height: 1.7; max-width: 320px; }
.footer-brand strong { color: var(--fg); font-size: 1.1rem; display: block; margin-bottom: 8px; }
.footer-bottom {
  font-size: 12px;
  color: var(--fg-dimmer);
  display: flex;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
  gap: 10px;
}

/* ── Language picker ── */
.lang-picker {
  position: relative;
  display: inline-block;
}
.lang-btn {
  padding: 8px 14px;
  background: transparent;
  color: var(--fg-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.lang-btn:hover { color: var(--fg); border-color: var(--border-strong); }
.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  min-width: 180px;
  max-height: 360px;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-5px);
  transition: all 0.2s;
  z-index: 200;
}
.lang-menu.open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.lang-menu::-webkit-scrollbar { width: 6px; }
.lang-menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.lang-menu button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
  white-space: nowrap;
}
.lang-menu button:hover { background: var(--card-bg-hover); }
.lang-menu button.active { background: var(--glow); color: var(--accent); }

/* ── RTL support (Arabic) ── */
html[dir="rtl"] .lang-menu { right: auto; left: 0; }
html[dir="rtl"] .lang-menu button { text-align: right; }
html[dir="rtl"] body { text-align: right; }
/* Force RTL base direction on every translatable text element so paragraphs
 * with mixed scripts (Arabic + Latin brand names / numbers) read correctly.
 * The bidi algorithm picks paragraph direction from the first strong char by
 * default — if a paragraph starts with "PULSE" the algorithm would default LTR.
 * Setting `direction: rtl` explicitly forces the right base direction; <bdi>
 * elements still isolate Latin substrings within that RTL flow. */
html[dir="rtl"] [data-i18n],
html[dir="rtl"] [data-i18n-html],
html[dir="rtl"] p,
html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3,
html[dir="rtl"] h4,
html[dir="rtl"] li {
  direction: rtl;
  unicode-bidi: isolate;
  text-align: start;
}
/* Logical equivalents — bdi defaults to dir="auto" which works correctly. */
html[dir="rtl"] bdi { direction: ltr; unicode-bidi: isolate; }

/* Plural placeholders: keep empty elements out of layout until JS hydrates them,
 * so Cumulative Layout Shift stays at zero. Authors who want SSR fallback text
 * can set it inline; the first applyTranslations() pass overwrites it. */
[data-i18n-plural]:empty { display: none; }

/* ── Script-specific font fallbacks ──
 * Instrument Sans only covers Latin/Cyrillic glyphs. For CJK and Arabic/Devanagari
 * we prepend the appropriate Noto Sans so every language renders in a tuned font
 * instead of whatever the OS happens to pick. The Google Fonts loader uses
 * unicode-range, so English-only visitors never download these files.
 */
html[lang="ja"] body, html[lang="ja"] button, html[lang="ja"] input, html[lang="ja"] select, html[lang="ja"] textarea {
  font-family: 'Instrument Sans', 'Noto Sans JP', system-ui, sans-serif;
}
html[lang="ko"] body, html[lang="ko"] button, html[lang="ko"] input, html[lang="ko"] select, html[lang="ko"] textarea {
  font-family: 'Instrument Sans', 'Noto Sans KR', system-ui, sans-serif;
}
html[lang="zh"] body, html[lang="zh"] button, html[lang="zh"] input, html[lang="zh"] select, html[lang="zh"] textarea {
  font-family: 'Instrument Sans', 'Noto Sans SC', system-ui, sans-serif;
}
html[lang="ar"] body, html[lang="ar"] button, html[lang="ar"] input, html[lang="ar"] select, html[lang="ar"] textarea {
  font-family: 'Instrument Sans', 'Noto Sans Arabic', system-ui, sans-serif;
}
html[lang="hi"] body, html[lang="hi"] button, html[lang="hi"] input, html[lang="hi"] select, html[lang="hi"] textarea {
  font-family: 'Instrument Sans', 'Noto Sans Devanagari', system-ui, sans-serif;
}

/* ── Discord callout ── */
.discord-callout {
  background: linear-gradient(135deg, rgba(88, 101, 242, 0.08) 0%, rgba(0, 212, 200, 0.06) 100%);
  border: 1px solid rgba(88, 101, 242, 0.25);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  margin: 40px auto;
  max-width: 800px;
}
.discord-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 20px;
  color: #5865f2;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .footer-top { grid-template-columns: 1fr 1fr; }
  .nav-links { display: none; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .nav-actions .nav-link { display: none; }
}
@media (max-width: 600px) {
  .section { padding: 80px 20px; }
  .section-tight { padding: 60px 20px; }
  .footer-top { grid-template-columns: 1fr; }
  .nav { padding: 12px 20px; }
  .btn-lg { padding: 14px 28px; }
}
