/* ============================================
   Company Modal Plugin — modal.css v1.1
   ============================================ */

/* ── Overlay ─────────────────────────────── */
.cmp-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.cmp-overlay[hidden] {
    display: none !important;
}

.cmp-overlay.is-visible {
    opacity: 1;
}

/* ── Modal box ───────────────────────────── */
.cmp-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: translateY(16px);
    transition: transform 0.3s ease;
    overscroll-behavior: contain;
}

.cmp-overlay.is-visible .cmp-modal {
    transform: translateY(0);
}

/* ── Header (title + close) ──────────────── */
.cmp-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 32px 32px 0;
}

.cmp-modal__title {
    margin: 0;
    font-size: clamp(1.15rem, 2.5vw, 1.5rem);
    font-weight: 700;
    line-height: 1.25;
    color: #111;
    flex: 1;
}

.cmp-modal__close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #555;
    line-height: 1;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    margin-top: 2px;
}

.cmp-modal__close:hover {
    color: #111;
    background: rgba(0, 0, 0, 0.06);
}

/* ── Body ────────────────────────────────── */
.cmp-modal__body {
    padding: 24px 32px 32px;
}

@media (max-width: 540px) {
    .cmp-modal__header { padding: 24px 20px 0; }
    .cmp-modal__body   { padding: 20px 20px 28px; }
}

/* ── Loading ─────────────────────────────── */
.cmp-modal__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
}

.cmp-modal__loading[hidden] {
    display: none !important;
}

.cmp-spinner {
    display: inline-block;
    width: 36px;
    height: 36px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: #555;
    border-radius: 50%;
    animation: cmp-spin 0.7s linear infinite;
}

@keyframes cmp-spin {
    to { transform: rotate(360deg); }
}

/* ── Content wrapper ─────────────────────── */
.cmp-modal__content[hidden],
.cmp-modal__error[hidden],
.cmp-gallery[hidden] {
    display: none !important;
}

/* ── Gallery grid (3-up like screenshot) ─── */
.cmp-gallery {
    margin-bottom: 24px;
}

.cmp-gallery__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* If only 1 image — full width */
.cmp-gallery__grid:has(.cmp-gallery__item:only-child) {
    grid-template-columns: 1fr;
}

/* If only 2 images — split 50/50 */
.cmp-gallery__grid:has(.cmp-gallery__item:nth-child(2):last-child) {
    grid-template-columns: repeat(2, 1fr);
}

.cmp-gallery__item {
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    background: #f0f0f0;
}

.cmp-gallery__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@media (max-width: 480px) {
    .cmp-gallery__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Post content ────────────────────────── */
.cmp-modal__post-content {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: #333;
}

.cmp-modal__post-content p {
    margin: 0 0 1em;
}

.cmp-modal__post-content p:last-child {
    margin-bottom: 0;
}

/* Strip any block-level padding Gutenberg might inject */
.cmp-modal__post-content .wp-block-group,
.cmp-modal__post-content .wp-block-columns {
    padding: 0 !important;
    margin: 0 0 1em !important;
}

/* ── Read more link ──────────────────────── */
.cmp-modal__read-more {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 20px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--wp--preset--color--custom-primary);
    text-decoration: none;
    transition: opacity 0.2s;
}

.cmp-modal__read-more:hover {
    opacity: 0.75;
}

/* .cmp-modal__read-more svg {
    flex-shrink: 0;
    transition: transform 0.2s;
}

.cmp-modal__read-more:hover svg {
    transform: translate(2px, -2px);
} */

/* ── Error state ─────────────────────────── */
.cmp-modal__error {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 0.9375rem;
}
