/* pages.captain.works — shared styles. shadcn/ui-inspired: neutral tokens,
   thin borders, soft radius, visible focus rings, light + dark themes. */

:root {
  --background: #ffffff;
  --foreground: #0a0a0a;
  --card: #ffffff;
  --muted: #f4f4f5;
  --muted-foreground: #6b7280;
  --border: #e4e4e7;
  --primary: #18181b;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --ring: #93c4fd;
  --radius: 0.6rem;
  --maxw: 820px;
}

:root[data-theme="dark"] {
  --background: #0a0a0b;
  --foreground: #fafafa;
  --card: #111113;
  --muted: #1c1c20;
  --muted-foreground: #a1a1aa;
  --border: #27272a;
  --primary: #fafafa;
  --accent: #60a5fa;
  --accent-soft: #172033;
  --ring: #1d4ed8;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #0a0a0b;
    --foreground: #fafafa;
    --card: #111113;
    --muted: #1c1c20;
    --muted-foreground: #a1a1aa;
    --border: #27272a;
    --primary: #fafafa;
    --accent: #60a5fa;
    --accent-soft: #172033;
    --ring: #1d4ed8;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Top bar ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem clamp(1rem, 4vw, 2rem);
  background: color-mix(in srgb, var(--background) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  font-weight: 600;
  color: var(--foreground);
  letter-spacing: -0.01em;
}
.topbar nav {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
  align-items: center;
}
.topbar nav a {
  color: var(--muted-foreground);
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.topbar nav a:hover { background: var(--muted); text-decoration: none; color: var(--foreground); }
.topbar nav a.active { color: var(--foreground); background: var(--muted); }

/* Keep the header inside the viewport on small screens: compact the nav,
   let it wrap, and drop the brand text before anything can overflow. */
@media (max-width: 560px) {
  .topbar { padding: 0.55rem 0.8rem; gap: 0.5rem; flex-wrap: wrap; }
  .topbar .brand { font-size: 0.9rem; }
  .topbar nav { gap: 0.1rem; flex-wrap: wrap; justify-content: flex-end; }
  .topbar nav a { padding: 0.35rem 0.5rem; font-size: 0.82rem; }
}
@media (max-width: 430px) {
  .topbar .brand { display: none; }
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--muted); }
.theme-toggle:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
}

/* ── Layout ──────────────────────────────────────────────── */
main { max-width: var(--maxw); margin: 0 auto; padding: clamp(1.5rem, 5vw, 3.5rem) clamp(1rem, 4vw, 2rem) 5rem; }

.hero { margin-bottom: 2.5rem; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 0.75rem; }
.hero p { color: var(--muted-foreground); font-size: 1.08rem; margin: 0.4rem 0; max-width: 62ch; }
.eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.9rem;
}

h2 { font-size: 1.5rem; letter-spacing: -0.01em; margin: 2.8rem 0 0.4rem; }
h3 { font-size: 1.12rem; margin: 1.6rem 0 0.3rem; }
p { margin: 0.6rem 0; }
.lead { color: var(--muted-foreground); }

section > p, .section-intro { max-width: 68ch; }

/* ── Cards ───────────────────────────────────────────────── */
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.5rem; }
@media (max-width: 640px) { .card-grid { grid-template-columns: 1fr; } }

.card {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 1.4rem 1.4rem 1.5rem;
  color: inherit;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
a.card:hover {
  text-decoration: none;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -12px rgba(0,0,0,0.25);
}
.card .ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 0.9rem;
}
.card .ico svg { width: 20px; height: 20px; }
.card h3 { margin: 0 0 0.35rem; font-size: 1.15rem; color: var(--foreground); }
.card p { margin: 0; color: var(--muted-foreground); font-size: 0.95rem; }
.card .go { display: inline-flex; align-items: center; gap: 0.3rem; margin-top: 0.9rem; color: var(--accent); font-size: 0.9rem; font-weight: 500; }
.card .go svg { width: 15px; height: 15px; }

/* ── Rule blocks ─────────────────────────────────────────── */
.group-label {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted-foreground); margin: 2.6rem 0 0.2rem; padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.rule {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 1.15rem 1.3rem;
  margin: 1rem 0;
}
.rule h3 { margin: 0 0 0.3rem; font-size: 1.08rem; display: flex; align-items: center; gap: 0.55rem; }
.rule h3 .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.rule p { margin: 0.45rem 0 0; color: var(--muted-foreground); font-size: 0.96rem; }
.rule p strong { color: var(--foreground); font-weight: 600; }

code, .mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: 0.88em; }
:not(pre) > code { background: var(--muted); padding: 0.1em 0.4em; border-radius: 5px; }

pre {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
}
pre code { background: none; padding: 0; }

.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  margin: 1.4rem 0;
  font-size: 0.94rem;
}
.callout strong { color: var(--foreground); }

ul.clean { padding-left: 1.15rem; margin: 0.5rem 0; }
ul.clean li { margin: 0.35rem 0; }

.doc h2 { border-bottom: 1px solid var(--border); padding-bottom: 0.35rem; }
.doc ul { padding-left: 1.2rem; }
.doc li { margin: 0.3rem 0; }
.doc li strong { color: var(--foreground); }

footer {
  max-width: var(--maxw); margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2rem) 3rem;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground); font-size: 0.88rem;
}
