/* Grundform — the Leroy Baker design language.
   Three forms, three colours, one typeface, two lines. See DESIGN.md. */

/* ---- Tokens ---- */
:root {
  color-scheme: light dark;

  --paper: #f3f1ec;
  --ink: #151515;
  --muted: #5f5b55;
  --line: #d6d1c7;

  /* The primaries. Each belongs to exactly one form. */
  --blue: #1e4fa6;    /* circle   — writing */
  --red: #d63a22;     /* square   — hacks */
  --yellow: #f2b705;  /* triangle — ideas   */

  /* Set per page by data-section. Home is ink. */
  --accent: var(--ink);
  --on-accent: var(--paper);
  --form: inset(0);   /* the section's form, as a clip-path */

  --font: "Jost", "Futura", "Century Gothic", "Avenir Next", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Space: one unit, Fibonacci multiples */
  --s1: 8px;
  --s2: 16px;
  --s3: 24px;
  --s5: 40px;
  --s8: 64px;
  --s13: 104px;

  /* Lines: a bar carries structure, a hair divides */
  --bar: 6px;
  --rule: 2px;
  --hair: 1px;

  --page: 1200px;
  --gutter: clamp(16px, 4vw, 48px);
  --measure: 64ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111110;
    --ink: #edeae3;
    --muted: #9d988f;
    --line: #2f2d2a;
    --blue: #5b86e5;
    --red: #f0563d;
    --yellow: #f7c21b;
  }
}

[data-section="writing"] { --accent: var(--blue);   --on-accent: #fff;    --form: circle(50%); }
[data-section="ideas"]   { --accent: var(--yellow); --on-accent: #151515; --form: polygon(50% 6.7%, 100% 93.3%, 0 93.3%); }
[data-section="hacks"]   { --accent: var(--red);    --on-accent: #fff;    --form: inset(0); }

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

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

body {
  margin: 0;
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font: 400 18px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
img, svg, video { display: block; max-width: 100%; height: auto; }
p, li, td, figcaption { overflow-wrap: break-word; }
a, code { overflow-wrap: anywhere; }
strong { font-weight: 600; }

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

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: var(--hair);
  text-underline-offset: .22em;
}
a:hover {
  text-decoration-thickness: 3px;
  text-decoration-color: var(--accent);
}
:focus-visible {
  outline: var(--rule) solid var(--ink);
  outline-offset: 3px;
}

code {
  font-family: var(--mono);
  font-size: .84em;
  padding: .08em .3em;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
}

/* ---- Type ----
   The interface speaks lowercase (after Herbert Bayer); prose keeps its capitals.
   Hierarchy comes from size, weight and position — never from colour. */
.display {
  font-size: clamp(64px, 14vw, 184px);
  font-weight: 500;
  line-height: .86;
  letter-spacing: -.045em;
  text-transform: lowercase;
}
h1, .h1 {
  font-size: clamp(44px, 7.5vw, 104px);
  font-weight: 500;
  line-height: .94;
  letter-spacing: -.035em;
  text-transform: lowercase;
  text-wrap: balance;
}
h2, .h2 {
  font-size: clamp(30px, 4.2vw, 52px);
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -.025em;
  text-transform: lowercase;
  text-wrap: balance;
}
h3, .h3 {
  font-size: 22px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -.005em;
}
.lede {
  max-width: 34ch;
  font-size: clamp(20px, 2.1vw, 26px);
  line-height: 1.4;
  color: var(--muted);
}
.label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: .03em;
  text-transform: lowercase;
  color: var(--muted);
}
.label b { color: var(--ink); font-weight: 500; }
.muted { color: var(--muted); }

/* ---- The forms ----
   Circle is blue, square is red, triangle is yellow. Always. */
.form {
  --size: 14px;
  display: inline-block;
  flex: none;
  width: var(--size);
  height: var(--size);
  background: var(--ink);
}
.form.circle   { background: var(--blue); border-radius: 50%; }
.form.square   { background: var(--red); }
.form.triangle { background: var(--yellow); clip-path: polygon(50% 6.7%, 100% 93.3%, 0 93.3%); }
.form.ink      { background: var(--ink); clip-path: var(--form); }
.form.quiet    { background: var(--line); clip-path: var(--form); }

/* ---- Page frame ---- */
.page {
  width: min(var(--page), calc(100% - 2 * var(--gutter)));
  margin-inline: auto;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  min-height: 72px;
  border-bottom: var(--bar) solid var(--ink);
}
.mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.01em;
  text-transform: lowercase;
  text-decoration: none;
  color: var(--ink);
}
.mark .forms { display: inline-flex; gap: 4px; }
.mark .form { --size: 16px; }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s3);
}
.nav a {
  font-size: 15px;
  font-weight: 500;
  text-transform: lowercase;
  text-decoration: none;
  color: var(--muted);
}
.nav a:hover { color: var(--ink); }

