/* =========================================================================
   oh-my-matrix — hand-drawn landing design system
   Visual language lifted verbatim from website/public/hero.png (cream whiteboard)
   + docs/assets/architecture.svg (Kalam/JetBrains Mono, roughen filter).
   Palette is NOT invented — it is the extracted brand.
   ========================================================================= */

:root {
  /* paper + ink (hero.png) */
  --paper:      #f5f0e6;
  --paper-2:    #efe7d6;
  --paper-3:    #e8dec9;
  --ink:        #2d3436;
  --ink-soft:   #34495e;
  --ink-muted:  #6b7785;

  /* module accents (hero.png → svg bridge) */
  --blue:   #3498db;   /* Autopilot · primary */
  --green:  #2ecc71;   /* Dynamic Workflows · verified */
  --amber:  #e6a23c;   /* Permission Policy · gate */
  --brown:  #8b7355;   /* warm underline / castle */
  --rose:   #fb7185;   /* blocked */
  --gray:   #dcdcdc;

  /* dark "engineering" section (architecture.svg) */
  --ink-deep: rgba(15, 23, 42, .97);
  --ink-deep-2: rgba(30, 41, 59, .85);
  --cyan:   #22d3ee;
  --light:  #e2e8f0;
  --light-muted: #94a3b8;

  --font-display: 'Caveat', 'Kalam', 'PingFang SC', 'Noto Sans SC', cursive;
  --font-hand: 'Kalam', 'PingFang SC', 'Noto Sans SC', cursive;
  --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;
  --font-body: 'PingFang SC', 'Noto Sans SC', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --maxw: 1120px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  line-height: 1.6;
  background-color: var(--paper);
  /* faint paper grain — SVG fractalNoise */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  /* warm paper vignette */
  box-shadow: inset 0 0 160px rgba(139, 115, 85, .1);
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--blue); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.05; margin: 0; }
/* wobbly hand-drawn underline under section title accents + hero accent */
h2.title em, .hero h1 .accent { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 12' preserveAspectRatio='none'%3E%3Cpath d='M3 8 C 40 3, 70 11, 100 6 S 160 2, 197 8' fill='none' stroke='%233498db' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 0 96%; background-size: 100% .26em; padding-bottom: .08em; }
.hero h1 .accent { background-size: 100% .22em; }

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
section { position: relative; padding: 96px 0; }
.section-head { max-width: 680px; margin-bottom: 56px; }
.eyebrow {
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted);
  display: inline-block; margin-bottom: 14px;
}
.eyebrow::before { content: "✎ "; color: var(--blue); }
h2.title { font-size: clamp(30px, 4.4vw, 46px); }
h2.title em { font-style: normal; color: var(--blue); }
.lede { font-size: 18px; color: var(--ink-soft); margin-top: 16px; }

/* hand-drawn wobbly underline (reusable) */
.scribble-underline {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 12' preserveAspectRatio='none'%3E%3Cpath d='M3 7 C 40 2, 70 11, 100 6 S 160 2, 197 7' fill='none' stroke='%233498db' stroke-width='3.2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: bottom left;
  background-size: 100% .32em;
  padding-bottom: .14em;
}

/* ---------- a11y: keyboard focus + skip link ---------- */
a:focus-visible, button:focus-visible, .btn:focus-visible, .lang-toggle button:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
  border-radius: 8px;
}
.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--ink); color: var(--paper);
  font-family: var(--font-mono); font-size: 14px;
  padding: 8px 14px; border-radius: 8px; text-decoration: none;
}
.skip-link:focus { left: 12px; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(245, 240, 230, .82);
  backdrop-filter: blur(8px);
  border-bottom: 2px dashed rgba(45,52,54,.18);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 26px; color: var(--ink); }
.brand .logo-dot { width: 30px; height: 30px; flex: none; }
.brand .brand-text { line-height: 1; }
.brand .brand-text small { display: block; font-family: var(--font-mono); font-weight: 400; font-size: 10px; letter-spacing: .14em; color: var(--ink-muted); }
.nav-links { display: flex; align-items: center; gap: 26px; }
.nav-links a { color: var(--ink-soft); font-weight: 400; font-size: 16px; }
.nav-links a:hover { color: var(--blue); text-decoration: none; }
.nav-actions { display: flex; align-items: center; gap: 14px; }

