.mod-td-grid-v1 {
    --tdg-accent: #1e6437;
    --tdg-hover-green: #004d26;
    --tdg-active-green: #003a1d;
    --tdg-focus: #1b72b9;
    --tdg-line: #d4dbd7;
    --tdg-image-height: 260px;
    --tdg-modal-width: 800px;
    --tdg-image-fit: contain;
    --tdg-bar-radius: 6px;
    --tdg-border-width: 1px;
    --tdg-bar-size: 5px;
    width: 100%;
}

.mod-td-grid-v1--bar-square {
    --tdg-bar-radius: 0;
}

.mod-td-grid-v1--bar-rounded {
    --tdg-bar-radius: 6px;
}

/* Stretch within each UIkit row; never fix or truncate the content height.
   The native layout also recalculates when details open or images load. */
.mod-td-grid-v1 .mod-td-grid-v1__grid {
    margin-top: 0;
    align-items: stretch;
}

.mod-td-grid-v1 .mod-td-grid-v1__grid > div {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    align-self: stretch;
    min-width: 0;
}

.mod-td-grid-v1 .mod-td-grid-v1__card {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    box-sizing: border-box;
    width: 100%;
    height: auto;
    min-width: 0;
    background: #fff;
    border: var(--tdg-border-width) solid var(--tdg-line);
    border-radius: 6px;
    box-shadow: none;
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
    overflow-wrap: anywhere;
}

/* The accent bar is independent of the surrounding border and its width. */
.mod-td-grid-v1__card--bar-square {
    --tdg-bar-radius: 0;
}

.mod-td-grid-v1__card--bar-rounded {
    --tdg-bar-radius: 6px;
}

.mod-td-grid-v1 .mod-td-grid-v1__card::before {
    content: '';
    position: absolute;
    z-index: 1;
    top: calc(-1 * var(--tdg-border-width));
    left: calc(-1 * var(--tdg-border-width));
    right: calc(-1 * var(--tdg-border-width));
    bottom: auto;
    width: auto;
    height: var(--tdg-bar-size);
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--tdg-accent);
    border-radius: var(--tdg-bar-radius) var(--tdg-bar-radius) 0 0;
    pointer-events: none;
}

.mod-td-grid-v1 .mod-td-grid-v1__card--bar-bottom::before {
    top: auto;
    bottom: calc(-1 * var(--tdg-border-width));
    border-radius: 0 0 var(--tdg-bar-radius) var(--tdg-bar-radius);
}

.mod-td-grid-v1 .mod-td-grid-v1__card--bar-left::before {
    right: auto;
    bottom: calc(-1 * var(--tdg-border-width));
    width: var(--tdg-bar-size);
    height: auto;
    border-radius: var(--tdg-bar-radius) 0 0 var(--tdg-bar-radius);
}

.mod-td-grid-v1 .mod-td-grid-v1__card--bar-right::before {
    left: auto;
    bottom: calc(-1 * var(--tdg-border-width));
    width: var(--tdg-bar-size);
    height: auto;
    border-radius: 0 var(--tdg-bar-radius) var(--tdg-bar-radius) 0;
}

.mod-td-grid-v1 .mod-td-grid-v1__card--bar-off::before {
    content: none;
    display: none;
}

.mod-td-grid-v1 .mod-td-grid-v1__card:hover {
    border-color: var(--tdg-accent);
}

/* Focusing a child must not recolor the card border. Keyboard focus is
   indicated on the actual button/summary below, not on the whole card. */

.mod-td-grid-v1--hover-lift .mod-td-grid-v1__card:hover {
    transform: translateY(-4px);
}

.mod-td-grid-v1--hover-zoom .mod-td-grid-v1__card:hover {
    transform: scale(1.02);
}

.mod-td-grid-v1--hover-wiggle .mod-td-grid-v1__card:hover {
    animation: tdg-card-wiggle 400ms ease-in-out 1;
}

@keyframes tdg-card-wiggle {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(-1deg); }
    40% { transform: rotate(1deg); }
    60% { transform: rotate(-0.7deg); }
    80% { transform: rotate(0.7deg); }
}

