/* ==========================================================
   w3g.dev — design tokens
   Dark is the base theme; light applies via [data-theme=light]
   or the OS preference when no explicit choice is stored.
   Per-app accent colors live in apps.json and are emitted as
   .a-{slug} rules in the page head — adding an app needs no
   CSS changes.
   ========================================================== */
:root {
  --bg: #0b0e14;
  --bg-raise: #11151f;
  --surface: #151a26;
  --line: #232b3b;
  --text: #e9edf5;
  --muted: #96a0b5;
  --faint: #5c6579;

  --brand: #4da0f0;          /* azure from the W3G cube */
  --brand-2: #2bd9c8;        /* cyan from the W3G cube */
  --brand-soft: rgba(77, 160, 240, 0.14);

  --link-hover: #fff;
  --header-bg: rgba(11, 14, 20, 0.85);
  --card-shadow: none;
  --article-text: #c6cddc;
  --soon: #5c6579;

  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Instrument Sans", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --maxw: 1080px;
  --radius: 14px;
}

[data-theme="light"] {
  --bg: #f7f8fb;
  --bg-raise: #eef0f6;
  --surface: #ffffff;
  --line: #e2e6ef;
  --text: #171c26;
  --muted: #5b6577;
  --faint: #8a93a6;

  --brand: #2653d4;
  --brand-2: #0f9d9a;
  --brand-soft: rgba(38, 83, 212, 0.10);

  --link-hover: #000;
  --header-bg: rgba(247, 248, 251, 0.85);
  --card-shadow: 0 1px 3px rgba(23, 28, 38, 0.05);
  --article-text: #333c4d;
  --soon: #8a93a6;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f7f8fb;
    --bg-raise: #eef0f6;
    --surface: #ffffff;
    --line: #e2e6ef;
    --text: #171c26;
    --muted: #5b6577;
    --faint: #8a93a6;

    --brand: #2653d4;
    --brand-2: #0f9d9a;
    --brand-soft: rgba(38, 83, 212, 0.10);

    --link-hover: #000;
    --header-bg: rgba(247, 248, 251, 0.85);
    --card-shadow: 0 1px 3px rgba(23, 28, 38, 0.05);
    --article-text: #333c4d;
    --soon: #8a93a6;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--text); text-decoration: none; }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: 4px; }

img { max-width: 100%; display: block; }

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

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--brand); color: #fff;
  padding: 10px 18px; border-radius: 0 0 8px 0; font-weight: 600;
}
.skip-link:focus { left: 0; color: #fff; }

.linklike {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; color: var(--muted); font-size: 0.92rem;
}
.linklike:hover { color: var(--text); }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.logo {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em;
}
.logo img { width: 26px; height: 26px; }
.logo span {
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.site-nav { display: flex; gap: 26px; align-items: center; }
.site-nav a { color: var(--muted); font-size: 0.95rem; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); }
.nav-cta {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 16px; color: var(--text) !important;
  background: var(--bg-raise);
}
.nav-cta:hover { border-color: var(--brand); }

.theme-toggle {
  display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-raise); color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--brand); color: var(--text); }
.theme-toggle .i-moon { display: none; }
[data-theme="light"] .theme-toggle .i-sun { display: none; }
[data-theme="light"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="dark"]) .theme-toggle .i-moon { display: block; }
}

/* ---------- terminal eyebrow ---------- */
.prompt {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--faint);
  letter-spacing: 0.01em;
}
.prompt b { color: var(--brand); font-weight: 500; }
.prompt a { color: var(--brand); }

/* ---------- hero ---------- */
.hero { padding: 72px 0 40px; }
.hero-compact { padding-bottom: 8px; }
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.12; letter-spacing: -0.03em;
  margin: 14px 0 16px; max-width: 22ch;
}
.hero p.lede { color: var(--muted); max-width: 56ch; margin: 0 0 26px; font-size: 1.08rem; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 10px; padding: 11px 20px;
  font-weight: 600; font-size: 0.95rem;
  border: 1px solid var(--line);
  background: var(--bg-raise); color: var(--text);
  cursor: pointer; font-family: var(--font-body);
}
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); color: #fff; }

/* ---------- section scaffolding ---------- */
section { padding: 48px 0; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; margin-bottom: 26px; flex-wrap: wrap;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 1.6rem; letter-spacing: -0.02em; margin: 0;
}
.section-head .more { font-family: var(--font-mono); font-size: 0.85rem; color: var(--brand); }

