/* ---------------------------------------------------------------------------
   Found To Fixed — foundtofixed.com

   ⚠ The brand tokens are NOT defined here any more. They live in
   brand/tokens.json and are generated into theme/static/css/tokens.css by
   `make brand`. That file is linked before this one, so every var() below
   resolves against it.

   The reason they moved: the website is not the only thing that consumes the
   brand. A slide deck, a Word document and an Inkscape file need the same
   values, and a palette that lives in a stylesheet can only be copied into
   those by hand — which is how a deck ends up a shade off the site. One source
   of truth, several generated consumers, and `make check` fails if they drift.

   Contrast is measured, not estimated, and it is recomputed at build time
   rather than transcribed into a comment: see brand/dist/CONTRAST.md and the
   `contrast.pairs` list in brand/tokens.json. Changing a colour that breaks a
   pair fails the build.
   --------------------------------------------------------------------------- */


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

html {
  -webkit-text-size-adjust: 100%;
  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 {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  color: var(--brand-light);
}

/* No border-radius here. It is not the outline's radius — it is the element's,
   and setting it would flatten .btn's corners the moment a button takes focus.
   Browsers already curve the outline to follow whatever radius the element
   has, so leaving it alone is both correct and what looks right. */
:focus-visible {
  outline: 2px solid var(--brand-light);
  outline-offset: 3px;
}

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

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

/* --- Skip link ----------------------------------------------------------- */

/* Off-screen rather than display:none — a hidden element is not focusable, so
   display:none would remove the only thing this exists to provide. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--brand-dark);
  color: var(--surface);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
  color: var(--surface);
}

/* --- Shell --------------------------------------------------------------- */

.wrap {
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.wrap.narrow {
  max-width: 46rem;
}

.section {
  padding-block: clamp(3rem, 8vw, 5.5rem);
}

/* Sections change GROUND rather than being separated by a rule. A 1px line
   between two identical grounds is a seam, not a rhythm. */
.section-alt {
  background: var(--surface-alt);
}

.section-deep {
  background: var(--deep);
  color: var(--surface);
}

.section-deep a {
  color: var(--mist);
}

.section-deep a:hover {
  color: var(--surface);
}

.section-title {
  font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem);
  margin-top: 0;
  margin-bottom: 1.5rem;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(150%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding-block: 0.75rem;
}

/* The lockup is composed from an SVG mark plus live text rather than shipped
   as a single SVG. The gap below is the whole lockup spec: the mark's clear
   space is half its own width, so this must not go below 0.5em of the mark
   size. Nothing else sets inside it. */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--ink);
}

/* Clamped at the bottom by the mark's own legibility floor: below about 22px
   the two chevrons stop reading as two and the gap between them closes. */
.brand-mark {
  width: clamp(26px, 4vw, 32px);
  height: auto;
  flex: none;
}

.brand-word {
  font-weight: 700;
  font-size: clamp(1.05rem, 0.95rem + 0.4vw, 1.25rem);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

/* The "To" is the hinge of the name, so it is set apart rather than emphasised
   — lighter and non-italic, against two bold words. */
.brand-word em {
  font-style: normal;
  font-weight: 400;
  color: var(--ink-quiet);
}

.site-footer .brand {
  color: var(--surface);
}

.site-footer .brand-word em {
  color: var(--mist);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.5rem);
  flex-wrap: wrap;
  font-size: 0.9375rem;
}

.site-nav a {
  color: var(--ink-muted);
  text-decoration: none;
  font-weight: 500;
}

.site-nav a:hover {
  color: var(--brand);
  text-decoration: underline;
}

.nav-cta {
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-pill);
  background: var(--brand);
  color: var(--surface) !important;
  font-weight: 600;
}

.nav-cta:hover {
  background: var(--brand-dark);
  text-decoration: none !important;
}

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: var(--brand);
  color: var(--surface);
  font-weight: 600;
  text-decoration: none;
  line-height: 1.3;
}

.btn:hover {
  background: var(--brand-dark);
  color: var(--surface);
}

/* The only ghost variant left is the dark-ground one. Its border is the only
   thing identifying it as a control, so it uses --mist (9.73:1 on --deep)
   rather than --brand-light, which is 3.44:1 there. */
.btn-invert {
  background: var(--surface);
  color: var(--brand-dark);
}

.btn-invert:hover {
  background: var(--mist);
  color: var(--brand-dark);
}

.btn-ghost-invert {
  background: transparent;
  border-color: var(--mist);
  color: var(--surface) !important;
}

.btn-ghost-invert:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--surface) !important;
}

/* --- Hero ---------------------------------------------------------------- */

.hero {
  background: linear-gradient(135deg, var(--deep) 0%, var(--deep-grad) 100%);
  color: var(--surface);
  padding-block: clamp(3.5rem, 10vw, 7rem);
}

.hero .wrap {
  max-width: 54rem;
}

.eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mist);
}

