@import url("./tokens.css");
@import url("./base.css");

/* Components. Values from spec/intent.md 4.5 to 4.8 and 9. */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.grid-12 {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap-columns);
}

/* ---------- Controls (4.5) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 var(--space-lg);
  border: 1px solid var(--color-accent-deep);
  border-radius: 4px;
  background: var(--color-accent-deep);
  color: var(--color-accent-ink);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--text-md);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color var(--dur-short) var(--ease-out), border-color var(--dur-short) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
.btn:hover { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-accent-ink); }
.btn:active { transform: translateY(1px); }
.btn--quiet { background: transparent; color: var(--color-ink); border-color: var(--color-rule); }
.btn--quiet:hover { background: var(--color-paper-3); border-color: var(--color-muted); color: var(--color-ink); }

/* Status pill: data, so monospace. */
.status {
  display: inline-block;
  padding: var(--space-2xs) var(--space-sm);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-pill);
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.3;
  white-space: nowrap;
}
.status--live { background: var(--color-accent-deep); border-color: var(--color-accent-deep); color: var(--color-accent-ink); }

.prose-links a,
.facts a,
.measures a,
.flow a,
.caption a,
.offer-text > a:not(.btn) {
  color: var(--color-accent-deep);
  text-decoration-color: var(--color-rule);
}
.prose-links a:hover,
.facts a:hover,
.measures a:hover,
.flow a:hover,
.caption a:hover,
.offer-text > a:not(.btn):hover { color: var(--color-accent); text-decoration-color: var(--color-accent); }

/* Small UI labels: "01 · Find", "Shared · Preliminary", "Experiments". Bricolage, the one place it lives. */
.label, .finding-id, h3.sub {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-muted);
  max-width: none;
  font-variation-settings: normal;
}

.lead {
  font-size: var(--text-lead);
  line-height: 1.46;
  letter-spacing: -0.011em;
  max-width: 52ch;
  color: var(--color-ink);
}

/* ---------- Skip link, banner, bar (4.6) ---------- */
.skip {
  position: absolute;
  left: var(--space-md);
  top: -96px;
  z-index: var(--z-tooltip);
  padding: var(--space-xs) var(--space-md);
  background: var(--color-ink);
  color: var(--color-paper);
  text-decoration: none;
}
.skip:focus { top: var(--space-md); }

/* The shell prompt: the one line of monospace outside the data. */
.banner {
  height: var(--banner-h);
  border-bottom: 1px solid var(--color-rule);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-muted);
}
.banner .container { height: 100%; display: flex; align-items: center; white-space: nowrap; }
.banner b { color: var(--color-accent-deep); font-weight: 600; }
.cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  margin-left: 4px;
  vertical-align: -0.2em;
  background: var(--color-accent);
  animation: blink 1.1s steps(1) 5;
}
@keyframes blink { 50% { opacity: 0; } }

.bar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky-nav);
  height: var(--bar-h);
  background: var(--color-paper);
  border-bottom: 1px solid var(--color-rule);
}
.bar .container { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--space-lg); }
.mark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-family: var(--font-display);
  font-variation-settings: "opsz" 24, "SOFT" 10, "WONK" 0;
  font-weight: 600;
  font-size: var(--text-lg);
  line-height: 1;
  letter-spacing: -0.018em;
  color: var(--color-ink);
  text-decoration: none;
  white-space: nowrap;
}
.mark:hover { color: var(--color-ink); }
.mark svg { width: 22px; height: 22px; flex: none; }
.mark .bolt { fill: var(--color-accent); }
.mark-word > span { color: var(--color-accent); }
.links { display: flex; align-items: center; gap: var(--space-lg); font-family: var(--font-ui); font-size: var(--text-sm); font-weight: 500; }
.links a:not(.btn) {
  color: var(--color-ink-2);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur-short) var(--ease-out);
}
.links a:not(.btn):hover { color: var(--color-ink); }
.links a:not(.btn):active { color: var(--color-accent-deep); }
.links .btn { min-height: 44px; font-size: var(--text-sm); }

/* ---------- Sections ---------- */
.band { padding-block: var(--section-gap-s); }
.band--2 { background: var(--color-paper-2); }
.band > .container > h2 + .lead,
.band > .container > .lead + .lead { margin-top: var(--space-lg); }
.facts a[href^="#f-"] { white-space: nowrap; }

