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

:root {
    --bg: #0a0a0a;
    --bg-secondary: #101010;
    --bg-card: #131313;
    --text: #d4d4d4;
    --text-dim: #6b6b6b;
    --red: #ff3b3b;
    --red-bright: #ff5c5c;
    --red-dim: #7a1f1f;
    --border: #1f1f1f;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
    --radius: 10px;
    --glow: 0 0 12px rgba(255, 59, 59, 0.45);
}

html {
    font-size: 15px;
}

body {
    background:
        radial-gradient(ellipse at 50% -20%, #131313 0%, #0a0a0a 60%),
        var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0 1.25rem;
}

/* Grid background */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 59, 59, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 59, 59, 0.035) 1px, transparent 1px);
    background-size: 38px 38px;
    mask-image: radial-gradient(ellipse at 50% 0%, black 40%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse at 50% 0%, black 40%, transparent 100%);
}

/* CRT scanlines */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.18) 0px,
        rgba(0, 0, 0, 0.18) 1px,
        transparent 1px,
        transparent 3px
    );
    animation: flicker 4s infinite;
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    92% { opacity: 1; }
    93% { opacity: 0.6; }
    94% { opacity: 1; }
    97% { opacity: 0.8; }
    98% { opacity: 1; }
}

a {
    color: var(--red);
    text-decoration: none;
    transition: color 0.15s ease, text-shadow 0.15s ease;
}

a:hover {
    color: var(--red-bright);
    text-shadow: var(--glow);
    text-decoration: none;
}

.red {
    color: var(--red);
}

::selection {
    background: var(--red);
    color: #0a0a0a;
}

