/* ============================================================
   Xfence landing page: motion layer
   Loaded after site.css. Everything here is progressive enhancement:
   - hidden "before" states only exist under html.js, so no-JS visitors see all content
   - transform and opacity only (no layout-shifting properties)
   - prefers-reduced-motion switches every animation off and shows the final state
   ============================================================ */

@property --xf-a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

@keyframes xfRise    { from { opacity: 0; transform: translateY(18px); } }
@keyframes xfRiseLg  { from { opacity: 0; transform: translateY(32px) scale(.985); } }
@keyframes xfSpin    { to { --xf-a: 360deg; } }
@keyframes xfDrift1  { 0%,100% { transform: translate3d(0,0,0) scale(1); }   50% { transform: translate3d(60px,30px,0) scale(1.12); } }
@keyframes xfDrift2  { 0%,100% { transform: translate3d(0,0,0) scale(1.05); } 50% { transform: translate3d(-70px,-24px,0) scale(.94); } }
@keyframes xfDraw    { to { stroke-dashoffset: 0; } }
@keyframes xfSweep   { from { stroke-dashoffset: 1.14; } to { stroke-dashoffset: -.14; } }
@keyframes xfPop     { 0% { transform: translate(-50%,-50%) scale(0); } 70% { transform: translate(-50%,-50%) scale(1.35); } 100% { transform: translate(-50%,-50%) scale(1); } }
@keyframes xfPing    { from { opacity: .55; transform: translate(-50%,-50%) scale(1); } to { opacity: 0; transform: translate(-50%,-50%) scale(3.2); } }
@keyframes xfLabelIn { from { opacity: 0; transform: translate(-8px,-50%); } to { opacity: 1; transform: translate(0,-50%); } }
@keyframes xfBlink   { 50% { opacity: 0; } }
@keyframes xfLineIn  { from { opacity: 0; transform: translateY(4px); } }

/* ---- Scroll progress hairline ---- */
.xf-progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 250; pointer-events: none; }
.xf-progress i { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }

/* ---- Hero ---- */
.hero { position: relative; isolation: isolate; }
.hero > .wrap { position: relative; z-index: 1; }
.hero::before, .hero::after {
  content: ''; position: absolute; z-index: 0; pointer-events: none; border-radius: 50%; filter: blur(70px);
}
.hero::before { width: 520px; height: 520px; left: -140px; top: -200px; background: color-mix(in srgb, var(--accent) 12%, transparent); animation: xfDrift1 22s ease-in-out infinite; }
.hero::after  { width: 460px; height: 460px; right: -80px; top: -120px; background: color-mix(in srgb, var(--accent) 8%, transparent); animation: xfDrift2 28s ease-in-out infinite; }

.hero h1, .hero .lead, .hero-ctas { animation: xfRise .8s var(--ease) backwards; }
.hero h1      { animation-delay: .05s; }
.hero .lead   { animation-delay: .18s; }
.hero-ctas    { animation-delay: .3s; }
.hero .shot   { animation: xfRiseLg 1s var(--ease) .25s backwards; }

/* Slow light running around the hero screenshot and the quote form */
.hero .shot::after, .quote::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 2px; pointer-events: none;
  background: conic-gradient(from var(--xf-a), transparent 0 62%, color-mix(in srgb, var(--accent) 85%, transparent) 82%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: xfSpin 7s linear infinite;
}
.quote { position: relative; }

/* ---- Scroll reveal (hidden state only when JS is running) ---- */
html.js .rv { opacity: 0; }
html.js .rv.in { opacity: 1; animation: xfRise .75s var(--ease) var(--rv-d, 0ms) backwards; }

/* ---- Pointer spotlight on cards ---- */
.cell:not(.cell-c), .person { position: relative; }
.cell:not(.cell-c)::after, .person::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .3s var(--ease);
  background: radial-gradient(380px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent) 9%, transparent), transparent 62%);
}
@media (hover: hover) {
  .cell:not(.cell-c):hover::after, .person:hover::after { opacity: 1; }
}

