@font-face {
  font-family: Merriweather;
  src: url("/kansas-notebook/type/merriweather-text.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Lora;
  src: url("/kansas-notebook/type/lora-notes.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/kansas-notebook/type/jetbrains-amounts.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --cocoa: #5b3a30;
  --cream: #ffe3c3;
  --quiet: #edcbae;
  --paper-edge: #926d59;
  --deep: #4c3028;
  --section-gap: clamp(4rem, 8vw, 8rem);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
}

body {
  margin: 0;
  background: var(--cocoa);
  color: var(--cream);
  font-family: Lora, Georgia, serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
  min-width: 44px;
  min-height: 44px;
}

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

a:focus-visible,
summary:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--cream);
  outline-offset: 5px;
}

h1,
h2,
h3,
h4,
summary,
button,
.guide-name,
.chapter-label,
.rail-label,
.diagram-label {
  font-family: Merriweather, Georgia, serif;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 700;
  text-align: left;
}

h1 {
  max-width: 19ch;
  font-size: 2.25rem;
  line-height: 0.9;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 1.5rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

h3,
h4 {
  font-size: 1.125rem;
  line-height: 1.4;
}

p,
ul,
ol,
figure,
dl,
dd {
  margin: 0;
}

p {
  max-width: 72ch;
}

p + p {
  margin-top: 1rem;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.masthead,
.chapter-opening,
.chapter-reading,
.footer,
.missing-opening {
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: 1.5rem;
}

.skip-link {
  position: fixed;
  z-index: 20;
  inset: 1rem auto auto 1rem;
  padding: 0.75rem 1rem;
  background: var(--deep);
  opacity: 0;
  pointer-events: none;
}

.skip-link:focus {
  opacity: 1;
  pointer-events: auto;
}

.masthead {
  display: grid;
  grid-template-columns: 260px 1fr auto;
  gap: 2rem;
  align-items: center;
  padding-block: 1.5rem;
  border-bottom: 1px solid var(--paper-edge);
}

.guide-name {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-self: start;
  padding-block: 0.25rem;
  font-size: 1.5rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.guide-name span {
  margin-top: 0.375rem;
  font-size: 1rem;
  line-height: 1.4;
  font-weight: 400;
  letter-spacing: 0;
}

.guide-purpose {
  color: var(--quiet);
}

.chapter-menu {
  position: relative;
  z-index: 10;
}

.chapter-menu summary {
  min-width: 150px;
  min-height: 48px;
  padding: 0.625rem 1rem;
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.chapter-menu[open] summary {
  background: var(--deep);
}

.chapter-menu nav {
  position: absolute;
  top: calc(100% + 1rem);
  right: 0;
  width: 560px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 1rem;
  padding: 1rem;
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  background: var(--deep);
  box-shadow: 0 16px 40px #2b1b1840;
}

.chapter-menu a {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  font-size: 1rem;
  text-decoration: none;
}

.chapter-menu a:hover,
.chapter-menu a[aria-current="page"] {
  text-decoration: underline;
}

.chapter-opening {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(3rem, 6vw, 6rem);
  align-items: center;
  padding-block: var(--section-gap);
}

.opening-text {
  animation: arrive 420ms ease-out both;
}

.chapter-label,
.rail-label {
  margin-bottom: 1.5rem;
  color: var(--quiet);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
}

.home h1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  max-width: 15ch;
}

.opening-lead {
  max-width: 48ch;
  margin-top: 2rem;
  font-size: 1.125rem;
}

.opening-link {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-block: 0.75rem;
  font-size: 1rem;
}

.care-diagram {
  width: 100%;
  max-width: 432px;
  justify-self: end;
  padding: 2rem;
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  box-shadow: 0 12px 32px #2b1b1820;
  animation: arrive 420ms 80ms ease-out both;
}

.care-diagram figcaption {
  margin-bottom: 1.5rem;
  font-size: 1rem;
}

.care-diagram ol {
  padding: 0;
  list-style: none;
}

.care-diagram li {
  position: relative;
  padding: 1rem;
  border-left: 2px solid var(--cream);
  background: var(--deep);
  border-radius: 0 8px 8px 0;
}

.care-diagram li + li {
  margin-top: 1.5rem;
}

.care-diagram li + li::before {
  content: "";
  position: absolute;
  left: -2px;
  top: -1.5rem;
  height: 1.5rem;
  border-left: 1px solid var(--paper-edge);
}

.care-diagram li:nth-child(even) {
  margin-left: 2rem;
}

.care-diagram li:nth-child(even)::before {
  left: -2rem;
  width: 2rem;
  border-bottom: 1px solid var(--paper-edge);
}

.diagram-label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--quiet);
  font-size: 0.875rem;
  font-weight: 500;
}

.care-diagram strong {
  display: block;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.6;
}

.chapter-reading {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  align-items: start;
  gap: 4rem;
}

.anchor-rail {
  position: sticky;
  top: 2rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border-top: 1px solid var(--paper-edge);
  padding-top: 1.5rem;
}

.anchor-rail .rail-label {
  margin-bottom: 0.5rem;
}

.anchor-rail a {
  display: flex;
  align-items: center;
  padding-block: 0.625rem;
  font-size: 1rem;
  text-decoration: none;
}

.anchor-rail a:hover {
  text-decoration: underline;
}

.chapter {
  min-width: 0;
}

.short-answer {
  padding: 2.5rem;
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  background: var(--deep);
  box-shadow: 0 12px 32px #2b1b1820;
}

.short-answer h2 {
  margin-bottom: 1.5rem;
}

.short-answer p:not(.chapter-label) {
  font-size: 1rem;
}

.myth {
  margin-block: 3rem var(--section-gap);
  padding: 0.5rem 0 0.5rem 1.5rem;
  border-left: 2px solid var(--paper-edge);
}

.myth .chapter-label {
  margin-bottom: 0.75rem;
}

.myth p + p {
  margin-top: 0;
  max-width: 45ch;
  font-size: 1.375rem;
}

.depth-row {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 3rem;
  align-items: start;
}

.depth-row + .depth-row {
  margin-top: var(--section-gap);
}

.reading-group + .reading-group,
.reading-group + .depth-row,
.depth-row + .reading-group {
  margin-top: var(--section-gap);
}

.group-readings {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--paper-edge);
}

