/* ==========================================================================
   IG Stories Downloader — Instagram stories downloader
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7fb;
  --card: #ffffff;
  --text: #0d1020;
  --text-soft: #3c4257;
  --muted: #6b7288;
  --border: #e6e8f0;
  --border-strong: #d3d7e4;
  --brand: #e1306c;
  --grad: linear-gradient(120deg, #7b3ff2 0%, #e1306c 55%, #f7b928 100%);
  --ring: rgba(225, 48, 108, 0.22);
  --shadow-sm: 0 1px 2px rgba(13, 16, 32, 0.06);
  --shadow: 0 1px 2px rgba(13, 16, 32, 0.05), 0 16px 40px -20px rgba(13, 16, 32, 0.28);
  --radius: 16px;
  --radius-sm: 11px;
  --wrap: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #08080d;
    --bg-soft: #0d0e15;
    --card: #12131c;
    --text: #f3f4f9;
    --text-soft: #c8ccdb;
    --muted: #9aa0b5;
    --border: #23252f;
    --border-strong: #31343f;
    --ring: rgba(225, 48, 108, 0.35);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 20px 44px -22px rgba(0, 0, 0, 0.9);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
video,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0;
  font-weight: 700;
}

p {
  margin: 0;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

.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;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--text);
  color: var(--bg);
  border-radius: 8px;
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 12px;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 20px;
}

.wrap-narrow {
  max-width: 780px;
}

/* ---------------------------------------------------------------- header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 62px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.05rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 6px 16px -8px rgba(225, 48, 108, 0.9);
}

.brand-name span {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.site-nav {
  display: flex;
  gap: 22px;
  font-size: 0.92rem;
  color: var(--muted);
}

.site-nav a {
  text-decoration: none;
  transition: color 0.15s ease;
}

.site-nav a:hover {
  color: var(--text);
}

@media (max-width: 620px) {
  .site-nav {
    display: none;
  }
}

/* ------------------------------------------------------------------ hero */

.hero {
  position: relative;
  padding: clamp(44px, 7vw, 84px) 0 clamp(24px, 4vw, 40px);
  text-align: center;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -40% 0 auto;
  height: 480px;
  background:
    radial-gradient(42% 55% at 22% 30%, rgba(123, 63, 242, 0.16), transparent 70%),
    radial-gradient(40% 55% at 78% 22%, rgba(225, 48, 108, 0.16), transparent 70%),
    radial-gradient(38% 45% at 50% 62%, rgba(247, 185, 40, 0.13), transparent 72%);
  pointer-events: none;
  z-index: -1;
}

.hero h1 {
  font-size: clamp(2rem, 5.4vw, 3.3rem);
  max-width: 18ch;
  margin-inline: auto;
}

.lede {
  max-width: 58ch;
  margin: 16px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 2.2vw, 1.12rem);
}

/* ---------------------------------------------------------------- search */

.search {
  display: flex;
  gap: 10px;
  align-items: stretch;
  max-width: 720px;
  margin: 30px auto 0;
}

.search-field {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 8px 0 14px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-field:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
}

.search-icon {
  flex: none;
  color: var(--muted);
}

#story-url {
  flex: 1 1 auto;
  min-width: 0;
  height: 50px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.97rem;
}

#story-url::placeholder {
  color: color-mix(in srgb, var(--muted) 78%, transparent);
}

#story-url:focus {
  outline: none;
}

.btn-ghost {
  flex: none;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-soft);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-ghost:hover {
  background: var(--border);
  color: var(--text);
}

.btn-primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: none;
  padding: 0 26px;
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  background: var(--grad);
  color: #fff;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 10px 26px -12px rgba(225, 48, 108, 0.85);
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary[disabled] {
  cursor: progress;
  filter: saturate(0.6) brightness(0.95);
  transform: none;
}

.spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.search[data-loading="true"] .spinner {
  display: block;
}

.search[data-loading="true"] .btn-label {
  opacity: 0.85;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 560px) {
  .search {
    flex-direction: column;
    gap: 12px;
  }

  .search-field {
    padding-inline: 14px 8px;
  }

  .btn-primary {
    width: 100%;
    min-height: 50px;
  }
}

/* ---------------------------------------------------------------- result */

.result-section {
  padding-bottom: 8px;
}

.status {
  margin: 0 auto;
  max-width: 720px;
  text-align: center;
  font-size: 0.93rem;
  color: var(--muted);
}

.status:empty {
  display: none;
}

.status[data-tone="error"] {
  max-width: 640px;
  margin-top: 4px;
  padding: 13px 16px;
  border: 1px solid color-mix(in srgb, #e5484d 34%, var(--border));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, #e5484d 8%, var(--card));
  color: color-mix(in srgb, #e5484d 78%, var(--text));
}

.status[data-tone="info"] {
  margin-top: 4px;
}

.result {
  max-width: 860px;
  margin: 18px auto 0;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: rise 0.28s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.profile {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
}

.profile-meta {
  min-width: 0;
}

.profile-name {
  font-weight: 700;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-sub {
  font-size: 0.83rem;
  color: var(--muted);
}

.result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-secondary:hover {
  background: var(--border);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.media-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.media-frame {
  display: grid;
  place-items: center;
  background:
    repeating-conic-gradient(
      color-mix(in srgb, var(--muted) 10%, transparent) 0% 25%,
      transparent 0% 50%
    )
    50% / 18px 18px;
  min-height: 200px;
}

.media-frame img,
.media-frame video {
  width: 100%;
  height: auto;
  max-height: 380px;
  object-fit: contain;
  background: #000;
}

.media-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--card);
}

.media-tag {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font: inherit;
  font-size: 0.83rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn-download:hover {
  opacity: 0.85;
}

/* -------------------------------------------------------------- sections */

.section {
  padding: clamp(48px, 7vw, 84px) 0;
}

.section h2 {
  font-size: clamp(1.5rem, 3.4vw, 2.05rem);
  text-align: center;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
  margin: 38px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  padding: 24px 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.step-num {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-bottom: 14px;
  border-radius: 10px;
  background: var(--grad);
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
}

.steps h3 {
  font-size: 1.02rem;
  margin-bottom: 7px;
}

.steps p {
  color: var(--muted);
  font-size: 0.92rem;
}

.faq-item {
  margin-top: 12px;
  padding: 4px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0;
  font-weight: 600;
  font-size: 0.97rem;
  cursor: pointer;
  list-style: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  flex: none;
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
}

.faq-item p {
  padding: 0 0 18px;
  color: var(--muted);
  font-size: 0.93rem;
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  padding: 40px 0 48px;
  border-top: 1px solid var(--border);
  font-size: 0.87rem;
  color: var(--muted);
}

.footer-inner {
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
}

.footer-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.footer-note {
  max-width: 66ch;
  font-size: 0.83rem;
  line-height: 1.65;
}

.footer-copy {
  font-size: 0.8rem;
  opacity: 0.85;
}

/* ------------------------------------------------------------- utilities */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .site-header,
  .search,
  .site-footer {
    display: none;
  }
}
