/* ByteByteGo Book Engine - Artisanal Print & Publication Typesetting */

@import url('theme-engine.css');
@import url('code-engine.css');

/* ==========================================================================
   1. PAGE GEOMETRY & PRINT SPECIFICATIONS
   ========================================================================== */
@page {
  size: 7in 10in; /* Standard Technical Crown Quarto / Trade */
  margin: 22mm 18mm 24mm 22mm; /* Inside gutter for binding */
  @bottom-center {
    content: counter(page);
    font-family: 'JetBrains Mono', monospace;
    font-size: 9pt;
    color: #64748B;
  }
}

@page :left {
  margin-left: 20mm;
  margin-right: 24mm;
  @top-left {
    content: string(book-title);
    font-family: 'Lexica Ultralegible', sans-serif;
    font-size: 8pt;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94A3B8;
  }
}

@page :right {
  margin-left: 24mm;
  margin-right: 20mm;
  @top-right {
    content: string(chapter-title);
    font-family: 'Lexica Ultralegible', sans-serif;
    font-size: 8pt;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94A3B8;
  }
}

/* ==========================================================================
   2. SCREEN PREVIEW CONTAINER (Tactile Book Reader Mode)
   ========================================================================== */
body.book-mode {
  background: #0B0F19;
  color: #0F172A;
  margin: 0;
  padding: 40px 0 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: 'Lexica Ultralegible', -apple-system, sans-serif;
}

.book-toolbar {
  position: sticky;
  top: 16px;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  margin-bottom: 30px;
}

.book-toolbar-title {
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
}

.book-toolbar-btn {
  background: #00BA83;
  color: #FFFFFF;
  border: none;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.book-toolbar-btn:hover {
  background: #009E6F;
  transform: translateY(-1px);
}

.book-toolbar-btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #E2E8F0;
}

.book-toolbar-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* The Compiled Book Volume */
.book-volume {
  width: 100%;
  max-width: 820px;
  background: #FFFFFF;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  border-radius: 8px;
  overflow: hidden;
  box-sizing: border-box;
}

/* ==========================================================================
   3. FRONT MATTER (Covers, Title Page, Colophon, TOC)
   ========================================================================== */
/* Full Page Book Cover */
.book-front-cover {
  width: 100%;
  min-height: 1050px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 64px 54px;
  box-sizing: border-box;
  page-break-after: always;
  break-after: page;
}

.book-front-cover .cover-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.9;
}

.book-front-cover .cover-main-title {
  font-size: 46px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 24px 0 12px;
  text-transform: uppercase;
}

.book-front-cover .cover-subtitle {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.book-front-cover .cover-graphic {
  margin: 60px 0;
  display: flex;
  justify-content: center;
}

.book-front-cover .cover-graphic svg {
  width: 240px;
  height: 240px;
}

.book-front-cover .cover-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding-top: 20px;
}

