/**
 * Blog — No-BS Toolbox UI
 * Industrial, dense, utility-first. Zero fluff.
 * Fonts: Bricolage Grotesque (display), JetBrains Mono (meta)
 */

/* ——— Tokens ——— */
.blog-toolbox {
    --bt-font-display: 'Bricolage Grotesque', system-ui, sans-serif;
    --bt-font-mono: 'JetBrains Mono', ui-monospace, monospace;
    --bt-radius: 2px;
    --bt-border: 1px solid rgba(255, 255, 255, 0.1);
    --bt-bg-surface: rgba(255, 255, 255, 0.02);
    --bt-text-primary: #fafafa;
    --bt-text-secondary: rgba(255, 255, 255, 0.6);
    --bt-text-muted: rgba(255, 255, 255, 0.4);
    --bt-accent: #84CC16;
    --bt-space-1: 8px;
    --bt-space-2: 12px;
    --bt-space-3: 16px;
    --bt-space-4: 24px;
    --bt-space-5: 32px;
}

/* ——— Index: Masthead ——— */
.bt-masthead {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: var(--bt-space-4) 0 var(--bt-space-3);
    border-bottom: var(--bt-border);
}

.bt-masthead-title {
    font-family: var(--bt-font-display);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--bt-text-primary);
    margin: 0;
}

.bt-masthead-count {
    font-family: var(--bt-font-mono);
    font-size: 0.75rem;
    color: var(--bt-text-muted);
}

/* ——— Index: Post list (dense rows) ——— */
.bt-list {
    margin-top: var(--bt-space-3);
}

.bt-entry {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: var(--bt-space-3);
    align-items: center;
    padding: var(--bt-space-3) 0;
    border-bottom: var(--bt-border);
    text-decoration: none;
    color: inherit;
    transition: background 120ms ease;
}

.bt-entry:hover {
    background: var(--bt-bg-surface);
}

@media (max-width: 560px) {
    .bt-entry {
        grid-template-columns: 1fr;
    }
    .bt-entry-thumb,
    .bt-entry-thumb-link { display: none; }
}

.bt-entry-thumb {
    width: 80px;
    height: 56px;
    border-radius: var(--bt-radius);
    overflow: hidden;
    background: var(--bt-bg-surface);
    flex-shrink: 0;
}

.bt-entry-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bt-entry-thumb-placeholder {
    width: 80px;
    height: 56px;
    border-radius: var(--bt-radius);
    background: var(--bt-bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--bt-text-muted);
}

.bt-entry-body {
    min-width: 0;
}

.bt-entry-meta {
    font-family: var(--bt-font-mono);
    font-size: 0.7rem;
    color: var(--bt-text-muted);
    margin-bottom: 2px;
}

.bt-entry-title {
    font-family: var(--bt-font-display);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--bt-text-primary);
    line-height: 1.35;
}

.bt-entry:hover .bt-entry-title {
    color: var(--bt-accent);
}

.bt-entry-excerpt {
    font-size: 0.8rem;
    color: var(--bt-text-secondary);
    line-height: 1.4;
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

a.bt-entry-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--bt-space-1);
    text-decoration: none;
}

a.bt-entry-thumb-link {
    text-decoration: none;
}

.bt-entry-read {
    font-family: var(--bt-font-mono);
    font-size: 0.7rem;
    color: var(--bt-text-muted);
}

.bt-entry-link {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--bt-accent);
}

/* Admin row in entry */
.bt-entry-admin {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.bt-admin-btn {
    font-family: var(--bt-font-mono);
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: var(--bt-radius);
    border: var(--bt-border);
    background: transparent;
    color: var(--bt-text-secondary);
    cursor: pointer;
    text-decoration: none;
}

.bt-admin-btn:hover {
    background: var(--bt-bg-surface);
    color: var(--bt-text-primary);
}

.bt-admin-delete {
    color: #e57373;
    border-color: rgba(229, 115, 115, 0.3);
}

.bt-admin-delete:hover {
    background: rgba(229, 115, 115, 0.1);
}

/* ——— Index: Empty ——— */
.bt-empty {
    padding: var(--bt-space-5);
    text-align: center;
    font-size: 0.9rem;
    color: var(--bt-text-muted);
}

/* ——— Index: Pagination ——— */
.bt-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: var(--bt-space-5);
    padding-top: var(--bt-space-4);
}

.bt-pag-link {
    font-family: var(--bt-font-mono);
    font-size: 0.8rem;
    padding: 6px 12px;
    border: var(--bt-border);
    border-radius: var(--bt-radius);
    color: var(--bt-text-secondary);
    text-decoration: none;
}

