/* ══════════════════════════════════════════════
   Neutral Blog Theme — Custom CSS
   Complements Tailwind utility classes
   ══════════════════════════════════════════════ */

/* ── Base Reset ─────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-body, 'Inter', sans-serif);
    color: var(--foreground, #404040);
    background: var(--background, #ffffff);
}

/* ── Sticky Navigation ──────────────────────── */
.nav-sticky {
    position: sticky;
    top: 0;
    z-index: 40;
}

@media (max-width: 767px) {
    .mob-sticky {
        position: sticky;
        top: 0;
        z-index: 20;
    }
}

/* ── Sticky Sidebar ─────────────────────────── */
.hc-sticky {
    position: sticky;
    top: 5rem;
}

/* ── Scroll to Top ──────────────────────────── */
.back-top {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.back-top.show {
    opacity: 1;
    pointer-events: auto;
}

/* ── Dropdown Animation ─────────────────────── */
.dropdown-menu {
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* ── Post Card Hover Effects ────────────────── */
article.grid:hover img {
    transform: scale(1.03);
    transition: transform 0.5s ease;
}

article.grid img {
    transition: transform 0.5s ease;
}

/* ── Prose Overrides for Post Content ───────── */
.post-prose h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--foreground);
}

.post-prose h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--foreground);
}

.post-prose p {
    margin-bottom: 1.25rem;
    line-height: 1.8;
}

.post-prose img {
    border-radius: 0.25rem;
    margin: 1.5rem auto;
    max-width: 100%;
}

