/* Blog Styles — Core (shared by all domains) */

/* ── Fonts (self-hosted) ── */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('/fonts/inter-latin.woff2') format('woff2');
    size-adjust: 107%;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 500;
    font-display: swap;
    src: url('/fonts/jetbrains-mono-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Reserve space for JS-populated grids (prevents CLS on mobile) ── */
#filterGrid { min-height: 320px; }

/* ── New article badge ── */
.new-badge {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #fb923c;
    background: rgba(251, 146, 60, 0.1);
    border: 1px solid rgba(251, 146, 60, 0.2);
    padding: 0.1rem 0.45rem;
    border-radius: 9999px;
    white-space: nowrap;
}

/* ── Base ── */
html { overflow-x: clip; }
body { overflow-x: clip; max-width: 100vw; }

/* ── Nav Glass ── */
.nav-glass {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border-bottom: 1px solid rgba(71, 85, 105, 0.3);
}

/* ── Navbar Search ── */
.nav-search-input {
    width: 11rem;
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(71, 85, 105, 0.4);
    border-radius: 0.5rem;
    color: #f8fafc;
    font-size: 0.8125rem;
    outline: none;
    transition: width 0.25s ease, border-color 0.15s;
}
.nav-search-input::placeholder { color: #8494a7; }
.nav-search-input:focus {
    width: 16rem;
    border-color: rgba(56, 189, 248, 0.5);
}
.nav-search-icon {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    color: #8494a7;
    pointer-events: none;
}
.nav-search-mobile {
    width: 100%;
    padding: 0.625rem 1rem;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(71, 85, 105, 0.5);
    border-radius: 0.625rem;
    color: #f8fafc;
    font-size: 0.9375rem;
    outline: none;
    transition: border-color 0.15s;
}
.nav-search-mobile::placeholder { color: #8494a7; }
.nav-search-mobile:focus { border-color: rgba(56, 189, 248, 0.5); }

/* ── Navbar Search Dropdown ── */
.nav-search-wrap { position: relative; }
.nav-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 22rem;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid rgba(71, 85, 105, 0.4);
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 50;
    max-height: 340px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(71, 85, 105, 0.5) transparent;
    display: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.nav-search-dropdown.open { display: block; }
.nav-search-dropdown.visible { opacity: 1; transform: translateY(0); }
.nav-search-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    color: #cbd5e1;
    font-size: 0.8125rem;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.1s;
}
.nav-search-item:first-child { border-radius: 0.75rem 0.75rem 0 0; }
.nav-search-item:last-child { border-radius: 0 0 0.75rem 0.75rem; }
.nav-search-item:hover,
.nav-search-item.active {
    background: rgba(56, 189, 248, 0.1);
    color: #f8fafc;
}
.nav-search-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nav-search-item-title strong {
    color: #38bdf8;
    font-weight: 600;
}
.nav-search-item-cat {
    flex-shrink: 0;
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 9999px;
    text-transform: capitalize;
    opacity: 0.8;
}
.nav-search-hint {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.625rem;
    font-family: 'JetBrains Mono', monospace;
    color: #64748b;
    background: rgba(51, 65, 85, 0.5);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    border: 1px solid rgba(71, 85, 105, 0.3);
    pointer-events: none;
    transition: opacity 0.15s;
}
.nav-search-input:focus ~ .nav-search-hint,
.nav-search-input:not(:placeholder-shown) ~ .nav-search-hint { opacity: 0; }
.nav-search-recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.875rem 0.25rem;
    font-size: 0.6875rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.nav-search-recent-clear {
    color: #64748b;
    font-size: 0.6875rem;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
    background: none;
    border: none;
    padding: 0;
    transition: color 0.15s;
}
.nav-search-recent-clear:hover { color: #94a3b8; }

/* Mobile dropdown */
.nav-search-dropdown-mobile {
    width: 100%;
    margin-top: 0.5rem;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid rgba(71, 85, 105, 0.4);
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    max-height: 280px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(71, 85, 105, 0.5) transparent;
    display: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.nav-search-dropdown-mobile.open { display: block; }
.nav-search-dropdown-mobile.visible { opacity: 1; transform: translateY(0); }

/* ── Featured Cards ── */
.featured-card {
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    background: #1e293b;
    border: 1px solid rgba(71, 85, 105, 0.4);
    border-radius: 1rem;
    transition: all 0.2s ease;
    text-decoration: none;
}
.featured-card:hover {
    border-color: rgba(56, 189, 248, 0.3);
    background: rgba(30, 41, 59, 0.8);
    box-shadow: 0 4px 20px rgba(56, 189, 248, 0.06);
    transform: translateY(-2px);
}

/* ── Article Cards ── */
.article-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background: #1e293b;
    border: 1px solid rgba(71, 85, 105, 0.3);
    border-radius: 1rem;
    transition: all 0.2s ease;
    text-decoration: none;
}
.article-card:hover {
    border-color: rgba(56, 189, 248, 0.3);
    background: rgba(30, 41, 59, 0.8);
    box-shadow: 0 4px 20px rgba(56, 189, 248, 0.06);
    transform: translateY(-2px);
}

/* ── Category Badges ── */
.category-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid;
    text-transform: capitalize;
}

.category-badge-sm {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    border: 1px solid;
    text-transform: capitalize;
}

/* ── Tag Chips ── */
.tag-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
}
.tag-scroll::-webkit-scrollbar { display: none; }

.tag-chip {
    flex-shrink: 0;
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 500;
    background: #1e293b;
    color: #94a3b8;
    border: 1px solid rgba(71, 85, 105, 0.4);
    transition: all 0.15s ease;
    cursor: pointer;
    white-space: nowrap;
}
.tag-chip:hover {
    color: #e2e8f0;
    border-color: rgba(71, 85, 105, 0.7);
}
.tag-chip.active {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.3);
}

