/* ==========================================================================
   Magazine Spread Layout, Crisp Slide/Flip Animation & Continuous Scroll Mode
   ========================================================================== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 54px;
  background: var(--bg-chrome);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 12px;
  z-index: 40;
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-center { flex: 1; max-width: 480px; }

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 13px;
  white-space: nowrap;
}
.brand-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary);
}
.brand-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-glow);
  color: var(--accent-primary);
  font-weight: 600;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
}
.icon-btn:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.icon-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}
.divider-v { width: 1px; height: 22px; background: var(--border-subtle); margin: 0 2px; }

/* SEARCH BAR */
.search-shell { position: relative; width: 100%; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
#search-input {
  width: 100%;
  height: 34px;
  padding: 0 34px 0 32px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
}
#search-input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 11px; color: var(--text-muted);
  background: var(--bg-elevated); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border-subtle);
}
.search-dropdown {
  position: absolute; top: 40px; left: 0; right: 0;
  max-height: 360px; overflow-y: auto;
  background: var(--bg-chrome); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); box-shadow: 0 16px 36px rgba(0,0,0,0.45);
  z-index: 60;
}
.search-item {
  padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); cursor: pointer;
}
.search-item:hover { background: var(--bg-elevated); }
.search-item-head { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; color: var(--accent-primary); }
.search-item-snippet { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }

/* STAGE & MAGAZINE SPREAD */
.book-stage {
  position: fixed;
  top: 54px; bottom: 44px; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 52px;
  overflow: hidden;
}

.spread-viewport {
  width: 100%;
  height: 100%;
  max-width: 1460px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-container {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-page);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px var(--spine-shadow);
  overflow: hidden;
  position: relative;
}

/* Central Book Spine Effect */
.book-container::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 28px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(0,0,0,0.22) 48%, rgba(255,255,255,0.06) 50%, rgba(0,0,0,0.22) 52%, transparent);
  pointer-events: none;
  z-index: 5;
}

/* Crisp Slide/Flip Transition */
.book-container.flip-next { animation: slideNext 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
.book-container.flip-prev { animation: slidePrev 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes slideNext {
  0% { opacity: 0.45; transform: translateX(18px) scale(0.992); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes slidePrev {
  0% { opacity: 0.45; transform: translateX(-18px) scale(0.992); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}

.magazine-page {
  height: 100%;
  padding: 26px 32px 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-y: auto;
  border-right: 1px solid var(--border-subtle);
}
.magazine-page:last-child { border-right: none; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.page-body { flex: 1; display: flex; flex-direction: column; gap: 14px; }

.page-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.page-title {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.22;
  margin: 2px 0 4px;
  color: var(--text-primary);
}

.page-lead {
  font-size: 13.5px;
  line-height: 1.58;
  color: var(--text-secondary);
  margin: 0;
}

.page-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  margin-top: 12px;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* Spec Cards & Parameter Tables */
.spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.spec-card {
  background: var(--bg-page-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 11px 13px;
}
.spec-card h4 { margin: 0 0 4px; font-size: 13px; color: var(--text-primary); }
.spec-card p { margin: 0; font-size: 12px; line-height: 1.48; color: var(--text-secondary); }
.mono-chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--accent-secondary);
}

.cad-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.cad-table th {
  text-align: left;
  padding: 7px 9px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-strong);
  font-weight: 600;
}
.cad-table td {
  padding: 7px 9px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: top;
}

/* Video Walkthrough Card */
.video-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  background: linear-gradient(135deg, var(--bg-page-alt), var(--bg-elevated));
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent-primary);
  border-radius: var(--radius-md);
}
.video-callout-info strong { display: block; font-size: 12.5px; color: var(--text-primary); }
.video-callout-info span { font-size: 11.5px; color: var(--text-muted); }
.btn-watch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--accent-primary);
  color: #06131c;
  font-weight: 700;
  font-size: 12px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}
.btn-watch:hover { filter: brightness(1.1); }

/* Edge Navigation Arrows */
.edge-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 68px;
  background: var(--bg-chrome);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 30;
  transition: var(--transition);
}
.edge-nav:hover:not(:disabled) { border-color: var(--accent-primary); color: var(--accent-primary); }
.edge-nav:disabled { opacity: 0.28; cursor: not-allowed; }
.edge-prev { left: 8px; }
.edge-next { right: 8px; }

/* CONTINUOUS SCROLL MODE */
.book-stage.mode-scroll {
  position: relative;
  top: 54px;
  bottom: auto;
  height: auto;
  min-height: calc(100vh - 98px);
  padding: 24px 20px 68px;
  overflow-y: visible;
}
.book-stage.mode-scroll .edge-nav { display: none; }
.book-stage.mode-scroll .book-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: transparent;
  border: none;
  box-shadow: none;
  max-width: 920px;
}
.book-stage.mode-scroll .book-container::after { display: none; }
.book-stage.mode-scroll .magazine-page {
  background: var(--bg-page);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px var(--spine-shadow);
  height: auto;
  overflow: visible;
}

