/* ==========================================================================
   Power Scraping - marketing site + dashboard
   Vanilla CSS. No build step, no framework, no CDN.
   Works light and dark, and down to a 360px viewport.
   ========================================================================== */

/* --- Design tokens ------------------------------------------------------ */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --bg-alt: #f5f7fa;
  --surface: #ffffff;
  --surface-alt: #f0f3f8;
  --ink: #131820;
  --ink-soft: #4d5665;
  --ink-faint: #6b7688;
  --line: #d9e0ea;
  --line-strong: #b9c4d3;

  --accent: #1750d6;
  --accent-hover: #113ea8;
  --accent-ink: #ffffff;
  --accent-soft: #e8eeff;

  --ok: #0f6b45;
  --ok-soft: #e2f4ec;
  --warn: #8a5a00;
  --warn-soft: #fdf1da;
  --danger: #a51d2d;
  --danger-soft: #fdeaec;

  --focus: #1750d6;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);

  --measure: 68rem;
  --gutter: 20px;

  --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1017;
    --bg-alt: #12161f;
    --surface: #161b25;
    --surface-alt: #1c2230;
    --ink: #e8ecf4;
    --ink-soft: #b3bdcd;
    --ink-faint: #8b97a9;
    --line: #29313f;
    --line-strong: #3b4557;

    --accent: #7ba4ff;
    --accent-hover: #a2bfff;
    --accent-ink: #0d1017;
    --accent-soft: #1b2740;

    --ok: #6fdcaa;
    --ok-soft: #12271f;
    --warn: #f0c274;
    --warn-soft: #2b2314;
    --danger: #ff9ba5;
    --danger-soft: #2d171b;

    --focus: #7ba4ff;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 10px 28px rgba(0, 0, 0, 0.42);
  }
}

/* --- Reset -------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  /* The site header is sticky, so a fragment link or scrollIntoView() would
     otherwise land its target underneath it. Keep anchors clear of the bar. */
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  overflow-wrap: break-word;
}

img,
svg {
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  margin: 0 0 0.5em;
  letter-spacing: -0.015em;
}

h1 {
  font-size: clamp(2rem, 1.3rem + 3vw, 3.25rem);
}

h2 {
  font-size: clamp(1.5rem, 1.15rem + 1.6vw, 2.15rem);
}

h3 {
  font-size: 1.2rem;
}

p {
  margin: 0 0 1em;
}

ul,
ol {
  margin: 0 0 1em;
  padding-left: 1.25em;
}

li {
  margin-bottom: 0.35em;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-hover);
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

code {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.1em 0.35em;
}

pre {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 1em;
}

pre code {
  background: none;
  border: 0;
  padding: 0;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2.5rem 0;
}

/* --- Focus and skip link ------------------------------------------------ */

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  z-index: 100;
  border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
  left: 0;
}

/* --- Layout ------------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.wrap-narrow {
  max-width: 52rem;
}

section {
  padding: clamp(2.5rem, 1.5rem + 3vw, 4.5rem) 0;
  border-top: 1px solid var(--line);
}

section:first-of-type {
  border-top: 0;
}

.band {
  background: var(--bg-alt);
}

.lede {
  font-size: 1.15rem;
  color: var(--ink-soft);
  max-width: 44rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 0.75rem;
}

.section-head {
  max-width: 46rem;
  margin-bottom: 2rem;
}

/* --- Header and footer -------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding-top: 10px;
  padding-bottom: 10px;
}

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

.brand-mark {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  flex: 0 0 auto;
}

.site-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
  margin: 0;
  padding: 0;
}

.site-nav li {
  margin: 0;
}

.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 6px 2px;
  display: inline-block;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--ink);
  text-decoration: underline;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-alt);
  padding: 2.5rem 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.footer-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.footer-grid h2 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin-bottom: 0.6rem;
}

.footer-grid ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* --- Buttons ------------------------------------------------------------ */

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 12px 20px;
  background: var(--accent);
  color: var(--accent-ink);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: var(--accent-hover);
  color: var(--accent-ink);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-secondary:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--line-strong);
}

.btn-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-small {
  padding: 7px 13px;
  font-size: 0.88rem;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

/* --- Hero --------------------------------------------------------------- */

.hero {
  padding: clamp(2.5rem, 1rem + 6vw, 5.5rem) 0 clamp(2rem, 1rem + 3vw, 3.5rem);
  border-top: 0;
}

.hero h1 {
  max-width: 20ch;
}

.hero .lede {
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.3rem);
}

.hero-proof {
  list-style: none;
  padding: 0;
  margin: 2rem 0 0;
  display: grid;
  gap: 10px 22px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  max-width: 54rem;
}

.hero-proof li {
  position: relative;
  padding-left: 26px;
  color: var(--ink-soft);
  margin: 0;
}

.hero-proof li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.62em;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

/* --- Cards and grids ---------------------------------------------------- */

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin-top: 0;
}

.card p:last-child,
.card ul:last-child {
  margin-bottom: 0;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 12px;
}

/* --- Tables ------------------------------------------------------------- */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 520px;
  font-size: 0.93rem;
}

caption {
  text-align: left;
  padding: 12px 14px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--line);
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

