:root {
  --paper: #f3ecdf;
  --paper-card: #fffaf2;
  --ink: #241910;
  --ink-soft: #4a3b32;
  --rail: #243044;
  --rail-deep: #1a2433;
  --amber: #e39b3a;
  --amber-deep: #b56d22;
  --clay: #8c3d2f;
  --line: rgba(36, 25, 16, 0.12);
  --bs-body-font-family: "Atkinson Hyperlegible", "Segoe UI", sans-serif;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--paper);
  --bs-heading-color: var(--ink);
  --bs-link-color: var(--clay);
  --bs-link-hover-color: var(--ink);
  --bs-primary: var(--rail);
  --bs-border-radius: 0.4rem;
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 31px,
    rgba(36, 25, 16, 0.045) 32px
  );
  font-family: var(--bs-body-font-family);
  line-height: 1.65;
}

h1, h2, h3, .navbar-brand, .rung-title, .code-mark {
  font-family: Fraunces, Georgia, serif;
  font-optical-sizing: auto;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 4.1rem);
  font-weight: 560;
  line-height: 1.08;
  margin: 0 0 1rem;
}

h2 { font-size: clamp(1.5rem, 2.4vw, 2rem); font-weight: 560; margin: 0 0 0.75rem; }
h3 { font-size: 1.2rem; margin: 1.4rem 0 0.4rem; }

a { color: var(--clay); }
a:hover { color: var(--ink); }

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  background: var(--amber);
  color: var(--ink);
  padding: 0.4rem 0.8rem;
  z-index: 20;
}
.skip-link:focus { top: 0.75rem; }

.rail-header {
  background: var(--rail);
  color: #f6f1e7;
  border-bottom: 6px solid var(--amber);
}

.rail-nav { padding-top: 0.85rem; padding-bottom: 0.85rem; }
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #f6f1e7 !important;
  font-weight: 560;
  font-size: 1.25rem;
}
.brand-text em { font-style: italic; color: var(--amber); }
.brand-mark {
  width: 1.35rem;
  height: 1.7rem;
  border-left: 3px solid #f6f1e7;
  border-right: 3px solid #f6f1e7;
  background:
    linear-gradient(var(--amber), var(--amber)) center 20% / 100% 3px no-repeat,
    linear-gradient(var(--amber), var(--amber)) center 50% / 100% 3px no-repeat,
    linear-gradient(var(--amber), var(--amber)) center 80% / 100% 3px no-repeat;
}
.rail-nav .nav-link {
  color: rgba(246, 241, 231, 0.82);
  font-weight: 700;
  letter-spacing: 0.01em;
}
.rail-nav .nav-link:hover,
.rail-nav .nav-link:focus,
.rail-nav .nav-link.active {
  color: var(--amber);
}

.mast { padding: 3.5rem 0 1rem; }
.eyebrow {
  font-family: "Atkinson Hyperlegible", sans-serif;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--amber-deep);
  margin-bottom: 0.7rem;
}
.lede, .section-lead {
  font-size: 1.15rem;
  max-width: 42rem;
  color: var(--ink-soft);
}
.section-title { margin-bottom: 0.4rem; }

