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

:root {
  --bg:        #f7f5f0;
  --bg-card:   #ffffff;
  --bg-detail: #fefefe;
  --text:      #1a1a1a;
  --muted:     #666;
  --light:     #aaa;
  --serif:     Georgia, 'Times New Roman', serif;
  --sans:      system-ui, -apple-system, sans-serif;
  --mono:      'SF Mono', 'Fira Mono', 'Consolas', monospace;
  --detail-w:  520px;
  --radius:    3px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Navigation ─────────────────────────────────────── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid #ddd;
  padding: 12px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

nav .site-title {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}

nav a.machines-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

nav a.machines-link:hover { color: var(--text); border-color: var(--text); }

nav span.nav-current {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  border-bottom: 1px solid var(--text);
}

/* ── Timeline layout ─────────────────────────────────── */
.timeline-outer {
  display: flex;
  padding-top: 52px;
}

/* Left spine */
.timeline-spine {
  width: 64px;
  flex-shrink: 0;
  position: relative;
}

.spine-svg {
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  width: 64px;
  pointer-events: none;
}

/* Center content */
.timeline-content {
  flex: 1;
  max-width: 700px;
  padding: 48px 40px 120px 8px;
}

/* ── Era headers ─────────────────────────────────────── */
.era-header {
  margin: 56px 0 8px;
  padding-bottom: 12px;
}

.era-header:first-child { margin-top: 0; }

.era-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.era-name {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: normal;
  line-height: 1.3;
}

.era-years {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

.era-question {
  font-style: italic;
  font-size: 13px;
  color: var(--muted);
}

/* ── Milestone cards ─────────────────────────────────── */
.milestone {
  position: relative;
  margin-bottom: 28px;
  scroll-margin-top: 72px;
}

.milestone-card {
  position: relative;
  background: var(--bg-card);
  padding: 24px 28px 20px;
  cursor: default;
  transition: box-shadow 0.2s;
}

.milestone-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.06); }

/* rough.js SVG overlay — injected by JS */
.rough-border {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.milestone-year {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--light);
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.milestone-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: normal;
  line-height: 1.3;
  margin-bottom: 4px;
}

.milestone-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  line-height: 1.5;
}

.milestone-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}

.tag {
  font-size: 11px;
  padding: 3px 8px;
  background: var(--bg);
  color: var(--muted);
  border-radius: 2px;
  font-family: var(--mono);
}

.dive-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-family: var(--sans);
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  letter-spacing: 0.04em;
  transition: color 0.15s;
}

.dive-btn:hover { color: var(--text); }
.dive-btn .arrow { transition: transform 0.2s; }
.dive-btn:hover .arrow { transform: translateX(4px); }

/* ── Detail panel ────────────────────────────────────── */
.detail-panel {
  position: fixed;
  top: 52px;
  right: 0;
  bottom: 0;
  width: var(--detail-w);
  max-width: 100vw;
  background: var(--bg-detail);
  border-left: 1px solid #e0ddd8;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 90;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.detail-panel.open { transform: translateX(0); }

.detail-panel-inner { padding: 28px 32px 64px; }

.detail-close {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-bottom: 24px;
  letter-spacing: 0.04em;
  font-family: var(--sans);
  transition: color 0.15s;
}

.detail-close:hover { color: var(--text); }

.detail-year {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--light);
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.detail-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: normal;
  line-height: 1.3;
  margin-bottom: 6px;
}

.detail-location {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 24px;
  font-style: italic;
}

/* Detail sections */
.detail-section { margin-bottom: 28px; }

.detail-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--light);
  margin-bottom: 8px;
  font-family: var(--sans);
}

.detail-section p {
  font-size: 14px;
  line-height: 1.7;
  color: #333;
}

.detail-machine-name {
  font-family: var(--serif);
  font-size: 16px;
  margin-bottom: 6px;
}

/* Code block */
.code-block {
  background: #f4f3ef;
  border-left: 3px solid #ddd;
  padding: 14px 16px;
  overflow-x: auto;
}

.code-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
  font-style: italic;
}

.code-block pre {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  color: #2a2a2a;
  white-space: pre;
}

/* People */
.people-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.person-chip {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--bg);
  border-radius: 2px;
  color: #444;
}

/* Links */
.links-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.links-list li a {
  font-size: 13px;
  color: #3a5a8a;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.links-list li a:hover { border-color: #3a5a8a; }

.links-list li.paper a { color: #555; font-style: italic; }

.detail-divider {
  border: none;
  border-top: 1px solid #e8e5e0;
  margin: 20px 0;
}

/* ── Machines page ───────────────────────────────────── */
.machines-page {
  padding-top: 52px;
}

.machines-header {
  padding: 40px 48px 24px;
  border-bottom: 1px solid #e8e5e0;
}

.machines-header h1 {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: normal;
  margin-bottom: 8px;
}

.machines-header p {
  font-size: 14px;
  color: var(--muted);
  max-width: 560px;
}

.machines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 32px;
  padding: 40px 48px 80px;
}

.machine-card {
  position: relative;
  background: var(--bg-card);
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.machine-card:hover { box-shadow: 0 3px 16px rgba(0,0,0,0.07); }

.machine-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: #ece9e3;
}

.machine-img-placeholder {
  width: 100%;
  aspect-ratio: 4/3;
  background: #ece9e3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.machine-img-placeholder span {
  font-size: 36px;
  opacity: 0.3;
}

.machine-card-body {
  padding: 16px 18px 14px;
}

.machine-card-year {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--light);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.machine-card-name {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: normal;
  margin-bottom: 4px;
}

.machine-card-location {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.machine-card-peak {
  font-size: 13px;
  color: #444;
}

/* Machine detail modal */
.machine-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(240, 238, 232, 0.85);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.machine-modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.machine-modal {
  background: var(--bg-card);
  max-width: 680px;
  width: calc(100% - 40px);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  padding: 40px;
}

.machine-modal-close {
  position: absolute;
  top: 16px; right: 20px;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--sans);
}

.machine-modal-img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  display: block;
  margin-bottom: 24px;
  background: #ece9e3;
}

.machine-modal h2 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: normal;
  margin-bottom: 4px;
}

.machine-modal-year {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--light);
  margin-bottom: 20px;
}

.machine-spec-row {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  font-size: 14px;
}

.machine-spec-key {
  width: 120px;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--light);
  padding-top: 2px;
  font-family: var(--sans);
}

.machine-spec-val { color: #333; line-height: 1.5; }

.machine-modal-link {
  display: inline-block;
  margin-top: 20px;
  font-size: 13px;
  color: #3a5a8a;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.machine-modal-link:hover { border-color: #3a5a8a; }

/* ── Misc ────────────────────────────────────────────── */
.era-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

/* Swipe hint on mobile */
@media (max-width: 600px) {
  .timeline-content { padding: 32px 20px 80px 8px; }
  .detail-panel { width: 100vw; }
  .machines-grid { grid-template-columns: 1fr 1fr; gap: 16px; padding: 24px 20px 60px; }
  .machines-header { padding: 24px 20px 20px; }
  nav { padding: 12px 20px; }
  .timeline-spine { width: 36px; }
}

@media (max-width: 400px) {
  .machines-grid { grid-template-columns: 1fr; }
}
