/* Fonts are self-hosted (SIL OFL 1.1, licenses in fonts/), so no visitor
   request goes to a third party. Orbitron is a variable font, so one file
   covers 700 and 900. */
@font-face {
    font-family: 'Bebas Neue';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(fonts/bebas-neue-400.woff2) format('woff2');
}

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(fonts/jetbrains-mono-400.woff2) format('woff2');
}

@font-face {
    font-family: 'Orbitron';
    font-style: normal;
    font-weight: 400 900;
    font-display: swap;
    src: url(fonts/orbitron-var.woff2) format('woff2');
}

:root {
    /* Palette taken from the ShabbaDoo emblem (public/img/). Orange carries
       headings and actions, steel carries secondary text, and the emblem blue
       is for fills and glows only, since it is too dark for text on black. */
    --primary: #f06018;
    --accent: #a8c0d8;
    --blue: #0b5ea8;
    --deep-orange: #903000;
    --dark: #0a0a0a;
    --darker: #050505;
    --gray: #1a1a1a;
    --text: #e0e0e0;
    --nav-h: 70px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    background: var(--darker);
    color: var(--text);
    overflow-x: hidden;
    position: relative;
}

/* Animated cyber grid. The layer is oversized by one tile on every side so
   the 50px drift never exposes a bare edge. */
