/* Essentials of Classical Mechanics (Ryan D. Martin) — book-specific styles */
/* Generic theme styles are in theme.css */

:root {
  --physics-color-primary: #1f4e5f;
  --physics-color-primary-hover: #173b48;
  --physics-color-secondary: #2e7d8f;
  --physics-color-accent: #2e7d8f;
  --physics-color-example: #2e7d8f;
  --physics-color-example-bg: #eff6f8;
  --physics-color-problem: #9a5b1e;
  --physics-color-problem-bg: #fdf6ec;
  --physics-color-target: #fff7e0;
  --physics-color-header-link: #2e7d8f;
  --physics-color-table-border: #cbd5e1;
  --example-margin-top: 24px;
  --transition-opacity: opacity 0.2s ease-in-out 0.1s;
  --touch-target-min: 44px;
}

:is(.summary li:not(.visited) > .fa-check, .summary li:not(.visited) .fa-check) {
  display: none !important;
}

.summary li.visited > .fa-check,
.summary li.visited .fa-check {
  display: inline-block !important;
}

:target {
  background-color: var(--physics-color-target);
}

.header-link {
  position: absolute;
  inset-inline-start: -1em;
  opacity: 0;
  transition: var(--transition-opacity);
}

:is(h1:hover, h2:hover, h3:hover, h4:hover) .header-link {
  opacity: 1;
  color: var(--physics-color-header-link) !important;
}

.book .book-body .page-wrapper .page-inner {
  max-inline-size: calc(80% - 100px);
}

@media (max-width: 1000px) {
  .book .book-body .page-wrapper .page-inner {
    max-inline-size: calc(100% - 100px);
  }
}

@media (max-width: 600px) {
  .book .book-body .page-wrapper .page-inner {
    max-inline-size: calc(100% - 50px);
  }
}

