/* =========================================================================
   rudderless — shared design system
   Drafting-paper aesthetic: monospace type, vertical rails, a graph-paper
   footer, and hairline rules with + crosshairs. Loaded by every page.
   ========================================================================= */

:root {
  --mono: "Spline Sans Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Fluid base size. Body copy stays in a calm 16px (mobile) to 18px (4K)
     range, like Zed: hierarchy comes from headings + weight + the breakout
     screenshot, not from scaling body text up. Monospace reads a touch large
     per px, so this deliberately sits at the lower end. */
  font-size: clamp(16px, 0.2vw + 13.5px, 18px);

  /* Drafting-grid geometry. --frame is the rail-to-rail content width; it is
     expressed in rem, so it widens on large screens along with the type. */
  --frame: 47rem;
  --gutter: 1.25rem;                                      /* min viewport-edge inset */
  --rail: max(var(--gutter), calc((100% - var(--frame)) / 2)); /* edge -> rail inset */
}

/* ---- Theme tokens ------------------------------------------------------- */

html[data-theme="light"] {
  --bg:     oklch(0.986 0.001 286);
  --ink:    oklch(0.265 0.006 286);
  --muted:  oklch(0.515 0.008 286);
  --faint:  oklch(0.665 0.008 286);
  --line:   oklch(0.905 0.003 286);
  --cross:  oklch(0.740 0.010 286);
  --grid:   oklch(0.885 0.028 300); /* faint purple graph-paper dots */
  --accent: oklch(0.505 0.215 293);
}

html[data-theme="dark"] {
  --bg:     oklch(0.205 0.006 286);
  --ink:    oklch(0.925 0.004 286);
  --muted:  oklch(0.685 0.010 286);
  --faint:  oklch(0.545 0.012 286);
  --line:   oklch(0.305 0.008 286);
  --cross:  oklch(0.460 0.014 286);
  --grid:   oklch(0.400 0.045 300);
  --accent: oklch(0.740 0.165 296);
}

/* ---- Reset & document --------------------------------------------------- */

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1.72;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "liga" 0;
  transition: background 0.3s ease, color 0.3s ease;
}

::selection { background: var(--accent); color: var(--bg); }

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

/* ---- Background: full-height vertical rails ----------------------------- */

.rails { position: fixed; inset: 0; pointer-events: none; z-index: 0; }

.rails i {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

.rails i.l { left: var(--rail); }
.rails i.r { right: var(--rail); }

/* ---- Background: graph-paper fill across the bottom, full-bleed --------- */

.paper {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 25vh;
  z-index: 0;
  pointer-events: none;
  --cell: 13px;
  background-image: radial-gradient(var(--grid) 1px, transparent 1.4px);
  background-size: var(--cell) var(--cell);
  background-position: left bottom;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 45%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 45%);
}

/* ---- Full-bleed double rule with + crosshairs over the rails ------------ */

.hr {
  position: relative;
  width: 100vw;
  left: 50%;
  transform: translateX(-50%);
  height: 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.hr::before,
.hr::after {
  content: "+";
  position: absolute;
  top: 50%;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1;
  color: var(--cross);
}

.hr::before { left: var(--rail);  transform: translate(-50%, -50%); }
.hr::after  { right: var(--rail); transform: translate(50%, -50%); }

/* ---- Content column ----------------------------------------------------- */

main {
  position: relative;
  z-index: 1;
  max-width: var(--frame);
  margin: 0 auto;
  padding: 0 clamp(1.7rem, 5vw, 2.7rem);
}

section { padding: clamp(2.6rem, 6vw, 3.8rem) 0 0; }

/* A faint mono caption that labels a section (e.g. "apps"). */
.label {
  color: var(--faint);
  margin: 0 0 1.1rem;
  font-size: 0.84rem;
  letter-spacing: 0.01em;
}

/* ---- Header ------------------------------------------------------------- */

header {
  padding: clamp(3.5rem, 11vw, 7rem) 0 clamp(2.6rem, 6vw, 3.8rem);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
}

.header-text { min-width: 0; }

.wordmark {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}

/* Breadcrumb wordmark (e.g. rudderless/raft): the studio name links home. */
.wordmark a { color: inherit; transition: color 0.18s ease; }
.wordmark a:hover { color: var(--accent); }
.wordmark .sep { color: var(--faint); }

/* ---- Theme toggle (pill) ------------------------------------------------ */

.theme-toggle {
  flex: none;
  margin-top: 0.15rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5ch;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  color: var(--faint);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.32rem 0.7rem 0.32rem 0.58rem;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.theme-toggle:hover { color: var(--ink); border-color: var(--cross); }

.theme-toggle .icon {
  width: 0.82em;
  height: 0.82em;
  display: inline-block;
  color: var(--accent);
}

/* Show the moon in light mode (tap for dark), the sun in dark mode. */
.theme-toggle .sun  { display: none; }
.theme-toggle .moon { display: inline-block; }
html[data-theme="dark"] .theme-toggle .sun  { display: inline-block; }
html[data-theme="dark"] .theme-toggle .moon { display: none; }

.theme-toggle .label-light { display: none; }
.theme-toggle .label-dark  { display: inline; }
html[data-theme="dark"] .theme-toggle .label-light { display: inline; }
html[data-theme="dark"] .theme-toggle .label-dark  { display: none; }

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

footer {
  padding: clamp(3rem, 8vw, 5rem) 0 clamp(3.5rem, 10vw, 6rem);
  color: var(--faint);
  font-size: 0.82rem;
  line-height: 1.7;
  letter-spacing: 0.01em;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

footer a { color: var(--muted); }
footer a:hover { color: var(--accent); }

/* ---- Motion preferences ------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
