:root {
  --ink: #102c22;
  --muted: #506b5e;
  --green: #087447;
  --green-dark: #075a39;
  --green-soft: #e4f4ea;
  --blue: #2769a7;
  --blue-soft: #eaf2f9;
  --amber: #a76d05;
  --amber-soft: #fff5d8;
  --red: #9e4138;
  --red-soft: #fff0ed;
  --line: #d3e0d8;
  --paper: #fff;
  --canvas: #eaf0ec;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
  color-scheme: light;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(16, 44, 34, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 44, 34, 0.035) 1px, transparent 1px),
    var(--canvas);
  background-size: 28px 28px;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid #216bc0;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.toolbar {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 8px max(20px, calc((100vw - 1220px) / 2));
  color: #fff;
  background: var(--ink);
}

.brand {
  color: inherit;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.045em;
  text-decoration: none;
}

.brand span {
  color: #aed7c0;
  font-weight: 500;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-button {
  min-height: 34px;
  padding: 5px 10px;
  color: #e4f8ed;
  background: transparent;
  border: 1px solid #557766;
  border-radius: 6px;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.toolbar-button:hover {
  background: #183e30;
}

.journey-shell {
  width: min(1220px, calc(100% - 32px));
  min-height: calc(100dvh - 98px);
  margin: 10px auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(16, 44, 34, 0.08);
  overflow: hidden;
}

.journey-shell.showing-intro .journey-map {
  display: none;
}

.intro-view {
  min-height: calc(100dvh - 100px);
  display: grid;
  align-content: center;
  gap: clamp(18px, 2.4vw, 28px);
  padding: clamp(32px, 5.5vw, 68px);
}

.intro-opening {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.1fr);
  align-items: end;
  gap: clamp(26px, 5vw, 72px);
}

.intro-view h1 {
  max-width: 640px;
  font-size: clamp(46px, 6vw, 76px);
  line-height: 0.96;
}

.intro-summary > p:first-child {
  margin-bottom: 16px;
  color: #345347;
  font-size: clamp(18px, 1.8vw, 22px);
  line-height: 1.38;
}

.intro-warning {
  margin-bottom: 0;
  padding: 13px 16px;
  color: #5c4517;
  background: var(--amber-soft);
  border-left: 4px solid var(--amber);
  font-size: 15px;
  line-height: 1.42;
}

.intro-timing {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.intro-timing article {
  padding: 17px 19px;
  background: var(--green-soft);
  border: 1px solid #bfdcca;
  border-radius: 9px;
}

.intro-timing article:last-child {
  background: var(--red-soft);
  border-color: #edc9c3;
}

.intro-timing span,
.intro-purpose span {
  display: block;
  margin-bottom: 5px;
  color: var(--green-dark);
  font: 800 11px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.intro-timing article:last-child span {
  color: var(--red);
}

.intro-timing h2 {
  margin-bottom: 6px;
  font-size: clamp(20px, 2vw, 27px);
  line-height: 1.08;
}

.intro-timing p {
  margin-bottom: 0;
  color: #3d5a4e;
  font-size: 15px;
}

.intro-timing article:last-child p {
  color: #62423e;
}

.intro-purpose {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  align-items: center;
  gap: 28px;
  padding: 15px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.intro-purpose p {
  margin-bottom: 0;
}

.intro-purpose > div p {
  font-size: clamp(17px, 1.65vw, 21px);
  font-weight: 750;
  line-height: 1.35;
}

.intro-scope {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.42;
}

.intro-start {
  justify-self: start;
  min-height: 46px;
  padding: 10px 17px;
  color: #fff;
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: 7px;
  font-weight: 750;
  cursor: pointer;
}

.intro-start:hover {
  background: var(--green-dark);
}

.journey-map {
  position: relative;
  padding: 13px 30px 11px;
  background: #f6f9f7;
  border-bottom: 1px solid var(--line);
}

.journey-map ol {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.journey-map li {
  position: relative;
  min-width: 0;
}

.journey-map li:not(:last-child)::after {
  content: "";
  position: absolute;
  z-index: 0;
  top: 23px;
  left: calc(50% + 17px);
  width: calc(100% - 24px);
  height: 2px;
  background: #cbd7d0;
  transition: background 240ms ease;
}

.journey-map li.done-connector::after {
  background: var(--green);
}

.journey-map button {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 82px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 34px auto auto;
  align-items: center;
  justify-items: center;
  gap: 3px;
  padding: 7px 4px;
  color: var(--muted);
  text-align: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.journey-map button:hover {
  background: #e9f1ec;
}

.journey-map button > span {
  grid-row: 1;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #fff;
  background: #8ba197;
  border: 4px solid #f6f9f7;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #9eb0a7;
  font: 800 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.journey-map button strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.15;
}

.journey-map button small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journey-map button.done > span,
.journey-map button.active > span {
  background: var(--green);
  box-shadow: 0 0 0 1px #5c9e7a;
}

.journey-map button.active {
  background: transparent;
}

.journey-map button.active strong,
.journey-map button.active small {
  color: var(--green-dark);
}

.chapter-view {
  padding: clamp(16px, 2vw, 24px);
}

.chapter-heading {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  align-items: end;
  gap: 22px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font: 800 12px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(29px, 3.2vw, 42px);
  line-height: 1.03;
  letter-spacing: -0.045em;
}

h1:focus,
h2:focus {
  outline: none;
}

.chapter-lead {
  margin-bottom: 2px;
  color: #3f5d50;
  font-size: clamp(16px, 1.35vw, 18px);
  line-height: 1.35;
}

.chapter-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(390px, 1.05fr);
  gap: 18px;
  align-items: stretch;
}

.case-visual {
  min-width: 0;
  margin: 0;
}

.image-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #e7ece8;
  border: 1px solid #cfdcd4;
  border-radius: 10px;
}

.image-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: object-position 280ms ease, transform 280ms ease;
}

.image-zone {
  position: absolute;
  z-index: 3;
  left: 12px;
  bottom: 12px;
  max-width: calc(100% - 24px);
  padding: 6px 9px;
  color: #fff;
  background: rgba(9, 39, 28, 0.9);
  border-radius: 5px;
  font-size: 13px;
  font-weight: 700;
}

.case-visual figcaption {
  min-height: 0;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.case-panel {
  position: relative;
  min-height: 100%;
  padding: 14px 16px;
  background: #f9fbfa;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.case-position {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--muted);
  font: 750 11px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.case-position span:last-child {
  padding: 4px 7px;
  color: var(--green-dark);
  background: var(--green-soft);
  border-radius: 4px;
}

.case-panel h2 {
  margin-bottom: 6px;
  font-size: clamp(22px, 2.1vw, 28px);
  line-height: 1.08;
  letter-spacing: -0.025em;
}

.case-summary {
  margin-bottom: 10px;
  color: #405f51;
  font-size: 15px;
  line-height: 1.32;
}

.case-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin: 0 0 10px;
}

.case-option {
  min-width: 0;
  padding: 7px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.case-option strong {
  display: block;
  margin-bottom: 2px;
  color: var(--green-dark);
  font-size: 13px;
  line-height: 1.2;
}

.case-option p {
  margin: 0;
  color: #506b5e;
  font-size: 12px;
  line-height: 1.3;
}

.case-options.dense {
  gap: 5px;
}

.case-options.dense .case-option {
  padding: 6px 8px;
}

.case-options.dense .case-option p {
  font-size: 12px;
  line-height: 1.25;
}

@media (min-width: 1101px) {
  .case-options[data-count="3"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.case-facts {
  display: grid;
  gap: 0;
  margin: 0;
  border-top: 1px solid var(--line);
}

.case-facts div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.case-facts dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.case-facts dd {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.3;
}

.case-alert,
.term-card {
  margin-top: 8px;
  padding: 7px 9px;
  background: var(--amber-soft);
  border-left: 3px solid var(--amber);
}

.case-alert span,
.term-card span {
  display: block;
  margin-bottom: 3px;
  color: #72500e;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.case-alert p,
.term-card p {
  margin-bottom: 0;
  color: #5c4517;
  font-size: 12px;
  line-height: 1.3;
}

.term-card {
  background: var(--blue-soft);
  border-color: var(--blue);
}

.term-card span,
.term-card p {
  color: #214f79;
}

.source-link {
  display: inline-block;
  margin-top: 7px;
  color: var(--green);
  font-size: 13px;
  text-underline-offset: 3px;
}

.step-navigation {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 190px;
  align-items: center;
  gap: 14px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.step-navigation > button,
.completion-actions button,
.completion-actions a {
  min-height: 38px;
  padding: 7px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #b8cdbf;
  border-radius: 7px;
  font-weight: 650;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.step-navigation > button:hover,
.completion-actions button:hover {
  background: #f1f6f3;
}

.step-navigation .next-button {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.step-navigation .next-button:hover {
  background: var(--green-dark);
}

.step-navigation > p {
  display: grid;
  gap: 2px;
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.step-navigation > p strong {
  color: var(--ink);
  font-size: 14px;
}

.completion-view {
  min-height: calc(100dvh - 198px);
  display: grid;
  align-content: center;
  justify-items: center;
  padding: clamp(30px, 6vw, 70px);
  text-align: center;
}

.completion-signal {
  position: relative;
  width: min(680px, 90%);
  height: 5px;
  margin-bottom: 35px;
  background: linear-gradient(90deg, var(--blue), var(--green));
  border-radius: 99px;
}

.completion-signal span {
  position: absolute;
  right: -8px;
  top: 50%;
  width: 17px;
  height: 17px;
  background: #fff;
  border: 3px solid var(--green);
  border-radius: 50%;
  box-shadow: 0 0 17px 7px #76eda5;
  transform: translateY(-50%);
  animation: arrival-pulse 1.4s ease-in-out infinite alternate;
}

@keyframes arrival-pulse {
  from { box-shadow: 0 0 8px 2px #76eda5; }
  to { box-shadow: 0 0 22px 9px #76eda5; }
}

.completion-view h1 {
  max-width: 820px;
  font-size: clamp(35px, 5vw, 62px);
}

.completion-view > p:not(.eyebrow) {
  max-width: 690px;
  margin: 16px 0 25px;
  color: var(--muted);
  font-size: 19px;
}

.completion-grid {
  width: min(900px, 100%);
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 9px;
}

.completion-grid div {
  display: grid;
  gap: 5px;
  padding: 13px 9px;
  background: var(--green-soft);
  border: 1px solid #c7e0d1;
  border-radius: 7px;
}

.completion-grid span {
  color: var(--green);
  font: 800 12px ui-monospace, monospace;
}

.completion-grid strong {
  font-size: 14px;
}

.completion-view blockquote {
  max-width: 780px;
  margin: 26px 0 21px;
  color: var(--ink);
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 750;
}

.completion-actions {
  display: flex;
  justify-content: center;
  gap: 9px;
}

.completion-actions a {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.page-footer {
  width: min(1220px, calc(100% - 40px));
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 8px;
  color: var(--muted);
  font-size: 12px;
}

.sources-dialog {
  width: min(680px, calc(100% - 28px));
  max-height: min(760px, calc(100dvh - 40px));
  padding: 24px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 80px rgba(9, 36, 26, 0.28);
}

.sources-dialog::backdrop {
  background: rgba(6, 25, 18, 0.62);
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-heading h2 {
  margin-bottom: 10px;
  font-size: 28px;
}

.dialog-heading button {
  width: 40px;
  height: 40px;
  color: var(--ink);
  background: #f3f7f4;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 25px;
  cursor: pointer;
}

.sources-dialog ul {
  display: grid;
  gap: 9px;
  margin: 12px 0 20px;
  padding-left: 22px;
}

.sources-dialog a {
  color: var(--green);
  text-underline-offset: 3px;
}

.sources-dialog > p {
  margin-bottom: 0;
  padding: 12px;
  color: var(--muted);
  background: #f3f7f4;
  font-size: 14px;
}

.noscript {
  position: fixed;
  right: 15px;
  bottom: 15px;
  padding: 10px 14px;
  background: var(--amber-soft);
  border: 1px solid #d8b95e;
}

@media (max-height: 820px) and (min-width: 901px) {
  .intro-view {
    gap: 14px;
    padding-top: 25px;
    padding-bottom: 25px;
  }

  .intro-view h1 {
    font-size: 52px;
  }

  .intro-timing article {
    padding-top: 13px;
    padding-bottom: 13px;
  }

  .journey-map {
    padding-top: 8px;
    padding-bottom: 7px;
  }

  .journey-map button {
    min-height: 66px;
  }

  .chapter-view {
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .chapter-heading {
    margin-bottom: 10px;
  }

  h1 {
    font-size: 34px;
  }

  .image-stage {
    aspect-ratio: 1.78;
  }

  .case-panel {
    padding: 12px 14px;
  }

  .case-panel h2 {
    font-size: 23px;
  }

  .case-summary {
    margin-bottom: 7px;
  }

  .case-facts div {
    padding: 5px 0;
  }

  .case-alert,
  .term-card {
    margin-top: 6px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .step-navigation {
    margin-top: 7px;
    padding-top: 7px;
  }
}

@media (max-width: 1000px) {
  .journey-map {
    overflow-x: auto;
    padding-right: 18px;
    padding-left: 18px;
  }

  .journey-map ol {
    min-width: 900px;
  }

  .chapter-layout {
    grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
  }
}

@media (max-width: 820px) {
  .intro-opening,
  .intro-purpose,
  .chapter-heading,
  .chapter-layout {
    grid-template-columns: 1fr;
  }

  .intro-opening {
    align-items: start;
    gap: 18px;
  }

  .intro-purpose {
    gap: 12px;
  }

  .chapter-heading {
    align-items: start;
    gap: 10px;
  }

  .case-visual figcaption {
    min-height: 0;
  }

  .case-panel {
    min-height: 0;
  }

  .step-navigation {
    grid-template-columns: 1fr 1fr;
  }

  .step-navigation > p {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .completion-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .toolbar {
    min-height: 48px;
    padding: 7px 12px;
  }

  .brand span,
  .toolbar-actions .toolbar-button:first-child {
    display: none;
  }

  .journey-shell {
    width: calc(100% - 16px);
    min-height: calc(100dvh - 82px);
    margin: 8px auto;
  }

  .intro-view {
    min-height: calc(100dvh - 82px);
    gap: 17px;
    padding: 28px 17px;
  }

  .intro-view h1 {
    font-size: 43px;
  }

  .intro-summary > p:first-child {
    font-size: 17px;
  }

  .intro-timing {
    grid-template-columns: 1fr;
  }

  .intro-start {
    width: 100%;
  }

  .journey-map ol {
    min-width: 860px;
  }

  .journey-map button {
    min-height: 72px;
  }

  .chapter-view {
    padding: 19px 15px;
  }

  h1 {
    font-size: 33px;
  }

  .chapter-lead {
    font-size: 16px;
  }

  .image-stage {
    aspect-ratio: 4 / 3;
  }

  .case-panel {
    padding: 16px;
  }

  .case-options {
    grid-template-columns: 1fr;
  }

  .case-facts div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .step-navigation {
    grid-template-columns: 1fr;
  }

  .step-navigation > p {
    grid-column: auto;
    grid-row: auto;
  }

  .completion-view {
    padding: 35px 16px;
  }

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

  .completion-actions,
  .page-footer {
    flex-direction: column;
  }

  .completion-actions {
    width: 100%;
  }

  .completion-actions button,
  .completion-actions a {
    width: 100%;
  }

  .page-footer {
    width: calc(100% - 26px);
  }

  .page-footer span:last-child {
    display: none;
  }
}

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

@media print {
  body {
    background: #fff;
  }

  .toolbar,
  .journey-map,
  .step-navigation,
  .page-footer,
  .sources-dialog,
  .noscript {
    display: none !important;
  }

  .journey-shell,
  .chapter-view {
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
}
