/* ============================================================
   Free Data Tools — design system
   Editorial-technical: warm paper canvas + dark terminal widgets
   ============================================================ */

:root {
  /* paper / ink */
  --paper:      #F7F4EC;
  --paper-2:    #EFEADC;
  --paper-3:    #E7E1D0;
  --ink:        #16150F;
  --ink-2:      #38362B;
  --muted:      #6C6856;
  --line:       #DBD4C2;
  --line-soft:  #E6E0D1;

  /* accent */
  --accent:     #FF5A1F;
  --accent-ink: #C23B0C;
  --accent-wash:#FFE7DC;

  /* trust / secondary */
  --teal:       #0E3A43;

  /* terminal */
  --term-bg:    #0E1411;
  --term-bg-2:  #131B17;
  --term-line:  #243029;
  --term-text:  #CDD8D1;
  --term-dim:   #7E8C84;
  --term-green: #5BE08A;
  --term-amber: #FFC56B;
  --term-blue:  #6FB7FF;

  /* type — editorial serif display + warm grotesque body + tool mono */
  --f-display: "Fraunces", Georgia, "Times New Roman", serif;
  --f-body:    "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* space scale (4px base) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px; --s10: 128px;

  --maxw: 1120px;
  --radius: 4px;
  --radius-lg: 8px;

  --shadow-sm: 0 1px 2px rgba(22,21,15,.06), 0 1px 1px rgba(22,21,15,.04);
  --shadow-md: 0 8px 24px -10px rgba(22,21,15,.18), 0 2px 6px rgba(22,21,15,.06);
  --shadow-term: 0 24px 60px -24px rgba(8,18,13,.55), 0 4px 12px rgba(8,18,13,.25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-2);
  background-color: var(--paper);
  /* faint engineering-grid texture */
  background-image:
    linear-gradient(rgba(22,21,15,.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22,21,15,.022) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: -1px -1px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent); color: #fff; }

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

img { max-width: 100%; display: block; }
h1, h2, h3, h4 { color: var(--ink); font-family: var(--f-display); font-optical-sizing: auto; font-weight: 600; line-height: 1.1; letter-spacing: -.015em; margin: 0 0 var(--s4); }
.hero h1 { font-weight: 600; }
p { margin: 0 0 var(--s4); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--s5); }
.wrap-narrow { max-width: 760px; margin: 0 auto; padding: 0 var(--s5); }

/* mono eyebrow label */
.eyebrow {
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  margin: 0 0 var(--s4);
}
.eyebrow::before { content: "//"; color: var(--accent); }

/* ---------- masthead ---------- */
.masthead {
  position: sticky; top: 0; z-index: 50;
  background: rgba(247,244,236,.82);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
.masthead .bar { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: var(--s3); font-family: var(--f-display); font-weight: 700; color: var(--ink); font-size: 18px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--ink); color: var(--term-green);
  display: grid; place-items: center;
  font-family: var(--f-mono); font-size: 15px; font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.nav-links { display: flex; gap: var(--s5); align-items: center; }
.nav-links a { color: var(--ink-2); font-size: 15px; font-weight: 500; }
.nav-links a:hover { color: var(--ink); text-decoration: none; }
.nav-links .ghost { font-family: var(--f-mono); font-size: 13px; color: var(--muted); }
@media (max-width: 640px){ .nav-links .hide-sm { display:none; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-family: var(--f-body); font-weight: 600; font-size: 15px;
  padding: 12px 20px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  min-height: 44px; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-ink); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); background: var(--paper-2); }