/* The two sections the page is about now: bigger heads than the rest. */
.band--lead > .container > h2 { font-size: var(--text-display-s); line-height: 1; max-width: 20ch; }

/* ---------- Hero ---------- */
.hero { padding-top: var(--space-3xl); padding-bottom: var(--space-2xl); }
.built { padding-top: var(--space-2xl); }
.hero-head { align-items: start; }
.hero h1 { grid-column: 1 / 8; max-width: 14ch; line-height: 0.98; }
.hero-side { grid-column: 9 / 13; display: flex; flex-direction: column; gap: var(--space-lg); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-sm); }

/* ---------- Index rows (4.8) ---------- */
.index { border-top: 1px solid var(--color-rule); }
.row {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gap-columns);
  align-items: baseline;
  padding-block: var(--space-lg);
  border-bottom: 1px solid var(--color-rule);
  color: inherit;
  text-decoration: none;
}
.row h3 {
  grid-column: 1 / 4;
  font-size: var(--text-section);
  font-variation-settings: "opsz" 48, "SOFT" 20, "WONK" 0;
  letter-spacing: var(--tracking-display);
  line-height: 1;
  transition: color var(--dur-short) var(--ease-out);
}
.row .addr { grid-column: 4 / 7; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-muted); overflow-wrap: anywhere; }
.row .addr--live { color: var(--color-accent-deep); }
.row .stage { display: block; } /* the Agents stage, a second line of the address */
.index + .caption { margin-top: var(--space-md); }
.row > p { grid-column: 7 / 11; color: var(--color-ink-2); }
.row > .status { grid-column: 11 / 13; justify-self: end; }
a.row:hover { color: inherit; }
a.row:hover h3 { color: var(--color-accent-deep); }
a.row:active h3 { color: var(--color-ink-2); }
a.row:focus-visible { outline-offset: -2px; }
.row h3 a { color: inherit; text-decoration: none; }
.row h3 a:hover { color: var(--color-accent-deep); }
.row h3 a:active { color: var(--color-ink-2); }
.row--dim h3, .row--dim .addr { color: var(--color-muted); }
.row--grad h3 { font-size: var(--text-2xl); overflow-wrap: normal; } /* scar 12 */

/* ---------- Built and in use (#built) ---------- */
.built-block + .built-block { margin-top: var(--space-4xl); }
.built-intro { margin-bottom: var(--space-2xl); }
.built-intro .lead { margin-top: var(--space-lg); }
.built-block > h3.sub { margin-bottom: var(--space-lg); }

/* pia case, nested in Built */
.pia-head { align-items: center; margin-bottom: var(--space-2xl); }
.pia-text { grid-column: 1 / 8; display: flex; flex-direction: column; gap: var(--space-2xl); }
.pia-text h3, .offer-text h3 { font-size: var(--text-3xl); font-variation-settings: "opsz" 48, "SOFT" 20, "WONK" 0; letter-spacing: var(--tracking-display); line-height: 1.05; max-width: 20ch; }
.pia-phone { grid-column: 9 / 13; }
.shot { border-radius: var(--radius-card); outline: 1px solid var(--color-rule); outline-offset: -1px; }
.shot--phone { aspect-ratio: 780 / 1180; }
.shot--desktop { aspect-ratio: 2880 / 1300; }
.shot img { border-radius: var(--radius-card); }
.pia-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-md); margin-top: var(--space-md); }
.caption { font-family: var(--font-ui); color: var(--color-muted); font-size: var(--text-sm); line-height: 1.5; max-width: 60ch; }

/* The company connector: a paper-2 panel inside the Built band. */
.offer {
  background: var(--color-paper-2);
  border-radius: var(--radius-card);
  padding: var(--space-3xl) var(--space-2xl);
}
.offer-grid { align-items: center; }
.offer-text { grid-column: 1 / 6; display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-lg); }
.offer-text > p { color: var(--color-ink-2); }
.offer-tools { grid-column: 7 / 13; min-width: 0; }
.offer-tools pre {
  min-height: 360px;
  padding: var(--space-2xl) var(--space-xl);
  background: var(--color-paper-3);
  border-radius: var(--radius-card);
  font-size: var(--text-sm);
  font-weight: 400;
  line-height: 2;
  color: var(--color-ink-2);
  overflow-x: auto;
}
.offer-tools pre b { color: var(--color-ink); font-weight: 600; }
.offer-tools pre i { color: var(--color-muted); font-style: normal; }
.offer-tools pre .prompt { color: var(--color-accent); }
.offer-tools .caption { margin-top: var(--space-sm); }

