/* Motion for the whole site. Everything here is decoration: content stays visible
   if an animation is unsupported, and all of it stops under prefers-reduced-motion. */

/* Animated AI network behind page heroes (drawn by ai-motion.js) */
.ai-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: .7; -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent); mask-image: linear-gradient(to bottom, #000 70%, transparent); }
.has-ai-canvas { position: relative; }
.has-ai-canvas > :not(.ai-canvas) { position: relative; z-index: 1; }

/* Typing word in the home page headline */
.hero-rotate::after { content: ""; display: inline-block; width: 3px; height: .85em; margin-left: 6px; vertical-align: -.06em; background: var(--gold); animation: caret 1s steps(2) infinite; }
@keyframes caret { 50% { opacity: 0; } }

/* Sections rise in as they scroll into view */
@supports (animation-timeline: view()) {
  .reveal, .service-card, .tile, .academy-course, .academy-steps li, .impact article, .ai-card, .ai-spot, .tutorial-card, .tutorial-step, .project-card, .credential-card {
    animation: rise-in linear backwards;
    animation-timeline: view();
    animation-range: entry 0% entry 35%;
  }
}
@keyframes rise-in { from { opacity: 0; transform: translateY(36px); } }

/* Cards light up on hover */
.service-card, .ai-card, .tutorial-card, .academy-course, .tile { transition: transform .3s, border-color .3s, box-shadow .3s; }
.service-card:hover, .ai-card:hover, .tutorial-card:hover { transform: translateY(-5px); border-color: rgba(201,168,106,.55); box-shadow: 0 18px 50px rgba(201,168,106,.09); }

/* A light sweep across gold buttons */
.button.gold { position: relative; overflow: hidden; }
.button.gold::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 35%, rgba(255,255,255,.45) 50%, transparent 65%); transform: translateX(-120%); pointer-events: none; }
.button.gold:hover::after { animation: sweep .8s ease; }
@keyframes sweep { to { transform: translateX(120%); } }

/* Eyebrow line and signal band */
.eyebrow span { flex: 0 0 28px; }
.signal-grid i { animation: diamond 2.4s ease-in-out infinite; }
.signal-grid i:nth-of-type(2) { animation-delay: .4s; }
.signal-grid i:nth-of-type(3) { animation-delay: .8s; }
@keyframes diamond { 50% { transform: rotate(225deg) scale(1.9); box-shadow: 0 0 12px var(--gold); } }

/* AI section */
.ai-section { padding-block: 110px; border-bottom: 1px solid var(--line); }
.ai-head { display: flex; justify-content: space-between; align-items: end; gap: 60px; margin-bottom: 48px; }
.ai-head h2 { margin: 0; }
.ai-head p { max-width: 420px; margin: 0; color: var(--muted); }

