/* ==========================================================================
   ale.bles.nu
   Synthwave palette with terminal accents. Tokens live here; the Snake
   canvas reads the --snake-* values via getComputedStyle, so those must
   stay literal (no var() references).
   ========================================================================== */

:root {
    --bg: #0b0a1a;
    --bg-2: #1a1040;
    --surface: rgba(16, 14, 36, 0.92);
    --surface-2: #1c1940;
    --border: rgba(157, 107, 255, 0.28);

    --magenta: #ff4fd8;
    --cyan: #3df5ff;
    --purple: #9d6bff;
    --amber: #ffb347;
    --text: #e6e4f5;
    --muted: #a39fc4;
    --grid-line: rgba(61, 245, 255, 0.22);

    --glow-cyan: 0 0 8px rgba(61, 245, 255, 0.55), 0 0 24px rgba(61, 245, 255, 0.25);
    --glow-magenta: 0 0 8px rgba(255, 79, 216, 0.55), 0 0 24px rgba(255, 79, 216, 0.25);

    /* Snake canvas palette. Literal values only, mirrors the palette above. */
    --snake-bg: #0f0d24;
    --snake-grid: rgba(157, 107, 255, 0.16);
    --snake-body: #3df5ff;
    --snake-head: #d6fcff;
    --snake-food: #ff4fd8;
    --snake-score: #ffb347;

    --radius: 8px;
    --radius-sm: 4px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 16px;
    --space-4: 24px;
    --space-5: 40px;
    --content-max: 880px;
    /* Measured, per breakpoint: the bar wraps to two rows below 640px.
       Used by .sticky-intro and :target so neither lands under it. */
    --topbar-h: 67px;

    --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Fira Code", Menlo, Consolas, "Courier New", monospace;
    --scanline-opacity: 0.045;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

:target {
    scroll-margin-top: calc(var(--topbar-h) + var(--space-3));
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-mono);
    font-size: clamp(15px, 0.9vw + 12px, 17px);
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    position: relative;
    isolation: isolate;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: var(--cyan);
}

/* --------------------------------------------------------------------------
   Backdrop: horizon, sun, perspective grid, scanlines
   -------------------------------------------------------------------------- */

.backdrop {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    background: linear-gradient(
        180deg,
        var(--bg) 0%,
        var(--bg-2) 40%,
        #2a0f4a 52%,
        #120b2a 60%,
        var(--bg) 100%
    );
}

.backdrop__glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse 70% 40% at 50% 47%,
        rgba(255, 79, 216, 0.38),
        rgba(255, 79, 216, 0) 70%
    );
}

.backdrop__sun {
    position: absolute;
    left: 50%;
    top: 16%;
    width: min(60vw, 440px);
    aspect-ratio: 1;
    translate: -50% 0;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--amber) 0%, var(--magenta) 55%, var(--purple) 100%);
    opacity: 0.65;
    filter: blur(1px);
    -webkit-mask-image: linear-gradient(to bottom, #000 0 48%, transparent 48% 51%, #000 51% 58%, transparent 58% 61%, #000 61% 68%, transparent 68% 72%, #000 72% 80%, transparent 80% 86%, #000 86% 100%);
    mask-image: linear-gradient(to bottom, #000 0 48%, transparent 48% 51%, #000 51% 58%, transparent 58% 61%, #000 61% 68%, transparent 68% 72%, #000 72% 80%, transparent 80% 86%, #000 86% 100%);
}

.backdrop__grid {
    position: absolute;
    left: -50%;
    right: -50%;
    top: 47%;
    height: 130%;
    background-image:
        repeating-linear-gradient(90deg, var(--grid-line) 0 1px, transparent 1px 64px),
        repeating-linear-gradient(0deg, var(--grid-line) 0 1px, transparent 1px 64px);
    background-size: 64px 64px;
    transform-origin: top center;
    transform: perspective(480px) rotateX(62deg);
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.6) 40%, transparent 85%);
    mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.6) 40%, transparent 85%);
    animation: grid-scroll 4s linear infinite;
}

@keyframes grid-scroll {
    to {
        background-position: 0 0, 0 64px;
    }
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 50;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0, 0, 0, var(--scanline-opacity)) 0 1px,
        transparent 1px 3px
    );
}

/* --------------------------------------------------------------------------
   Skip link and focus
   -------------------------------------------------------------------------- */

.skip-link {
    position: absolute;
    left: var(--space-3);
    top: -100px;
    z-index: 100;
    padding: var(--space-2) var(--space-3);
    background: var(--surface-2);
    border: 1px solid var(--cyan);
    border-radius: var(--radius-sm);
    color: var(--cyan);
    text-decoration: none;
}

.skip-link:focus {
    top: var(--space-3);
}

:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 3px;
    box-shadow: 0 0 0 5px rgba(61, 245, 255, 0.25);
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