/* ---------- app grid ---------- */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.app-card {
  --accent: var(--brand);
  position: relative;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--card-shadow);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.app-card:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  transform: translateY(-2px);
  box-shadow: 0 12px 40px -18px color-mix(in srgb, var(--accent) 45%, transparent);
}
.app-card img.icon {
  width: 52px; height: 52px; border-radius: 12px;
  border: 1px solid var(--line);
}
.icon-letter {
  width: 52px; height: 52px; border-radius: 12px;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 1.3rem;
  background: color-mix(in srgb, var(--accent) 18%, var(--bg-raise));
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
}
.app-card h3 {
  margin: 0; font-family: var(--font-display);
  font-size: 1.15rem; letter-spacing: -0.01em;
}
.app-card h3 a::after { content: ""; position: absolute; inset: 0; }
.app-card p { margin: 0; color: var(--muted); font-size: 0.95rem; flex: 1; }
.app-meta {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 0.72rem;
  color: var(--faint); letter-spacing: 0.02em;
}
.app-meta .dot { color: var(--accent); }
.app-card.soon { border-style: dashed; }
.app-card.soon .icon-letter { color: var(--faint); }
.a-soon { --accent: var(--soon); }

/* ---------- filter chips (apps hub) ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.chip {
  font-family: var(--font-mono); font-size: 0.8rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--muted);
  padding: 6px 14px; cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--brand-soft); border-color: var(--brand); color: var(--text); }

/* ---------- links hub (linktree replacement) ---------- */
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.link-tile {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 15px 18px;
  box-shadow: var(--card-shadow);
  transition: border-color 0.2s ease;
}
.link-tile:hover { border-color: var(--brand); }
.link-tile .label { font-weight: 600; font-size: 0.95rem; }
.link-tile .handle { font-family: var(--font-mono); font-size: 0.78rem; color: var(--faint); }
.link-tile .arrow { color: var(--brand); }

/* ---------- story strip ---------- */
.story {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--bg-raise);
}
.story .wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }
.story p { color: var(--muted); margin-top: 0; }
.story-title { font-family: var(--font-display); letter-spacing: -0.02em; }
@media (max-width: 760px) { .story .wrap { grid-template-columns: 1fr; } }

/* ---------- blog cards ---------- */
.post-list { display: grid; gap: 14px; }
.post-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 18px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); padding: 16px 20px;
  box-shadow: var(--card-shadow);
}
.post-row:hover { border-color: var(--faint); }
.post-row .title { font-weight: 600; }
.post-row time { font-family: var(--font-mono); font-size: 0.78rem; color: var(--faint); white-space: nowrap; }

/* ---------- app detail page ---------- */
.app-hero { padding: 64px 0 32px; }
.app-hero .top { display: flex; gap: 20px; align-items: center; margin: 18px 0; }
.app-hero img.icon-lg {
  width: 84px; height: 84px; border-radius: 20px;
  border: 1px solid var(--line);
}
.app-hero h1 { font-family: var(--font-display); font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0; letter-spacing: -0.02em; }
.app-hero .hero-sub { margin: 6px 0 0; }
.app-hero .tagline { color: var(--muted); font-size: 1.1rem; max-width: 58ch; }
.store-badges { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.feature {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--card-shadow);
}
.feature h3 { font-family: var(--font-display); font-size: 1.02rem; margin: 0 0 8px; }
.feature p { color: var(--muted); font-size: 0.92rem; margin: 0; }

/* screenshot strip: uniform-height row, horizontal scroll with snap.
   Works with any image aspect and count; scales from phone to desktop. */
.shots {
  display: flex; gap: 14px;
  overflow-x: auto;
  padding-top: 4px; padding-bottom: 16px;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.shot-btn {
  flex: 0 0 auto; scroll-snap-align: start;
  padding: 0; border: none; background: none;
  cursor: zoom-in; border-radius: 18px;
}
img.shot {
  height: clamp(320px, 48vh, 460px); width: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-raise);
  transition: transform 0.2s ease;
}
.shot-btn:hover img.shot { transform: translateY(-2px); }