/* ---------- Facts lists ---------- */
.facts { display: flex; flex-direction: column; gap: var(--space-xs); }
.facts > div { display: grid; grid-template-columns: minmax(0, 11ch) minmax(0, 1fr); column-gap: var(--space-lg); align-items: baseline; }
.facts dt { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-muted); }
.facts dd { color: var(--color-ink-2); min-width: 0; }
.facts--sm { font-size: var(--text-sm); }
.facts--sm dt { font-size: 0.75rem; }

/* ---------- Running now (#running): experiments ----------
   A planned test. The flask marks it; the track shows where it stands. */
.run-area { margin-top: var(--space-2xl); }
.run-area > .label { margin-bottom: var(--space-md); }
.row--run {
  position: relative;
  grid-template-columns: 28px minmax(0, 1fr);
  column-gap: var(--space-md);
  row-gap: var(--space-sm);
  align-items: start;
  padding-block: var(--space-xl);
}
.row--run .exp-mark { grid-column: 1; grid-row: 1; width: 22px; height: 22px; margin-top: 0.2em; color: var(--color-accent); }
.row--run h3 { grid-column: 2; grid-row: 1; font-size: var(--text-2xl); line-height: 1.1; max-width: 30ch; padding-right: 9rem; }
.row--run .track { grid-column: 2; grid-row: 2; }
.row--run .stage { grid-column: 2; grid-row: 2; justify-self: end; align-self: center; font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1; color: var(--color-muted); }
.row--run .facts { grid-column: 2; grid-row: 3; max-width: 88ch; margin-top: var(--space-sm); }
.row--run .run-status {
  position: absolute;
  top: var(--space-xl);
  right: 0;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding-top: 0.35em;
  font-size: var(--text-sm);
}
.row--run .run-status dt { font-size: var(--text-xs); }
.row--run .facts > .run-status { display: flex; }

/* The status track: question, run, result. Dots fill as the experiment moves. */
.track {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1;
  color: var(--color-muted);
}
.track li { display: flex; align-items: center; gap: var(--space-xs); }
.track li::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--color-muted);
  background: transparent;
}
.track li + li::before { margin-left: 0; }
.track li + li { padding-left: var(--space-lg); position: relative; }
.track li + li::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  width: var(--space-md);
  height: 1px;
  background: var(--color-rule);
}
.track[data-step="1"] li:nth-child(-n+1)::before,
.track[data-step="2"] li:nth-child(-n+2)::before,
.track[data-step="3"] li::before { background: var(--color-accent); border-color: var(--color-accent); }
.track[data-step="1"] li:nth-child(1),
.track[data-step="2"] li:nth-child(2),
.track[data-step="3"] li:nth-child(3) { color: var(--color-ink); }
.track[data-step="2"] li:nth-child(2)::after,
.track[data-step="3"] li + li::after { background: var(--color-accent); }

/* ---------- Logo strip (4.7 #4, 7) ---------- */
.logos { padding-block: var(--space-xl); border-top: 1px solid var(--color-rule); border-bottom: 1px solid var(--color-rule); }
.logos-title { font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.14em; color: var(--color-muted); margin-bottom: var(--space-md); }
.logos ul { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-lg) var(--space-xl); }
.logos img { width: auto; max-width: 150px; filter: brightness(0); opacity: 0.62; transition: opacity 0.2s; }
.logos img:hover { opacity: 1; }

/* ---------- Knowledge ---------- */
.knowledge { scroll-margin-top: var(--bar-h); }
.knowledge .lead { max-width: 64ch; }
.knowledge h2 { max-width: 20ch; }
.steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2xl) var(--gap-columns); margin-top: var(--space-2xl); }
.step { border-top: 1px solid var(--color-ink); padding-top: var(--space-lg); display: flex; flex-direction: column; gap: var(--space-md); }
.step:last-child { border-top-color: var(--color-accent); }
.step h3, .area h3 { font-size: var(--text-xl); }
.step > p:not(.label) { color: var(--color-ink-2); }
.knowledge > .container > h3.sub { margin-top: var(--space-2xl); margin-bottom: var(--space-md); }
.knowledge .closing { margin-top: var(--space-xl); color: var(--color-ink-2); }
.measures li { padding-left: 1.1em; position: relative; }
.measures li::before { content: "–"; position: absolute; left: 0; color: var(--color-accent); }

