/* ═══════════════════════════════════════════════════════════════
   InstaDown — Complete Mobile-First Redesign
   Base: 375px (iPhone SE/12/13 size)
   Breakpoints: 600px (tablet), 1024px (desktop)
═══════════════════════════════════════════════════════════════ */

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

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Instagram brand colours */
  --ig1: #f09433;
  --ig3: #dc2743;
  --ig5: #bc1888;
  --grad: linear-gradient(135deg, #f09433, #dc2743, #bc1888);

  /* Backgrounds */
  --bg-page:   #0a0a18;
  --bg-card:   #141428;
  --bg-input:  #0e0e20;
  --bg-muted:  #1a1a30;

  /* Borders */
  --brd: rgba(255,255,255,0.10);
  --brd-focus: #dc2743;

  /* Text */
  --txt:   #f0f0ff;
  --muted: rgba(240,240,255,0.52);

  /* Feedback */
  --green: #22c55e;
  --red:   #f87171;

  /* Shadows */
  --card-shadow: 0 8px 32px rgba(0,0,0,0.55);
  --glow:        0 0 60px rgba(220,39,67,0.12);

  /* Transition */
  --ease: 0.18s ease;

  /* Touch target minimum */
  --touch: 48px;
}

/* ── Base Styles ───────────────────────────────────────────── */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-page);
  color: var(--txt);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input { font-family: inherit; }

/* ── Layout Container ──────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── Gradient Text ─────────────────────────────────────────── */
.grad-txt {
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ══════════════════════════════════════════════════════════════
   HEADER — compact, sticky, blurred
══════════════════════════════════════════════════════════════ */
.header {
  position: sticky;
  top: 0; z-index: 999;
  height: 52px;
  background: rgba(10,10,24,0.93);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--brd);
}
.header .container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo__icon { display: flex; align-items: center; flex-shrink: 0; }
.logo__name {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--txt);
}
.logo__name span {
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
/* Nav hidden on mobile */
.nav { display: none; gap: 24px; align-items: center; }
.nav a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  transition: color var(--ease);
}
.nav a:hover { color: var(--txt); }

/* ══════════════════════════════════════════════════════════════
   HERO SECTION
══════════════════════════════════════════════════════════════ */
.hero {
  background: linear-gradient(175deg, #0d0d22 0%, #171730 55%, #0d0d22 100%);
  padding: 36px 0 40px;
  position: relative;
  overflow: hidden;
}
/* Decorative glows */
.hero::before {
  content: "";
  position: absolute; top: -60px; right: -40px;
  width: 240px; height: 240px; border-radius: 50%;
  background: rgba(220,39,67,0.10);
  filter: blur(60px);
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute; bottom: -40px; left: -30px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(240,148,51,0.08);
  filter: blur(50px);
  pointer-events: none;
}

.hero__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  position: relative; z-index: 1;
}

/* Pill badge */
.hero__pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 5px 14px;
  border-radius: 999px;
}

.hero__title {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  padding: 0 8px;
}

.hero__sub {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.65;
  max-width: 320px;
  padding: 0 4px;
}

/* ══════════════════════════════════════════════════════════════
   DOWNLOADER CARD — the main widget
══════════════════════════════════════════════════════════════ */
.dl-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--brd);
  border-radius: 20px;
  box-shadow: var(--card-shadow), var(--glow);
  overflow: hidden;
  margin-top: 4px;
}

/* ══════════════════════════════════════════════════════════════
   TABS — 6 equal columns, scrollable on tiny screens
══════════════════════════════════════════════════════════════ */
.tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: var(--bg-input);
  border-bottom: 1px solid var(--brd);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 11px 4px 10px;
  border: none;
  border-bottom: 2.5px solid transparent;
  background: none;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
  cursor: pointer;
}
.tab:active { background: rgba(255,255,255,0.04); }
.tab--active {
  color: var(--txt);
  border-bottom-color: var(--ig3);
  background: rgba(220,39,67,0.07);
}
.tab__ico { font-size: 1.2rem; line-height: 1; }
.tab__lbl { font-size: 0.58rem; }

/* ══════════════════════════════════════════════════════════════
   TAB PANELS
══════════════════════════════════════════════════════════════ */
.tab-panel {
  display: none;
  padding: 18px 16px 20px;
}
.tab-panel--active { display: block; }

/* Tip row */
.tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--brd);
  border-radius: 10px;
  padding: 10px 13px;
  margin-bottom: 14px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}
.tip__ico { flex-shrink: 0; font-size: 0.9rem; margin-top: 1px; }
.tip code {
  font-size: 0.72rem;
  background: rgba(255,255,255,0.09);
  color: var(--ig1);
  padding: 1px 5px;
  border-radius: 4px;
  word-break: break-all;
}

