/*
 * Clipyzy web client.
 *
 * Same design language as the Android app: near-black surfaces, one purple accent,
 * colour reserved for status meaning. No framework and no build step — the whole site
 * is three files served by the same Node process that runs the API.
 */

:root {
  --bg: #0b0a12;
  --surface: #14131d;
  --surface-2: #1c1b28;
  --border: #2a2838;
  --text: #f4f3f8;
  --text-2: #a9a6bd;
  --text-muted: #6f6b85;

  --accent: #7c6cff;
  --accent-strong: #9b8dff;
  --accent-text: #ffffff;

  --success: #3ddc97;
  --warning: #ffb454;
  --danger: #ff5c72;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;

  --space-1: 6px;
  --space-2: 12px;
  --space-3: 18px;
  --space-4: 26px;
  --space-5: 40px;
  --space-6: 64px;

  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --max: 1080px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* The ambient glow behind everything. Fixed so it doesn't scroll away. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(60rem 40rem at 15% -10%, rgba(124, 108, 255, 0.18), transparent 60%),
    radial-gradient(45rem 35rem at 90% 0%, rgba(155, 141, 255, 0.10), transparent 55%);
  z-index: 0;
}

#app { position: relative; z-index: 1; }

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; }
h2 { font-size: clamp(1.3rem, 3vw, 1.9rem); font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--space-3); }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.stack-sm { display: flex; flex-direction: column; gap: var(--space-2); }
.row { display: flex; align-items: center; gap: var(--space-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-2); }
.small { font-size: 0.85rem; }
.tiny { font-size: 0.78rem; }
.center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- header */

header.top {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  background: rgba(11, 10, 18, 0.82);
  border-bottom: 1px solid var(--border);
}
header.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 62px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.02em; font-size: 1.05rem; }
.brand .mark {
  width: 28px; height: 28px; border-radius: 9px;
  background: linear-gradient(140deg, var(--accent), #4b3fd1);
  display: grid; place-items: center; color: #fff; font-size: 15px;
  box-shadow: 0 6px 18px rgba(124, 108, 255, 0.4);
}
.brand:hover { text-decoration: none; }

nav.links { display: flex; align-items: center; gap: var(--space-1); }
nav.links a {
  color: var(--text-2); padding: 7px 12px; border-radius: 999px;
  font-size: 0.88rem; font-weight: 600;
}
nav.links a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
nav.links a.active { color: var(--text); background: var(--surface-2); }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 999px;
  padding: 11px 20px;
  font: inherit; font-weight: 700; font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: var(--accent-text); box-shadow: 0 10px 26px rgba(124, 108, 255, 0.32); }
.btn-primary:hover:not([disabled]) { background: var(--accent-strong); text-decoration: none; }

.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not([disabled]) { border-color: var(--accent); text-decoration: none; }

.btn-quiet { background: transparent; color: var(--text-2); padding: 8px 12px; }
.btn-quiet:hover:not([disabled]) { color: var(--text); text-decoration: none; }

.btn-danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
}
.card-pad-lg { padding: var(--space-4); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-2); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); }
.tile .value { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.tile .label { color: var(--text-muted); font-size: 0.78rem; }

/* Option cards — the split-mode and format pickers. */
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-2); }
.option {
  text-align: left; background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: var(--space-3); cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  color: var(--text); font: inherit;
}
.option:hover { border-color: var(--accent); }
.option.selected { border-color: var(--accent); background: rgba(124, 108, 255, 0.10); }
.option .name { font-weight: 700; font-size: 0.95rem; }
.option .desc { color: var(--text-2); font-size: 0.82rem; }

/* ---------------------------------------------------------------- forms */

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.82rem; color: var(--text-2); font-weight: 600; }
input[type='text'], input[type='number'], input.key {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font: inherit; padding: 12px 14px; width: 100%;
}
input:focus { outline: none; border-color: var(--accent); }
input.key { font-family: ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: 0.04em; text-align: center; font-size: 1.02rem; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); position: relative; cursor: pointer; transition: background 0.15s ease; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-2); transition: transform 0.15s ease, background 0.15s ease; }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(18px); background: #fff; }

/* ---------------------------------------------------------------- status */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.02em;
  border: 1px solid transparent; white-space: nowrap;
}
.pill::before { content: '●'; font-size: 0.6em; }
.pill.progress { color: var(--accent-strong); border-color: rgba(124, 108, 255, 0.45); background: rgba(124, 108, 255, 0.12); }
.pill.success { color: var(--success); border-color: rgba(61, 220, 151, 0.4); background: rgba(61, 220, 151, 0.10); }
.pill.waiting { color: var(--warning); border-color: rgba(255, 180, 84, 0.4); background: rgba(255, 180, 84, 0.10); }
.pill.danger { color: var(--danger); border-color: rgba(255, 92, 114, 0.4); background: rgba(255, 92, 114, 0.10); }
.pill.neutral { color: var(--text-2); border-color: var(--border); background: var(--surface-2); }

.track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); border-radius: 999px; transition: width 0.35s ease; }

.notice { border-radius: var(--radius); padding: var(--space-3); border: 1px solid; font-size: 0.88rem; }
.notice.info { border-color: rgba(124, 108, 255, 0.4); background: rgba(124, 108, 255, 0.09); }
.notice.warn { border-color: rgba(255, 180, 84, 0.4); background: rgba(255, 180, 84, 0.08); }
.notice.bad { border-color: rgba(255, 92, 114, 0.4); background: rgba(255, 92, 114, 0.08); }
.notice.good { border-color: rgba(61, 220, 151, 0.4); background: rgba(61, 220, 151, 0.08); }
.notice strong { display: block; margin-bottom: 3px; }

