/* Contained layout: clamp the grid to the site content width. Use a dedicated
   modifier class so the rule always wins regardless of Tailwind load order
   or post-content constraint selectors missing the section. */
.kdk-mosaic__grid--contained {
    max-width: var(--wp--style--global--content-size, 1000px);
    margin-inline: auto;
    padding-inline: 1.5rem;
    width: 100%;
    box-sizing: border-box;
}
.kdk-mosaic__grid--hero {
    width: 100%;
    box-sizing: border-box;
}

/* ── Tile alignment ─────────────────────────────────────────────────────── */
/* Left (default): tiles flow in CSS grid with 1fr columns — unchanged. */

/* Center: the grid container is flex (set inline by the renderer); this rule
   just applies justify-content so tiles center inside each row. Per-tile
   width is set inline as a calc() flex-basis. */
.kdk-mosaic__grid--align-center {
    justify-content: center;
    align-content: flex-start;
}

/* Justified: tiles flow left-to-right like "left" mode, but the LAST tile
   in the entire grid gets pushed to the right edge of its row via auto-
   margin. This keeps all other tiles packed left while only the final row's
   gap gets closed on the right side. */
.kdk-mosaic__grid--align-justified {
    justify-content: flex-start;
    align-content: flex-start;
}
.kdk-mosaic__grid--align-justified > :last-child {
    margin-inline-start: auto;
}

/* ── Mobile: single-column stack regardless of alignment mode ─────────── */
@media (max-width: 640px) {
    .kdk-mosaic__grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        grid-auto-rows: auto !important;
        grid-auto-flow: row !important;
        justify-content: stretch !important;
    }
    .kdk-mosaic__tile {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
        min-height: 200px;
        /* Clear any flex-mode inline widths so mobile grid takes over */
        flex: initial !important;
        width: auto !important;
        max-width: none !important;
        height: auto !important;
    }
}

.kdk-mosaic__tile {
    border-radius: 0;
    overflow: hidden;
    position: relative;
    cursor: default;
    transition: transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 280ms ease;
    opacity: 0;
    transform: translateY(12px);
    text-decoration: none;
    display: block;
}

.kdk-mosaic__tile.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.kdk-mosaic__tile:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
    z-index: 2;
}

.kdk-mosaic__tile--linked {
    cursor: pointer;
}

/* Background image layer — sits above the bg-color, below the text */
.kdk-mosaic__tile-img {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    pointer-events: none;
}

/* Inner text container — base styles shared by all positions */
.kdk-mosaic__tile-inner {
    position: absolute;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-width: 100%;
    z-index: 1;
}

/* ── 9 positions ─────────────────────────────────────────────────────────── */

.kdk-mosaic__tile-inner.pos-tl { top: 0; left: 0; align-items: flex-start; text-align: left; }
.kdk-mosaic__tile-inner.pos-tc { top: 0; left: 0; right: 0; align-items: center; text-align: center; }
.kdk-mosaic__tile-inner.pos-tr { top: 0; right: 0; align-items: flex-end; text-align: right; }

.kdk-mosaic__tile-inner.pos-cl { top: 50%; left: 0; transform: translateY(-50%); align-items: flex-start; text-align: left; }
.kdk-mosaic__tile-inner.pos-cc { top: 50%; left: 0; right: 0; transform: translateY(-50%); align-items: center; text-align: center; }
.kdk-mosaic__tile-inner.pos-cr { top: 50%; right: 0; transform: translateY(-50%); align-items: flex-end; text-align: right; }

.kdk-mosaic__tile-inner.pos-bl { bottom: 0; left: 0; align-items: flex-start; text-align: left; }
.kdk-mosaic__tile-inner.pos-bc { bottom: 0; left: 0; right: 0; align-items: center; text-align: center; }
.kdk-mosaic__tile-inner.pos-br { bottom: 0; right: 0; align-items: flex-end; text-align: right; }

/* ── Typography — driven by CSS vars set on the section element ──────────── */

.kdk-mosaic__tile-text {
    font-family: var(--mosaic-title-font, var(--wp--preset--font-family--display, sans-serif));
    font-size: var(--mosaic-title-size, clamp(1rem, 2vw, 1.5rem));
    font-weight: 400;
    line-height: 1.1;
}

.kdk-mosaic__tile-sub {
    font-family: var(--mosaic-sub-font, inherit);
    font-size: var(--mosaic-sub-size, 0.8rem);
}

.kdk-mosaic__tile-content {
    font-family: var(--mosaic-sub-font, inherit);
    font-size: var(--mosaic-sub-size, 0.875rem);
    line-height: 1.5;
    margin-top: 0.25rem;
}
.kdk-mosaic__tile-content p { margin: 0.35em 0; }
.kdk-mosaic__tile-content p:first-child { margin-top: 0; }
.kdk-mosaic__tile-content p:last-child { margin-bottom: 0; }
.kdk-mosaic__tile-content a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 0.15em;
}
.kdk-mosaic__tile-content a:hover { opacity: 0.75; }

/* ── Editor preview — skip animations, show tiles immediately ────────────── */
.editor-styles-wrapper .kdk-mosaic__tile,
.acf-block-preview .kdk-mosaic__tile {
    opacity: 1 !important;
    transform: none !important;
}


