/* OpenPlan Labs — apex site.
 *
 * Every colour here comes from tokens.css (openplan-labs/branding). No hex
 * literals below this line; if one appears, the branding repo wins and this
 * file is wrong.
 *
 * Accent budget, per brand/palette.md: --color-path is spent on inline links,
 * the mark, the solution stroke in the figure, and one primary action. It is
 * exactly 4.50:1 on light paper, so it is never lightened for a hover state —
 * hover changes underline weight and background, not the colour.
 */

/* ---- reset ------------------------------------------------------------ */

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

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

body,
h1, h2, h3, h4, p, ul, ol, figure, blockquote, dl, dd {
  margin: 0;
  padding: 0;
}

ul, ol { list-style: none; }

img, svg { max-width: 100%; }

html, body { overflow-x: clip; }

/* ---- page -------------------------------------------------------------- */

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-size: var(--text-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  width: 100%;
  max-width: 66rem;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2.5rem);
}

.prose { max-width: var(--measure); }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-heading);
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }

p { text-wrap: pretty; }
p + p { margin-top: 0.9em; }

a {
  color: var(--color-path);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

a:hover {
  text-decoration-thickness: 2px;
  background: var(--color-path-soft);
}

code, kbd, samp, pre { font-family: var(--font-mono); }

code {
  font-size: 0.88em;
  color: var(--color-heading);
}

strong { color: var(--color-heading); font-weight: 700; }

hr {
  border: 0;
  border-top: 1px solid var(--color-line);
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--color-path);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: 0.5rem;
  top: -3.5rem;
  z-index: 20;
  padding: 0.55rem 0.9rem;
  background: var(--color-bg-raised);
  border: 1px solid var(--color-line);
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: top 120ms ease;
}

.skip:focus { top: 0.5rem; }

/* ---- header ------------------------------------------------------------ */

.masthead {
  border-bottom: 1px solid var(--color-line);
  background: var(--color-bg);
}

.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  min-height: 3.75rem;
  padding-block: 0.5rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--color-heading);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.wordmark:hover { background: none; }
.wordmark:hover .wordmark-text { text-decoration: underline; text-underline-offset: 0.2em; }

.mark { flex: none; width: 26px; height: 26px; }
.mark .mark-lattice { fill: var(--color-expanded); opacity: 0.4; }
.mark .mark-stroke { fill: none; stroke: var(--color-path); }
.mark .mark-goal { fill: var(--color-path); }

.masthead-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem clamp(0.75rem, 2.5vw, 1.5rem);
}

.masthead-nav a {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  color: var(--color-muted);
  text-decoration: none;
}

.masthead-nav a:hover {
  color: var(--color-heading);
  background: none;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

@media (max-width: 34rem) {
  .masthead-nav .nav-optional { display: none; }
}

/* ---- theme toggle ------------------------------------------------------ */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  font: inherit;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--color-muted);
  background: var(--color-bg-raised);
  border: 1px solid var(--color-line);
  border-radius: 999px;
  cursor: pointer;
}

.theme-toggle:hover { color: var(--color-heading); border-color: var(--color-muted); }
.theme-toggle svg { width: 14px; height: 14px; flex: none; }

/* Only the icon for the active setting is shown. */
.theme-toggle [data-icon] { display: none; }
:root .theme-toggle [data-icon="system"],
:root[data-theme-choice="system"] .theme-toggle [data-icon="system"] { display: inline; }
:root[data-theme-choice="light"] .theme-toggle [data-icon="system"],
:root[data-theme-choice="dark"] .theme-toggle [data-icon="system"] { display: none; }
:root[data-theme-choice="light"] .theme-toggle [data-icon="light"] { display: inline; }
:root[data-theme-choice="dark"] .theme-toggle [data-icon="dark"] { display: inline; }

.theme-label::after { content: "System"; }
:root[data-theme-choice="light"] .theme-label::after { content: "Light"; }
:root[data-theme-choice="dark"] .theme-label::after { content: "Dark"; }

@media (max-width: 34rem) {
  .theme-label { display: none; }
  .theme-toggle { padding: 0.35rem; }
}

/* ---- sections ---------------------------------------------------------- */

section { padding-block: clamp(2.75rem, 7vw, 4.5rem); }
section + section { border-top: 1px solid var(--color-line); }

.section-label {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--color-muted);
  margin-bottom: 0.6rem;
}

.section-lead {
  margin-top: 0.9rem;
  color: var(--color-body);
}

/* ---- hero -------------------------------------------------------------- */

.hero { padding-block: clamp(2.5rem, 8vw, 5rem); }

.hero-grid {
  display: grid;
  gap: clamp(2rem, 5vw, 3.5rem);
  align-items: start;
}

@media (min-width: 62rem) {
  .hero-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
}

.hero h1 {
  font-size: clamp(1.9rem, 5.2vw, var(--text-3xl));
  margin-bottom: 1rem;
}

