@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap');

:root {
  --bg: #0f0a1a;
  --bg-soft: #17102b;
  --surface: #1e1533;
  --surface-2: #241a3f;
  --border: #362a56;
  --text: #ece7f7;
  --text-dim: #b7abd6;
  --text-faint: #8a7db0;
  --purple: #a855f7;
  --purple-bright: #c084fc;
  --purple-deep: #7c3aed;
  --purple-glow: rgba(168, 85, 247, 0.35);
  --radius: 14px;
  --maxw: 1080px;
  font-family: "Montserrat", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body { font-family: "Montserrat", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  background-image:
    radial-gradient(1200px 600px at 50% -10%, rgba(124, 58, 237, 0.25), transparent 70%),
    radial-gradient(800px 400px at 90% 10%, rgba(168, 85, 247, 0.12), transparent 60%);
  background-attachment: fixed;
}

/* Neural-network background canvas: fixed, behind all content. */
#neural-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.9;
}

/* Keep page chrome and content above the canvas. */
header, main, footer { position: relative; z-index: 1; }

a { color: var(--purple-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  /* Padding lateral com piso garantido: nunca menor que 5px, respeitando a
     safe-area (notch). Assim o conteúdo nunca cola na borda em nenhuma
     largura, mesmo entre breakpoints. */
  padding-left: max(24px, env(safe-area-inset-left), 5px);
  padding-right: max(24px, env(safe-area-inset-right), 5px);
  /* Never let the container itself exceed the viewport. */
  width: 100%;
}

/* Nav */
header {
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(15, 10, 26, 0.7);
  border-bottom: 1px solid var(--border);
}
.nav { position: relative; display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .04em; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo-badge {
  width: 60px; height: 60px; border-radius: 8px;
  object-fit: contain; display: block;
}
.nav-links { display: flex; gap: 22px; align-items: center; }

/* Hamburger button (hidden on desktop, shown on mobile). */
.nav-toggle {
  display: none;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  width: 40px; height: 40px; cursor: pointer; padding: 0;
  align-items: center; justify-content: center;
}
.nav-toggle:hover { border-color: var(--purple); }
.nav-toggle .bars { position: relative; width: 18px; height: 2px; background: var(--text); display: block; transition: background .15s; }
.nav-toggle .bars::before, .nav-toggle .bars::after {
  content: ""; position: absolute; left: 0; width: 18px; height: 2px; background: var(--text);
  transition: transform .2s, top .2s;
}
.nav-toggle .bars::before { top: -6px; }
.nav-toggle .bars::after { top: 6px; }
/* Animate into an "X" when the menu is open. */
.nav.open .nav-toggle .bars { background: transparent; }
.nav.open .nav-toggle .bars::before { top: 0; transform: rotate(45deg); }
.nav.open .nav-toggle .bars::after { top: 0; transform: rotate(-45deg); }
.nav-links a { color: var(--text-dim); font-size: 14px; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--purple-bright); }

/* Icon links (npm, GitHub) */
.nav-links a.icon-link { display: inline-flex; align-items: center; }
.nav-links a.icon-link svg { width: 22px; height: 22px; display: block; fill: currentColor; }
.nav-links a.icon-link:hover { color: var(--purple-bright); }

/* Hero */
.hero { text-align: center; padding: 96px 0 64px; }
.hero-logo {
  width: 300px; margin: 0 auto 28px; display: block;
  object-fit: contain;  border-radius: 20px; padding: 10px;
}
.eyebrow {
  display: inline-block; font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--purple-bright); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 14px; margin-bottom: 26px; background: var(--surface);
}
.hero h1 {
  font-size: clamp(34px, 6vw, 60px); line-height: 1.08; font-weight: 500; letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff, var(--purple-bright));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  max-width: 900px; margin: 0 auto 22px;
}
.hero p.lead { color: var(--text-dim); font-size: clamp(16px, 2.2vw, 20px); max-width: 680px; margin: 0 auto 34px; }

/* Typewriter headline: blinking caret + stable height so the layout
   doesn't jump while the text is typed/erased. */
.typewriter { min-height: 1.2em; }
/* Keep the white→purple gradient on the TYPED text (not the whole h1), so it
   repaints correctly as textContent changes and the span is never invisible. */
