/* ==========================================================================
   ads-farming-machine — shared design system (mobile-first)
   Each project's css/app.css is loaded AFTER this file and overrides:
     --brand, --brand-dark, --brand-soft, --accent, --radius
   ========================================================================== */

:root {
  --brand: #2563eb;
  --brand-dark: #1e40af;
  --brand-soft: #dbeafe;
  --accent: #16a34a;
  --radius: 14px;

  --ink: #0f172a;
  --ink-soft: #334155;
  --ink-faint: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --surface: #ffffff;

  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;

  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.08);
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
}

main {
  flex: 1;
}

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

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  line-height: 1.2;
  color: var(--ink);
  margin: 0 0 0.6em;
}

h1 {
  font-size: clamp(1.6rem, 4.5vw, 2.4rem);
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(1.25rem, 3.5vw, 1.6rem);
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0 0 1em;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--brand);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius) 0;
}

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

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1rem;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: block;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: cover;
}

.brand-name {
  white-space: nowrap;
}

.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.nav-toggle-bars {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
}

.nav-toggle-bars span {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.site-nav {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  padding: 0.5rem 1rem 1rem;
}

.site-nav.is-open {
  display: block;
}

.site-nav a {
  display: block;
  padding: 0.65rem 0.5rem;
  font-weight: 600;
  color: var(--ink-soft);
  border-radius: 8px;
}

.site-nav a:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
  text-decoration: none;
}

.site-nav a.is-active {
  color: var(--brand-dark);
  background: var(--brand-soft);
}

@media (min-width: 720px) {
  .nav-toggle {
    display: none;
  }

  .site-nav {
    display: flex;
    position: static;
    gap: 0.25rem;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .site-nav a {
    padding: 0.45rem 0.8rem;
  }
}

/* ---------------- page scaffolding ---------------- */

.page {
  padding: 2rem 0 3rem;
}

.page > .container > h1 {
  margin-top: 0.5rem;
}

.lead {
  font-size: 1.1rem;
  color: var(--ink-soft);
  max-width: 62ch;
}

.section {
  margin-top: 2.5rem;
}

.section h2 {
  margin-bottom: 0.75rem;
}

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

.card h3 {
  margin-bottom: 0.4rem;
}

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

.grid {
  display: grid;
  gap: 1rem;
}

.grid-2 {
  grid-template-columns: 1fr;
}

.grid-3 {
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------------- forms & controls ---------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.field label {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.input,
.select,
.textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  width: 100%;
}

.textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.5;
}

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible,
.btn:focus-visible,
.chip:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent);
  outline-offset: 1px;
  border-color: var(--brand);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--ink-faint);
}

.hint {
  font-size: 0.85rem;
  color: var(--ink-faint);
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font: inherit;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.65rem 1.2rem;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-sm);
  transition: filter 120ms ease, transform 80ms ease;
}

.btn:hover {
  filter: brightness(1.08);
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

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

.btn-danger {
  background: var(--bad);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-faint);
  box-shadow: none;
  padding: 0.3rem 0.5rem;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.check span {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

input[type='range'] {
  width: 100%;
  accent-color: var(--brand);
}

/* ---------------- tool result panels ---------------- */

.result-panel {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.result-panel[hidden] {
  display: none;
}

.status-up {
  border-color: color-mix(in srgb, var(--ok) 40%, var(--line));
  background: var(--ok-soft);
}

.status-down {
  border-color: color-mix(in srgb, var(--bad) 40%, var(--line));
  background: var(--bad-soft);
}

.status-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 800;
  font-size: 1.05rem;
}

.status-up .status-label {
  color: #166534;
}

.status-down .status-label {
  color: #991b1b;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
}

.dot-pulse {
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  word-break: break-all;
}

/* ---------------- stat tiles (counters etc.) ---------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  display: block;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-top: 0.2rem;
}

@media (min-width: 720px) {
  .stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 980px) {
  .stats {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* ---------------- chips / quick actions ---------------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.chip {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
  text-decoration: none;
}

/* ---------------- article pages (about/terms/...) ---------------- */

.article {
  max-width: 75ch;
}

.article h2 {
  margin-top: 2rem;
}

.article ul,
.article ol {
  padding-left: 1.3rem;
  margin: 0 0 1em;
}

.article li {
  margin-bottom: 0.35rem;
}

.article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 0 0 1em;
}

.article th,
.article td {
  border: 1px solid var(--line);
  padding: 0.5rem 0.7rem;
  text-align: left;
  vertical-align: top;
}

.article th {
  background: var(--bg);
}

.updated {
  font-size: 0.85rem;
  color: var(--ink-faint);
}

/* ---------------- ad slots ---------------- */

.ad-wrap {
  margin: 1.75rem auto;
  text-align: center;
}

.ad-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.35rem;
}

.ad-wrap:empty,
.ad-wrap:has(> .ad-label:only-child) {
  display: none;
}

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

.site-footer {
  background: #0f172a;
  color: #cbd5e1;
  margin-top: 3rem;
  padding: 2.25rem 0 1.5rem;
  font-size: 0.92rem;
}

.site-footer a {
  color: #e2e8f0;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.footer-brand {
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  margin-bottom: 0.35rem;
}

.footer-blurb {
  color: #94a3b8;
  max-width: 46ch;
  margin-bottom: 0;
}

.footer-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
  margin-bottom: 0.6rem;
}

.footer-col nav,
nav.footer-col {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.footer-col a {
  width: fit-content;
}

@media (min-width: 720px) {
  .footer-grid {
    grid-template-columns: 2fr 1fr 1fr;
  }
}

.footer-bottom {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-top: 1.25rem;
  font-size: 0.82rem;
  color: #94a3b8;
}

.footer-bottom p {
  margin: 0;
}

@media (min-width: 720px) {
  .footer-bottom {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
  }
}

/* ---------------- 404 ---------------- */

.notfound {
  text-align: center;
  padding: 4rem 0;
}

.notfound .big {
  font-size: 4rem;
  font-weight: 800;
  color: var(--brand);
  line-height: 1;
}
