/* BitMonkey site. Shared by every page.
   No external requests: system fonts only.
   Two skins, set on <body>:
     .skin-term  studio home and developer tools (monospace, dark first)
     .skin-app   consumer apps (rounded, calm)
   .theme-<slug> sets a consumer app's palette, or a tool's accent. */

/* ---------- Tokens ---------- */

:root {
  color-scheme: light dark;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --round: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;

  /* Ink: always dark. Studio bar and terminal windows. */
  --ink-bg: #0e0f11;
  --ink-surface: #16181c;
  --ink-line: #30363d;
  --ink-text: #d7dbe0;
  --ink-heading: #f0f3f6;
  --ink-muted: #8b949e;
  --ink-accent: #7ee787;
}

.skin-term {
  --bg: #f6f8fa;
  --surface: #eaeef2;
  --line: #d0d7de;
  --text: #1f2328;
  --heading: #0d1117;
  --muted: #59636e;
  --accent: #18742f;
}

.skin-term.theme-rugittu { --accent: #a3461a; }
.skin-term.theme-gtop { --accent: #862a82; }

/* Consumer app palettes. Also used by the app cards on the home page. */
.theme-focus-audio {
  --bg: #eef3f0;
  --surface: #e2eae6;
  --line: #c9d7d1;
  --text: #17231f;
  --heading: #17231f;
  --muted: #4d615a;
  --accent: #326a5e; /* darker than the app's #3f7d70, so links pass AA */
}

@media (prefers-color-scheme: dark) {
  .logo-mark { background: #fbf6ea; }

  .skin-term {
    --bg: #0e0f11;
    --surface: #16181c;
    --line: #30363d;
    --text: #d7dbe0;
    --heading: #f0f3f6;
    --muted: #8b949e;
    --accent: #7ee787;
  }

  .skin-term.theme-rugittu { --accent: #e79a6e; }
  .skin-term.theme-gtop { --accent: #d08fcc; }

  .theme-focus-audio {
    --bg: #131b18;
    --surface: #1b2622;
    --line: #2a3833;
    --text: #e3ece8;
    --heading: #eef5f2;
    --muted: #9db0a8;
    --accent: #92c4b8;
  }
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.6 var(--sans);
}

.wrap { max-width: 44rem; margin: 0 auto; padding: 0 1rem; }
.wrap.wide { max-width: 62rem; }

a { color: var(--accent); text-underline-offset: 0.15em; }

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

h1, h2, h3 { color: var(--heading); line-height: 1.2; }
h1 { font-size: clamp(2rem, 6vw, 3rem); font-weight: 700; margin: 0 0 1rem; letter-spacing: -0.02em; }
h2 { font-size: 1.375rem; font-weight: 650; margin: 2.5rem 0 0.5rem; }
h3 { font-size: 1.0625rem; margin: 1.75rem 0 0.25rem; }

p, ul { margin: 0 0 1rem; }
ul { padding-left: 1.25rem; }
li { margin-bottom: 0.35rem; }

main { padding-bottom: 4rem; }

.lede { font-size: 1.1875rem; color: var(--muted); max-width: 34rem; }
.meta { color: var(--muted); font-size: 0.9375rem; }

/* ---------- Terminal skin type ---------- */

.skin-term h1, .skin-term h2, .skin-term h3 { font-family: var(--mono); letter-spacing: -0.01em; }
.skin-term h1 { font-size: clamp(1.625rem, 5vw, 2.5rem); font-weight: 600; }
.skin-term h2 { font-size: 1.1875rem; font-weight: 600; }

.hl { color: var(--accent); }

.cursor {
  display: inline-block;
  width: 0.55em;
  height: 0.95em;
  margin-left: 0.12em;
  vertical-align: -0.1em;
  background: var(--accent);
}

@media (prefers-reduced-motion: no-preference) {
  .cursor { animation: blink 1.1s steps(1) infinite; }
  @keyframes blink { 50% { opacity: 0; } }
}

.comment { font-family: var(--mono); font-size: 0.9375rem; color: var(--muted); }

.section-title {
  font-family: var(--mono);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--muted);
  margin: 3.5rem 0 1rem;
}

/* ---------- App skin type ---------- */

.skin-app h1, .skin-app h2 { font-family: var(--round); }
.skin-app h1 { font-weight: 800; letter-spacing: -0.015em; }

/* ---------- Header, logo, studio bar ---------- */

header.site { padding: 1.5rem 0; }

header.site .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  flex-wrap: wrap;
}

.logo {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--heading);
  text-decoration: none;
}

.logo span { color: var(--accent); }

/* Monkey mark. On dark backgrounds it sits on a cream disc. */
.logo-mark {
  width: 1.75em;
  height: 1.75em;
  margin-right: 0.45em;
  vertical-align: middle;
  padding: 0.14em;
  border-radius: 50%;
  object-fit: contain;
}
.studio-bar .logo-mark { background: #fbf6ea; }

nav.site a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 1.25rem;
}

nav.site a:first-child { margin-left: 0; }
nav.site a[aria-current="page"] { color: var(--heading); }
nav.site a:hover { color: var(--accent); }

.skin-term nav.site { font-family: var(--mono); font-size: 0.875rem; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--round);
  font-weight: 800;
  font-size: 1.125rem;
  color: var(--heading);
  text-decoration: none;
}

.app-icon { width: 2rem; height: 2rem; border-radius: 22%; }

.studio-bar {
  background: var(--ink-bg);
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.studio-bar .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.studio-bar a { color: var(--ink-muted); text-decoration: none; }
.studio-bar a:hover { color: var(--ink-heading); }
.studio-bar .logo { color: var(--ink-heading); }
.studio-bar .logo span { color: var(--ink-accent); }

/* ---------- Footer ---------- */

footer.site {
  border-top: 1px solid var(--line);
  padding: 1.5rem 0 2.5rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8125rem;
}

footer.site .wrap {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

footer.site a { color: var(--muted); }
footer.site a:hover { color: var(--accent); }
footer.site .logo { color: var(--heading); text-decoration: none; }

.skin-app footer.site { background: var(--surface); border-top: 0; }

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

.hero { padding: 3rem 0 1.5rem; }

/* ---------- Home: app cards ---------- */

.app-cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(19rem, 100%), 1fr));
  gap: 1rem;
}

