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

body {
  font-family: Arial, Helvetica, sans-serif;
  background-color: #f4f4f4; /* Light gray background for contrast */
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  padding: 2rem 0;
  counter-reset: page;
}

/* Paper container */
.paper-container {
  display: flex;
  flex-direction: column;
  gap: 2rem; /* Space between pages */
  align-items: center;
  width: 100%;
}

/* A4 Paper styling */
.a4-paper {
  background-color: white;
  width: 210mm; /* A4 paper width */
  height: 297mm; /* Fixed A4 paper height */
  padding: 2rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.1);
  border: 1px solid #ddd; /* Subtle border for realism */
  margin: 1rem 0;
  position: relative;
  overflow: hidden; /* Prevent content from spilling */
  counter-increment: page;
}

/* Page Numbers */
.a4-paper::after {
  content: "Page " counter(page);
  position: absolute;
  bottom: 1rem;
  right: 2rem;
  font-size: 12px;
  color: #999;
}

/* Content Block to keep headings and paragraphs/lists together */
.content-block {
  margin-bottom: 1rem; /* Add some space between blocks */
  page-break-inside: avoid; /* Prevent splitting within the block */
  break-inside: avoid; /* Modern syntax for avoiding breaks */
}

/* Headings */
.a4-paper h1,
.a4-paper h2 {
  font-size: 1.75rem;
  line-height: 2.2rem;
  color: #222;
  margin-bottom: 1rem;
  page-break-after: avoid; /* Prevent heading splitting */
}

.a4-paper h2 {
  font-size: 1.5rem;
  line-height: 2rem;
  color: #333;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}

/* Paragraphs */
.a4-paper p {
  margin-bottom: 1rem;
  line-height: 1.6; /* Adjusted for better spacing */
  color: #555;
  font-size: 14px; /* Realistic paper text size */
  text-align: justify;
  page-break-inside: avoid; /* Prevent splitting paragraphs */
  break-inside: avoid;
}

/* Lists */
.a4-paper ul,
.a4-paper ol {
  margin: 1rem 0;
  padding-left: 1.5rem; /* Indentation for bullets */
  list-style-type: disc; /* Default bullet style */
}

.a4-paper li {
  margin-bottom: 0.5rem; /* Spacing between list items */
  line-height: 1.6; /* Match paragraph line height */
  color: #555; /* Match paragraph color */
  font-size: 14px; /* Match paragraph font size */
  text-align: justify; /* Align text for clean look */
  page-break-inside: avoid; /* Prevent list items from breaking */
  break-inside: avoid;
}

/* Responsive Design */
@media (max-width: 768px) {
  .a4-paper {
    width: 90%; /* Adjust width for smaller screens */
    padding: 1rem; /* Reduce padding */
    font-size: 16px; /* Slightly larger text for small screens */
    line-height: 1.8;
  }
}

/* Print Styles */
@media print {
  body {
    background: none;
  }

  .a4-paper {
    box-shadow: none;
    border: none;
    margin: 0;
    page-break-after: always; /* Force new page for printing */
    break-after: page; /* Modern page break */
  }

  .a4-paper::after {
    content: none; /* Remove page numbers in print */
  }

  /* Ensure content-blocks do not split during printing */
  .content-block,
  .a4-paper h1,
  .a4-paper h2,
  .a4-paper p,
  .a4-paper li {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}