.typewriter .tw-text {
  background: linear-gradient(180deg, #fff, var(--purple-bright));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.tw-cursor {
  display: inline-block;
  margin-left: 2px;
  font-weight: 400;
  color: var(--purple-bright);
  -webkit-text-fill-color: var(--purple-bright); /* defeat the h1 gradient clip */
  /* !important so the blink survives the global reduced-motion reset below.
     A blinking caret is standard UI, not disruptive motion. */
  animation: tw-blink 1s step-end infinite !important;
}
@keyframes tw-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.cta-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px;
  padding: 12px 22px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
}
.btn-primary {
  background: linear-gradient(135deg, var(--purple-deep), var(--purple)); color: #fff;
  box-shadow: 0 8px 30px var(--purple-glow);
}
.btn-primary:hover { text-decoration: none; filter: brightness(1.08); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { text-decoration: none; border-color: var(--purple); }

/* Sections */
section.block { padding: 56px 0; }
.section-title { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--purple-bright); margin-bottom: 12px; }
.section-lead { color: var(--text-dim); max-width: 720px; }

.synopsis {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 34px; margin-top: 20px;
}
.synopsis p { color: var(--text-dim); margin-bottom: 14px; }
.synopsis strong { color: var(--text); }

/* Grid cards */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-top: 26px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--purple); transform: translateY(-2px); }
.card h3 { font-size: 16px; font-weight: 500; margin-bottom: 8px; }
.card p { color: var(--text-faint); font-size: 14px; }

/* Code block */
.code {
  background: #0b0716; border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; font-family: "Montserrat", ui-sans-serif, system-ui, sans-serif;
  font-size: 14px; color: var(--text); overflow-x: auto; margin-top: 18px;
}
.code .c { color: var(--text-faint); }
.code .p { color: var(--purple-bright); }

/* Workflow */
.flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-top: 24px; }
.step {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
}
.step .cmd { color: var(--purple-bright); font-family: "Montserrat", ui-sans-serif, system-ui, sans-serif; font-size: 14px; font-weight: 600; }
.step .desc { color: var(--text-faint); font-size: 13px; margin-top: 8px; }
.step .num { color: var(--purple-deep); font-weight: 800; font-size: 12px; letter-spacing: .1em; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.chip {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 16px; font-size: 13px; color: var(--text-dim);
}
.chip.accent { border-color: var(--purple); color: var(--purple-bright); }

/* Footer */
footer { border-top: 1px solid var(--border); padding: 40px 0; margin-top: 40px; color: var(--text-faint); font-size: 14px; }
.foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
.foot a { color: var(--text-dim); }

/* ─── Doc pages ─────────────────────────────────────────────── */
.doc { padding: 56px 0 24px; }
.doc-head { margin-bottom: 8px; }
.doc-head .kicker { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--purple-bright); }
.doc h1 { font-size: clamp(30px, 5vw, 44px); font-weight: 500; letter-spacing: -0.02em; margin: 10px 0 16px; }
.doc .subtitle { color: var(--text-dim); font-size: 18px; margin-bottom: 8px; }

