/* Cristaline Tech — homepage v2 (scroll-driven sequence). Loads after styles.css. */
:root {
  --bg: #f1f3f4;
  --bg-2: #e8ebed;
  --ink: #0b0e11;
  --ink-2: #3a4148;
  --mute: #737b83;
  --hair: rgba(11, 14, 17, 0.1);
  --hair-2: rgba(11, 14, 17, 0.2);
  --glass: rgba(255, 255, 255, 0.55);
  --accent: oklch(62% 0.15 195);
  --night: #07090b;
  --night-2: #0f1316;
  --night-line: rgba(255, 255, 255, 0.09);
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display: 'Sora', system-ui, sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --gut: clamp(16px, 4vw, 56px);
}

body.home { background: var(--bg); color: var(--ink); overflow-x: hidden; }
.home a:hover { color: inherit; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 var(--gut); }

/* ---------- loader ---------- */
.loadbar { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 60; pointer-events: none; }
.loadbar span { display: block; height: 100%; width: 0; background: var(--ink); transition: width .3s ease, opacity .6s ease .4s; }
.loadbar.done span { opacity: 0; }

/* ---------- nav ---------- */
.hnav { position: fixed; top: 14px; left: 0; right: 0; z-index: 50; padding: 0 var(--gut); pointer-events: none; }
.hnav-inner {
  pointer-events: auto; max-width: 1240px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 10px 10px 10px 20px; border-radius: 100px;
  background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 10px 30px -18px rgba(11, 14, 17, 0.35), inset 0 0 0 1px var(--hair);
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  transition: background .4s ease, box-shadow .4s ease;
}
.hnav.on-dark .hnav-inner { background: rgba(15, 19, 22, 0.6); border-color: rgba(255, 255, 255, 0.08); box-shadow: inset 0 0 0 1px var(--night-line); }
.hnav.on-dark .brand, .hnav.on-dark .hnav-links a { color: #e9edf0; }
.hnav.on-dark .hbtn-dark { background: #f4f6f7; color: var(--ink); }
.hnav.on-dark .hbtn-dark:hover { background: var(--accent); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-family: var(--display); font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.hnav-links { display: flex; gap: 30px; }
.hnav-links a { font-size: 13.5px; font-weight: 500; color: var(--ink-2); position: relative; }
.hnav-links a::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease); }
.hnav-links a:hover::after { transform: scaleX(1); }

/* ---------- buttons ---------- */
.hbtn {
  display: inline-flex; align-items: center; gap: 10px; white-space: nowrap;
  padding: 12px 20px; border-radius: 100px; font-size: 14px; font-weight: 600;
  border: 1px solid transparent; transition: transform .2s ease, background .3s ease, color .3s ease, border-color .3s ease;
}
.hbtn:active { transform: scale(.97); }
.hbtn .arr { transition: transform .3s var(--ease); }
.hbtn:hover .arr { transform: translateX(3px); }
.hbtn-dark { background: var(--ink); color: #fff; }
.hbtn-dark:hover { background: var(--accent); color: #fff; }
.hbtn-glass { background: var(--glass); color: var(--ink); border-color: var(--hair-2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.hbtn-glass:hover { border-color: var(--ink); color: var(--ink); }

/* ---------- type ---------- */
.kicker { display: flex; align-items: center; gap: 12px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); }
.kicker .idx { color: var(--accent); }
.kicker::after { content: ""; width: 48px; height: 1px; background: var(--hair-2); }
.display { font-family: var(--display); font-weight: 300; font-size: clamp(46px, 7.2vw, 108px); line-height: .95; letter-spacing: -0.045em; color: var(--ink); }
.display em, .title em { font-style: normal; font-weight: 600; }
.display.sm { font-size: clamp(42px, 6vw, 88px); }
.title { font-family: var(--display); font-weight: 300; font-size: clamp(34px, 4.4vw, 62px); line-height: 1; letter-spacing: -0.04em; }
.lede { font-size: 17px; line-height: 1.6; color: var(--ink-2); max-width: 470px; }
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

/* ---------- sequence ---------- */
.seq { position: relative; height: 560vh; }
.seq .anchor { position: absolute; left: 0; width: 1px; height: 1px; }
.seq-stage { position: sticky; top: 0; height: 100vh; height: 100lvh; overflow: hidden; background: var(--bg) url(frames/sd/f001.webp) 72% center / cover no-repeat; }
.seq-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.seq-veil {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(241, 243, 244, .92) 0%, rgba(241, 243, 244, .55) 34%, rgba(241, 243, 244, 0) 58%),
    linear-gradient(0deg, rgba(241, 243, 244, .9) 0%, rgba(241, 243, 244, 0) 22%);
}
/* faint scanline grain for a screen-like texture */
.seq-stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .35; mix-blend-mode: multiply;
  background: repeating-linear-gradient(0deg, rgba(11, 14, 17, .025) 0 1px, transparent 1px 3px);
}

.chapter {
  position: absolute; z-index: 3; left: var(--gut); top: 50%;
  width: min(560px, 46vw); display: flex; flex-direction: column; gap: 24px;
  transform: translateY(-50%);
}
.js .chapter { opacity: 0; visibility: hidden; will-change: opacity, transform; }
.js .chapter.live { visibility: visible; }
.ch-hero { gap: 28px; width: min(640px, 52vw); }

.tagline { list-style: none; margin: 6px 0 0; padding: 18px 0 0; border-top: 1px solid var(--hair); display: flex; flex-wrap: wrap; gap: 8px 22px; }
.tagline li { font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.tagline li::before { content: "/ "; color: var(--accent); }

.scroll-cue { position: fixed; display: none; }
.js .scroll-cue { display: flex; position: absolute; top: calc(100% + 8vh); left: 0; align-items: center; gap: 12px; font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); }
.scroll-cue span { width: 1px; height: 36px; background: var(--hair-2); position: relative; overflow: hidden; }
.scroll-cue span::after { content: ""; position: absolute; left: 0; top: -40%; width: 1px; height: 40%; background: var(--ink); animation: cue 1.8s var(--ease) infinite; }
@keyframes cue { to { top: 100%; } }

.caps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--hair); }
.caps li { padding: 14px 18px 14px 0; border-bottom: 1px solid var(--hair); display: flex; flex-direction: column; gap: 4px; counter-increment: cap; }
.caps li:nth-child(odd) { border-right: 1px solid var(--hair); }
.caps li:nth-child(even) { padding-left: 18px; }
.caps b { font-family: var(--display); font-weight: 600; font-size: 14.5px; display: flex; gap: 8px; }
.caps b::before { content: counter(cap, decimal-leading-zero); font-family: var(--mono); font-weight: 400; font-size: 10.5px; color: var(--accent); padding-top: 3px; }
.caps span { font-size: 13px; line-height: 1.45; color: var(--mute); }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.steps li { display: grid; grid-template-columns: 52px 1fr; gap: 8px; padding: 16px 0; border-top: 1px solid var(--hair); }
.steps li:last-child { border-bottom: 1px solid var(--hair); }
.steps .n { font-family: var(--mono); font-size: 12px; color: var(--accent); padding-top: 4px; }
.steps b { font-family: var(--display); font-weight: 600; font-size: 18px; letter-spacing: -0.01em; }
.steps p { font-size: 14px; line-height: 1.55; color: var(--ink-2); margin-top: 4px; }
.chip { align-self: flex-start; display: inline-flex; gap: 10px; align-items: baseline; padding: 10px 16px; border-radius: 100px; background: var(--glass); border: 1px solid var(--hair-2); font-size: 13px; color: var(--ink-2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.chip b { font-family: var(--display); color: var(--ink); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); }
.stats > div { padding: 22px 16px 22px 0; display: flex; flex-direction: column; gap: 6px; }
.stats > div + div { padding-left: 18px; border-left: 1px solid var(--hair); }
.stats b { white-space: nowrap; font-family: var(--display); font-weight: 300; font-size: clamp(30px, 3.3vw, 48px); letter-spacing: -0.04em; line-height: 1; }
.stats span { font-size: 13px; color: var(--mute); line-height: 1.35; }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.hud-corner { position: absolute; width: 18px; height: 18px; border: 0 solid var(--hair-2); }
.hud-corner.tl { top: 92px; left: var(--gut); border-top-width: 1px; border-left-width: 1px; }
.hud-corner.tr { top: 92px; right: var(--gut); border-top-width: 1px; border-right-width: 1px; }
.hud-corner.bl { bottom: 24px; left: var(--gut); border-bottom-width: 1px; border-left-width: 1px; }
.hud-corner.br { bottom: 24px; right: var(--gut); border-bottom-width: 1px; border-right-width: 1px; }
.hud-meta { position: absolute; bottom: 30px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; color: var(--mute); display: flex; align-items: center; gap: 8px; }
.hud-meta b { color: var(--ink); font-weight: 500; }
.hud-left { left: calc(var(--gut) + 28px); }
.hud-right { right: calc(var(--gut) + 28px); }
.hud .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: ping 2.4s ease-out infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 oklch(62% 0.15 195 / .5); } 80%, 100% { box-shadow: 0 0 0 8px oklch(62% 0.15 195 / 0); } }

