/* ─────────────────────────────────────────────────────────────
   Perceptix — shared design system
   Palette matches the EchoGuard app (lib/config/app_theme.dart)
   ───────────────────────────────────────────────────────────── */

:root {
  /* Brand */
  --purple: #667EEA;
  --purple-dark: #764BA2;
  --grad: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);

  /* Light surfaces (app light theme) */
  --bg: #F4F4F9;
  --surface: #FFFFFF;
  --surface-mid: #E9E8F2;

  /* Ink (derived from the app's dark background so both feel like one brand) */
  --text: #1A1633;
  --text-2: #6B6880;
  --text-3: #A9A6BC;
  --border: rgba(26, 22, 51, 0.08);

  /* Status */
  --green: #16A34A;
  --green-deep: #15803D;
  --amber: #D97706;
  --red: #DC2626;

  /* Dark surfaces (footer / hero) */
  --ink: #0F0A2A;
  --ink-surface: #1A1040;
  --ink-mid: #231555;

  --shadow-sm: 0 2px 10px rgba(26, 22, 51, 0.05);
  --shadow: 0 8px 28px rgba(26, 22, 51, 0.08);
  --shadow-lg: 0 18px 48px rgba(26, 22, 51, 0.12);
  --radius: 18px;
  --radius-sm: 14px;
  --max: 1180px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; }
a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: var(--max); margin: 0 auto; padding: 0 24px; }

/* ── Header / nav ───────────────────────────────────────────── */
header {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

nav {
  max-width: var(--max); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 24px;
}

.logo-wrap { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-wrap:hover { text-decoration: none; }
.logo-svg { width: 44px; height: 44px; flex-shrink: 0; }
.logo-text {
  font-size: 1.4rem; font-weight: 800; letter-spacing: -0.3px;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links {
  display: flex; align-items: center; gap: 22px;
  list-style: none; margin-left: auto;
}
/* Never let a nav item wrap or get squashed — that was clipping the CTA. */
.nav-links > li { flex-shrink: 0; }
.nav-links a {
  color: var(--text-2); font-size: 0.94rem; font-weight: 500;
  text-decoration: none; padding: 6px 0; position: relative;
  white-space: nowrap;
}
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--purple); font-weight: 600; }
.nav-links a.active::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -2px;
  height: 2px; background: var(--grad); border-radius: 2px;
}

/* ── Legal dropdown (keeps the bar short) ───────────────────── */
.has-drop { position: relative; }
.drop-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: 0; cursor: pointer;
  font: inherit; font-size: 0.94rem; font-weight: 500;
  color: var(--text-2); padding: 6px 0; white-space: nowrap;
}
.drop-toggle:hover { color: var(--text); }
.drop-toggle.active { color: var(--purple); font-weight: 600; }
.drop-toggle .caret {
  border: solid currentColor; border-width: 0 1.6px 1.6px 0;
  padding: 2.5px; transform: rotate(45deg) translateY(-2px);
  transition: transform .2s ease;
}
.has-drop.open .drop-toggle .caret { transform: rotate(-135deg) translateY(-1px); }

.drop-menu {
  position: absolute; top: calc(100% + 12px); right: 0;
  min-width: 218px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 8px;
  display: none; list-style: none; z-index: 1200;
}
.has-drop.open .drop-menu { display: block; }
.drop-menu li { flex-shrink: 0; }
.drop-menu a {
  display: block; padding: 9px 12px; border-radius: 10px;
  font-size: 0.9rem; color: var(--text-2); white-space: nowrap;
}
.drop-menu a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.drop-menu a.active { background: rgba(102,126,234,.1); color: var(--purple); font-weight: 600; }
.drop-menu a.active::after { display: none; }

/* NOTE: selector must beat `.nav-links a` (0-1-1) or its `padding: 6px 0`
   collapses the pill and the label spills outside it. */
.nav-links a.cta-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--grad); color: #fff !important;
  padding: 9px 20px; border-radius: 999px;
  font-weight: 600; font-size: 0.85rem; letter-spacing: .2px;
  text-decoration: none; white-space: nowrap; line-height: 1;
  box-shadow: 0 6px 18px rgba(102, 126, 234, 0.32);
  transition: transform .2s ease, box-shadow .2s ease;
}
.nav-links a.cta-btn:hover {
  transform: translateY(-2px); text-decoration: none;
  box-shadow: 0 10px 26px rgba(102, 126, 234, 0.44);
}
.nav-links a.cta-btn.active::after { display: none; }
/* Breathing room so the glow never kisses the viewport edge. */
.nav-links > li:last-child { margin-left: 6px; }

