/* CAForum Topic Tiles — styles apply only to the topic list in viewforum. */
body.section-viewforum .topiclist.topics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin: 18px 0 28px;
    padding: 0;
    background: transparent;
    border: 0;
}

body.section-viewforum .topiclist.topics > li.row {
    display: block;
    min-width: 0;
    min-height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: var(--topic-tile-background, #fff);
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 18px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, .10);
    transition: transform .18s ease, box-shadow .18s ease;
}

body.section-viewforum .topiclist.topics > li.row:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 14px rgba(0, 0, 0, .14);
}

/* Replace the native topic row visually. Different styles can wrap native
   topic details in dl, div, or other elements, so hide every sibling of the tile. */
body.section-viewforum .topiclist.topics > li.row > *:not(.topic-tile) {
    display: none !important;
}

body.section-viewforum .topiclist.topics > li.row .topic-tile {
    display: flex;
    height: 100%;
    min-height: 330px;
    flex-direction: column;
    color: var(--topic-tile-text, #222);
}

.topic-tile__image-link {
    position: relative;
    display: block;
    height: 190px;
    overflow: hidden;
    background: #666;
    text-decoration: none !important;
}

.topic-tile__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .25s ease;
}

.topic-tile__image-link:hover .topic-tile__image { transform: scale(1.035); }

.topic-tile__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: rgba(255,255,255,.8);
    background: linear-gradient(135deg, #777, #4c4c4c);
    font-size: 42px;
}

.topic-tile__badge {
    position: absolute;
    top: 10px;
    right: 10px;
    max-width: calc(100% - 20px);
    padding: 5px 10px;
    overflow: hidden;
    color: #fff;
    background: #e91e63;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topic-tile__content {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    padding: 12px 13px 10px;
}

.topic-tile__title {
    margin: 0 0 7px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
}

.topic-tile__title a { color: inherit; text-decoration: none; }
.topic-tile__title a:hover { text-decoration: underline; }

.topic-tile__excerpt {
    display: -webkit-box;
    margin: 0 0 14px;
    overflow: hidden;
    color: inherit;
    font-size: 14px;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.topic-tile__excerpt--empty { opacity: .65; font-style: italic; }

.topic-tile__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
    padding-top: 9px;
    border-top: 1px solid rgba(127,127,127,.18);
    font-size: 12px;
}

body.section-viewforum .topic-tile__author,
body.section-viewforum .topic-tile__lastpost {
    min-width: 0;
    max-width: 100%;
}

/* Date/time is displayed below the author, avoiding overlap with long usernames. */
body.section-viewforum .topic-tile__meta {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 5px;
}

body.section-viewforum .topic-tile__author {
    width: 100%;
}

body.section-viewforum .topic-tile__lastpost {
    display: block;
    margin-left: 37px;
    overflow-wrap: anywhere;
    text-align: left;
    white-space: normal;
    line-height: 1.4;
}

body.section-viewforum .topic-tile__lastpost a { color: inherit; text-decoration: none; }
body.section-viewforum .topic-tile__lastpost a:hover { text-decoration: underline; }

@media (max-width: 1000px) {
    body.section-viewforum .topiclist.topics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    body.section-viewforum .topiclist.topics { grid-template-columns: minmax(0, 1fr); gap: 14px; }
    body.section-viewforum .topiclist.topics > li.row .topic-tile { min-height: 0; }
    .topic-tile__image-link { height: 180px; }
}

@media (prefers-reduced-motion: reduce) {
    body.section-viewforum .topiclist.topics > li.row,
    .topic-tile__image { transition: none; }
}

/* v1.0.1: remove the native blue forum wrapper/header around card rows.
   :has() keeps the change limited to the wrapper containing topic cards. */
@supports selector(.forumbg:has(ul.topiclist.topics)) {
    body.section-viewforum .forumbg:has(> .inner > ul.topiclist.topics) {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 18px 0 28px !important;
    }

    body.section-viewforum .forumbg:has(> .inner > ul.topiclist.topics) > .inner {
        padding: 0 !important;
        background: transparent !important;
        border: 0 !important;
    }

    body.section-viewforum .forumbg:has(> .inner > ul.topiclist.topics) > .inner > ul.topiclist:not(.topics) {
        display: none !important;
    }
}

/* Ensure only topic cards are styled; do not affect forum-index lists. */
body.section-viewforum .topic-tile__image-link,
body.section-viewforum .topic-tile__content,
body.section-viewforum .topic-tile__title,
body.section-viewforum .topic-tile__excerpt,
body.section-viewforum .topic-tile__meta {
    box-sizing: border-box;
}

/* Author avatar and native phpBB group colour. */
body.section-viewforum .topic-tile__author {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    align-items: center;
    gap: 7px;
    white-space: normal;
}

body.section-viewforum .topic-tile__avatar {
    display: inline-flex;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 50%;
}

body.section-viewforum .topic-tile__avatar img {
    display: block;
    width: 30px;
    height: 30px;
    object-fit: cover;
    border-radius: 50%;
}

body.section-viewforum .topic-tile__author-details {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    overflow: visible;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.4;
}

body.section-viewforum .topic-tile__author-link {
    display: inline;
    max-width: 100%;
    overflow-wrap: anywhere;
    vertical-align: baseline;
    white-space: normal;
}

body.section-viewforum .topic-tile__author-name {
    display: inline;
    font-weight: 700;
    overflow-wrap: anywhere;
}
