/* Fixes font and display issues in edit forms */
.node-form .placeholder {
  display: inline;
  min-height: inherit;
  vertical-align: inherit;
  cursor: none;
  background-color: transparent;
  opacity: 1;
}

.node-form legend {
  font-size: inherit;
}

.node-form .form-select {
  width: inherit;
}

/* Center aligns caption in left and right aligned media */
.align-right .blazy__caption, 
.align-left .blazy__caption,
.align-center .blazy__caption {
  text-align: center;
}

/* Center alignment for media on rendered pages */
.align-center {
  float: none !important;
  clear: both;
  margin-right: auto !important;
  margin-left: auto !important;
}

/* Center the image inside the aligned media wrapper */
.align-center img {
  display: block;
  margin-right: auto;
  margin-left: auto;
}

/* Center alignment for media within CKEditor */
.ck-content .align-center,
.ck-content .drupal-media-style-align-center {
  float: none !important;
  clear: both;
  margin-right: auto !important;
  margin-left: auto !important;
}

/* Center the image within CKEditor */
.ck-content .align-center img,
.ck-content .drupal-media-style-align-center img {
  display: block;
  margin-right: auto;
  margin-left: auto;
}

/* Left alignment for media within CKEditor */
.ck-content .drupal-media-style-align-left {
  float: left;
  margin-right: 1.5rem !important;
}

/* Right alignment for media within CKEditor */
.ck-content .drupal-media-style-align-right {
  float: right;
  margin-left: 1.5rem !important;
}

/* Fix for video thumbnail in edit form */
.ck .drupal-media {
  display: block;
}

.ck .media--bundle--remote-video img {
  position: relative;
}

.ck .media--bundle--remote-video .media__icon--litebox {
  position: absolute;
  top: 50%;
  left: 50%;
}

/* Responsive alignment adjustments for media on larger screens */
@media (min-width: 576px) {
  .align-right {
    max-width: 50%;
    clear: both;
    margin-left: 20px;
    float: right;
    padding-top: 0;
  }
  
  .align-left {
    max-width: 50%;
    clear: both;
    margin-right: 20px;
    float: left;
    padding-top: 0;
  }
}

/* Embedded media uses the same wrap/break behavior in previews and pages.
 * Keep natural image/view-mode sizing within the available column. */
.text-formatted .align-center,
.ck-content :is(.align-center, .drupal-media-style-align-center, .drupal-media-style-align-left, .drupal-media-style-align-right) {
  max-width: 50%;
}
/* Drupal's rendered preview can itself contain an alignment wrapper. Only
 * the editor figure floats; otherwise gaps and percentage limits apply twice. */
.ck-content figure.drupal-media :is(.align-left, .align-right, .align-center) {
  float: none !important;
  clear: none;
  max-width: none !important;
  width: auto !important;
  margin-inline: 0 !important;
}
/* Break-text previews also follow the selected image's intrinsic dimensions. */
.ck-content figure.drupal-media:has(img):not(:has(.field--name-field-media-oembed-video, .media--bundle--remote-video)):not(.drupal-media-style-align-left):not(.drupal-media-style-align-right):not(.drupal-media-style-align-center) {
  display: block !important;
  width: fit-content !important;
  max-width: 100%;
}
/* Shrink small styles to their image rather than reserving half a column.
 * Captions wrap within that width; larger styles retain the column limit. */
.ck-content figure.drupal-media:is(.drupal-media-style-align-left, .drupal-media-style-align-right, .drupal-media-style-align-center) {
  display: block !important;
  width: fit-content !important;
}
.text-formatted :is(.align-left, .align-right, .align-center) {
  width: fit-content;
}
.ck-content figure.drupal-media:has(img) :is(.blazy__caption, figcaption),
.text-formatted :is(.align-left, .align-right, .align-center) :is(.blazy__caption, figcaption) {
  width: 0;
  min-width: 100%;
  box-sizing: border-box;
  overflow-wrap: anywhere;
}
@media (max-width: 575px) {
  .text-formatted :is(.align-left, .align-right, .align-center),
  .ck-content :is(.align-left, .align-right, .align-center, .drupal-media-style-align-left, .drupal-media-style-align-right, .drupal-media-style-align-center) {
    float: none !important;
    clear: both;
    max-width: 100%;
    margin-inline: auto !important;
  }
}

/* Video posters and oEmbed players have out-of-flow children, so they cannot
 * use the image widget's shrink-to-fit sizing. Reserve an explicit width. */
