/* ═══════════════════════════════════════════════
   AnyDown — style.css
   Palette: Mustard (#E8B800) + Black/Near-Black
   ═══════════════════════════════════════════════ */

:root {
  --mustard:        #E8B800;
  --mustard-light:  #FFD43B;
  --mustard-dark:   #B88A00;
  --mustard-glow:   rgba(232, 184, 0, 0.35);
  --black:          #0A0A0A;
  --surface:        #111111;
  --surface-2:      #1A1A1A;
  --surface-3:      #242424;
  --text-primary:   #F0E6C8;
  --text-secondary: #8A7A5A;
  --text-muted:     #4A4030;
  --radius-sm:      8px;
  --radius-md:      14px;
  --radius-lg:      20px;
  --transition:     0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--black);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

#bgCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
}

.wrapper {
  position: relative;
  z-index: 2;
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* ════════════════════════════
   HEADER
════════════════════════════ */
.header {
  text-align: center;
  padding: 72px 0 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--mustard), var(--mustard-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 0 0 1px rgba(232,184,0,0.3),
    0 8px 32px rgba(232,184,0,0.25),
    0 2px 8px rgba(0,0,0,0.6);
  margin-bottom: 6px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.logo-mark:hover {
  transform: scale(1.05) rotate(-2deg);
  box-shadow:
    0 0 0 1px rgba(232,184,0,0.5),
    0 12px 48px rgba(232,184,0,0.4),
    0 2px 8px rgba(0,0,0,0.6);
}
.favicon-img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 10px;
}
.logo-fallback {
  font-size: 28px;
  color: var(--black);
  font-weight: 900;
  line-height: 1;
}
.favicon-img + .logo-fallback { display: none; }

.brand {
  font-family: 'Bebas Neue', 'Impact', sans-serif;
  font-size: clamp(3.2rem, 10vw, 5.5rem);
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1;
  background: linear-gradient(135deg, var(--mustard-light) 0%, var(--mustard) 40%, var(--mustard-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 24px var(--mustard-glow));
  animation: brandReveal 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes brandReveal {
  from { opacity: 0; transform: translateY(20px) scaleX(0.9); letter-spacing: 0.2em; }
  to   { opacity: 1; transform: translateY(0) scaleX(1); }
}

.tagline {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 300;
  letter-spacing: 0.03em;
  animation: fadeUp 0.7s 0.3s both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════
   SEARCH BAR
════════════════════════════ */
.search-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: fadeUp 0.7s 0.45s both;
}

.search-bar {
  width: 100%;
  display: flex;
  background: var(--surface);
  border: 1.5px solid var(--surface-3);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

.search-bar:focus-within {
  border-color: var(--mustard);
  box-shadow: 0 0 0 3px var(--mustard-glow), 0 8px 32px rgba(0,0,0,0.5);
}

.url-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 18px 22px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.97rem;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}
.url-input::placeholder { color: var(--text-muted); }

.fetch-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--mustard-light), var(--mustard));
  color: var(--black);
  border: none;
  padding: 18px 28px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: filter var(--transition), transform var(--transition);
  white-space: nowrap;
}
.fetch-btn:hover { filter: brightness(1.1); }
.fetch-btn:active { transform: scale(0.97); filter: brightness(0.95); }
.fetch-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-arrow {
  display: inline-block;
  transition: transform var(--transition);
}
.fetch-btn:hover:not(:disabled) .btn-arrow { transform: translateX(3px); }

.supported-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* ════════════════════════════
   RESULT SECTION
════════════════════════════ */
.result-section {
  width: 100%;
  margin-top: 40px;
}

/* ── Loading ── */
.state-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 60px 0;
}

.spinner {
  position: relative;
  width: 52px;
  height: 52px;
}
.spinner-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2.5px solid transparent;
  border-top-color: var(--mustard);
  animation: spin 1s linear infinite;
}
.spinner-ring--2 {
  inset: 8px;
  border-top-color: transparent;
  border-right-color: var(--mustard-dark);
  animation-duration: 0.7s;
  animation-direction: reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 300;
}

/* ── Generic Error ── */
.state-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 24px;
  background: rgba(255, 60, 60, 0.06);
  border: 1px solid rgba(255, 60, 60, 0.2);
  border-radius: var(--radius-lg);
  text-align: center;
  animation: fadeUp 0.4s both;
}
.error-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 60, 60, 0.15);
  border: 1.5px solid rgba(255,60,60,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #FF6B6B;
}
.error-msg {
  color: #FF9090;
  font-size: 0.92rem;
  line-height: 1.6;
}

