/* kbuilt — terminal-first product page. Monospace identity, terracotta accent,
   glassmorphism terminal floating above a Three.js particle scene (#fx). */

:root {
  --bg: #0b0d0e;
  --panel: rgba(19, 22, 24, .72);
  --panel-solid: #131618;
  --bar: rgba(27, 31, 34, .85);
  --fg: #d6d3cd;
  --muted: #6b7177;
  --border: #23282c;
  --border-soft: #2c3236;
  --input-bg: rgba(14, 17, 19, .75);
  --accent: #d97757;       /* claude-ish terracotta */
  --accent-soft: rgba(217, 119, 87, .35);
  --accent-fg: #1a0f0a;
  --green: #7fae6e;
  --red: #d96c6c;
  --yellow: #d9b75e;
  --blue: #6e9ec4;
  --shadow: rgba(0, 0, 0, .55);
  --bg-grad-top: #15191b;
  --card: rgba(19, 22, 24, .6);
  --mono: "SFMono-Regular", "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

:root[data-theme="light"] {
  --bg: #f4f1ea;
  --panel: rgba(251, 249, 244, .78);
  --panel-solid: #fbf9f4;
  --bar: rgba(236, 231, 221, .88);
  --fg: #2b2b2b;
  --muted: #8a8377;
  --border: #ddd6c8;
  --border-soft: #d0c8b8;
  --input-bg: rgba(255, 253, 248, .8);
  --accent: #c75f3e;
  --accent-soft: rgba(199, 95, 62, .3);
  --accent-fg: #fff;
  --green: #4f8f3f;
  --red: #c0463f;
  --yellow: #b7891f;
  --blue: #3f6f99;
  --shadow: rgba(120, 100, 70, .22);
  --bg-grad-top: #efe9dd;
  --card: rgba(251, 249, 244, .66);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(120% 120% at 50% 0%, var(--bg-grad-top) 0%, var(--bg) 60%);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  transition: background .25s, color .25s;
}

/* ---- 3D background canvas ------------------------------------------------ */
#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.page { position: relative; z-index: 1; }

/* ---- accessibility helpers ----------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---- hero ----------------------------------------------------------------- */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4vh 16px;
  gap: 18px;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .25em;
  text-transform: lowercase;
  animation: fade-down .9s ease both;
}

.scroll-hint {
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  letter-spacing: .15em;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  animation: hint-float 2.6s ease-in-out infinite;
  transition: color .2s, border-color .2s;
}
.scroll-hint:hover { color: var(--accent); border-color: var(--border-soft); }

@keyframes hint-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(5px); }
}
@keyframes fade-down {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- terminal (glass panel) ----------------------------------------------- */
.terminal {
  width: 100%;
  max-width: 860px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow:
    0 0 0 1px var(--accent-soft) inset,
    0 0 42px -18px var(--accent-soft),
    0 28px 70px var(--shadow);
  overflow: hidden;
  transition: background .25s, border-color .25s, box-shadow .4s;
  animation: terminal-rise .9s cubic-bezier(.22, .8, .3, 1) both;
}

@keyframes terminal-rise {
  from { opacity: 0; transform: translateY(22px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .terminal { background: var(--panel-solid); }
}

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bar);
  border-bottom: 1px solid var(--border);
}
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot.red { background: #ff5f56; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #27c93f; }
.bar .title { margin-left: 10px; color: var(--muted); font-size: 12px; }
.bar .grow { flex: 1; }
.chip {
  background: var(--input-bg); color: var(--fg);
  border: 1px solid var(--border-soft); border-radius: 6px;
  padding: 3px 8px; font: inherit; font-size: 12px; cursor: pointer;
  transition: border-color .15s;
}
.chip:hover { border-color: var(--accent); }
#theme { min-width: 30px; }

.screen { padding: 18px 20px 12px; min-height: 320px; }

.banner { color: var(--accent); margin: 0 0 14px; font-size: 12px; line-height: 1.2; white-space: pre; text-shadow: 0 0 18px var(--accent-soft); }

.prompt-line { margin-bottom: 6px; }
.ps1 { color: var(--green); margin-right: 8px; }
.ps1 .muted { color: var(--muted); }
.typed { color: var(--muted); }
.cursor::after { content: "▋"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

.input-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.input-row .ps1 { color: var(--accent); }
#url {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-soft);
  color: var(--fg);
  font: inherit;
  padding: 6px 2px;
  outline: none;
  transition: border-color .2s;
}
#url:focus { border-bottom-color: var(--accent); }

.controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 14px 0 8px; }
.controls label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.controls select {
  background: var(--input-bg); color: var(--fg); border: 1px solid var(--border-soft);
  border-radius: 5px; padding: 4px 6px; font: inherit;
  transition: border-color .15s;
}
.controls select:hover { border-color: var(--accent); }

#go {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: var(--accent-fg); border: none;
  border-radius: 6px; padding: 8px 16px; font: inherit; font-weight: 600;
  cursor: pointer;
  transition: filter .15s, box-shadow .25s, transform .12s;
  box-shadow: 0 0 0 0 var(--accent-soft);
}
#go:hover { filter: brightness(1.08); box-shadow: 0 0 22px -4px var(--accent-soft); }
#go:active { transform: translateY(1px); }
#go:disabled { opacity: .55; cursor: progress; }
#go.busy .go-icon { display: inline-block; animation: go-spin .8s linear infinite; }
@keyframes go-spin { to { transform: rotate(360deg); } }

