/* ==========================================================
   The ChatML Handbook – Enhanced EPUB Styles
   Author: Ranjan Kumar
   Version: 1.2
   Target: Quarto EPUB / Kindle / Kobo
   ========================================================== */

/* ------------------------------
   Global Layout
------------------------------ */
body {
  font-family: "Georgia", "Times New Roman", serif;
  line-height: 1.6;
  font-size: 1em;
  margin: 0 7%;
  color: #222;
  background: #fff;
}

/* ------------------------------
   Headings
------------------------------ */
h1, h2, h3, h4, h5 {
  font-family: "Helvetica Neue", Arial, sans-serif;
  color: #003366;
  font-weight: 700;
  margin-top: 1.8em;
  margin-bottom: 0.7em;
}

h1 {
  font-size: 1.8em;
  border-bottom: 3px solid #00509e;
  padding-bottom: 0.4em;
}
h2 {
  font-size: 1.5em;
  border-left: 4px solid #0077cc;
  padding-left: 0.5em;
}
h3 {
  font-size: 1.25em;
  color: #0a3d62;
}

/* ------------------------------
   Links
------------------------------ */
a {
  color: #0077cc;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ------------------------------
   Paragraphs & Lists
------------------------------ */
p, ul, ol {
  margin-top: 0.4em;
  margin-bottom: 0.8em;
}

li {
  margin-bottom: 0.4em;
}

/* ------------------------------
   Code Blocks & ChatML Highlighting
------------------------------ */
pre, code {
  font-family: "JetBrains Mono", "Courier New", monospace;
  background: #f7f9fb;
  border: 1px solid #e0e6ef;
  border-radius: 5px;
}

code {
  padding: 0.1em 0.3em;
}

pre {
  padding: 0.8em;
  overflow-x: auto;
  font-size: 0.95em;
  line-height: 1.4;
}

/* ChatML syntax highlight */
code.language-chatml {
  background: #eef5ff;
  border-left: 4px solid #007bff;
  display: block;
  padding: 0.8em;
  color: #003366;
  white-space: pre-wrap;
}

/* Highlight <|im_start|> and <|im_end|> visually */
.language-chatml span.im-start {
  color: #00509e;
  font-weight: bold;
}
.language-chatml span.im-end {
  color: #cc0000;
  font-weight: bold;
}

/* ------------------------------
   Tables
------------------------------ */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.95em;
}

th, td {
  border: 1px solid #ccc;
  padding: 0.6em;
}

th {
  background-color: #f0f4f8;
  text-align: left;
}

/* ------------------------------
   Notes, Tips, and Warnings
------------------------------ */
div.note, div.tip, div.warning {
  border-left: 5px solid #0077cc;
  background: #f8fbff;
  padding: 0.8em 1em;
  margin: 1em 0;
  border-radius: 4px;
}

div.tip {
  border-color: #00b894;
  background: #f2fff9;
}

div.warning {
  border-color: #e17055;
  background: #fff6f5;
}

/* ------------------------------
   Blockquotes
------------------------------ */
blockquote {
  border-left: 4px solid #0077cc;
  background: #f8f9fc;
  margin: 1em 2em;
  padding: 0.6em 1em;
  font-style: italic;
  color: #444;
}

/* ------------------------------
   Figures & Images
------------------------------ */
figure, img {
  display: block;
  margin: 1.5em auto;
  max-width: 95%;
}

figcaption {
  text-align: center;
  font-size: 0.9em;
  color: #555;
}

/* ------------------------------
   Footer
------------------------------ */
footer {
  text-align: center;
  font-size: 0.85em;
  color: #666;
  margin-top: 3em;
  border-top: 1px solid #ddd;
  padding-top: 1em;
}

/* ------------------------------
   Page Breaks (for EPUB/PDF)
------------------------------ */
.page-break {
  page-break-before: always;
  margin-top: 2em;
}

/* ------------------------------
   Advertisement Styles
------------------------------ */

/* Sidebar Ad */
.sidebar-ad {
  margin: 1.5rem 0;
  padding: 1rem;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
}

.sidebar-ad .ad-content {
  text-align: center;
}

/* After Content Ad */
.after-content-ad {
  margin: 2rem 0 1rem 0;
  padding: 0;
}

.after-content-ad .ad-separator {
  height: 1px;
  background: linear-gradient(to right, transparent, #dee2e6, transparent);
  margin-bottom: 1.5rem;
}

.after-content-ad .ad-content {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
}

/* Ad Labels */
.ad-label {
  font-size: 0.75rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

/* Placeholder Ad Styles (remove when using real ads) */
.ad-placeholder {
  padding: 1rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 6px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.ad-placeholder-wide {
  min-height: 200px;
}

.ad-placeholder h4 {
  color: white;
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.ad-placeholder p {
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 1rem;
}

.ad-link, .ad-button {
  display: inline-block;
  padding: 0.5rem 1.5rem;
  background: white;
  color: #667eea;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.ad-link:hover, .ad-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  text-decoration: none;
}

/* Dark mode support */
.quarto-dark .sidebar-ad,
.quarto-dark .after-content-ad .ad-content {
  background: #2b2b2b;
  border-color: #444;
}

.quarto-dark .ad-label {
  color: #adb5bd;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .sidebar-ad {
    margin: 1rem 0;
    padding: 0.75rem;
  }

  .after-content-ad .ad-content {
    padding: 1rem;
  }

  .ad-placeholder {
    min-height: 100px;
  }

  .ad-placeholder-wide {
    min-height: 150px;
  }
}
