/* BBS styles — visually aligned with noisefactor-website/blog.
   Keeps all existing class names so route handlers and JS continue to work. */

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--hf-font-family);
    color: var(--hf-text-normal);
    background: var(--hf-bg-base);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--hf-link-color);
    text-decoration: none;
}

a:hover {
    color: var(--hf-link-hover);
    text-decoration: underline;
}

/* Layout container — centered column, matches noisefactor blog */
.bbs-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

/* Sticky header — mirrors .blog-header from noisefactor-website/css/blog.css */
.bbs-header {
    background: var(--hf-bg-surface);
    border-bottom: 1px solid var(--hf-border-subtle);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.bbs-logo {
    display: flex;
    align-items: center;
    line-height: 0;
    color: inherit;
    margin: 0;
    text-decoration: none;
}

.bbs-logo:hover {
    text-decoration: none;
    color: inherit;
}

.bbs-logo picture,
.bbs-logo img {
    display: block;
}

.bbs-logo img {
    height: 56px;
    width: auto;
    vertical-align: middle;
    margin: -8px 0;
    max-width: none;
}

.bbs-nav {
    display: flex;
    align-items: center;
}

.bbs-nav a {
    margin-left: 1.5rem;
    text-decoration: none;
    color: var(--hf-text-dim);
    font-size: 0.9rem;
    transition: color 0.15s ease;
}

.bbs-nav a:hover {
    color: var(--hf-text-bright);
    text-decoration: none;
}

/* Active section indicator — the link to the section the user is currently in */
.bbs-nav .bbs-nav-current {
    color: var(--hf-text-bright);
    font-weight: 600;
}

/* Buttons inside the nav (New Thread, Sign In) get the same gap.
   Override .bbs-nav a's dim color so the primary button keeps its dark
   text on the lime fill — selector is more specific than .bbs-nav a. */
.bbs-nav .bbs-btn {
    margin-left: 1.5rem;
    color: var(--hf-text-normal);
}
.bbs-nav .bbs-btn:hover {
    color: var(--hf-text-normal);
}
.bbs-nav .bbs-btn-primary,
.bbs-nav .bbs-btn-primary:hover {
    color: var(--hf-color-1);
}

.bbs-nav-link {
    margin-left: 1.5rem;
}

.bbs-nav-divider {
    display: inline-block;
    width: 1px;
    height: 1.25rem;
    background: var(--hf-border-subtle);
    margin-left: 1.5rem;
    align-self: center;
}

.bbs-user {
    margin-left: 1.5rem;
    color: var(--hf-text-dim);
    font-size: 0.9rem;
}

/* On narrow screens, hide the dim cross-property links so the
   functional BBS controls (logo + user + new thread) keep priority */
@media (max-width: 720px) {
    .bbs-header {
        padding: 0.75rem 1rem;
    }
    .bbs-logo img {
        height: 44px;
        margin: -6px 0;
    }
    .bbs-nav a {
        margin-left: 1rem;
    }
    .bbs-nav .bbs-btn,
    .bbs-nav-divider,
    .bbs-user {
        margin-left: 1rem;
    }
}

@media (max-width: 540px) {
    /* Drop the cross-site nav links on phones; keep brand logo + the
       essential controls (user, New Thread / Sign In). */
    .bbs-nav > a[href^="https://noisefactor.io/"],
    .bbs-nav > a[href^="https://noisedeck.app"],
    .bbs-nav-divider {
        display: none;
    }
}

/* Headings — bright text, no backgrounds, no inline-block boxes */
h1, h2, h3, h4 {
    color: var(--hf-text-bright);
    margin-top: 0;
    line-height: 1.3;
    font-weight: 600;
    background: none;
    padding: 0;
    display: block;
}

/* Buttons.
   Use inline-flex with explicit centering so <button> and <label>
   instances of .bbs-btn end up the same height. inline-block alone
   doesn't equalize them — <button> has UA font-metric and line-height
   defaults that <label> doesn't, and the resulting box heights differ.
   `font: inherit` resets the entire UA font shorthand; line-height is
   then pinned explicitly. appearance: none drops the native button
   chrome on platforms that still apply it. */
.bbs-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 0.5rem 1rem;
    border-radius: var(--hf-radius-sm, 4px);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.2;
    cursor: pointer;
    border: 1px solid var(--hf-border-subtle);
    background: transparent;
    color: var(--hf-text-normal);
    text-decoration: none;
    vertical-align: middle;
    transition: background 0.15s ease, border-color 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}

.bbs-btn:hover {
    background: var(--hf-bg-elevated);
    border-color: var(--hf-text-dim);
    text-decoration: none;
    color: var(--hf-text-normal);
}