/* Sticky: it spans the full width so it can carry a background. Without one,
   content scrolls underneath and the links become unreadable. z-index sits
   below body::after (50) so the scanlines still run over the bar. */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(11, 10, 26, 0.72);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.topbar__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-4);
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--space-3);
}

.brand {
    color: var(--cyan);
    text-decoration: none;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-shadow: var(--glow-cyan);
    white-space: nowrap;
}

.brand__path {
    color: var(--muted);
    font-weight: 400;
    text-shadow: none;
}

.cursor {
    display: inline-block;
    margin-left: 1px;
    animation: blink 1s steps(1) infinite;
}

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

.topnav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-2);
}

.topnav a {
    color: var(--muted);
    text-decoration: none;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    transition: color 0.15s ease, text-shadow 0.15s ease;
}

.topnav a::before {
    content: "./";
    opacity: 0.5;
}

.topnav a:hover {
    color: var(--text);
}

.topnav a.active {
    color: var(--cyan);
    text-shadow: var(--glow-cyan);
}

/* --------------------------------------------------------------------------
   Page column and surfaces
   -------------------------------------------------------------------------- */

.page {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--space-3) var(--space-5);
}

.surface {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.window__bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border);
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--magenta);
    box-shadow: 0 0 6px currentColor;
    color: var(--magenta);
}

.dot:nth-child(2) {
    background: var(--amber);
    color: var(--amber);
}

.dot:nth-child(3) {
    background: var(--cyan);
    color: var(--cyan);
}

.window__title {
    margin-left: var(--space-2);
    color: var(--muted);
    font-size: 0.8em;
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

.hero__body {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-4);
    align-items: center;
    padding: var(--space-4);
}

.hero__profile {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-width: 0;
}

.avatar {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 2px solid var(--cyan);
    box-shadow: var(--glow-cyan);
    object-fit: cover;
}

.hero h1 {
    margin: 0 0 var(--space-1);
    font-size: clamp(1.5rem, 4vw, 2.1rem);
    font-weight: 600;
    line-height: 1.15;
    color: var(--magenta);
    text-shadow: var(--glow-magenta);
}

.hero h1::before {
    content: "> ";
    color: var(--cyan);
    text-shadow: var(--glow-cyan);
}

.hero__role {
    margin: 0 0 var(--space-2);
    color: var(--text);
}

.hero__meta {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
    font-size: 0.85em;
}

.hero__meta a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.hero__meta a:hover {
    color: var(--cyan);
}

.hero__meta svg {
    flex-shrink: 0;
}

.hero__snake {
    padding: var(--space-2);
    background: var(--snake-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 24px rgba(61, 245, 255, 0.08), 0 0 16px rgba(157, 107, 255, 0.15);
}

#snakeCanvas {
    display: block;
    width: 140px;
    height: 140px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* --------------------------------------------------------------------------
   Content
   -------------------------------------------------------------------------- */

.content {
    margin-top: var(--space-4);
    padding: var(--space-5) var(--space-4);
}

.content > .prompt:first-child {
    margin-top: 0;
}

.content h2,
.content h3 {
    line-height: 1.25;
}

.prompt {
    text-transform: lowercase;
    color: var(--cyan);
    font-weight: 600;
    margin: var(--space-4) 0 var(--space-3);
}

.prompt::before {
    content: "> ";
    color: var(--magenta);
    text-shadow: var(--glow-magenta);
}

h2.prompt {
    font-size: 1.5em;
    padding-bottom: var(--space-2);
    border-bottom: 1px dashed var(--border);
    margin-bottom: var(--space-4);
}

h3.prompt {
    font-size: 1.1em;
    margin-top: var(--space-5);
}

.content p {
    margin: 0 0 var(--space-3);
}

.content a {
    color: var(--cyan);
    text-decoration: underline dotted;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: color 0.15s ease;
}

.content a:hover {
    color: var(--magenta);
}

.content h2:not(.prompt) {
    margin: 0 0 var(--space-2);
    font-size: 1.5em;
    color: var(--text);
}

/* --------------------------------------------------------------------------
   Cards, skills, tags
   -------------------------------------------------------------------------- */

.card-list {
    display: grid;
    gap: var(--space-3);
    margin-top: var(--space-2);
}

/* Two columns where there is room, one column on narrow screens. */
.card-list--grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    align-items: stretch;
}

.card-list--grid .card {
    display: flex;
    flex-direction: column;
}

.card-list--grid .card__links {
    margin-top: auto;
    padding-top: var(--space-2);
}

.card__image {
    display: block;
    width: calc(100% + 36px);
    max-width: none;
    margin: calc(-1 * var(--space-3)) -18px var(--space-3);
    aspect-ratio: 2 / 1;
    object-fit: cover;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    border-radius: 0 var(--radius-sm) 0 0;
}

.card,
.skill-group {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--magenta);
    border-radius: var(--radius-sm);
    padding: var(--space-3) 18px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.card:hover,
.skill-group:hover {
    border-left-color: var(--cyan);
    box-shadow: var(--glow-cyan);
    transform: translateY(-2px);
}