.page-title {
  font-weight: bold;
  color: var(--physics-color-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.subheading {
  color: var(--physics-color-secondary);
  margin-block: 1.25em 0.5em;
}

/* Display equations */
.equation-block {
  margin-block: 12px;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Worked examples — the print book rules them off above and below and sets the
   worked solution small and italic; keep the same reading hierarchy. */
.example {
  margin-block: var(--example-margin-top);
  padding: 12px 16px;
  border-inline-start: 4px solid var(--physics-color-accent);
  background: var(--physics-color-example-bg);
}

.example-title {
  font-weight: bold;
  color: var(--physics-color-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 0.5em;
}

.example-prompt {
  font-weight: 500;
  margin-block-end: 0.5em;
}

.example-body {
  font-size: 0.95em;
  border-block-start: 1px solid rgb(46 125 143 / 30%);
  padding-block-start: 0.75em;
}

body.dark-mode .example {
  background: #17282e;
}

body.dark-mode .example-body {
  border-block-start-color: rgb(46 125 143 / 45%);
}

/* The deep-teal heading colour is unreadable on the dark plate — lift it. */
body.dark-mode .example-title {
  color: #8fd3e0;
}

/* End-of-chapter problems */
.problem {
  margin-block: 20px;
  padding: 12px 16px;
  border-inline-start: 4px solid var(--physics-color-problem);
  background: var(--physics-color-problem-bg);
}

.problem-title {
  font-weight: bold;
  color: var(--physics-color-problem);
  margin: 0 0 0.5em;
}

body.dark-mode .problem {
  background: #2a2116;
}

body.dark-mode .problem-title {
  color: #e3a866;
}

/* Solutions are hidden in the printed book (\showproblemsolutions is false)
   and stay collapsed here; book-viewer.js injects the toggle button and only
   typesets the body once the reader opens it. */
.solution {
  margin-block: 12px;
}

.solution > section {
  display: none;
  padding: 8px 12px;
  border: 1px dashed var(--physics-color-secondary);
  border-radius: 6px;
}

.solution.ui-solution-visible > section {
  display: block;
}

.solution .ui-toggle {
  background: none;
  border: 1px solid var(--physics-color-secondary);
  border-radius: 6px;
  color: var(--physics-color-primary);
  cursor: pointer;
  font: inherit;
  font-weight: bold;
  min-block-size: var(--touch-target-min);
  padding: 6px 14px;
}

.solution .ui-toggle:hover {
  background: var(--physics-color-example-bg);
}

body.dark-mode .solution .ui-toggle {
  border-color: #8fd3e0;
  color: #8fd3e0;
}

body.dark-mode .solution .ui-toggle:hover {
  background: #17282e;
}

/* \begin{detailedderivation} — an aside the author can switch off in print */
.derivation {
  margin-block: 16px;
  padding-inline-start: 16px;
  border-inline-start: 2px solid var(--physics-color-table-border);
}

/* Figures */
figure.figure-float,
figure.table-float {
  margin-block: 20px;
  text-align: center;
}

figure.figure-float figcaption,
figure.table-float figcaption {
  text-align: start;
  font-size: 0.925em;
  font-style: italic;
}

.figure-number,
.table-number {
  font-weight: bold;
  font-style: normal;
  margin-inline-end: 0.5em;
}

figure img {
  max-inline-size: 100%;
  block-size: auto;
}

/* The author sizes each diagram as a fraction of \textwidth (0.15 to 0.7).
   Honour that ratio, but floor it: 0.15 of a screen column is unreadable for
   raster line art that was drawn for a 6.5-inch printed measure. */
figure.figure-float img.figure-asset {
  inline-size: clamp(220px, var(--fig-width, 100%), 100%);
}

/* Tabular */
.tabular-wrap {
  overflow-x: auto;
}

table.tabular {
  border-collapse: collapse;
  margin-inline: auto;
  margin-block: 12px;
}

table.tabular td {
  padding: 4px 12px;
}

table.tabular td.align-center {
  text-align: center;
}

table.tabular td.align-right {
  text-align: right;
}

table.tabular tr.topline td {
  border-block-start: 1px solid currentColor;
}

table.tabular.bottomline tr:last-child td {
  border-block-end: 1px solid currentColor;
}

/* Verbatim listings (Appendix: numerical integration code) */
pre.code {
  overflow-x: auto;
  background: #fff7e0;
  border: 1px solid #e8d98a;
  border-radius: 4px;
  padding: 12px;
  font-size: 0.9em;
}

body.dark-mode pre.code {
  background: #2a2618;
  border-color: #6b5f2a;
}

/* Lists */
.item-label {
  font-weight: bold;
}

.desc-list {
  margin-block: 12px;
}

.desc-item dt {
  font-weight: bold;
}

.desc-item dd {
  margin-inline-start: 1.5em;
  margin-block-end: 0.75em;
}

/* Footnotes */
.footnotes {
  font-size: 0.875em;
  color: var(--color-secondary, #555);
  margin-block-start: 24px;
}

.footnote-back {
  text-decoration: none;
}

/* Sidebar TOC */
.book .book-summary ul.summary li.chapter > p {
  display: contents;
  margin: 0;
}

.book .book-summary ul.summary li.chapter > p > a {
  display: inline !important;
  font-size: 120%;
  white-space: normal;
}

/* Landing page */
.landing {
  max-inline-size: 720px;
  margin-inline: auto;
  padding: 1rem;
}

.landing .landing-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-block: 24px;
}

/* theme.css colours every in-page link via
   `.page-wrapper .page-inner section.normal a`, which outranks a plain
   `.landing a` — match that weight so the filled button keeps white text. */
.book .book-body .page-wrapper .page-inner .landing .landing-actions a,
.landing .landing-actions a {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 6px;
  background: var(--physics-color-primary);
  color: #fff;
  text-decoration: none;
  font-weight: bold;
}

.book .book-body .page-wrapper .page-inner .landing .landing-actions a.secondary,
.landing .landing-actions a.secondary {
  background: transparent;
  color: var(--physics-color-primary);
  border: 2px solid var(--physics-color-primary);
}

body.dark-mode .landing .landing-actions a.secondary {
  color: #8fd3e0;
  border-color: #8fd3e0;
}

.landing .chapter-list {
  list-style: none;
  padding-inline-start: 0;
}

.landing .chapter-list li {
  padding-block: 6px;
}

.chapter-sections ul {
  list-style: none;
  padding-inline-start: 0;
}

.chapter-sections li {
  padding-block: 4px;
}

.chapter-pdf {
  margin-block-start: 24px;
  padding: 12px;
  border: 1px dashed var(--physics-color-secondary);
  border-radius: 6px;
}

/* Cross-references */
.missing-ref {
  color: #b91c1c;
  border-block-end: 1px dotted #b91c1c;
}

.figure-missing {
  min-block-size: 80px;
  background: repeating-linear-gradient(
    -45deg,
    #f3f4f6,
    #f3f4f6 8px,
    #e5e7eb 8px,
    #e5e7eb 16px
  );
  border: 1px dashed #9ca3af;
  border-radius: 4px;
}

/* The author's diagrams are black line art on white; keep a light plate for
   them in dark mode instead of inverting to an unreadable smear. */
body.dark-mode figure img {
  background: #fff;
  border-radius: 4px;
  padding: 4px;
}

.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.smallcaps {
  font-variant: small-caps;
}

.center,
.centerline {
  text-align: center;
}

.flushleft {
  text-align: start;
}

.flushright {
  text-align: end;
}

.size-small {
  font-size: 0.9em;
}

.size-footnotesize,
.size-scriptsize,
.size-tiny {
  font-size: 0.85em;
}

.size-large {
  font-size: 1.1em;
}

.size-Large {
  font-size: 1.25em;
}

@media (max-width: 768px) {
  .book .book-body .navigation {
    min-inline-size: 48px;
    min-block-size: 48px;
  }
}
