/* dlthisvid — the downloader arrangement people already know how to use,
 * built at the finish level of a tool that respects them. */

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

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

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

h1, h2, h3 {
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 0;
}

p { margin: 0; }

a { color: inherit; }

.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -3rem;
  z-index: 10;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top 160ms var(--ease);
}
.skip-link:focus { top: var(--space-3); }

:where(a, button, input, select, summary):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.icon {
  width: 1.125rem;
  height: 1.125rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes spin { to { transform: rotate(1turn); } }
.spin { animation: spin 700ms linear infinite; }

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

.site-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-block: var(--space-4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
  margin-right: auto;
}
.brand-mark { width: 26px; height: 26px; flex: none; }
.brand em { font-style: normal; color: var(--text-muted); }

.site-nav {
  display: flex;
  gap: var(--space-4);
  font-size: var(--step--1);
}
.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding-block: var(--space-1);
  transition: color 140ms var(--ease);
}
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current='page'] { color: var(--text); }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 140ms var(--ease), border-color 140ms var(--ease);
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }

/* ---------- the tool ---------- */

.hero {
  padding-block: var(--space-7) var(--space-5);
}

.hero h1 {
  font-size: var(--step-4);
  font-weight: 620;
  letter-spacing: -0.035em;
}

.hero > p {
  margin-top: var(--space-3);
  max-width: 52ch;
  color: var(--text-muted);
  font-size: var(--step-1);
}

.grab {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

.grab-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 var(--space-4);
  color: var(--text);
  font: inherit;
  font-size: var(--step-0);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 140ms var(--ease), background 140ms var(--ease);
}
.grab-input::placeholder { color: var(--text-muted); opacity: 1; }
.grab-input:hover { border-color: var(--border-strong); }
.grab-input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}
.grab-input[aria-invalid='true'] { border-color: var(--danger); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 var(--space-5);
  color: var(--accent-text);
  font: inherit;
  font-weight: 550;
  white-space: nowrap;
  text-decoration: none;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 140ms var(--ease), transform 140ms var(--ease);
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.btn-secondary {
  color: var(--text);
  background: var(--surface-raised);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface); border-color: var(--text-muted); }

.status {
  margin-top: var(--space-3);
  min-height: 1.4em;
  color: var(--text-muted);
  font-size: var(--step--1);
}
.status[data-tone='error'] {
  color: var(--danger);
  padding: var(--space-3) var(--space-4);
  background: var(--danger-surface);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  border-radius: var(--radius);
}

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

.result { margin-top: var(--space-5); }

.result-title {
  font-size: var(--step-2);
  font-weight: 600;
}

.result-by {
  margin-top: var(--space-1);
  color: var(--text-muted);
  font-size: var(--step--1);
}

.quality-list {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.quality {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* The one authored moment: rows settle in, from an already-visible default. */
  animation: settle 420ms var(--ease) backwards;
}
.quality:nth-child(2) { animation-delay: 60ms; }
.quality:nth-child(3) { animation-delay: 120ms; }

@keyframes settle {
  from { opacity: 0; transform: translateY(6px); }
}

.quality-label {
  display: block;
  font-weight: 560;
}

.quality-note {
  display: block;
  color: var(--text-muted);
  font-size: var(--step--1);
}

/* The figure is the decision on this page, so it is sized to be read before
 * the button is pressed, not after. */
.quality-size {
  font-family: var(--font-mono);
  font-size: var(--step-2);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  color: var(--text);
  white-space: nowrap;
}
.quality-size .unit {
  margin-left: 0.15em;
  font-size: var(--step--1);
  color: var(--text-muted);
}

/* ---------- prose ---------- */

.prose {
  padding-block: var(--space-7);
  border-top: 1px solid var(--border);
}

.prose h2 {
  margin-top: var(--space-7);
  margin-bottom: var(--space-3);
  font-size: var(--step-2);
  font-weight: 600;
}
.prose h2:first-child { margin-top: 0; }

.prose p {
  margin-top: var(--space-3);
  max-width: 68ch;
  color: var(--text-muted);
}

.prose code {
  padding: 0.1em 0.35em;
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.steps {
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: var(--space-4);
}
.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-3);
  max-width: 68ch;
  color: var(--text-muted);
}
.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 1.6rem; height: 1.6rem;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
}
.steps strong { color: var(--text); font-weight: 560; }

.faq-item {
  border-bottom: 1px solid var(--border);
}
.faq-item summary {
  padding-block: var(--space-4);
  font-weight: 550;
  cursor: pointer;
  list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+';
  float: right;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.faq-item[open] summary::after { content: '\2212'; }
.faq-item p {
  margin: 0;
  padding-bottom: var(--space-4);
  max-width: 68ch;
  color: var(--text-muted);
}

.more-link {
  display: inline-block;
  margin-top: var(--space-5);
  color: var(--text);
  font-size: var(--step--1);
  text-underline-offset: 4px;
}

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

.site-footer {
  padding-block: var(--space-6) var(--space-7);
  margin-top: var(--space-7);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--step--1);
}
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.site-footer p { max-width: 68ch; }

/* ---------- small screens ---------- */

@media (max-width: 34rem) {
  .site-nav { gap: var(--space-3); }
  .grab { flex-wrap: wrap; }
  .grab-input { flex-basis: 100%; }
  .btn { width: 100%; }

  .quality {
    grid-template-columns: 1fr auto;
    row-gap: var(--space-3);
  }
  .quality .btn {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