.bbs-btn-primary {
    background: var(--hf-accent);
    color: var(--hf-color-1);
    border-color: var(--hf-accent);
    font-weight: 600;
}

.bbs-btn-primary:hover {
    background: var(--hf-accent);
    color: var(--hf-color-1);
    opacity: 0.85;
}

.bbs-btn-danger {
    color: var(--hf-red, #e57373);
    border-color: var(--hf-red, #e57373);
}

.bbs-btn-sm {
    padding: 0.25rem 0.625rem;
    font-size: 0.8rem;
}

/* Tags — small caps with letter-spacing, lime accent on hover/active */
.bbs-tag {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: var(--hf-radius-sm, 4px);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    background: var(--hf-bg-elevated);
    color: var(--hf-text-dim);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.bbs-tag:hover {
    background: var(--hf-accent);
    color: var(--hf-color-1);
    text-decoration: none;
}

.bbs-tag.active {
    background: var(--hf-accent);
    color: var(--hf-color-1);
}

.bbs-tag-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--hf-border-subtle);
}

/* Thread list page */
.bbs-thread-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.bbs-thread-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--hf-border-subtle);
    gap: 1rem;
}

.bbs-thread-item:first-child {
    padding-top: 0;
}

.bbs-thread-item:last-child {
    border-bottom: none;
}

.bbs-thread-info {
    flex: 1;
    min-width: 0;
}

.bbs-thread-title {
    font-weight: 600;
    font-size: 1.15rem;
    line-height: 1.3;
    color: var(--hf-text-bright);
    display: block;
    margin-bottom: 0.4rem;
}

.bbs-thread-title:hover {
    color: var(--hf-link-color);
    text-decoration: none;
}

.bbs-thread-meta {
    font-size: 0.8rem;
    color: var(--hf-text-dim);
    display: flex;
    gap: 0.625rem;
    align-items: center;
    flex-wrap: wrap;
}

.bbs-thread-stats {
    text-align: right;
    font-size: 0.8rem;
    color: var(--hf-text-dim);
    white-space: nowrap;
    margin-left: 0.75rem;
}

/* Thread detail — OP */
.bbs-op {
    padding: 0 0 2rem 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--hf-border-subtle);
}

.bbs-op-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1rem;
    gap: 1rem;
}

.bbs-op h1 {
    font-size: 1.875rem;
    line-height: 1.2;
    margin: 0;
    color: var(--hf-text-bright);
    flex: 1;
    min-width: 0;
}

/* Posts / replies */
.bbs-post {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--hf-border-subtle);
}

.bbs-post:last-child {
    border-bottom: none;
}

.bbs-post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 0.75rem;
}

.bbs-post-author {
    font-weight: 600;
    color: var(--hf-text-bright);
    font-size: 0.95rem;
}

.bbs-post-time {
    font-size: 0.8rem;
    color: var(--hf-text-dim);
}

.bbs-post-body {
    color: var(--hf-text-normal);
    font-size: 1.0625rem;
    line-height: 1.7;
}

.bbs-post-body p {
    margin: 0 0 1rem 0;
}

.bbs-post-body p:last-child {
    margin-bottom: 0;
}

.bbs-post-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--hf-radius, 6px);
    margin: 1rem 0;
    box-shadow: var(--hf-shadow, 0 2px 8px rgba(0,0,0,0.15));
}

.bbs-post-body pre {
    background: var(--hf-bg-elevated);
    padding: 1rem 1.25rem;
    border-radius: var(--hf-radius, 6px);
    overflow-x: auto;
    margin: 1.25rem 0;
    font-size: 0.9rem;
}

.bbs-post-body code {
    font-family: var(--hf-font-family-mono);
    font-size: 0.9em;
    background: var(--hf-bg-elevated);
    padding: 0.1rem 0.35rem;
    border-radius: var(--hf-radius-sm, 4px);
}

.bbs-post-body pre code {
    background: none;
    padding: 0;
}

.bbs-post-body blockquote {
    border-left: 4px solid var(--hf-accent);
    margin: 1.25rem 0;
    padding: 0.5rem 0 0.5rem 1.25rem;
    color: var(--hf-text-dim);
    background: var(--hf-bg-elevated);
}

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

.bbs-post-body h1, .bbs-post-body h2, .bbs-post-body h3 {
    margin: 1.75rem 0 0.75rem 0;
}

.bbs-post-body h2 { font-size: 1.35rem; }
.bbs-post-body h3 { font-size: 1.15rem; }

.bbs-post-body ul, .bbs-post-body ol {
    margin: 0 0 1rem 0;
    padding-left: 1.5rem;
}