.mod-td-grid-v1--shadow-soft .mod-td-grid-v1__card:hover {
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.11);
}

.mod-td-grid-v1--shadow-strong .mod-td-grid-v1__card:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.23);
}

.mod-td-grid-v1__icon {
    min-height: 36px;
    margin-bottom: 15px;
    color: var(--tdg-accent);
}

.mod-td-grid-v1__card-image {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    height: var(--tdg-image-height) !important;
    max-height: var(--tdg-image-height) !important;
    margin: 0 0 15px;
    object-fit: var(--tdg-image-fit) !important;
    border-radius: 4px;
    background: #fff;
}

/* Keep the TD title/teaser hierarchy even if the template assigns a large
   font to all card paragraphs. Only these module elements are affected. */
.mod-td-grid-v1 .mod-td-grid-v1__card > .mod-td-grid-v1__card-title {
    margin: 0 0 12px;
    color: #252a27;
    font-size: 20px !important;
    line-height: 28px !important;
    font-weight: 700 !important;
}

.mod-td-grid-v1 .mod-td-grid-v1__card > .mod-td-grid-v1__teaser {
    margin: 0 0 22px;
    color: #252a27;
    font-size: 16px !important;
    line-height: 26px !important;
    font-weight: 400 !important;
    white-space: pre-line;
}

/* Secondary TD action; shared by popup buttons and native details summaries. */
.mod-td-grid-v1 .mod-td-grid-v1__more,
.mod-td-grid-v1 .mod-td-grid-v1__expand-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    align-self: flex-start;
    box-sizing: border-box;
    max-width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 10px 18px;
    border: 1px solid var(--tdg-accent);
    border-radius: 4px;
    background: #fff;
    box-shadow: none;
    color: var(--tdg-accent);
    font-family: inherit;
    font-size: 16px;
    line-height: 24px;
    font-weight: 600;
    letter-spacing: normal;
    text-transform: none;
    text-decoration: none;
    text-align: center;
    appearance: none;
    cursor: pointer;
}

.mod-td-grid-v1 .mod-td-grid-v1__more:visited {
    color: var(--tdg-accent);
}

.mod-td-grid-v1 .mod-td-grid-v1__more:hover,
.mod-td-grid-v1 .mod-td-grid-v1__more:focus-visible,
.mod-td-grid-v1 .mod-td-grid-v1__expand-toggle:hover,
.mod-td-grid-v1 .mod-td-grid-v1__expand-toggle:focus-visible {
    border-color: var(--tdg-hover-green);
    background: #e8f2ed;
    color: var(--tdg-hover-green);
    text-decoration: none;
}

.mod-td-grid-v1 .mod-td-grid-v1__more:active,
.mod-td-grid-v1 .mod-td-grid-v1__expand-toggle:active {
    border-color: var(--tdg-active-green);
    color: var(--tdg-active-green);
}

