/* Forum: uses the theme tokens (--c-*, --radius-*), falls back to neutral values */
/* Sidebar on the left on desktop; on phones it goes under the content (DOM order) */
.ma-forum__grid {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    align-items: start;
    gap: clamp(24px, 4vw, 56px);
}

.ma-forum__grid > .ma-forum-side {
    grid-column: 1;
    grid-row: 1;
}

.ma-forum__grid > .ma-forum__main {
    grid-column: 2;
    grid-row: 1;
}

@media (max-width: 992px) {
    .ma-forum__grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .ma-forum__grid > .ma-forum-side,
    .ma-forum__grid > .ma-forum__main {
        grid-column: auto;
        grid-row: auto;
    }
}

.ma-forum__main {
    display: flex;
    flex-direction: column;
    gap: 48px;
    min-width: 0;
}

.ma-forum-card,
.ma-forum-box,
.ma-forum-section,
.ma-forum-topic,
.ma-forum-post {
    border-radius: var(--radius-lg, 20px);
    background: var(--c-surface, #fff);
    box-shadow: var(--shadow-card, 0 10px 30px -18px rgba(0, 0, 0, .25));
}

/* Notices */
.ma-forum-notice {
    margin-top: 20px;
    padding: 14px 18px;
    border-radius: var(--radius-md, 14px);
    background: var(--c-surface, #fff);
    border-left: 3px solid var(--c-green, #3b7a1e);
}

.ma-forum-notice.is-err {
    border-left-color: #d2452b;
}

.ma-forum-notice.is-dev {
    margin: 0;
    background: var(--c-accent-soft, #fbe3cd);
    border-left-color: var(--c-accent, #ee7d2b);
}

/* Sections */
/* Title, description and list of the three cards share rows, so the lists start on one line */
.ma-forum-sections {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.ma-forum-sections > .ma-forum-section {
    display: grid;
    grid-row: span 3;
    grid-template-rows: subgrid;
    row-gap: 12px;
    align-content: start;
}

@media (max-width: 1280px) {
    .ma-forum-sections {
        grid-template-columns: 1fr;
    }
}

.ma-forum-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px 24px 10px;
}

.ma-forum-section__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.ma-forum-section__head a {
    transition: color var(--t, .3s);
}

.ma-forum-section__head a:hover {
    color: var(--c-accent-strong, #e2661a);
}

.ma-forum-section__head .mono {
    flex-shrink: 0;
    white-space: nowrap;
}

.ma-forum-section__subs {
    display: flex;
    flex-direction: column;
    align-self: start;
    border-top: 1px solid var(--c-line, rgba(0, 0, 0, .12));
}

.ma-forum-section__subs a {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--c-line, rgba(0, 0, 0, .12));
    font-size: .9375rem;
    transition: color var(--t, .3s);
}

.ma-forum-section__subs a:hover {
    color: var(--c-accent-strong, #e2661a);
}

.ma-forum-section__subs li:last-child a {
    border-bottom: 0;
}

.ma-forum-section__subs .mono {
    color: var(--c-muted, #6f6c60);
}

/* Topic lists */
.ma-forum-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ma-forum-list__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 6px;
}

.ma-forum-topic {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 16px 24px;
    padding: 20px 22px;
    transition: transform .5s var(--ease-out, ease);
}

.ma-forum-topic:hover {
    transform: translateY(-2px);
}

.ma-forum-topic.is-sticky {
    box-shadow: inset 0 0 0 1px var(--c-accent, #ee7d2b), var(--shadow-card, none);
}

@media (max-width: 680px) {
    .ma-forum-topic {
        grid-template-columns: 1fr;
    }
}

.ma-forum-topic__main {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.ma-forum-topic__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ma-forum-topic__tags:empty {
    display: none;
}

.ma-forum-topic__title {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -.015em;
    line-height: 1.3;
}

.ma-forum-topic__title a {
    transition: color var(--t, .3s);
}

.ma-forum-topic__title a::after {
    content: '';
    position: absolute;
    inset: 0;
}

.ma-forum-topic {
    position: relative;
}

.ma-forum-topic__tags a {
    position: relative;
    z-index: 1;
}

.ma-forum-topic:hover .ma-forum-topic__title a {
    color: var(--c-accent-strong, #e2661a);
}

.ma-forum-topic__excerpt {
    font-size: .9375rem;
}

.ma-forum-topic__meta {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    padding-left: 24px;
    border-left: 1px solid var(--c-line, rgba(0, 0, 0, .12));
}

@media (max-width: 680px) {
    .ma-forum-topic__meta {
        flex-direction: row;
        align-items: center;
        padding: 12px 0 0;
        border-left: 0;
        border-top: 1px solid var(--c-line, rgba(0, 0, 0, .12));
    }
}

.ma-forum-topic__who,
.ma-forum-box__user,
.ma-forum-post__head {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ma-forum-topic__who > span:not(.ma-forum-avatar):not(.tag),
.ma-forum-box__user > span:not(.ma-forum-avatar):not(.tag),
.ma-forum-post__head > span:not(.ma-forum-avatar):not(.tag) {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ma-forum-topic__who .mono {
    color: var(--c-muted, #6f6c60);
    font-size: .625rem;
}

.ma-forum-topic__counts {
    display: flex;
    gap: 20px;
    margin: 0;
}

.ma-forum-topic__counts div {
    display: flex;
    flex-direction: column;
}

.ma-forum-topic__counts dt {
    font-family: var(--font-mono, monospace);
    font-size: .625rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--c-muted, #6f6c60);
}

.ma-forum-topic__counts dd {
    margin: 0;
    font-weight: 600;
}

/* Avatar */
.ma-forum-avatar {
    flex-shrink: 0;
    display: inline-grid;
    place-items: center;
    width: var(--s);
    height: var(--s);
    border-radius: 50%;
    background: hsl(var(--h) 45% 88%);
    color: hsl(var(--h) 40% 28%);
    font-size: calc(var(--s) * .38);
    font-weight: 600;
    line-height: 1;
    letter-spacing: -.02em;
}

.ma-forum-avatar.is-staff {
    background: var(--c-accent-strong, #e2661a);
    color: #fff;
}

/* Sidebar */
.ma-forum-side {
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: calc(var(--header-nav-h, 72px) + 24px);
}

@media (max-width: 992px) {
    .ma-forum-side {
        position: static;
    }
}

.ma-forum-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
}

.ma-forum-box__title {
    font-weight: 600;
}

.ma-forum-box__user .mono {
    color: var(--c-accent-strong, #e2661a);
}

.ma-forum-search__row {
    display: flex;
    gap: 8px;
}

.ma-forum-search .field__input {
    height: 52px;
}

.ma-forum-places {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ma-forum-places .chip {
    height: 34px;
    padding: 0 12px;
    font-size: .875rem;
}

.ma-forum-places .is-extra {
    display: none;
}

.ma-forum-places.is-expanded .is-extra {
    display: inline-flex;
}

.ma-forum-more {
    align-self: flex-start;
    padding: 0;
    border: 0;
    background: none;
    color: var(--c-accent-strong, #e2661a);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ma-forum-rating {
    display: flex;
    flex-direction: column;
    gap: 10px;
    counter-reset: rating;
}

.ma-forum-rating li {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ma-forum-rating li span:not(.ma-forum-avatar) {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ma-forum-rating b {
    color: var(--c-accent-strong, #e2661a);
    font-size: .875rem;
}

.ma-forum-rules {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--c-muted, #6f6c60);
    font-size: .875rem;
}

.ma-forum-rules li {
    position: relative;
    padding-left: 16px;
}

.ma-forum-rules li::before {
    content: '';
    position: absolute;
    left: 0;
    top: .55em;
    width: 6px;
    height: 6px;
    border-radius: 2px;
    background: var(--c-accent, #ee7d2b);
}

/* Topic page */
.ma-forum-post {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 24px;
    scroll-margin-top: calc(var(--header-nav-h, 72px) + 16px);
}

.ma-forum-post_first {
    padding: 28px;
}

.ma-forum-delete {
    margin-left: auto;
}

.ma-forum-delete button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 0;
    border-radius: var(--radius-pill, 999px);
    background: none;
    color: var(--c-muted, #6f6c60);
    font-size: .875rem;
    transition: background var(--t, .3s), color var(--t, .3s);
}

.ma-forum-delete button:hover {
    background: rgba(210, 69, 43, .1);
    color: #d2452b;
}

.ma-forum-delete svg {
    width: 16px;
    height: 16px;
}

.ma-forum-post__badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    margin-left: auto;
}

.ma-forum-post__body.ma-prose {
    font-size: 1rem;
}

.ma-forum-post__foot {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ma-forum-replies {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-left: clamp(0px, 3vw, 40px);
}

.ma-forum-replies .ma-forum-post:target {
    box-shadow: inset 0 0 0 2px var(--c-accent, #ee7d2b);
}

.ma-forum-like {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--c-line-strong, rgba(0, 0, 0, .26));
    border-radius: var(--radius-pill, 999px);
    background: transparent;
    font-weight: 500;
    transition: background var(--t, .3s), color var(--t, .3s), border-color var(--t, .3s);
}

.ma-forum-like svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.ma-forum-like [data-forum-like-count] {
    min-width: 1ch;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

/* Own messages: the counter is shown, liking yourself is not possible */
.ma-forum-like.is-own {
    cursor: default;
    opacity: .7;
}

.ma-forum-like.is-own:hover {
    border-color: var(--c-line-strong, rgba(0, 0, 0, .26));
    color: inherit;
}

.ma-forum-like:hover {
    border-color: var(--c-accent-strong, #e2661a);
    color: var(--c-accent-strong, #e2661a);
}

.ma-forum-like.is-liked {
    border-color: var(--c-accent-strong, #e2661a);
    background: var(--c-accent-strong, #e2661a);
    color: #fff;
}

.ma-forum-like.is-liked svg path {
    fill: currentColor;
}

/* Forms */
.ma-forum-card {
    padding: clamp(20px, 3vw, 32px);
}

.ma-forum-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ma-forum-form__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 680px) {
    .ma-forum-form__row {
        grid-template-columns: 1fr;
    }
}

.ma-forum-form select.field__input {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 22px) 50%, calc(100% - 17px) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
}

.ma-forum-form .ma-forum-form__text {
    display: block;
    height: auto;
    min-height: 140px;
    padding: 16px 18px;
    line-height: 1.55;
    resize: vertical;
}

.ma-forum-form__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.ma-forum-reply {
    margin-top: 6px;
}

.ma-forum-empty {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: clamp(24px, 3vw, 36px);
    border: 1px dashed var(--c-line-strong, rgba(0, 0, 0, .26));
    border-radius: var(--radius-lg, 20px);
}

.ma-forum-empty a:not(.btn) {
    color: var(--c-accent-strong, #e2661a);
    text-decoration: underline;
}

/* Sign-in */
.ma-forum-login {
    max-width: 520px;
}

.ma-forum-login__step {
    color: var(--c-accent-strong, #e2661a);
}

.ma-forum-form .ma-forum-login__code {
    font-family: var(--font-mono, monospace);
    font-size: 1.5rem;
    letter-spacing: .4em;
    text-align: center;
}

.ma-forum-login__note,
.ma-forum-login__again {
    font-size: .875rem;
}

.ma-forum-login__note a,
.ma-forum-login__again {
    color: var(--c-ink-soft, #3c3a31);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ma-forum-login__again {
    align-self: center;
}