.hero h1 {
  margin: 0 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.slogan {
  font-size: clamp(2.25rem, 1.6rem + 3.2vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

/* The "to" is the hinge of the name here too — set in mist so the two states
   either side of it carry the weight. */
.slogan em {
  font-style: normal;
  font-weight: 300;
  color: var(--mist);
}

.sub {
  max-width: 40rem;
  margin: 0 0 2rem;
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  color: var(--mist);
}

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

/* --- Hero stat row ------------------------------------------------------- */

/* A <dl>, because each number genuinely is a term with a definition. The
   grid sits on the <dl> and each pair is wrapped in a div, since dt/dd cannot
   be grid items in their own right without losing the association. */
.stats {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
  margin: 2.5rem 0 0;
  padding: 1.5rem 0 0;
  border-top: 1px solid rgba(185, 192, 228, 0.3);
}

.stats dt {
  font-size: clamp(2rem, 1.5rem + 2vw, 2.75rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--surface);
}

.stats dd {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--mist);
}

/* The provenance line. Set quieter than the sub, because it is the evidence
   for the claim above rather than part of the pitch — but it is the reason to
   believe any of it, so it sits above the fold rather than in an About page. */
.hero-provenance {
  margin: 2rem 0 0;
  max-width: 42rem;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--mist);
}

.hero-provenance a {
  color: var(--surface);
}

/* --- Cards --------------------------------------------------------------- */

.card-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
}

.card {
  padding: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.card h3 {
  margin: 0 0 0.6rem;
  font-size: 1.1875rem;
}

.card h3 a {
  text-decoration: none;
}

.card h3 a:hover {
  text-decoration: underline;
}

.card p {
  margin: 0;
  color: var(--ink-muted);
}

/* --- Numbered steps ------------------------------------------------------ */

.steps {
  display: grid;
  gap: 1.75rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
}

.steps li {
  counter-increment: step;
  padding-top: 0.75rem;
  border-top: 3px solid var(--accent);
}

/* The number is decoration on top of a heading that already reads in order, so
   it is generated content rather than markup — a screen reader gets "Find it
   properly", not "01 Find it properly". */
.steps li::before {
  content: counter(step, decimal-leading-zero);
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.steps h3 {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
}

.steps p {
  margin: 0;
  color: var(--ink-muted);
}

/* A labelled timeline rather than a counted list: the headings already say
   "Week 1", so the generated counter would read it out twice. Same rhythm as
   .steps, without the number. */
.steps-labelled {
  counter-reset: none;
}

.steps-labelled li {
  counter-increment: none;
}

.steps-labelled li::before {
  content: none;
}

.steps-labelled h3 {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

/* --- Trigger list -------------------------------------------------------- */

/* Four short statements, each its own line. A plain <ul> would set them as
   dense body copy; these are meant to be scanned and matched against the
   reader's own situation, so they get room and a rule between them. */
.trigger-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 48rem;
}

.trigger-list li {
  padding: 1rem 0 1rem 2rem;
  border-top: 1px solid var(--border-strong);
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.125rem);
  color: var(--ink);
  position: relative;
}

.trigger-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.55em;
  width: 1rem;
  height: 2px;
  background: var(--accent);
}

/* --- Prose --------------------------------------------------------------- */

/* Prose keeps the readable measure while the shell stays wide. Scoped to the
   wrap inside .prose so a full-width element can still opt out by sitting
   outside it. */
.prose .wrap {
  max-width: calc(var(--measure) + 2 * var(--gutter));
}

.prose h1 {
  font-size: clamp(1.85rem, 1.4rem + 2vw, 2.6rem);
  margin-top: 0;
  margin-bottom: 1rem;
}

.prose h2 {
  font-size: 1.4rem;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.prose h3 {
  font-size: 1.15rem;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}

.prose p,
.prose li {
  color: var(--ink-muted);
}

.prose li + li {
  margin-top: 0.4rem;
}

/* A page's opening line, one step up from body copy. Set from `standfirst:` in
   frontmatter rather than from the summary, because the summary is written for
   search results and rarely reads well as an opening sentence. */
.standfirst {
  font-size: 1.1875rem;
  line-height: 1.5;
  color: var(--ink) !important;
  margin-bottom: 2rem;
}

.prose blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--border-strong);
  color: var(--ink-quiet);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9375rem;
}

.prose th,
.prose td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.prose th {
  font-weight: 600;
  color: var(--ink);
}

/* A table can carry more columns than the measure allows; let it scroll on its
   own rather than pushing the whole page sideways. */
.prose > .wrap > table {
  display: block;
  overflow-x: auto;
}

code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.prose :not(pre) > code {
  padding: 0.12em 0.35em;
  background: var(--brand-tint);
  border-radius: 4px;
  color: var(--ink);
}

.prose pre,
.highlight pre {
  overflow-x: auto;
  padding: 1rem;
  background: var(--deep);
  color: #e7e9f6;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.5;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border-strong);
  margin: 2.5rem 0;
}

/* --- Heading permalinks -------------------------------------------------- */

/* Appended to every prose heading by the Markdown toc extension, so a passage
   can be linked to and cited directly. Quiet until you go looking for it —
   but NOT hidden: opacity alone would leave it focusable and invisible, which
   is worse than not having it. It returns to full opacity on keyboard focus. */
