/* ==========================================================================
   Living Systems
   Dark, terminal-inspired theme. Design tokens mirror the reference layout:
   biology / computation / instrumentation.
   ========================================================================== */

:root {
    --background: oklch(17% .008 160);
    --foreground: oklch(93% .012 150);
    --card: oklch(21% .012 160);
    --card-foreground: oklch(93% .012 150);
    --primary: oklch(78% .19 150);
    --primary-foreground: oklch(16% .02 160);
    --secondary: oklch(26% .015 160);
    --muted: oklch(24% .012 160);
    --muted-foreground: oklch(66% .025 155);
    --accent: oklch(30% .05 158);
    --accent-foreground: oklch(90% .1 150);
    --border: oklch(78% .19 150 / .18);
    --glow: oklch(85% .21 148);

    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
        Consolas, "Liberation Mono", "Courier New", monospace;

    --container: 56rem;
    --radius: .25rem;

    color-scheme: dark;
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    background-color: var(--background);
    color: var(--foreground);
    font-family: var(--font-mono);
    font-size: 1rem;
    line-height: 1.6;
    overflow-wrap: break-word;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-variant-ligatures: none;
}

::selection {
    background: color-mix(in oklab, var(--primary) 35%, transparent);
    color: var(--foreground);
}

/* --------------------------------------------------------------------------
   Fixed background layers
   -------------------------------------------------------------------------- */

.bg-helix {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: .6;
    pointer-events: none;
    z-index: 0;
}

.grid-etch {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .4;
    z-index: 0;
    background-image:
        linear-gradient(color-mix(in oklab, var(--glow) 7%, transparent) 1px, transparent 1px),
        linear-gradient(90deg, color-mix(in oklab, var(--glow) 7%, transparent) 1px, transparent 1px);
    background-size: 44px 44px;
}

.scanline {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .5;
    z-index: 0;
    background-image: repeating-linear-gradient(
        to bottom,
        color-mix(in oklab, var(--glow) 5%, transparent) 0px,
        transparent 1px,
        transparent 4px
    );
}

.top-line {
    position: fixed;
    inset: 0 0 auto 0;
    height: 1px;
    z-index: 0;
    pointer-events: none;
    background: color-mix(in oklab, var(--primary) 60%, transparent);
    animation: pulse-line 4s ease-in-out infinite;
}

@keyframes pulse-line {
    0%, 100% { opacity: .35; }
    50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .top-line { animation: none; }
    html { scroll-behavior: auto; }
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.container {
    position: relative;
    z-index: 1;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 1.5rem 6rem;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .3em;
}

.site-brand,
.site-brand:link,
.site-brand:visited,
.site-brand:active {
    color: var(--primary);
    text-decoration: none;
    text-transform: lowercase;
    text-shadow: 0 0 18px color-mix(in oklab, var(--glow) 55%, transparent);
    transition: text-shadow .25s ease;
}

.site-brand:hover {
    text-shadow: 0 0 26px color-mix(in oklab, var(--glow) 80%, transparent);
}

.site-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-nav li {
    display: inline;
}

.site-nav a,
.site-nav a:link,
.site-nav a:visited {
    color: var(--muted-foreground);
    text-decoration: none;
    transition: color .2s ease;
}

.site-nav a:hover,
.site-nav a.active,
.site-nav a.ancestor {
    color: var(--primary);
}

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

.hero {
    padding: 5rem 0;
    border-bottom: 1px solid var(--border);
}

.hero .eyebrow {
    margin: 0;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .35em;
    color: var(--muted-foreground);
}

.hero h1 {
    margin: 1.5rem 0 0;
    font-size: clamp(2.25rem, 8vw, 3.75rem);
    font-weight: 300;
    line-height: 1.05;
    letter-spacing: -.025em;
}

.hero h1 .accent {
    color: var(--primary);
    text-shadow: 0 0 18px color-mix(in oklab, var(--glow) 55%, transparent);
}

.hero p:not(.eyebrow),
.hero .hero-content {
    margin: 1.5rem 0 0;
    max-width: 36rem;
    font-size: .875rem;
    line-height: 1.7;
    color: var(--muted-foreground);
}

.hero .hero-content > :first-child { margin-top: 0; }
.hero .hero-content > :last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   Section headings
   -------------------------------------------------------------------------- */

.section-title {
    margin: 0 0 2rem;
    font-size: .75rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: .3em;
    color: var(--muted-foreground);
}

/* --------------------------------------------------------------------------
   Archive / post list
   -------------------------------------------------------------------------- */

.archive {
    padding: 3rem 0;
}

.post-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.post-list > li + li {
    margin-top: 1px;
}

.post-item,
.post-item:link,
.post-item:visited,
.post-item:active {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    padding: 1.5rem 1.25rem;
    border-left: 2px solid transparent;
    background: color-mix(in oklab, var(--card) 40%, transparent);
    color: inherit;
    text-decoration: none;
    transition: background-color .25s ease, border-color .25s ease;
}

.post-item:hover {
    border-left-color: var(--primary);
    background: var(--card);
}

.post-content {
    flex: 1 1 auto;
    min-width: 0;
}

.post-thumb {
    position: relative;
    flex: 0 0 auto;
    order: 2;
    width: 16rem;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--secondary);
    box-shadow: 0 0 28px -18px color-mix(in oklab, var(--glow) 55%, transparent);
}

.post-thumb::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: repeating-linear-gradient(
        to bottom,
        color-mix(in oklab, var(--glow) 6%, transparent) 0px,
        transparent 1px,
        transparent 3px
    );
}

.post-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    filter: saturate(.7) brightness(.82);
    opacity: .85;
    transition: filter .3s ease, opacity .3s ease;
}

