/* Ocean From Motion — Online Book Styles */

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

:root {
  --max-width: 700px;
  --color-bg: #fafaf8;
  --color-text: #2c2c2c;
  --color-text-light: #666;
  --color-link: #1a5276;
  --color-link-hover: #0e3a56;
  --color-border: #ddd;
  --color-nav-bg: #f5f5f3;
  --color-accent: #1a5276;
}

html {
  font-size: 18px;
}

body {
  margin: 0;
  padding: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

/* ── Top Navigation ────────────────────────────────── */

header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-nav-bg);
}

.top-nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.nav-title {
  font-weight: bold;
  font-size: 1rem;
  text-decoration: none;
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.85rem;
}

.nav-links a {
  color: var(--color-link);
  text-decoration: none;
}

.nav-links a:hover {
  text-decoration: underline;
}

.download-link::before {
  content: "\2B73 ";
}

/* ── Main Content ──────────────────────────────────── */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.page-title {
  font-size: 1.8rem;
  margin: 0 0 0.25rem;
  line-height: 1.3;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--color-text-light);
  font-style: italic;
  margin: 0 0 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

h1 {
  font-size: 1.6rem;
  margin: 2.5rem 0 1rem;
  line-height: 1.3;
}

h2 {
  font-size: 1.3rem;
  margin: 2rem 0 0.75rem;
  line-height: 1.35;
}

h3 {
  font-size: 1.1rem;
  margin: 1.75rem 0 0.5rem;
  line-height: 1.4;
}

h4 {
  font-size: 1rem;
  margin: 1.5rem 0 0.5rem;
  line-height: 1.4;
}

p {
  margin: 0 0 1rem;
}

p.list-item {
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.math-display {
  margin: 1.25rem 0;
  text-align: center;
  overflow-x: auto;
}

strong {
  font-weight: bold;
}

em {
  font-style: italic;
}

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

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

/* ── Tables ────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

th, td {
  border: 1px solid var(--color-border);
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--color-nav-bg);
  font-weight: bold;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.85rem;
}

/* ── Bottom Navigation ─────────────────────────────── */

footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.85rem;
}

.nav-prev, .nav-toc, .nav-next {
  flex: 1;
}

.nav-toc {
  text-align: center;
}

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

.chapter-nav a {
  color: var(--color-link);
  text-decoration: none;
}

.chapter-nav a:hover {
  text-decoration: underline;
}

/* ── Cover / Index Page ────────────────────────────── */

.cover {
  text-align: center;
  padding-top: 3rem;
}

.book-title {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.book-subtitle {
  font-size: 1.15rem;
  color: var(--color-text-light);
  margin-bottom: 0.25rem;
}

.book-subtitle-secondary {
  font-size: 1rem;
  color: var(--color-text-light);
  margin-bottom: 2rem;
  line-height: 1.8;
}

.download-section {
  margin: 2rem 0 2.5rem;
}

.btn-download {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.9rem;
  transition: background 0.15s;
}

.btn-download:hover {
  background: var(--color-link-hover);
  color: #fff;
}

.toc {
  text-align: left;
  margin-top: 2rem;
}

.toc h2 {
  text-align: center;
  font-size: 1.4rem;
  margin-bottom: 1rem;
}

.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc ol li {
  margin: 0.3rem 0;
}

.toc ol li a {
  text-decoration: none;
  color: var(--color-link);
  font-size: 1rem;
  padding-left: 1rem;
}

.toc ol li a:hover {
  text-decoration: underline;
}

.toc ol li.part-header {
  font-weight: bold;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-light);
  margin: 1.25rem 0 0.35rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.toc ol li.part-header:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

/* ── Responsive ────────────────────────────────────── */

@media (max-width: 600px) {
  html {
    font-size: 16px;
  }

  .top-nav {
    padding: 0.5rem 1rem;
  }

  main {
    padding: 1.5rem 1rem 2rem;
  }

  footer {
    padding: 0 1rem 1.5rem;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .book-title {
    font-size: 2rem;
  }

  .chapter-nav {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }

  .nav-prev, .nav-toc, .nav-next {
    text-align: center;
  }

  table {
    font-size: 0.8rem;
  }

  th, td {
    padding: 0.35rem 0.5rem;
  }
}
