@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg: #000000;
    --text: #d6d6d6;
    --heading: #e9e9e9;
    --muted: #9aa0a6;
    --surface: rgba(255,255,255,0.04);
    --surface-2: rgba(255,255,255,0.06);
    --border: rgba(255,255,255,0.08);
    --accent: #33b0d8;
    --transition: 0.2s ease;
    --radius: 18px;
}

/* -------------------- BASE -------------------- */

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, sans-serif;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    color: var(--heading);
    letter-spacing: -0.02em;
}

p { color: var(--text); }

img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: opacity var(--transition);
}
a:hover { opacity: 0.85; }

a:focus-visible, .post-card a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: 4px;
    opacity: 1;
}

/* -------------------- BACKGROUND -------------------- */

.background {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: #000;
    overflow: hidden;
}

.background::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 50% 100% at 50% 50%, #000 0%, transparent 100%);
    z-index: 1;
    pointer-events: none;
}

.background .floating-logo {
    position: absolute;
    width: 120px;
    height: 120px;
    opacity: 0.12;
    animation: float-logo 45s linear infinite;
}

.background .floating-logo:nth-child(1) { left: 2%; top: 10%; animation-duration: 50s; animation-delay: 0s; width: 150px; height: 150px; }
.background .floating-logo:nth-child(2) { right: 2%; left: auto; top: 5%; animation-duration: 38s; animation-delay: -8s; width: 110px; height: 110px; opacity: 0.10; }
.background .floating-logo:nth-child(3) { left: 3%; top: 65%; animation-duration: 55s; animation-delay: -20s; width: 170px; height: 170px; opacity: 0.09; }
.background .floating-logo:nth-child(4) { right: 3%; left: auto; top: 70%; animation-duration: 42s; animation-delay: -12s; width: 100px; height: 100px; opacity: 0.11; }
.background .floating-logo:nth-child(5) { right: 5%; left: auto; top: 40%; animation-duration: 60s; animation-delay: -30s; width: 130px; height: 130px; opacity: 0.10; }

@keyframes float-logo {
    0%   { transform: translate(0, 0) rotate(0deg); }
    25%  { transform: translate(80px, -60px) rotate(90deg); }
    50%  { transform: translate(-40px, -120px) rotate(180deg); }
    75%  { transform: translate(60px, 40px) rotate(270deg); }
    100% { transform: translate(0, 0) rotate(360deg); }
}

/* -------------------- LAYOUT -------------------- */

.container {
    max-width: 820px;
    margin: auto;
    padding: 80px 24px;
}

.hero { margin-bottom: 60px; }