body::before {
    content: '';
    position: fixed;
    inset: -50px;
    background-image:
        linear-gradient(rgba(240, 96, 24, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(240, 96, 24, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: grid-move 20s linear infinite;
    z-index: -1;
}

@keyframes grid-move {
    0% { transform: translate(0, 0); }
    100% { transform: translate(50px, 50px); }
}

/* Glitch effect */
@keyframes glitch {
    0%, 100% {
        text-shadow:
            0.05em 0 0 rgba(144, 48, 0, 0.9),
            -0.025em -0.05em 0 rgba(168, 192, 216, 0.55),
            0.025em 0.05em 0 rgba(11, 94, 168, 0.9);
    }
    14% {
        text-shadow:
            0.05em 0 0 rgba(144, 48, 0, 0.9),
            -0.05em -0.025em 0 rgba(168, 192, 216, 0.55),
            -0.025em 0.05em 0 rgba(11, 94, 168, 0.9);
    }
    15% {
        text-shadow:
            -0.05em -0.025em 0 rgba(144, 48, 0, 0.9),
            0.025em 0.025em 0 rgba(168, 192, 216, 0.55),
            -0.05em -0.05em 0 rgba(11, 94, 168, 0.9);
    }
    49% {
        text-shadow:
            -0.05em -0.025em 0 rgba(144, 48, 0, 0.9),
            0.025em 0.025em 0 rgba(168, 192, 216, 0.55),
            -0.05em -0.05em 0 rgba(11, 94, 168, 0.9);
    }
    50% {
        text-shadow:
            0.025em 0.05em 0 rgba(144, 48, 0, 0.9),
            0.05em 0 0 rgba(168, 192, 216, 0.55),
            0 -0.05em 0 rgba(11, 94, 168, 0.9);
    }
    99% {
        text-shadow:
            0.025em 0.05em 0 rgba(144, 48, 0, 0.9),
            0.05em 0 0 rgba(168, 192, 216, 0.55),
            0 -0.05em 0 rgba(11, 94, 168, 0.9);
    }
}

/* Keyboard access */
.skip-link {
    position: absolute;
    left: 16px;
    top: -100px;
    z-index: 2000;
    padding: 10px 16px;
    background: var(--primary);
    color: var(--dark);
    font-weight: 700;
    text-decoration: none;
}

.skip-link:focus {
    top: 16px;
}

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

/* Anchored sections clear the fixed nav */
section[id],
main {
    scroll-margin-top: var(--nav-h);
}

/* Navigation */
body > nav {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 20px 40px;
    background: linear-gradient(180deg, rgba(10,10,10,0.95) 0%, rgba(10,10,10,0) 100%);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    font-weight: 900;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: 3px;
    position: relative;
}

.logo::after {
    content: '_';
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.nav-links {
    display: flex;
    gap: 30px;
    list-style: none;
}

.nav-links a {
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s;
    position: relative;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-links a::before {
    content: '> ';
    color: var(--primary);
    opacity: 0;
    transition: opacity 0.3s;
}

.nav-links a:hover::before {
    opacity: 1;
}

.nav-links a:hover {
    color: var(--primary);
    padding-left: 10px;
}

/* Hero. Top padding keeps the headline clear of the fixed nav on short
   screens, where the content is taller than the viewport. */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: calc(var(--nav-h) + 30px) 40px 40px;
}

.hero-content {
    max-width: 1200px;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: center;
}

.hero-text {
    animation: slideInLeft 1s ease-out;
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-50px); }
    to { opacity: 1; transform: translateX(0); }
}

.hero h1 {
    font-family: 'Bebas Neue', 'Arial Narrow', sans-serif;
    font-weight: 400;
    font-size: 80px;
    line-height: 0.9;
    margin-bottom: 20px;
    letter-spacing: 2px;
}

.hero h1 .name {
    color: var(--primary);
    display: block;
    animation: glitch 2s infinite;
}

.hero .title {
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    color: var(--accent);
    margin-bottom: 30px;
    font-weight: 700;
    letter-spacing: 2px;
}

.hero .subtitle {
    font-size: 16px;
    line-height: 1.8;
    margin-bottom: 40px;
    opacity: 0.9;
}

.terminal-window {
    background: var(--gray);
    border: 1px solid var(--primary);
    overflow: hidden;
    box-shadow: 0 0 40px rgba(240, 96, 24, 0.3);
    animation: slideInRight 1s ease-out;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

.terminal-header {
    background: var(--dark);
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--primary);
}

.terminal-btn {
    width: 12px;
    height: 12px;
}

.terminal-btn.red { background: #ff5f56; }
.terminal-btn.yellow { background: #ffbd2e; }
.terminal-btn.green { background: #27c93f; }

.terminal-body {
    padding: 20px;
    font-size: 14px;
    min-height: 240px;
}

.terminal-line {
    margin-bottom: 10px;
    opacity: 0;
    animation: fadeIn 0.5s forwards;
}

.terminal-line:nth-child(1) { animation-delay: 0.5s; }
.terminal-line:nth-child(2) { animation-delay: 0.7s; }
.terminal-line:nth-child(3) { animation-delay: 0.9s; }
.terminal-line:nth-child(4) { animation-delay: 1.1s; }
.terminal-line:nth-child(5) { animation-delay: 1.3s; }
.terminal-line:nth-child(6) { animation-delay: 1.5s; }

@keyframes fadeIn {
    to { opacity: 1; }
}

.prompt { color: var(--primary); }
.command { color: var(--accent); }
.output { color: var(--text); opacity: 0.8; }

.cursor {
    display: inline-block;
    width: 8px;
    height: 1em;
    vertical-align: text-bottom;
    background: var(--primary);
    animation: blink 1s infinite;
}

/* Emblem. The glow is a drop-shadow so it follows the badge outline rather
   than the transparent square around it. */
.hero-emblem {
    display: flex;
    justify-content: center;
    animation: slideInRight 1s ease-out;
}

.hero-emblem img {
    width: 100%;
    max-width: 520px;
    height: auto;
    filter: drop-shadow(0 0 28px rgba(240, 96, 24, 0.45));
}

/* The terminal sits in its own band under the hero */
.whoami {
    max-width: 820px;
    margin: 0 auto;
    padding: 20px 40px 40px;
}

.whoami .terminal-body {
    min-height: 0;
}

/* CTA Buttons */
.cta-buttons {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 30px;
    border: 2px solid var(--primary);
    background: transparent;
    color: var(--primary);
    text-decoration: none;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--primary);
    transition: left 0.3s;
    z-index: -1;
}

.btn:hover::before,
.btn:focus-visible::before {
    left: 0;
}

.btn:hover,
.btn:focus-visible {
    color: var(--dark);
}

.btn.secondary {
    border-color: var(--accent);
    color: var(--accent);
}

.btn.secondary::before {
    background: var(--accent);
}

.btn.secondary:hover,
.btn.secondary:focus-visible {
    color: var(--dark);
}

/* Section headings */
.section-title {
    font-family: 'Bebas Neue', 'Arial Narrow', sans-serif;
    font-weight: 400;
    font-size: 60px;
    text-align: center;
    margin-bottom: 60px;
    color: var(--primary);
    position: relative;
}

/* Writeups and Focus */
.expertise {
    padding: 100px 40px;
    background: var(--darker);
}

.expertise-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 40px;
}

.expertise-card {
    background: linear-gradient(135deg, rgba(240, 96, 24, 0.1) 0%, rgba(11, 94, 168, 0.1) 100%);
    border: 1px solid rgba(240, 96, 24, 0.3);
    padding: 40px;
    position: relative;
    transition: all 0.3s;
}

.expertise-card:hover {
    background: linear-gradient(135deg, rgba(240, 96, 24, 0.2) 0%, rgba(11, 94, 168, 0.2) 100%);
    transform: scale(1.02);
}

.expertise-number {
    font-family: 'Bebas Neue', 'Arial Narrow', sans-serif;
    font-size: 48px;
    color: var(--primary);
    opacity: 0.3;
    position: absolute;
    top: 15px;
    right: 25px;
}

.expertise-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--accent);
}

.expertise-description {
    font-size: 14px;
    line-height: 1.8;
    opacity: 0.9;
}

/* Footer */
footer {
    padding: 40px;
    background: var(--darker);
    text-align: center;
    border-top: 1px solid rgba(240, 96, 24, 0.2);
    font-size: 14px;
}

.footer-text {
    opacity: 0.7;
}

/* 404 */
.not-found {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--nav-h) + 30px) 20px 40px;
}