.group-readings .depth-row + .depth-row {
  margin-top: 3rem;
}

.depth-turn {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
}

.depth-turn > :is(h2, h3, h4) {
  grid-column: 2;
  grid-row: 1;
}

.depth-turn .depth-text {
  grid-column: 1;
  grid-row: 1;
}

.depth-text {
  min-width: 0;
}

.ask,
.chapter-notes,
.topics,
.worksheet,
.next-chapter {
  margin-top: var(--section-gap);
}

.ask {
  padding: 2.5rem;
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
}

.ask ul {
  padding: 0;
  margin-top: 1.5rem;
  list-style: none;
}

.ask li {
  max-width: 72ch;
  padding-block: 1rem;
  font-size: 1rem;
  border-top: 1px solid var(--paper-edge);
}

.ask li:last-child {
  padding-bottom: 0;
}

.topic-row {
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr);
  gap: 3rem;
  margin-top: 2rem;
  padding-block: 1rem;
  border-top: 1px solid var(--paper-edge);
}

.topic-row h3 {
  padding-top: 0.875rem;
}

.topic-link,
.source-link,
.next-link,
.read-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding-block: 0.625rem;
  font-size: 1rem;
}

.topic-link {
  display: flex;
  justify-content: space-between;
  min-height: 56px;
}

.topic-link span,
.source-link span,
.next-link span {
  flex-shrink: 0;
}

.topic-link + .topic-link {
  border-top: 1px solid var(--paper-edge);
}

.chapter-notes ol {
  padding: 0;
  margin-top: 1.5rem;
  list-style: none;
}

.chapter-notes > summary {
  padding-block: 1rem;
  border-block: 1px solid var(--paper-edge);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1.4;
}

.chapter-notes[open] > summary {
  margin-bottom: 1.5rem;
}

.chapter-notes li {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.note-letter {
  padding-top: 0.625rem;
  color: var(--quiet);
  font-family: "JetBrains Mono", monospace;
  font-size: 1rem;
}

.chapter-notes li p {
  max-width: 65ch;
  color: var(--quiet);
  font-size: 1rem;
}

.next-chapter {
  padding-top: 2rem;
  border-top: 1px solid var(--paper-edge);
}

.next-chapter .chapter-label {
  margin-bottom: 0.5rem;
}

.next-link {
  font-family: Merriweather, Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
}

.worksheet > p:not(.chapter-label) {
  margin-top: 1.5rem;
}

.cost-worksheet {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 2.5rem;
  margin-top: 2rem;
  padding: 2rem;
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  background: var(--deep);
  box-shadow: 0 12px 32px #2b1b1820;
}

.quote-fields,
.quote-results,
.quote-line {
  min-width: 0;
}

.quote-line {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr);
  gap: 1rem;
  align-items: center;
  padding-block: 1rem;
  border-bottom: 1px solid var(--paper-edge);
}

.quote-line:first-child {
  padding-top: 0;
}

.quote-line label {
  font-size: 1rem;
  line-height: 1.5;
}

.quote-line label span {
  display: block;
  margin-top: 0.5rem;
  color: var(--quiet);
  font-size: 1rem;
}

.amount-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.amount-input > span,
.amount-input input,
.quote-results output {
  font-family: "JetBrains Mono", monospace;
}

.amount-input input {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  padding: 0.625rem 0.5rem;
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  background: var(--cocoa);
  color: var(--cream);
  font-size: 1rem;
}

.amount-input input[aria-invalid="true"] {
  border-width: 2px;
  border-color: var(--cream);
}

.worksheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 1.5rem;
}