.error-text { color: var(--danger); font-size: 0.85rem; }

/* ---------------------------------------------------------------- landing */

.hero { padding: var(--space-6) 0 var(--space-5); text-align: center; }
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 6px 14px;
  font-size: 0.78rem; font-weight: 600; color: var(--text-2);
  margin-bottom: var(--space-3);
}
.hero h1 { margin-bottom: var(--space-3); }
.hero h1 .grad {
  background: linear-gradient(120deg, var(--accent-strong), #d9d3ff 60%, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .sub { color: var(--text-2); font-size: 1.08rem; max-width: 34rem; margin: 0 auto var(--space-4); }
.hero .cta { display: flex; gap: var(--space-2); justify-content: center; flex-wrap: wrap; }

/* One long landscape frame fanning out into vertical clips. */
.split-demo {
  margin: var(--space-5) auto 0;
  display: flex; align-items: center; justify-content: center; gap: var(--space-3);
  flex-wrap: wrap;
}
.demo-source {
  width: 190px; height: 107px; border-radius: 10px;
  background: linear-gradient(135deg, #2a2550, #3b2f7a);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--text-2); font-size: 0.72rem; font-weight: 600;
}
.demo-arrow { color: var(--accent); font-size: 1.4rem; }
.demo-clips { display: flex; gap: 10px; }
.demo-clip {
  width: 46px; height: 82px; border-radius: 8px;
  background: linear-gradient(160deg, var(--accent), #4b3fd1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: grid; place-items: center;
  color: #fff; font-size: 0.6rem; font-weight: 700;
  animation: rise 0.5s ease backwards;
}
.demo-clip:nth-child(1) { animation-delay: 0.05s; }
.demo-clip:nth-child(2) { animation-delay: 0.15s; }
.demo-clip:nth-child(3) { animation-delay: 0.25s; }
.demo-clip:nth-child(4) { animation-delay: 0.35s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--space-2); padding: var(--space-5) 0; }
.feature .icon { font-size: 1.5rem; margin-bottom: 6px; }
.feature h3 { margin-bottom: 4px; }

.steps { counter-reset: step; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-2); }
.step { position: relative; padding-top: var(--space-3); }
.step::before {
  counter-increment: step; content: counter(step);
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 0.85rem;
  margin-bottom: 10px;
}

/* ---------------------------------------------------------------- dropzone */

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-3); text-align: center;
  cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease;
  background: var(--surface);
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: rgba(124, 108, 255, 0.07); }
.dropzone .big { font-size: 2.2rem; margin-bottom: var(--space-2); }

/* ---------------------------------------------------------------- clips grid */

.clip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-2); }
.clip-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: var(--space-2);
  display: flex; flex-direction: column; gap: 6px;
}
.clip-card .thumb {
  aspect-ratio: 9 / 16; border-radius: 6px;
  background: linear-gradient(160deg, #2a2550, #3b2f7a);
  display: grid; place-items: center; color: var(--text-2); font-size: 0.72rem; font-weight: 700;
}

/* ---------------------------------------------------------------- misc */

.job-row { display: flex; flex-direction: column; gap: var(--space-2); }
.device-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.device-row:last-child { border-bottom: none; }

footer.bottom { border-top: 1px solid var(--border); margin-top: var(--space-6); padding: var(--space-4) 0; color: var(--text-muted); font-size: 0.82rem; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25); border-top-color: #fff;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page { padding: var(--space-4) 0 var(--space-6); }

@media (max-width: 620px) {
  .hero { padding: var(--space-5) 0 var(--space-4); }
  nav.links a { padding: 7px 9px; font-size: 0.82rem; }
  .brand span.word { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------------------------------------------------------------- a11y + SEO markup */

/*
 * Visible only to screen readers. Headings like "Why Clipyzy" exist so the document
 * outline is complete for crawlers and assistive tech without adding visual noise.
 */
.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;
}

/* Keyboard users get a way past the header without tabbing through every nav link. */
.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 100;
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}
.skip-link:focus { left: 8px; text-decoration: none; }

/* A visible focus ring everywhere, since the design removes the default on buttons. */
:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
  border-radius: 4px;
}

/* The steps list is an <ol> for document structure; the numbering is drawn by ::before. */
ol.steps { list-style: none; margin: 0; padding: 0; }

details.card > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after {
  content: '+';
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}
details.card[open] > summary::after { content: '−'; }
details.card > summary:hover { color: var(--accent-strong); }

/* Toast — confirmation that doesn't steal focus or block the page. */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  animation: toast-in 0.22s ease;
}
.toast.good { border-left-color: var(--success); }
.toast.bad { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Skeleton shimmer while the first job list loads, instead of an empty flash. */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton-row { height: 84px; margin-bottom: var(--space-2); }

/* ---------------------------------------------------------------- live clip grid */

/*
 * Clips are published as they are cut, so the grid shows every slot from the start —
 * filled ones are downloadable, the rest are placeholders. Growing the grid from nothing
 * would hide how much of the job is left.
 */
.clip-card.pending { opacity: 0.65; }
.clip-card.pending .thumb { color: var(--text-muted); }
.clip-card.ready { animation: clip-in 0.28s ease backwards; }
@keyframes clip-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.clip-card .thumb span { font-weight: 700; }

/* A queued job has no progress to report, so its bar pulses instead of pretending. */
.fill.idle {
  background: linear-gradient(90deg, var(--surface-2), var(--accent), var(--surface-2));
  background-size: 200% 100%;
  animation: idle-sweep 1.6s ease-in-out infinite;
}
@keyframes idle-sweep {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* Digits that sit in columns or tick upward shouldn't jiggle as they change. */
.tabular { font-variant-numeric: tabular-nums; }
