/* =========================================================
   ABBUC Forum – post and forum-listing styles
   Depends on abbuc.css (Bootstrap + ABBUC custom properties)
   ========================================================= */

/* ----- Breadcrumb --------------------------------------- */

.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    overflow: hidden;
    white-space: nowrap;
    list-style: none;
    background: none;
    border: none;
    padding: 0.2rem 0;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.breadcrumb-item a {
    color: var(--primary-dark, #226188);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    text-decoration: underline;
    color: var(--primary-medium, #479CD1);
}

.breadcrumb-item.active {
    color: #555;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    padding: 0 0.45rem;
    color: var(--primary-medium, #479CD1);
}

/* ----- Forum listing ------------------------------------ */

.forum-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 2rem;
}

.forum-card {
    display: flex;
    border: 1px solid var(--primary-pale, #A1CDE8);
    border-radius: 0.6rem;
    box-shadow: 0 2px 6px rgba(34, 97, 136, 0.09);
    overflow: hidden;
    background: #fff;
}

.forum-card-main {
    flex: 1;
    padding: 0.85rem 1.1rem;
    border-right: 1px solid var(--primary-light, #CEE5F3);
    min-width: 0; /* allow text truncation inside flex child */
}

.forum-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 0.3rem;
    line-height: 1.3;
}

.forum-card-title a {
    color: var(--primary-dark, #226188);
    text-decoration: none;
}

.forum-card-title a:hover {
    text-decoration: underline;
    color: var(--primary-medium, #479CD1);
}

/* Downgrade h1/h2 inside forum.md info to subtitle size */
.forum-card-info {
    font-size: 0.875rem;
    color: #555;
}

.forum-card-info h1,
.forum-card-info h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #444;
    margin: 0 0 0.2rem;
}

.forum-card-info > :last-child { margin-bottom: 0; }

/* Stats column */
.forum-card-stats {
    width: 230px;
    flex-shrink: 0;
    padding: 0.85rem 1.1rem;
    background: var(--primary-hint, #EBF5FA);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.45rem;
}

.forum-stat-counts {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.forum-stat-item {
    font-size: 0.82rem;
    color: #555;
}

.forum-stat-item strong {
    font-size: 1rem;
    color: var(--primary-dark, #226188);
    font-variant-numeric: tabular-nums;
}

.forum-last-post {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    font-size: 0.8rem;
    min-width: 0;
}

.last-post-title {
    font-weight: 600;
    color: #333;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.last-post-title:hover {
    text-decoration: underline;
    color: var(--primary-medium, #479CD1);
}

.last-post-meta {
    color: #6c757d;
    display: block;
}

.forum-no-posts {
    color: #aaa;
    font-style: italic;
    font-size: 0.8rem;
}

@media (max-width: 575px) {
    .forum-card { flex-direction: column; }
    .forum-card-main { border-right: none; border-bottom: 1px solid var(--primary-light, #CEE5F3); }
    .forum-card-stats { width: auto; }
}

/* ----- Thread listing table ----------------------------- */

.forum-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
    margin-bottom: 0.6rem;
}

.thread-list-heading {
    margin: 0;
    font-size: 1.1rem;
    color: var(--primary-dark, #226188);
}

a.btn-new-topic {
    font-size: 0.82rem;
    padding: 0.25rem 0.75rem;
    border-radius: 0.3rem;
    text-decoration: none;
    color: #fff;
    background: var(--primary-medium, #479CD1);
    border: 1px solid var(--primary-medium, #479CD1);
    white-space: nowrap;
}

a.btn-new-topic:hover {
    background: var(--primary-pale, #A1CDE8);
    border-color: var(--primary-pale, #A1CDE8);
    color: var(--primary-dark, #226188);
    text-decoration: none;
}

.thread-list {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--primary-pale, #A1CDE8);
    border-radius: 0.6rem;
    box-shadow: 0 2px 6px rgba(34, 97, 136, 0.09);
    margin-bottom: 1.5rem;
    overflow: hidden; /* needed for border-radius in most browsers */
}

.thread-list thead th {
    background-color: var(--primary-dark, #226188);
    color: #fff;
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: none;
    white-space: nowrap;
}

.thread-list thead th.col-title   { width: 100%; } /* greedy: takes remaining space */
.thread-list thead th.col-author  { width: 1%; }   /* shrink-wrap */
.thread-list thead th.col-posts   { width: 1%; text-align: center; }
.thread-list thead th.col-date    { width: 1%; }

.thread-list tbody tr {
    transition: background-color 0.1s;
}

.thread-list tbody tr:hover {
    background-color: var(--primary-hint, #EBF5FA);
}

.thread-list tbody tr.thread-new td {
    background-color: var(--primary-hint, #EBF5FA);
}

.thread-list tbody tr.thread-new .thread-title a {
    color: var(--primary-medium, #479CD1);
}

.thread-list tbody td {
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--primary-light, #CEE5F3);
    vertical-align: middle;
    font-size: 0.9rem;
}

.thread-list tbody tr:first-child td {
    border-top: none;
}

.thread-title a {
    color: var(--primary-dark, #226188);
    font-weight: 600;
    text-decoration: none;
}

.thread-title a:hover {
    text-decoration: underline;
    color: var(--primary-medium, #479CD1);
}

.thread-author {
    white-space: nowrap;
    color: #555;
}

.thread-posts {
    text-align: center;
    white-space: nowrap;
    color: #555;
    font-variant-numeric: tabular-nums;
}

.thread-date {
    white-space: nowrap;
    color: #6c757d;
    font-size: 0.82rem;
    text-align: right;
}

/* ----- Post sort bar ------------------------------------ */

.post-sort-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.post-sort-label {
    font-size: 0.82rem;
    color: #6c757d;
}

.btn-sort-posts {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.2rem 0.5rem;
    margin-left: auto;
    border: 1px solid var(--primary-pale, #A1CDE8);
    border-radius: 0.3rem;
    background: var(--primary-hint, #EBF5FA);
    color: var(--primary-dark, #226188);
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
}

.btn-sort-posts:hover {
    background: var(--primary-light, #CEE5F3);
    border-color: var(--primary-medium, #479CD1);
}

.btn-sort-posts .sort-asc,
.btn-sort-posts .sort-desc {
    opacity: 0.35;
    transition: opacity 0.15s;
}

.btn-sort-posts .sort-asc {
    opacity: 1;
}

.btn-sort-posts.sort-order-desc .sort-asc {
    opacity: 0.35;
}

.btn-sort-posts.sort-order-desc .sort-desc {
    opacity: 1;
}

/* Theme switcher <select> — shares visual style with .btn-sort-posts */
.select-theme {
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--primary-pale, #A1CDE8);
    border-radius: 0.3rem;
    background: var(--primary-hint, #EBF5FA);
    color: var(--primary-dark, #226188);
    cursor: pointer;
    line-height: 1;
}

.select-theme:hover,
.select-theme:focus {
    border-color: var(--primary-medium, #479CD1);
    background: var(--primary-light, #CEE5F3);
    outline: none;
}

/* ----- Post card ---------------------------------------- */

.post.card {
    border: 1px solid var(--primary-pale, #A1CDE8);
    border-radius: 0.65rem;
    box-shadow: 0 2px 10px rgba(34, 97, 136, 0.13);
    overflow: hidden;
    margin-bottom: 1.5rem !important;
}

/* New posts (appeared since current visit started) */
article.post.card.post-new {
    border-color: var(--primary-medium, #479CD1);
    box-shadow: 0 2px 12px rgba(71, 156, 209, 0.35);
}
article.post.card.post-new .card-header {
    background-color: var(--primary-medium, #479CD1);
}
.post-new-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-dark, #226188);
    border-radius: 0.2rem;
    padding: 0.05rem 0.3rem;
    margin-left: 0.45rem;
    vertical-align: middle;
}

/* Reply posts (not from thread opener) are left-indented, chat-style */
.post.card.post-reply {
    margin-left: 2.5rem;
}

/* Post header (author · date · optional title) */
.post .card-header {
    background-color: var(--primary-dark, #226188);
    color: #fff;
    border-bottom: none;
    padding: 0.6rem 1rem;
}

.post-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    line-height: 1.3;
}

.post-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.post-author {
    font-weight: 600;
    font-size: 0.95rem;
}

.post-date {
    font-size: 0.82rem;
    opacity: 0.72;
    white-space: nowrap;
    margin-left: auto;
}

.post-link {
    color: inherit;
    opacity: 0.4;
    font-size: 0.75rem;
    line-height: 1;
    text-decoration: none;
    margin-right: 0.4rem;
    flex-shrink: 0;
}

.post-link:hover {
    opacity: 1;
    color: inherit;
    text-decoration: none;
}

/* Post body */
.post .card-body.post-body {
    padding: 1rem 1.25rem;
    line-height: 1.7;
}

.post-body pre,
.post-body code {
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.875em;
}

.post-body pre {
    white-space: pre;
    overflow-x: auto;
    background: var(--primary-hint, #EBF5FA);
    border: 1px solid var(--primary-light, #CEE5F3);
    border-radius: 0.35rem;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0 1rem;
    line-height: 1.5;
}

.post-body pre code {
    background: transparent;
    padding: 0;
    font-size: inherit;
    border-radius: 0;
}

.post-body code {
    background: var(--primary-hint, #EBF5FA);
    padding: 0.1em 0.3em;
    border-radius: 0.2em;
}

.post .card-body.post-body > :first-child { margin-top: 0; }
.post .card-body.post-body > :last-child  { margin-bottom: 0; }

/* Images always occupy their own line — nothing floats beside them */
.post-body img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Blockquotes: each nesting level adds 10vw left indent, capped at 5 levels (≈50vw) */
.post-body blockquote {
    margin: 0.6rem 0 0.6rem 10vw;
    padding: 0.5rem 0.9rem 0.5rem 1rem;
    border-left: 4px solid var(--primary-medium, #479CD1);
    background: var(--primary-hint, #EBF5FA);
    border-radius: 0 0.35rem 0.35rem 0;
    color: #3a5a72;
    font-size: 0.92em;
}

.post-body blockquote p { margin: 0; }

.post-body blockquote blockquote {
    margin-left: 10vw;
    background: var(--primary-light, #CEE5F3);
}

.post-body blockquote blockquote blockquote {
    margin-left: 10vw;
    background: var(--primary-pale, #A1CDE8);
    color: #2a4a5e;
}

.post-body blockquote blockquote blockquote blockquote {
    margin-left: 10vw;
    background: #8bbbd8;
    color: #1e3a4e;
}

.post-body blockquote blockquote blockquote blockquote blockquote {
    margin-left: 10vw; /* 50vw total — cap reached */
    background: #6aaac9;
    color: #152b3a;
}

/* Level 6+: no further indentation */
.post-body blockquote blockquote blockquote blockquote blockquote blockquote {
    margin-left: 0;
}

/* Signature */
.post-signature {
    padding: 0.45rem 1.25rem 0.5rem;
    border-top: 1px dashed var(--primary-pale, #A1CDE8);
    background: var(--primary-hint, #EBF5FA);
    font-size: 0.82rem;
    color: #555;
}

.post-signature > :first-child { margin-top: 0; }
.post-signature > :last-child  { margin-bottom: 0; }

/* Attachments */
.post-attachments {
    padding: 0.5rem 1.25rem 0.75rem;
    border-top: 1px solid var(--primary-light, #CEE5F3);
    font-size: 0.875rem;
}

.post-attachments ul {
    margin: 0.25rem 0 0;
    padding-left: 1.2rem;
}

/* Reply / quote action buttons */
.post-actions {
    display: flex;
    gap: 0.4rem;
    padding: 0.35rem 1.25rem 0.5rem;
    justify-content: flex-end;
    border-top: 1px solid var(--primary-light, #CEE5F3);
}

.post-actions a {
    font-size: 0.78rem;
    padding: 0.15rem 0.55rem;
    border-radius: 0.25rem;
    text-decoration: none;
    color: var(--primary-dark, #226188);
    border: 1px solid var(--primary-pale, #A1CDE8);
    background: var(--primary-hint, #EBF5FA);
    line-height: 1.4;
}

.post-actions a:hover {
    background: var(--primary-light, #CEE5F3);
    text-decoration: none;
}

/* Post author avatar (inside dark card header) */
.post-author-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 0.45rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    flex-shrink: 0;
}

/* Post author link (inside dark card header) */
.post-author a {
    color: inherit;
    text-decoration: none;
}

.post-author a:hover {
    text-decoration: underline;
}

/* Thread list author link */
.thread-author a {
    color: inherit;
    text-decoration: none;
}

.thread-author a:hover {
    text-decoration: underline;
    color: var(--primary-medium, #479CD1);
}

/* ----- User profile page -------------------------------- */

.user-profile {
    max-width: 640px;
}

.user-profile-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.user-avatar {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--primary-pale, #A1CDE8);
    flex-shrink: 0;
}

.user-profile-name {
    margin: 0;
    font-size: 1.6rem;
    color: var(--primary-dark, #226188);
}

.user-profile-fields {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.45rem 1.5rem;
    font-size: 0.9rem;
    border: 1px solid var(--primary-pale, #A1CDE8);
    border-radius: 0.6rem;
    padding: 1rem 1.25rem;
    background: var(--primary-hint, #EBF5FA);
}

.user-profile-fields dt {
    color: #6c757d;
    font-weight: 600;
    white-space: nowrap;
}

.user-profile-fields dd {
    margin: 0;
    word-break: break-word;
}

/* ----- Logged-in user bar (injected by forum.js) ---------- */

.user-login-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.45rem 1.5rem;
    background: var(--primary-hint, #EBF5FA);
    border-top: 1px solid var(--primary-light, #CEE5F3);
    font-size: 0.875rem;
}

a.user-login-bar-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-dark, #226188);
    text-decoration: none;
}

a.user-login-bar-link:hover {
    text-decoration: underline;
    color: var(--primary-medium, #479CD1);
}

.user-login-bar-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--primary-pale, #A1CDE8);
}

.user-login-bar-avatar-icon {
    font-size: 28px;
    line-height: 1;
    color: var(--primary-pale, #A1CDE8);
}

/* Username field locked by AMBMU cookie */
#username[readonly] {
    background-color: var(--primary-hint, #EBF5FA);
    border-color: var(--primary-pale, #A1CDE8);
    color: var(--primary-dark, #226188);
    cursor: default;
}