.heading-anchor {
  margin-left: 0.4em;
  opacity: 0;
  color: var(--ink-quiet);
  text-decoration: none;
  font-weight: 400;
  transition: opacity 0.12s ease-in-out;
}

h1:hover > .heading-anchor,
h2:hover > .heading-anchor,
h3:hover > .heading-anchor,
h4:hover > .heading-anchor,
.heading-anchor:focus-visible {
  opacity: 1;
}

.heading-anchor:hover {
  color: var(--brand);
}

/* Touch devices have no hover, so the affordance would never appear at all.
   Show it permanently there, at low emphasis. */
@media (hover: none) {
  .heading-anchor {
    opacity: 0.45;
  }
}

/* --- Post lists ---------------------------------------------------------- */

.post-list {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
}

.post-list li {
  padding-block: 1.1rem;
  border-top: 1px solid var(--border);
}

.post-list li:first-child {
  border-top: 0;
}

.post-list li > a {
  display: block;
  font-size: 1.1875rem;
  font-weight: 600;
  text-decoration: none;
}

.post-list li > a:hover {
  text-decoration: underline;
}

.post-list time {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.8125rem;
  color: var(--ink-quiet);
}

.post-list p {
  margin: 0.5rem 0 0;
  color: var(--ink-muted);
}

.post-meta {
  margin-top: -0.5rem;
  margin-bottom: 2rem;
  font-size: 0.875rem;
  color: var(--ink-quiet) !important;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 2rem 0;
}

.tag-list a,
.tag-list span {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-pill);
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

.tag-list a:hover {
  background: var(--brand);
  color: var(--surface);
}

/* A draft's tags render as spans, not links — its tag pages are not generated,
   so linking them would be a dead link on every draft. Made visually distinct
   so the difference is not silent. */
.tag-list span {
  background: var(--surface-alt);
  color: var(--ink-quiet);
  border: 1px dashed var(--border-strong);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 2rem 0;
  font-size: 0.9375rem;
  color: var(--ink-quiet);
}

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

.site-footer {
  background: var(--deep);
  color: var(--mist);
  padding-block: clamp(2.5rem, 6vw, 4rem);
  font-size: 0.9375rem;
}

.footer-cols {
  display: grid;
  gap: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
}

/* The brand column carries a sentence, so it earns more room than a link
   column once there is space for the difference to matter. */
.footer-brand {
  grid-column: span 1;
}

@media (min-width: 60rem) {
  .footer-cols {
    grid-template-columns: 2fr 1fr 1fr 1fr;
  }
}

.footer-brand p {
  margin: 0.9rem 0 0;
  max-width: 28rem;
}

.col-label {
  margin: 0 0 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--surface);
}

.site-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-footer li + li {
  margin-top: 0.4rem;
}

.site-footer a {
  color: var(--mist);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--surface);
  text-decoration: underline;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.social-icon {
  width: 1em;
  height: 1em;
  flex: none;
}

.fine {
  margin: 2.5rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(185, 192, 228, 0.25);
  font-size: 0.8125rem;
  color: var(--mist);
}

/* --- Brand guidelines page ----------------------------------------------- */

/* Only used by brand.html. Kept here rather than in a second stylesheet: one
   page's worth of rules does not justify another request, and tokens.css is
   generated so nothing hand-written belongs in it. */

.brand-lede {
  max-width: 46rem;
  color: var(--ink-muted);
  margin-top: 0;
}

.swatches {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
}

.swatch {
  display: flex;
  gap: 1rem;
  padding: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

/* The chip carries its own border because two of the swatches are white or
   near-white, and a white square on a white card is not a swatch. */
.swatch-chip {
  flex: none;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
}

.swatch-body {
  min-width: 0;
}

.swatch-body h3 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
}

.swatch-body p {
  margin: 0 0 0.4rem;
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.swatch-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.swatch-vars code {
  padding: 0.1em 0.4em;
  background: var(--brand-tint);
  border-radius: 4px;
  color: var(--ink);
  font-size: 0.8125rem;
}

.swatch-caution {
  color: var(--accent) !important;
}

.swatch-media {
  font-size: 0.75rem !important;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-quiet) !important;
  margin-bottom: 0 !important;
}

/* A table of 27 contrast pairs is wider than the measure on a phone. Let it
   scroll on its own rather than pushing the page sideways. */
.table-scroll {
  overflow-x: auto;
}

.brand-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.brand-table th,
.brand-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.brand-table th {
  font-weight: 600;
  white-space: nowrap;
}

.brand-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.brand-table code {
  font-size: 0.8125rem;
}

.mark-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1.5rem 0;
}

.mark-demo {
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.mark-demo-dark {
  background: var(--deep);
  border-color: var(--deep);
}

/* --- Print --------------------------------------------------------------- */

/* The header is sticky and the footer is a dark flood; both waste a page in
   print. A printed page also loses every href, so expose them. */
@media print {
  .site-header,
  .site-footer,
  .skip-link,
  .hero-actions,
  .pagination {
    display: none;
  }

  body {
    color: #000;
    background: #fff;
  }

  .prose a::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    word-break: break-all;
  }
}