/* zh / en toggle */
.lang-toggle {
  display: inline-flex; border: 1.8px solid var(--ink); border-radius: 20px; overflow: hidden;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600; cursor: pointer;
  background: var(--paper);
}
.lang-toggle button {
  border: 0; background: transparent; padding: 5px 11px; color: var(--ink-soft); cursor: pointer;
  font: inherit; transition: background .2s, color .2s;
}
.lang-toggle button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* GitHub star pill */
.gh-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 14px;
  border: 1.8px solid var(--ink); border-radius: 22px; background: var(--paper);
  color: var(--ink); font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  transition: transform .2s var(--ease), box-shadow .2s;
}
.gh-pill:hover { transform: translate(-1px, -2px); box-shadow: 3px 4px 0 var(--ink); text-decoration: none; }
.gh-pill svg { width: 15px; height: 15px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  font-family: var(--font-display); font-weight: 700; font-size: 20px;
  padding: 12px 24px; border-radius: 14px; border: 2.2px solid var(--ink);
  transition: transform .18s var(--ease), box-shadow .18s, background .18s;
  background: var(--paper); color: var(--ink);
}
.btn:hover { transform: translate(-2px, -3px); box-shadow: 4px 5px 0 var(--ink); text-decoration: none; }
.btn:active { transform: translate(0, 0); box-shadow: 1px 1px 0 var(--ink); }
.btn--primary { background: var(--blue); color: #fff; border-color: var(--ink); }
.btn--ghost { background: transparent; }
.btn svg { width: 18px; height: 18px; }

/* ---------- hero ---------- */
.hero { padding-top: 64px; padding-bottom: 88px; }
.hero-grid {
  display: grid; grid-template-columns: 1.05fr .95fr; gap: 56px; align-items: center;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 20px;
  border: 1.8px dashed var(--brown); color: var(--brown);
  font-family: var(--font-mono); font-size: 12px; font-weight: 600; letter-spacing: .04em;
  background: rgba(139,115,85,.06); margin-bottom: 22px;
}
.hero-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.hero h1 { font-size: clamp(44px, 7vw, 84px); letter-spacing: -.01em; }
.hero h1 .accent { color: var(--blue); }
.hero .tagline { font-size: clamp(18px, 2.2vw, 23px); color: var(--ink-soft); margin: 18px 0 30px; max-width: 30ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.hero-meta { margin-top: 22px; font-family: var(--font-mono); font-size: 13px; color: var(--ink-muted); }
.hero-meta b { color: var(--ink-soft); }

/* ---------- terminal (rough.js draws the frame; content is typed by hero.js) ---------- */
.terminal-stage { position: relative; }
.terminal-frame-svg { position: absolute; inset: -16px; width: calc(100% + 32px); height: calc(100% + 32px); pointer-events: none; z-index: 2; }
.terminal {
  position: relative; z-index: 1;
  background: var(--ink-deep); border-radius: 14px; padding: 44px 22px 22px;
  font-family: var(--font-mono); font-size: 13.5px; line-height: 1.7; color: var(--light);
  min-height: 340px; overflow: hidden;
  box-shadow: 0 14px 40px rgba(15,23,42,.22);
}
.terminal .term-bar {
  position: absolute; top: 14px; left: 18px; display: flex; gap: 7px;
}
.terminal .term-bar i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.terminal .term-bar i:nth-child(1){ background:#fb7185; } .terminal .term-bar i:nth-child(2){ background:#fbbf24; } .terminal .term-bar i:nth-child(3){ background:#2ecc71; }
.terminal .term-title { position: absolute; top: 13px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--light-muted); letter-spacing:.08em; }
.terminal .line { white-space: pre-wrap; word-break: break-word; }
.terminal .prompt { color: var(--cyan); }
.terminal .arrow { color: var(--light-muted); }
.terminal .ok { color: var(--green); }
.terminal .gate { color: var(--amber); }
.terminal .caret { display: inline-block; width: 8px; background: var(--cyan); color: transparent; animation: blink 1s steps(2) infinite; }
.terminal .line.hidden { display: none; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- feature cards (the three modules) ---------- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.card {
  position: relative; background: var(--paper-2); border: 2.2px solid var(--ink);
  border-radius: 16px 22px 18px 24px; padding: 30px 26px 28px;
  box-shadow: 4px 5px 0 rgba(45,52,54,.85);
  transition: transform .22s var(--ease), box-shadow .22s;
}
.card:hover { transform: translate(-3px, -4px); box-shadow: 7px 8px 0 rgba(45,52,54,.85); }
.card .card-icon { width: 46px; height: 46px; margin-bottom: 16px; }
.card h3 { font-size: 26px; margin-bottom: 4px; }
.card .module-tag { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-muted); margin-bottom: 14px; display: block; }
.card p { color: var(--ink-soft); font-size: 15.5px; margin: 0 0 16px; }
.card ul { list-style: none; padding: 0; margin: 0; font-size: 14px; color: var(--ink-soft); }
.card ul li { position: relative; padding-left: 22px; margin-bottom: 7px; }
.card ul li::before { content: ""; position: absolute; left: 0; top: 9px; width: 12px; height: 2px; border-radius: 2px; }
.card--blue { border-top: 6px solid var(--blue); } .card--blue li::before { background: var(--blue); }
.card--green { border-top: 6px solid var(--green); } .card--green li::before { background: var(--green); }
.card--amber { border-top: 6px solid var(--amber); } .card--amber li::before { background: var(--amber); }

/* ---------- dark "engineering" section (workflow demo) ---------- */
.dark {
  background-color: var(--ink-deep);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='34'%3E%3Cpath d='M34 0H0V34' fill='none' stroke='%2333415555' stroke-width='1'/%3E%3C/svg%3E");
  color: var(--light);
}
.dark .eyebrow { color: var(--light-muted); } .dark .eyebrow::before { color: var(--cyan); }
.dark h2.title { color: var(--light); } .dark h2.title em { color: var(--cyan); }
.dark .lede { color: var(--light-muted); }
.flow-stage { background: var(--ink-deep-2); border-radius: 16px; padding: 28px; border: 2px dashed rgba(148,163,184,.3); position: relative; min-height: 360px; }
#flow-canvas { width: 100%; height: 380px; display: block; }
.flow-legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 18px; font-family: var(--font-mono); font-size: 12px; color: var(--light-muted); }
.flow-legend span { display: inline-flex; align-items: center; gap: 7px; }
.flow-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---------- permission gate ---------- */
.gate-grid { display: grid; grid-template-columns: .8fr 1.2fr; gap: 48px; align-items: center; }
.shield-art { width: 100%; max-width: 320px; margin: 0 auto; }
.blocklist { list-style: none; padding: 0; margin: 0; }
.blocklist li {
  display: flex; align-items: center; gap: 12px; padding: 11px 16px; margin-bottom: 10px;
  background: var(--paper-2); border: 2px solid var(--ink); border-radius: 10px 14px 9px 13px;
  font-family: var(--font-mono); font-size: 14px;
}
.blocklist li.struck code { color: var(--rose); } .blocklist li.struck .mark { color: var(--rose); }
.blocklist li code { background: rgba(45,52,54,.06); padding: 1px 7px; border-radius: 5px; color: var(--ink); }
.blocklist .mark { font-weight: 700; width: 18px; text-align: center; }
.note-callout {
  margin-top: 22px; padding: 16px 18px; border-left: 4px solid var(--amber);
  background: rgba(230,162,60,.1); border-radius: 0 10px 10px 0; font-size: 14.5px; color: var(--ink-soft);
}
.note-callout strong { color: var(--ink); }

/* ---------- honest surface ---------- */
.honest-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.honest-card { background: var(--paper-2); border: 2.2px dashed var(--ink); border-radius: 14px 18px; padding: 26px; }
.honest-card h3 { font-size: 22px; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.honest-card .tag-ok { color: var(--green); } .honest-card .tag-wip { color: var(--amber); }
.honest-card ul { list-style: none; padding: 0; margin: 0; }
.honest-card li { padding: 8px 0; border-bottom: 1px dotted rgba(45,52,54,.2); font-size: 15px; color: var(--ink-soft); }
.honest-card li:last-child { border-bottom: 0; }
.honest-card li b { color: var(--ink); }

/* ---------- roadmap timeline ---------- */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background-image: linear-gradient(var(--blue), var(--blue) 50%, transparent 0); background-size: 2px 12px; background-repeat: repeat-y; }
.timeline .item { position: relative; padding: 0 0 28px; }
.timeline .item::before { content: ""; position: absolute; left: -28px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--paper); border: 2.5px solid var(--blue); }
.timeline .item h4 { font-family: var(--font-hand); font-size: 19px; margin-bottom: 4px; }
.timeline .item p { margin: 0; color: var(--ink-soft); font-size: 14.5px; }