.not-found .terminal-window {
    width: 100%;
    max-width: 640px;
}

.not-found .terminal-body {
    min-height: 0;
}

.not-found .cta-buttons {
    margin-top: 30px;
    justify-content: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    :root {
        --nav-h: 60px;
    }

    body > nav {
        padding: 16px 20px;
    }

    .logo {
        font-size: 18px;
        letter-spacing: 2px;
    }

    .nav-links {
        gap: 16px;
    }

    .nav-links a {
        font-size: 12px;
    }

    .hero {
        padding: calc(var(--nav-h) + 30px) 20px 40px;
    }

    .hero-content {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .hero h1 {
        font-size: 50px;
    }

    /* Emblem first on small screens, so the brand is above the fold */
    .hero-emblem {
        order: -1;
    }

    .hero-emblem img {
        max-width: 240px;
    }

    .whoami {
        padding: 0 20px 30px;
    }

    .expertise {
        padding: 70px 20px;
    }

    .expertise-grid {
        grid-template-columns: 1fr;
    }

    .expertise-card {
        padding: 30px 24px;
    }

    .section-title {
        font-size: 40px;
        margin-bottom: 40px;
    }
}

@media (max-width: 420px) {
    .nav-links a:hover {
        padding-left: 0;
    }

    .nav-links a::before {
        display: none;
    }
}

/* Respect the OS "reduce motion" setting (WCAG 2.3.3). Everything that
   starts hidden for an entrance animation is shown immediately instead. */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }

    .terminal-line {
        opacity: 1;
    }

    .expertise-card:hover {
        transform: none;
    }
}

/* Writeup cards on the homepage: an expertise-card whose title is a link */
.expertise-title a {
    color: inherit;
    text-decoration: none;
}

.expertise-title a:hover,
.expertise-title a:focus-visible {
    text-decoration: underline;
    text-underline-offset: 4px;
}

.post-tags {
    font-size: 12px;
    color: var(--primary);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin: -8px 0 16px;
}

/* Writeup pages */
.post {
    max-width: 820px;
    margin: 0 auto;
    padding: calc(var(--nav-h) + 50px) 40px 80px;
    line-height: 1.8;
    font-size: 15px;
}

.post .back {
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
}

.post .back:hover {
    text-decoration: underline;
}

.post h1 {
    font-family: 'Bebas Neue', 'Arial Narrow', sans-serif;
    font-weight: 400;
    font-size: 64px;
    line-height: 1;
    color: var(--primary);
    margin: 24px 0 12px;
    letter-spacing: 1px;
}

.post h2 {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 22px;
    color: var(--accent);
    margin: 48px 0 16px;
}