.log {
  margin-top: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 60px;
  border-top: 1px dashed var(--border-soft);
  padding-top: 12px;
}
.log .line { display: block; }
.log .ok { color: var(--green); }
.log .err { color: var(--red); }
.log .info { color: var(--blue); }
.log .warn { color: var(--yellow); }
.log .dim { color: var(--muted); }
.log a { color: var(--accent); }

/* ---- download history ------------------------------------------------------ */
.history { margin-top: 10px; border-top: 1px dashed var(--border-soft); padding-top: 8px; font-size: 12px; }
.history summary {
  cursor: pointer;
  color: var(--muted);
  list-style: none;
  display: flex; align-items: center; gap: 6px;
  -webkit-user-select: none; user-select: none;
}
.history summary::-webkit-details-marker { display: none; }
.history summary:hover { color: var(--fg); }
.history-caret { display: inline-block; transition: transform .2s; color: var(--accent); }
.history[open] .history-caret { transform: rotate(90deg); }
.history-count { color: var(--accent); }
.history-list { list-style: none; margin: 8px 0 6px; padding: 0; }
.history-list li { margin: 2px 0; }
.history-empty { color: var(--muted); }
.history-row {
  display: flex; align-items: baseline; gap: 8px;
  width: 100%; text-align: left;
  background: none; border: none; font: inherit; font-size: 12px;
  color: var(--muted); cursor: pointer; padding: 3px 4px; border-radius: 4px;
}
.history-row:hover { background: var(--input-bg); color: var(--fg); }
.history-row .h-status { flex: none; }
.history-row .h-status.ok { color: var(--green); }
.history-row .h-status.err { color: var(--red); }
.history-row .h-time { flex: none; color: var(--muted); }
.history-row .h-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-clear { margin: 2px 0 4px; }

/* ---- terminal status bar ----------------------------------------------------- */
.status {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; background: var(--bar); border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}
.status .grow { flex: 1; }
.status .up { color: var(--green); }
.status .down { color: var(--red); }
.muted { color: var(--muted); }

/* ---- below-the-fold sections -------------------------------------------------- */
.section {
  max-width: 860px;
  margin: 0 auto;
  padding: 96px 20px 24px;
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .04em;
  margin: 0 0 36px;
  color: var(--fg);
}
.section-title::before { content: "## "; color: var(--accent); }

/* scroll-reveal */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity .7s cubic-bezier(.22, .8, .3, 1), transform .7s cubic-bezier(.22, .8, .3, 1);
}
.reveal.visible { opacity: 1; transform: translateY(0); }
.steps .step:nth-child(2) { transition-delay: .12s; }
.steps .step:nth-child(3) { transition-delay: .24s; }

