/* crofty theme — static, no-JS, no trackers. Terminal-utility, restrained by design.
   Design system: doc/wip/website-design/03_design_system.md (mock B2). */

:root {
  --bg: #fbfaf8;        /* warm near-white */
  --ink: #15181b;
  --muted: #5b6168;
  --line: #e6e3dd;
  --panel: #f4f2ec;
  --term: #0f1417;      /* dark terminal block */
  --term-ink: #e9efe9;
  --accent: #157a5b;    /* functional green */
  --mint: #4fd0a0;
  --measure: 46rem;     /* the one site-wide content width (all pages) */
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16.5px/1.65 var(--sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* One layout for the whole product site: header, content, and footer share a
   single measure on every page — the frame never changes between pages. Content
   arranges itself within that frame as each page needs (the home lays things out
   in columns/cards; long-form pages just flow prose) — but the layout itself is
   the top-level constant, not something a page bends to fit. */
.site-header,
.content,
.site-footer {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: 1.4rem;
}

a { color: var(--ink); text-underline-offset: 2px; }
a:focus-visible,
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

/* ---- header ---- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.4rem 1.3rem;
  border-bottom: 1px solid var(--line);
}
.site-title {
  font-family: var(--mono);
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--ink);
}
.site-title::before { content: "$ "; color: var(--accent); }
.site-header-end { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.site-header nav a {
  margin-left: 1.1rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-family: var(--mono);
  text-decoration: none;
}
.site-header nav a:first-child { margin-left: 0; }
.site-header nav a:hover { color: var(--accent); }

/* external-link affordance (demo / github) */
.ext-icon {
  width: 0.72em;
  height: 0.72em;
  margin-left: 0.28em;
  vertical-align: -0.05em;
  opacity: 0.6;
}
.site-header nav a:hover .ext-icon,
.footer-nav a:hover .ext-icon { opacity: 1; }
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.lang-switch { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); gap: 0.5rem; }
.lang-switch a { color: var(--muted); text-decoration: none; }
.lang-switch a:hover { color: var(--accent); }
.lang-switch .lang-current { color: var(--ink); font-weight: 600; }

/* ---- shared content ---- */
.content { padding-top: 0; padding-bottom: 2rem; }

h1 {
  font-size: clamp(2rem, 7vw, 2.5rem);
  line-height: 1.13;
  letter-spacing: -0.025em;
  font-weight: 680;
  margin: 0 0 1.15rem;
}
h2 { font-size: 1.4rem; line-height: 1.28; letter-spacing: -0.015em; font-weight: 660; margin: 2rem 0 1rem; }
h3 { font-size: 1.1rem; line-height: 1.3; font-weight: 640; margin: 1.8rem 0 0.5rem; }
p, ul, ol, blockquote { margin: 0 0 1rem; }

blockquote {
  margin-inline: 0;
  padding-left: 1rem;
  border-left: 2px solid var(--line);
  color: var(--muted);
}

code, pre { font-family: var(--mono); font-size: 0.9em; }
:not(pre) > code { background: var(--panel); padding: 0.12em 0.38em; border-radius: 4px; font-size: 0.85em; }
pre {
  padding: 1rem;
  overflow-x: auto;
  background: var(--term);
  color: var(--term-ink);
  border-radius: 8px;
}
pre code { background: none; padding: 0; color: inherit; }

/* ---- copy-to-clipboard button (progressive enhancement, JS-injected) ---- */
.highlight, .install .cta { position: relative; }
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.35rem 0.55rem;
  color: var(--term-ink);
  background: rgba(233, 239, 233, 0.07);
  border: 1px solid rgba(233, 239, 233, 0.2);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.highlight:hover .copy-btn,
.install .cta:hover .copy-btn,
.copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { background: rgba(233, 239, 233, 0.16); }
.copy-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.copy-btn.copied { color: var(--mint); border-color: var(--mint); opacity: 1; }
/* Touch devices have no hover — keep the button visible. */
@media (hover: none) {
  .copy-btn { opacity: 0.75; }
}

time { color: var(--muted); font-size: 0.85rem; font-family: var(--mono); }

/* ---- home: hero ---- */
.hero { padding-top: 3.4rem; }
.lede { font-size: 1.06rem; color: #393f45; margin: 0 0 0.7rem; }
.hero-breadth { font-size: 0.98rem; color: #393f45; margin: 0 0 1.5rem; }
.hero-breadth b { color: var(--accent); font-weight: 600; }
.hero-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem; margin: 0 0 1.1rem; }
.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  padding: 0.72rem 1.2rem;
  border-radius: 8px;
  font-size: 0.98rem;
  white-space: nowrap;
}
.btn:hover { background: #11664c; }

.cta {
  background: var(--term);
  color: var(--term-ink);
  border-radius: 9px;
  padding: 1rem 1.15rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: 0 1px 2px rgba(15, 20, 23, 0.06);
}
/* flex-start (not center/baseline): on Windows the command's overflow-x scroll
   container reserves classic-scrollbar height; centering would float that
   scrollbar mid-line, and baseline is synthesized from a scroll container's
   bottom edge — both misalign the "$" prompt. Top-align keeps them aligned. */
.cta-line { display: flex; align-items: flex-start; gap: 0.6rem; }
.cta .pr { color: var(--mint); }
/* Each command line scrolls independently when long (e.g. the Windows scoop
   line). Hide the scrollbar: on Windows its classic (space-reserving) bar would
   otherwise sit between lines, looking like a stray bar in the middle of the
   block. The line stays scrollable, and the copy button yields the full text. */
.cta .cm {
  color: #cfe9df; flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap;
  scrollbar-width: none;      /* Firefox / modern Edge */
  -ms-overflow-style: none;   /* legacy Edge */
}
.cta .cm::-webkit-scrollbar { display: none; }  /* Chromium / WebKit (incl. Windows) */

/* CSS-only OS toggle for the hero install commands (no JS). */
.install { flex: 1; min-width: 17rem; display: flex; flex-direction: column; gap: 0.5rem; }
.os-radio { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.os-tabs { display: flex; gap: 0.4rem; }
.os-tabs label {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
}
.os-tabs label:hover { color: var(--ink); }
#os-mac:checked ~ .os-tabs label[for="os-mac"],
#os-win:checked ~ .os-tabs label[for="os-win"] {
  color: var(--term-ink);
  background: var(--term);
  border-color: var(--term);
}
#os-mac:focus-visible ~ .os-tabs label[for="os-mac"],
#os-win:focus-visible ~ .os-tabs label[for="os-win"] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.os-panel { display: none; }
#os-mac:checked ~ .os-panel.os-mac,
#os-win:checked ~ .os-panel.os-win { display: block; }
.row { display: flex; align-items: center; gap: 1.3rem; font-family: var(--mono); font-size: 0.85rem; flex-wrap: wrap; }
.row a { color: var(--accent); text-decoration: none; }
.row a:hover { text-decoration: underline; }
.pipe { color: var(--muted); }
.pipe b { color: var(--ink); }

/* ---- home: sections ---- */
.content section { padding-top: 3.6rem; }
.label { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.02em; color: var(--accent); margin: 0 0 0.9rem; }
.label::before { content: "// "; }

.who { font-size: 1.25rem; line-height: 1.45; color: #2a3036; }
.who b { color: var(--accent); font-weight: 660; }

.grid {
  display: grid;
  grid-template-columns: 1fr;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: #fff;
}
.grid .cell { padding: 0.95rem 1.1rem; border-bottom: 1px solid var(--line); display: flex; gap: 1rem; align-items: baseline; }
.grid .cell:last-child { border-bottom: 0; }
.grid .k { font-family: var(--mono); font-size: 0.85rem; color: var(--ink); min-width: 6.5rem; }
.grid .v { color: var(--muted); font-size: 0.93rem; }

.keeps-word {
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 720;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 1rem;
}
.keeps-note { color: var(--muted); font-size: 0.95rem; line-height: 1.6; margin: 0; }
/* CJK glyphs read much heavier than Latin at the same size, so the big "keeps"
   word is oversized in Japanese — scale it down and drop the Latin letter-spacing. */
:lang(ja) .keeps-word { font-size: clamp(1.5rem, 4.5vw, 2rem); letter-spacing: normal; line-height: 1.3; }

.steps { list-style: none; padding: 0; margin: 0; font-family: var(--mono); font-size: 0.9rem; }
.steps li { padding: 0.7rem 0; border-bottom: 1px dashed var(--line); display: flex; gap: 0.4rem 0.85rem; flex-wrap: wrap; align-items: baseline; }
.steps li:last-child { border-bottom: 0; }
.steps .n { flex: 0 0 1rem; color: var(--accent); }
.steps b { flex: 0 0 4.5rem; color: var(--ink); font-weight: 600; }
.steps .desc { flex: 1 1 14rem; font-family: var(--sans); color: var(--muted); font-size: 0.95rem; }

.trust {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 1.3rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}
.trust li { padding: 0.5rem 0; color: var(--muted); }
.trust li::before { content: "✓ "; color: var(--accent); }
.trust b { color: var(--ink); font-weight: 600; }

.closer-lead,
.closer-punch {
  font-size: clamp(1.3rem, 5vw, 1.6rem);
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin: 0;
}
.closer-lead { font-weight: 600; color: var(--ink); }
.closer-punch { font-weight: 680; color: var(--accent); margin-bottom: 1.1rem; }
.closer-note { color: var(--muted); font-size: 0.95rem; line-height: 1.5; margin: 0 0 1.1rem; }
.closer-cta { color: var(--accent); text-decoration: none; font-family: var(--mono); font-size: 0.9rem; }
.closer-cta:hover { text-decoration: underline; }

.example-lead { font-size: 1.05rem; margin: 0 0 0.5rem; }
.example-lead a { color: var(--accent); text-decoration: none; font-family: var(--mono); white-space: nowrap; }
.example-lead a:hover { text-decoration: underline; }
.demo-links {
  list-style: none;
  padding: 0;
  margin: 0.6rem 0 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.82rem;
}
.demo-links a { color: var(--accent); text-decoration: none; }
.demo-links a:hover { text-decoration: underline; }
.demo-links a:hover .ext-icon { opacity: 1; }
.example-note { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* ---- prose pages (single / list) ---- */
.post, .page-header, .notfound { padding-top: 2.6rem; }
.post-header { margin-bottom: 1.2rem; }
.post-header h1, .page-header h1 { margin-bottom: 0.4rem; }
.post a, .page-intro a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--line);
}
.post a:hover { text-decoration-color: var(--accent); }

.post-list { list-style: none; padding: 0; }
.post-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

/* ---- footer ---- */
.site-footer {
  margin-top: 4.2rem;
  padding-top: 1.4rem;
  padding-bottom: 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.site-footer p { margin: 0; }
.footer-meta { display: flex; flex-direction: column; gap: 0.3rem; }
/* nowrap keeps each label glued to its trailing external-link icon so the
   icon can't orphan onto the next line at a wrap point. */
.site-footer a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.site-footer a:hover { color: var(--accent); }
.footer-nav { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.45rem 1rem; }

/* ---- responsive ---- */
@media (max-width: 30rem) {
  .trust { grid-template-columns: 1fr; }
  .site-header { flex-direction: column; align-items: flex-start; }
}
