@charset "utf-8";

:root {
  --blue: #04306C;
  --blue-dark: #02234f;
  --link-hover: #990000;
  --text: #222222;
  --muted: #666666;
  --line: #d9dde3;
  --panel: #f5f7f9;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 100%;
  color: var(--text);
  background: var(--white);
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
}

.site-header {
  background: var(--blue-dark);
  color: var(--white);
}

.site-header-inner {
  width: 92%;
  max-width: 1100px;
  min-height: 54px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.site-header a {
  color: #e7edf5;
}

.site-header a:hover {
  color: #ffffff;
}

.author-link {
  font-weight: bold;
  font-size: 1.02rem;
}

.personal-link {
  font-size: 0.92rem;
}

.book-hero {
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.hero-inner {
  width: 92%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 0 42px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.92rem;
  font-weight: bold;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.book-hero h1 {
  margin: 0;
  color: var(--blue);
  font-size: clamp(2.25rem, 5vw, 3.7rem);
  line-height: 1.05;
  font-weight: 700;
}

.subtitle {
  margin: 8px 0 26px;
  color: #3f4d5d;
  font-size: clamp(1.4rem, 3vw, 2rem);
  line-height: 1.2;
}

.author {
  margin: 0 0 4px;
  font-size: 1.08rem;
}

.publication {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.book-nav {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.book-nav-inner {
  width: 92%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}

.book-nav a {
  display: block;
  padding: 15px 17px;
  font-size: 0.96rem;
  font-weight: bold;
  color: var(--blue);
  border-bottom: 3px solid transparent;
}

.book-nav a:hover {
  color: var(--link-hover);
  background: #ffffff;
}

.book-nav a.active {
  color: var(--blue-dark);
  background: #ffffff;
  border-bottom-color: var(--blue);
}

.content {
  width: 92%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 38px 0 54px;
}

.intro {
  max-width: 830px;
  margin-bottom: 34px;
}

.content h2 {
  color: var(--blue);
  font-size: 1.42rem;
  margin: 0 0 12px;
}

.content h3 {
  color: var(--blue);
  font-size: 1.08rem;
  margin: 0 0 8px;
}

.content p {
  margin: 0 0 12px;
  line-height: 1.58;
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin: 34px 0 44px;
}

.resource-card {
  display: block;
  min-height: 185px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.resource-card:hover {
  color: var(--text);
  border-color: #bcc7d5;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.resource-card h2 {
  margin-bottom: 10px;
}

.resource-card p {
  color: var(--text);
}

.card-link {
  display: inline-block;
  margin-top: 5px;
  color: var(--blue);
  font-weight: bold;
}

.book-structure {
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.book-structure > h2 {
  margin-top: 28px;
}

.part {
  max-width: 900px;
  margin: 0 0 20px;
  padding: 16px 18px;
  background: var(--panel);
  border-left: 4px solid var(--blue);
}

.part p {
  margin-bottom: 0;
}

footer {
  border-top: 1px solid var(--line);
  background: #eeeeee;
  color: #555555;
}

.footer-inner {
  width: 92%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 0;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 0.9rem;
}

.footer-inner p {
  margin: 0;
}

@media (max-width: 760px) {
  .hero-inner {
    padding: 36px 0 32px;
  }

  .book-nav-inner {
    display: block;
  }

  .book-nav a {
    border-bottom: 1px solid var(--line);
  }

  .book-nav a.active {
    border-bottom: 1px solid var(--line);
    border-left: 4px solid var(--blue);
  }

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

  .footer-inner {
    display: block;
  }

  .footer-inner p + p {
    margin-top: 5px;
  }
}

/* Individual chapter pages */

.compact-hero .hero-inner {
  padding-top: 34px;
  padding-bottom: 30px;
}

.compact-hero .subtitle {
  margin-bottom: 0;
}

.chapter-breadcrumb {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 0.92rem;
}

.chapter-heading {
  max-width: 880px;
  margin-bottom: 36px;
}

.chapter-kicker {
  margin: 0 0 4px !important;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: bold;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chapter-heading h2 {
  margin: 0 0 14px;
  font-size: 2rem;
}

.chapter-summary {
  max-width: 820px;
  font-size: 1.03rem;
}

.chapter-contents {
  max-width: 900px;
  margin-bottom: 38px;
  padding-top: 4px;
}

.section-list {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.section-list li {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--line);
  line-height: 1.4;
}

.section-list li span {
  color: var(--blue);
  font-weight: bold;
}

.chapter-resources {
  margin-top: 8px;
}

.chapter-navigation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin-top: 48px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.chapter-nav-item {
  color: var(--muted);
}

.chapter-nav-item.next {
  text-align: right;
}

.chapter-nav-label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.82rem;
  font-weight: bold;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chapter-nav-title {
  display: block;
  color: var(--text);
  font-size: 0.96rem;
  line-height: 1.35;
}

.all-chapters-link {
  font-weight: bold;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .chapter-heading h2 {
    font-size: 1.7rem;
  }

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

  .chapter-nav-item.next {
    text-align: left;
  }

  .all-chapters-link {
    grid-row: 1;
  }
}


/* Code catalog */

.code-chapter {
  margin-top: 36px;
  scroll-margin-top: 20px;
}

.code-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 16px;
}

.code-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 980px;
}

.code-table th,
.code-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.code-table thead th {
  background: var(--panel);
  color: var(--blue);
  font-size: 0.92rem;
  white-space: nowrap;
}

.code-table th:first-child,
.code-table td:first-child {
  width: 52%;
}

.code-table th:not(:first-child),
.code-table td:not(:first-child) {
  width: 12%;
  text-align: center;
  white-space: nowrap;
}

.code-description {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.code-table td a {
  display: inline-block;
  min-width: 72px;
  font-weight: bold;
}

.back-to-chapter {
  margin-top: 20px !important;
  font-weight: bold;
}




/* Chapter label above a chapter title on resource pages */
.code-chapter .part-label {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.25;
}

/* Resource tables
   These tables contain explanatory text, unlike the code catalog.
   Cells are allowed to wrap so long routine names and notes do not overlap. */

.resource-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 16px 0 30px;
  -webkit-overflow-scrolling: touch;
}

.resource-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  line-height: 1.45;
}

.resource-table th,
.resource-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}

.resource-table thead th {
  background: var(--panel);
  color: var(--blue);
  font-size: 0.92rem;
  font-weight: bold;
}

.resource-table td a {
  font-weight: normal;
}

.resource-table code {
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Five-column software table */
.software-table {
  min-width: 1040px;
}

.software-table th:nth-child(1),
.software-table td:nth-child(1) {
  width: 25%;
}

.software-table th:nth-child(2),
.software-table td:nth-child(2),
.software-table th:nth-child(3),
.software-table td:nth-child(3),
.software-table th:nth-child(4),
.software-table td:nth-child(4),
.software-table th:nth-child(5),
.software-table td:nth-child(5) {
  width: 18.75%;
}

/* Three-column benchmark table */
.benchmark-table {
  min-width: 820px;
}

.benchmark-table th:nth-child(1),
.benchmark-table td:nth-child(1) {
  width: 42%;
}

.benchmark-table th:nth-child(2),
.benchmark-table td:nth-child(2) {
  width: 25%;
}

.benchmark-table th:nth-child(3),
.benchmark-table td:nth-child(3) {
  width: 33%;
}

/* Three-column method-selection table */
.method-table {
  min-width: 820px;
}

.method-table th:nth-child(1),
.method-table td:nth-child(1) {
  width: 28%;
}

.method-table th:nth-child(2),
.method-table td:nth-child(2) {
  width: 30%;
}

.method-table th:nth-child(3),
.method-table td:nth-child(3) {
  width: 42%;
}

.table-note {
  margin-top: -2px;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 760px) {
  .resource-table th,
  .resource-table td {
    padding: 10px 11px;
    font-size: 0.92rem;
  }
}

/* Exercises and physics projects */
.project-chapter { margin-top: 34px; }
.chapter-page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 14px 0 30px;
  font-size: 0.95rem;
}
.exercise-section,
.physics-project-section { margin-top: 34px; }
.exercise-list {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: exercise;
}
.exercise-item {
  counter-increment: exercise;
  position: relative;
  margin: 0 0 20px;
  padding: 20px 22px 18px 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.exercise-item::before {
  content: counter(exercise);
  position: absolute;
  top: 19px;
  left: 20px;
  width: 25px;
  height: 25px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--blue);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 23px;
  text-align: center;
}
.exercise-item h4,
.physics-project h4 {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 1.08rem;
  line-height: 1.35;
}
.exercise-item p:last-child,
.physics-project p:last-child { margin-bottom: 0; }
.equation-block {
  margin: 10px 0;
  padding: 7px 10px;
  overflow-x: auto;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.03rem;
  line-height: 1.55;
  text-align: center;
  white-space: nowrap;
}
.physics-project {
  margin: 0 0 24px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}
.project-objective,
.project-validation,
.project-extension { margin-top: 12px; }
.project-objective span,
.project-validation span,
.project-extension span {
  font-weight: 600;
  color: var(--blue);
}
@media (max-width: 760px) {
  .chapter-page-links { display: block; line-height: 1.8; }
  .chapter-page-links span { margin: 0 5px; }
  .exercise-item { padding: 18px 16px 16px 48px; }
  .exercise-item::before { top: 17px; left: 14px; }
  .physics-project { padding: 18px 16px; }
  .equation-block {
    margin-left: -2px;
    margin-right: -2px;
    padding-left: 4px;
    padding-right: 4px;
    font-size: 0.98rem;
    text-align: left;
  }
}