.book-front-cover .cover-author {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Cover Colorway Themes */
.cover-sdi-1 {
  background: linear-gradient(145deg, #0F172A 0%, #070B14 100%) !important;
  color: #FFFFFF !important;
  border-top: 6px solid #00BA83 !important;
}
.cover-sdi-1 .cover-main-title { color: #FFFFFF !important; }
.cover-sdi-1 .cover-subtitle { color: #00BA83 !important; }

.cover-sdi-2 {
  background: linear-gradient(145deg, #7C2D12 0%, #451A03 100%) !important;
  color: #FBF0D9 !important;
  border-top: 6px solid #F97316 !important;
}
.cover-sdi-2 .cover-subtitle { color: #FDBA74 !important; }

.cover-ml {
  background: linear-gradient(145deg, #064E3B 0%, #022C22 100%) !important;
  color: #ECFDF5 !important;
  border-top: 6px solid #10B981 !important;
}
.cover-ml .cover-subtitle { color: #6EE7B7 !important; }

.cover-genai {
  background: linear-gradient(145deg, #1E1B4B 0%, #0F0E2A 100%) !important;
  color: #F5F3FF !important;
  border-top: 6px solid #8B5CF6 !important;
}
.cover-genai .cover-subtitle { color: #C4B5FD !important; }

.cover-coding {
  background: linear-gradient(145deg, #FAF8F5 0%, #ECE8E1 100%) !important;
  color: #18181B !important;
  border-top: 6px solid #DC2626 !important;
}
.cover-coding .cover-subtitle { color: #DC2626 !important; }
.cover-coding .cover-footer { border-color: rgba(0, 0, 0, 0.15) !important; }

.cover-ood {
  background: linear-gradient(145deg, #0B2545 0%, #031224 100%) !important;
  color: #F0F9FF !important;
  border-top: 6px solid #0284C7 !important;
}
.cover-ood .cover-subtitle { color: #38BDF8 !important; }

.cover-mobile {
  background: linear-gradient(145deg, #1E293B 0%, #0F172A 100%) !important;
  color: #F8FAFC !important;
  border-top: 6px solid #3B82F6 !important;
}
.cover-mobile .cover-subtitle { color: #60A5FA !important; }

.cover-resume {
  background: linear-gradient(145deg, #271810 0%, #150C08 100%) !important;
  color: #FEF3C7 !important;
  border-top: 6px solid #D97706 !important;
}
.cover-resume .cover-subtitle { color: #FBBF24 !important; }

/* Interior Pages Padding */
.book-page-wrap {
  padding: 64px 72px 80px;
}

/* Half Title & Formal Title Pages */
.book-half-title,
.book-title-page,
.book-colophon,
.book-epigraph,
.book-toc {
  page-break-after: always;
  break-after: page;
}

.book-title-page {
  text-align: center;
  padding: 120px 40px 60px;
}

.book-title-page h1 {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.book-title-page .sub {
  font-size: 16px;
  font-weight: 600;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 80px;
}

.book-title-page .author {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 120px;
}

.book-title-page .publisher {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #00BA83;
}

/* Colophon (Micro-typography) */
.book-colophon {
  font-size: 9pt;
  line-height: 1.6;
  color: #64748B;
  padding-top: 140px;
}

.book-colophon h4 {
  font-size: 11pt;
  color: #0F172A;
  margin-bottom: 8px;
}

/* Epigraph */
.book-epigraph {
  padding: 180px 40px;
  text-align: center;
  font-style: italic;
  font-size: 14pt;
  color: #334155;
  line-height: 1.7;
}

.book-epigraph .cite {
  font-style: normal;
  font-size: 10pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748B;
  margin-top: 16px;
  display: block;
}

/* Table of Contents with Dot Leaders */
.book-toc {
  margin-bottom: 40px;
}

.book-toc h2 {
  font-size: 22pt;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  border-bottom: 2px solid #0F172A;
  padding-bottom: 12px;
  margin-bottom: 24px;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 11pt;
}

.toc-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.toc-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10pt;
  font-weight: 700;
  color: #00BA83;
  width: 24px;
  flex-shrink: 0;
}

.toc-title {
  font-weight: 600;
  color: #0F172A;
  text-decoration: none;
}

.toc-dots {
  flex-grow: 1;
  border-bottom: 1px dotted #CBD5E1;
  margin: 0 8px;
  min-width: 20px;
}

.toc-page {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10pt;
  color: #64748B;
  flex-shrink: 0;
}

/* ==========================================================================
   4. CHAPTERS & INTERIOR TYPESETTING
   ========================================================================== */
.book-chapter {
  page-break-before: always;
  break-before: page;
  padding-top: 40px;
  margin-bottom: 60px;
}

.chapter-opener {
  margin-bottom: 36px;
  border-bottom: 1px solid #E2E8F0;
  padding-bottom: 24px;
}

.chapter-number-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 38pt;
  font-weight: 900;
  color: #00BA83;
  line-height: 1;
  letter-spacing: -0.04em;
  margin-bottom: 12px;
  display: block;
}

.chapter-headline {
  font-size: 26pt;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.025em;
  color: #0F172A;
  margin: 0;
}

/* Article Typography for Book Print */
.book-chapter h2 {
  font-size: 16pt;
  font-weight: 700;
  margin-top: 36px;
  margin-bottom: 12px;
  page-break-after: avoid;
  break-after: avoid;
}

.book-chapter h3 {
  font-size: 13pt;
  font-weight: 700;
  margin-top: 24px;
  margin-bottom: 8px;
  page-break-after: avoid;
  break-after: avoid;
}

.book-chapter p {
  font-size: 10.5pt;
  line-height: 1.7;
  color: #1E293B;
  margin-bottom: 16px;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

.book-chapter ul, .book-chapter ol {
  font-size: 10.5pt;
  line-height: 1.6;
  margin-bottom: 16px;
  padding-left: 22px;
}

.book-chapter li {
  margin-bottom: 6px;
}

/* High-Contrast Technical Diagrams */
.diagram-figure {
  margin: 28px 0;
  padding: 16px;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  text-align: center;
  page-break-inside: avoid;
  break-inside: avoid;
}

.diagram-figure img {
  max-width: 100%;
  max-height: 480px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.diagram-figure figcaption {
  font-size: 9.5pt;
  font-weight: 600;
  color: #64748B;
  margin-top: 10px;
}

/* Code Snippets for Book Print */
.code-block-card {
  page-break-inside: avoid;
  break-inside: avoid;
  margin: 20px 0;
  border: 1px solid #CBD5E1;
  background: #F8FAFC;
}

.code-header {
  background: #EDF2F7;
  padding: 4px 10px;
}

.code-pane pre {
  padding: 12px 14px;
  font-size: 9pt;
  line-height: 1.5;
  color: #0F172A;
}

/* Print Overrides */
@media print {
  body.book-mode {
    background: #FFFFFF !important;
    padding: 0 !important;
  }

  .book-toolbar {
    display: none !important;
  }

  .book-volume {
    box-shadow: none !important;
    border-radius: 0 !important;
    max-width: 100% !important;
  }

  .book-front-cover {
    height: 100vh !important;
    min-height: 100vh !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
