/* ==========================================================================
   JS Craft — design system
   ========================================================================== */
:root {
  --ink: #111112;
  --ink-2: #57564f;
  --ink-3: #8b897e;
  --paper: #ffffff;
  --paper-2: #fbfbf9;
  --panel: #f2f2ef;
  --panel-2: #ebebe6;
  --lime: #e7fd5c;
  --lime-deep: #d3ee36;
  --purple: #503bff;
  --purple-deep: #3f2be6;
  --line: #111112;
  --line-soft: #e6e5df;
  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --maxw: 1200px;
  --gutter: clamp(1.1rem, 4vw, 2.75rem);
  --display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--display); font-weight: 700; line-height: 1.04; letter-spacing: -0.02em; margin: 0; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img, svg, canvas { display: block; max-width: 100%; }
::selection { background: var(--lime); color: var(--ink); }

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.stack > * + * { margin-top: 1rem; }

.skip { position: absolute; left: -999px; top: .5rem; z-index: 100; background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 8px; font-family: var(--display); }
.skip:focus { left: .75rem; }

/* highlighter + accents */
.hl { background: var(--lime); box-decoration-break: clone; -webkit-box-decoration-break: clone; padding: .04em .28em; border-radius: 4px; }
.pp { color: var(--purple); }
.eyebrow {
  font-family: var(--display); font-weight: 500; font-size: .8rem; letter-spacing: .02em;
  text-transform: uppercase; color: var(--ink); display: inline-flex; align-items: center; gap: .55rem;
  padding: .35rem .7rem .35rem .55rem; background: var(--panel); border-radius: 8px;
}
.eyebrow::before { content: ""; width: 9px; height: 9px; background: var(--purple); border-radius: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  font-family: var(--display); font-weight: 500; font-size: .95rem; line-height: 1;
  padding: .85rem 1.35rem; border-radius: 999px; border: 1.5px solid var(--ink);
  background: var(--paper); color: var(--ink); cursor: pointer; min-height: 46px;
  transition: transform .14s ease, background-color .14s ease, color .14s ease, box-shadow .14s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn--dark { background: var(--ink); color: #fff; }
.btn--dark:hover { background: #000; }
.btn--lime { background: var(--lime); border-color: var(--ink); color: var(--ink); }
.btn--lime:hover { background: var(--lime-deep); }
.btn--purple { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn--purple:hover { background: var(--purple-deep); border-color: var(--purple-deep); }
.btn--sm { padding: .55rem .9rem; min-height: 38px; font-size: .85rem; }
.btn .arrow { transition: transform .14s ease; }
.btn:hover .arrow { transform: translateX(3px); }

/* ---------- header ---------- */
.site-header { position: sticky; top: 0; z-index: 60; background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: saturate(1.3) blur(9px); border-bottom: 1px solid var(--line-soft); }
.nav { display: flex; align-items: center; gap: 1rem; height: 70px; }
.brand { display: inline-flex; align-items: center; gap: .55rem; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand-word { font-family: var(--display); font-size: 1.2rem; font-weight: 700; letter-spacing: -.03em; }
.brand-word .c { font-weight: 500; }
.nav-links { display: flex; align-items: center; gap: .35rem; list-style: none; margin: 0 0 0 1.5rem; padding: 0; }
.nav-links a { font-family: var(--display); font-weight: 500; font-size: .93rem; padding: .5rem .8rem; border-radius: 8px; color: var(--ink); }
.nav-links a:hover { background: var(--panel); }
.nav-links a[aria-current="page"], .nav-links a.is-active { background: var(--panel); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: .7rem; }
.nav-toggle { display: none; width: 46px; height: 46px; border: 1.5px solid var(--ink); border-radius: 10px; background: var(--paper); cursor: pointer; align-items: center; justify-content: center; }
.nav-toggle svg { width: 22px; height: 22px; }

/* ---------- hero ---------- */
.hero { padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(2rem, 4vw, 3.5rem); }
.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: clamp(1.5rem, 4vw, 3rem); align-items: center; }
.hero h1 { font-size: clamp(2.6rem, 7vw, 5rem); letter-spacing: -0.035em; }
.hero-sub { margin-top: 1.4rem; font-size: 1.15rem; color: var(--ink-2); max-width: 42ch; }
.hero-stat { margin-top: 1.5rem; font-family: var(--display); font-weight: 500; font-size: 1rem; }
.searchbar { margin-top: 1.9rem; display: flex; align-items: center; gap: .5rem; background: var(--ink); border-radius: 999px; padding: .5rem .5rem .5rem 1.4rem; max-width: 560px; }
.searchbar input { flex: 1; border: 0; background: transparent; color: #fff; font-family: var(--body); font-size: 1rem; padding: .7rem 0; outline: none; }
.searchbar input::placeholder { color: #9b9aa6; }
.searchbar button { flex: none; width: 48px; height: 48px; border-radius: 999px; border: 0; background: var(--lime); color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.searchbar button:hover { background: var(--lime-deep); }

/* decorative tile cluster */
.hero-art { position: relative; min-height: 300px; }
.tilewrap { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.tile { aspect-ratio: 1; border: 1.5px solid var(--ink); border-radius: 16px; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 1.1rem; background: var(--paper); box-shadow: var(--shadow-sm); }
.tile--lime { background: var(--lime); }
.tile--dark { background: var(--ink); color: #fff; }
.tile--purple { background: var(--purple); color: #fff; }
.tile--ghost { border-style: dashed; box-shadow: none; color: var(--ink-3); }

/* ---------- generic section ---------- */
.section { padding: clamp(2.6rem, 6vw, 4.5rem) 0; }
.section + .section { border-top: 1px solid var(--line-soft); }
.section-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.8rem; }
.section-head h2 { font-size: clamp(1.7rem, 4vw, 2.6rem); }
.section-head p { margin-top: .6rem; color: var(--ink-2); max-width: 60ch; }
.section-note { color: var(--ink-2); font-size: .95rem; }

/* ---------- cards / grids ---------- */
.grid { display: grid; gap: 1rem; }
.grid--hubs { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid--tools { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.card {
  display: flex; flex-direction: column; gap: .5rem;
  background: var(--paper); border: 1.5px solid var(--ink); border-radius: var(--radius);
  padding: 1.15rem 1.2rem; transition: transform .14s ease, box-shadow .14s ease, background-color .14s ease;
}
.card:hover { transform: translate(-3px, -3px); box-shadow: var(--shadow); }
.card--lime { background: var(--lime); }
.card--lime:hover { background: var(--lime); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.card-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--ink); color: var(--lime); display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: .95rem; flex: none; }
.card--lime .card-mark { background: var(--ink); color: var(--lime); }
.card-count { font-family: var(--display); font-weight: 500; font-size: .78rem; color: var(--ink-2); white-space: nowrap; }
.card h3 { font-family: var(--display); font-size: 1.15rem; letter-spacing: -.01em; }
.card .card-desc { font-size: .9rem; color: var(--ink-2); }
.card .tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .2rem; }
.tag { font-family: var(--display); font-weight: 500; font-size: .7rem; padding: .2rem .5rem; border-radius: 6px; background: var(--panel); color: var(--ink-2); }
.card--lime .tag { background: rgba(17,17,18,.09); }

.toolcard { display: block; border: 1.5px solid var(--ink); border-radius: var(--radius-sm); padding: .85rem 1rem; background: var(--paper); transition: transform .12s ease, box-shadow .12s ease; }
.toolcard:hover { transform: translate(-2px,-2px); box-shadow: var(--shadow-sm); }
.toolcard .t-name { font-family: var(--display); font-weight: 500; font-size: .98rem; }
.toolcard .t-type { font-size: .74rem; color: var(--ink-3); font-family: var(--display); }

/* ---------- breadcrumb ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; font-family: var(--display); font-weight: 500; font-size: .82rem; color: var(--ink-2); padding: 1.4rem 0 0; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.crumbs .sep { color: var(--ink-3); }
.crumbs [aria-current="page"] { color: var(--ink); }

/* ---------- tool page ---------- */
.page-head { padding: .4rem 0 1.6rem; }
.page-head h1 { font-size: clamp(2rem, 5vw, 3.1rem); margin-top: 1rem; }
.page-head h1::first-letter { text-transform: uppercase; }
.page-head .lead { margin-top: 1rem; font-size: 1.1rem; color: var(--ink-2); max-width: 66ch; }
.page-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; }

.tool-shell { border: 1.5px solid var(--ink); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); background: var(--paper); }
.tool-bar { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; background: var(--ink); color: #fff; }
.tool-bar .dot { width: 11px; height: 11px; border-radius: 50%; background: #3b3b45; }
.tool-bar .dot.lime { background: var(--lime); }
.tool-bar .file { font-family: var(--display); font-weight: 500; font-size: .85rem; margin-left: .3rem; }
.tool-bar .mode { margin-left: auto; font-family: var(--display); font-size: .74rem; color: var(--lime); text-transform: uppercase; letter-spacing: .04em; }
.tool-body { padding: 1.1rem; display: grid; gap: .9rem; }
.tool-controls { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.tool-io { display: grid; gap: .9rem; }
@media (min-width: 780px) { .tool-io.split { grid-template-columns: 1fr 1fr; } }
.field label { display: block; font-family: var(--display); font-weight: 500; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); margin-bottom: .35rem; }
textarea.io, input.io, select.io {
  width: 100%; font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: .9rem; line-height: 1.55; color: var(--ink); background: var(--paper-2);
  border: 1.5px solid var(--line-soft); border-radius: var(--radius-sm); padding: .8rem .9rem; outline: none; resize: vertical;
}
textarea.io { min-height: 190px; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
textarea.io:focus, input.io:focus, select.io:focus { border-color: var(--ink); }
input.io, select.io { font-family: var(--body); }
.io-out { min-height: 190px; }
.result-note { font-family: var(--display); font-weight: 500; font-size: .9rem; padding: .6rem .85rem; border-radius: 10px; }
.result-note.ok { background: var(--lime); color: var(--ink); }
.result-note.err { background: #ffe0e0; color: #8a1f1f; }
.result-note.info { background: var(--panel); color: var(--ink); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; }
.stat { border: 1.5px solid var(--line-soft); border-radius: 12px; padding: .7rem .8rem; }
.stat .n { font-family: var(--display); font-weight: 700; font-size: 1.4rem; }
.stat .k { font-size: .75rem; color: var(--ink-2); }
.dropzone { border: 1.5px dashed var(--ink); border-radius: var(--radius-sm); padding: 1.4rem; text-align: center; background: var(--paper-2); cursor: pointer; }
.dropzone.drag { background: var(--lime); }
.preview-img { max-height: 240px; margin: .6rem auto 0; border-radius: 10px; border: 1px solid var(--line-soft); }
.noscript-note { border: 1.5px solid var(--ink); border-radius: 12px; padding: .8rem 1rem; background: var(--lime); font-size: .9rem; }

/* prose */
.prose { max-width: 72ch; }
.prose h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin: 2.2rem 0 .7rem; }
.prose h3 { font-size: 1.15rem; margin: 1.4rem 0 .5rem; }
.prose p { color: var(--ink-2); margin-top: .7rem; }
.prose ul, .prose ol { color: var(--ink-2); margin: .6rem 0 0; padding-left: 1.2rem; }
.prose li { margin-top: .35rem; }

.related-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: .7rem; }
.uphub { display: inline-flex; align-items: center; gap: .5rem; border: 1.5px solid var(--ink); border-radius: 999px; padding: .6rem 1.1rem; font-family: var(--display); font-weight: 500; background: var(--lime); }
.uphub:hover { transform: translateY(-2px); }

/* subcluster anchor sections on hubs */
.subhead { display: flex; align-items: center; gap: .7rem; margin: 2.2rem 0 1rem; }
.subhead h2 { font-size: 1.4rem; }
.subhead .count { font-family: var(--display); font-weight: 500; font-size: .8rem; color: var(--ink-2); }

/* ---------- footer ---------- */
.site-footer { background: var(--ink); color: #e9e9ea; padding: clamp(2.6rem,6vw,4rem) 0 2.5rem; margin-top: 3rem; }
.site-footer a { color: #c9c9cc; }
.site-footer a:hover { color: #fff; }
.footer-grid { display: grid; grid-template-columns: 1.5fr repeat(4, minmax(120px, 1fr)); gap: 2rem; }
.footer-brand .brand-word { color: #fff; }
.footer-brand p { color: #9b9aa2; font-size: .92rem; margin-top: .9rem; max-width: 40ch; }
.footer-col h4 { font-family: var(--display); font-weight: 500; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: #7d7c85; margin: 0 0 .9rem; }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.footer-col a { font-size: .92rem; }
.footer-seo { color: #86858d; font-size: .85rem; line-height: 1.7; margin-top: 2.2rem; max-width: 90ch; }
.footer-bottom { margin-top: 2rem; padding-top: 1.4rem; border-top: 1px solid #2a2a30; display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; justify-content: space-between; font-family: var(--display); font-weight: 500; font-size: .8rem; color: #7d7c85; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .nav-links { position: absolute; top: 70px; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0; margin: 0; background: var(--paper); border-bottom: 1px solid var(--line-soft); padding: .4rem var(--gutter) 1rem; display: none; }
  .nav-links.open { display: flex; }
  .nav-links a { padding: .85rem .2rem; border-bottom: 1px solid var(--line-soft); border-radius: 0; }
  .nav-right .btn--outline-hide { display: none; }
  .nav-toggle { display: inline-flex; }
}
@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: start; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; border-radius: 6px; }