/* Layout - centered column for desktop */
nav,
main,
footer {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Nav */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 0;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.logo {
    font-size: 1rem;
    font-weight: bold;
    letter-spacing: 1px;
}

.logo .red {
    text-shadow: 0 0 14px rgba(255, 59, 59, 0.6);
    animation: blink 2.5s steps(1) infinite;
}

@keyframes blink {
    50% { opacity: 0.25; }
}

.links {
    display: flex;
    gap: 1.4rem;
}

.nav-link {
    font-size: 0.8rem;
    color: var(--text-dim);
    transition: color 0.15s ease;
}

.nav-link::before {
    content: ">";
    opacity: 0;
    margin-right: 2px;
    transition: opacity 0.15s ease;
}

.nav-link:hover {
    color: var(--red);
}

.nav-link:hover::before {
    opacity: 1;
}

/* Main */
main {
    flex: 1;
    padding: 2.5rem 0;
}

/* Hero */
.hero {
    margin-bottom: 2.5rem;
}

/* Matrix intro - hacker terminal */
.matrix-stage {
    position: relative;
    width: 100%;
    height: 60vh;
    min-height: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #08060a;
    margin-bottom: 2.5rem;
}

.matrix {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.matrix-overlay {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    text-align: center;
    padding: 0 1rem;
}

.matrix-quotes {
    max-width: 760px;
}

.matrix-quote-inner {
    font-size: 1.15rem;
    color: #ffb3c1;
    text-shadow: 0 0 14px rgba(255, 59, 91, 0.7);
    line-height: 1.5;
    white-space: pre-wrap;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.matrix-quote-inner.mq-enter {
    animation: mq-in 0.25s steps(3) both;
}

@keyframes mq-in {
    0%   { transform: translateX(-6px); opacity: 0; clip-path: inset(0 100% 0 0); }
    50%  { transform: translateX(3px); }
    100% { transform: translateX(0); opacity: 1; clip-path: inset(0 0 0 0); }
}

.mq-text.mq-done::after {
    content: "▌";
    color: #ff3b6b;
    animation: blink 0.9s steps(1) infinite;
}

/* quote navigation - subtle, integrated */
.matrix-nav {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.mat-btn {
    background: transparent;
    border: none;
    color: #ff6b86;
    padding: 0.25rem 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 0.2s ease, text-shadow 0.2s ease;
}

.mat-btn:hover {
    color: #ffb3c1;
    text-shadow: 0 0 10px rgba(255, 59, 91, 0.8);
}

.matrix-count {
    font-size: 0.72rem;
    color: var(--text-dim);
    letter-spacing: 1px;
}

.content-after-matrix {
    opacity: 1;
    transform: translateY(0);
}

.hero h1 {
    position: relative;
    display: inline-block;
    font-size: 1.75rem;
    font-weight: bold;
    margin-bottom: 0.35rem;
    letter-spacing: 0.5px;
    text-shadow: 0 0 20px rgba(255, 59, 59, 0.3);
}

/* Glitch layers (invisible until hover) */
.hero h1::before,
.hero h1::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
}

.hero h1:hover::before {
    opacity: 0.75;
    color: var(--red-bright);
    clip-path: inset(0 0 55% 0);
    animation: glitch-a 0.35s steps(2) infinite;
}

.hero h1:hover::after {
    opacity: 0.75;
    color: #ff8787;
    clip-path: inset(55% 0 0 0);
    animation: glitch-b 0.35s steps(2) infinite;
}

@keyframes glitch-a {
    0%   { transform: translateX(-2px); }
    50%  { transform: translateX(2px); }
    100% { transform: translateX(-2px); }
}

@keyframes glitch-b {
    0%   { transform: translateX(2px); }
    50%  { transform: translateX(-3px); }
    100% { transform: translateX(2px); }
}

.tagline {
    color: var(--text-dim);
    font-size: 0.85rem;
}

/* Typing cursor */
[data-typing]::after {
    content: "▌";
    margin-left: 2px;
    color: var(--red);
    animation: blink 0.9s steps(1) infinite;
}

h1 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

/* Page intro (from _index.md) */
.page-intro {
    margin-bottom: 2rem;
}

.page-intro p {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 0.85rem;
}

.page-intro ul,
.page-intro ol {
    margin-left: 1.2rem;
    margin-bottom: 0.9rem;
    font-size: 0.85rem;
    color: var(--text-dim);
    list-style: none;
}

.page-intro ul li,
.page-intro ol li {
    margin-bottom: 0.15rem;
    padding-left: 0.3rem;
}

.page-intro ul li::before {
    content: ">";
    color: var(--red);
    margin-right: 0.4rem;
}

.page-intro li a {
    color: var(--red);
}

.page-intro li a:hover {
    color: var(--red-bright);
}

/* Section */
section h2 {
    font-size: 0.9rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

section h2::before {
    content: "# ";
    color: var(--red);
}

/* Section header + slider controls */
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
}

.section-head h2 {
    margin-bottom: 0;
}

.scroll-controls {
    display: flex;
    gap: 0.4rem;
}

.scroll-btn {
    background: var(--bg-card);
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 1rem;
    line-height: 1;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.scroll-btn:hover {
    border-color: var(--red-dim);
    color: var(--red);
}

/* Horizontal scroll slider */
.recent-scroll {
    display: flex;
    gap: 0.7rem;
    overflow-x: auto;
    padding: 0.15rem 0.15rem 1rem;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: var(--red-dim) transparent;
}

.recent-scroll::-webkit-scrollbar {
    height: 5px;
}

.recent-scroll::-webkit-scrollbar-thumb {
    background: var(--red-dim);
    border-radius: 3px;
}

.recent-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.recent-card {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-width: 210px;
    max-width: 300px;
    padding: 0.9rem 1.1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.recent-card:hover {
    border-color: var(--red-dim);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(255, 59, 59, 0.1);
}

.recent-cat {
    font-size: 0.58rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--red);
    opacity: 0.8;
}

.recent-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1.35;
}

.recent-date {
    font-size: 0.62rem;
    color: var(--text-dim);
}

.recent-desc {
    font-size: 0.72rem;
    color: var(--text-dim);
    opacity: 0.8;
    margin: 0;
    line-height: 1.4;
}

/* Items */
.item-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.item {
    padding: 0.85rem 1.1rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: var(--radius);
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.item:hover {
    border-color: var(--red-dim);
    transform: translateX(3px);
    box-shadow: 0 0 16px rgba(255, 59, 59, 0.08);
}

.item a {
    font-weight: 600;
    font-size: 0.9rem;
}

.item a::before {
    content: "> ";
    color: var(--red-dim);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.item:hover a::before {
    opacity: 1;
}

.item .date {
    float: right;
    font-size: 0.7rem;
    color: var(--text-dim);
    padding-top: 0.25rem;
}

.item p {
    font-size: 0.78rem;
    margin-top: 0.25rem;
    color: var(--text-dim);
}

.empty {
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.8rem;
}

/* Post */
.post-header {
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.back {
    font-size: 0.75rem;
    color: var(--text-dim);
    display: inline-block;
    margin-bottom: 0.9rem;
}

.back:hover {
    color: var(--red);
}

.post-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.4rem;
}

.post-header .date {
    font-size: 0.7rem;
    color: var(--text-dim);
}

.post-header .date::before {
    content: "[ ";
    color: var(--red-dim);
}

.post-header .date::after {
    content: " ]";
    color: var(--red-dim);
}

/* Article content */
article h1,
article h2,
article h3 {
    margin-top: 1.4rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

article h1 { font-size: 1.25rem; }
article h2 { font-size: 1.05rem; }
article h3 { font-size: 0.9rem; }

article p {
    margin-bottom: 0.9rem;
    font-size: 0.85rem;
}

article ul, article ol {
    margin-left: 1.4rem;
    margin-bottom: 0.9rem;
    font-size: 0.85rem;
}

article li {
    margin-bottom: 0.25rem;
}

article code {
    background: var(--bg-card);
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.8rem;
    color: var(--red);
}

/* Terminal window for code blocks */
article pre {
    position: relative;
    background: #0c0c0c;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.4rem 1rem 1rem;
    margin-bottom: 0.9rem;
    overflow-x: auto;
    font-size: 0.78rem;
    line-height: 1.6;
    box-shadow: inset 0 0 40px rgba(255, 59, 59, 0.04);
}

article pre::before {
    content: "/ sys $";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.45rem 1rem;
    border-bottom: 1px solid var(--border);
    background: #101010;
    color: var(--text-dim);
    font-size: 0.68rem;
    letter-spacing: 0.5px;
    border-radius: var(--radius) var(--radius) 0 0;
}

article pre code {
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    color: var(--text);
}

article blockquote {
    border-left: 2px solid var(--red-dim);
    padding-left: 1rem;
    margin-bottom: 0.9rem;
    color: var(--text-dim);
    font-style: italic;
}

article strong {
    color: var(--text);
}

article a {
    border-bottom: 1px solid var(--red-dim);
}

/* Footer */
footer {
    text-align: center;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border);
    font-size: 0.7rem;
    color: var(--text-dim);
}

footer .red {
    animation: blink 2.5s steps(1) infinite;
}

/* Responsive */
@media (max-width: 600px) {
    main,
    footer {
        padding-left: 1.1rem;
        padding-right: 1.1rem;
    }

    nav {
        padding: 0.9rem 1.1rem;
        gap: 0.6rem;
    }

    .logo {
        font-size: 0.9rem;
        white-space: nowrap;
    }

    .links {
        gap: 0.7rem;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .nav-link {
        font-size: 0.72rem;
        white-space: nowrap;
    }

    .item .date {
        float: none;
        display: block;
    }
}