/* ── URL input row ─────────────────────────────────────────── */
.input-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-ico {
  position: absolute;
  left: 14px;
  font-size: 1rem;
  pointer-events: none;
  z-index: 1;
  line-height: 1;
  top: 50%; transform: translateY(-50%);
}
.url-input {
  width: 100%;
  height: var(--touch);          /* 48px — iOS won't zoom */
  background: var(--bg-input);
  border: 1.5px solid var(--brd);
  border-radius: 12px;
  color: var(--txt);
  font-size: 1rem;               /* must be ≥ 16px to prevent iOS zoom */
  padding: 0 46px 0 42px;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
  -webkit-appearance: none;
}
.url-input::placeholder { color: var(--muted); font-size: 0.85rem; }
.url-input:focus {
  border-color: var(--brd-focus);
  box-shadow: 0 0 0 3px rgba(220,39,67,0.16);
}

/* Paste icon button */
.paste-btn {
  position: absolute;
  right: 10px;
  top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px;
  background: var(--bg-muted);
  border: 1px solid var(--brd);
  border-radius: 7px;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--ease);
  z-index: 1;
}
.paste-btn:active { transform: translateY(-50%) scale(0.93); }
.paste-btn:hover { color: var(--txt); background: var(--bg-card); }

/* Download button — full width on mobile */
.dl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 50px;
  background: var(--grad);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity var(--ease), transform var(--ease), box-shadow var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.dl-btn:hover { opacity: 0.92; box-shadow: 0 6px 22px rgba(220,39,67,0.38); }
.dl-btn:active { transform: scale(0.97); opacity: 0.85; }
.dl-btn:disabled { opacity: 0.55; pointer-events: none; }

.btn-spin {
  width: 19px; height: 19px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error alert ───────────────────────────────────────────── */
.err-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding: 11px 14px;
  background: rgba(248,113,113,0.10);
  border: 1px solid rgba(248,113,113,0.30);
  border-radius: 10px;
  font-size: 0.83rem;
  line-height: 1.5;
  color: var(--red);
}
.err-box[hidden] { display: none; }
.err-ico { flex-shrink: 0; }
.err-msg a { color: inherit; text-decoration: underline; }

/* ── Results ───────────────────────────────────────────────── */
.results { margin-top: 16px; }
.results[hidden] { display: none; }