/* Plain text appearance does not change the action or keyboard semantics. */
.mod-td-grid-v1 .mod-td-grid-v1__card--more-link .mod-td-grid-v1__more,
.mod-td-grid-v1 .mod-td-grid-v1__card--more-link .mod-td-grid-v1__expand:not([open]) > .mod-td-grid-v1__expand-toggle {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-weight: 400;
    text-align: left;
    text-decoration-line: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.mod-td-grid-v1 .mod-td-grid-v1__card--more-link .mod-td-grid-v1__more:hover,
.mod-td-grid-v1 .mod-td-grid-v1__card--more-link .mod-td-grid-v1__expand:not([open]) > .mod-td-grid-v1__expand-toggle:hover {
    text-decoration-thickness: 2px;
}

.mod-td-grid-v1__card--more-link .mod-td-grid-v1__more-arrow {
    display: none;
}

.mod-td-grid-v1 .mod-td-grid-v1__more:focus-visible,
.mod-td-grid-v1 .mod-td-grid-v1__expand-toggle:focus-visible,
.mod-td-grid-v1__dialog .uk-modal-close-default:focus-visible {
    outline: 3px solid var(--tdg-focus, #1b72b9);
    outline-offset: 2px;
}

/* Only remove pointer focus outlines, never keyboard focus visibility. */
.mod-td-grid-v1 .mod-td-grid-v1__more:focus:not(:focus-visible),
.mod-td-grid-v1 .mod-td-grid-v1__expand-toggle:focus:not(:focus-visible) {
    outline: none;
}

.mod-td-grid-v1__expand {
    width: 100%;
    margin: 0;
}

/* Align closed-card actions along the bottom of each equal-height row.
   Open details remain directly below their own teaser. */
.mod-td-grid-v1 .mod-td-grid-v1__card > .mod-td-grid-v1__more,
.mod-td-grid-v1 .mod-td-grid-v1__card > .mod-td-grid-v1__expand:not([open]) {
    margin-top: auto;
}

.mod-td-grid-v1__expand > summary {
    list-style: none;
}

.mod-td-grid-v1__expand > summary::marker {
    content: '';
}

.mod-td-grid-v1__expand > summary::-webkit-details-marker {
    display: none;
}

.mod-td-grid-v1__expand-open {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.mod-td-grid-v1__expand-close {
    display: none;
}

/* A thin, bare cross like the UIkit popup, with an invisible 44px hit area. */
.mod-td-grid-v1 .mod-td-grid-v1__expand[open] > .mod-td-grid-v1__expand-toggle {
    position: absolute;
    z-index: 2;
    top: 8px;
    right: 8px;
    width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: #5f6762;
    text-decoration: none;
}

.mod-td-grid-v1 .mod-td-grid-v1__expand[open] > .mod-td-grid-v1__expand-toggle:hover,
.mod-td-grid-v1 .mod-td-grid-v1__expand[open] > .mod-td-grid-v1__expand-toggle:active {
    color: #252a27;
}

/* Reserve room so the cross cannot obscure an image or title on mobile. */
.mod-td-grid-v1 .mod-td-grid-v1__card:has(> .mod-td-grid-v1__expand[open]) {
    padding-top: 56px;
}

.mod-td-grid-v1__expand[open] .mod-td-grid-v1__expand-open {
    display: none;
}

.mod-td-grid-v1__expand[open] .mod-td-grid-v1__expand-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
}

.mod-td-grid-v1 .mod-td-grid-v1__close-icon {
    display: block;
    flex: none;
    width: 14px;
    height: 14px;
    max-width: none;
    fill: none;
}

.mod-td-grid-v1__expand-body {
    margin-top: 16px;
    padding-top: 20px;
    border-top: 1px solid var(--tdg-line);
}

.mod-td-grid-v1__sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.uk-modal-dialog.mod-td-grid-v1__dialog {
    width: min(calc(100% - 30px), var(--tdg-modal-width)) !important;
    max-width: var(--tdg-modal-width) !important;
    border-radius: 8px;
}

.mod-td-grid-v1__modal-title {
    margin-top: 0;
    padding-right: 38px;
}

.mod-td-grid-v1__image {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    height: var(--tdg-image-height) !important;
    max-height: var(--tdg-image-height) !important;
    margin: 20px 0 25px;
    object-fit: var(--tdg-image-fit) !important;
    border-radius: 4px;
    background: #fff;
}

.mod-td-grid-v1__image--inline {
    margin: 0 0 18px;
}

.mod-td-grid-v1__content {
    margin: 0;
    overflow-wrap: anywhere;
}

.mod-td-grid-v1__content > :first-child {
    margin-top: 0;
}

.mod-td-grid-v1__content > :last-child {
    margin-bottom: 0;
}

@media (max-width: 639px) {
    .uk-modal-dialog.mod-td-grid-v1__dialog {
        width: calc(100% - 20px) !important;
    }

    .mod-td-grid-v1__card-image,
    .mod-td-grid-v1__image {
        height: min(var(--tdg-image-height), 220px) !important;
        max-height: min(var(--tdg-image-height), 220px) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mod-td-grid-v1 .mod-td-grid-v1__card {
        transition: none;
    }

    .mod-td-grid-v1 .mod-td-grid-v1__card:hover {
        transform: none;
        animation: none;
    }
}