.doc-body { padding-bottom: 60px; }
.doc-body h2 {
  font-size: 24px; font-weight: 500; margin: 44px 0 14px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.doc-body h2:first-child { border-top: none; padding-top: 0; margin-top: 12px; }
.doc-body h3 { font-size: 18px; font-weight: 500; margin: 26px 0 10px; color: var(--text); }
.doc-body p { color: var(--text-dim); margin: 12px 0; }
.doc-body ul, .doc-body ol { color: var(--text-dim); margin: 12px 0 12px 22px; }
.doc-body li { margin: 6px 0; }
.doc-body strong { color: var(--text); }
.doc-body a { color: var(--purple-bright); }

.doc-body code {
  background: #0b0716; border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 7px; font-family: "Montserrat", ui-sans-serif, system-ui, sans-serif; font-size: 13px; color: var(--purple-bright);
}
.doc-body pre {
  background: #0b0716; border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; overflow-x: auto; margin: 18px 0;
}
.doc-body pre code { background: none; border: none; padding: 0; color: var(--text); font-size: 13.5px; }

.doc-body table {
  width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.doc-body th, .doc-body td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.doc-body th { color: var(--purple-bright); font-weight: 600; background: var(--surface-2); }
.doc-body tr:last-child td { border-bottom: none; }
.doc-body td code { white-space: nowrap; }

.callout {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--purple);
  border-radius: 10px; padding: 16px 20px; margin: 20px 0; color: var(--text-dim);
}
.callout strong { color: var(--text); }

.next-links { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 30px; }
.next-links a {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 18px; font-size: 14px; color: var(--text);
}
.next-links a:hover { border-color: var(--purple); text-decoration: none; }

/* ─── Responsive ────────────────────────────────────────────── */

/* Prevent long tokens (URLs, package names) from forcing horizontal scroll. */
.doc-body p, .doc-body li, .synopsis p { overflow-wrap: anywhere; }

/* Tablet and below */
@media (max-width: 860px) {
  /* Mantém o piso de 5px (e a safe-area) também no tablet. */
  .wrap {
    padding-left: max(20px, env(safe-area-inset-left), 5px);
    padding-right: max(20px, env(safe-area-inset-right), 5px);
  }

  /* Collapse the nav into a hamburger-driven dropdown. */
  .nav { height: 60px; }
  .nav-toggle { display: inline-flex; }
  .nav-links {
    display: none;
    position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: rgba(15, 10, 26, 0.97);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }
  .nav.open .nav-links { display: flex; }
  .nav-links a { padding: 12px 20px; font-size: 15px; }
  .nav-links a:hover { background: var(--surface); text-decoration: none; }
  .nav-links a.icon-link { padding: 12px 20px; }

  .hero { padding: 64px 0 48px; }
  .hero-logo { width: 200px; margin-bottom: 22px; }

  section.block { padding: 44px 0; }
  .doc { padding: 40px 0 20px; }

  .synopsis { padding: 26px; }

  /* Single-column stacks read better than cramped multi-column on tablets. */
  .grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .flow { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

/* Phones */
@media (max-width: 560px) {
  /* Guaranteed side gutter, honoring the device safe-area (notch) with a 5px floor. */
  .wrap {
    padding-left: max(16px, env(safe-area-inset-left), 5px);
    padding-right: max(16px, env(safe-area-inset-right), 5px);
  }

  /* Nothing inside a wrap may push wider than the screen. */
  main, .hero, .doc, .doc-body, .synopsis { max-width: 100%; }
  .doc-body pre, .code {
    max-width: 100%;
    overflow-x: auto;   /* long code scrolls inside its box instead of the page */
    white-space: pre;
  }
  img, canvas, svg, table, pre { max-width: 100%; }

  
  .hero-logo { width: 200px; height: 96px; margin-bottom: 18px; }
  .eyebrow { margin-bottom: 20px; }

  /* Full-width, comfortably tappable CTAs. */
  .cta-row { flex-direction: column; align-items: stretch; }
  .btn { justify-content: center; width: 100%; padding: 13px 18px; }

  section.block { padding: 20px 20px 20px 20px; }
  .synopsis { padding: 20px; }

  .grid, .flow { grid-template-columns: 1fr; }

  .code, .doc-body pre { padding: 14px 16px; font-size: 13px; }

  .doc { padding: 32px 0 16px; }
  .doc-body h2 { margin: 34px 0 12px; font-size: 22px; }

  /* Footer stacks its two halves. */
  .foot { flex-direction: column; gap: 12px; }
  .next-links { flex-direction: column; }
  .next-links a { text-align: center; }

  /* Let wide tables scroll horizontally instead of breaking the layout. */
  .doc-body table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ── Overflow safety net ─────────────────────────────────────
   The real cause of "content touching the edge" on phones is a wide child
   (code block, table, long token) overflowing past the .wrap padding. This
   contains every such element so the .wrap gutter is always respected. */
html, body { max-width: 100%; overflow-x: hidden; }
main, header, footer, section, .doc, .doc-body, .synopsis, .grid, .flow { max-width: 100%; }
pre, code, table, img, canvas, svg, .code { max-width: 100%; }
.doc-body pre, .code { overflow-x: auto; }

/* Respect users who prefer less motion: soften transitions site-wide. */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