/* ---------- Research areas ---------- */
.research { padding-top: var(--section-gap); }
.areas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap-columns); margin-top: var(--space-2xl); }
.area { border-top: 1px solid var(--color-ink); padding-top: var(--space-lg); display: flex; flex-direction: column; gap: var(--space-md); }

/* ---------- Open models ---------- */
.sovereign { scroll-margin-top: var(--bar-h); }
.sovereign .lead { max-width: 64ch; }
.sovereign .facts { margin-top: var(--space-2xl); max-width: 80ch; }
.sovereign .closing { margin-top: var(--space-xl); color: var(--color-ink-2); }

/* ---------- Field notes: a notebook page ----------
   An observation from real work, no planned test. The pencil marks it;
   the margin rule and the ruled fact rows set it apart from the lab rows. */
.finding {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
  gap: var(--space-md) var(--gap-columns);
  margin-top: var(--space-xl);
  scroll-margin-top: calc(var(--bar-h) + var(--space-md));
}
.notes .lead + .finding { margin-top: var(--space-2xl); }
.finding .finding-id { grid-column: 1 / 4; display: flex; align-items: center; gap: var(--space-xs); padding-top: var(--space-2xs); }
.finding .note-mark { width: 18px; height: 18px; flex: none; color: var(--color-accent); }
.finding-page {
  grid-column: 4 / 13;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding-left: var(--space-lg);
  border-left: 2px solid color-mix(in srgb, var(--color-accent) 55%, var(--color-paper));
}
.finding h3 { font-size: var(--text-title); font-variation-settings: "opsz" 24, "SOFT" 10, "WONK" 0; }
.finding .facts { max-width: 72ch; gap: 0; }
.finding .facts > div { padding-block: var(--space-xs); border-bottom: 1px solid var(--color-rule); }
.finding .facts > div:last-child { border-bottom: 0; }

/* ---------- From research to products ---------- */
.flow { padding-top: var(--section-gap); }
.flow-cols { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap-columns); margin-top: var(--space-2xl); }
.flow-col { border-top: 1px solid var(--color-ink); padding-top: var(--space-lg); display: flex; flex-direction: column; gap: var(--space-md); }
.flow-col:nth-child(4) { border-top-color: var(--color-accent); }
.flow-col h3 { font-size: var(--text-2xl); font-variation-settings: "opsz" 48, "SOFT" 20, "WONK" 0; letter-spacing: var(--tracking-display); }
.flow-col > p:not(.label) { color: var(--color-ink-2); }

/* ---------- House rules ---------- */
.rules { padding-top: var(--section-gap-l); padding-bottom: var(--section-gap); }
.rules h2 { margin-bottom: var(--space-2xl); }
.rule-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2xl) var(--gap-columns); }
.rule-list li { border-top: 1px solid var(--color-ink); padding-top: var(--space-lg); display: flex; flex-direction: column; gap: var(--space-md); }
.rule-list h3 { font-size: var(--text-display-s); font-variation-settings: "opsz" 72, "SOFT" 20, "WONK" 0; letter-spacing: var(--tracking-display); line-height: 1; }
.rule-list p { color: var(--color-ink-2); max-width: 32ch; }

