:root {
    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

body {
    font-family: var(--font-sans);
    color: #1a1a1a;
}

[data-bs-theme="dark"] body {
    background: #14161a;
    color: #e8e8e8;
}

.site-header {
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(0,0,0,.06);
}
[data-bs-theme="dark"] .site-header {
    background: rgba(20,22,26,.92);
    border-bottom-color: rgba(255,255,255,.08);
}

.site-footer {
    background: #f8f9fa;
    border-top: 1px solid rgba(0,0,0,.06);
}
[data-bs-theme="dark"] .site-footer {
    background: #1c1e23;
    border-top-color: rgba(255,255,255,.08);
}

/* --- Mobile nav panel: when the hamburger menu is open, give the
   category links / search box / theme toggle some breathing room and a
   visible divider from the brand row above, so it reads as one attached
   panel instead of loose floating controls. ------------------------- */
@media (max-width: 991.98px) {
    .site-header .navbar-collapse {
        margin-top: .75rem;
        padding-top: .75rem;
        padding-bottom: .75rem;
        border-top: 1px solid rgba(0,0,0,.08);
    }
    [data-bs-theme="dark"] .site-header .navbar-collapse {
        border-top-color: rgba(255,255,255,.12);
    }
    .site-header .navbar-nav .nav-link { padding: .5rem 0; }
    .site-header form[role="search"] { margin-bottom: .5rem; }
}

/* Extra breathing room between the header and the page content that
   follows it once the viewport is small enough that the collapsed menu
   panel is in play (phones) - without this, the last control in the
   panel (theme toggle) sits flush against the hero image/content below. */
@media (max-width: 575.98px) {
    .site-header { margin-bottom: 1rem; }
}

/* --- Hero / Featured -------------------------------------------------- */
.hero-card {
    position: relative;
    border-radius: 1rem;
    overflow: hidden;
    min-height: 420px;
    display: flex;
    align-items: flex-end;
    background: linear-gradient(135deg, #1a2332, #2d3a52);
    color: #fff;
}
.hero-card .hero-overlay {
    background: linear-gradient(0deg, rgba(0,0,0,.75) 0%, rgba(0,0,0,.1) 60%);
    padding: 2.5rem;
    width: 100%;
}
.hero-card h1 {
    font-size: clamp(1.375rem, 1rem + 2.2vw, 2rem);
    font-weight: 800;
    line-height: 1.2;
    overflow-wrap: anywhere;
    /* Guard against unusually long/garbled titles: cap to 3 lines
       instead of letting the hero card grow unbounded and cover the image. */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}
.hero-card .hero-overlay p {
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}
/* Phones: the clamp() above still leaves the title fairly large relative
   to a narrow screen - pin it to a clearly smaller fixed size here. */
@media (max-width: 576px) {
    .hero-card { min-height: 280px; }
    .hero-card .hero-overlay { padding: 1.25rem; }
    .hero-card h1 { font-size: 1.15rem; line-height: 1.3; }
    .hero-card .hero-overlay p { font-size: .85rem; }
}

.post-card {
    border-radius: .75rem;
    transition: transform .15s ease, box-shadow .15s ease;
}
.post-card:hover { transform: translateY(-2px); box-shadow: 0 .5rem 1.5rem rgba(0,0,0,.08); }
.post-card img { border-radius: .75rem .75rem 0 0; aspect-ratio: 16/9; object-fit: cover; }
.post-card .card-body h2,
.post-card .card-body h3 {
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.category-pill {
    font-size: .7rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: .03em;
}

/* --- Single post reading experience ----------------------------------- */
.reading-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    background: #0d6efd;
    z-index: 1050;
    width: 0%;
    transition: width .1s ease;
}

.article-body {
    font-size: 1.125rem;
    line-height: 1.8;
    max-width: 720px;
}
.article-body h2 { margin-top: 2.5rem; font-weight: 700; font-size: 1.5rem; }
.article-body h3 { margin-top: 2rem; font-weight: 700; font-size: 1.25rem; }
.article-body p { margin-bottom: 1.25rem; }
.article-body img { max-width: 100%; border-radius: .5rem; margin: 1.5rem 0; }
.article-body blockquote {
    border-left: 3px solid #0d6efd;
    padding-left: 1.25rem;
    color: #555;
    font-style: italic;
    margin: 1.5rem 0;
}
[data-bs-theme="dark"] .article-body blockquote { color: #aaa; }
.article-body pre {
    background: #f6f8fa;
    padding: 1.25rem;
    border-radius: .5rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: .875rem;
    position: relative;
}
[data-bs-theme="dark"] .article-body pre { background: #1e2126; }
.article-body table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
    margin: 1.5rem 0;
}
.article-body table th, .article-body table td {
    border: 1px solid #dee2e6;
    padding: .6rem .8rem;
    white-space: nowrap;
}

.copy-code-btn {
    position: absolute;
    top: .6rem;
    right: .6rem;
    font-size: .7rem;
    padding: .2rem .5rem;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: .25rem;
    cursor: pointer;
}
[data-bs-theme="dark"] .copy-code-btn { background: #2a2d33; border-color: #444; color: #ddd; }

.toc-sidebar {
    position: sticky;
    top: 6rem;
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
}
.toc-sidebar a { display: block; padding: .25rem 0; font-size: .875rem; color: #6c757d; text-decoration: none; border-left: 2px solid transparent; padding-left: .75rem; }
.toc-sidebar a:hover, .toc-sidebar a.active { color: #0d6efd; border-left-color: #0d6efd; }

.author-box {
    border-radius: .75rem;
    background: #f8f9fa;
}
[data-bs-theme="dark"] .author-box { background: #1c1e23; }

.share-btn {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    border: 1px solid #dee2e6;
    color: inherit;
}
[data-bs-theme="dark"] .share-btn { border-color: #444; }

/* --- Accessibility (Phase 8) ------------------------------------------ */

/* Visible only when focused via keyboard - lets keyboard/screen-reader
   users jump past the header/nav straight to the main content. */
.skip-link {
    position: absolute;
    top: -3rem;
    left: .5rem;
    z-index: 2000;
    background: #0d6efd;
    color: #fff;
    padding: .5rem 1rem;
    border-radius: .25rem;
    text-decoration: none;
}
.skip-link:focus {
    top: .5rem;
}

/* Bootstrap's default focus ring is good; this strengthens it specifically
   for the custom, non-Bootstrap interactive elements this theme adds
   (share/bookmark buttons, TOC links) so keyboard focus is never invisible. */
.share-btn:focus-visible,
.toc-sidebar a:focus-visible,
.post-card:focus-within {
    outline: 3px solid #0d6efd;
    outline-offset: 2px;
}