.ladder-section { padding-top: 2rem; padding-bottom: 1rem; }
.ladder {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0.25rem 0 0.25rem 0;
  position: relative;
}
.ladder::before {
  content: "";
  position: absolute;
  left: 0.35rem;
  top: 0;
  bottom: 0;
  width: 10px;
  background:
    linear-gradient(#c8b89a, #c8b89a) 0 0 / 3px 100% no-repeat,
    linear-gradient(#c8b89a, #c8b89a) 7px 0 / 3px 100% no-repeat;
}
.rung { margin: 0 0 0.85rem 1.6rem; position: relative; }
.rung::before {
  content: "";
  position: absolute;
  left: -1.55rem;
  top: 1.55rem;
  width: 1.45rem;
  height: 8px;
  background: var(--amber);
  box-shadow: 0 7px 0 rgba(36, 48, 68, 0.18);
}
.rung-link {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem 1.25rem;
  text-decoration: none;
  color: inherit;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-left: 0;
  padding: 1.1rem 1.25rem 1.15rem;
  box-shadow: 0 10px 24px rgba(36, 25, 16, 0.04);
}
.rung-link:hover { color: inherit; background: #fff; }
.rung-code {
  font-family: Fraunces, Georgia, serif;
  font-size: 2rem;
  line-height: 1;
  color: var(--rail);
  min-width: 3.2rem;
}
.rung-kicker {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber-deep);
}
.rung-title { display: block; font-size: 1.45rem; line-height: 1.15; }
.rung-summary { display: block; color: var(--ink-soft); margin-top: 0.25rem; }
.rung.is-later .rung-link { background: transparent; box-shadow: none; }
.rung.is-later .rung-code,
.rung.is-later .rung-title { color: var(--ink-soft); }
.rung.is-later::before { background: #c8b89a; }

.path-section { padding-top: 1.5rem; padding-bottom: 4rem; }
.path-card {
  display: block;
  height: 100%;
  background: var(--rail);
  color: #f6f1e7;
  text-decoration: none;
  padding: 1.4rem 1.3rem 1.5rem;
  border-top: 6px solid var(--amber);
}
.path-card:hover { color: #f6f1e7; background: var(--rail-deep); }
.path-card h2 { font-size: 1.55rem; color: #f6f1e7; }
.path-card p { margin: 0; color: rgba(246, 241, 231, 0.84); }

.page-wrap { padding: 2rem 0 4rem; }
.narrow { max-width: 46rem; }
.page-intro { margin-bottom: 1.5rem; }
.code-mark {
  display: inline-block;
  margin-right: 0.25rem;
  color: var(--rail);
}
.prose-block { margin: 0 0 1.75rem; max-width: 42rem; }
.prose-block ul, .prose-block ol { padding-left: 1.2rem; }
.prose-block li { margin: 0.35rem 0; }
.method-list li { margin: 0.7rem 0; }

.later-flag {
  display: inline-block;
  background: var(--rail);
  color: var(--amber);
  padding: 0.35rem 0.7rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.mind-card {
  background: var(--paper-card);
  border-left: 8px solid var(--rail);
  padding: 1.1rem 1.2rem;
  margin: 1.5rem 0;
  max-width: 42rem;
  box-shadow: 6px 0 0 var(--amber) inset;
}
.mind-card p:last-child { margin-bottom: 0; }
.mind-more { font-weight: 700; }

.rung-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}
.rung-chip {
  display: inline-flex;
  gap: 0.4rem;
  align-items: baseline;
  text-decoration: none;
  color: var(--ink);
  background: rgba(255, 250, 242, 0.7);
  border: 1px solid var(--line);
  padding: 0.25rem 0.6rem;
  font-size: 0.92rem;
}
.rung-chip span { font-family: Fraunces, Georgia, serif; font-weight: 680; }
.rung-chip.is-current { background: var(--rail); color: #f6f1e7; border-color: var(--rail); }
.rung-chip.is-later { color: var(--ink-soft); }

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
  max-width: 42rem;
}
.pager a {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  background: var(--paper-card);
  border: 1px solid var(--line);
  padding: 0.8rem 0.9rem;
  color: var(--ink);
  font-family: Fraunces, Georgia, serif;
  font-size: 1.15rem;
}
.pager a span {
  font-family: "Atkinson Hyperlegible", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber-deep);
  font-weight: 700;
}
.pager-next { text-align: right; }

.choice-row { margin-bottom: 1.5rem; }
.choice-card {
  height: 100%;
  background: var(--paper-card);
  padding: 1.2rem 1.15rem 1.3rem;
  border-top: 8px solid var(--amber);
  box-shadow: 0 0 0 1px var(--line);
}
.choice-card h2 { font-size: 1.7rem; }

.battery-table {
  background: var(--paper-card);
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
  font-size: 0.95rem;
}
.battery-table th { font-family: "Atkinson Hyperlegible", sans-serif; }

.btn-ladder {
  background: var(--rail);
  color: #f6f1e7;
  border: 0;
  border-bottom: 4px solid var(--amber);
  border-radius: 0;
  padding: 0.7rem 1.1rem;
  font-weight: 700;
  text-decoration: none;
}
.btn-ladder:hover { background: var(--rail-deep); color: #f6f1e7; }

.source-list { list-style: none; padding: 0; }
.source-list li {
  margin: 0 0 0.9rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
}
.source-list a { font-weight: 700; }
.source-list span { display: block; color: var(--ink-soft); }

.site-footer {
  background: var(--rail-deep);
  color: rgba(246, 241, 231, 0.84);
  padding: 2.5rem 0 2rem;
}
.site-footer a { color: var(--amber); text-decoration: none; }
.site-footer a:hover { color: #f6f1e7; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: 0.25rem 0; }
.footer-brand {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.4rem;
  color: #f6f1e7;
  margin-bottom: 0.4rem;
}
.footer-label {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 700;
}
.footer-note {
  margin: 1.5rem 0 0;
  font-size: 0.92rem;
  color: rgba(246, 241, 231, 0.62);
}

@media (max-width: 575.98px) {
  .mast .container,
  .ladder-section.container,
  .path-section.container {
    padding-left: max(1.35rem, env(safe-area-inset-left));
    padding-right: max(1.35rem, env(safe-area-inset-right));
  }
  .rung-link { grid-template-columns: 1fr; gap: 0.2rem; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { text-align: left; }
}