/* ghost button on a dark section (e.g. the CTA block) — light text + visible border */
.cta .btn-ghost { color: var(--paper); border-color: rgba(247,244,236,.35); }
.cta .btn-ghost:hover { color: #fff; border-color: var(--paper); background: rgba(247,244,236,.10); }

/* kind badges (light context: cards) */
.badge { display:inline-block; font-family: var(--f-mono); font-size:10px; letter-spacing:.06em; text-transform:uppercase; padding:2px 7px; border-radius:3px; font-weight:600; vertical-align:middle; }
.badge-live { background: var(--accent-wash); color: var(--accent-ink); }
.badge-live::before { content:""; display:inline-block; width:6px; height:6px; border-radius:50%; background: var(--term-green); margin-right:5px; vertical-align:middle; }
.badge-builder { background: var(--paper-3); color: var(--ink-2); }

/* "Example output" callout in the terminal widget (dark context) — makes clear the sample is fixed, not live */
.example-head { font-size: 13px; color: var(--term-amber); background: rgba(255,197,107,.08); border:1px solid rgba(255,197,107,.28); border-radius: var(--radius); padding: 10px 14px; margin-bottom: var(--s3); line-height: 1.5; }
.example-head b { color: var(--term-text); }
.example-badge { display:inline-block; font-family: var(--f-mono); font-size:10px; letter-spacing:.08em; text-transform:uppercase; background: var(--term-amber); color:#1a1206; padding:2px 7px; border-radius:3px; margin-right:6px; font-weight:700; }
.btn[disabled]{ opacity:.5; cursor: not-allowed; transform:none; }
.btn .arr { transition: transform .15s ease; }
.btn:hover .arr { transform: translateX(3px); }

/* ---------- hero ---------- */
.hero { padding: var(--s9) 0 var(--s7); border-bottom: 1px solid var(--line); position: relative; }
.hero h1 { font-size: clamp(2.4rem, 6vw, 4.2rem); max-width: 16ch; }
.hero .lede { font-size: clamp(1.05rem, 2.2vw, 1.32rem); color: var(--ink-2); max-width: 56ch; }
.hero .lede strong { color: var(--ink); }
.hero-cta { display: flex; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s6); align-items: center; }
.hero-stats { display:flex; gap: var(--s6); flex-wrap: wrap; margin-top: var(--s7); padding-top: var(--s5); border-top: 1px dashed var(--line); }
.stat .n { font-family: var(--f-display); font-weight: 700; font-size: 1.9rem; color: var(--ink); line-height: 1; }
.stat .l { font-family: var(--f-mono); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 6px; }

/* ---------- tool grid (hub) ---------- */
.section { padding: var(--s9) 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s5); margin-bottom: var(--s7); flex-wrap: wrap; }
.section-head h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0; }
.section-head p { color: var(--muted); margin: 0; max-width: 46ch; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: var(--s4); }
.tool-card {
  position: relative; display: flex; flex-direction: column;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: var(--s5);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  overflow: hidden;
}
.tool-card::after { content:""; position:absolute; left:0; right:0; top:0; height:3px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .2s ease; }
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--paper-3); text-decoration: none; }
.tool-card:hover::after { transform: scaleX(1); }
.tool-card .tag { font-family: var(--f-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: var(--s4); display:flex; gap: var(--s2); align-items:center; }
.tool-card .live { color: var(--accent-ink); }
.tool-card .live::before { content:""; width:7px; height:7px; border-radius:50%; background: var(--term-green); box-shadow: 0 0 0 3px rgba(91,224,138,.18); display:inline-block; }
.tool-card h3 { font-size: 1.28rem; margin: 0 0 var(--s3); color: var(--ink); }
.tool-card p { font-size: 15px; color: var(--ink-2); margin: 0 0 var(--s5); flex: 1; }
.tool-card .go { font-family: var(--f-mono); font-size: 13px; font-weight: 500; color: var(--ink); display:inline-flex; gap: var(--s2); align-items:center; }
.tool-card .go .arr { color: var(--accent); transition: transform .15s ease; }
.tool-card:hover .go .arr { transform: translateX(4px); }

/* ---------- terminal widget ---------- */
.terminal {
  background: var(--term-bg);
  border: 1px solid var(--term-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-term);
  color: var(--term-text);
  font-family: var(--f-mono);
  overflow: hidden;
}
.term-bar { display:flex; align-items:center; gap: var(--s3); padding: 10px var(--s4); border-bottom: 1px solid var(--term-line); background: var(--term-bg-2); }
.term-dots { display:flex; gap: 7px; }
.term-dots i { width:11px; height:11px; border-radius:50%; display:block; }
.term-dots i:nth-child(1){ background:#FF5F56; } .term-dots i:nth-child(2){ background:#FFBD2E; } .term-dots i:nth-child(3){ background:#27C93F; }
.term-title { font-size: 12px; color: var(--term-dim); letter-spacing:.04em; }
.term-body { padding: var(--s5); }

.term-body label { display:block; font-size: 12px; color: var(--term-dim); text-transform: uppercase; letter-spacing:.06em; margin: 0 0 var(--s2); }
.term-row { display:flex; gap: var(--s3); flex-wrap: wrap; align-items: flex-end; }
.term-field { flex: 1; min-width: 180px; }
.term-input, .term-select {
  width:100%; background: #0A0F0C; color: var(--term-text);
  border: 1px solid var(--term-line); border-radius: var(--radius);
  font-family: var(--f-mono); font-size: 14px; padding: 11px var(--s3); min-height: 44px;
}
.term-input:focus, .term-select:focus { outline: none; border-color: var(--term-green); box-shadow: 0 0 0 3px rgba(91,224,138,.15); }
.term-input::placeholder { color: #4f5c54; }
.term-hint { font-size: 12px; color: var(--term-dim); margin-top: var(--s2); }
.term-hint code { color: var(--term-amber); background: rgba(255,197,107,.08); padding: 1px 5px; border-radius: 3px; }

.btn-term { background: var(--term-green); color: #06150C; border:none; font-family: var(--f-mono); font-weight: 700; }
.btn-term:hover { background: #74ef9f; transform: translateY(-1px); }

/* output area */
.term-out { margin-top: var(--s5); border-top: 1px dashed var(--term-line); padding-top: var(--s4); }
.term-status { font-size: 12px; color: var(--term-dim); margin-bottom: var(--s3); min-height: 1.2em; }
.term-status .ok { color: var(--term-green); } .term-status .err { color: #FF8367; } .term-status .run { color: var(--term-amber); }
.result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.result-item { background: var(--term-bg-2); border: 1px solid var(--term-line); border-radius: var(--radius); padding: var(--s3) var(--s4); font-size: 13.5px; }
.result-item .rt { color: var(--term-text); font-weight: 500; }
.result-item .rm { color: var(--term-dim); font-size: 12px; margin-top: 4px; display:flex; gap: var(--s4); flex-wrap: wrap; }
.result-item .rm b { color: var(--term-blue); font-weight: 500; }
.signal-pill { display:inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(91,224,138,.12); color: var(--term-green); border:1px solid rgba(91,224,138,.25); }

/* JSON input panel + copy */
.json-panel { position: relative; background: #0A0F0C; border: 1px solid var(--term-line); border-radius: var(--radius); margin-top: var(--s3); }
.json-panel pre { margin:0; padding: var(--s4); overflow-x:auto; font-family: var(--f-mono); font-size: 12.5px; line-height: 1.55; color: var(--term-text); }
.json-panel .k { color: var(--term-blue); } .json-panel .s { color: var(--term-green); } .json-panel .n { color: var(--term-amber); }
.copy-btn {
  position: absolute; top: 8px; right: 8px; z-index:2;
  background: var(--term-line); color: var(--term-text); border:none; border-radius: 4px;
  font-family: var(--f-mono); font-size: 11px; padding: 6px 10px; cursor:pointer;
}
.copy-btn:hover { background: #2f3d35; }
.copy-btn.copied { background: var(--term-green); color:#06150C; }

/* ---------- content prose ---------- */
.prose { font-size: 17px; }
.prose h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin: var(--s8) 0 var(--s4); }
.prose h3 { font-size: 1.25rem; margin: var(--s6) 0 var(--s3); }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 var(--s4); }
.prose li { margin-bottom: var(--s2); }
.prose code { font-family: var(--f-mono); font-size: .9em; background: var(--paper-2); border:1px solid var(--line-soft); padding: 1px 6px; border-radius: 4px; color: var(--accent-ink); }

/* CTA conversion block */
.cta {
  margin: var(--s8) 0; padding: var(--s7);
  background: var(--ink); color: var(--paper);
  border-radius: var(--radius-lg); position: relative; overflow: hidden;
}
.cta::before { content:""; position:absolute; inset:0; background:
  radial-gradient(600px 200px at 100% 0%, rgba(255,90,31,.16), transparent 60%); pointer-events:none; }
.cta .eyebrow { color: #b9b3a0; }
.cta .eyebrow::before { color: var(--accent); }
.cta h2 { color: var(--paper); font-size: clamp(1.5rem, 3vw, 2.1rem); }
.cta p { color: #cfc9b8; max-width: 54ch; }
.cta-actions { display:flex; gap: var(--s3); flex-wrap: wrap; align-items:center; margin-top: var(--s5); }
.cta-note { font-family: var(--f-mono); font-size: 12px; color: #9a9482; margin-top: var(--s4); }

/* FAQ */
.faq details { border-bottom: 1px solid var(--line); padding: var(--s4) 0; }
.faq summary { cursor: pointer; font-family: var(--f-display); font-weight: 600; color: var(--ink); font-size: 1.08rem; list-style: none; display:flex; justify-content: space-between; gap: var(--s4); }
.faq summary::-webkit-details-marker { display:none; }
.faq summary::after { content: "+"; color: var(--accent); font-family: var(--f-mono); font-size: 1.3rem; line-height:1; }
.faq details[open] summary::after { content: "–"; }
.faq details[open] summary { margin-bottom: var(--s3); }
.faq p { margin: 0; color: var(--ink-2); }

/* breadcrumb */
.crumb { font-family: var(--f-mono); font-size: 12px; color: var(--muted); padding: var(--s5) 0 0; }
.crumb a { color: var(--muted); } .crumb a:hover { color: var(--ink); }

/* footer */
.foot { border-top: 1px solid var(--line); margin-top: var(--s9); padding: var(--s8) 0 var(--s7); background: var(--paper-2); }
.foot .cols { display:grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--s6); }
.foot h4 { font-family: var(--f-mono); font-size: 12px; text-transform: uppercase; letter-spacing:.08em; color: var(--muted); font-weight: 500; margin-bottom: var(--s4); }
.foot a { color: var(--ink-2); display:block; font-size: 14px; margin-bottom: var(--s2); }
.foot a:hover { color: var(--ink); text-decoration:none; }
.foot .fine { margin-top: var(--s7); padding-top: var(--s5); border-top:1px solid var(--line); font-size: 13px; color: var(--muted); display:flex; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
@media (max-width: 760px){ .foot .cols { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px){ .foot .cols { grid-template-columns: 1fr; } }

/* utilities */
.disclaimer { font-size: 13px; color: var(--muted); font-style: italic; }
.mono { font-family: var(--f-mono); }
.center { text-align:center; }
.mt-0{margin-top:0}.mb-0{margin-bottom:0}

/* ---------- SEO/AEO content components ---------- */
/* answer-first callout — the featured-snippet / LLM-citation block */
.answer-first { position: relative; background: var(--paper-2); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius-lg); padding: var(--s5) var(--s6); }
.answer-first .af-label { font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); display: block; margin-bottom: var(--s2); }
.answer-first p { font-size: 1.18rem; line-height: 1.55; color: var(--ink); margin: 0; font-family: var(--f-display); font-weight: 400; }

/* key takeaways — scannable check list */
.takeaways { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.takeaways li { position: relative; padding-left: 30px; font-size: 16px; color: var(--ink-2); }
.takeaways li::before { content: "✓"; position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 5px; background: var(--accent-wash); color: var(--accent-ink); font-size: 12px; font-weight: 700; display: grid; place-items: center; }

/* key facts — citable statements + source */
.facts { margin: 0; padding: 0; display: grid; gap: var(--s4); }
.facts .fact { border-left: 2px solid var(--line); padding-left: var(--s4); }
.facts dt { font-size: 16px; color: var(--ink); margin: 0 0 4px; font-weight: 500; }
.facts dd { margin: 0; font-family: var(--f-mono); font-size: 12px; color: var(--muted); }

/* how-to steps */
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: var(--s4); }
.steps li { counter-increment: step; position: relative; padding-left: 44px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--paper); font-family: var(--f-mono); font-size: 14px; font-weight: 700; display: grid; place-items: center; }
.steps li b { display: block; color: var(--ink); font-family: var(--f-display); font-size: 1.05rem; margin-bottom: 2px; }
.steps li span { color: var(--ink-2); font-size: 15px; }

/* related links */
.related { display: grid; gap: var(--s2); }
.related a { font-family: var(--f-mono); font-size: 14px; color: var(--ink-2); padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .12s ease, background .12s ease; }
.related a:hover { border-color: var(--ink); background: var(--paper-2); text-decoration: none; color: var(--ink); }
