:root {
    --mainem-reference-accent: var(--e-global-color-accent, #c99a45);
    --mainem-reference-dark: var(--e-global-color-primary, #1f252b);
    --mainem-reference-text: #5f656b;
    --mainem-reference-border: rgba(31, 37, 43, .12);
    --mainem-reference-shadow: 0 18px 45px rgba(31, 37, 43, .08);
    --mainem-reference-radius: 36px;
}

.mainem-references,
.mainem-reference-single-wrap,
.mainem-reference-container,
.mainem-reference-single {
    box-sizing: border-box;
}

.mainem-references *,
.mainem-reference-single-wrap *,
.mainem-lightbox,
.mainem-lightbox * {
    box-sizing: border-box;
}

.mainem-references-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 38px 34px;
}

.mainem-references--cols-1 .mainem-references-grid { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.mainem-references--cols-2 .mainem-references-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mainem-references--cols-3 .mainem-references-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mainem-references--cols-4 .mainem-references-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.mainem-reference-card {
    overflow: visible;
    border: 0;
    border-radius: var(--mainem-reference-radius);
    background: transparent;
    box-shadow: none;
}

.mainem-reference-card:hover {
    transform: none;
    box-shadow: none;
}

.mainem-reference-card__media {
    display: block;
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    border-radius: var(--mainem-reference-radius);
    background: #f4f4f4;
}

.mainem-reference-card__image {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
    transition: transform .35s ease;
}

.mainem-reference-card:hover .mainem-reference-card__image {
    transform: scale(1.045);
}

.mainem-reference-card__placeholder {
    display: grid;
    place-items: center;
    height: 100%;
    color: #8a8f94;
}

.mainem-reference-card__body {
    padding: 24px 0 0;
    text-align: center;
}

.mainem-reference-card__title {
    max-width: 92%;
    margin: 0 auto 20px;
    color: var(--mainem-reference-dark);
    font-size: 20px;
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: -.03em;
}

.mainem-reference-card__title a {
    color: inherit;
    text-decoration: none;
}


.mainem-reference-card .elementor-button-wrapper {
    display: inline-block;
}

.mainem-reference-card__button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0 62px 0 30px;
    border: 1px solid rgba(31, 37, 43, .82);
    border-radius: 999px;
    background: #fff;
    color: var(--mainem-reference-dark) !important;
    font-weight: 700;
    line-height: 1;
    text-decoration: none !important;
    box-shadow: none;
    transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}

.mainem-reference-card__button:hover,
.mainem-reference-card__button:focus {
    border-color: var(--mainem-reference-dark);
    color: var(--mainem-reference-dark) !important;
    transform: translateY(-1px);
    box-shadow: 0 10px 26px rgba(31, 37, 43, .08);
    text-decoration: none !important;
}

.mainem-reference-card__button-icon {
    position: absolute;
    top: 50%;
    right: -1px;
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 999px;
    background: var(--mainem-reference-accent);
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    transform: translateY(-50%);
    transition: transform .2s ease, filter .2s ease;
}

.mainem-reference-card__button:hover .mainem-reference-card__button-icon,
.mainem-reference-card__button:focus .mainem-reference-card__button-icon {
    transform: translate(2px, calc(-50% - 2px));
    filter: brightness(.96);
}


/* Elementor na webu nastavuje .elementor-widget-button .elementor-button na accent pozadí.
   U referencí používáme PBMIT text/outline button, proto pozadí tlačítka nesmí být zlaté. */
.mainem-references .elementor-widget-button .elementor-button,
.mainem-reference-card .elementor-widget-button .elementor-button,
.mainem-reference-more .elementor-widget-button .elementor-button {
    background-color: transparent !important;
    background-image: none !important;
}

.mainem-references .elementor-widget-button .elementor-button:hover,
.mainem-references .elementor-widget-button .elementor-button:focus,
.mainem-reference-card .elementor-widget-button .elementor-button:hover,
.mainem-reference-card .elementor-widget-button .elementor-button:focus,
.mainem-reference-more .elementor-widget-button .elementor-button:hover,
.mainem-reference-more .elementor-widget-button .elementor-button:focus {
    background-color: transparent !important;
    background-image: none !important;
}

.mainem-reference-pagination {
    margin-top: 42px;
    text-align: center;
}

.mainem-reference-pagination ul {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mainem-reference-pagination li {
    margin: 0;
}

.mainem-reference-pagination a,
.mainem-reference-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    padding: 0 16px;
    border: 1px solid var(--mainem-reference-border);
    border-radius: 36px;
    background: #fff;
    color: var(--mainem-reference-dark);
    font-weight: 700;
    line-height: 1;
    text-decoration: none !important;
    transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.mainem-reference-pagination .current,
.mainem-reference-pagination a:hover,
.mainem-reference-pagination a:focus {
    background: var(--mainem-reference-accent);
    border-color: var(--mainem-reference-accent);
    color: #fff;
}

.mainem-reference-empty {
    padding: 22px;
    border: 1px solid var(--mainem-reference-border);
    border-radius: var(--mainem-reference-radius);
    background: #fff;
    color: var(--mainem-reference-text);
}

.mainem-reference-single-wrap {
    padding: 30px 0;
}

/* Detail reference: theme wrapper on mainem.cz can add large vertical spacing to #content.
   Override only vertical spacing. Horizontal spacing stays fully controlled by the theme/container. */
body.mainem-reference-detail-page #content,
body.single-mainem_reference #content,
body.post-type-mainem_reference #content,
body.mainem-reference-detail-page .site-content,
body.single-mainem_reference .site-content,
body.post-type-mainem_reference .site-content {
    padding-top: 30px !important;
    padding-bottom: 30px !important;
}

body.mainem-reference-detail-page #content .mainem-reference-single-wrap,
body.single-mainem_reference #content .mainem-reference-single-wrap,
body.post-type-mainem_reference #content .mainem-reference-single-wrap,
body.mainem-reference-detail-page .site-content .mainem-reference-single-wrap,
body.single-mainem_reference .site-content .mainem-reference-single-wrap,
body.post-type-mainem_reference .site-content .mainem-reference-single-wrap {
    padding: 0 !important;
}


.mainem-reference-single__header {
    margin: 0 0 36px;
    text-align: left;
}

.mainem-reference-single--title-hidden .mainem-reference-single__header {
    margin-top: 0;
}

.mainem-reference-single__label {
    margin: 0 0 10px;
    color: var(--mainem-reference-accent);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.mainem-reference-single__title {
    margin: 0 0 18px;
    color: var(--mainem-reference-dark);
    font-size: clamp(34px, 5vw, 58px);
    line-height: 1.08;
}

.mainem-reference-single__description {
    color: #000 !important;
    font-size: 16px;
    font-weight: 400 !important;
    line-height: 1.65 !important;
}

.mainem-reference-single__description p {
    margin: 0 0 18px !important;
    color: #000 !important;
    font-weight: 400 !important;
    line-height: 1.65 !important;
}

.mainem-reference-single__description p:last-child {
    margin-bottom: 0;
}

.mainem-reference-single__description ul,
.mainem-reference-single__description ol {
    margin: 18px 0 18px;
    padding-left: 1.25em;
    color: #000 !important;
    font-weight: 400 !important;
    line-height: 1.65 !important;
}

.mainem-reference-single__description li {
    break-inside: avoid;
    margin: 0 0 8px;
    color: #000 !important;
    font-weight: 400 !important;
    line-height: 1.65 !important;
}

.mainem-reference-single__description ul {
    column-count: 2;
    column-gap: 36px;
}

@media (min-width: 1200px) {
    .mainem-reference-single__description ul {
        column-count: 3;
    }
}

.mainem-reference-gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.mainem-reference-gallery__item {
    display: block;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border-radius: var(--mainem-reference-radius);
    background: #f4f4f4;
    box-shadow: 0 12px 35px rgba(31, 37, 43, .08);
}

.mainem-reference-gallery__image {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
    transition: transform .35s ease, opacity .2s ease;
}

.mainem-reference-gallery__item:hover .mainem-reference-gallery__image {
    transform: scale(1.045);
    opacity: .92;
}

.mainem-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(0, 0, 0, .88);
}

.mainem-lightbox[hidden] {
    display: none;
}

.mainem-lightbox__image {
    display: block;
    max-width: min(1180px, 94vw);
    max-height: 86vh;
    width: auto;
    height: auto;
    border-radius: var(--mainem-reference-radius);
    box-shadow: 0 20px 80px rgba(0, 0, 0, .45);
}

.mainem-lightbox__close,
.mainem-lightbox__prev,
.mainem-lightbox__next {
    position: fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 999px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, .16) !important;
    color: #fff !important;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 400;
    line-height: 1 !important;
    text-align: center;
    cursor: pointer;
    box-shadow: none !important;
    transition: background .2s ease;
}

.mainem-lightbox__close:hover,
.mainem-lightbox__prev:hover,
.mainem-lightbox__next:hover,
.mainem-lightbox__close:focus,
.mainem-lightbox__prev:focus,
.mainem-lightbox__next:focus {
    background: rgba(255, 255, 255, .28) !important;
}

.mainem-lightbox__close span,
.mainem-lightbox__prev span,
.mainem-lightbox__next span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    line-height: 1;
    pointer-events: none;
}

