/* The Fourth Industrial Superintendent — Book Style */
@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #faf8f5;
  --text: #1a1a1a;
  --text-secondary: #555;
  --accent: #8b2500;
  --accent-light: #c04000;
  --sidebar-bg: #1a1a1a;
  --sidebar-text: #ccc;
  --sidebar-active: #fff;
  --sidebar-part: #e8a87c;
  --border: #e0dcd4;
  --code-bg: #f0ece4;
  --figure-bg: #f5f0e8;
  --max-width: 720px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Crimson Pro', 'Georgia', 'Times New Roman', serif;
  font-size: 19px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
#sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 2rem 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}

.nav-header {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid #333;
  margin-bottom: 1rem;
}

.nav-header h2 {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.nav-author {
  font-size: 0.8rem;
  color: #888;
  margin-top: 0.25rem;
  font-style: italic;
}

.nav-list {
  list-style: none;
}

.nav-list li a {
  display: block;
  padding: 0.5rem 1.5rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  line-height: 1.4;
  transition: all 0.15s;
}

.nav-list li a:hover {
  color: #fff;
  background: rgba(255,255,255,0.05);
}

.nav-list li.active a {
  color: var(--sidebar-active);
  background: rgba(255,255,255,0.08);
  border-left: 3px solid var(--accent-light);
  font-weight: 600;
}

.nav-part {
  padding: 1rem 1.5rem 0.3rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--sidebar-part);
}

.ch-num {
  display: inline-block;
  width: 1.6em;
  color: #777;
  font-weight: 400;
}

/* Main content */
main {
  flex: 1;
  margin-left: 300px;
  padding: 3rem 2rem 4rem;
  max-width: calc(var(--max-width) + 300px);
}

article {
  max-width: var(--max-width);
  margin: 0 auto;
}

.part-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

/* Typography */
h1 {
  font-family: 'Inter', sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

h2 {
  font-family: 'Inter', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
  margin: 2.5rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

h3 {
  font-family: 'Inter', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin: 2rem 0 0.75rem;
}

h4, h5, h6 {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

p {
  margin: 0 0 1.25rem;
  text-align: justify;
  hyphens: auto;
}

strong { font-weight: 600; }
em { font-style: italic; }

blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 3px solid var(--accent);
  background: var(--code-bg);
  font-style: italic;
}

/* Lists */
ul, ol {
  margin: 0 0 1.25rem 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

th, td {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  text-align: left;
}

th {
  background: var(--code-bg);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
}

/* Figures */
.figure-placeholder {
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--figure-bg);
  border: 1px dashed var(--border);
  border-radius: 4px;
  text-align: center;
}

.figure-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* HR */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* Chapter nav */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--max-width);
  margin: 3rem auto 0;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.chapter-nav a {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.chapter-nav a:hover {
  color: var(--accent-light);
}

/* Mobile menu button */
#menu-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--sidebar-bg);
  color: #fff;
  border: none;
  padding: 0.5rem 0.75rem;
  font-size: 1.5rem;
  border-radius: 4px;
  cursor: pointer;
}

/* Responsive */
@media (max-width: 900px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
  }
  main {
    margin-left: 0;
    padding: 4rem 1.5rem 3rem;
  }
  #menu-toggle {
    display: block;
  }
  h1 { font-size: 1.7rem; }
  h2 { font-size: 1.3rem; }
  body { font-size: 17px; }
}

@media (max-width: 600px) {
  main { padding: 3.5rem 1rem 2rem; }
  h1 { font-size: 1.5rem; }
  table { font-size: 0.8rem; }
  th, td { padding: 0.4rem; }
}

/* Print */
@media print {
  #sidebar, #menu-toggle, .chapter-nav { display: none; }
  main { margin-left: 0; }
  body { font-size: 11pt; }
}