/* ---------- Footer (9) ---------- */
.foot { border-top: 1px solid var(--color-rule); padding-top: var(--space-3xl); padding-bottom: var(--space-xl); }
.mast {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144, "SOFT" 30, "WONK" 1;
  font-weight: 600;
  font-size: clamp(2rem, 10.5vw, 10rem);
  line-height: 0.9;
  letter-spacing: -0.035em;
  color: var(--color-ink);
  margin-bottom: var(--space-xl);
  white-space: nowrap;
  font-synthesis: none;
}
.mast span { color: var(--color-accent); }
.family { border-top: 1px solid var(--color-rule); padding-top: var(--space-lg); }
.family-title { font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.14em; color: var(--color-muted); margin-bottom: var(--space-lg); }
.family ul { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-lg) var(--gap-columns); }
.family li > a, .family li > span { position: relative; display: block; padding-top: var(--space-md); text-decoration: none; color: inherit; }
.family li > a::before, .family li > span::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 16px;
  height: 2px;
  border-radius: 1px;
  background: var(--color-accent);
  opacity: 0.4;
  transition: width var(--dur-short) var(--ease-out), opacity var(--dur-short) var(--ease-out);
}
.family-name { display: block; font-family: var(--font-display); font-variation-settings: "opsz" 24, "SOFT" 10, "WONK" 0; font-weight: 520; font-size: var(--text-md); line-height: 1.3; color: var(--color-ink); font-synthesis: none; }
.family-line { display: block; margin-top: var(--space-2xs); font-family: var(--font-ui); font-size: var(--text-xs); line-height: 1.45; color: var(--color-muted); }
.family li > a:hover::before, .family li > a:focus-visible::before { opacity: 1; width: 28px; }
.family li > a:hover .family-name, .family li > a:focus-visible .family-name { color: var(--color-accent-deep); text-decoration: underline; text-decoration-color: var(--color-accent); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.family .is-current > span::before { opacity: 1; width: 28px; }
.family-here {
  position: absolute;
  top: -0.45em;
  left: 40px;
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-accent-deep);
}
.foot-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-md); margin-top: var(--space-2xl); font-family: var(--font-ui); font-size: var(--text-sm); color: var(--color-muted); }
.foot-row ul { display: flex; flex-wrap: wrap; gap: var(--space-lg); }
.foot-row a { color: var(--color-ink-2); text-decoration: none; }
.foot-row a:hover { color: var(--color-ink); text-decoration: underline; text-decoration-color: var(--color-accent); }
.foot-row a:active { color: var(--color-accent-deep); }

/* ---------- Breakpoints ---------- */
@media (max-width: 75rem) {
  .family ul { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 60rem) {
  .links li:not(:last-child) { display: none; } /* scar 9 */

  /* The 12-col heads collapse to one column; only the row gap stays. */
  .grid-12 { grid-template-columns: minmax(0, 1fr); }
  .hero-head { row-gap: var(--space-xl); }
  .hero h1, .hero-side { grid-column: 1 / -1; }

  .row { grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-xs) var(--space-md); }
  .row h3 { grid-column: 1; }
  .row > .status { grid-column: 2; grid-row: 1; align-self: center; }
  .row .addr, .row > p { grid-column: 1 / -1; }

  /* The running row keeps its own two columns: the mark and the text. */
  .row--run { grid-template-columns: 28px minmax(0, 1fr); gap: var(--space-sm) var(--space-md); }
  .row--run h3 { grid-column: 2; grid-row: 1; }


  .pia-text { grid-column: 1 / -1; }
  .pia-phone { display: none; }
  .offer { padding: var(--space-2xl) var(--space-lg); }
  .offer-text, .offer-tools { grid-column: 1 / -1; }

  .steps, .areas, .rule-list { grid-template-columns: minmax(0, 1fr); }
  .flow-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .finding { grid-template-columns: minmax(0, 1fr); }
  .finding .finding-id, .finding-page { grid-column: 1 / -1; }
}

@media (max-width: 40rem) {
  .links { display: none; } /* scar 9 */

  .offer { padding: var(--space-xl) var(--space-md); }
  .offer-tools pre { padding: var(--space-lg); font-size: var(--text-xs); }

  .flow-cols { grid-template-columns: minmax(0, 1fr); }

  .facts > div { grid-template-columns: minmax(0, 1fr); }
  .facts dd { margin-bottom: var(--space-sm); }
  .finding .facts dd { margin-bottom: 0; }

  /* The status leaves the corner and closes the facts list. */
  .row--run h3 { padding-right: 0; }
  .row--run .run-status { position: static; padding-top: 0; margin-top: var(--space-2xs); }
  .row--run .facts > .run-status dd { margin-bottom: 0; }
  .row--run .stage { grid-row: 4; justify-self: start; }

  .finding-page { padding-left: var(--space-md); }

  .family ul { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-lg) var(--space-md); }
}
