/* ═══════════════════════════════════════════════════════════════════
   TikSnap UI — Stylesheet v2 (Optimized)
   Critical above-the-fold styles are inlined in index.html.
   This file contains the full stylesheet loaded non-blocking.
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  color: #1a1a2e;
  background-color: #f8f9ff;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: inherit; }
ul { list-style: none; }

/* Accessibility */
.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 for keyboard navigation */
:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ─── Navbar ───────────────────────────────────────────────────── */
.navbar {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 100;
  height: 60px;
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.navbar-brand a {
  font-size: 1.5rem;
  font-weight: 800;
  color: #2563eb;
  letter-spacing: -0.5px;
}

.navbar-brand a span {
  color: #0f172a;
}

.navbar-end {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Language Switcher */
.lang-switcher {
  position: relative;
}

.lang-switcher-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
  transition: all 0.2s;
}

.lang-switcher-toggle:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.lang-switcher-toggle svg { transition: transform 0.2s; }
.lang-switcher.open .lang-switcher-toggle svg { transform: rotate(180deg); }

.lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  min-width: 160px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s;
  z-index: 50;
  overflow: hidden;
}

.lang-switcher.open .lang-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-dropdown a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  color: #334155;
  transition: background 0.15s;
}

.lang-dropdown a:hover { background: #f1f5f9; }
.lang-dropdown a.active { background: #eff6ff; color: #2563eb; font-weight: 600; }

/* Mobile Nav */
.navbar-burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  gap: 5px;
  padding: 0;
}

.navbar-burger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #334155;
  border-radius: 2px;
  transition: all 0.3s;
}

.navbar-burger.is-active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.navbar-burger.is-active span:nth-child(2) { opacity: 0; }
.navbar-burger.is-active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.navbar-menu {
  display: flex;
  align-items: center;
}

@media (max-width: 640px) {
  .navbar-burger { display: flex; }
  .navbar-menu {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    padding: 1rem;
    flex-direction: column;
    align-items: stretch;
  }
  .navbar-menu.is-active { display: flex; }
  .lang-dropdown { right: auto; left: 0; }
}

/* ─── Hero Section ─────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 50%, #ede9fe 100%);
  padding: 3rem 0 3.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(99,102,241,0.08) 0%, transparent 70%);
  border-radius: 50%;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: #1e293b;
  line-height: 1.15;
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
}

.hero-subtitle {
  font-size: 1.1rem;
  font-weight: 400;
  color: #475569;
  margin-bottom: 2rem;
}

/* ─── Download Form ────────────────────────────────────────────── */
.download-form {
  max-width: 680px;
  margin: 0 auto;
  position: relative;
}

.form-wrapper {
  background: #fff;
  border-radius: 16px;
  padding: 6px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.input-wrapper {
  flex: 1;
  position: relative;
}

.url-input {
  width: 100%;
  border: none;
  outline: none;
  padding: 14px 90px 14px 16px;
  font-size: 1rem;
  color: #1e293b;
  background: #f8fafc;
  border-radius: 12px;
  transition: background 0.2s;
}

.url-input:focus { background: #f1f5f9; }

.url-input::placeholder { color: #94a3b8; }

.paste-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s;
}

.paste-btn:hover { background: #dbeafe; }
.paste-btn.has-text { background: #fef2f2; color: #dc2626; }
.paste-btn.has-text:hover { background: #fee2e2; }

.submit-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  transition: all 0.3s;
  white-space: nowrap;
}

.submit-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(37,99,235,0.4); }
.submit-btn:active { transform: translateY(0); }
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

.submit-btn svg { flex-shrink: 0; }

/* Error Box */
.error-box {
  margin-top: 0.75rem;
  padding: 0.65rem 1rem;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  display: none;
  text-align: left;
  border: 1px solid #fecaca;
}

.error-box.show { display: block; animation: slideDown 0.3s ease; }

/* Loader */
.loader {
  display: none;
  justify-content: center;
  margin-top: 1.5rem;
}

.loader.show { display: flex; }

.loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Result Box ───────────────────────────────────────────────── */
.result-box {
  max-width: 680px;
  margin: 0 auto;
  display: none;
}

.result-box.show {
  display: block;
  animation: slideDown 0.4s ease;
}

.result-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  overflow: hidden;
  margin-top: 1.25rem;
}

.result-header {
  display: flex;
  gap: 1rem;
  padding: 1rem;
}

.result-cover {
  width: 100px;
  height: 130px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: #f1f5f9;
}

.result-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: #f1f5f9;
}

.result-info {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.result-author {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.result-author .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.author-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #1e293b;
}

.result-desc {
  font-size: 0.8rem;
  color: #64748b;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}

.result-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: auto;
}

.stat {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 500;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 1rem 1rem;
}

/* ─── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(37,99,235,0.3); transform: translateY(-1px); }

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-audio {
  background: #faf5ff;
  color: #7c3aed;
  border: 1px solid #e9d5ff;
}
.btn-audio:hover { background: #f3e8ff; }

/* ─── Sections ─────────────────────────────────────────────────── */
.section {
  padding: 3rem 0;
}

.section-title {
  font-size: 1.75rem;
  font-weight: 800;
  text-align: center;
  color: #1e293b;
  margin-bottom: 2rem;
  letter-spacing: -0.3px;
}

/* ─── How-To Steps ─────────────────────────────────────────────── */
.howto-section { background: #fff; }

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.step-card {
  text-align: center;
  padding: 1.5rem 1rem;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  transition: all 0.3s;
  position: relative;
}

.step-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.06); }

.step-card,
.feature-card,
.faq-item { contain: content; }

.step-icon { font-size: 2rem; margin-bottom: 0.5rem; }

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.step-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.4rem;
}