/* ── Section Chips ── */
.section-chip {
    flex-shrink: 0;
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 600;
    background: #1e293b;
    color: #94a3b8;
    border: 1px solid rgba(71, 85, 105, 0.4);
    transition: all 0.15s ease;
    cursor: pointer;
    white-space: nowrap;
}
.section-chip:hover {
    color: #e2e8f0;
    border-color: rgba(71, 85, 105, 0.7);
}
.section-chip.active {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.3);
}

/* ── Line Clamp ── */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Table of Contents ── */
.toc-nav .toc-link {
    display: block;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    color: #8494a7;
    border-left: 2px solid transparent;
    text-decoration: none;
    transition: all 0.15s ease;
    line-height: 1.4;
}
.toc-nav .toc-link:hover {
    color: #e2e8f0;
}
.toc-nav .toc-link.active {
    color: #38bdf8;
    border-left-color: #38bdf8;
}

/* ── Prose (Markdown Content) ── */
.prose-custom {
    line-height: 1.8;
    font-size: 1.0625rem;
    color: #cbd5e1;
}

.prose-custom h2 {
    font-size: 1.625rem;
    font-weight: 700;
    color: #f8fafc;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(71, 85, 105, 0.3);
}

.prose-custom h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.prose-custom h4 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.prose-custom p {
    margin-bottom: 1.25rem;
}

.prose-custom a {
    color: #38bdf8;
    text-decoration: underline;
    text-decoration-color: rgba(56, 189, 248, 0.3);
    text-underline-offset: 3px;
    transition: all 0.15s;
}
.prose-custom a:hover {
    text-decoration-color: #38bdf8;
}

.prose-custom strong {
    color: #f8fafc;
    font-weight: 600;
}

.prose-custom ul, .prose-custom ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}
.prose-custom ul { list-style-type: disc; }
.prose-custom ol { list-style-type: decimal; }
.prose-custom li {
    margin-bottom: 0.5rem;
    line-height: 1.7;
}

.prose-custom blockquote {
    border-left: 3px solid #38bdf8;
    margin: 1.5rem 0;
    padding: 0.75rem 1.25rem;
    background: rgba(56, 189, 248, 0.05);
    border-radius: 0 0.5rem 0.5rem 0;
    color: #94a3b8;
    font-style: italic;
}
.prose-custom blockquote p:last-child {
    margin-bottom: 0;
}

.prose-custom code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875em;
    background: rgba(30, 41, 59, 0.8);
    color: #7dd3fc;
    padding: 0.15em 0.4em;
    border-radius: 0.25rem;
    border: 1px solid rgba(71, 85, 105, 0.3);
}

.prose-custom pre {
    position: relative;
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: #0d1117;
    border: 1px solid rgba(71, 85, 105, 0.3);
    border-radius: 0.75rem;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(71, 85, 105, 0.5) transparent;
}

.code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: rgba(71, 85, 105, 0.4);
    border: 1px solid rgba(71, 85, 105, 0.3);
    border-radius: 0.375rem;
    color: #94a3b8;
    font-size: 0.6875rem;
    font-family: inherit;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    z-index: 1;
}
.prose-custom pre:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover {
    background: rgba(71, 85, 105, 0.6);
    color: #e2e8f0;
}
.code-copy-btn.copied {
    background: rgba(74, 222, 128, 0.15);
    border-color: rgba(74, 222, 128, 0.3);
    color: #4ade80;
}
.prose-custom pre::-webkit-scrollbar { height: 6px; }
.prose-custom pre::-webkit-scrollbar-track { background: transparent; }
.prose-custom pre::-webkit-scrollbar-thumb { background: rgba(71, 85, 105, 0.5); border-radius: 3px; }

.prose-custom pre code {
    background: none;
    border: none;
    padding: 0;
    color: #e6edf3;
    font-size: 0.8125rem;
    line-height: 1.6;
}