.nav-toggle {
  display: none; background: none; border: 0; cursor: pointer;
  font-size: 1.5rem; color: var(--text); line-height: 1;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn-primary, .btn-secondary {
  display: inline-block; padding: 14px 30px; border-radius: 999px;
  font-weight: 600; font-size: 1rem; text-decoration: none;
  transition: transform .2s ease, box-shadow .2s ease;
}
.btn-primary {
  background: var(--grad); color: #fff;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.35);
}
.btn-primary:hover { transform: translateY(-2px); text-decoration: none; }
.btn-secondary {
  background: rgba(255,255,255,.1); color: #fff;
  border: 1.5px solid rgba(255,255,255,.35);
}
.btn-secondary:hover { background: rgba(255,255,255,.2); text-decoration: none; }

/* ── Sections ───────────────────────────────────────────────── */
section { padding: 92px 0; }
.section-head { text-align: center; max-width: 720px; margin: 0 auto 54px; }
.section-head h2 {
  font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 800;
  letter-spacing: -0.5px; margin-bottom: 12px;
}
.section-head p { color: var(--text-2); font-size: 1.08rem; }

.eyebrow {
  display: inline-block; font-size: 0.74rem; font-weight: 700;
  letter-spacing: 1.8px; text-transform: uppercase;
  color: var(--purple); margin-bottom: 10px;
}

/* ── Cards ──────────────────────────────────────────────────── */
.grid { display: grid; gap: 22px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  box-shadow: var(--shadow-sm);
  transition: transform .25s ease, box-shadow .25s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.card h3 { font-size: 1.16rem; font-weight: 700; margin-bottom: 8px; }
.card p { color: var(--text-2); font-size: 0.97rem; }

.icon-badge {
  width: 52px; height: 52px; border-radius: 15px;
  background: rgba(102, 126, 234, 0.12);
  display: grid; place-items: center; font-size: 1.5rem;
  margin-bottom: 16px; color: var(--purple);
}

/* ── Footer ─────────────────────────────────────────────────── */
footer { background: var(--ink); color: rgba(255,255,255,.75); padding: 68px 0 28px; }
footer h4 { color: #fff; font-size: 1rem; margin-bottom: 16px; font-weight: 700; }
footer a { color: rgba(255,255,255,.6); text-decoration: none; font-size: 0.94rem; }
footer a:hover { color: #fff; text-decoration: none; }
.footer-grid {
  display: grid; gap: 36px;
  grid-template-columns: 1.6fr repeat(3, 1fr);
}
.footer-grid ul { list-style: none; display: grid; gap: 10px; }
.footer-brand .logo-text { font-size: 1.3rem; }
.footer-brand p { font-size: 0.94rem; margin-top: 12px; max-width: 320px; }
.footer-bottom {
  margin-top: 46px; padding-top: 22px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex; justify-content: space-between; gap: 14px;
  flex-wrap: wrap; font-size: 0.87rem; color: rgba(255,255,255,.5);
}

/* ── Legal / document pages ─────────────────────────────────── */
.doc-hero {
  background: var(--grad); color: #fff; padding: 66px 0 54px; text-align: center;
}
.doc-hero h1 {
  font-size: clamp(1.9rem, 4vw, 2.7rem); font-weight: 800; letter-spacing: -0.5px;
}
.doc-hero .meta { opacity: .88; margin-top: 10px; font-size: 0.98rem; }
.doc-hero .company { opacity: .95; font-weight: 600; margin-top: 4px; }

.doc-layout {
  max-width: var(--max); margin: 0 auto; padding: 52px 24px 86px;
  display: grid; grid-template-columns: 268px 1fr; gap: 44px; align-items: start;
}

.toc {
  position: sticky; top: 88px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow-sm); max-height: calc(100vh - 130px);
  overflow-y: auto;
}
.toc h2 {
  font-size: 0.74rem; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 14px; font-weight: 700;
}
.toc ol { list-style: none; counter-reset: toc; display: grid; gap: 3px; }
.toc li { counter-increment: toc; }
.toc a {
  display: block; padding: 7px 10px; border-radius: 9px;
  font-size: 0.88rem; color: var(--text-2); text-decoration: none;
  border-left: 2px solid transparent;
}
.toc a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.toc a.active {
  background: rgba(102,126,234,.1); color: var(--purple);
  font-weight: 600; border-left-color: var(--purple);
}

.doc-body {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 44px 48px;
  box-shadow: var(--shadow-sm);
}
.doc-body .lead {
  font-size: 1.05rem; color: var(--text-2);
  padding: 18px 20px; background: var(--bg);
  border-left: 3px solid var(--purple); border-radius: 0 12px 12px 0;
  margin-bottom: 30px;
}
.doc-body h2 {
  font-size: 1.35rem; font-weight: 700; margin: 40px 0 12px;
  padding-top: 14px; border-top: 1px solid var(--border);
  scroll-margin-top: 90px;
}
.doc-body h2:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.doc-body h3 { font-size: 1.06rem; font-weight: 700; margin: 24px 0 8px; }
.doc-body p { margin-bottom: 14px; color: var(--text-2); }
.doc-body ul, .doc-body ol { margin: 0 0 16px 22px; color: var(--text-2); }
.doc-body li { margin-bottom: 8px; }
.doc-body strong { color: var(--text); font-weight: 650; }
.doc-body table {
  width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 0.94rem;
}
.doc-body th, .doc-body td {
  border: 1px solid var(--border); padding: 10px 12px; text-align: left;
}
.doc-body th { background: var(--bg); font-weight: 700; color: var(--text); }

.doc-nav {
  display: flex; gap: 12px; flex-wrap: wrap;
  justify-content: center; margin-top: 26px;
}
.doc-nav a {
  background: rgba(255,255,255,.16); color: #fff;
  border: 1px solid rgba(255,255,255,.3);
  padding: 8px 18px; border-radius: 999px;
  font-size: 0.88rem; font-weight: 600; text-decoration: none;
}
.doc-nav a:hover, .doc-nav a.active {
  background: #fff; color: var(--purple); text-decoration: none;
}

.print-hint {
  text-align: center; margin-top: 28px; color: var(--text-3); font-size: 0.86rem;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 940px) {
  .doc-layout { grid-template-columns: 1fr; gap: 26px; }
  .toc { position: static; max-height: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

/* Tighten spacing before collapsing, so nothing clips at mid widths. */
@media (max-width: 1240px) {
  nav { padding: 10px 20px; }
  .nav-links { gap: 18px; }
  .nav-links a, .drop-toggle { font-size: 0.9rem; }
  .nav-links a.cta-btn { padding: 8px 18px; font-size: 0.82rem; }
}

@media (max-width: 1040px) {
  .nav-links { gap: 14px; }
  .nav-links a.cta-btn { padding: 8px 16px; font-size: 0.8rem; }
}

/* Collapse to a burger menu — the full set never fits a tablet bar. */
@media (max-width: 940px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: #fff; border-bottom: 1px solid var(--border);
    padding: 8px 24px 20px; display: none;
    box-shadow: var(--shadow); max-height: 80vh; overflow-y: auto;
  }
  .nav-links.open { display: flex; }
  .nav-links > li { width: 100%; }
  .nav-links a { padding: 13px 0; border-bottom: 1px solid var(--border); }
  .nav-links a.active::after { display: none; }

  /* Dropdown becomes a plain inline list on mobile */
  .drop-toggle {
    width: 100%; justify-content: space-between;
    padding: 13px 0; border-bottom: 1px solid var(--border);
  }
  .drop-menu {
    position: static; display: block; border: 0; box-shadow: none;
    padding: 0 0 0 12px; min-width: 0; background: transparent;
  }
  .drop-menu a { padding: 11px 0; font-size: 0.9rem; }

  /* Full-width pill in the burger menu */
  .nav-links a.cta-btn {
    display: flex; width: 100%; margin-top: 14px;
    border-bottom: 0; padding: 14px 22px; font-size: 0.95rem;
  }
  .nav-links > li:last-child { margin-left: 0; }
}

@media (max-width: 720px) {
  section { padding: 64px 0; }
  .doc-body { padding: 28px 22px; }
  .footer-grid { grid-template-columns: 1fr; }
  .logo-svg { width: 38px; height: 38px; }
  .logo-text { font-size: 1.22rem; }
}

@media print {
  header, footer, .toc, .doc-nav, .print-hint, .nav-toggle { display: none !important; }
  .doc-layout { grid-template-columns: 1fr; padding: 0; }
  .doc-body { border: 0; box-shadow: none; padding: 0; }
  .doc-hero { background: none !important; color: #000; padding: 0 0 20px; }
  body { background: #fff; }
}