.colophon {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s1) var(--s3);
  padding: var(--s3) 0 var(--s5);
  border-top: var(--hair) solid var(--line);
}

/* ---- The grid ----
   Asymmetric: a narrow margin column for labels and numbers,
   a wide main column for the work. Flush left. Nothing centred. */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 9fr);
  column-gap: var(--s5);
}
.grid > .margin { grid-column: 1; }
.grid > .main,
.grid > :not(.margin) { grid-column: 2; }

.section {
  padding: var(--s3) 0 var(--s13);
  border-top: var(--rule) solid var(--ink);
}

@media (max-width: 760px) {
  .grid { grid-template-columns: minmax(0, 1fr); row-gap: var(--s3); }
  .grid > .margin, .grid > .main, .grid > :not(.margin) { grid-column: 1; }
  .section { padding-bottom: var(--s8); }
}

/* ---- Prose ---- */
.prose > * + * { margin-top: var(--s2); }
.prose p, .prose ul, .prose ol { max-width: var(--measure); }
.prose h3 { margin-top: var(--s8); }
.prose h3 + * { margin-top: var(--s2); }

/* Bullets take the section's form */
.prose ul, ul.list {
  list-style: none;
  padding: 0;
}
.prose ul > li, ul.list > li {
  position: relative;
  padding-left: 26px;
}
.prose ul > li + li, ul.list > li + li { margin-top: var(--s1); }
.prose ul > li::before, ul.list > li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: .62em;
  width: 9px;
  height: 9px;
  background: var(--accent);
  clip-path: var(--form);
}

/* ---- Components ---- */

/* Status: a form and a word. Filled accent = in motion; quiet = waiting. */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .03em;
  text-transform: lowercase;
}
.status .form { --size: 10px; background: var(--accent); clip-path: var(--form); }
.status.quiet .form { background: var(--line); }

/* Aside: the accent bar beside a thought that matters */
.aside {
  max-width: var(--measure);
  padding: 2px 0 2px var(--s3);
  border-left: var(--bar) solid var(--accent);
}

/* Field: the one block of solid colour a page may have */
.field {
  background: var(--accent);
  color: var(--on-accent);
}
.field .label { color: color-mix(in srgb, var(--on-accent) 72%, transparent); }

/* Units: things set side by side, each topped with a rule */
.units {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--s5) var(--s3);
}
.unit {
  padding-top: var(--s2);
  border-top: var(--rule) solid var(--ink);
}

/* Tabs */
.tabs {
  display: flex;
  gap: var(--s3);
  border-bottom: var(--hair) solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none;
  flex: none;
  padding: 14px 0;
  border: 0;
  border-radius: 0;
  background: none;
  font: 500 16px/1 var(--font);
  text-transform: lowercase;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  box-shadow: inset 0 calc(-1 * var(--bar)) 0 transparent;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] {
  color: var(--ink);
  box-shadow: inset 0 calc(-1 * var(--bar)) 0 var(--accent);
}
.tab:focus-visible { outline-offset: -2px; }

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.5;
  border-top: var(--rule) solid var(--ink);
}
.table th, .table td {
  padding: 12px var(--s3) 12px 0;
  text-align: left;
  vertical-align: top;
  border-bottom: var(--hair) solid var(--line);
}
.table th {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .03em;
  text-transform: lowercase;
  color: var(--muted);
}
.table td:first-child { font-weight: 500; white-space: nowrap; }

/* Figures are numbered, like plates */
.figures { counter-reset: fig; }
figure { counter-increment: fig; }
figure img { width: 100%; }
figcaption {
  max-width: var(--measure);
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}
figcaption::before {
  content: "fig. " counter(fig);
  margin-right: 12px;
  font-weight: 500;
  color: var(--ink);
}

/* Forms (the input kind) */
.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 0;
  border: 0;
  border-bottom: var(--rule) solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 400 20px/1.2 var(--font);
}
.input:focus { outline: none; box-shadow: 0 var(--rule) 0 var(--accent); border-bottom-color: var(--accent); }
.button {
  appearance: none;
  min-height: 48px;
  padding: 0 var(--s3);
  border: 0;
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  font: 500 15px/1 var(--font);
  letter-spacing: .02em;
  text-transform: lowercase;
  cursor: pointer;
}
.button:hover { background: var(--accent); color: var(--on-accent); }

/* Stillness. The page doesn't move; the reader does. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