.card h3 {
    margin: 0 0 var(--space-2);
    font-size: 1.05em;
    color: var(--text);
}

.card h3 a {
    color: var(--text);
    text-decoration: none;
}

.card h3 a:hover {
    color: var(--cyan);
}

.card p {
    margin-bottom: var(--space-2);
}

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

.meta {
    color: var(--muted);
    font-size: 0.8em;
    margin-bottom: var(--space-1);
}

.meta::before {
    content: "# ";
    color: var(--purple);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: var(--space-2);
}

.tag {
    border: 1px solid var(--purple);
    color: var(--purple);
    font-size: 0.75em;
    padding: 1px 8px;
    border-radius: 999px;
}

.read-more {
    display: inline-block;
    font-weight: 600;
}

.card__links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
    margin-top: var(--space-2);
    font-size: 0.9em;
}

.card__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--cyan);
    text-decoration: none;
    font-weight: 600;
}

.card__link:hover {
    color: var(--magenta);
}

.card__link svg {
    flex-shrink: 0;
}

.card__link:hover svg {
    filter: drop-shadow(0 0 4px currentColor);
}

.skills {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.skill-group h4 {
    margin: 0 0 var(--space-2);
    font-size: 0.8em;
    color: var(--amber);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.skill-group ul {
    list-style: disc;
    margin: 0;
    padding: 0 0 0 18px;
}

.skill-group li {
    font-size: 0.9em;
    padding: 2px 0;
    line-height: 1.45;
}

.skill-group li::marker {
    color: var(--cyan);
}

/* --------------------------------------------------------------------------
   Posts and helpers
   -------------------------------------------------------------------------- */

.post-article {
    overflow-wrap: anywhere;
}

.post-article .meta {
    margin-bottom: var(--space-3);
}

.post-article pre {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--cyan);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    overflow-x: auto;
    font-size: 0.85em;
    margin: var(--space-3) 0;
}

.post-article code {
    background: rgba(157, 107, 255, 0.15);
    color: var(--text);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.9em;
}

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

.post-article ul,
.post-article ol {
    margin: var(--space-2) 0 var(--space-3) var(--space-4);
}

.post-article blockquote {
    margin: var(--space-3) 0;
    padding-left: var(--space-3);
    border-left: 3px solid var(--purple);
    color: var(--muted);
}

.back-link {
    display: inline-block;
    margin-bottom: var(--space-3);
    font-size: 0.9em;
}

.sticky-intro {
    position: sticky;
    top: var(--topbar-h);
    z-index: 5;
    background: var(--surface-2);
    margin: calc(-1 * var(--space-5)) calc(-1 * var(--space-4)) var(--space-4);
    padding: var(--space-4) var(--space-4) var(--space-3);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
}

.sticky-intro h2.prompt {
    margin-top: 0;
}

.sticky-intro p {
    margin-bottom: var(--space-2);
}

.sticky-intro p:last-child {
    margin-bottom: 0;
}

.muted {
    color: var(--muted);
    font-style: italic;
    font-size: 0.9em;
}

.empty {
    color: var(--muted);
    font-style: italic;
    padding: var(--space-3) 0;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.footer {
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--muted);
    font-size: 0.8em;
}

.footer p {
    margin: var(--space-1) 0;
}

.footer a {
    color: var(--muted);
    text-decoration: none;
}

.footer a:hover {
    color: var(--cyan);
}

/* --------------------------------------------------------------------------
   Motion and responsive
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .backdrop__grid,
    .cursor {
        animation: none;
    }

    .card,
    .skill-group,
    .topnav a,
    .hero__meta a,
    .content a {
        transition: none;
    }

    .card:hover,
    .skill-group:hover {
        transform: none;
    }
}

@media (max-width: 640px) {
    :root {
        --topbar-h: 102px;
    }

    .brand {
        flex-basis: 100%;
    }

    .hero__body {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }

    .hero__profile {
        flex-direction: column;
        gap: var(--space-3);
    }

    .hero__meta {
        justify-content: center;
    }

    .content {
        padding: var(--space-4) var(--space-3);
    }

    .sticky-intro {
        margin: calc(-1 * var(--space-4)) calc(-1 * var(--space-3)) var(--space-3);
        padding: var(--space-3);
    }

    .backdrop__grid {
        background-image:
            repeating-linear-gradient(90deg, var(--grid-line) 0 1px, transparent 1px 48px),
            repeating-linear-gradient(0deg, var(--grid-line) 0 1px, transparent 1px 48px);
        background-size: 48px 48px;
    }

    @keyframes grid-scroll {
        to {
            background-position: 0 0, 0 48px;
        }
    }
}

@media (max-width: 420px) {
    :root {
        --topbar-h: 96px;
    }

    .hero h1 {
        font-size: 1.4rem;
    }

    #snakeCanvas {
        width: 120px;
        height: 120px;
    }

    .topnav {
        gap: 2px;
        font-size: 0.9em;
    }
}