/* ---------- final CTA ---------- */
.cta-band { text-align: center; }
.cta-band .cta-card {
  display: inline-block; background: var(--paper-2); border: 2.4px solid var(--ink);
  border-radius: 22px 28px; padding: 44px 56px; box-shadow: 6px 7px 0 var(--ink);
  max-width: 720px;
}
.cta-band h2 { font-size: clamp(28px, 4vw, 40px); margin-bottom: 10px; }
.cta-band p { color: var(--ink-soft); margin: 0 0 26px; font-size: 17px; }
.cta-row { display: inline-flex; flex-wrap: wrap; gap: 14px; justify-content: center; }

/* ---------- footer ---------- */
.footer { border-top: 2px dashed rgba(45,52,54,.2); padding: 40px 0 56px; color: var(--ink-muted); font-size: 14px; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; align-items: center; }
.footer a { color: var(--ink-soft); }
.footer .made { font-family: var(--font-mono); font-size: 12px; }

/* ---------- scroll reveal ---------- */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: .08s; } .reveal.d2 { transition-delay: .16s; } .reveal.d3 { transition-delay: .24s; }

/* floating doodles */
.doodle { position: absolute; pointer-events: none; opacity: .9; z-index: 3; }
.float { animation: floaty 6s ease-in-out infinite; }
@keyframes floaty { 0%,100% { transform: translateY(0) rotate(var(--r,0deg)); } 50% { transform: translateY(-10px) rotate(var(--r,0deg)); } }

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .cards { grid-template-columns: 1fr; }
  .gate-grid, .honest-grid { grid-template-columns: 1fr; gap: 32px; }
  section { padding: 72px 0; }
  .nav-links { display: none; }
}
@media (max-width: 560px) {
  .nav-actions .gh-pill .gh-label { display: none; }
  .cta-band .cta-card { padding: 32px 24px; }
  .terminal { font-size: 12px; min-height: 300px; }
}

/* ---------- accessibility: reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
  .float, .terminal .caret { animation: none !important; }
  .btn:hover, .card:hover, .gh-pill:hover { transform: none !important; box-shadow: 4px 5px 0 rgba(45,52,54,.85) !important; }
  * { scroll-behavior: auto !important; }
}