.mainem-lightbox__close {
    top: 22px;
    right: 22px;
    width: 44px;
    height: 44px;
}

.mainem-lightbox__close span {
    font-size: 32px;
    transform: translateY(-1px);
}

.mainem-lightbox__prev,
.mainem-lightbox__next {
    top: 50%;
    width: 54px;
    height: 54px;
    transform: translateY(-50%);
}

.mainem-lightbox__prev span,
.mainem-lightbox__next span {
    font-size: 42px;
    transform: translateY(-2px);
}

.mainem-lightbox__prev { left: 24px; }
.mainem-lightbox__next { right: 24px; }

@media (max-width: 980px) {
    .mainem-references-grid,
    .mainem-references--cols-3 .mainem-references-grid,
    .mainem-references--cols-4 .mainem-references-grid,
    .mainem-reference-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .mainem-references-grid,
    .mainem-references--cols-2 .mainem-references-grid,
    .mainem-references--cols-3 .mainem-references-grid,
    .mainem-references--cols-4 .mainem-references-grid,
    .mainem-reference-gallery {
        grid-template-columns: 1fr;
    }

    .mainem-reference-card__body {
        padding: 20px 0 0;
    }

    .mainem-reference-card__button {
        padding-left: 26px;
    }

    .mainem-lightbox {
        padding: 14px;
    }

    .mainem-lightbox__prev,
    .mainem-lightbox__next {
        width: 44px;
        height: 44px;
    }

    .mainem-lightbox__prev span,
    .mainem-lightbox__next span {
        font-size: 34px;
    }

    .mainem-reference-single__description ul {
        column-count: 1;
    }

    .mainem-lightbox__prev { left: 10px; }
    .mainem-lightbox__next { right: 10px; }
}

.mainem-references-random .mainem-references-grid {
    margin-bottom: 0;
}

.mainem-reference-more {
    margin-top: 42px;
    text-align: center;
}

.mainem-reference-card .elementor-button-wrapper,
.mainem-reference-more .elementor-button-wrapper {
    display: inline-block;
}


/* Safety overrides for detail text on mainem.cz theme. */
body.mainem-reference-detail-page .mainem-reference-single__description,
body.single-mainem_reference .mainem-reference-single__description,
body.post-type-mainem_reference .mainem-reference-single__description,
body.mainem-reference-detail-page .mainem-reference-single__description p,
body.single-mainem_reference .mainem-reference-single__description p,
body.post-type-mainem_reference .mainem-reference-single__description p,
body.mainem-reference-detail-page .mainem-reference-single__description li,
body.single-mainem_reference .mainem-reference-single__description li,
body.post-type-mainem_reference .mainem-reference-single__description li {
    color: #000 !important;
    font-weight: 400 !important;
    line-height: 1.65 !important;
}