.post-prose blockquote {
    border-inline-start: 3px solid var(--primary, #404040);
    padding-inline-start: 1.25rem;
    font-style: italic;
    color: var(--muted-foreground, #737373);
    margin: 1.5rem 0;
}

.post-prose pre {
    background: #0d1117;
    color: #c9d1d9;
    padding: 1.25rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.post-prose code {
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
}

.post-prose a {
    color: var(--primary, #404040);
    text-decoration: underline;
}

.post-prose ul,
.post-prose ol {
    padding-inline-start: 1.5rem;
    margin-bottom: 1.25rem;
}

.post-prose li {
    margin-bottom: 0.25rem;
    line-height: 1.7;
}

/* ── Universal blog table: .blog-table injected via JS, covers all themes ──
   CSS variables fall through both namespaces:
     Tailwind/shadcn: --primary, --primary-foreground, --border, --muted, --foreground
     Inkwell:         --link, --bg, --border, --surface, --fg-body             ── */
.blog-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.75rem 0;
    border-radius: 6px;
    border: 1px solid var(--border, #e2e8f0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.blog-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    line-height: 1.5;
    margin: 0;
}
.blog-table thead {
    background: var(--primary, var(--link, #1e293b));
    color: var(--primary-foreground, #fff);
}
.blog-table th {
    padding: 0.7rem 1rem;
    font-weight: 700;
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: start;
    border-inline-end: 1px solid rgba(255, 255, 255, 0.14);
    white-space: nowrap;
    color: inherit;
}
.blog-table th:last-child {
    border-inline-end: none;
}
.blog-table td {
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--border, #e2e8f0);
    vertical-align: top;
    color: var(--foreground, var(--fg-body, var(--fg, inherit)));
}
.blog-table tbody tr:nth-child(even) {
    background: var(--muted, var(--surface, rgba(0, 0, 0, 0.025)));
}
.blog-table tbody tr:hover {
    background: var(--muted, var(--surface, rgba(0, 0, 0, 0.04)));
    transition: background 0.12s;
}
.blog-table td strong {
    color: var(--primary, var(--link, inherit));
    font-weight: 600;
}

/* ── Fallback: bare tables not yet processed by JS ── */
.post-prose table:not(.blog-table),
.ink-essay-body table:not(.blog-table) {
    width: 100%;
    border-collapse: collapse;
    margin: 1.75rem 0;
    font-size: 0.875rem;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.post-prose table:not(.blog-table) thead,
.ink-essay-body table:not(.blog-table) thead {
    background: var(--primary, var(--link, #1e293b));
    color: var(--primary-foreground, #fff);
}
.post-prose table:not(.blog-table) th,
.ink-essay-body table:not(.blog-table) th {
    padding: 0.65rem 0.9rem;
    font-weight: 700;
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: start;
    border-inline-end: 1px solid rgba(255, 255, 255, 0.14);
    white-space: nowrap;
    color: inherit;
}
.post-prose table:not(.blog-table) td,
.ink-essay-body table:not(.blog-table) td {
    padding: 0.6rem 0.9rem;
    border-top: 1px solid var(--border, #e2e8f0);
    vertical-align: top;
    color: var(--foreground, var(--fg-body, var(--fg, inherit)));
}
.post-prose table:not(.blog-table) tbody tr:nth-child(even),
.ink-essay-body table:not(.blog-table) tbody tr:nth-child(even) {
    background: var(--muted, var(--surface, rgba(0, 0, 0, 0.025)));
}

/* ── Component Builder Styles (for post content) ── */
.comp-hero {
    background: linear-gradient(135deg, var(--primary, #333), color-mix(in srgb, var(--primary, #333) 70%, black));
    color: white;
    padding: 3rem 2rem;
    text-align: center;
    margin: 1.5rem 0;
}

.comp-hero h2 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: white;
}

.comp-hero p {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 1.5rem;
    color: white;
}

.comp-hero a {
    display: inline-block;
    background: white;
    color: var(--primary, #333);
    padding: 0.6rem 1.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: transform 0.2s;
}

.comp-hero a:hover {
    transform: scale(1.05);
}

.comp-button {
    text-align: center;
    padding: 1rem 0;
}

.comp-button a {
    display: inline-block;
    background: var(--primary, #333);
    color: var(--primary-foreground, #fff);
    padding: 0.7rem 2rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s;
}

.comp-button a:hover {
    opacity: 0.9;
}

.comp-quote {
    border-inline-start: 3px solid var(--primary, #333);
    padding: 1rem 1.5rem;
    background: var(--muted, #f5f5f5);
    margin: 1.5rem 0;
}

.comp-quote blockquote {
    font-style: italic;
    font-size: 1.1rem;
    color: var(--foreground);
    margin-bottom: 0.5rem;
}

.comp-quote cite {
    font-size: 0.85rem;
    color: var(--muted-foreground, #737373);
}

.comp-imagetext {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin: 1.5rem 0;
}

.comp-imagetext img {
    width: 50%;
    object-fit: cover;
}

.comp-imagetext .it-content {
    flex: 1;
}

.comp-imagetext .it-content h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.comp-imagetext .it-content p {
    line-height: 1.7;
}

.comp-spacer {
    height: 60px;
}

.comp-divider hr {
    border: none;
    border-top: 1px solid var(--border, #e5e5e5);
    margin: 1.5rem 0;
}

.comp-video {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    margin: 1.5rem 0;
}

.comp-video iframe {
    position: absolute;
    top: 0;
    inset-inline-start: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.comp-image {
    margin: 1.5rem 0;
}

.comp-image img {
    width: 100%;
    display: block;
}

/* ── Gallery block (inkwell-gallery-editor.js writes it; inkwell-gallery.js adds the lightbox) ── */
.comp-gallery {
    display: grid;
    grid-template-columns: repeat(var(--gallery-cols, 3), minmax(0, 1fr));
    gap: 0.75rem;
    margin: 1.5rem 0;
}
.comp-gallery[data-columns="2"] { --gallery-cols: 2; }
.comp-gallery[data-columns="4"] { --gallery-cols: 4; }
.comp-gallery:empty { display: none; }
.comp-gallery-item { margin: 0; }
.comp-gallery-item a { display: block; border-radius: 6px; overflow: hidden; }
.comp-gallery-item a:focus-visible { outline: 2px solid var(--link, currentColor); outline-offset: 2px; }
.comp-gallery-item img {
    display: block;
    margin: 0;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: var(--surface, rgba(127, 127, 127, 0.12));
}
.comp-gallery-item figcaption {
    margin-top: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--fg-meta, inherit);
}
@media (max-width: 640px) {
    .comp-gallery, .comp-gallery[data-columns="2"], .comp-gallery[data-columns="4"] { --gallery-cols: 2; }
}

.ink-lightbox {
    width: min(96vw, 1200px);
    max-width: none;
    max-height: 96vh;
    padding: 0;
    border: 0;
    background: transparent;
    color: #fff;
}
.ink-lightbox::backdrop { background: rgba(0, 0, 0, 0.88); }
.ink-lightbox figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.ink-lightbox img { max-width: 100%; max-height: min(82vh, calc(96vh - 9rem)); object-fit: contain; }
.ink-lightbox figcaption { font-size: 0.9375rem; text-align: center; max-width: 70ch; }
.ink-lightbox-bar { display: flex; align-items: center; justify-content: center; gap: 0.75rem; margin-top: 0.75rem; }
.ink-lightbox button {
    min-width: 44px;
    min-height: 44px;
    padding: 0 0.875rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font: inherit;
    cursor: pointer;
}
.ink-lightbox button:hover { background: rgba(255, 255, 255, 0.15); }
.ink-lightbox button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.ink-lightbox-count { font-size: 0.875rem; opacity: 0.85; min-width: 4.5em; text-align: center; }

@media (max-width: 640px) {
    .comp-imagetext {
        flex-direction: column;
    }

    .comp-imagetext img {
        width: 100%;
    }
}

/* ── Pagination ─────────────────────────────── */
.pagination-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-btn {
    padding: 0.5rem 0.75rem;
    border: 1px dashed var(--border, #e5e5e5);
    font-size: 0.875rem;
    transition: all 0.2s;
}

.page-btn:hover,
.page-btn.active {
    background: var(--foreground, #171717);
    color: var(--background, #fff);
    border-style: solid;
}
/* ── Contact forms (ADR-0030) ─────────────────────────────────────────────────
   Theme tokens only, so every preset and both colour schemes style them. Errors are bold text with a marker,
   never colour alone. */
.ink-form { margin: 2rem 0; padding: 1.5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface, transparent); font-family: var(--font-body, inherit); }
.ink-form-title { margin: 0 0 1rem; font-size: 1.25rem; }
.ink-form-field { margin: 0 0 1rem; }
.ink-form-field > label { display: block; margin-bottom: 0.375rem; font-weight: 600; color: var(--fg); }
.ink-form input[type="text"], .ink-form input[type="email"], .ink-form textarea, .ink-form select {
    display: block; width: 100%; max-width: 36rem; padding: 0.625rem 0.75rem; font: inherit; font-size: 1rem;
    color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
}
.ink-form textarea { max-width: 100%; min-height: 8rem; }
.ink-form input:focus-visible, .ink-form textarea:focus-visible, .ink-form select:focus-visible, .ink-form-submit:focus-visible {
    outline: 2px solid var(--link, currentColor); outline-offset: 2px;
}
.ink-form [aria-invalid="true"] { border-width: 2px; border-color: var(--fg); }
.ink-form-check { display: flex; gap: 0.5rem; align-items: flex-start; color: var(--fg); }
.ink-form-check input { margin-top: 0.3rem; width: 1.1rem; height: 1.1rem; }
.ink-form-req { color: var(--fg-meta, inherit); }
.ink-form-help { margin: 0.25rem 0 0; font-size: 0.875rem; color: var(--fg-meta, inherit); }
.ink-form-field-error, .ink-form-error { margin: 0.375rem 0 0; font-weight: 700; color: var(--fg); }
.ink-form-field-error::before, .ink-form-error::before { content: "⚠ "; }
.ink-form-sent { margin: 0 0 1rem; padding: 0.75rem 1rem; border-inline-start: 4px solid var(--link, currentColor); color: var(--fg); }
.ink-form-sent::before { content: "✓ "; }
.ink-form-submit {
    display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0.625rem 1.5rem; font: inherit; font-weight: 600;
    color: var(--bg); background: var(--fg); border: 0; border-radius: 6px; cursor: pointer;
}
.ink-form-submit:disabled { opacity: 0.6; cursor: progress; }
.ink-form-hp { position: absolute; inset-inline-start: -10000px; width: 1px; height: 1px; overflow: hidden; }
