/* Stronger selectors to beat Tailwind Typography.
   Sizes are mobile-first and step up at sm/md — these were previously fixed at
   the desktop size, so a 36px h1 on a 360px phone broke long headlines into
   four cramped lines. */
.prose.quill-content h1 {
  @apply text-2xl sm:text-3xl md:text-4xl font-bold my-4 !important;
  line-height: 1.2 !important;
}

.prose.quill-content h2 {
  @apply text-xl sm:text-2xl md:text-3xl font-bold my-3 !important;
  line-height: 1.25 !important;
}

.prose.quill-content h3 {
  @apply text-lg sm:text-xl md:text-2xl font-bold my-2 !important;
  line-height: 1.3 !important;
}

.prose.quill-content h4 {
  @apply text-base sm:text-lg md:text-xl font-semibold my-2 !important;
}

.prose.quill-content h5 {
  @apply text-lg font-semibold my-1 !important;
}

.prose.quill-content h6 {
  @apply text-base font-semibold my-1 !important;
}
.quill-content ul {
  list-style-type: disc;
  margin-left: 1.5rem;
  padding-left: 0;
}

.quill-content ol {
  list-style-type: decimal;
  margin-left: 1.5rem;
  padding-left: 0;
}

.quill-content li {
  margin-bottom: 0.5rem;
}

/* Image optimization for article content */
.quill-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
  border-radius: 0.5rem;
  /* Smooth loading transition */
  transition: opacity 0.3s ease-in-out;
  /* Prevent layout shift - images will maintain aspect ratio */
  object-fit: contain;
}

/* Ensure images don't cause horizontal overflow */
.quill-content {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.quill-content img {
  /* 100vw includes the scrollbar, so the old min(100%, 100vw - 3rem) could
     still overflow on desktop. The container already constrains width. */
  max-width: 100%;
}

/* Image alignment and text wrapping.
   Floats only apply from 640px up: a 50%-wide float on a 360px screen leaves
   text running down a ~150px gutter, which is unreadable. Below sm they stack. */
.quill-content img.ql-align-left,
.quill-content img.ql-align-right {
  float: none;
  display: block;
  margin: 1.5rem auto;
  max-width: 100%;
  height: auto;
}

@media (min-width: 640px) {
  .quill-content img.ql-align-left {
    float: left;
    margin: 0.5rem 1.5rem 0.5rem 0;
    max-width: 50%;
  }

  .quill-content img.ql-align-right {
    float: right;
    margin: 0.5rem 0 0.5rem 1.5rem;
    max-width: 50%;
  }
}

.quill-content img.ql-align-center {
  display: block;
  margin: 2rem auto;
  float: none;
}

.quill-content::after {
  content: "";
  display: table;
  clear: both;
}

/* Text alignment support */
.ql-align-center {
  text-align: center;
}

.ql-align-right {
  text-align: right;
}

.ql-align-justify {
  text-align: justify;
}

.ql-align-left {
  text-align: left;
}