.post-item:hover .post-thumb {
    border-color: color-mix(in oklab, var(--primary) 55%, transparent);
}

.post-item:hover .post-thumb img {
    filter: none;
    opacity: 1;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem 1rem;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .25em;
    color: var(--muted-foreground);
}

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

.post-meta .post-tag {
    color: var(--accent-foreground);
}

.post-meta .post-time {
    margin-left: auto;
}

.post-item h3 {
    margin: .75rem 0 0;
    font-size: 1.125rem;
    font-weight: 400;
    line-height: 1.3;
    transition: color .2s ease;
}

.post-item:hover h3 {
    color: var(--primary);
}

.post-item p {
    margin: .5rem 0 0;
    max-width: 42rem;
    font-size: .875rem;
    line-height: 1.7;
    color: var(--muted-foreground);
}

/* --------------------------------------------------------------------------
   Article (single)
   -------------------------------------------------------------------------- */

.article-header {
    padding: 4rem 0 2rem;
    border-bottom: 1px solid var(--border);
}

.article-title {
    margin: 0;
    font-size: clamp(1.75rem, 5vw, 2.75rem);
    font-weight: 300;
    line-height: 1.15;
    letter-spacing: -.02em;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem 1rem;
    margin-top: 1.25rem;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .25em;
    color: var(--muted-foreground);
}

.article-meta .post-time {
    margin-left: auto;
}

.article-body {
    padding: 2.5rem 0 0;
}

/* --------------------------------------------------------------------------
   Prose
   -------------------------------------------------------------------------- */

.prose {
    max-width: 48rem;
}

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

.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
    margin: 2.5rem 0 1rem;
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: -.01em;
}

.prose h2 { font-size: 1.5rem; }
.prose h3 { font-size: 1.25rem; }
.prose h4 { font-size: 1.05rem; }

.prose p {
    margin: 1.1rem 0;
}

.prose ul,
.prose ol {
    margin: 1.1rem 0;
    padding-left: 1.5rem;
}

.prose li {
    margin: .4rem 0;
}

.prose a,
.prose a:link,
.prose a:visited {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: color-mix(in oklab, var(--primary) 40%, transparent);
    transition: text-decoration-color .2s ease;
}

.prose a:hover {
    text-decoration-color: var(--primary);
}

.prose blockquote {
    margin: 1.5rem 0;
    padding: .25rem 0 .25rem 1.25rem;
    border-left: 2px solid var(--primary);
    color: var(--muted-foreground);
    font-style: italic;
}

.prose img {
    max-width: 100%;
    height: auto;
}

.prose hr {
    margin: 2.5rem 0;
    border: 0;
    border-top: 1px solid var(--border);
}

.prose table {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: collapse;
    font-size: .85rem;
}

.prose th,
.prose td {
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    text-align: left;
}

.prose th {
    color: var(--accent-foreground);
    font-weight: 500;
}

/* --------------------------------------------------------------------------
   Code
   The Hugo syntax highlighter (Chroma, noClasses = true) emits a dark-theme
   background and token colors inline, so the block is left to the highlighter.
   Inline code is styled as a subtle accent chip.
   -------------------------------------------------------------------------- */

pre {
    overflow-x: auto;
    margin: 1.5rem 0;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: .85rem;
    line-height: 1.55;
    box-shadow: 0 0 28px -16px color-mix(in oklab, var(--glow) 45%, transparent);
}

pre code {
    font-family: inherit;
}

p code,
li > code,
td code {
    padding: .1em .35em;
    background: var(--secondary);
    color: var(--accent-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .9em;
}

/* --------------------------------------------------------------------------
   Tags
   -------------------------------------------------------------------------- */

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    margin: 2rem 0 0;
    padding: 0;
    list-style: none;
}

.tags li {
    display: inline;
    margin: 0;
    padding: 0;
}

.tags a,
.tags a:link,
.tags a:visited {
    color: var(--accent-foreground);
    text-decoration: none;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .2em;
    transition: color .2s ease;
}

.tags a::before {
    content: "[";
    color: var(--muted-foreground);
}

.tags a::after {
    content: "]";
    color: var(--muted-foreground);
}

.tags a:hover {
    color: var(--primary);
}

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

.site-footer {
    padding: 3rem 0 0;
    border-top: 1px solid var(--border);
    font-size: .875rem;
    line-height: 1.7;
    color: var(--muted-foreground);
}

.site-footer p {
    margin: 0;
    max-width: 40rem;
}

.site-footer p + p {
    margin-top: 1rem;
}

.site-footer a,
.site-footer a:link,
.site-footer a:visited {
    color: var(--accent-foreground);
    text-decoration: none;
    border-bottom: 1px solid color-mix(in oklab, var(--primary) 35%, transparent);
    transition: color .2s ease, border-color .2s ease;
}

.site-footer a:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.site-footer .copyright {
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .3em;
}

/* --------------------------------------------------------------------------
   Content helper classes (used from Markdown)
   -------------------------------------------------------------------------- */

.align_right {
    float: right;
    max-width: 37%;
    margin: 0 0 1rem 1rem;
}

p.image {
    margin: 1.5rem 0;
}

.disqus {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    color: #f0e5e4;
    background-color: #130e0e;
}

@media (max-width: 820px) {
    .post-item--thumb {
        flex-direction: column;
        gap: 1rem;
    }

    .post-item--thumb .post-thumb {
        order: 0;
        width: 100%;
        aspect-ratio: 16 / 9;
    }
}

@media (max-width: 640px) {
    .hero { padding: 3.5rem 0; }
    .article-header { padding: 3rem 0 1.5rem; }
    .post-item { padding: 1.25rem 1rem; }
}