thead th {
  background: var(--surface-alt);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td code {
  white-space: nowrap;
}

/* --- Example record ----------------------------------------------------- */

.record {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.record dl {
  margin: 0;
  display: grid;
  gap: 4px 18px;
  grid-template-columns: minmax(9rem, auto) 1fr;
}

.record dt {
  color: var(--ink-faint);
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 3px;
}

.record dd {
  margin: 0 0 8px;
}

.unknown {
  color: var(--ink-faint);
  font-style: italic;
}

/* --- Badges ------------------------------------------------------------- */

.badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-alt);
  color: var(--ink-soft);
  white-space: nowrap;
}

.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: transparent;
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

/* --- Pricing ------------------------------------------------------------ */

.plan-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  align-items: start;
}

.plan {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.plan-featured {
  border-color: var(--accent);
  border-width: 2px;
}

.plan-price {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0.2em 0 0;
}

.plan-price .per {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink-faint);
}

.plan-meta {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 0.4em 0 1em;
}

.plan ul {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
}

.plan li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 0.5em;
}

.plan li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 0.55em;
  width: 10px;
  height: 5px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
}

.plan .btn {
  margin-top: auto;
}

/* --- FAQ ---------------------------------------------------------------- */

.faq details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 4px 18px;
  margin-bottom: 12px;
}

.faq summary {
  cursor: pointer;
  font-weight: 600;
  padding: 12px 0;
  list-style-position: outside;
}

.faq summary::marker {
  color: var(--accent);
}

.faq details[open] summary {
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

/* --- Forms -------------------------------------------------------------- */

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 5px;
}

.field .hint {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-faint);
  margin-top: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 0.97rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-height: 44px;
}

select {
  /* Keeps the native control usable in dark mode across browsers. */
  color-scheme: inherit;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--accent);
}

.form-grid {
  display: grid;
  gap: 0 18px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

legend {
  padding: 0;
  font-weight: 700;
}

/* --- Dashboard ---------------------------------------------------------- */

.dash {
  padding: 2rem 0 4rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}

.panel > h2 {
  font-size: 1.25rem;
  margin-top: 0;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.25rem;
}

.dash-columns {
  display: grid;
  gap: 0 22px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  align-items: start;
}

.account-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
  margin-bottom: 22px;
}

.account-bar dl {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  margin: 0;
  align-items: baseline;
}

.account-bar dt {
  color: var(--ink-faint);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.account-bar dd {
  margin: 0 12px 0 0;
  font-weight: 600;
}

/* Usage meter */
.meter {
  display: flex;
  height: 14px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  overflow: hidden;
  margin: 10px 0 8px;
}

.meter-fill {
  display: block;
  flex: 0 0 auto;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.3s ease;
}

.meter-fill.is-warn {
  background: var(--warn);
}

.meter-fill.is-full {
  background: var(--danger);
}

/* Allowance held by jobs that have not finished: spent-in-principle, not yet
   billed. Hatched rather than merely paler, so it is still distinguishable
   from the solid "used" segment without relying on colour. */
.meter-fill-reserved {
  background-color: var(--accent-soft);
  background-image: repeating-linear-gradient(
    135deg,
    var(--accent) 0,
    var(--accent) 3px,
    transparent 3px,
    transparent 7px
  );
  border-left: 1px solid var(--surface);
}

.meter-fill-reserved[hidden] {
  display: none;
}

.meter-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

/* Item lists */
.items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.items > li {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--bg);
}

.item-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: baseline;
  justify-content: space-between;
}

.item-title {
  font-weight: 700;
  word-break: break-word;
}

.item-meta {
  color: var(--ink-soft);
  font-size: 0.88rem;
  margin: 4px 0 0;
}

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

.muted {
  color: var(--ink-faint);
}

.empty {
  color: var(--ink-faint);
  font-style: italic;
  margin: 0;
}

/* Messages */
.msg {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 16px;
  border: 1px solid var(--line-strong);
  background: var(--surface-alt);
  font-size: 0.95rem;
}

.msg-error {
  border-color: transparent;
  background: var(--danger-soft);
  color: var(--danger);
}

.msg-ok {
  border-color: transparent;
  background: var(--ok-soft);
  color: var(--ok);
}

.msg-warn {
  border-color: transparent;
  background: var(--warn-soft);
  color: var(--warn);
}

.msg[hidden] {
  display: none;
}

/* One-time secret box */
.secret {
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--accent-soft);
  margin-bottom: 16px;
}

.secret code {
  display: block;
  word-break: break-all;
  white-space: pre-wrap;
  background: var(--bg);
  padding: 10px;
  margin: 8px 0;
  font-size: 0.9rem;
}

/* Results viewer */
.result-record {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  background: var(--bg);
}

.result-record h4 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.result-json {
  margin-top: 10px;
}

.result-json summary {
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

/* --- Utilities ---------------------------------------------------------- */

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

[hidden] {
  display: none !important;
}

.stack > * + * {
  margin-top: 1rem;
}

.note {
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 14px;
  color: var(--ink-soft);
  margin: 0 0 1em;
}

@media (max-width: 420px) {
  :root {
    --gutter: 16px;
  }

  body {
    font-size: 16px;
  }

  .card,
  .panel {
    padding: 16px;
  }

  .record dl {
    grid-template-columns: 1fr;
  }

  .record dt {
    padding-top: 8px;
  }
}

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

@media print {
  .site-header,
  .site-footer,
  .btn {
    display: none !important;
  }
}

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

.flush {
  margin: 0;
}

.spaced-top-sm {
  margin-top: 14px;
}

.spaced-top-md {
  margin-top: 20px;
}

.spaced-top-lg {
  margin-top: 1.5rem;
}