/* Media meta row */
.res-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--brd);
  margin-bottom: 14px;
}
.res-thumb {
  width: 50px; height: 50px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-muted);
}
.res-thumb-ph {
  width: 50px; height: 50px;
  border-radius: 8px;
  background: var(--bg-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.res-info { flex: 1; min-width: 0; }
.res-type {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.res-caption {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Result items */
.res-grid { display: flex; flex-direction: column; gap: 10px; }
.res-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-input);
  border: 1px solid var(--brd);
  border-radius: 12px;
  padding: 11px 13px;
  transition: border-color var(--ease);
}
.res-item:hover { border-color: rgba(220,39,67,0.35); }
.res-item-thumb {
  width: 44px; height: 44px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-muted);
}
.res-item-ph {
  width: 44px; height: 44px;
  border-radius: 6px;
  background: var(--bg-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.res-item-info { flex: 1; min-width: 0; }
.res-item-label { font-size: 0.875rem; font-weight: 600; }
.res-item-meta { font-size: 0.72rem; color: var(--muted); margin-top: 1px; }
.res-item-action { flex-shrink: 0; }

/* Save button */
.save-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 36px;
  padding: 0 14px;
  background: var(--grad);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: opacity var(--ease), transform var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.save-btn:hover { opacity: 0.88; }
.save-btn:active { transform: scale(0.95); }

/* ══════════════════════════════════════════════════════════════
   HOW IT WORKS SECTION
══════════════════════════════════════════════════════════════ */
.section { padding: 52px 0; }
.section--alt { background: var(--bg-muted); }

.sec-head { text-align: center; margin-bottom: 32px; }
.sec-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}
.sec-sub { font-size: 0.875rem; color: var(--muted); }

/* Steps */
.steps {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--brd);
  border-radius: 16px;
  padding: 18px 16px;
  width: 100%;
  text-align: left;
}
.step-left { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.step-num {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  font-size: 0.78rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.step-ico { font-size: 1.6rem; }
.step-body {}
.step-title { font-size: 0.925rem; font-weight: 700; margin-bottom: 5px; }
.step-desc { font-size: 0.82rem; color: var(--muted); line-height: 1.6; }

/* ══════════════════════════════════════════════════════════════
   FEATURES GRID
══════════════════════════════════════════════════════════════ */
.feat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.feat-card {
  background: var(--bg-card);
  border: 1px solid var(--brd);
  border-radius: 16px;
  padding: 18px 14px;
  transition: border-color var(--ease), transform var(--ease);
}
.feat-card:hover { border-color: rgba(220,39,67,0.30); transform: translateY(-2px); }
.feat-ico { font-size: 1.5rem; margin-bottom: 10px; }
.feat-title { font-size: 0.85rem; font-weight: 700; margin-bottom: 5px; }
.feat-desc { font-size: 0.78rem; color: var(--muted); line-height: 1.55; }

/* ══════════════════════════════════════════════════════════════
   FAQ
══════════════════════════════════════════════════════════════ */
.faq { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--brd);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color var(--ease);
}
.faq-item:hover { border-color: rgba(220,39,67,0.25); }
.faq-q {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  background: none; border: none;
  color: var(--txt);
  font-size: 0.875rem; font-weight: 600;
  text-align: left;
  padding: 16px;
  min-height: 56px;
  cursor: pointer;
}
.faq-arr {
  flex-shrink: 0;
  width: 18px; height: 18px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform var(--ease);
  margin-top: -5px;
}
.faq-q[aria-expanded="true"] .faq-arr {
  transform: rotate(-135deg); margin-top: 3px;
}
.faq-a {
  display: none;
  padding: 0 16px 16px;
  font-size: 0.85rem; color: var(--muted); line-height: 1.7;
}
.faq-a code {
  background: var(--bg-muted);
  padding: 2px 6px; border-radius: 5px; font-size: 0.78em;
}
.faq-a.open { display: block; }
.faq-a strong { color: var(--txt); }

/* ══════════════════════════════════════════════════════════════
   FOOTER
══════════════════════════════════════════════════════════════ */
.footer {
  background: var(--bg-muted);
  border-top: 1px solid var(--brd);
  padding: 40px 0;
}
.footer__inner {
  display: flex; flex-direction: column;
  align-items: center; gap: 20px; text-align: center;
}
.footer__tagline { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.footer__links {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 8px 20px; font-size: 0.85rem; color: var(--muted);
}
.footer__links a:hover { color: var(--txt); }
.footer__copy { font-size: 0.72rem; color: var(--muted); }

/* ══════════════════════════════════════════════════════════════
   SCROLL REVEAL
══════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: no-preference) {
  .feat-card, .step, .faq-item {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.45s ease, transform 0.45s ease, border-color var(--ease);
  }
  .feat-card.visible, .step.visible, .faq-item.visible {
    opacity: 1; transform: translateY(0);
  }
}

/* ══════════════════════════════════════════════════════════════
   TINY PHONES  < 360px
══════════════════════════════════════════════════════════════ */
@media (max-width: 359px) {
  .hero__title { font-size: 1.4rem; }
  .tab { padding: 9px 2px; }
  .tab__lbl { display: none; }          /* icon-only */
  .tab__ico { font-size: 1.05rem; }
  .tab-panel { padding: 14px 12px 18px; }
  .feat-grid { grid-template-columns: 1fr; }
  .step { flex-direction: column; }
  .step-left { flex-direction: row; align-items: center; }
}

/* ══════════════════════════════════════════════════════════════
   TABLET  ≥ 600px
══════════════════════════════════════════════════════════════ */
@media (min-width: 600px) {
  .container { padding: 0 24px; }

  .header { height: 60px; }

  .hero { padding: 52px 0 60px; }
  .hero__title { font-size: 2.2rem; }
  .hero__sub { font-size: 0.95rem; max-width: 420px; }

  .dl-card { max-width: 580px; margin-inline: auto; }

  .tab { padding: 12px 6px; }
  .tab__ico { font-size: 1.35rem; }
  .tab__lbl { font-size: 0.62rem; }

  /* Side-by-side input + button on tablet */
  .input-row { flex-direction: row; }
  .input-row .dl-btn { width: auto; flex-shrink: 0; padding: 0 28px; border-radius: 12px; }

  .steps { gap: 16px; }

  .sec-title { font-size: 1.75rem; }
  .feat-grid { gap: 16px; }
  .feat-card { padding: 22px 18px; }
  .feat-ico { font-size: 1.7rem; }
  .feat-title { font-size: 0.9rem; }
  .feat-desc { font-size: 0.82rem; }
}

/* ══════════════════════════════════════════════════════════════
   DESKTOP  ≥ 1024px
══════════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  .container { padding: 0 40px; }

  .header { height: 64px; }
  .logo__name { font-size: 1.25rem; }
  .nav { display: flex; }

  .hero { padding: 72px 0 80px; }
  .hero__title { font-size: 3rem; }
  .hero__sub { font-size: 1.05rem; max-width: 500px; }

  .dl-card { max-width: 680px; }

  .tab { padding: 13px 10px; }
  .tab__ico { font-size: 1.5rem; }
  .tab__lbl { font-size: 0.68rem; }
  .tab-panel { padding: 24px 28px 28px; }

  .sec-title { font-size: 2rem; }
  .section { padding: 72px 0; }

  /* Steps — horizontal on desktop */
  .steps { flex-direction: row; align-items: stretch; gap: 20px; }
  .step { flex: 1; flex-direction: column; text-align: center; }
  .step-left { flex-direction: column; align-items: center; }

  .feat-grid { grid-template-columns: repeat(3, 1fr); gap: 20px; }

  .footer__inner { flex-direction: row; justify-content: space-between; text-align: left; }
  .footer__links { justify-content: flex-start; }
}
