/* Backlog Writing System, field guide.
   The page borrows the ledger: ruled paper, one red margin rule, entries in order. */

:root {
  --paper: #F4F7F1;
  --paper-2: #FCFDFB;
  --ink: #1B2621;
  --ink-2: #4A5852;
  --rule: #C9D3CA;
  --line: rgba(27, 38, 33, 0.10);
  --red: #B4372F;
  --red-soft: rgba(180, 55, 47, 0.12);
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  --page: 1120px;
  --gutter: 16px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121917;
    --paper-2: #182320;
    --ink: #E7ECE7;
    --ink-2: #A9B6AE;
    --rule: #2E3B35;
    --line: rgba(231, 236, 231, 0.12);
    --red: #E58A80;
    --red-soft: rgba(229, 138, 128, 0.16);
  }
}

:root[data-theme="dark"] {
  --paper: #121917;
  --paper-2: #182320;
  --ink: #E7ECE7;
  --ink-2: #A9B6AE;
  --rule: #2E3B35;
  --line: rgba(231, 236, 231, 0.12);
  --red: #E58A80;
  --red-soft: rgba(229, 138, 128, 0.16);
}

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

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--sans);
  overflow-x: hidden;
}

h1,
h2,
h3,
p,
dl,
dd,
figure {
  margin: 0;
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

code {
  font-family: inherit;
  font-size: 0.95em;
  background: var(--red-soft);
  padding: 0.05em 0.35em;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
}

.skip:focus {
  left: var(--gutter);
  top: var(--gutter);
  z-index: 10;
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 0.75rem;
}

/* Hero: ruled paper */

.hero {
  padding: clamp(3rem, 8vw, 6rem) var(--gutter) clamp(2.5rem, 6vw, 4rem);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(1.7rem - 1px),
    var(--line) calc(1.7rem - 1px),
    var(--line) 1.7rem
  );
}

.hero-inner {
  max-width: var(--page);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.85fr);
  gap: 3rem;
  align-items: start;
}

.site-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.thesis {
  font: italic 500 clamp(2.5rem, 6.5vw, 4.5rem) / 1.05 var(--serif);
  letter-spacing: -0.01em;
  margin-bottom: 1.25rem;
  max-width: 14ch;
}

.lede {
  font-size: 1.15rem;
  line-height: 1.55;
  max-width: 54ch;
  margin-bottom: 1.75rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.button {
  display: inline-block;
  padding: 0.7rem 1.1rem;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  color: var(--ink);
  background: var(--paper);
  text-decoration: none;
  font-weight: 500;
  line-height: 1.2;
}

.button.primary {
  background: var(--ink);
  color: var(--paper);
}

.button:hover {
  text-decoration: underline;
  text-decoration-color: currentColor;
}

.note {
  color: var(--ink-2);
  font-size: 0.95rem;
}

.specimen {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--red);
  padding: 1.25rem 1.25rem 1rem;
}

.specimen figcaption {
  font: italic 500 1.2rem/1.3 var(--serif);
  margin-bottom: 0.5rem;
}

.specimen dt {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-2);
  margin-top: 0.75rem;
}

.specimen dd {
  margin-top: 0.15rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.98rem;
  line-height: 1.5;
}

.specimen-note {
  margin-top: 0.75rem;
  color: var(--ink-2);
  font-size: 0.85rem;
}

/* Ledger: one red margin rule down the page */