/* pipeline SVG */
.pipeline {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 8px;
  margin-bottom: 28px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.pipeline-svg { width: 100%; height: auto; display: block; }
.pipeline-svg text { font-family: var(--mono); }

.p-node rect {
  fill: var(--input-bg);
  stroke: var(--border-soft);
  stroke-width: 1.5;
  transition: stroke .3s;
}
.p-node:hover rect { stroke: var(--accent); }
.p-node .p-label { fill: var(--fg); font-size: 13px; }
.p-node .p-glyph { fill: var(--accent); font-size: 22px; }
.p-node .p-dot { fill: var(--muted); }
.p-node .p-line { stroke: var(--border-soft); stroke-width: 1; }

.p-flow {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 7;
  opacity: 0;
  transition: opacity .6s .4s;
}
.p-arrowhead { fill: var(--accent); }

.p-node { opacity: 0; transform: translateY(10px); transition: opacity .6s ease, transform .6s ease; }
.reveal.visible .p-node { opacity: 1; transform: translateY(0); }
.reveal.visible .n2 { transition-delay: .18s; }
.reveal.visible .n3 { transition-delay: .36s; }
.reveal.visible .p-flow { opacity: 1; animation: flow-march 1.1s linear infinite; }
.reveal.visible .f2 { animation-delay: .3s; }

@keyframes flow-march { to { stroke-dashoffset: -26; } }

/* step cards */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.step {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 18px 14px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: border-color .25s, transform .25s, opacity .7s cubic-bezier(.22, .8, .3, 1);
}
.step:hover { border-color: var(--accent); transform: translateY(-3px); }
.step h3 { margin: 0 0 8px; font-size: 13px; color: var(--accent); letter-spacing: .03em; }
.step p { margin: 0; font-size: 13px; color: var(--muted); }

/* ---- platforms grid ------------------------------------------------------------- */
.platform-grid {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.platform {
  --brand: var(--accent);
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--muted);
  filter: grayscale(1);
  transition: color .25s, border-color .25s, filter .25s, transform .2s, box-shadow .25s;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor: default;
}
.platform .p-mark { color: var(--muted); width: 18px; text-align: center; flex: none; transition: color .25s; }
.platform:hover {
  filter: grayscale(0);
  color: var(--fg);
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -12px var(--brand);
}
.platform:hover .p-mark { color: var(--brand); }

.p-youtube    { --brand: #ff4133; }
.p-bilibili   { --brand: #00a1d6; }
.p-douyin     { --brand: #00f2ea; }
.p-tiktok     { --brand: #fe2c55; }
.p-x          { --brand: #8a96a3; }
.p-instagram  { --brand: #e1306c; }
.p-reddit     { --brand: #ff4500; }
.p-twitch     { --brand: #9146ff; }
.p-vimeo      { --brand: #1ab7ea; }
.p-soundcloud { --brand: #ff5500; }
.p-pinterest  { --brand: #e60023; }
.p-tumblr     { --brand: #529ecc; }

.platforms-note { margin-top: 18px; font-size: 12px; }

/* ---- FAQ --------------------------------------------------------------------------- */
.faq-list { display: flex; flex-direction: column; gap: 12px; }
.faq-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: border-color .25s, opacity .7s cubic-bezier(.22, .8, .3, 1), transform .7s cubic-bezier(.22, .8, .3, 1);
}
.faq-item:hover { border-color: var(--border-soft); }
.faq-item[open] { border-color: var(--accent-soft); }
.faq-item summary {
  cursor: pointer;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--fg);
  list-style: none;
  -webkit-user-select: none; user-select: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: "? "; color: var(--accent); }
.faq-item p { margin: 0; padding: 0 16px 14px 30px; font-size: 13px; color: var(--muted); }

/* ---- site footer -------------------------------------------------------------------- */
.site-footer {
  max-width: 860px;
  margin: 64px auto 0;
  padding: 22px 20px 30px;
  border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.site-footer .footer-brand { color: var(--accent); font-weight: 600; }
.site-footer a { color: var(--fg); text-decoration: none; border-bottom: 1px dotted var(--border-soft); }
.site-footer a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.footer-sep { color: var(--border-soft); }

/* ---- responsive ----------------------------------------------------------------------- */
@media (max-width: 720px) {
  .steps { grid-template-columns: 1fr; }
  .platform-grid { grid-template-columns: repeat(2, 1fr); }
  .section { padding: 64px 16px 16px; }
}

@media (max-width: 600px) {
  .hero { padding: 12px 0 24px; }
  .terminal { border-radius: 0; border-left: none; border-right: none; }
  #go { margin-left: 0; }
  .banner { font-size: 10px; }
}

/* ---- reduced motion --------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tagline, .terminal { animation: none; }
  .scroll-hint { animation: none; }
  .cursor::after { animation: none; }
  #go.busy .go-icon { animation: none; }
  .reveal, .p-node, .step, .faq-item, .platform { transition: none; opacity: 1; transform: none; }
  .reveal { opacity: 1; transform: none; }
  .reveal.visible .p-flow { animation: none; opacity: 1; }
}
