/* ==========================================================================
   Cipher — single-page write-up
   The structural layer (sigils, headings, figures) is set in mono; the prose
   is set in a serif. The page is about plain-text files, so the marks that
   organise it are shown rather than hidden.
   ========================================================================== */

:root {
  /* Colour. The accent marks the machine-readable layer only: heading sigils,
     links, and the four kinds of content the fidelity gate protects. */
  --ink:        #0e0f11;
  --paper:      #e6e2da;
  --paper-dim:  #99958c;
  --wheat:      #c2a878;
  --rule:       #24282c;

  --font-prose: "Spectral", Iowan Old Style, Palatino, Georgia, serif;
  --font-struct: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --measure: 68ch;
  --gutter: 3.5rem;
}

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

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

body {
  margin: 0;
  padding: 7rem 1.5rem 9rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-prose);
  font-size: 1.1875rem;
  font-weight: 300;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.doc {
  max-width: calc(var(--measure) + var(--gutter));
  margin: 0 auto;
  padding-left: var(--gutter);
}

/* --- the signature: markdown sigils hanging in the gutter ---------------- */

h1, h2, h3 { position: relative; }

.sigil {
  position: absolute;
  right: calc(100% + 0.9rem);
  font-family: var(--font-struct);
  font-weight: 400;
  color: var(--wheat);
  opacity: 0.72;
  -webkit-user-select: none;
  user-select: none;
  /* Required, not cosmetic. Positioned with `right` past its containing block,
     the sigil's shrink-to-fit width collapses to the widest unbreakable unit,
     so `---` would break at its hyphens and stack one glyph per line. */
  white-space: nowrap;
}

/* --- headings ------------------------------------------------------------ */

h1 {
  margin: 0 0 1.75rem;
  font-family: var(--font-struct);
  font-size: 2.4rem;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

h1 .sigil { font-size: 2.4rem; line-height: 1.1; }

h2 {
  margin: 0 0 1.5rem;
  font-family: var(--font-struct);
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0.005em;
}

h3 {
  margin: 3rem 0 1.25rem;
  font-family: var(--font-prose);
  font-size: 1.1875rem;
  font-weight: 600;
  font-style: italic;
  line-height: 1.5;
  color: var(--paper);
}

h3 .sigil {
  font-size: 0.9375rem;
  font-style: normal;
  font-weight: 400;
  top: 0.2em;
}

/* --- flow --------------------------------------------------------------- */

p {
  margin: 0 0 1.5rem;
  max-width: var(--measure);
  text-wrap: pretty;
}

section {
  margin-top: 5.5rem;
}

/* --- opening ------------------------------------------------------------ */

.head { margin-top: 0; }

.lede {
  font-size: 1.375rem;
  line-height: 1.6;
  color: var(--paper);
  margin-bottom: 1.75rem;
}

/* The one line the page most needs to be unmissable. A left rule and an
   italic, not a box. Kept in the neutral rule colour so the accent stays
   reserved for the plain-text layer. */
.aside {
  margin: 0;
  padding-left: 1.25rem;
  border-left: 1px solid var(--rule);
  font-style: italic;
  color: var(--paper-dim);
}

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

ul.plain {
  margin: 0 0 1.5rem;
  padding: 0;
  max-width: var(--measure);
  list-style: none;
}

ul.plain li {
  position: relative;
  padding-left: 1.4rem;
  margin-bottom: 0.4rem;
}

ul.plain li::before {
  content: "-";
  position: absolute;
  left: 0;
  font-family: var(--font-struct);
  color: var(--wheat);
  opacity: 0.72;
}

/* --- inline mark: the content the fidelity gate refuses to drop --------- */

.mark {
  font-family: var(--font-struct);
  font-size: 0.875em;
  color: var(--wheat);
  white-space: nowrap;
}

/* --- figures: numbers presented plainly, not as tiles ------------------- */

.figures {
  margin: 0 0 2.25rem;
  max-width: var(--measure);
}

.figure {
  display: grid;
  grid-template-columns: 3.75rem 1fr;
  column-gap: 1.25rem;
  align-items: baseline;
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
}

.figure:last-child { border-bottom: 1px solid var(--rule); }

.figures dt {
  font-family: var(--font-struct);
  font-size: 1.375rem;
  font-weight: 400;
  line-height: 1.3;
  color: var(--wheat);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.figures dd {
  margin: 0;
  line-height: 1.65;
}

/* --- closing ------------------------------------------------------------ */

footer {
  margin-top: 5.5rem;
  padding-top: 3rem;
  border-top: 1px solid var(--rule);
}

h2.quiet {
  color: var(--paper-dim);
  font-weight: 400;
}

/* --- links -------------------------------------------------------------- */

a {
  color: var(--wheat);
  text-decoration: none;
  border-bottom: 1px solid rgba(194, 168, 120, 0.35);
  transition: border-color 120ms ease, color 120ms ease;
}

a:hover {
  color: #d8c299;
  border-bottom-color: #d8c299;
}

a:focus-visible {
  outline: 2px solid var(--wheat);
  outline-offset: 3px;
  border-bottom-color: transparent;
}

::selection {
  background: rgba(194, 168, 120, 0.24);
  color: var(--paper);
}

/* --- narrow screens ----------------------------------------------------- */
/* The gutter collapses and the sigils fall inline, which is still an honest
   rendering of the source: `## What it does`. */

@media (max-width: 34rem) {
  :root { --gutter: 0rem; }

  body {
    padding: 3.5rem 1.25rem 5rem;
    font-size: 1.0625rem;
    line-height: 1.7;
  }

  .doc { padding-left: 0; }

  .sigil {
    position: static;
    right: auto;
    top: auto;
    margin-right: 0.45em;
  }

  h1 { font-size: 1.875rem; }
  h1 .sigil { font-size: 1.875rem; }

  .lede { font-size: 1.1875rem; }

  h2 { font-size: 1rem; }
  h3 { margin-top: 2.5rem; }

  section { margin-top: 3.75rem; }
  footer { margin-top: 3.75rem; padding-top: 2.25rem; }

  .figure {
    grid-template-columns: 2.75rem 1fr;
    column-gap: 1rem;
  }

  .figures dt { font-size: 1.1875rem; }
}

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