/* BOTTOM BAR */
.bottombar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 44px;
  background: var(--bg-chrome);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 16px;
  z-index: 40;
}
.bottom-left, .bottom-right { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.bottom-center { flex: 1; max-width: 420px; }
#page-scrubber { width: 100%; accent-color: var(--accent-primary); cursor: pointer; }
.chapter-pill {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 4px; background: var(--accent-glow); color: var(--accent-primary);
}
.section-title { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-counter { font-family: var(--font-mono); color: var(--text-muted); }

/* DRAWER & MODALS */
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: 320px;
  background: var(--bg-chrome); border-right: 1px solid var(--border-strong);
  transform: translateX(-100%); transition: transform 0.25s ease;
  z-index: 70; display: flex; flex-direction: column; padding: 18px;
}
.drawer.open { transform: translateX(0); }
.drawer-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 14px; border-bottom: 1px solid var(--border-subtle); }
.drawer-header h2 { margin: 2px 0 0; font-size: 17px; }
.drawer-eyebrow, .drawer-label { font-family: var(--font-mono); font-size: 10.5px; color: var(--accent-primary); letter-spacing: 0.08em; }
.drawer-section { padding: 14px 0; border-bottom: 1px solid var(--border-subtle); }
.bookmarks-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.empty-note { font-size: 12px; color: var(--text-muted); }
.toc-nav { flex: 1; overflow-y: auto; padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.toc-item {
  text-align: left; padding: 9px 11px; background: var(--bg-page-alt);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  color: var(--text-primary); cursor: pointer; font-size: 12.5px;
}
.toc-item:hover, .toc-item.active { border-color: var(--accent-primary); background: var(--accent-glow); }
.toc-item small { display: block; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }

.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 65; }
.hidden { display: none !important; }

.modal {
  position: fixed; inset: 0; background: rgba(8, 10, 14, 0.88);
  backdrop-filter: blur(6px); z-index: 90;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-toolbar {
  width: 100%; max-width: 1280px; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--bg-chrome); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.modal-title-group h3 { margin: 2px 0 0; font-size: 15px; }
.modal-badge { font-family: var(--font-mono); font-size: 10px; color: var(--accent-secondary); letter-spacing: 0.08em; }
.modal-controls { display: flex; align-items: center; gap: 8px; }
.zoom-readout { font-family: var(--font-mono); font-size: 12px; min-width: 48px; text-align: center; }
.lightbox-canvas {
  width: 100%; max-width: 1280px; flex: 1; background: var(--svg-bg);
  border-left: 1px solid var(--border-strong); border-right: 1px solid var(--border-strong);
  overflow: hidden; display: flex; align-items: center; justify-content: center; cursor: grab;
}
.lightbox-stage { transition: transform 0.12s ease-out; width: 92%; max-width: 1080px; }
.lightbox-caption {
  width: 100%; max-width: 1280px; padding: 10px 16px;
  background: var(--bg-chrome); border: 1px solid var(--border-strong);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-size: 12.5px; color: var(--text-secondary);
}

.modal-card {
  width: 100%; max-width: 860px; background: var(--bg-chrome);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg); overflow: hidden;
}
.modal-card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border-subtle);
}
.modal-card-header h3 { margin: 2px 0 0; font-size: 16px; }
.hotkey-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 18px; }
.hk-group h4 { margin: 0 0 10px; font-size: 12.5px; color: var(--accent-primary); text-transform: uppercase; letter-spacing: 0.05em; }
.hk-row { display: flex; flex-direction: column; gap: 3px; padding: 7px 0; border-bottom: 1px solid var(--border-subtle); font-size: 12px; color: var(--text-secondary); }
.hk-row kbd { align-self: flex-start; font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 4px; color: var(--text-primary); }

.video-card { max-width: 920px; }
.video-frame-wrap { position: relative; padding-bottom: 56.25%; height: 0; background: #000; }
.video-frame-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; }

/* RESPONSIVE TABLET PORTRAIT BREAKPOINT (<1024px -> SINGLE PAGE SPREAD) */
@media (max-width: 1024px) {
  .book-container { grid-template-columns: 1fr; max-width: 720px; }
  .book-container::after { display: none; }
  .btn-label { display: none; }
  .hotkey-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .book-stage { padding: 10px 12px; }
  .edge-nav { width: 30px; height: 50px; }
  .spec-grid { grid-template-columns: 1fr; }
}
