/* SPDX-License-Identifier: Apache-2.0 */

:root {
  color-scheme: light dark;

  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e6e8ef;
  --text: #0f172a;
  --muted: #5b6577;
  --accent: #4f46e5;
  --accent-2: #3b82f6;
  --accent-grad: linear-gradient(135deg, #6366f1, #3b82f6);
  --on-accent: #ffffff;
  --ring: rgba(79, 70, 229, 0.35);
  --danger: #dc2626;
  --ok: #16a34a;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 18px;
  --radius-md: 12px;
  --radius-sm: 9px;
  --wrap: 60rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #080b14;
    --surface: #111726;
    --surface-2: #0c1220;
    --border: rgba(255, 255, 255, 0.08);
    --text: #e8ebf2;
    --muted: #9aa6bd;
    --accent: #818cf8;
    --accent-2: #60a5fa;
    --on-accent: #0b1020;
    --ring: rgba(129, 140, 248, 0.45);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 40px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* A soft glow behind the hero. */
body::before {
  content: "";
  position: fixed;
  inset: -20% -20% auto -20%;
  height: 60vh;
  z-index: -1;
  background:
    radial-gradient(60% 60% at 30% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(50% 50% at 85% 10%, color-mix(in srgb, var(--accent-2) 18%, transparent), transparent 70%);
  pointer-events: none;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 1.25rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ---- Top navigation ---- */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(1.4) blur(10px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 60px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  font-size: 1.05rem;
}
.brand:hover {
  text-decoration: none;
}
.brand .logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent-grad);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.95rem;
}
.nav-links a {
  color: var(--muted);
}
.nav-links a:hover {
  color: var(--text);
}

/* ---- Hero ---- */
.hero {
  text-align: center;
  padding: 3.5rem 0 1rem;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.eyebrow .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}
.hero h1 {
  margin: 1.1rem 0 0.5rem;
  font-size: clamp(2rem, 6vw, 3.25rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 800;
}
.hero h1 .grad {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .tagline {
  max-width: 38rem;
  margin: 0 auto;
  font-size: 1.12rem;
  color: var(--muted);
}
.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 1.4rem 0 0;
}
.badge {
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
}

/* ---- The app card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.app-card {
  max-width: 40rem;
  margin: 1.75rem auto 0;
  padding: 1.5rem;
  /* The card lives inside the centered hero; keep its form left-aligned. */
  text-align: left;
}

form {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  margin: 0;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}
.field > label,
.field > legend {
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0;
}
.hint {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.82rem;
}
/* A wrapper that toggles as one unit but lays out several fields. */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}
.field-help {
  margin: 0;
  font-size: 0.83rem;
  line-height: 1.45;
  color: var(--muted);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.15rem;
}

input[type="file"],
input[type="number"],
select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem;
}
input[type="file"] {
  padding: 0.5rem;
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  font: inherit;
  font-weight: 600;
  margin-right: 0.7rem;
  padding: 0.4rem 0.8rem;
  border: 0;
  border-radius: 7px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}
input:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}

/* Segmented control (the mode radios). */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  padding: 0.3rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.segmented label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-align: center;
  padding: 0.55rem 0.6rem;
  border-radius: 9px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented label:has(input:checked) {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.segmented label:has(input:focus-visible) {
  box-shadow: 0 0 0 3px var(--ring);
}

/* Primary action. */
button[type="submit"] {
  margin-top: 0.2rem;
  padding: 0.85rem 1rem;
  font: inherit;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--on-accent);
  background: var(--accent-grad);
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform 0.06s ease, filter 0.15s ease, box-shadow 0.15s ease;
}
button[type="submit"]:hover {
  filter: brightness(1.05);
}
button[type="submit"]:active {
  transform: translateY(1px);
}
button[type="submit"]:disabled {
  opacity: 0.65;
  cursor: progress;
  box-shadow: none;
}

/* Secondary action (e.g. the manual "download again" button). */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-secondary:hover {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.hidden {
  display: none !important;
}

/* ---- Status + progress ---- */
#status {
  margin: 0;
  min-height: 1.4rem;
  font-size: 0.95rem;
  color: var(--muted);
}
#status.error {
  color: var(--danger);
  font-weight: 600;
}
#status.ok {
  color: var(--ok);
  font-weight: 600;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.45rem;
  font-weight: 600;
  font-size: 0.95rem;
}
#progress-pct {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.progress-track {
  height: 0.55rem;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent-grad);
  transition: width 0.25s ease;
}
.progress.indeterminate .progress-bar {
  width: 40% !important;
  transition: none;
  animation: progress-slide 1.2s ease-in-out infinite;
}
@keyframes progress-slide {
  0% {
    margin-left: -40%;
  }
  100% {
    margin-left: 100%;
  }
}
.progress-note {
  margin: 0.45rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2rem;
  font-variant-numeric: tabular-nums;
}

/* ---- Generic section ---- */
section {
  padding: 2.75rem 0;
}
.section-title {
  text-align: center;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.4rem;
}
.section-sub {
  text-align: center;
  color: var(--muted);
  max-width: 36rem;
  margin: 0 auto 1.8rem;
}

/* Format chips. */
.formats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: var(--shadow-sm);
}
.chip code {
  color: var(--muted);
  font-weight: 500;
}

/* Steps / feature grids. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.tile {
  padding: 1.25rem;
}
.tile .num {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  margin-bottom: 0.7rem;
}
.tile h3 {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
}
.tile p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---- FAQ accordion ---- */
.faq-list {
  max-width: 44rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
details.faq {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 1.1rem;
  box-shadow: var(--shadow-sm);
}
details.faq summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  padding: 1rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
details.faq summary::-webkit-details-marker {
  display: none;
}
details.faq summary::after {
  content: "+";
  font-size: 1.3rem;
  color: var(--muted);
  line-height: 1;
  transition: transform 0.2s ease;
}
details.faq[open] summary::after {
  transform: rotate(45deg);
}
details.faq p {
  margin: 0 0 1rem;
  color: var(--muted);
}

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 1rem;
  padding: 2rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer .footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
}
.site-footer .footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

code {
  background: color-mix(in srgb, currentColor 12%, transparent);
  padding: 0 0.3rem;
  border-radius: 5px;
  font-size: 0.92em;
}

/* ---- Long-form article (how-it-works.html) ---- */
.back {
  display: inline-block;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}
.prose {
  max-width: 44rem;
  margin: 0 auto;
}
.prose .lead {
  font-size: 1.12rem;
  color: var(--muted);
}
.prose h1 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: -0.02em;
  margin: 0.5rem 0 0.75rem;
}
.prose h2 {
  margin: 2.25rem 0 0.5rem;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}
.prose ul,
.prose ol {
  padding-left: 1.25rem;
}
.prose li {
  margin: 0.45rem 0;
}
.colophon {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--muted);
}

@media (max-width: 560px) {
  .field-row {
    grid-template-columns: 1fr;
  }
  .nav-links {
    gap: 0.9rem;
    font-size: 0.9rem;
  }
  .hero {
    padding-top: 2.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .progress.indeterminate .progress-bar {
    animation: none;
    width: 100% !important;
    opacity: 0.5;
  }
  .progress-bar {
    transition: none;
  }
}