.bbs-post-body li {
    margin-bottom: 0.4rem;
}

.bbs-post-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Reply-to quote stub */
.bbs-reply-to {
    background: var(--hf-bg-elevated);
    border-left: 3px solid var(--hf-accent);
    padding: 0.625rem 1rem;
    margin-bottom: 0.75rem;
    border-radius: 0 var(--hf-radius-sm, 4px) var(--hf-radius-sm, 4px) 0;
    font-size: 0.875rem;
    color: var(--hf-text-dim);
    cursor: pointer;
}

.bbs-reply-to strong {
    color: var(--hf-text-normal);
}

/* Forms */
.bbs-form {
    margin: 1.5rem 0;
}

/* Form-field labels — only direct children of .bbs-form (the
   "Title", "Tags", "Body" labels). NOT all descendant labels,
   because .bbs-upload-btn is also a <label> and we don't want
   the form-field font-size / margin-bottom to override its
   button styling. */
.bbs-form > label {
    display: block;
    color: var(--hf-text-dim);
    font-size: 0.875rem;
    margin-bottom: 0.4rem;
}

.bbs-form input[type="text"],
.bbs-form textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--hf-border-subtle);
    border-radius: var(--hf-radius-sm, 4px);
    background: var(--hf-bg-elevated);
    color: var(--hf-text-normal);
    font-family: inherit;
    font-size: 1rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.bbs-form textarea {
    min-height: 160px;
    resize: vertical;
}

.bbs-form input[type="text"]:focus,
.bbs-form textarea:focus {
    outline: none;
    border-color: var(--hf-accent);
}

.bbs-tag-picker {
    display: flex;
    gap: 0.625rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.bbs-tag-picker label {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--hf-text-normal);
    margin: 0;
}

/* Reply form */
.bbs-reply-form {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--hf-border-subtle);
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--hf-border-subtle);
}

.bbs-replying-to {
    background: var(--hf-bg-elevated);
    padding: 0.5rem 0.75rem;
    border-radius: var(--hf-radius-sm, 4px);
    margin-bottom: 0.75rem;
    display: none;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
}

.bbs-replying-to.active {
    display: flex;
}

.bbs-replying-to .bbs-cancel-reply {
    cursor: pointer;
    color: var(--hf-text-dim);
}

/* Upload — <label> styled as a button. .bbs-btn already gives it
   inline-flex + centering; the override here exists only to beat
   handfish's `.hf-form label { display: flex; width: 100% }` rule
   if it ever applies, by pinning width and re-asserting inline-flex
   at higher specificity. */
label.bbs-upload-btn,
label.bbs-upload-btn.bbs-btn {
    display: inline-flex;
    width: auto;
    min-width: 0;
}
.bbs-upload-btn input[type="file"] {
    display: none;
}

/* Pagination */
.bbs-pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 0 0 0;
}

/* Locked / hidden / sign-in notice */
.bbs-locked {
    padding: 1rem 1.25rem;
    background: var(--hf-bg-elevated);
    border-radius: var(--hf-radius, 6px);
    text-align: center;
    color: var(--hf-text-dim);
    margin: 2rem 0;
    font-size: 0.95rem;
}

/* Admin bar */
.bbs-admin-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Footer */
.bbs-footer {
    padding-top: 0;
    padding-bottom: 3rem;
    text-align: center;
    color: var(--hf-text-dim);
}

.bbs-footer .bbs-container {
    padding-top: 2rem;
    padding-bottom: 0;
    border-top: 1px solid var(--hf-border-subtle);
}

.bbs-footer p {
    font-size: 0.85rem;
    margin: 0.5rem 0;
}

/* Deleted post reference */
.bbs-deleted {
    color: var(--hf-text-dim);
    font-style: italic;
}

/* ============================================================
   Moderation UI
   ============================================================ */

.bbs-hidden-by-mod {
    opacity: 0.6;
    border: 1px dashed var(--hf-text-dim);
}
.bbs-mod-banner {
    background: var(--hf-bg-elevated);
    padding: 0.5rem 0.75rem;
    font-size: 0.85em;
    color: var(--hf-text-dim);
    margin-bottom: 0.5rem;
    border-left: 3px solid var(--hf-accent);
    border-radius: 0 var(--hf-radius-sm, 4px) var(--hf-radius-sm, 4px) 0;
}
.bbs-mod-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}
.bbs-mod-table th, .bbs-mod-table td {
    padding: 0.625rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--hf-border-subtle);
    vertical-align: top;
}
.bbs-mod-table th {
    font-weight: 600;
    color: var(--hf-text-bright);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

/* Replies section — explicit container so the empty state has context */
.bbs-replies {
    margin-top: 1rem;
}
.bbs-replies-heading {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--hf-text-dim);
    font-weight: 600;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--hf-border-subtle);
}