/* ── YouTube Busy Card ── */
.state-yt-busy {
  animation: fadeUp 0.5s both;
}

.yt-busy-card {
  background: var(--surface);
  border: 1.5px solid rgba(232, 184, 0, 0.25);
  border-radius: var(--radius-lg);
  padding: 40px 32px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  box-shadow: 0 4px 32px rgba(232, 184, 0, 0.08);
}

.yt-busy-icon {
  margin-bottom: 4px;
}

.yt-busy-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--mustard-light);
  line-height: 1.3;
}

.yt-busy-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 420px;
}

.yt-busy-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-top: -4px;
}

/* ── Play Store Button (shared) ── */
.playstore-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--mustard);
  color: var(--black);
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 24px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: filter var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.playstore-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(232, 184, 0, 0.35);
}
.playstore-btn:active {
  transform: translateY(0) scale(0.97);
  filter: brightness(0.95);
}

/* Dark variant used in banner (black bg on mustard border) */
.playstore-btn--dark {
  background: var(--black);
  color: var(--mustard);
  border: 1.5px solid var(--mustard);
}
.playstore-btn--dark:hover {
  background: var(--mustard);
  color: var(--black);
}

/* ── Result Card ── */
.result-card {
  background: var(--surface);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.55);
  animation: cardReveal 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes cardReveal {
  from { opacity: 0; transform: translateY(28px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--surface-2);
  overflow: hidden;
}
.thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s ease;
}
.result-card:hover .thumb { transform: scale(1.03); }

.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 50%, rgba(10,10,10,0.75) 100%);
}

.card-body { padding: 28px 28px 32px; }

.video-title {
  font-family: 'DM Sans', sans-serif;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.45;
  margin-bottom: 6px;
}

.video-meta {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
  letter-spacing: 0.02em;
}

.formats-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mustard-dark);
  margin-bottom: 14px;
}

.formats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.format-item {
  background: var(--surface-2);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.format-item:hover {
  border-color: var(--mustard-dark);
  background: var(--surface-3);
  transform: translateY(-2px);
}

.format-info { flex: 1; min-width: 0; }
.format-quality { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.format-ext { font-size: 0.72rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }
.format-size { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.dl-btn {
  background: transparent;
  border: 1.5px solid var(--mustard);
  color: var(--mustard);
  border-radius: var(--radius-sm);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: background var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
  flex-shrink: 0;
  text-decoration: none;
}
.dl-btn:hover {
  background: var(--mustard);
  color: var(--black);
  box-shadow: 0 0 14px var(--mustard-glow);
  transform: scale(1.1);
}
.dl-btn:active { transform: scale(0.95); }

.format-group-label {
  grid-column: 1 / -1;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 0 4px;
  border-top: 1px solid var(--surface-3);
  margin-top: 6px;
}

/* ════════════════════════════
   APP BANNER
════════════════════════════ */
.app-banner {
  width: 100%;
  margin-top: 64px;
  background: var(--surface);
  border: 1.5px solid rgba(232, 184, 0, 0.2);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 32px rgba(0,0,0,0.4);
  animation: fadeUp 0.7s 0.6s both;
}

.app-banner-inner {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 36px 36px;
}

.app-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.app-banner-eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mustard);
}

.app-banner-title {
  font-family: 'Bebas Neue', 'Impact', sans-serif;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  line-height: 1.1;
}

.app-banner-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 380px;
}