.rail { position: absolute; right: calc(var(--gut) + 6px); top: 50%; transform: translateY(-50%); list-style: none; margin: 0; padding: 0 0 0 0; display: flex; flex-direction: column; gap: 34px; text-align: right; }
.rail::before { content: ""; position: absolute; right: -14px; top: 4px; bottom: 4px; width: 1px; background: var(--hair-2); }
.rail-fill { position: absolute; right: -14px; top: 4px; width: 1px; height: calc(100% - 8px); background: var(--ink); transform-origin: top; transform: scaleY(0); }
.rail li { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); transition: color .4s ease, opacity .4s ease; opacity: .55; position: relative; }
.rail li span { margin-right: 6px; }
.rail li em { font-style: normal; display: inline-block; opacity: 0; transform: translateX(6px); transition: opacity .4s ease, transform .4s var(--ease); }
.rail li.active em { opacity: 1; transform: none; }
.rail li::after { content: ""; position: absolute; right: -17px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: var(--bg); border: 1px solid var(--hair-2); transition: background .4s ease, border-color .4s ease; }
.rail li.active { color: var(--ink); opacity: 1; }
.rail li.active::after { background: var(--accent); border-color: var(--accent); }

/* ---------- portfolio (dark) ---------- */
.portfolio { position: relative; background: var(--night); color: #e9edf0; padding: clamp(96px, 14vw, 168px) 0 clamp(80px, 12vw, 140px); overflow: hidden; }
.portfolio::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .6;
  background-image: linear-gradient(var(--night-line) 1px, transparent 1px), linear-gradient(90deg, var(--night-line) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, #000 0%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, #000 0%, transparent 75%);
}
.portfolio::after { content: ""; position: absolute; left: 50%; top: -280px; width: 900px; height: 560px; margin-left: -450px; background: radial-gradient(closest-side, oklch(62% 0.15 195 / .22), transparent); pointer-events: none; }
.portfolio .wrap { position: relative; z-index: 1; }
.sec-head { display: flex; flex-direction: column; gap: 22px; margin-bottom: 64px; max-width: 640px; }
.kicker.light { color: #aab3ba; }
.kicker.light::after { background: var(--night-line); }
.title.light { color: #f4f6f7; }
.lede.light { color: #9aa3aa; }

.pf-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.pf-card {
  position: relative; display: flex; flex-direction: column; gap: 18px; padding: 28px;
  border-radius: 20px; background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.015));
  border: 1px solid var(--night-line); color: #e9edf0;
  transition: transform .5s var(--ease), border-color .4s ease, background .4s ease;
}
a.pf-card:hover { transform: translateY(-6px); border-color: rgba(255,255,255,.22); color: #e9edf0; }
.pf-card p { font-size: 14.5px; line-height: 1.6; color: #9aa3aa; }
.pf-top { display: flex; align-items: center; gap: 16px; }
.pf-top img, .pf-ph { width: 56px; height: 56px; border-radius: 14px; flex-shrink: 0; border: 1px solid var(--night-line); }
.pf-ph { display: flex; align-items: center; justify-content: center; color: #737b83; border-style: dashed; border-color: rgba(255,255,255,.2); }
.pf-name { font-family: var(--display); font-weight: 600; font-size: 18px; letter-spacing: -0.01em; color: #f4f6f7; }
.pf-meta { margin-top: 5px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: #737b83; }
.badge { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; padding: 3px 9px; border-radius: 100px; background: oklch(62% 0.15 195); color: #021012; font-weight: 500; }
.badge.outline { background: transparent; color: oklch(72% 0.13 195); border: 1px solid oklch(62% 0.15 195 / .6); }
.pf-link { margin-top: auto; font-size: 13.5px; font-weight: 600; color: oklch(76% 0.12 195); display: flex; gap: 6px; align-items: center; }
.pf-link.muted { color: #737b83; font-weight: 500; }
.pf-link .arr { transition: transform .3s var(--ease); }
a.pf-card:hover .pf-link .arr { transform: translate(2px, -2px); }
.pf-soon { border-style: dashed; border-color: rgba(255,255,255,.14); background: transparent; }

/* featured: Caption Remover spans the full row */
.pf-feature { grid-column: 1 / -1; display: grid; grid-template-columns: 1.05fr 1fr; gap: 0; padding: 0; overflow: hidden; }
.pf-feature .pf-body { padding: clamp(28px, 4vw, 48px); display: flex; flex-direction: column; gap: 20px; justify-content: center; }
.pf-feature p { font-size: 16px; max-width: 460px; }
.pf-feature .pf-name { font-size: clamp(20px, 2.2vw, 26px); }
.pf-visual { position: relative; min-height: 300px; background: radial-gradient(120% 120% at 20% 0%, #8b5cf6 0%, #6d3fd6 45%, #2a1a52 100%); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pf-visual::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px); background-size: 32px 32px; }
.cr-demo { position: relative; z-index: 1; width: min(78%, 380px); aspect-ratio: 16 / 10; border-radius: 18px; background: linear-gradient(160deg, #ffffff, #efe9fb); box-shadow: 0 30px 60px -20px rgba(20, 6, 50, .6); display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; padding: 26px; overflow: hidden; }
.cr-line { height: 12px; border-radius: 10px; background: #8b5cf6; transform-origin: left; animation: erase 4.2s var(--ease) infinite; }
.cr-line.l1 { width: 78%; }
.cr-line.l2 { width: 52%; animation-delay: .25s; }
.cr-scan { position: absolute; top: 0; bottom: 0; width: 40%; left: -40%; background: linear-gradient(90deg, transparent, rgba(139, 92, 246, .22), transparent); animation: scan 4.2s var(--ease) infinite; }
@keyframes erase { 0%, 18% { transform: scaleX(1); opacity: 1; } 52%, 78% { transform: scaleX(0); opacity: 0; } 100% { transform: scaleX(1); opacity: 1; } }
@keyframes scan { 0%, 10% { left: -40%; } 55%, 100% { left: 110%; } }

/* ---------- CTA + footer ---------- */
.cta { padding: clamp(96px, 14vw, 180px) 0; background: var(--bg); position: relative; overflow: hidden; }
.cta::before { content: ""; position: absolute; right: -10%; top: 50%; width: 60vw; max-width: 760px; aspect-ratio: 1; transform: translateY(-50%); border-radius: 50%; border: 1px solid var(--hair); box-shadow: 0 0 0 80px rgba(255,255,255,.25), 0 0 0 81px var(--hair), 0 0 0 180px rgba(255,255,255,.15), 0 0 0 181px var(--hair); pointer-events: none; }
.cta .wrap { position: relative; display: flex; flex-direction: column; gap: 28px; }
.cta .mail { font-size: 14.5px; font-weight: 600; color: var(--ink-2); padding: 0 8px; }
.cta .mail:hover { color: var(--accent); }
.hfoot { border-top: 1px solid var(--hair); padding: 32px 0; background: var(--bg); }
.hfoot .wrap { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.hfoot nav { display: flex; flex-wrap: wrap; gap: 10px 24px; }
.hfoot a { color: var(--mute); }
.hfoot a:hover { color: var(--ink); }

/* reveal (reuses scripts from home.js) */
.js .reveal { opacity: 0; transform: translateY(26px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }
.pf-grid > .reveal:nth-child(2) { transition-delay: .08s; }
.pf-grid > .reveal:nth-child(3) { transition-delay: .16s; }
.pf-grid > .reveal:nth-child(4) { transition-delay: .24s; }

/* ---------- no-JS fallback: show chapters as a normal stacked page ---------- */
html:not(.js) .seq { height: auto; }
html:not(.js) .seq-stage { position: relative; height: auto; overflow: visible; padding: 120px 0 60px; background-size: cover; }
html:not(.js) .chapter { position: relative; top: auto; transform: none; margin: 0 0 96px; }
html:not(.js) .hud, html:not(.js) .seq-canvas { display: none; }

/* ---------- tablet ---------- */
@media (max-width: 1080px) {
  .hnav-links { gap: 20px; }
  .rail { display: none; }
  .chapter, .ch-hero { width: min(560px, 58vw); }
}

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .hnav { top: 10px; }
  .hnav-inner { padding: 8px 8px 8px 16px; flex-wrap: wrap; border-radius: 22px; row-gap: 6px; }
  .hnav-links { order: 3; width: 100%; justify-content: space-between; gap: 8px; padding: 6px 8px 4px; border-top: 1px solid var(--hair); }
  .hnav.on-dark .hnav-links { border-top-color: var(--night-line); }
  .hnav-links a { font-size: 12.5px; }
  .hnav-inner > .hbtn { padding: 9px 14px; font-size: 13px; }

  /* Phones: picture sits in the top part of the screen (less zoom = sharper), text below it */
  .seq-stage { background: var(--bg); }
  .seq-canvas {
    top: 92px; height: min(calc(100vw + 40px), 62svh);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 9%, #000 78%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 9%, #000 78%, transparent 100%);
  }
  .seq-veil { background: linear-gradient(0deg, rgba(241, 243, 244, .97) 0%, rgba(241, 243, 244, .93) 34%, rgba(241, 243, 244, 0) 54%); }
  .seq { height: 420vh; }
  .chapter, .ch-hero { left: var(--gut); right: var(--gut); width: auto; top: auto; bottom: 64px; bottom: calc(60px + 100lvh - 100svh); transform: none; gap: 16px; }
  .hud-meta { bottom: calc(22px + 100lvh - 100svh) !important; }
  .hud-corner.bl, .hud-corner.br { bottom: calc(16px + 100lvh - 100svh) !important; }
  .display { font-size: clamp(42px, 13vw, 64px); }
  .title { font-size: clamp(30px, 9vw, 44px); }
  .lede { font-size: 15px; }
  .ch-hero .lede { display: none; }
  .tagline { display: none; }
  .js .scroll-cue { display: none; }
  .caps { grid-template-columns: 1fr 1fr; }
  .caps span { display: none; }
  .caps li { padding: 10px 10px 10px 0; }
  .caps li:nth-child(even) { padding-left: 10px; }
  .caps b { font-size: 13px; }
  .ch-caps .lede { display: none; }
  .steps li { grid-template-columns: 36px 1fr; padding: 10px 0; }
  .steps b { font-size: 15.5px; }
  .steps p { font-size: 12.5px; }
  .chip { font-size: 12px; }
  .ch-results .lede { display: none; }
  .stats > div { padding-right: 8px; }
  .stats > div + div { padding-left: 10px; }
  .hud-corner.tl, .hud-corner.tr { top: 120px; }
  .hud-left { display: none; }
  .hud-meta { bottom: 22px; }
  .hud-corner.bl, .hud-corner.br { bottom: 16px; }

  .pf-grid { grid-template-columns: 1fr; }
  .pf-feature { grid-template-columns: 1fr; }
  .pf-visual { min-height: 220px; }
  .pf-card { padding: 24px; }
  .pf-feature { padding: 0; }
  .cta::before { width: 120vw; right: -60vw; }
}

@media (prefers-reduced-motion: reduce) {
  .cr-line, .cr-scan, .scroll-cue span::after, .hud .dot { animation: none !important; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
}