/* Sort indicator + empty state */
.bbs-sort-indicator {
    font-size: 0.8rem;
    color: var(--hf-text-dim);
    font-style: italic;
    margin: 0 0 0.75rem 0;
}
.bbs-no-replies {
    text-align: center;
    padding: 2rem 0;
    color: var(--hf-text-dim);
    font-style: italic;
}
.bbs-footer-links {
    font-size: 0.85rem;
    margin: 0.5rem 0;
}
.bbs-footer-links a, .bbs-footer-links button {
    color: var(--hf-text-dim);
}

/* Flag link — small understated dotted-underline link */
.bbs-flag-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: var(--hf-text-dim);
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    font-family: inherit;
}
.bbs-flag-link:hover {
    color: var(--hf-text-normal);
}
.bbs-flag-link:focus-visible {
    outline: var(--hf-focus-ring-width, 2px) solid var(--hf-focus-ring-color, var(--hf-accent));
    outline-offset: 2px;
}

/* Flag dialog: explicit centering override */
.bbs-flag-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    margin: 0;
    transform: translate(-50%, -50%);
    translate: none;
}
.bbs-flag-dialog .hf-dialog-body {
    min-width: 360px;
    max-width: 480px;
}
.bbs-flag-dialog textarea {
    font-family: inherit;
    background: var(--hf-bg-elevated);
    border: 1px solid var(--hf-border-subtle);
    border-radius: var(--hf-radius-sm, 4px);
    color: var(--hf-text-normal);
    padding: 0.625rem 0.75rem;
    resize: vertical;
}

/* Post header layout: author/time on the left, meta actions (flag/block) on the right */
.bbs-post-meta-left {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    min-width: 0;
}
.bbs-post-meta-actions {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: auto;
    flex-shrink: 0;
}
.bbs-post-meta-actions .bbs-flag-link {
    margin: 0;
}
.bbs-meta-sep {
    color: var(--hf-text-dim);
    font-size: 0.8em;
    user-select: none;
}
.bbs-block-form {
    display: inline;
    margin: 0;
    padding: 0;
}

/* Confirm + notice dialogs — same explicit centering as the others */
.bbs-confirm-dialog,
.bbs-notice-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    margin: 0;
    transform: translate(-50%, -50%);
    translate: none;
    width: min(440px, 92vw);
}
.bbs-confirm-dialog .hf-dialog-body p,
.bbs-notice-dialog .hf-dialog-body p {
    margin: 0;
    line-height: 1.5;
}

/* Rules dialog */
.bbs-rules-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    margin: 0;
    transform: translate(-50%, -50%);
    translate: none;
    width: min(560px, 92vw);
}
.bbs-rules-dialog .hf-dialog-body.bbs-rules-body {
    max-height: 60vh;
    overflow-y: auto;
}
.bbs-rules-list {
    margin: 0.5rem 0 1rem 0;
    padding-left: 1.25em;
}
.bbs-rules-list li {
    margin: 0.5rem 0;
    line-height: 1.5;
}

/* Form-header row: heading on the left, contextual link on the right */
.bbs-form-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.bbs-form-header h1,
.bbs-form-header h3 {
    margin: 0;
}

/* Footer button styled to match other muted footer links */
.bbs-footer-link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--hf-text-dim);
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    font-size: 0.85rem;
}
.bbs-footer-link-btn:hover {
    color: var(--hf-text-normal);
    text-decoration: none;
}

/* Long-post collapse */
.bbs-post-body.bbs-collapsed {
    max-height: 500px;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, black 78%, transparent);
    mask-image: linear-gradient(to bottom, black 78%, transparent);
}
.bbs-show-more {
    display: block;
    margin: 0.75rem 0;
    background: none;
    border: 1px solid var(--hf-border-subtle);
    border-radius: var(--hf-radius-sm, 4px);
    color: var(--hf-text-dim);
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
}
.bbs-show-more:hover {
    background: var(--hf-bg-elevated);
    border-color: var(--hf-text-dim);
    color: var(--hf-text-normal);
}

/* Responsive */
@media (max-width: 600px) {
    .bbs-container {
        padding: 1.5rem 1rem 3rem;
    }
    .bbs-header {
        padding: 0.75rem 1rem;
    }
    .bbs-op h1 {
        font-size: 1.5rem;
    }
    .bbs-post-body {
        font-size: 1rem;
    }
}