.hero h1 {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 1.1;
    background: linear-gradient(to right, #e9e9e9, #33b0d8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    margin-top: 12px;
    color: var(--muted);
    font-size: 1.05rem;
    max-width: 520px;
}

.discord {
    display: inline-block;
    margin-top: 18px;
    color: var(--accent);
}

/* -------------------- TAG FILTERS -------------------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 32px;
}

.filter-btn {
    padding: 6px 16px;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.filter-btn:hover {
    border-color: rgba(255,255,255,0.16);
    color: var(--text);
}

.filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #0b0c0f;
    font-weight: 600;
}

.filter-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* -------------------- POSTS -------------------- */

.posts {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.post-card {
    padding: 26px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    transition: transform var(--transition), border-color var(--transition), opacity 0.25s ease;
}

.post-card:hover {
    transform: translateY(-3px);
    border-color: rgba(51, 176, 216, 0.3);
}

.post-card h2 {
    margin-top: 10px;
    margin-bottom: 10px;
    font-size: 1.4rem;
}

.post-card p {
    color: var(--muted);
    margin-bottom: 14px;
}

.date {
    color: var(--muted);
    font-size: 0.85rem;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    border: 1px solid var(--border);
    color: var(--muted);
    transition: color var(--transition), border-color var(--transition);
}

.post-card:hover .tag {
    color: var(--text);
    border-color: rgba(255,255,255,0.14);
}

/* Hidden state for filtered cards */
.post-card.hidden {
    display: none;
}

/* -------------------- EMPTY STATE -------------------- */

.empty-state {
    display: none;
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}

.empty-state.visible {
    display: block;
}

.empty-state p {
    color: var(--muted);
    font-size: 0.95rem;
}

/* -------------------- ARTICLE (post pages) -------------------- */

.article {
    max-width: 760px;
    margin: auto;
    padding: 80px 24px;
}

.article p, .article h1, .article h2 {
    overflow-wrap: break-word;
}

.article h1 {
    font-size: clamp(2rem, 6vw, 3rem);
    margin-bottom: 18px;
    line-height: 1.2;
}

.article h2 {
    margin-top: 44px;
    margin-bottom: 12px;
}

.article p {
    margin-bottom: 18px;
    color: var(--text);
}

.meta {
    color: var(--muted);
    margin-bottom: 18px;
}

.back {
    display: inline-block;
    margin-bottom: 28px;
    color: var(--accent);
}

/* -------------------- BLOCKQUOTE -------------------- */

blockquote {
    margin: 24px 0;
    padding-left: 16px;
    border-left: 3px solid var(--accent);
    color: #cfd3d7;
    font-size: 1.05rem;
    font-style: italic;
}

/* -------------------- CODE & SYNTAX HIGHLIGHTING -------------------- */

pre {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    overflow-x: auto;
    margin: 20px 0;
    position: relative;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.88rem;
    color: #cfd3d7;
    line-height: 1.7;
}

p code {
    background: rgba(255,255,255,0.06);
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 0.88rem;
}

.tok-keyword    { color: #ff7b72; }
.tok-string     { color: #a5d6ff; }
.tok-comment    { color: #6e7681; font-style: italic; }
.tok-number     { color: #79c0ff; }
.tok-builtin    { color: #ffa657; }
.tok-function   { color: #7ee787; }
.tok-decorator  { color: #ffa657; }
.tok-operator   { color: #ff7b72; }
.tok-self       { color: #ffa657; font-style: italic; }
.tok-punctuation{ color: #8b949e; }

/* -------------------- TABLES (cell hover) -------------------- */

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 24px 0;
    font-size: 0.95rem;
    display: block;
    overflow-x: auto;
}

th, td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

th {
    color: var(--heading);
    font-weight: 600;
    background: rgba(255,255,255,0.03);
}

td {
    color: var(--text);
    transition: background 0.15s ease;
}

td:hover {
    background: rgba(51, 176, 216, 0.08);
}

/* -------------------- KATEX OVERRIDES -------------------- */

.katex { color: var(--text); font-size: 1.08em; }

.katex-display {
    margin: 24px 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 0;
}

.katex-display > .katex { color: #e0e0e0; }

/* -------------------- INLINE ELEMENTS -------------------- */

mark {
    background: rgba(51, 176, 216, 0.18);
    color: var(--text);
    padding: 1px 5px;
    border-radius: 4px;
}

kbd {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 2px 7px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.82em;
    color: var(--heading);
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 36px 0;
}

/* -------------------- DETAILS / SUMMARY -------------------- */

details {
    margin: 16px 0;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

details summary {
    cursor: pointer;
    color: var(--heading);
    font-weight: 500;
    list-style: none;
    transition: color var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

details summary::-webkit-details-marker { display: none; }

details summary::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid var(--accent);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform var(--transition);
    flex-shrink: 0;
}

details[open] summary::before {
    transform: rotate(90deg);
}

details summary:hover { color: var(--accent); }
details p { margin-top: 12px; }

/* -------------------- LIGHTBOX -------------------- */

.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 10px;
    object-fit: contain;
    transform: scale(0.92);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    user-select: none;
    -webkit-user-drag: none;
}

.lightbox-overlay.active .lightbox-img {
    transform: scale(1);
    opacity: 1;
}

.lightbox-btn {
    position: absolute;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.2);
}

.lightbox-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.lightbox-close {
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
}

.lightbox-arrow {
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

.lightbox-counter {
    position: absolute;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    pointer-events: none;
}

@media (max-width: 640px) {
    .lightbox-arrow { width: 42px; height: 42px; }
    .lightbox-prev { left: 10px; }
    .lightbox-next { right: 10px; }
    .lightbox-close { top: 14px; right: 14px; width: 40px; height: 40px; }
    .lightbox-img { max-width: 95vw; max-height: 78vh; border-radius: 8px; }
    .lightbox-counter { bottom: 16px; }
}

/* -------------------- CLICKABLE ARTICLE IMAGES -------------------- */

.article img {
    cursor: zoom-in;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.article img:hover {
    filter: brightness(1.08);
    transform: scale(1.005);
}

/* -------------------- SIDEBAR -------------------- */

.article-sidebar {
    position: fixed;
    top: 80px;
    right: 24px;
    width: 220px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 16px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 14px;
    z-index: 100;
}

.sidebar-title {
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
    margin-top: 16px;
}

.sidebar-title:first-child { margin-top: 0; }

.sidebar-toc, .sidebar-files {
    list-style: none;
    padding: 0;
    margin: 0 0 8px 0;
}

.sidebar-toc li { margin-bottom: 2px; }

.sidebar-toc a {
    display: block;
    padding: 3px 8px;
    color: var(--muted);
    font-size: 0.8rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-toc a:hover { color: var(--heading); background: rgba(255,255,255,0.05); }
.sidebar-toc a.active { color: var(--accent); background: rgba(51,176,216,0.1); }

.toc-h1 a { font-weight: 600; }
.toc-h2 a { padding-left: 16px; }
.toc-h3 a { padding-left: 28px; font-size: 0.75rem; }

.sidebar-files li { margin-bottom: 4px; }

.sidebar-file-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 5px 8px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.78rem;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    text-align: left;
    font-family: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-file-btn:hover {
    color: var(--accent);
    background: rgba(51,176,216,0.08);
    border-color: rgba(51,176,216,0.3);
}

.sidebar-file-btn svg { flex-shrink: 0; }

@media (max-width: 1200px) {
    .article-sidebar { display: none; }
}

/* -------------------- COLLAPSIBLE CODE -------------------- */

.code-collapsible { margin: 20px 0; }

.code-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
    color: var(--heading);
    font-size: 0.85rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.code-toggle:hover { background: rgba(255,255,255,0.07); }

.code-toggle-arrow {
    color: var(--accent);
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.code-collapsible pre {
    margin-top: 0;
    border-top: none;
    border-radius: 0 0 14px 14px;
    max-height: 2000px;
    transition: max-height 0.3s ease;
}

.code-collapsible pre.collapsed {
    max-height: 0;
    padding: 0 20px;
    overflow: hidden;
    border-color: transparent;
}

.code-collapsible .code-toggle[aria-expanded="false"] + pre {
    border-top: none;
}

.code-collapsible .code-toggle[aria-expanded="false"] {
    border-radius: 14px;
}

/* copy button */
pre { position: relative; }
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #1e1e1e;
    color: #fff;
    border: 1px solid #333;
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0;
    transition: 0.2s;
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:active { transform: scale(0.95); }

/* -------------------- SELECTION & SCROLLBARS -------------------- */

::selection {
    background: rgba(51,176,216,0.25);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }