/* WordPress / Gutenberg integration without changing the original design. */
.at-content-grid>.wp-block-group.at-article{grid-column:2;grid-row:1}
.at-content-grid.at-module-070>.wp-block-group.at-article{grid-column:1}
.wp-block-group.at-article{min-width:0}
.tonplay-pagination{margin:20px 0}
.tonplay-pagination .page-numbers{display:flex;flex-wrap:wrap;gap:9px;list-style:none;padding:0}
.tonplay-pagination .page-numbers a,.tonplay-pagination .page-numbers span{display:inline-block;padding:8px 12px;border:1px solid var(--line-soft);border-radius:9px;text-decoration:none}
.tonplay-pagination .page-numbers .current{background:var(--panel-2);color:var(--text)}
.at-article .wp-block-heading{color:var(--text)}
.at-related-item a{color:var(--blue)}
@media(max-width:900px){.at-content-grid>.wp-block-group.at-article{grid-column:1;grid-row:auto}}

/* Nav items are managed in WordPress; mobile quick menu may contain more/fewer items. */
@media (max-width: 900px) {
  .at-bottom-nav { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0,1fr); }
}

/*
 * WordPress block layout compatibility (Atlas Tonplays 1.5.0).
 * Imported pages use the original site grid inside Gutenberg Group blocks.
 * Core's constrained/flex layout styles may shrink the grid to the intrinsic
 * width of its first child. Explicitly keep the page container and article
 * stretched to their grid areas on desktop, tablet and mobile.
 */
.at-main > .at-container.at-content-space {
  display: block !important;
  width: min(calc(100% - 32px), var(--container, 1180px)) !important;
  max-width: var(--container, 1180px) !important;
  min-width: 0 !important;
  margin-inline: auto !important;
}
.at-main .at-container.at-content-space > .at-content-grid {
  display: grid !important;
  grid-template-columns: 236px minmax(0, 1fr) !important;
  align-items: start !important;
  gap: 36px !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  margin: 0 !important;
}
.at-main .at-content-grid > .at-article {
  display: block !important;
  grid-column: 2 !important;
  grid-row: 1 !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  margin: 0 !important;
  justify-self: stretch !important;
}
.at-main .at-content-grid > .at-module-037 {
  grid-column: 1 !important;
  grid-row: 1 !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  margin-inline: 0 !important;
}
/* Gutenberg may assign a default 620px max-width to direct children. */
.at-main .wp-block-group.at-article > :where(*) {
  max-width: 100% !important;
  min-width: 0;
  margin-inline: 0 !important;
}
.at-main .at-article :is(.tonplay-demo-section, .tonplay-demo-frame, .at-definition-grid, table) {
  max-width: 100%;
  min-width: 0;
}
.at-main .at-content-grid.at-module-070 {
  grid-template-columns: minmax(0, 1fr) !important;
}
.at-main .at-content-grid.at-module-070 > .at-article {
  grid-column: 1 !important;
}
@media (max-width: 980px) {
  .at-main .at-container.at-content-space > .at-content-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
  }
  .at-main .at-content-grid > .at-article,
  .at-main .at-content-grid > .at-module-037 {
    grid-column: 1 !important;
    grid-row: auto !important;
  }
}
@media (max-width: 640px) {
  .at-main > .at-container.at-content-space {
    width: min(calc(100% - 28px), var(--container, 1180px)) !important;
  }
}

/* Atlas Tonplays 1.5.0: imported full-width content and sidebar grids.
   WordPress block supports can otherwise constrain a Group to theme.json
   contentSize even when the site's original HTML grid is wider. */
.at-main > :is(.wp-block-group, div).at-container.at-content-space {
  box-sizing: border-box !important;
  flex: none !important;
  align-self: stretch !important;
}
.at-main > .at-container.at-content-space > .wp-block-group.at-content-grid,
.at-main > .at-container.at-content-space > .at-content-grid {
  box-sizing: border-box !important;
  justify-self: stretch !important;
  margin-inline: 0 !important;
}
.at-main .at-content-grid > :is(.wp-block-group, article, div).at-article {
  box-sizing: border-box !important;
  overflow-wrap: anywhere;
}
/* Gutenberg's default constrained group layout must not clip paragraphs,
   headings, lists, tables or the demo player inside the original article. */
.at-main .at-article.is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)),
.at-main .at-article.wp-block-group > :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
  width: auto;
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}
.at-main .at-article iframe,
.at-main .at-article .tonplay-demo-frame { max-width: 100%; }
/* Do not reserve an empty sidebar column on templates with no sidebar. */
@supports selector(:has(> .at-module-037)) {
  .at-main .at-content-grid:not(:has(> .at-module-037)) {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .at-main .at-content-grid:not(:has(> .at-module-037)) > .at-article {
    grid-column: 1 !important;
  }
}

/* The intro Group appears only on the two published catalog pages. The
 * default Gutenberg constrained-layout paragraph max-width (620px) would
 * otherwise make the introduction narrower than the card grid. */
.at-main > .wp-block-group.at-container:not(.at-content-space) > :where(*) {
  width: auto !important;
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Atlas Tonplays 1.6.0: full-width hub/catalog/provider/karta-sajta-tonplays pages.
 * The original at-content-grid grid ALWAYS reserves a 236px sidebar column.
 * Catalogs have no sidebar, so render their own single-column wrapper rather
 * than relying on :has() to override a more specific !important rule. */
.at-main .tonplay-directory {
  box-sizing: border-box !important;
  width: min(calc(100% - 32px), var(--container, 1180px)) !important;
  max-width: var(--container, 1180px) !important;
  margin-left: auto !important;
  margin-right: auto !important;
  min-width: 0 !important;
}
.at-main .tonplay-directory > .tonplay-directory-content {
  display: block !important;
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  margin: 0 !important;
}
.at-main .tonplay-directory-content > .at-article {
  display: block !important;
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  margin: 0 !important;
}
/* Do not let a shortcode wrapper constrain the directory to Gutenberg's
 * default 620px contentSize if one is emitted by the active WordPress build. */
.at-main > .wp-block-shortcode:has(> .tonplay-directory) {
  width: 100% !important;
  max-width: none !important;
  margin-inline: 0 !important;
}
@media (max-width: 640px) {
  .at-main .tonplay-directory {
    width: min(calc(100% - 28px), var(--container, 1180px)) !important;
  }
}

/* Atlas Tonplays 1.8.0: Gutenberg posts inherit the exact numbered-card
 * design of editorial pages. The data is read from editable H2 blocks. */
.zenith-post-detail {
  margin-bottom: 36px;
  min-width: 0;
}
.zenith-post-detail .at-module-065 {
  width: 100%;
  min-width: 0;
}
.zenith-post-detail .at-module-051 {
  width: 100%;
  min-width: 0;
  max-width: none;
}
.zenith-post-detail .zenith-post-intro {
  margin: 0 0 18px;
  color: var(--body);
  font-size: 15.5px;
  line-height: 1.72;
}
.zenith-post-detail .at-module-003 { min-width: 0; }
.zenith-post-detail .at-module-039 > :where(*) {
  max-width: 100%;
  min-width: 0;
}
.zenith-post-detail .at-module-039 :is(iframe, img, video, table) {
  max-width: 100%;
}
.zenith-post-detail .at-module-039 :is(.tonplay-demo-frame, .at-definition-grid, .at-module-043) {
  max-width: 100%;
  min-width: 0;
}
.zenith-post-detail .at-module-039 .tonplay-demo-section {
  margin: 16px 0 0;
}
.zenith-post-detail .at-module-039 .tonplay-demo-section:first-child { margin-top: 0; }
.zenith-post-detail .at-nearby-links { margin-top: 22px; }
@media (max-width: 980px) {
  .zenith-post-detail .at-module-065 { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .zenith-post-detail .at-module-061 {
    position: static;
    max-height: none;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    overflow: visible;
  }
  .zenith-post-detail .at-module-061 .at-module-018 { flex-basis: 100%; }
  .zenith-post-detail .at-module-061 a {
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--panel);
    border: 1px solid var(--line-soft);
  }
}
@media (max-width: 640px) {
  .zenith-post-detail .at-module-003 { padding: 18px 16px; }
  .zenith-post-detail .at-module-003 h2 { font-size: 20px; }
}
