/**
 * Main Styles
 * Core styles loaded on all pages (public and admin)
 */

/* ==========================================================================
   Base Styles
   ========================================================================== */

/* Remove outline on contenteditable elements */
[contenteditable]:focus {
  outline: none;
}

/* ==========================================================================
   Responsive Page Layout Container
   ========================================================================== */

.layout-width-container {
  width: var(--layout-width, 100%);
}

.layout-align-left {
  margin-left: 0;
  margin-right: auto;
}

.layout-align-center {
  margin-left: auto;
  margin-right: auto;
}

.layout-align-right {
  margin-left: auto;
  margin-right: 0;
}

@media (max-width: 767px) {
  .layout-width-container {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

/* ==========================================================================
   Shared Rich Text Styles
   ========================================================================== */

.rich-text-content p {
  margin: 0.5em 0;
}

.rich-text-content p:empty::before {
  content: "\00a0";
}

.rich-text-content h1,
.rich-text-content h2,
.rich-text-content h3,
.rich-text-content h4,
.rich-text-content h5,
.rich-text-content h6 {
  margin: 0.75em 0 0.5em;
  font-size: revert;
  font-weight: revert;
}

.rich-text-content ul,
.rich-text-content ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
  list-style: revert;
}

.rich-text-content blockquote {
  margin: 0.5em 0;
  padding-left: 1em;
  border-left: 3px solid #e5e7eb;
  color: #6b7280;
}

.rich-text-content pre {
  overflow-x: auto;
  padding: 0.75em 1em;
  border-radius: 0.5em;
  background: #1f2937;
  color: #e5e7eb;
}

.rich-text-content code {
  padding: 0.2em 0.4em;
  border-radius: 0.25em;
  background: #f3f4f6;
  font-size: 0.9em;
}

.rich-text-content pre code {
  padding: 0;
  background: none;
}

.rich-text-content hr {
  margin: 1em 0;
  border: none;
  border-top: 2px solid #e5e7eb;
}

.rich-text-content a {
  color: var(--page-link-color, #000000);
  font-weight: inherit;
  text-decoration: var(--page-link-decoration, underline);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
}

.rich-text-content a:hover {
  color: var(--page-link-color, #000000);
}

/* A link-dialog override applies to the whole link, not only a nested span. */
.rich-text-content a[style] * {
  color: inherit !important;
}

.rich-text-content a[style*="text-decoration: none"],
.rich-text-content a[style*="text-decoration: none"] * {
  text-decoration-line: none !important;
}

.rich-text-content a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: 2px;
}

/* ==========================================================================
   Image Block Sizing
   ========================================================================== */

.image-frame {
  position: relative;
  max-width: 100%;
}

.image-link,
.image-rendered {
  display: block;
  width: 100%;
}

.image-frame--legacy,
.image-frame--legacy .image-link,
.image-frame--legacy .image-rendered {
  height: 100%;
}

.image-frame--legacy .image-rendered {
  object-fit: cover;
}

.image-frame--fit .image-rendered {
  height: auto;
}

.image-frame--crop {
  height: var(--image-crop-height);
  overflow: hidden;
}

.image-frame--crop .image-link,
.image-frame--crop .image-rendered {
  height: 100%;
}

.image-frame--crop .image-rendered {
  object-fit: cover;
}

.image-frame--canvas.image-frame--crop {
  height: 100%;
}

.image-structured-block .image-frame {
  width: var(--image-width, 100%);
}

.image-frame--align-left {
  margin-left: 0;
  margin-right: auto;
}

.image-frame--align-center {
  margin-left: auto;
  margin-right: auto;
}

.image-frame--align-right {
  margin-left: auto;
  margin-right: 0;
}

@media (max-width: 767px) {
  .image-frame--crop.image-frame--mobile-fit:not(.image-frame--canvas) {
    height: auto;
    overflow: visible;
  }

  .image-frame--crop.image-frame--mobile-fit:not(.image-frame--canvas) .image-link,
  .image-frame--crop.image-frame--mobile-fit:not(.image-frame--canvas) .image-rendered {
    height: auto;
  }

  .image-frame--crop.image-frame--mobile-fit:not(.image-frame--canvas) .image-rendered {
    object-fit: contain;
  }
}

/* ==========================================================================
   Grid Layout - Responsive Column Spans
   ========================================================================== */

.grid-blocks-container {
  align-items: start;
  align-content: start;
}

/* Responsive grid span classes - clamps to available columns */
.grid-span-1 {
  grid-column: span 1;
}

.grid-span-2 {
  grid-column: span 1; /* Mobile: 1 col available */
}

.grid-span-3 {
  grid-column: span 1; /* Mobile: 1 col available */
}

.grid-span-4 {
  grid-column: span 1; /* Mobile: 1 col available */
}

@media (min-width: 768px) {
  .grid-span-2 {
    grid-column: span 2; /* md: 2 cols available */
  }
  .grid-span-3 {
    grid-column: span 2; /* md: clamp to 2 cols */
  }
  .grid-span-4 {
    grid-column: span 2; /* md: clamp to 2 cols */
  }
}

@media (min-width: 1024px) {
  .grid-span-3 {
    grid-column: span 3; /* lg: all 3 cols available */
  }
  .grid-span-4 {
    grid-column: span 4; /* lg: all 4 cols available */
  }
}

/* ==========================================================================
   Columns Layout - Independent Vertical Stacks
   ========================================================================== */

.columns-layout-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.columns-layout-region {
  width: 100%;
}

.columns-layout-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: start;
}

.columns-full-region {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 1px;
}

.columns-layout-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  min-height: 1px;
}

.columns-block-container {
  width: 100%;
}

@media (min-width: 768px) {
  .columns-layout-container {
    grid-template-columns: repeat(var(--column-count, 2), minmax(0, 1fr));
  }
}

/* Keep horizontal layout rhythm stable while allowing page-specific vertical spacing. */
.flow-blocks-container,
.grid-blocks-container,
.columns-layout-page,
.columns-layout-container,
.columns-full-region,
.columns-layout-column {
  row-gap: var(--layout-row-gap, 1rem);
}