/* Workflow: each step lights up in turn while a dot travels to the next */
.ai-flow { --beat: 1.3s; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; margin-bottom: 14px; padding: 0; list-style: none; }
.ai-flow-step { position: relative; margin-right: 30px; padding: 20px 16px; background: var(--surface); border: 1px solid var(--line); animation: flow-node calc(var(--beat) * var(--n)) linear infinite; animation-delay: calc(var(--beat) * var(--i)); }
.ai-flow-step:last-child { margin-right: 0; }
.ai-flow-step b { display: block; color: var(--light); font: 600 15px/1.3 var(--display); }
.ai-flow-step small { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.ai-flow-step:not(:last-child)::before { content: ""; position: absolute; left: 100%; top: 50%; width: 30px; height: 1px; background: rgba(201,168,106,.35); }
.ai-flow-step:not(:last-child)::after { content: ""; position: absolute; left: 100%; top: 50%; width: 7px; height: 7px; margin-top: -3px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px var(--gold); opacity: 0; animation: flow-dot calc(var(--beat) * var(--n)) linear infinite; animation-delay: calc(var(--beat) * var(--i)); }
@keyframes flow-node { 0%, 28%, 100% { border-color: var(--line); box-shadow: none; } 6%, 18% { border-color: var(--gold); box-shadow: 0 0 26px rgba(201,168,106,.22); } }
@keyframes flow-dot { 0%, 14% { opacity: 0; transform: translateX(0); } 16% { opacity: 1; transform: translateX(0); } 26% { opacity: 1; transform: translateX(24px); } 28%, 100% { opacity: 0; transform: translateX(24px); } }
@media (max-width: 900px) {
  .ai-flow { grid-auto-flow: row; }
  .ai-flow-step { margin: 0 0 28px; }
  .ai-flow-step:last-child { margin-bottom: 0; }
  .ai-flow-step:not(:last-child)::before { left: 50%; top: 100%; width: 1px; height: 28px; }
  .ai-flow-step:not(:last-child)::after { left: 50%; top: 100%; margin: 0 0 0 -3px; animation-name: flow-dot-down; }
  @keyframes flow-dot-down { 0%, 14% { opacity: 0; transform: translateY(0); } 16% { opacity: 1; transform: translateY(0); } 26% { opacity: 1; transform: translateY(22px); } 28%, 100% { opacity: 0; transform: translateY(22px); } }
}

/* Service cards with a live visual */
.ai-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
.ai-card { display: flex; flex-direction: column; padding: 28px; background: linear-gradient(145deg, var(--surface), #101c30); border: 1px solid var(--line); color: inherit; text-decoration: none; }
.ai-visual { display: grid; place-items: center; height: 170px; margin-bottom: 24px; background: #0b1424; border: 1px solid var(--line); overflow: hidden; }
.ai-card h3 { margin: 0 0 10px; font: 500 23px/1.25 var(--display); letter-spacing: -.02em; }
.ai-card p { margin: 0 0 20px; color: var(--muted); font-size: 15px; line-height: 1.6; }
.ai-card .ai-more { margin-top: auto; color: var(--gold); font-size: 14px; }
@media (max-width: 1000px) { .ai-cards { grid-template-columns: 1fr; } .ai-head { display: block; } .ai-head p { margin-top: 16px; } }
@media (max-width: 600px) { .ai-section { padding-block: 72px; } }

/* Server rack */
.rack { display: grid; gap: 7px; width: 190px; }
.rack-unit { display: flex; align-items: center; gap: 7px; height: 26px; padding: 0 10px; background: #15233b; border: 1px solid rgba(255,255,255,.14); }
.rack-unit i { width: 7px; height: 7px; border-radius: 50%; background: #65d39b; animation: led 1.4s steps(2) infinite; }
.rack-unit i:nth-child(2) { background: var(--gold); animation-duration: .9s; }
.rack-unit:nth-child(2) i { animation-delay: .35s; }
.rack-unit:nth-child(3) i { animation-delay: .7s; }
.rack-unit:nth-child(4) i { animation-delay: 1s; }
.rack-unit span { flex: 1; height: 5px; margin-left: 6px; background: rgba(255,255,255,.08); overflow: hidden; }
.rack-unit span::after { content: ""; display: block; width: 45%; height: 100%; background: linear-gradient(90deg, transparent, var(--gold)); animation: activity 2.2s ease-in-out infinite; }
.rack-unit:nth-child(2) span::after { animation-delay: .6s; }
.rack-unit:nth-child(3) span::after { animation-delay: 1.1s; }
.rack-unit:nth-child(4) span::after { animation-delay: 1.6s; }
@keyframes led { 50% { opacity: .25; } }
@keyframes activity { from { transform: translateX(-110%); } to { transform: translateX(240%); } }

/* Directory tree and neural network drawings */
.motion-svg { width: 100%; height: 100%; }
.motion-svg text { fill: var(--light); font: 500 12px var(--sans); text-anchor: middle; }
.motion-svg .box { fill: #15233b; stroke: rgba(201,168,106,.55); }
.motion-svg .wire { fill: none; stroke: rgba(201,168,106,.55); stroke-width: 1.2; stroke-dasharray: 4 6; animation: wire-flow 1.1s linear infinite; }
.motion-svg .dot { fill: var(--gold); animation: dot-pulse 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.motion-svg .d2 { animation-delay: .4s; } .motion-svg .d3 { animation-delay: .8s; } .motion-svg .d4 { animation-delay: 1.2s; } .motion-svg .d5 { animation-delay: 1.6s; } .motion-svg .d6 { animation-delay: 2s; }
@keyframes wire-flow { to { stroke-dashoffset: -10; } }
@keyframes dot-pulse { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.25); } }

/* Services page spotlight */
.ai-spot { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 48px; align-items: center; padding: 36px; margin-bottom: 12px; background: linear-gradient(145deg, var(--surface), #101c30); border: 1px solid var(--line); scroll-margin-top: calc(var(--nav-h) + 16px); }
.ai-spot .ai-visual { height: 240px; margin: 0; }
.ai-spot h2 { margin: 0 0 12px; font-size: clamp(26px, 3vw, 38px); letter-spacing: -.03em; }
.ai-spot p { margin: 0 0 18px; color: var(--muted); }
.ai-spot ul { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; margin: 0 0 24px; padding: 0; list-style: none; font-size: 14px; }
.ai-spot li { display: flex; gap: 10px; }
.ai-spot li::before { content: "✓"; color: var(--gold); }
.ai-spot-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
@media (max-width: 900px) {
  .ai-spot { grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 22px; }
  .ai-spot ul { grid-template-columns: 1fr; }
}

/* Tutorials */
.tutorial-search { width: 100%; min-height: 50px; margin: 0 0 14px; }
.tutorial-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.tutorial-filters button { min-height: 42px; padding: 0 16px; background: none; border: 1px solid var(--line); color: var(--muted); font: 500 14px var(--sans); cursor: pointer; transition: color .2s, border-color .2s, background .2s; }
.tutorial-filters button:hover { border-color: var(--gold); color: var(--gold); }
.tutorial-filters button[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #101827; }
.tutorial-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tutorial-card { display: flex; flex-direction: column; padding: 28px; background: linear-gradient(145deg, var(--surface), #101c30); border: 1px solid var(--line); color: inherit; text-decoration: none; }
.tutorial-tag { align-self: flex-start; margin-bottom: 18px; padding: 5px 9px; border: 1px solid rgba(201,168,106,.35); color: var(--gold); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.tutorial-card h3 { margin: 0 0 10px; font: 500 22px/1.3 var(--display); letter-spacing: -.02em; }
.tutorial-card p { margin: 0 0 20px; color: var(--muted); font-size: 15px; line-height: 1.6; }
.tutorial-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: auto; color: var(--muted); font-size: 13px; }
.tutorial-meta b { margin-left: auto; color: var(--gold); font-weight: 500; }
@media (max-width: 1000px) { .tutorial-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .tutorial-grid { grid-template-columns: 1fr; } }

.tutorial-progress { position: fixed; top: var(--nav-h); left: 0; right: 0; z-index: 90; height: 2px; background: var(--gold); transform-origin: left; transform: scaleX(0); }
@supports (animation-timeline: scroll()) {
  .tutorial-progress { animation: read-progress linear both; animation-timeline: scroll(root); }
}
@keyframes read-progress { to { transform: scaleX(1); } }
.tutorial-body { width: min(860px, calc(100% - 48px)); margin-inline: auto; }
.tutorial-flow { margin-bottom: 48px; }
.tutorial-flow .ai-flow { --beat: 1.1s; }
.tutorial-box { margin-bottom: 44px; padding: 22px 24px; border: 1px solid var(--line); background: var(--surface); }
.tutorial-box h2 { margin: 0 0 10px; font-size: 20px; letter-spacing: -.02em; }
.tutorial-box ul { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.8; }
.tutorial-steps { margin: 0; padding: 0; list-style: none; }
.tutorial-step { position: relative; padding: 0 0 44px 58px; }
.tutorial-step::before { content: ""; position: absolute; left: 18px; top: 40px; bottom: 0; width: 1px; background: linear-gradient(var(--gold), var(--line)); }
.tutorial-step:last-child::before { display: none; }
.tutorial-num { position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 37px; height: 37px; border: 1px solid var(--gold); color: var(--gold); font: 400 15px var(--serif); }
.tutorial-step h2 { margin: 4px 0 12px; font-size: clamp(21px, 2.4vw, 27px); letter-spacing: -.02em; line-height: 1.25; }
.tutorial-step p { margin: 0 0 14px; color: var(--muted); line-height: 1.75; }
.tutorial-note { margin: 0 0 14px; padding: 12px 14px; border-left: 2px solid var(--gold); background: rgba(201,168,106,.08); color: #e5c992; font-size: 14px; line-height: 1.6; }
.code-block { position: relative; margin: 0 0 14px; background: #080e18; border: 1px solid var(--line); }
.code-block pre { margin: 0; padding: 18px; overflow-x: auto; color: #dbe3ee; font: 13px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; }
.code-copy { position: absolute; top: 8px; right: 8px; padding: 5px 10px; background: var(--surface); border: 1px solid var(--line); color: var(--gold); font: 500 12px var(--sans); cursor: pointer; }
.code-copy:hover { border-color: var(--gold); }
.tutorial-cta { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 20px; margin-top: 12px; padding: 32px; background: linear-gradient(135deg, #172641, #101a2c); border: 1px solid var(--line); }
.tutorial-cta h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.02em; }
.tutorial-cta p { margin: 0; color: var(--muted); }
.tutorial-next { display: block; margin-top: 12px; padding: 22px 24px; border: 1px solid var(--line); color: inherit; text-decoration: none; transition: border-color .2s; }
.tutorial-next:hover { border-color: var(--gold); }
.tutorial-next small { color: var(--muted); font-size: 13px; }
.tutorial-next b { display: block; margin-top: 4px; color: var(--gold); font: 500 18px var(--display); }
@media (max-width: 600px) {
  .tutorial-body { width: min(100% - 32px, 860px); }
  .tutorial-step { padding-left: 0; }
  .tutorial-step::before { display: none; }
  .tutorial-num { position: static; margin-bottom: 12px; }
  .tutorial-cta { padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .tutorial-progress { display: none; }
  .hero-rotate::after { display: none; }
}