.worksheet-actions button {
  min-width: 44px;
  min-height: 48px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--cream);
  border-radius: 8px;
  background: var(--cream);
  color: var(--deep);
  font-family: Merriweather, Georgia, serif;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
}

.worksheet-actions .clear-button {
  border-color: var(--paper-edge);
  background: transparent;
  color: var(--cream);
}

.input-message:empty {
  display: none;
}

.input-message {
  margin-top: 1rem;
  font-size: 1rem;
}

.quote-results {
  padding-left: 1.5rem;
  border-left: 1px solid var(--paper-edge);
}

.quote-results dl {
  margin-top: 1rem;
}

.quote-results dl > div {
  padding-block: 1rem;
  border-bottom: 1px solid var(--paper-edge);
}

.quote-results dt {
  font-size: 1rem;
}

.quote-results dd {
  margin-top: 0.5rem;
}

.quote-results output {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.25rem;
  line-height: 1.5;
}

.quote-results p,
.quote-results h3:not(:first-child) {
  margin-top: 1.5rem;
}

.quote-results ul {
  padding-left: 1.25rem;
  margin-top: 1rem;
}

.quote-results li + li {
  margin-top: 1rem;
}

.worksheet-footnote {
  font-size: 1rem;
  color: var(--quiet);
}

.footer {
  margin-top: var(--section-gap);
  padding-block: 2.5rem 3rem;
  border-top: 1px solid var(--paper-edge);
}

.footer p {
  font-size: 1rem;
}

.footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  margin-top: 1.5rem;
}

.footer a,
.missing-opening nav a {
  display: inline-flex;
  align-items: center;
  padding-block: 0.75rem;
  font-size: 1rem;
}

.missing-opening {
  padding-block: var(--section-gap);
}

.missing-opening h1 {
  max-width: 24ch;
}

.missing-opening > p:not(.chapter-label) {
  margin-top: 2rem;
}

.missing-opening nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  margin-top: 1.5rem;
}

@keyframes arrive {
  from {
    opacity: 0.9;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  .chapter-reading {
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 2rem;
  }

  .depth-row,
  .depth-turn,
  .topic-row {
    gap: 2rem;
  }

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

  .quote-results {
    padding: 2rem 0 0;
    border-left: 0;
    border-top: 1px solid var(--paper-edge);
  }

  .quote-results dl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }
}

@media (max-width: 850px) {
  .masthead {
    grid-template-columns: 1fr auto;
    gap: 1.5rem;
  }

  .guide-purpose {
    display: none;
  }

  .chapter-opening {
    gap: 2.5rem;
  }

  .care-diagram {
    padding: 1.5rem;
  }

  .chapter-reading {
    grid-template-columns: minmax(0, 1fr);
    gap: 2.5rem;
  }

  .anchor-rail {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.25rem 1.5rem;
    padding-block: 1rem;
    border-bottom: 1px solid var(--paper-edge);
  }

  .anchor-rail .rail-label {
    flex: 0 0 100%;
    margin: 0;
  }

  .depth-text p {
    max-width: 72ch;
  }
}

@media (max-width: 620px) {
  html {
    scroll-padding-top: 1rem;
  }

  .masthead {
    gap: 1rem;
    padding-block: 1rem;
  }

  .guide-name {
    font-size: 1.25rem;
  }

  .guide-name span {
    max-width: 11ch;
    font-size: 1rem;
  }

  .chapter-menu summary {
    min-width: 140px;
    padding-inline: 0.75rem;
  }

  .chapter-menu nav {
    width: calc(100vw - 3rem);
    max-width: 560px;
    grid-template-columns: minmax(0, 1fr);
    max-height: 70vh;
    overflow-y: auto;
  }

  .chapter-opening {
    grid-template-columns: minmax(0, 1fr);
    gap: 3rem;
  }

  .care-diagram {
    max-width: none;
  }

  .opening-lead {
    font-size: 1rem;
  }

  .short-answer,
  .ask {
    padding: 1.5rem;
  }

  .anchor-rail {
    gap: 0.25rem 1.25rem;
  }

  .myth {
    margin-top: 2.5rem;
  }

  .depth-row,
  .depth-turn,
  .topic-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }

  .depth-turn > :is(h2, h3, h4),
  .depth-turn .depth-text {
    grid-column: auto;
    grid-row: auto;
  }

  .topic-row h3 {
    padding-top: 0.5rem;
  }

  .topic-link {
    gap: 1rem;
  }

  .source-link {
    line-height: 1.6;
  }

  .chapter-notes li {
    grid-template-columns: 1.5rem minmax(0, 1fr);
    gap: 0.5rem;
  }

  .cost-worksheet {
    padding: 1.5rem;
    gap: 1.5rem;
  }

  .quote-line {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
  }

  .quote-line label span {
    margin-top: 0.25rem;
  }

  .amount-input {
    max-width: 240px;
  }

  .quote-results dl {
    display: block;
  }

  .worksheet-actions {
    display: grid;
  }

  .footer nav,
  .missing-opening nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