.hero-statement {
  font-family: var(--font-prose);
  font-size: var(--text-lg);
  color: var(--color-body);
  max-width: 34ch;
}

.hero-sub {
  margin-top: 1rem;
  color: var(--color-muted);
  max-width: var(--measure);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

/* The single primary action on the page — the rest of the accent budget is
   spent on inline links. */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  border-radius: 4px;
  text-decoration: none;
  border: 1px solid var(--color-line);
  color: var(--color-heading);
  background: var(--color-bg-raised);
}

.btn:hover { border-color: var(--color-muted); background: var(--color-bg-raised); }

.btn-primary {
  border-color: var(--color-path);
  color: var(--color-path);
  background: var(--color-bg-raised);
}

.btn-primary:hover { background: var(--color-path-soft); border-color: var(--color-path); }

/* ---- figure ------------------------------------------------------------ */

.figure {
  background: var(--color-bg-raised);
  border: 1px solid var(--color-line);
  border-radius: 6px;
  padding: clamp(0.9rem, 2.5vw, 1.4rem);
}

.figure-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.figure-svg {
  display: block;
  width: 100%;
  min-width: 20rem;
  height: auto;
}

/* Markers per brand/figures.md. Shape carries the meaning; colour reinforces
   it, so the three sets stay separable in greyscale. */
.fig-obstacle { fill: var(--color-line); }
.fig-unvisited { fill: var(--color-faint); }
.fig-expanded { fill: var(--color-expanded); }
.fig-frontier { fill: none; stroke: var(--color-frontier); stroke-width: 1.6; }
.fig-path {
  fill: none;
  stroke: var(--color-path);
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.fig-start { fill: none; stroke: var(--color-path); stroke-width: 1.8; }
.fig-goal { fill: var(--color-path); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--color-line);
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--color-muted);
}

.legend svg { width: 14px; height: 14px; flex: none; }

.caption {
  margin-top: 0.85rem;
  font-size: var(--text-sm);
  color: var(--color-muted);
}

/* ---- project cards ----------------------------------------------------- */

.group { margin-top: 2.5rem; }
.group:first-of-type { margin-top: 2rem; }

.group-head {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--color-line);
}

.group-head h3 { font-size: var(--text-lg); }

.group-note {
  font-size: var(--text-sm);
  color: var(--color-muted);
}

/* auto-fill, not auto-fit: a group with one project keeps a card-sized card
   rather than stretching one to the full width and setting its prose at 120
   characters. */
.cards {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.15rem 1.25rem 1.1rem;
  background: var(--color-bg-raised);
  border: 1px solid var(--color-line);
  border-radius: 6px;
}

.card h4 {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--color-heading);
  line-height: 1.3;
}

.card h4 a { color: var(--color-heading); text-decoration: none; }
.card h4 a:hover { background: none; text-decoration: underline; text-underline-offset: 0.2em; }

.card p {
  font-size: var(--text-sm);
  color: var(--color-body);
  flex: 1;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

.meta li { display: inline-flex; align-items: center; gap: 0.3rem; }
.meta svg { width: 12px; height: 12px; flex: none; }

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  font-family: var(--font-display);
  font-size: var(--text-sm);
}

/* ---- through-line list ------------------------------------------------- */

.threads {
  display: grid;
  gap: 1.5rem;
  margin-top: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
}

.thread h3 {
  font-size: var(--text-base);
  margin-bottom: 0.4rem;
  padding-top: 0.7rem;
  border-top: 2px solid var(--color-line);
}

.thread p { font-size: var(--text-sm); color: var(--color-body); }

/* ---- involved ---------------------------------------------------------- */

.steps {
  margin-top: 1.75rem;
  display: grid;
  gap: 1.25rem;
}

.steps li {
  padding-left: 1.4rem;
  position: relative;
  max-width: var(--measure);
}

.steps li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid var(--color-frontier);
}

.steps h3 { font-size: var(--text-base); margin-bottom: 0.15rem; }
.steps p { font-size: var(--text-sm); }

/* ---- footer ------------------------------------------------------------ */

.foot {
  border-top: 1px solid var(--color-line);
  padding-block: 2.25rem 3rem;
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.foot-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  justify-content: space-between;
  align-items: flex-start;
}

.foot p { max-width: var(--measure); }
.foot-links { display: flex; flex-wrap: wrap; gap: 0.3rem 1.25rem; font-family: var(--font-display); }

/* ---- 404 --------------------------------------------------------------- */

.notfound {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 62vh;
  padding-block: clamp(3rem, 10vw, 6rem);
}

.notfound .code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-muted);
  letter-spacing: var(--tracking-label);
  margin-bottom: 0.75rem;
}

.notfound h1 { font-size: clamp(1.7rem, 5vw, var(--text-2xl)); margin-bottom: 1rem; }