.bt-pag-link:hover {
    border-color: var(--bt-accent);
    color: var(--bt-accent);
}

.bt-pag-current {
    background: var(--bt-bg-surface);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--bt-text-primary);
}

.bt-pag-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.bt-pag-ellipsis {
    color: var(--bt-text-muted);
    padding: 0 4px;
}

/* ——— Post: Article ——— */
.bt-post-page {
    position: relative;
    z-index: 1;
    padding: var(--bt-space-4) 0 var(--bt-space-5);
}

.bt-post {
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.bt-post-header {
    display: block;
    width: 100%;
    clear: both;
    position: relative;
    z-index: 1;
    margin-bottom: calc(var(--bt-space-5) + var(--bt-space-1));
    isolation: isolate;
}

.bt-post-meta {
    font-family: var(--bt-font-mono);
    font-size: 0.75rem;
    color: var(--bt-text-muted);
    margin-bottom: var(--bt-space-2);
}

.bt-post-title {
    font-family: var(--bt-font-display);
    font-size: clamp(1.75rem, 5vw, 2.25rem);
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.02em;
    margin: 0 0 var(--bt-space-5);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.bt-post-excerpt {
    font-size: 1.125rem;
    color: var(--bt-text-secondary);
    line-height: 1.6;
    margin-bottom: var(--bt-space-5);
}

.bt-post-featured {
    margin: 0 calc(-1 * var(--bt-space-3)) var(--bt-space-4);
    border-radius: 0;
    overflow: hidden;
}

.bt-post-featured img {
    width: 100%;
    height: auto;
    max-height: 360px;
    object-fit: cover;
}

.bt-post-content {
    display: flow-root;
    width: 100%;
    margin-top: 0;
    padding-top: var(--bt-space-3);
    font-size: 1rem;
    line-height: 1.8;
    color: var(--bt-text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
    clear: both;
    position: relative;
    z-index: 0;
}

/* Keep CMS blocks in normal flow so excerpts/titles cannot be overlapped. */
.bt-post-content > :is(p, h1, h2, h3, h4, h5, h6, ul, ol, pre, blockquote, table, figure, div) {
    position: static !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    transform: none !important;
}

.bt-post-content > :first-child {
    margin-top: 0 !important;
}

.bt-post-content > :last-child {
    margin-bottom: 0;
}

.bt-post-content :is(h1, h2, h3, h4, h5, h6, p, ul, ol, pre, blockquote, table, figure) {
    max-width: 100%;
}

.bt-post-content h1 {
    font-family: var(--bt-font-display);
    font-size: clamp(1.35rem, 4vw, 1.75rem);
    font-weight: 600;
    line-height: 1.3;
    margin-top: 1.6em;
    margin-bottom: 0.6em;
}

.bt-post-content p {
    margin-bottom: 1.25em;
}

.bt-post-content h2 {
    font-family: var(--bt-font-display);
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2em;
    margin-bottom: 0.6em;
    padding-bottom: 8px;
    border-bottom: var(--bt-border);
    line-height: 1.3;
}

.bt-post-content h3 {
    font-family: var(--bt-font-display);
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1.75em;
    margin-bottom: 0.5em;
    line-height: 1.35;
}

.bt-post-content h4 {
    font-family: var(--bt-font-display);
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.4;
}

.bt-post-content blockquote {
    margin: 1.5em 0;
    padding: var(--bt-space-2) var(--bt-space-3);
    border-left: 3px solid var(--bt-accent);
    background: var(--bt-bg-surface);
    color: var(--bt-text-secondary);
}

.bt-post-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--bt-radius);
    display: block;
    margin: 1.5em 0;
}

.bt-post-content [style*="float"] {
    float: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.bt-post-content [style*="position"],
.bt-post-content [style*="top"],
.bt-post-content [style*="bottom"],
.bt-post-content [style*="left"],
.bt-post-content [style*="right"] {
    position: static !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
}

.bt-post-content a {
    color: var(--bt-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.bt-post-content a:hover {
    filter: brightness(1.2);
}

/* Lists */
.bt-post-content ul,
.bt-post-content ol {
    margin: 1.25em 0;
    padding-left: 1.75em;
}

.bt-post-content ul {
    list-style-type: disc;
}

.bt-post-content ol {
    list-style-type: decimal;
}

.bt-post-content li {
    margin-bottom: 0.5em;
    line-height: 1.7;
}

.bt-post-content li > ul,
.bt-post-content li > ol {
    margin: 0.5em 0;
}

/* Code */
.bt-post-content code {
    font-family: var(--bt-font-mono);
    font-size: 0.875em;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    color: var(--bt-text-primary);
}

.bt-post-content pre {
    font-family: var(--bt-font-mono);
    font-size: 0.875rem;
    line-height: 1.6;
    padding: var(--bt-space-3);
    margin: 1.5em 0;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--bt-radius);
    overflow-x: auto;
    border: var(--bt-border);
}

.bt-post-content pre code {
    background: none;
    padding: 0;
    font-size: inherit;
}

/* Tables */
.bt-post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.9375rem;
}

.bt-post-content th,
.bt-post-content td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: var(--bt-border);
}

.bt-post-content th {
    font-weight: 600;
    background: var(--bt-bg-surface);
    font-family: var(--bt-font-display);
}

.bt-post-content tr:hover {
    background: var(--bt-bg-surface);
}

/* Horizontal Rule */
.bt-post-content hr {
    border: none;
    border-top: var(--bt-border);
    margin: 2em 0;
}

/* Strong and Emphasis */
.bt-post-content strong {
    font-weight: 600;
    color: var(--bt-text-primary);
}

.bt-post-content em {
    font-style: italic;
}

/* ——— Post: Footer ——— */
.bt-post-footer {
    margin-top: var(--bt-space-5);
    padding-top: var(--bt-space-4);
    border-top: var(--bt-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--bt-space-3);
}

.bt-post-footer form {
    margin: 0;
}

.bt-post-back {
    font-size: 0.875rem;
    color: var(--bt-text-secondary);
}

.bt-post-back:hover {
    color: var(--bt-accent);
}

.bt-post-cta {
    font-weight: 600;
    font-size: 0.875rem;
    padding: 10px 20px;
    background: var(--bt-accent);
    color: #050505;
    border-radius: var(--bt-radius);
}

.bt-post-cta:hover {
    filter: brightness(1.1);
}

/* Subtle stagger on load */
.bt-entry {
    animation: btReveal 0.4s ease-out backwards;
}

.bt-entry:nth-child(1) { animation-delay: 0ms; }
.bt-entry:nth-child(2) { animation-delay: 40ms; }
.bt-entry:nth-child(3) { animation-delay: 80ms; }
.bt-entry:nth-child(4) { animation-delay: 120ms; }
.bt-entry:nth-child(5) { animation-delay: 160ms; }
.bt-entry:nth-child(6) { animation-delay: 200ms; }

@keyframes btReveal {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ——— Responsive: Post Page ——— */
@media (max-width: 768px) {
    .bt-post {
        max-width: 100%;
        padding: 0 var(--bt-space-2);
    }

    .bt-post-title {
        font-size: clamp(1.5rem, 6vw, 2rem);
        line-height: 1.25;
        margin-bottom: var(--bt-space-3);
    }

    .bt-post-meta {
        font-size: 0.8rem;
        margin-bottom: var(--bt-space-2);
    }

    .bt-post-excerpt {
        font-size: 1rem;
        line-height: 1.55;
        margin-bottom: var(--bt-space-4);
    }

    .bt-post-featured {
        margin: 0 calc(-1 * var(--bt-space-2)) var(--bt-space-3);
    }

    .bt-post-featured img {
        max-height: 280px;
    }

    .bt-post-content {
        font-size: 1rem;
        line-height: 1.75;
    }

    .bt-post-content h2 {
        font-size: 1.35rem;
        margin-top: 1.75em;
    }

    .bt-post-content h3 {
        font-size: 1.15rem;
        margin-top: 1.5em;
    }

    .bt-post-content h4 {
        font-size: 1.05rem;
    }

    .bt-post-content pre {
        font-size: 0.8rem;
        padding: var(--bt-space-2);
    }

    .bt-post-content table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        font-size: 0.875rem;
    }

    .bt-post-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--bt-space-3);
    }

    .bt-post-cta {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .bt-post-title {
        font-size: 1.4rem;
        letter-spacing: -0.01em;
    }

    .bt-post-content {
        font-size: 0.975rem;
        line-height: 1.7;
    }

    .bt-post-content h2 {
        font-size: 1.25rem;
    }

    .bt-post-content h3 {
        font-size: 1.1rem;
    }

    .bt-post-featured img {
        max-height: 220px;
    }

    .bt-post-footer {
        margin-top: var(--bt-space-4);
        padding-top: var(--bt-space-3);
    }
}
