/* ==========================================================
   FBReelsDown – styles
   ========================================================== */

:root {
  --primary: #1b74e4;
  --primary-600: #1462c4;
  --accent: #7c3aed;
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --text: #0f172a;
  --muted: #5b6577;
  --border: #e3e8f0;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 16px;
  --shadow: 0 10px 30px -12px rgba(15, 23, 42, .18);
  --shadow-lg: 0 25px 60px -20px rgba(27, 116, 228, .35);
  --header-h: 68px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111a2e;
  --surface-2: #0f1729;
  --text: #e6ebf5;
  --muted: #94a0b8;
  --border: #1f2a44;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 25px 60px -20px rgba(27, 116, 228, .45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}

img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.02em; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.container { width: 100%; max-width: 1140px; margin-inline: auto; padding-inline: 20px; }
.container.narrow { max-width: 820px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 0; cursor: pointer; font: inherit; font-weight: 600;
  padding: .9rem 1.6rem; border-radius: 12px;
  transition: transform .15s, box-shadow .2s, background .2s, opacity .2s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 8px 20px -8px rgba(27, 116, 228, .7);
}
.btn-primary:hover { box-shadow: 0 12px 26px -8px rgba(27, 116, 228, .85); }
.btn-primary:disabled { opacity: .7; cursor: progress; }
.btn-ghost { background: transparent; color: var(--muted); padding-inline: 0; }
.btn-ghost:hover { color: var(--primary); }
.btn-light { background: #fff; color: var(--primary); }
.btn-light:hover { box-shadow: 0 10px 25px -10px rgba(0, 0, 0, .4); }
.btn-hd { background: var(--success); color: #fff; }
.btn-sd { background: var(--primary); color: #fff; }
.btn-hd:hover, .btn-sd:hover { filter: brightness(1.08); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav { height: 100%; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-size: 1.2rem; font-weight: 600; color: var(--text); }
.brand strong { color: var(--primary); font-weight: 800; }

.nav-menu { display: flex; align-items: center; gap: 1.75rem; margin-left: auto; }
.nav-menu a { color: var(--muted); font-weight: 500; transition: color .2s; }
.nav-menu a:hover { color: var(--primary); }
.nav-menu-title { display: none; }
.nav-actions { display: flex; align-items: center; gap: .6rem; margin-left: 1.75rem; }
.nav-overlay { display: none; }

.theme-toggle {
  display: grid; place-items: center; width: 40px; height: 40px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
}
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.nav-toggle {
  position: relative; z-index: 2;
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 42px; height: 42px; padding: 0 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-toggle span { height: 2px; background: var(--text); border-radius: 2px; transition: transform .25s, opacity .25s; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding: 72px 0 80px; text-align: center; }
.hero-bg {
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(600px 300px at 15% 10%, rgba(27, 116, 228, .18), transparent 70%),
    radial-gradient(500px 300px at 85% 20%, rgba(124, 58, 237, .16), transparent 70%),
    radial-gradient(700px 300px at 50% 110%, rgba(27, 116, 228, .12), transparent 70%);
}
.hero-inner { max-width: 860px; }
.pill {
  display: inline-block; padding: .35rem .9rem; margin-bottom: 1.25rem;
  font-size: .85rem; font-weight: 600; color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-radius: 999px;
}
.hero h1 { font-size: clamp(2rem, 5.5vw, 3.6rem); font-weight: 800; }
.grad {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { font-size: clamp(1rem, 2.2vw, 1.2rem); color: var(--muted); max-width: 640px; margin: 0 auto 2rem; }

/* ---------- Download form ---------- */
.dl-form {
  display: flex; gap: .6rem; padding: .55rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-lg);
  transition: border-color .2s, box-shadow .2s;
}
.dl-form:focus-within { border-color: var(--primary); }
.dl-form.is-error { border-color: var(--danger); animation: shake .35s; }
.input-wrap { position: relative; flex: 1; display: flex; align-items: center; min-width: 0; }
.input-icon { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.input-wrap input {
  width: 100%; min-width: 0; height: 54px; padding: 0 84px 0 46px;
  font: inherit; color: var(--text); background: transparent; border: 0; outline: none;
}
.input-wrap input::placeholder { color: var(--muted); opacity: .8; }
.paste-btn {
  position: absolute; right: 6px;
  padding: .45rem .8rem; font: inherit; font-size: .85rem; font-weight: 600;
  color: var(--primary); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 9px; cursor: pointer;
}
.paste-btn:hover { border-color: var(--primary); }
#dl-btn { min-width: 150px; font-size: 1.05rem; }

.spinner {
  display: none; width: 18px; height: 18px;
  border: 2.5px solid rgba(255, 255, 255, .45); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
#dl-btn.loading .spinner { display: inline-block; }
#dl-btn.loading .btn-label::after { content: "ing…"; }

.form-msg { min-height: 1.5em; margin: .9rem 0 0; font-size: .95rem; font-weight: 500; }
.form-msg.error { color: var(--danger); }
.form-msg.ok { color: var(--success); }

.trust { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem 1.5rem; padding: 0; margin: 1.5rem 0 0; list-style: none; }
.trust li { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .92rem; }
.trust svg { color: var(--success); }

/* ---------- Result ---------- */
.result {
  display: grid; grid-template-columns: 280px 1fr; gap: 1.5rem;
  margin-top: 1.75rem; padding: 1rem; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  animation: rise .4s ease;
}
.result[hidden] { display: none; }
.result-thumb { position: relative; border-radius: 12px; overflow: hidden; background: var(--surface-2); aspect-ratio: 16 / 9; }
.result-thumb img { width: 100%; height: 100%; object-fit: cover; }
.badge {
  position: absolute; right: 8px; bottom: 8px; padding: .1rem .5rem;
  font-size: .78rem; font-weight: 600; color: #fff; background: rgba(0, 0, 0, .7); border-radius: 6px;
}
.badge:empty { display: none; }
.result-body { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.result-body h3 { font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.result-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: .5rem; }
.result-actions .btn { padding: .75rem 1.2rem; }
#reset-btn { align-self: flex-start; }

/* ---------- Sections ---------- */
.section { padding: 88px 0; }
.section-alt { background: var(--surface-2); border-block: 1px solid var(--border); }
.section-head { text-align: center; max-width: 640px; margin: 0 auto 3rem; }
.section-head h2 { font-size: clamp(1.6rem, 3.5vw, 2.3rem); font-weight: 800; }
.eyebrow { display: inline-block; margin-bottom: .6rem; font-size: .8rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--primary); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.75rem;
  transition: transform .25s, box-shadow .25s, border-color .25s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.card h3 { font-size: 1.15rem; }
.card p:last-child { margin-bottom: 0; }

/* Steps */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; padding: 0; margin: 0; list-style: none; counter-reset: none; }
.step { position: relative; text-align: center; padding-top: 2.5rem; }
.step-num {
  position: absolute; top: 14px; right: 18px;
  font-size: 2.6rem; font-weight: 800; line-height: 1;
  color: color-mix(in srgb, var(--primary) 14%, transparent);
}
.step-icon {
  display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 1.1rem;
  color: #fff; border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 10px 22px -10px rgba(27, 116, 228, .8);
}

/* Features */
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.feature-icon {
  display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 1rem;
  font-size: 1.5rem; border-radius: 14px;
  background: color-mix(in srgb, var(--c) 14%, transparent);
}

/* FAQ */
.faq { display: grid; gap: .85rem; }
.faq details {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 0 1.25rem; transition: border-color .2s;
}
.faq details[open] { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.faq summary {
  position: relative; list-style: none; cursor: pointer;
  padding: 1.1rem 2rem 1.1rem 0; font-weight: 600;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; position: absolute; right: 0; top: 50%; translate: 0 -50%;
  font-size: 1.5rem; font-weight: 400; color: var(--primary); transition: rotate .25s;
}
.faq details[open] summary::after { rotate: 45deg; }
.faq details p { color: var(--muted); padding-bottom: 1.1rem; margin: 0; }

/* CTA */
.cta { padding: 0 0 88px; }
.cta-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
  padding: 2.75rem; color: #fff; border-radius: 24px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: var(--shadow-lg);
}
.cta-inner h2 { margin: 0; font-size: clamp(1.4rem, 3vw, 2rem); }

/* Footer */
.site-footer { padding: 3rem 0 1.5rem; background: var(--surface); border-top: 1px solid var(--border); }
.footer-inner { display: flex; justify-content: space-between; align-items: flex-start; gap: 2rem; flex-wrap: wrap; }
.footer-inner .brand { margin-bottom: .6rem; }
.footer-links { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--primary); }
.copyright { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }

/* Legal pages */
.legal { padding: 64px 0 88px; }
.legal h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; }
.legal h2 { font-size: 1.25rem; margin-top: 2rem; }
.legal p, .legal li { color: var(--muted); }

/* ---------- Animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }

.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .features { grid-template-columns: repeat(2, 1fr); }

  /* Hamburger + slide-in drawer menu */
  .site-header {
    /* backdrop-filter would trap the fixed drawer inside the header */
    background: var(--surface);
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .nav-toggle { display: flex; }
  .nav-menu {
    position: fixed; z-index: 1;
    top: var(--header-h); right: 0; bottom: 0;
    width: min(82vw, 320px);
    flex-direction: column; align-items: stretch; gap: 0;
    margin: 0; padding: 1rem 20px calc(1.5rem + env(safe-area-inset-bottom, 0px));
    overflow-y: auto; overscroll-behavior: contain;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: -20px 0 40px -20px rgba(15, 23, 42, .35);
    transform: translateX(100%); visibility: hidden;
    transition: transform .3s cubic-bezier(.4, 0, .2, 1), visibility .3s;
  }
  .nav-menu.open { transform: none; visibility: visible; }
  .nav-menu-title {
    display: block; padding: .25rem 0 .75rem;
    font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  }
  .nav-menu a {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem .25rem; font-size: 1.05rem; color: var(--text);
    border-bottom: 1px solid var(--border);
  }
  .nav-menu a::after { content: "›"; font-size: 1.4rem; line-height: 1; color: var(--muted); }
  .nav-menu a:active { color: var(--primary); }
  .nav-actions { margin-left: auto; }

  .nav-overlay {
    display: block; position: fixed; inset: var(--header-h) 0 0 0; z-index: 45;
    background: rgba(15, 23, 42, .45);
    opacity: 0; transition: opacity .3s;
  }
  .nav-overlay.visible { opacity: 1; }
  .nav-overlay[hidden] { display: none; }
  body.nav-open { overflow: hidden; }
}

@media (max-width: 760px) {

  .steps { grid-template-columns: 1fr; }
  .result { grid-template-columns: 1fr; }
  .section { padding: 64px 0; }
  .cta-inner { flex-direction: column; text-align: center; padding: 2rem 1.5rem; }
}

@media (max-width: 560px) {
  .hero { padding: 48px 0 56px; }
  .dl-form { flex-direction: column; }
  #dl-btn { width: 100%; }
  .features { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; }
}

/* ---------- Cookie consent banner ---------- */
.consent {
  position: fixed; z-index: 100;
  left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  max-width: 560px; margin-inline: auto;
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.15rem;
  font-size: .9rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 20px 50px -15px rgba(15, 23, 42, .45);
  opacity: 0; transform: translateY(16px);
  transition: opacity .3s, transform .3s;
}
.consent.visible { opacity: 1; transform: none; }
.consent p { margin: 0; color: var(--muted); }
.consent p strong { color: var(--text); }
.consent-actions { display: flex; gap: .5rem; flex-shrink: 0; }
.consent .btn { padding: .6rem 1.1rem; font-size: .9rem; }
.btn-ghost-border { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost-border:hover { border-color: var(--primary); color: var(--primary); }
@media (max-width: 560px) {
  .consent { flex-direction: column; align-items: stretch; }
  .consent-actions .btn { flex: 1; }
}

/* ---------- Disclaimer notes ---------- */
.form-note { margin: .35rem auto 0; max-width: 620px; font-size: .82rem; color: var(--muted); }
.form-note a { text-decoration: underline; }
.footer-disclaimer { max-width: 440px; }
.notice {
  padding: 1rem 1.25rem; margin: 1.5rem 0;
  border-left: 4px solid var(--primary); border-radius: 10px;
  background: color-mix(in srgb, var(--primary) 7%, var(--surface));
}
.notice p { margin: 0; color: var(--text); }

/* ---------- Long-form SEO content ---------- */
.prose h3 { margin-top: 2rem; font-size: 1.2rem; }
.prose p, .prose li { color: var(--muted); }
.prose strong { color: var(--text); }
.prose ul { padding-left: 1.2rem; }
.prose li { margin-bottom: .4rem; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.link-types { list-style: none; padding: 0 !important; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .5rem; }
.link-types li { margin: 0; padding: .6rem .8rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; font-size: .9rem; }
.prose code, .legal code { font-size: .85em; padding: .1em .35em; border-radius: 5px; background: var(--surface-2); color: var(--text); word-break: break-all; }

/* ---------- Video preview ---------- */
.preview-btn {
  position: absolute; inset: 0; margin: auto;
  display: grid; place-items: center; width: 64px; height: 64px; padding: 0 0 0 4px;
  color: #fff; background: rgba(15, 23, 42, .6); border: 2px solid rgba(255, 255, 255, .85); border-radius: 50%;
  cursor: pointer; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: transform .2s, background .2s;
}
.preview-btn:hover { transform: scale(1.08); background: linear-gradient(135deg, var(--primary), var(--accent)); }
.result-thumb.playing { aspect-ratio: 16 / 9; background: #000; }
.result-thumb.playing.portrait { aspect-ratio: 9 / 16; max-height: 70vh; margin-inline: auto; }
.result-thumb.playing img, .result-thumb.playing .preview-btn, .result-thumb.playing .badge { display: none; }
.result-thumb video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }

/* ---------- Logo tagline ---------- */
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 1.2rem; }
.brand-tagline {
  margin-top: 2px;
  font-size: .68rem; font-weight: 500; letter-spacing: .02em;
  color: var(--muted); white-space: nowrap;
}
@media (max-width: 420px) {
  .site-header .brand { gap: .45rem; min-width: 0; }
  .site-header .brand img { width: 30px; height: 30px; }
  .site-header .brand-name { font-size: 1.08rem; }
  .site-header .brand-tagline { font-size: .58rem; letter-spacing: 0; }
  .nav-actions { gap: .4rem; }
}
@media (max-width: 351px) { .site-header .brand-tagline { display: none; } }