.ledger {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.block {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  column-gap: 2rem;
}

.block > .margin {
  padding-top: 3.25rem;
}

.block > .body {
  min-width: 0;
  border-left: 2px solid var(--red);
  padding: 3rem 0 3.5rem 2rem;
}

.block:last-of-type > .body {
  padding-bottom: 4.5rem;
}

.margin h2 {
  font: 500 1.75rem/1.15 var(--serif);
  position: sticky;
  top: 1rem;
}

.margin p {
  color: var(--ink-2);
  font-size: 0.92rem;
  line-height: 1.5;
  margin-top: 0.75rem;
}

/* The track: seven stages on one line */

.track {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  row-gap: 0.5rem;
  position: relative;
  isolation: isolate;
  margin-bottom: 1.5rem;
}

.track::before {
  content: "";
  position: absolute;
  left: 1.125rem;
  right: 3rem;
  top: calc(0.5rem + 1.125rem);
  height: 1px;
  background: var(--ink);
  z-index: -1;
}

.node {
  appearance: none;
  background: none;
  border: 0;
  padding: 0.5rem 0.75rem 0.5rem 0;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-align: left;
  min-width: 0;
}

.node .num {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  display: grid;
  place-items: center;
  font: 500 1.05rem/1 var(--serif);
  flex: none;
}

.node .name {
  line-height: 1.15;
  max-width: 7.5rem;
  background: var(--paper);
  padding: 0.15rem 0.3rem 0.15rem 0;
}

.node:hover .num {
  background: var(--red-soft);
}

.node[aria-selected="true"] .num {
  background: var(--ink);
  color: var(--paper);
}

.node[aria-selected="true"] .name {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35em;
}

.node:focus-visible {
  outline-offset: 2px;
  border-radius: 2px;
}

/* Panels */

.panel {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 1.75rem clamp(1.25rem, 3vw, 2.25rem) 2rem;
}

.panel + .panel {
  margin-top: 1rem;
}

.js .panels .panel:not(.is-active) {
  display: none;
}

.js .panel + .panel {
  margin-top: 0;
}

.panel.entering {
  animation: panel-in 180ms ease-out;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.gate-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 0.35rem;
}

.gate {
  font: italic 500 clamp(1.5rem, 3vw, 2.1rem) / 1.2 var(--serif);
  margin-bottom: 1.5rem;
  max-width: 26ch;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 2rem;
}

.panel h3 {
  font: 600 0.95rem/1.3 var(--sans);
  margin-bottom: 0.35rem;
}

.panel p {
  margin-bottom: 1.25rem;
  max-width: 60ch;
}

.panel p:last-child {
  margin-bottom: 0;
}

.facts dt {
  font-weight: 600;
  font-size: 0.95rem;
}

.facts dd {
  margin: 0.2rem 0 1rem;
  line-height: 1.55;
}

.facts dd:last-child {
  margin-bottom: 0;
}

.changed {
  border-top: 1px solid var(--rule);
  margin-top: 1.5rem;
  padding-top: 1.25rem;
}

.triple {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

.triple dt {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-2);
}

.triple dd {
  margin-top: 0.2rem;
  line-height: 1.5;
}

/* Loops */

.loops {
  list-style: none;
  padding: 0;
  margin: 1.75rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem 1.5rem;
}

.loops li {
  border-top: 2px solid var(--red);
  padding-top: 0.5rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.loops strong {
  display: block;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.poster-link {
  margin-top: 1.75rem;
  font-size: 0.95rem;
  color: var(--ink-2);
}

/* Four readers */

.readers {
  list-style: none;
  padding: 0;
  margin: 0 0 1.75rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.readers li {
  padding-right: 1.25rem;
}

.readers li + li {
  border-left: 1px solid var(--rule);
  padding-left: 1.25rem;
}

.readers h3 {
  font: 500 1.35rem/1.2 var(--serif);
  margin-bottom: 0.4rem;
}

.readers p {
  font-size: 0.98rem;
  line-height: 1.5;
}

.test {
  font: italic 500 clamp(1.35rem, 2.6vw, 1.75rem) / 1.3 var(--serif);
  max-width: 32ch;
}

/* Principles */

.principles {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 2.5rem;
}

.principles > li {
  border-top: 1px solid var(--rule);
  padding: 1.25rem 0;
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr);
  column-gap: 0.5rem;
}

.principles .n {
  font: 500 1.75rem/1 var(--serif);
  padding-top: 0.1rem;
}

.principles h3 {
  font: 600 1.05rem/1.3 var(--sans);
  margin-bottom: 0.35rem;
}

.principles p {
  font-size: 0.98rem;
  line-height: 1.55;
  margin-bottom: 0.5rem;
}

.principles details {
  font-size: 0.95rem;
}

.principles summary {
  cursor: pointer;
  color: var(--ink-2);
  font-weight: 500;
  list-style: none;
  display: inline-block;
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-underline-offset: 0.18em;
}

.principles summary::-webkit-details-marker {
  display: none;
}

.principles details .less,
.principles details[open] .more {
  display: none;
}

.principles details[open] .less {
  display: inline;
}

.principles dl {
  margin-top: 0.5rem;
}

.principles dt {
  font-weight: 600;
  margin-top: 0.6rem;
}

.principles dd {
  margin-top: 0.15rem;
  line-height: 1.5;
}

/* Skills */

.skills {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.98rem;
}

.skills th,
.skills td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 1rem 0.6rem 0;
  border-top: 1px solid var(--rule);
  line-height: 1.5;
}

.skills thead th {
  border-top: 0;
  padding-top: 0;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-2);
}

.skills tr.group th {
  font: 500 1.2rem/1.2 var(--serif);
  padding-top: 1.5rem;
  border-top: 0;
}

.skills td:first-child {
  width: 17rem;
}

.skills-note {
  margin-top: 1.5rem;
  color: var(--ink-2);
  font-size: 0.95rem;
}

/* Sources */

.sources {
  columns: 2;
  column-gap: 2.5rem;
  padding-left: 1.1rem;
  margin: 0;
}

.sources li {
  break-inside: avoid;
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* Footer */

.foot {
  max-width: var(--page);
  margin: 0 auto;
  padding: 2rem var(--gutter) 3rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: 0.95rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  justify-content: space-between;
}

/* Narrow screens */

@media (max-width: 900px) {
  .hero-inner {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .block {
    grid-template-columns: 1fr;
  }

  .block > .margin {
    padding-top: 2.5rem;
  }

  .margin h2 {
    position: static;
  }

  .margin p {
    margin-top: 0.4rem;
    margin-bottom: 0.75rem;
  }

  .block > .body {
    padding: 0.75rem 0 2.5rem 1rem;
  }

  .track::before {
    display: none;
  }
}

@media (max-width: 760px) {
  .track {
    justify-content: flex-start;
    column-gap: 0.5rem;
  }

  .node {
    padding-right: 0.5rem;
  }

  .node .name {
    max-width: none;
  }

  .readers {
    grid-template-columns: 1fr 1fr;
  }

  .readers li {
    padding: 0.75rem 1rem 0.75rem 0;
    border-top: 1px solid var(--rule);
  }

  .readers li + li {
    border-left: 0;
    padding-left: 0;
  }

  .principles {
    grid-template-columns: 1fr;
  }

  .sources {
    columns: 1;
  }
}

@media (max-width: 700px) {
  .panel-grid,
  .triple {
    grid-template-columns: 1fr;
  }

  .panel-grid {
    gap: 1.25rem;
  }
}

@media (max-width: 640px) {
  .skills thead {
    display: none;
  }

  .skills,
  .skills tbody,
  .skills tr,
  .skills th,
  .skills td {
    display: block;
    width: auto;
  }

  .skills tr {
    border-top: 1px solid var(--rule);
    padding: 0.6rem 0;
  }

  .skills tr.group {
    border-top: 0;
  }

  .skills th,
  .skills td {
    border: 0;
    padding: 0.1rem 0;
  }

  .skills tr.group th {
    padding-top: 1.25rem;
  }
}

@media (max-width: 460px) {
  .readers {
    grid-template-columns: 1fr;
  }

  .thesis {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel.entering {
    animation: none;
  }

  html {
    scroll-behavior: auto;
  }
}

/* Prioritize what makes it live */

.questions {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
  counter-reset: q;
}

.questions li {
  border-top: 2px solid var(--red);
  padding-top: 0.6rem;
  counter-increment: q;
}

.questions h3 {
  font: 500 1.2rem/1.25 var(--serif);
  margin-bottom: 0.35rem;
}

.questions h3::before {
  content: counter(q) ". ";
  color: var(--ink-2);
}

.questions p {
  font-size: 0.95rem;
  line-height: 1.5;
}

.sub {
  font: 600 0.95rem/1.3 var(--sans);
  margin: 1.5rem 0 0.6rem;
}

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

.board {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.board th,
.board td {
  text-align: left;
  vertical-align: top;
  padding: 0.45rem 1rem 0.45rem 0;
  border-top: 1px solid var(--rule);
  line-height: 1.45;
  white-space: nowrap;
}

.board th:last-child,
.board td:last-child {
  white-space: normal;
  min-width: 14rem;
}

.board thead th {
  border-top: 0;
  padding-top: 0;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-2);
}

.board .enabling {
  color: var(--red);
  font-weight: 600;
}

.chain {
  display: block;
  width: 100%;
  max-width: 46rem;
  height: auto;
  margin: 0.25rem 0 0.5rem;
  color: var(--ink);
  font-family: var(--sans);
}

.chain-caption {
  font-size: 0.95rem;
  color: var(--ink-2);
  max-width: 60ch;
  margin-bottom: 1.5rem;
}

@media (max-width: 760px) {
  .questions {
    grid-template-columns: 1fr;
  }
}