/* QR code box */
.app-banner-qr {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.qr-frame {
  background: #111111;
  border: 1.5px solid rgba(232,184,0,0.3);
  border-radius: var(--radius-md);
  padding: 14px 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.qr-img {
  display: block;
  border-radius: 6px;
}

.qr-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
}

/* ════════════════════════════
   FOOTER
════════════════════════════ */
.footer {
  margin-top: auto;
  padding-top: 48px;
  text-align: center;
}
.footer p {
  font-size: 0.73rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ════════════════════════════
   UTILITIES
════════════════════════════ */
[hidden] { display: none !important; }

/* ════════════════════════════
   ADSTERRA STYLES - Responsive, non-intrusive
   ════════════════════════════ */

/* Ad container base styles */
.adsterra-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto;
  text-align: center;
  background: transparent;
  transition: opacity 0.2s ease;
}

/* Ensure core elements stay above ad layers */
.result-card, .search-section, .app-banner, .header {
  position: relative;
  z-index: 2;
}

/* ═══════════════════════════════════════════════
   MOBILE LAYOUT FIXES - CENTERED WITH TIGHT GROUPING
   ═══════════════════════════════════════════════ */

@media (max-width: 600px) {
  /* Make wrapper full height and center content vertically */
  .wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px 20px 40px;
  }
  
  /* HEADER - compact and tight */
  .header {
    padding: 0 0 12px 0 !important;
    gap: 4px !important;
    margin-top: 0;
  }
  
  .logo-mark {
    width: 56px;
    height: 56px;
    margin-bottom: 0;
  }
  
  .favicon-img {
    width: 40px;
    height: 40px;
  }
  
  .brand {
    font-size: clamp(2.2rem, 8vw, 3rem);
    margin-top: 0;
    letter-spacing: 0.06em;
  }
  
  .tagline {
    font-size: 0.75rem;
    margin-top: -2px;
  }
  
  /* SEARCH SECTION - directly below header with minimal gap */
  .search-section {
    margin-top: 8px;
    gap: 10px;
  }
  
  .url-input {
    padding: 14px 18px;
    font-size: 0.9rem;
  }
  
  .fetch-btn {
    padding: 14px 20px;
  }
  
  .supported-hint {
    font-size: 0.7rem;
  }
  
  /* RESULT SECTION - when visible */
  .result-section {
    margin-top: 24px;
    width: 100%;
  }
  
  /* APP BANNER - positioned right after search bar or result */
  .app-banner {
    margin-top: 28px;
    order: 3;
  }
  
  /* When video result is visible, app banner stays below it naturally */
  .result-card:not([hidden]) {
    margin-bottom: 0;
  }
  
  .result-card:not([hidden]) ~ .app-banner,
  .state-yt-busy:not([hidden]) ~ .app-banner,
  .state-error:not([hidden]) ~ .app-banner,
  .state-loading:not([hidden]) ~ .app-banner {
    margin-top: 28px;
  }
  
  /* Reorder elements for proper flow */
  .wrapper {
    display: flex;
    flex-direction: column;
  }
  
  .search-section {
    order: 1;
  }
  
  .result-section {
    order: 2;
  }
  
  .soft-ad-break {
    order: 3;
    margin: 16px auto 8px;
  }
  
  .app-banner {
    order: 4;
  }
  
  .footer {
    order: 5;
    margin-top: 32px;
    padding-top: 24px;
  }
  
  /* Hide desktop ads on mobile */
  .desktop-only {
    display: none !important;
  }
  
  /* Compact result card */
  .card-body {
    padding: 16px 14px 20px;
  }
  
  /* Single column formats for better touch */
  .formats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  /* Larger touch targets */
  .format-item {
    padding: 12px 14px;
  }
  
  .dl-btn {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }
  
  /* YouTube busy card compact */
  .yt-busy-card {
    padding: 24px 20px;
  }
  
  .yt-busy-title {
    font-size: 1.1rem;
  }
  
  .yt-busy-desc {
    font-size: 0.85rem;
  }
  
  /* App banner inner padding */
  .app-banner-inner {
    padding: 24px 20px;
  }
  
  .app-banner-title {
    font-size: 1.4rem;
  }
  
  .app-banner-desc {
    font-size: 0.8rem;
  }
  
  /* Hide QR code on mobile for cleaner look */
  .app-banner-qr {
    display: none;
  }
  
  .app-banner-text {
    align-items: center;
    text-align: center;
  }
}

/* Extra small devices (below 380px) */
@media (max-width: 380px) {
  .wrapper {
    padding: 16px 16px 32px;
  }
  
  .logo-mark {
    width: 48px;
    height: 48px;
  }
  
  .favicon-img {
    width: 34px;
    height: 34px;
  }
  
  .brand {
    font-size: 1.8rem;
  }
  
  .tagline {
    font-size: 0.7rem;
  }
  
  .url-input {
    padding: 12px 14px;
    font-size: 0.85rem;
  }
  
  .fetch-btn {
    padding: 12px 16px;
  }
  
  .btn-text {
    display: inline-block;
    font-size: 0.8rem;
  }
  
  .app-banner-title {
    font-size: 1.2rem;
  }
}