.app-card {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 7rem;
  gap: 1rem;
  min-height: 15rem;
  padding: 1.5rem 1.5rem 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

.app-card h3 { font-family: var(--round); font-size: 1.375rem; margin: 0 0 0.25rem; }
.app-card h3 a { color: var(--heading); text-decoration: none; }
.app-card h3 a:hover { color: var(--accent); }
.app-card p { color: var(--muted); font-size: 0.9375rem; margin: 0 0 0.75rem; }
.app-card .phone-shot { align-self: end; margin-bottom: -2.5rem; }

.platforms { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); }

.links a { margin-right: 1rem; font-size: 0.9375rem; }

/* ---------- Home: tool list ---------- */

.tool-list { list-style: none; padding: 0; margin: 0; border-top: 1px dashed var(--line); }

.tool-list li {
  display: grid;
  grid-template-columns: 12rem 1fr auto;
  gap: 1.25rem;
  align-items: center;
  margin: 0;
  padding: 1rem 0;
  border-bottom: 1px dashed var(--line);
}

.tool-list h3 { margin: 0; font-size: 1.0625rem; }
.tool-list h3 a { color: var(--heading); text-decoration: none; }
.tool-list h3 a:hover { color: var(--accent); }
.tool-list p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.9375rem; }

@media (max-width: 36rem) {
  .tool-list li { grid-template-columns: 1fr; gap: 0.75rem; }
}

/* ---------- Screenshots ---------- */

/* Phone: a <picture class="phone-shot"> or a placeholder <div>. */
.phone-shot { display: block; }

.phone-shot > img,
.phone-shot.placeholder {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 600 / 1304;
  border: 3px solid #0b0d0e;
  border-radius: 13% / 6%;
  background: var(--surface);
  box-shadow: 0 18px 40px rgb(0 0 0 / 0.22);
}

.phone-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 13rem));
  justify-content: center;
  gap: 2rem;
  margin: 2.5rem 0;
}

.phone-row figure { margin: 0; }
.phone-row figcaption { margin-top: 0.75rem; text-align: center; color: var(--muted); font-size: 0.9375rem; }

/* Terminal: <figure class="term-window"> with an optional .bar and a pre.tty.
   The screen scales to the window width. Each shot sets --cols in its shots.css.
   The font-size math counts 0.61em per character: mono fonts are about 0.6em
   wide (SF Mono and Menlo 0.602em), and the small spare keeps the widest line
   inside the window. */
.term-window {
  --cols: 110;
  margin: 0;
  overflow: hidden;
  container-type: inline-size;
  border: 1px solid var(--ink-line);
  border-radius: 10px;
  background: var(--ink-bg);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.25);
}

.term-window .bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--ink-surface);
  border-bottom: 1px solid var(--ink-line);
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.term-window .bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-line); }
.term-window .bar span { margin-left: 0.5rem; }

.tty {
  margin: 0;
  padding: 2cqw;
  overflow: hidden;
  white-space: pre;
  color: var(--ink-text);
  font-family: var(--mono);
  font-size: calc(96cqw / (var(--cols) * 0.61));
  line-height: 1.15;
}

/* One character cell. Braille and other glyphs the mono font lacks come from a
   fallback font with another width; this box keeps them one cell (1ch) wide. */
.tty .c {
  display: inline-block;
  width: 1ch;
  overflow: hidden;
  vertical-align: top;
  font-weight: inherit;
  text-align: center;
}

/* 110 x 32 cells at 0.6em x 1.15em. */
.tty.placeholder { aspect-ratio: 66 / 36.8; background: var(--ink-surface); }

.hero .term-window { margin: 2.5rem 0 0; }

/* ---------- App page ---------- */

.app-hero {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 2rem;
  align-items: center;
  padding: 2.5rem 0 1rem;
}

.app-hero .phone-shot { max-width: 15rem; justify-self: center; }

@media (max-width: 40rem) {
  .app-hero { grid-template-columns: 1fr; }
  .app-hero .phone-shot { max-width: 13rem; }
}

.store-badge {
  display: inline-block;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  background: var(--heading);
  color: var(--bg);
  font-size: 0.9375rem;
  font-weight: 600;
}

/* ---------- Content blocks ---------- */

.groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1.5rem;
  margin: 2.5rem 0;
  padding: 1.5rem 0 0;
  border-top: 1px solid var(--line);
}

.groups h2 { margin: 0 0 0.25rem; font-size: 1.0625rem; }
.groups p { color: var(--muted); font-size: 0.9375rem; margin: 0; }

.note {
  background: var(--surface);
  border-radius: 14px;
  padding: 1.25rem 1.25rem 0.25rem;
  margin: 2rem 0;
}

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

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

kbd {
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.05em 0.4em;
}

pre.cmd {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  line-height: 1.55;
}

pre.cmd code { background: none; padding: 0; font-size: 0.875rem; }
