/* Thorsten Ball's design */

/* Theme Variables */
:root {
    --bg-color: #0f1419;
    --text-color: #e0e0e0;
    --link-color: #10b981;
    --link-hover: #34d399;
    --code-bg: #1e293b;
    --code-border: #334155;
    --accent-color: #10b981;
}

html[data-theme="light"] {
    --bg-color: #ffffff;
    --text-color: #000000;
    --link-color: #000000;
    --link-hover: #e74c3c;
    --code-bg: #faffff;
    --code-border: #ddd;
    --accent-color: #e74c3c;
}

html[data-theme="dark"] {
    --bg-color: #0f1419;
    --text-color: #e0e0e0;
    --link-color: #10b981;
    --link-hover: #34d399;
    --code-bg: #1e293b;
    --code-border: #334155;
    --accent-color: #10b981;
}

html[data-theme="sepia"] {
    --bg-color: #f5f5dc;
    --text-color: #5c4f3d;
    --link-color: #8b4513;
    --link-hover: #a0522d;
    --code-bg: #faf0e6;
    --code-border: #ddd;
    --accent-color: #8b4513;
}

html {
    font-family: "Inter", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    /* Keep fixed canvas + content in one stacking context so scroll
       at load cannot briefly composite the canvas over the page. */
    isolation: isolate;
}

/* Conway's Game of Life Canvas
   Prefer large viewport height (lvh) so mobile browser chrome
   show/hide on scroll does not resize/stretch the cells.
   Start hidden (opacity 0); JS adds .is-ready after first correct draw
   so a stretched default bitmap never flashes over content. */
#game-of-life-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100lvh;
    z-index: 0;
    opacity: 0;
    pointer-events: none;
    display: block;
}

#game-of-life-canvas.is-ready {
    opacity: 0.1;
    filter: none;
}

html[data-theme="dark"] #game-of-life-canvas.is-ready {
    opacity: 0.15;
    filter: invert(1);
}

html[data-theme="sepia"] #game-of-life-canvas.is-ready {
    opacity: 0.08;
}

@media screen and (max-width: 574px) {
    #game-of-life-canvas.is-ready {
        opacity: 0.18;
    }

    html[data-theme="dark"] #game-of-life-canvas.is-ready {
        opacity: 0.25;
    }

    html[data-theme="sepia"] #game-of-life-canvas.is-ready {
        opacity: 0.14;
    }
}

/* Theme Toggle Styles */
.theme-toggle {
    position: fixed;
    top: 1em;
    right: 1em;
    display: flex;
    align-items: center;
    gap: 0.3em;
    z-index: 1000;
    font-size: 1em;
    font-family: monospace;
}

.theme-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.3em 0.5em;
    font-family: monospace;
    font-size: 1em;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.theme-btn:hover {
    opacity: 0.8;
}

.theme-btn.active {
    opacity: 1;
    font-weight: bold;
}

.theme-separator {
    color: var(--text-color);
    opacity: 0.5;
}

a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: solid 2px var(--accent-color);
    padding: 0;
}

a:visited {
    color: var(--link-color);
}

a:hover,
a:active {
    color: var(--link-hover);
}

a.image-link,
a.image-link:visited,
a.image-link:hover,
a.image-link:active {
    text-decoration: none;
    border: none;
    padding: 0;
}

h1 {
    margin-top: 0;
    margin-bottom: 0.5em;
    line-height: 1.2em;
}

h2 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

p {
    margin-bottom: 1em;
}

body {
    line-height: 1.5em;
}

.clearfix {
    clear: both;
}