.ck-content figure.drupal-media:has(.field--name-field-media-oembed-video, .media--bundle--remote-video) {
  display: block !important;
  width: var(--acton-video-preview-width, 1200px) !important;
  max-width: 100%;
}
.ck-content figure.drupal-media:has(.field--name-field-media-oembed-video, .media--bundle--remote-video):is(.drupal-media-style-align-left, .drupal-media-style-align-right, .drupal-media-style-align-center) {
  max-width: 50%;
}
.text-formatted :is(.align-left, .align-right, .align-center):has(.field--name-field-media-oembed-video, .media--bundle--remote-video) {
  width: var(--acton-video-preview-width, 1200px);
}
.ck-content figure.drupal-media[data-view-mode*="250"],
.text-formatted :is(.align-left, .align-right, .align-center):has([class*="--portrait-250"], [class*="--square-250"]) { --acton-video-preview-width: 250px; }
.ck-content figure.drupal-media[data-view-mode*="560"],
.text-formatted :is(.align-left, .align-right, .align-center):has([class*="--small-560"]) { --acton-video-preview-width: 560px; }
.ck-content figure.drupal-media[data-view-mode*="768"],
.text-formatted :is(.align-left, .align-right, .align-center):has([class*="--medium-768"]) { --acton-video-preview-width: 768px; }
.ck-content figure.drupal-media[data-view-mode*="992"],
.text-formatted :is(.align-left, .align-right, .align-center):has([class*="--large-992"]) { --acton-video-preview-width: 992px; }
/* A Blazy poster already provides its own image ratio. The oEmbed field's
 * percentage-padding player wrapper must not crop or hide that poster. */
.ck-content figure.drupal-media .field--name-field-media-oembed-video:has(.media--video, .media--bundle--remote-video),
.text-formatted .field--name-field-media-oembed-video:has(.media--video, .media--bundle--remote-video):not(:where(.remote-video--custom-oembed--container *, .layout-bg-bg-container *)) {
  height: auto;
  padding-bottom: 0;
}
.ck-content figure.drupal-media :is(.media--video, .media--bundle--remote-video) {
  width: 100%;
  height: auto !important;
  min-height: 0;
  padding-bottom: 0 !important;
  aspect-ratio: auto;
}
.ck-content figure.drupal-media :is(.media--video, .media--bundle--remote-video) img {
  position: static !important;
  display: block;
  width: 100%;
  height: auto !important;
  max-width: 100%;
  object-fit: contain;
}
.ck-content figure.drupal-media .litebox--multimedia { display: block; }
.ck-content figure.drupal-media :is(.media--video, .media--bundle--remote-video) .media__icon--litebox {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
@media (max-width: 575px) {
  .ck-content figure.drupal-media:has(.field--name-field-media-oembed-video, .media--bundle--remote-video):is(.drupal-media-style-align-left, .drupal-media-style-align-right, .drupal-media-style-align-center) {
    max-width: 100%;
  }
}

/* NEW: CKEditor font styling to match theme */
.ck-content {
  font-family: 'Public Sans', sans-serif;
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-black);
}

/* NEW: Heading styles in CKEditor */
.ck-content h1 {
  font-size: 2.5rem;
  margin: 0 0 1.5rem 0;
}

.ck-content h2 {
  font-size: 2rem;
  margin: 0 0 1rem 0;
}

.ck-content h3 {
  font-size: 1.75rem;
  margin: 0 0 0.75rem 0;
}

.ck-content h4 {
  font-size: 1.4rem;
  margin: 0 0 0.5rem 0;
}

.ck-content h5 {
  font-size: 1.2rem;
  margin: 0 0 0.25rem 0;
}

.ck-content h6 {
  font-size: 1rem;
  color: #666;
}

/* NEW: Link styling in CKEditor */
.ck-content a {
  color: var(--color-gold-primary);
  text-decoration: none;
}

.ck-content a:hover {
  color: var(--color-black);;
}

.ck-content article a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

/* NEW: Blockquote styling in CKEditor */
.ck-content blockquote {
  width: 80%;
  margin: 20px auto;
  font-style: italic;
  padding: 1.2em 30px 1.2em 75px;
  border-left: 4px solid var(--color-gold);
  line-height: 1.6;
  position: relative;
}

/* NEW: Responsive font sizes in CKEditor */
@media (min-width: 768px) {
  .ck-content h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
  }
  
  .ck-content h2 {
    font-size: 2.4rem;
    margin-bottom: 1.75rem;
  }
  
  .ck-content h3 {
    font-size: 1.9rem;
  }
  
  .ck-content h4 {
    font-size: 1.5rem;
  }
  
  .ck-content h5 {
    font-size: 1.25rem;
  }
  
  .ck-content h6 {
    font-size: 1rem;
  }
}