.prose-custom table {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: collapse;
    font-size: 0.9375rem;
}
.prose-custom thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: rgba(30, 41, 59, 0.8);
    color: #e2e8f0;
    font-weight: 600;
    border-bottom: 2px solid rgba(71, 85, 105, 0.4);
    font-size: 0.875rem;
    white-space: nowrap;
}
.prose-custom tbody td {
    padding: 0.625rem 1rem;
    border-bottom: 1px solid rgba(71, 85, 105, 0.2);
    vertical-align: top;
}
.prose-custom tbody tr:hover {
    background: rgba(30, 41, 59, 0.4);
}

.prose-custom hr {
    border: none;
    border-top: 1px solid rgba(71, 85, 105, 0.3);
    margin: 2rem 0;
}

.prose-custom img {
    max-width: 100%;
    border-radius: 0.75rem;
}

/* ── Responsive Table Wrapper ── */
@media (max-width: 640px) {
    .prose-custom table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    .prose-custom thead th,
    .prose-custom tbody td {
        padding: 0.5rem 0.625rem;
        font-size: 0.8125rem;
    }
}

/* ── SVG Animation Container ── */
.hero-svg-container {
    animation: float 6s ease-in-out infinite;
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ── Scroll-triggered animations ── */
.svg-animate {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.svg-animate.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Fade-in ── */
.fade-in {
    animation: fadeIn 0.4s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Reading Progress Bar ── */
.reading-progress {
    position: fixed;
    top: 64px; /* below navbar */
    left: 0;
    width: 0%;
    height: 2px;
    background: linear-gradient(90deg, #38bdf8, #818cf8);
    z-index: 60;
    transition: width 50ms linear;
}

/* ── Article Card Thumbnail ── */
.card-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 200px;
    margin-bottom: 0.75rem;
    border-radius: 0.5rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(71, 85, 105, 0.2);
    overflow: hidden;
}
.card-thumb object {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ── Sidebar Scrollbar ── */
.scrollbar-thin {
    scrollbar-width: thin;
    scrollbar-color: rgba(71, 85, 105, 0.3) transparent;
}
.scrollbar-thin::-webkit-scrollbar { width: 4px; }
.scrollbar-thin::-webkit-scrollbar-track { background: transparent; }
.scrollbar-thin::-webkit-scrollbar-thumb { background: rgba(71, 85, 105, 0.3); border-radius: 2px; }

/* ── Mobile ToC Panel ── */
#tocMobilePanel {
    scrollbar-width: thin;
    scrollbar-color: rgba(71, 85, 105, 0.5) transparent;
}
#tocMobilePanel::-webkit-scrollbar { width: 4px; }
#tocMobilePanel::-webkit-scrollbar-track { background: transparent; }
#tocMobilePanel::-webkit-scrollbar-thumb { background: rgba(71, 85, 105, 0.5); border-radius: 2px; }

/* ── Newsletter Sticky Footer Bar ── */
.newsletter-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border-top: 1px solid rgba(71, 85, 105, 0.3);
    transform: translateY(0);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.newsletter-bar-hidden {
    transform: translateY(100%);
}
.newsletter-bar-inner {
    max-width: 72rem;
    margin: 0 auto;
    padding: 0.875rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.newsletter-bar-close {
    color: #8494a7;
    font-size: 1.5rem;
    line-height: 1;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 0.25rem;
    transition: color 0.15s;
}
.newsletter-bar-close:hover { color: #e2e8f0; }
.newsletter-bar-text {
    flex: 1;
    font-size: 0.875rem;
    color: #94a3b8;
    min-width: 180px;
}
.newsletter-bar-form {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}
.newsletter-bar-input {
    padding: 0.5rem 0.875rem;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(71, 85, 105, 0.5);
    border-radius: 0.625rem;
    color: #f8fafc;
    font-size: 0.8125rem;
    outline: none;
    width: 200px;
    transition: border-color 0.15s;
}
.newsletter-bar-input::placeholder { color: #8494a7; }
.newsletter-bar-input:focus { border-color: rgba(56, 189, 248, 0.5); }
.newsletter-bar-btn {
    padding: 0.5rem 1.25rem;
    background: #38bdf8;
    color: #0f172a;
    font-size: 0.8125rem;
    font-weight: 600;
    border: none;
    border-radius: 0.625rem;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.newsletter-bar-btn:hover { background: #0ea5e9; }
.newsletter-bar-telegram {
    display: flex;
    align-items: center;
    color: #8494a7;
    text-decoration: none;
    transition: color 0.15s;
    flex-shrink: 0;
}
.newsletter-bar-telegram:hover { color: #38bdf8; }

@media (max-width: 640px) {
    .newsletter-bar-inner { padding: 0.75rem 1rem; gap: 0.625rem; }
    .newsletter-bar-text { font-size: 0.8125rem; min-width: 0; flex-basis: 100%; order: 1; }
    .newsletter-bar-close { order: 0; }
    .newsletter-bar-form { order: 2; width: 100%; }
    .newsletter-bar-input { flex: 1; width: auto; }
    .newsletter-bar-telegram { order: 3; }
}