.step-desc {
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .steps-grid { grid-template-columns: 1fr; gap: 1rem; }
}

/* ─── Features ─────────────────────────────────────────────────── */
.features-section { background: #f8f9ff; }

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.feature-card {
  padding: 1.5rem;
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  transition: all 0.3s;
}

.feature-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.06); }

.feature-icon { font-size: 1.75rem; margin-bottom: 0.75rem; }

.feature-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.3rem;
}

.feature-desc {
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.5;
}

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

@media (max-width: 480px) {
  .features-grid { grid-template-columns: 1fr; }
}

/* ─── FAQ ──────────────────────────────────────────────────────── */
.faq-section { background: #fff; }

.faq-list {
  max-width: 720px;
  margin: 0 auto;
}

.faq-item {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 0.75rem;
  overflow: hidden;
  transition: all 0.2s;
}

.faq-item:hover { border-color: #cbd5e1; }
.faq-item.open { border-color: #93c5fd; box-shadow: 0 2px 8px rgba(37,99,235,0.08); }

.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1rem 1.25rem;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1e293b;
  gap: 1rem;
}

.faq-question:hover { color: #2563eb; }

.faq-arrow {
  flex-shrink: 0;
  transition: transform 0.3s;
  color: #94a3b8;
}

.faq-item.open .faq-arrow { transform: rotate(180deg); color: #2563eb; }

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.faq-item.open .faq-answer { max-height: 300px; }

.faq-answer p {
  padding: 0 1.25rem 1rem;
  font-size: 0.875rem;
  color: #64748b;
  line-height: 1.65;
}

/* ─── Footer ───────────────────────────────────────────────────── */
.footer {
  margin-top: auto;
  background: #0f172a;
  color: #94a3b8;
  padding: 2.5rem 0 1.5rem;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.footer-brand {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  margin-bottom: 0.5rem;
}

.footer-brand span { color: #60a5fa; }

.footer-desc {
  font-size: 0.85rem;
  max-width: 340px;
  line-height: 1.6;
}

.footer-links {
  display: flex;
  gap: 2rem;
}

.footer-links a {
  font-size: 0.85rem;
  color: #94a3b8;
  transition: color 0.2s;
}

.footer-links a:hover { color: #fff; }

.footer-bottom {
  border-top: 1px solid #1e293b;
  padding-top: 1rem;
  font-size: 0.8rem;
  text-align: center;
}

@media (max-width: 640px) {
  .footer-content { flex-direction: column; align-items: center; text-align: center; }
  .footer-desc { max-width: 100%; }
}

/* ─── Responsive Hero ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .hero { padding: 2rem 0 2.5rem; }
  .hero-title { font-size: 1.75rem; }
  .hero-subtitle { font-size: 0.95rem; }
  .form-wrapper { flex-direction: column; }
  .submit-btn { width: 100%; justify-content: center; }
  .section-title { font-size: 1.4rem; }
}

@media (max-width: 480px) {
  .hero-title { font-size: 1.5rem; }
  .url-input { padding: 12px 80px 12px 14px; font-size: 0.9rem; }
}

/* ─── Loading State on Form ────────────────────────────────────── */
.download-form.loading .form-wrapper { opacity: 0.6; pointer-events: none; }

/* ─── Reduced Motion ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─── Print ────────────────────────────────────────────────────── */
@media print {
  .navbar, .download-form, .loader, .error-box, .lang-switcher { display: none !important; }
  .hero { background: none; padding: 1rem 0; }
  .footer { background: #fff; color: #000; }
}
