/* Layer order must match Tailwind so these components sit above preflight and below utilities. */
@layer theme, base, components, utilities;

@layer base {
  html { scroll-behavior: smooth; scroll-padding-top: 80px; }
  :focus-visible { outline: 2px solid var(--color-brand-600); outline-offset: 2px; border-radius: 6px; }
}

@layer components {
  :root {
    --ease: cubic-bezier(0.33, 0, 0.2, 1);
    --shadow-card: 0 1px 4px rgba(31, 35, 41, 0.04);
    --shadow-float: 0 12px 32px rgba(31, 35, 41, 0.12);
  }

  .skip-link { position: fixed; left: 16px; top: -48px; z-index: 1200; padding: 8px 14px; border-radius: 8px; background: var(--color-canvas); box-shadow: var(--shadow-float); transition: top 0.2s var(--ease); }
  .skip-link:focus { top: 12px; }

  /* ---------- Header (transparent over navy hero, solid after scroll) ---------- */
  .site-header { position: fixed; inset: 0 0 auto; z-index: 1000; color: #fff; border-bottom: 1px solid transparent; transition: background 0.25s var(--ease), border-color 0.25s var(--ease), color 0.25s var(--ease); }
  .site-header .nav-link { color: rgba(255, 255, 255, 0.78); }
  .site-header .nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
  .site-header .brand-sub { color: rgba(255, 255, 255, 0.55); }
  .site-header.is-scrolled { color: var(--color-ink-900); background: rgba(255, 255, 255, 0.92); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px); border-color: var(--color-line); }
  .site-header.is-scrolled .nav-link { color: var(--color-ink-700); }
  .site-header.is-scrolled .nav-link:hover { color: var(--color-ink-900); background: var(--color-surface); }
  .site-header.is-scrolled .brand-sub { color: var(--color-ink-500); }
  .site-header.menu-open:not(.is-scrolled) { background: var(--color-navy-950); }

  /* ---------- Buttons ---------- */
  .btn-primary { color: #fff; background: var(--color-brand-600); box-shadow: 0 6px 20px rgba(30, 144, 255, 0.28); }
  .btn-primary:hover { background: var(--color-brand-700); }
  .btn-ghost-dark { color: #fff; border: 1px solid rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.04); }
  .btn-ghost-dark:hover { border-color: rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.1); }

  .text-brand { position: relative; isolation: isolate; color: var(--color-brand-700); white-space: nowrap; }
  .text-brand::after { content: ""; position: absolute; left: -2px; right: -2px; bottom: 0.08em; height: 0.32em; z-index: -1; border-radius: 6px; background: var(--color-brand-100); }

  /* ---------- Reveal ---------- */
  .js .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); transition-delay: var(--d, 0ms); }
  .js .reveal.is-visible { opacity: 1; transform: none; }

  /* ---------- Hero ---------- */
  .hero { --bleed: clamp(96px, 18vw, 240px); color: #fff; background: linear-gradient(var(--color-navy-950) calc(100% - var(--bleed)), var(--color-canvas) 0); }
  .hero .hero-grid { bottom: var(--bleed); }
  .hero-grid { position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px); background-size: 64px 64px; mask-image: radial-gradient(70% 60% at 50% 30%, #000 20%, transparent 80%); -webkit-mask-image: radial-gradient(70% 60% at 50% 30%, #000 20%, transparent 80%); }
  .hero-glow { position: absolute; left: 50%; top: 36%; width: 1100px; height: 420px; transform: translateX(-50%); pointer-events: none; border-radius: 50%; background: rgba(30, 144, 255, 0.22); filter: blur(120px); }
  .hero-eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; border-radius: 999px; font-size: 13px; color: rgba(255, 255, 255, 0.82); background: rgba(255, 255, 255, 0.06); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); }
  .hero-eyebrow b { padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--color-navy-950); background: #fff; }
  .hero-accent { color: #6CB8FF; }

  /* Plumb line motif: a hanging line with a bob that sways gently */
  .plumb { position: absolute; top: 0; width: 1px; pointer-events: none; transform-origin: top center; animation: sway 7s ease-in-out infinite; }
  .plumb::before { content: ""; position: absolute; inset: 0; background: linear-gradient(rgba(108, 184, 255, 0), rgba(108, 184, 255, 0.55)); }
  .plumb::after { content: ""; position: absolute; left: 50%; bottom: -14px; width: 12px; height: 16px; transform: translateX(-50%); background: #6CB8FF; clip-path: polygon(50% 100%, 0 30%, 25% 0, 75% 0, 100% 30%); box-shadow: 0 0 24px rgba(108, 184, 255, 0.8); }
  .plumb-l { left: 8%; height: 46%; animation-delay: -2s; }
  .plumb-r { right: 9%; height: 32%; animation-duration: 9s; opacity: 0.6; }

  /* ---------- Window frame ---------- */
  .window { overflow: hidden; border-radius: 16px; background: var(--color-canvas); border: 1px solid var(--color-line); box-shadow: 0 40px 100px -30px rgba(9, 22, 40, 0.45), 0 12px 32px rgba(31, 35, 41, 0.08); }
  .window-bar { display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 14px; border-bottom: 1px solid var(--color-line); background: var(--color-surface); }
  .dots { display: flex; gap: 6px; width: 48px; }
  .dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--color-line-strong); }
  .url { display: inline-flex; align-items: center; gap: 6px; margin: 0 auto; padding: 3px 14px; border-radius: 999px; background: var(--color-canvas); font-size: 12px; color: var(--color-ink-500); white-space: nowrap; }
  .window img { display: block; width: 100%; height: auto; }
  .hero-stage .window { border-color: rgba(255, 255, 255, 0.14); }

  .float-card { position: absolute; z-index: 2; display: flex; gap: 12px; align-items: flex-start; width: 252px; padding: 14px 16px; border-radius: 14px; background: rgba(255, 255, 255, 0.97); color: var(--color-ink-900); border: 1px solid var(--color-line); box-shadow: var(--shadow-float); animation: bob 6s ease-in-out infinite; }
  .float-card .icon-tile { width: 34px; height: 34px; border-radius: 10px; }
  .float-card b { display: block; font-size: 14px; font-weight: 600; }
  .float-card p { margin-top: 2px; font-size: 12px; line-height: 1.5; color: var(--color-ink-700); }
  .float-a { left: -56px; top: 30%; }
  .float-b { right: -64px; top: 12%; animation-delay: -2s; }
  .float-c { right: -40px; bottom: 14%; animation-delay: -4s; }

  /* ---------- Question list ---------- */
  .q-item { display: flex; gap: 18px; align-items: baseline; padding: 18px 4px; border-bottom: 1px solid var(--color-line); transition: padding 0.25s var(--ease), color 0.25s var(--ease); }
  .q-item span { flex: none; width: 28px; font: 600 13px var(--font-mono); color: var(--color-brand-600); }
  .q-item p { font-size: 17px; color: var(--color-ink-900); }
  .q-item:hover { padding-left: 12px; }
  .q-item:hover p { color: var(--color-brand-700); }

  /* ---------- Promo video ---------- */
  .promo { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 22px; border: 1px solid var(--color-line); background: var(--color-surface); box-shadow: 0 30px 80px -30px rgba(18, 115, 230, 0.35); }
  .promo-video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; object-fit: contain; }
  .promo-cover { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 14px; width: 100%; padding-bottom: 7%; background-size: cover; background-position: center; cursor: pointer; }
  .promo-cover:disabled { cursor: default; }
  .promo-play { position: relative; display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; background: var(--color-brand-600); color: #fff; box-shadow: 0 16px 40px rgba(18, 115, 230, 0.35); transition: transform 0.25s var(--ease); }
  .promo-play svg { margin-left: 4px; fill: currentColor; }
  .promo-play::before, .promo-play::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid rgba(30, 144, 255, 0.6); animation: ripple 2.6s var(--ease) infinite; }
  .promo-play::after { animation-delay: -1.3s; }
  .promo-cover:not(:disabled):hover .promo-play { transform: scale(1.06); }
  .promo-meta { display: inline-flex; gap: 10px; align-items: center; padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--color-ink-700); background: rgba(255, 255, 255, 0.92); box-shadow: var(--shadow-card); }
  .promo.is-playing .promo-cover { display: none; }

  /* ---------- Intelligence layer diagram ---------- */
  .layer-grid { display: grid; gap: 20px; align-items: center; }
  @media (min-width: 1024px) { .layer-grid { grid-template-columns: 1fr 64px 1.25fr 64px 1fr; } }
  .source { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--color-canvas); border: 1px solid var(--color-line); font-size: 14px; color: var(--color-ink-700); }
  .source svg { width: 16px; height: 16px; color: var(--color-ink-500); }
  .flow-line { position: relative; height: 2px; overflow: hidden; border-radius: 2px; background: var(--color-line); }
  .flow-line::after { content: ""; position: absolute; top: 0; left: -40%; width: 40%; height: 100%; background: var(--color-brand-600); animation: flow 2.2s linear infinite; }
  @media (max-width: 1023px) { .flow-line { justify-self: center; width: 2px; height: 36px; } .flow-line::after { left: 0; top: -40%; width: 100%; height: 40%; animation-name: flow-y; } }
  .core { position: relative; overflow: hidden; padding: 28px; border-radius: 22px; background: var(--color-navy-950); color: #fff; box-shadow: 0 30px 70px -30px rgba(9, 22, 40, 0.6); }
  .core .chip { color: rgba(255, 255, 255, 0.9); background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1); padding: 6px 10px; border-radius: 8px; font-size: 13px; justify-content: center; }

  /* ---------- Showcase tabs ---------- */
  .tab { position: relative; display: flex; gap: 14px; width: 100%; padding: 14px 16px; overflow: hidden; border-radius: 14px; text-align: left; transition: background 0.25s var(--ease); }
  .tab:hover { background: var(--color-surface); }
  .tab .icon-tile { background: var(--color-surface-2); color: var(--color-ink-500); transition: background 0.25s var(--ease), color 0.25s var(--ease); }
  .tab b { display: block; font-size: 15px; font-weight: 600; color: var(--color-ink-700); }
  .tab small { display: none; margin-top: 4px; font-size: 13px; line-height: 1.6; color: var(--color-ink-700); }
  .tab[aria-selected="true"] { background: var(--color-canvas); box-shadow: 0 0 0 1px var(--color-line), var(--shadow-float); }
  .tab[aria-selected="true"] .icon-tile { background: var(--color-brand-100); color: var(--color-brand-700); }
  .tab[aria-selected="true"] b { color: var(--color-ink-900); }
  .tab[aria-selected="true"] small { display: block; }
  .tab-progress { position: absolute; left: 0; bottom: 0; height: 2px; width: 0; background: var(--color-brand-600); }
  .tab[aria-selected="true"] .tab-progress { animation: progress var(--dur, 6s) linear forwards; }
  .showcase.is-paused .tab-progress { animation-play-state: paused; }
  .shot-stack { position: relative; aspect-ratio: 1600 / 1000; background: var(--color-surface); }
  .shot-stack img { position: absolute; inset: 0; opacity: 0; transform: scale(1.015); transition: opacity 0.5s var(--ease), transform 0.8s var(--ease); }
  .shot-stack img.is-active { opacity: 1; transform: none; }

  /* ---------- Drill-down plumb ---------- */
  .drill { position: relative; padding-left: 44px; }
  .drill-line { position: absolute; left: 15px; top: 10px; bottom: 10px; width: 2px; background: var(--color-line); }
  .drill-line span { position: absolute; inset: 0 0 auto; height: 0; background: var(--color-brand-600); transition: height 0.35s var(--ease); }
  .drill-bob { position: absolute; left: 9px; top: 0; width: 14px; height: 18px; background: var(--color-brand-600); clip-path: polygon(50% 100%, 0 30%, 25% 0, 75% 0, 100% 30%); transition: transform 0.35s var(--ease); }
  .drill-row { position: relative; display: grid; grid-template-columns: 88px 1fr auto; gap: 14px; align-items: center; padding: 12px 16px; margin-bottom: 8px; border-radius: 12px; border: 1px solid var(--color-line); background: var(--color-canvas); opacity: 0.45; transition: opacity 0.35s var(--ease), border-color 0.35s var(--ease), box-shadow 0.35s var(--ease); }
  .drill-row::before { content: ""; position: absolute; left: -33px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--color-canvas); border: 2px solid var(--color-line-strong); transition: border-color 0.3s var(--ease), background 0.3s var(--ease); }
  .drill-row.is-on { opacity: 1; }
  .drill-row.is-on::before { border-color: var(--color-brand-600); background: var(--color-brand-600); }
  .drill-row.is-current { border-color: var(--color-brand-100); box-shadow: 0 0 0 3px var(--color-brand-50), var(--shadow-float); }
  .drill-row em { font-style: normal; font-size: 12px; color: var(--color-ink-500); }
  .drill-row strong { font-size: 14px; font-weight: 600; color: var(--color-ink-900); }
  .drill-row small { font: 500 13px var(--font-mono); color: var(--color-ink-700); }
  .context-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--color-brand-50); color: var(--color-brand-800); font-size: 13px; font-weight: 500; box-shadow: inset 0 0 0 1px var(--color-brand-100); }

  /* ---------- Closed loop ---------- */
  .loop { display: flex; flex-wrap: wrap; gap: 6px; }
  .loop li { display: flex; align-items: center; gap: 6px; padding: 6px 12px 6px 6px; border-radius: 999px; font-size: 13px; color: var(--color-ink-500); background: var(--color-surface); transition: background 0.3s var(--ease), color 0.3s var(--ease); }
  .loop li i { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font: 600 11px var(--font-mono); font-style: normal; background: var(--color-surface-2); transition: background 0.3s var(--ease), color 0.3s var(--ease); }
  .loop li.is-done { color: var(--color-accent-700); background: var(--color-accent-100); }
  .loop li.is-done i { color: #fff; background: var(--color-accent-600); }
  .loop li.is-active { color: var(--color-brand-700); background: var(--color-brand-50); }
  .loop li.is-active i { color: #fff; background: var(--color-brand-600); }
  .evidence { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 14px 0; border-top: 1px dashed var(--color-line); font-size: 14px; line-height: 1.65; color: var(--color-ink-700); }
  .evidence > span { display: inline-flex; gap: 6px; align-items: center; height: fit-content; font-size: 12px; font-weight: 600; color: var(--color-ink-900); }
  .evidence svg { width: 14px; height: 14px; color: var(--color-brand-600); }
  .audit li { display: grid; grid-template-columns: 44px 1fr; gap: 10px; padding: 8px 0; font-size: 13px; color: var(--color-ink-700); opacity: 0; transform: translateY(6px); transition: opacity 0.4s var(--ease), transform 0.4s var(--ease); }
  .audit li.is-on { opacity: 1; transform: none; }
  .audit time { font: 12px var(--font-mono); color: var(--color-ink-500); }

  /* ---------- Copilot demo ---------- */
  .ask { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--color-brand-50); font-size: 15px; color: var(--color-ink-900); }
  .ask .caret { display: inline-block; width: 2px; height: 1.1em; margin-left: 2px; vertical-align: -0.15em; background: var(--color-brand-600); animation: blink 1s steps(2) infinite; }
  .step { display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--color-line); font-size: 14px; opacity: 0.35; transition: opacity 0.35s var(--ease); }
  .step svg { width: 18px; height: 18px; color: var(--color-line-strong); transition: color 0.3s var(--ease); }
  .step small { font-size: 12px; color: var(--color-ink-500); }
  .step.is-on { opacity: 1; }
  .step.is-on svg { color: var(--color-accent-600); }
  .answer { opacity: 0; transform: translateY(8px); transition: opacity 0.5s var(--ease), transform 0.5s var(--ease); }
  .answer.is-on { opacity: 1; transform: none; }

  /* ---------- Six ones ---------- */
  .pillars { background: var(--color-navy-950); color: #fff; }
  .pillar { position: relative; padding: 28px 26px; border-radius: 18px; background: rgba(255, 255, 255, 0.035); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); transition: background 0.3s var(--ease), box-shadow 0.3s var(--ease); }
  .pillar:hover { background: rgba(255, 255, 255, 0.06); box-shadow: inset 0 0 0 1px rgba(108, 184, 255, 0.35); }
  .pillar-glyph { font-size: 52px; line-height: 1; font-weight: 600; color: #6CB8FF; letter-spacing: -0.02em; }
  .pillar h3 { margin-top: 18px; font-size: 18px; font-weight: 600; }
  .pillar p { margin-top: 6px; font-size: 14px; line-height: 1.7; color: rgba(255, 255, 255, 0.66); }
  .pillar-no { position: absolute; top: 22px; right: 24px; font: 12px var(--font-mono); color: rgba(255, 255, 255, 0.35); }

  /* ---------- Metrics & CTA ---------- */
  .metric b { display: block; font-size: 34px; font-weight: 600; letter-spacing: -0.02em; color: var(--color-ink-900); }
  .metric b sub { margin-left: 2px; font-size: 15px; font-weight: 500; color: var(--color-ink-500); vertical-align: baseline; }
  .metric span { display: block; margin-top: 4px; font-size: 13px; color: var(--color-ink-500); }
  .cta { position: relative; overflow: hidden; padding: 64px 28px; border-radius: 28px; text-align: center; background: var(--color-navy-950); color: #fff; }
  .cta .hero-grid { mask-image: radial-gradient(60% 80% at 50% 50%, #000 10%, transparent 75%); -webkit-mask-image: radial-gradient(60% 80% at 50% 50%, #000 10%, transparent 75%); }

  @keyframes sway { 0%, 100% { transform: rotate(1.2deg); } 50% { transform: rotate(-1.2deg); } }
  @keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
  @keyframes ripple { from { transform: scale(1); opacity: 0.9; } to { transform: scale(1.7); opacity: 0; } }
  @keyframes flow { to { left: 100%; } }
  @keyframes flow-y { to { top: 100%; } }
  @keyframes progress { to { width: 100%; } }
  @keyframes blink { to { visibility: hidden; } }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}