.lightbox {
  border: none; padding: 0; margin: auto;
  background: transparent; max-width: none; max-height: none;
  overflow: visible;
}
.lightbox::backdrop { background: rgba(5, 8, 14, 0.88); backdrop-filter: blur(4px); }
.lightbox img {
  max-height: 88vh; max-width: 92vw;
  width: auto; height: auto;
  border-radius: 20px; display: block;
}
.lightbox-close {
  position: absolute; top: -14px; right: -14px; z-index: 1;
  width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 0.95rem; cursor: pointer;
}
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 1;
  width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.lightbox-nav.prev { left: -18px; }
.lightbox-nav.next { right: -18px; }
@media (max-width: 640px) {
  img.shot { height: min(62vh, 420px); }
  .lightbox-close { top: 8px; right: 8px; }
  .lightbox-nav.prev { left: 8px; }
  .lightbox-nav.next { right: 8px; }
}

.faq details {
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); padding: 4px 18px; margin-bottom: 10px;
  box-shadow: var(--card-shadow);
}
.faq summary { cursor: pointer; font-weight: 600; padding: 12px 0; }
.faq p { color: var(--muted); margin-top: 0; }
.faq a { color: var(--brand); }

.crosspromo {
  display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-raise); padding: 20px;
}
.crosspromo img.icon { width: 52px; height: 52px; border-radius: 12px; border: 1px solid var(--line); flex-shrink: 0; }
.crosspromo p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.crosspromo strong { color: var(--text); }
.crosspromo .promo-link { color: var(--accent); }

/* ---------- blog article & legal pages ---------- */
.article { max-width: 720px; margin: 0 auto; padding: 64px 24px 40px; }
.article h1 { font-family: var(--font-display); font-size: clamp(1.8rem, 4vw, 2.5rem); letter-spacing: -0.02em; line-height: 1.15; margin: 12px 0 10px; }
.article .meta { font-family: var(--font-mono); font-size: 0.8rem; color: var(--faint); display: flex; gap: 16px; margin-bottom: 34px; }
.article h2 { font-family: var(--font-display); font-size: 1.35rem; margin-top: 42px; letter-spacing: -0.01em; }
.article p, .article li { color: var(--article-text); }
.article a { color: var(--brand); }
.article code {
  font-family: var(--font-mono); font-size: 0.85em;
  background: var(--bg-raise); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 6px;
}
.article .numbers {
  width: 100%; border-collapse: collapse; margin: 18px 0;
  font-family: var(--font-mono); font-size: 0.85rem;
}
.article .numbers th, .article .numbers td {
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line);
}
.article .numbers th { color: var(--faint); font-weight: 500; }
.article blockquote {
  border-left: 3px solid var(--brand); margin: 24px 0;
  padding: 4px 0 4px 18px; color: var(--muted); font-style: italic;
}
.article-end { border: none; border-top: 1px solid var(--line); margin: 40px 0; }
.follow-line { font-family: var(--font-mono); font-size: 0.85rem; color: var(--faint) !important; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 44px 0 56px; margin-top: 40px; }
.site-footer .cols {
  display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px;
}
.site-footer h4 { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 12px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.site-footer a { color: var(--muted); font-size: 0.92rem; }
.site-footer a:hover { color: var(--text); }
.footer-blurb { color: var(--muted); font-size: 0.92rem; max-width: 40ch; }
.legal { font-size: 0.8rem; color: var(--faint); margin-top: 30px; font-family: var(--font-mono); }
@media (max-width: 700px) { .site-footer .cols { grid-template-columns: 1fr; } }

/* ---------- cookie consent ---------- */
.consent {
  position: fixed; z-index: 90;
  right: 20px; bottom: 20px; left: 20px;
  max-width: 400px; margin-left: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: 0 18px 50px -12px rgba(0, 0, 0, 0.45);
}
.consent p { margin: 0 0 14px; font-size: 0.88rem; color: var(--muted); }
.consent a { color: var(--brand); }
.consent-status { font-size: 0.8rem; font-weight: 600; color: var(--text); margin-top: -6px; }
.consent-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.consent-actions .btn { padding: 8px 15px; font-size: 0.88rem; }
.consent-actions .btn.current { box-shadow: 0 0 0 2px var(--brand) inset; }

/* ---------- motion & responsive ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
@media (max-width: 640px) {
  .site-nav { gap: 16px; }
  .site-nav .hide-sm { display: none; }
  .hero { padding: 48px 0 28px; }
}