.post h3 {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    margin: 32px 0 12px;
}

.post p,
.post ul,
.post ol {
    margin-bottom: 16px;
}

.post ul,
.post ol {
    padding-left: 24px;
}

.post a {
    color: var(--accent);
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    font-size: 13px;
    border-top: 1px solid rgba(240, 96, 24, 0.3);
    border-bottom: 1px solid rgba(240, 96, 24, 0.3);
    padding: 12px 0;
    margin-bottom: 32px;
}

.post-meta dt {
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.post-meta div {
    display: flex;
    gap: 8px;
}

.post code {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    background: var(--gray);
    padding: 1px 6px;
    font-size: 0.92em;
}

.post pre {
    background: var(--gray);
    border: 1px solid rgba(240, 96, 24, 0.3);
    border-left: 3px solid var(--primary);
    padding: 16px 20px;
    overflow-x: auto;
    margin: 0 0 20px;
    font-size: 13px;
    line-height: 1.6;
}

.post pre code {
    background: none;
    padding: 0;
}

.post img {
    max-width: 100%;
    height: auto;
    border: 1px solid rgba(240, 96, 24, 0.3);
}

.post table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 13px;
}

.post th,
.post td {
    border: 1px solid rgba(240, 96, 24, 0.25);
    padding: 8px 12px;
    text-align: left;
}

.post th {
    color: var(--primary);
}

.post .callout {
    border: 1px solid var(--accent);
    background: rgba(11, 94, 168, 0.06);
    padding: 16px 20px;
    margin-bottom: 20px;
}

/* Linked headings clear the fixed nav (table of contents, shared #anchors) */
.post h2[id],
.post h3[id] {
    scroll-margin-top: calc(var(--nav-h) + 16px);
}

.post-byline {
    font-size: 13px;
    opacity: 0.8;
    margin-bottom: 16px;
}

.post-byline a {
    color: var(--accent);
}

.post-meta dd a {
    color: var(--accent);
}

/* On this page */
.toc {
    border: 1px solid rgba(168, 192, 216, 0.3);
    padding: 16px 20px;
    margin-bottom: 32px;
    font-size: 13px;
}

.toc-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.post .toc ol {
    margin: 0;
    padding-left: 20px;
}

/* Code blocks: data-label names the shell or marks output, shown as a
   header strip so commands and output are easy to tell apart. */
.post pre[data-label]::before {
    content: attr(data-label);
    display: block;
    margin: -16px -20px 12px;
    padding: 4px 20px;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--accent);
    background: rgba(11, 94, 168, 0.18);
    border-bottom: 1px solid rgba(240, 96, 24, 0.2);
}

.post pre[data-label="output"]::before {
    color: var(--text);
    opacity: 0.7;
}

/* Screenshots */
.post figure {
    margin: 0 0 24px;
}

.post figcaption {
    font-size: 12px;
    opacity: 0.75;
    margin-top: 6px;
}

/* Wide tables scroll inside their own box instead of the page */
.table-wrap {
    overflow-x: auto;
    margin-bottom: 20px;
}

.post .table-wrap table {
    margin-bottom: 0;
    min-width: 560px;
}

.post td a {
    white-space: nowrap;
}

.post .callout p:last-child {
    margin-bottom: 0;
}

.callout-title {
    color: var(--accent);
    font-weight: 700;
}

/* Previous and next writeups */
.post-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 56px;
    padding-top: 24px;
    border-top: 1px solid rgba(240, 96, 24, 0.3);
    font-size: 14px;
}

.post-nav a {
    text-decoration: none;
    border: 1px solid rgba(240, 96, 24, 0.3);
    padding: 12px 16px;
    display: block;
}

.post-nav a:hover,
.post-nav a:focus-visible {
    border-color: var(--primary);
}

.post-nav span {
    display: block;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--primary);
}

.post-nav .next {
    grid-column: 2;
    text-align: right;
}

@media (max-width: 768px) {
    .post {
        padding: calc(var(--nav-h) + 30px) 20px 60px;
    }

    .post h1 {
        font-size: 44px;
    }

    .post-nav {
        grid-template-columns: 1fr;
    }

    .post-nav .next {
        grid-column: 1;
    }
}