/* ---- Walkthrough: activity log + timeline ---- */
.flow { margin-top: 80px; display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 48px; align-items: center; }
.flow-head { grid-column: 1 / -1; margin-bottom: -16px; }
.flow-head .eyebrow { margin-bottom: 8px; }
.flow-head h3 { font-size: clamp(1.4rem, 2.2vw, 1.75rem); letter-spacing: -.03em; font-weight: 600; }
.term { background: #0A1224; border: 1px solid #1E2B46; border-radius: var(--r-card); box-shadow: var(--shadow-3); overflow: hidden; }
.term-bar { display: flex; align-items: center; gap: 7px; padding: 13px 16px; border-bottom: 1px solid #1E2B46; }
.term-bar i { width: 10px; height: 10px; border-radius: 50%; background: #2A3A5C; }
.term-bar span { margin-left: 8px; font-family: var(--font-mono); font-size: 12px; letter-spacing: .04em; color: #7F90B0; }
.term-body { padding: 20px 22px 24px; min-height: 238px; font-family: var(--font-mono); font-size: 13.5px; line-height: 1.75; color: #D5DEEE; }
.tline { display: block; animation: xfLineIn .25s var(--ease); }
.tline + .tline { margin-top: 6px; }
.tg { display: inline-block; min-width: 64px; margin-right: 12px; padding: 0 7px; border-radius: 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-align: center; color: #0A1224; background: #8AA2FF; }
.tg-invite { background: #9CC2FF; } .tg-report { background: #F2A66B; } .tg-triage { background: #6CC495; } .tg-fix { background: #C8D3EA; }
/* Dark theme: the terminal takes the page's own near-black and neon signal */
:root[data-theme="dark"] .term { background: var(--surface); border-color: var(--line); }
:root[data-theme="dark"] .term-bar { border-bottom-color: var(--line); }
:root[data-theme="dark"] .term-bar i { background: var(--line-2); }
:root[data-theme="dark"] .term-bar span { color: var(--ink-2); }
:root[data-theme="dark"] .term-body { color: var(--ink); }
:root[data-theme="dark"] .tg { background: var(--accent); color: var(--accent-ink); }
:root[data-theme="dark"] .tg-invite { background: #BBCFEA; } :root[data-theme="dark"] .tg-report { background: #F0683F; }
:root[data-theme="dark"] .caret { background: var(--accent); }
.caret { display: inline-block; width: 8px; height: 1.05em; margin-left: 2px; vertical-align: -2px; background: #8AA2FF; animation: xfBlink 1s steps(1) infinite; }

.tl { list-style: none; position: relative; display: flex; flex-direction: column; gap: 22px; margin: 0; padding: 0; }
.tl::before { content: ''; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 1px; background: var(--line-2); }
.tl li { position: relative; display: grid; grid-template-columns: 16px 1fr; gap: 16px; opacity: .45; transition: opacity .4s var(--ease); }
.tl li.on { opacity: 1; }
.tl-dot { position: relative; z-index: 1; width: 15px; height: 15px; margin-top: 4px; border-radius: 50%; background: var(--canvas); border: 2px solid var(--line-2); transition: border-color .3s var(--ease), background .3s var(--ease), box-shadow .3s var(--ease); }
.sec-surface .tl-dot { background: var(--surface); }
.tl li.on .tl-dot { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 18%, transparent); }
.tl strong { display: block; font-size: 16px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
.tl span.d { display: block; font-size: 14.5px; color: var(--ink-2); line-height: 1.5; margin-top: 2px; }
.flow-note { grid-column: 1 / -1; font-size: 13.5px; color: var(--ink-3); margin-top: -16px; }

/* ---- Branching diagram (features) ---- */
.tree { position: relative; height: 210px; max-width: 460px; margin-top: 44px; }
.tree svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.tree path { fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.tree .tp { stroke: color-mix(in srgb, var(--ink-3) 55%, transparent); stroke-width: 1.5; }
.tree .ts { stroke: var(--accent); stroke-width: 2; stroke-dasharray: .14 1.14; stroke-dashoffset: 1.14; }
.tree-root { position: absolute; left: 0; width: 27%; top: 50%; transform: translateY(-50%); text-align: right; font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .02em; color: var(--ink); line-height: 1.3; }
.tdot { position: absolute; width: 11px; height: 11px; border-radius: 50%; transform: translate(-50%,-50%); }
.tdot-root { left: 31%; top: 50%; background: var(--accent); }
.tdot-root::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--accent); }
.tdot-end { left: 52%; background: var(--surface); border: 2px solid var(--accent); }
.sec-surface .tdot-end { background: var(--surface-2); }
.tlabel { position: absolute; left: calc(52% + 18px); right: 0; transform: translateY(-50%); font-size: 14.5px; font-weight: 550; color: var(--ink); line-height: 1.25; letter-spacing: -.005em; }
.tlabel .material-icons { font-size: 17px; vertical-align: -3px; margin-left: 4px; color: var(--ok); }
.t1 { top: 16.7%; } .t2 { top: 50%; } .t3 { top: 83.3%; }

html.js .tree .tp { stroke-dasharray: 1; stroke-dashoffset: 1; }
html.js .tree .tdot-end, html.js .tree .tlabel { opacity: 0; }
html.js .tree .tdot-root { transform: translate(-50%,-50%) scale(0); }
html.js .tree.in .tdot-root { animation: xfPop .5s var(--ease) forwards; }
html.js .tree.in .tdot-root::after { animation: xfPing 2.6s ease-out 1.2s infinite; }
html.js .tree.in .tp { animation: xfDraw .9s var(--ease) forwards; }
html.js .tree.in .tp1 { animation-delay: .35s; } html.js .tree.in .tp2 { animation-delay: .55s; } html.js .tree.in .tp3 { animation-delay: .75s; }
html.js .tree.in .tdot-end { animation: xfPop .45s var(--ease) forwards; opacity: 1; }
html.js .tree.in .e1 { animation-delay: 1.15s; } html.js .tree.in .e2 { animation-delay: 1.35s; } html.js .tree.in .e3 { animation-delay: 1.55s; }
html.js .tree.in .tlabel { animation: xfLabelIn .55s var(--ease) forwards; }
html.js .tree.in .t1 { animation-delay: 1.2s; } html.js .tree.in .t2 { animation-delay: 1.4s; } html.js .tree.in .t3 { animation-delay: 1.6s; }
html.js .tree.in .ts { animation: xfSweep 3.2s linear 2.2s infinite; }
html.js .tree.in .ts2 { animation-delay: 2.7s; } html.js .tree.in .ts3 { animation-delay: 3.2s; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .flow { grid-template-columns: 1fr; gap: 32px; margin-top: 56px; }
  .flow-head { margin-bottom: 0; } .flow-note { margin-top: 0; }
  .hero::before { width: 360px; height: 360px; } .hero::after { width: 320px; height: 320px; }
}
@media (max-width: 560px) {
  .term-body { padding: 16px 16px 20px; font-size: 12.5px; min-height: 270px; }
  .tg { min-width: 56px; margin-right: 8px; }
  .tree { margin-top: 32px; }
}

/* ---- Reduced motion: show the finished state, run nothing ---- */
@media (prefers-reduced-motion: reduce) {
  .hero::before, .hero::after, .hero h1, .hero .lead, .hero-ctas, .hero .shot { animation: none !important; }
  .hero .shot::after, .quote::after { animation: none !important; background: none; }
  html.js .rv, html.js .rv.in { opacity: 1; animation: none; }
  html.js .tree .tp, html.js .tree.in .tp { stroke-dashoffset: 0; animation: none; }
  html.js .tree .ts { display: none; }
  html.js .tree .tdot-end, html.js .tree .tlabel { opacity: 1; animation: none !important; }
  html.js .tree .tdot-root { transform: translate(-50%,-50%); animation: none !important; }
  html.js .tree .tdot-root::after { animation: none !important; }
  .caret { animation: none; }
  .tl li, .tl-dot { transition: none; }
  .xf-progress { display: none; }
}
@media print {
  html.js .rv { opacity: 1; } .xf-progress { display: none; }
}

/* ============================================================
   Hero illustration: a scan sweeping over the product's attack surface
   ============================================================ */
@keyframes hvSpin { to { transform: rotate(360deg); } }
@keyframes hvPing {
  0%   { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  10%  { box-shadow: 0 0 0 12px transparent; }
  35%, 100% { background: var(--surface); border-color: var(--line-2); box-shadow: 0 0 0 0 transparent; }
}
@keyframes hvHit {
  0%   { background: var(--high); border-color: var(--high); box-shadow: 0 0 0 0 color-mix(in srgb, var(--high) 60%, transparent); }
  12%  { box-shadow: 0 0 0 14px transparent; }
  55%  { background: var(--high); border-color: var(--high); box-shadow: 0 0 0 0 transparent; }
  75%, 100% { background: var(--surface); border-color: var(--line-2); }
}
@keyframes hvLabel { 0% { color: var(--ink); } 35%, 100% { color: var(--ink-2); } }
@keyframes hvCore { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 35%, transparent); } 50% { box-shadow: 0 0 0 14px transparent; } }

.hv { position: relative; width: 100%; max-width: 470px; aspect-ratio: 1 / 1; margin: 0 0 0 auto; }
.hv-radar { position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--accent) 11%, transparent) 0, transparent 68%), var(--surface);
  border: 1px solid var(--line-2); box-shadow: var(--shadow-2); overflow: hidden; }
.hv-rings { position: absolute; inset: 0; width: 100%; height: 100%; }
.hv-rings circle, .hv-rings line { fill: none; stroke: var(--line-2); stroke-width: 1; vector-effect: non-scaling-stroke; }
.hv-rings circle { stroke-dasharray: 3 5; }
.hv-rings .hv-outer { stroke-dasharray: none; stroke: transparent; }
.hv-sweep { position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg 290deg, color-mix(in srgb, var(--accent) 8%, transparent) 320deg, color-mix(in srgb, var(--accent) 34%, transparent) 359deg, transparent 360deg);
  animation: hvSpin 6s linear infinite; }
.hv-core { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; }
.hv-core span { display: inline-block; padding: 9px 15px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 13.5px; font-weight: 600; white-space: nowrap; animation: hvCore 3s ease-out infinite; }
.hv-node { position: absolute; z-index: 2; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .02em; color: var(--ink-2); white-space: nowrap; animation: hvLabel 6s linear var(--d, 0s) infinite; }
.hv-dot { width: 13px; height: 13px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-2); animation: hvPing 6s linear var(--d, 0s) infinite; }
.hv-node.is-hit .hv-dot { animation-name: hvHit; }
.hv-term { position: absolute; left: -36px; bottom: -34px; width: min(330px, 72%); z-index: 3; }
.hv-term .term-body { min-height: 132px; font-size: 12px; line-height: 1.65; padding: 12px 14px 14px; }
.hv-term .tg { min-width: 56px; margin-right: 8px; }

/* Trust numbers right under the hero */
.stats-band { padding: 8px 0 8px; }
.stats-band .stats { margin-top: 0; }

@media (max-width: 900px) {
  .hv { margin: 8px auto 0; max-width: 420px; aspect-ratio: auto; }
  .hv-radar { position: relative; inset: auto; aspect-ratio: 1 / 1; }
  .hv-term { position: relative; left: auto; bottom: auto; transform: none; width: 100%; margin-top: -24px; }
}
@media (max-width: 560px) {
  .hv-node { font-size: 11px; }
  .hv-core span { font-size: 12.5px; padding: 8px 12px; }
  .stats-band .stats { grid-template-columns: 1fr 1fr; }
  .stats-band .stat:nth-child(3) { border-left: 0; }
  .stats-band .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  .hv-sweep { display: none; }
  .hv-node, .hv-dot, .hv-core span { animation: none !important; }
  .hv-node.is-hit .hv-dot { background: var(--high); border-color: var(--high); }
}

/* Dark theme: neon lime is loud, so the radar sweep is a little softer than in light mode */
:root[data-theme="dark"] .hv-sweep { background: conic-gradient(from 0deg, transparent 0deg 290deg, color-mix(in srgb, var(--accent) 6%, transparent) 320deg, color-mix(in srgb, var(--accent) 24%, transparent) 359deg, transparent 360deg); }