.wrapper {
    max-width: 800px;

    margin-left: 1em;
    margin-right: 1em;
    margin-top: 2em;

    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.columns {
    display: flex;
    flex-direction: column;
    gap: 3em;
}

.menu {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;

    margin-top: 0;
    margin-bottom: 0;
}

@media screen and (min-width: 575px) {
    .wrapper {
        margin: auto;
        margin-top: 5em;
    }

    .columns {
        display: flex;
        flex-direction: row;
        gap: 0;
    }

    .sidebar {
        width: 30%;
        padding-right: 2em;
    }

    .main {
        width: 70%;
        min-width: 0;
        overflow-x: hidden;
    }

    .menu {
        flex-direction: column;
    }
}

.sidebar header {
    font-size: xx-large;
    margin-bottom: 1em;
    margin-top: 2em;
}

@media screen and (min-width: 575px) {
    .sidebar header {
        margin-top: 0;
    }
}

.sidebar header a {
    border-bottom: none;
}

.sidebar header a:hover {
    color: #e74c3c;
}

.main > :first-child {
    margin-top: 0 !important;
    margin-left: 0 !important;
}
.main > :last-child {
    margin-bottom: 0 !important;
    margin-right: 0 !important;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.photo-grid img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    object-position: center;
    border-radius: 4px;
}

.photo-grid > picture {
    display: contents;
}

.photo-grid__featured {
    grid-column: 1 / -1;
}

.photo-grid__portrait,
.photo-grid__secondary {
    grid-column: 1 / -1;
    justify-self: center;
    width: calc((100% - 1rem) / 2);
}

.photo-grid__portrait {
    object-position: center 80%;
}

@media screen and (max-width: 574px) {
    .photo-grid {
        grid-template-columns: 1fr;
    }

    .photo-grid__featured,
    .photo-grid__portrait,
    .photo-grid__secondary {
        grid-column: auto;
        width: 100%;
    }
}

.menu .menu-item {
    text-decoration: none;
    margin: 0.2em 0;
    line-height: 1.8em;
}

.menu .menu-item a {
    display: inline-block;
}

.menu .menu-item.active {
    font-weight: bold;
    color: black;
}

.menu .menu-item.active a {
    border-bottom: none;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5rem 0;
}

/* Article images */
article img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Image captions */
article p > em {
    display: block;
    text-align: center;
    font-style: italic;
    font-size: 0.9em;
    color: var(--text-color);
    opacity: 0.7;
    margin-top: -1rem;
    margin-bottom: 1.5rem;
}

/* Footnotes */
.footnote-ref {
    font-size: 0.75em;
    line-height: 0;
}

.footnote-ref a,
.footnote-backref {
    border-bottom: none;
}

.footnotes-sep {
    margin: 2.5rem 0 1rem;
    border: 0;
    border-top: 1px solid var(--code-border);
}

.footnotes {
    font-size: 0.9em;
}

.footnotes-list {
    margin-bottom: 0;
}

.footnote-item p {
    margin: 0.5rem 0;
}

.avatar {
    width: 125px;
    height: 125px;
    float: left;
    border-radius: 6px;
    margin-bottom: 1em;
    margin-right: 2em;
    margin-top: 1em;
}

ul.values {
    list-style-type: none;
    padding-left: none;
}
ul.values li {
    padding: 0.5em;
}

.book-detail {
    margin-top: 2em;
    margin-bottom: 2em;
}

.book-detail h2 {
    margin-bottom: 0.2em;
}

.book-detail .publication-date {
    font-weight: 200;
    margin-top: 0em;
}

.book-detail .cover {
    float: left;
    margin-top: 10px;
    margin-right: 10px;
}

.book-detail img {
    height: 126px;
    width: 100px;
}

.posts tr td:first-child,
.talks tr td:first-child,
.podcasts tr td:first-child {
    min-width: 100px;
    font-weight: 200;
    text-align: right;
}

.posts td.stars {
    max-width: 1em;
    padding: 0;
}

.posts,
.talks,
.podcats > tr,
td {
    padding: 10px;
}

.posts .post-star {
    color: #e74c3c;
}

ul.misc-list {
    padding-left: 0;
}
ul.misc-list li {
    padding: 0.5em;
}

.meta {
    margin-top: 0.3em;
    font-weight: 200;
}

pre {
    background-color: var(--code-bg);
    border: 1px solid var(--code-border);
    padding: 0.8em;
    overflow: scroll;
    border-radius: 6px;
    line-height: 1.3em;
}

pre::-webkit-scrollbar {
    display: none;
}

ul,
ol {
    margin-left: 1.35em;
}

code {
    border: 1px solid var(--code-border);
    background-color: var(--code-bg);
    padding: 0 0.2em;
}

pre code {
    border: none;
}

/* terminal */
pre.terminal {
    border: 1px solid #000;
    background-color: #333;
    color: #fff;
}

pre.terminal code {
    background-color: #333;
}

blockquote {
    font-style: italic;
    padding-left: 10px;
}

.postfooter {
    border-top: 1px solid;
    margin-top: 3em;
    font-style: italic;
}

.footer {
    margin-top: 5em;
    padding-top: 2em;
    text-align: center;
    color: var(--text-color);
    opacity: 0.6;
    font-size: 0.9em;
}
.footer a {
    color: var(--text-color);
    border-bottom-color: var(--text-color);
}

.footer a:visited {
    color: var(--text-color);
}

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

/* Syntax highlighting */
.highlight .c { color: #999988; font-style: italic } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { font-weight: bold } /* Keyword */
.highlight .o { font-weight: bold } /* Operator */
.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */
.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #999999 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #aaaaaa } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { font-weight: bold } /* Keyword.Constant */
.highlight .kd { font-weight: bold } /* Keyword.Declaration */
.highlight .kp { font-weight: bold } /* Keyword.Pseudo */
.highlight .kr { font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #009999 } /* Literal.Number */
.highlight .s { color: #d14 } /* Literal.String */
.highlight .na { color: #008080 } /* Name.Attribute */
.highlight .nb { color: #0086B3 } /* Name.Builtin */
.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */
.highlight .no { color: #008080 } /* Name.Constant */
.highlight .ni { color: #800080 } /* Name.Entity */
.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */
.highlight .nn { color: #555555 } /* Name.Namespace */
.highlight .nt { color: #000080 } /* Name.Tag */
.highlight .nv { color: #008080 } /* Name.Variable */
.highlight .ow { font-weight: bold } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mf { color: #009999 } /* Literal.Number.Float */
.highlight .mh { color: #009999 } /* Literal.Number.Hex */
.highlight .mi { color: #009999 } /* Literal.Number.Integer */
.highlight .mo { color: #009999 } /* Literal.Number.Oct */
.highlight .sb { color: #d14 } /* Literal.String.Backtick */
.highlight .sc { color: #d14 } /* Literal.String.Char */
.highlight .sd { color: #d14 } /* Literal.String.Doc */
.highlight .s2 { color: #d14 } /* Literal.String.Double */
.highlight .se { color: #d14 } /* Literal.String.Escape */
.highlight .sh { color: #d14 } /* Literal.String.Heredoc */
.highlight .si { color: #d14 } /* Literal.String.Interpol */
.highlight .sx { color: #d14 } /* Literal.String.Other */
.highlight .sr { color: #009926 } /* Literal.String.Regex */
.highlight .s1 { color: #d14 } /* Literal.String.Single */
.highlight .ss { color: #990073 } /* Literal.String.Symbol */
.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */
.highlight .vc { color: #008080 } /* Name.Variable.Class */
.highlight .vg { color: #008080 } /* Name.Variable.Global */
.highlight .vi { color: #008080 } /* Name.Variable.Instance */
.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */

/* Photo Portfolio Section */
.photo-portfolio {
    margin: 4em 0;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2em;
}

.portfolio-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: var(--bg-color);
    border: 1px solid var(--code-border);
}

.portfolio-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

.portfolio-item img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.portfolio-item:hover img {
    transform: scale(1.05);
}

/* Optional text below photos for retro storytelling */
.portfolio-caption {
    padding: 1em;
    text-align: center;
    font-size: 0.9em;
    color: var(--text-secondary);
    font-style: italic;
    border-top: 1px solid var(--code-border);
    background: var(--bg-secondary);
    font-family: 'Courier New', monospace;
}

/* Lightbox overlay for photos */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1.5rem;
    box-sizing: border-box;
}

.lightbox-overlay.visible {
    display: flex;
}

.lightbox-content {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img {
    max-width: min(600px, 100%);
    max-height: calc(100dvh - 4rem);
    width: auto;
    height: auto;
    display: block;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.lightbox-close {
    position: absolute;
    top: -0.75rem;
    right: -0.75rem;
    background: var(--text-color);
    color: var(--bg-color);
    border: none;
    font-size: 1.2rem;
    line-height: 1;
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.lightbox-close:hover {
    background: var(--accent-color);
    color: var(--bg-color);
}
