/* --------------------------------------------------------------------------
   stgm.nl — "wireframe" theme
   Hard 1px outlines and offset shadows (blueprint feel) over a warm off-white,
   with saturated gradients carrying the accents.
   -------------------------------------------------------------------------- */

:root {
    --bg: #f4f2ed;
    --panel: #fbfaf7;
    --ink: #16161d;
    --ink-soft: #5a5a68;
    --line: #16161d;
    --rule: #d8d4c9;

    --grad-cool: linear-gradient(135deg, #6d5cff, #21d4e6);
    --grad-warm: linear-gradient(135deg, #ff7a3d, #ff2d8d);
    --grad-leaf: linear-gradient(135deg, #14b866, #b9d900);

    --accent: #5b3df5;

    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    --sans:
        ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial,
        sans-serif;

    /* Background grid cell. Layout edges, gaps, and padding are kept in
     multiples (or halves) of this so panels line up with the grid lines. */
    --cell: 28px;
    --shell-max: calc(var(--cell) * 42);

    --sidebar-w: calc(var(--cell) * 8.5);
    --gap: var(--cell);
    --shadow: 4px 4px 0 var(--line);
}

/* Roomier once there is space for it. */
@media (min-width: 1060px) {
    :root {
        --sidebar-w: calc(var(--cell) * 10.5);
        --gap: calc(var(--cell) * 1.5);
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    /* faint blueprint grid */
    background-image:
        linear-gradient(rgba(22, 22, 29, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(22, 22, 29, 0.04) 1px, transparent 1px);
    background-size: var(--cell) var(--cell);
    color: var(--ink);
    /* 16px * 1.75 = 28px = one grid cell, so body text baselines land on the grid. */
    font: 16px/1.75 var(--sans);
    -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- layout --
   Mobile first: single column, nav lives in a modal <dialog>. From iPad
   portrait (768px) up, the same dialog is restyled into the static sidebar
   column — one DOM node, two roles.
   -------------------------------------------------------------------------- */

.shell {
    display: flex;
    flex-direction: column;
    gap: calc(var(--cell) / 2);
    max-width: var(--shell-max);
    /* Snapped auto-margin: stays visually centered but its left edge always
     lands on a grid line, matching the body background-image's 0 0 origin. */
    margin-inline: max(
        0px,
        round(down, calc((100vw - var(--shell-max)) / 2), var(--cell))
    );
    padding: var(--cell) calc(var(--cell) / 2) calc(var(--cell) * 2);
}

.content {
    max-width: calc(var(--cell) * 25); /* 700px, nearest cell multiple to the old 44rem/704px */
}

/* ------------------------------------------------------------ nav toggle -- */

/* Floated rather than fixed: it scrolls away with the text, and takes no
   vertical space of its own — the prose wraps around it. */
.nav-toggle {
    float: right;
    margin: 0 0 0.6rem 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.6rem 0.8rem;
    font: 600 0.7rem/1 var(--mono);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: 3px 3px 0 var(--line);
    cursor: pointer;
}

.nav-toggle:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 var(--line);
}

/* Gradient hamburger: three bars masked out of a gradient fill. */
.nav-toggle .bars {
    width: 1rem;
    height: 0.65rem;
    background: var(--grad-cool);
    --bar: linear-gradient(#000 0 0);
    -webkit-mask:
        var(--bar) 0 0 / 100% 2px no-repeat,
        var(--bar) 0 50% / 100% 2px no-repeat,
        var(--bar) 0 100% / 100% 2px no-repeat;
    mask:
        var(--bar) 0 0 / 100% 2px no-repeat,
        var(--bar) 0 50% / 100% 2px no-repeat,
        var(--bar) 0 100% / 100% 2px no-repeat;
}

/* ------------------------------------------------------- nav as a modal -- */

.site-nav {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: var(--cell);
    border: 0;
    background: var(--bg);
    background-image:
        linear-gradient(rgba(22, 22, 29, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(22, 22, 29, 0.04) 1px, transparent 1px);
    background-size: var(--cell) var(--cell);
    color: var(--ink);
    overflow-y: auto;
}

.site-nav::backdrop {
    background: rgba(22, 22, 29, 0.55);
}

.nav-close {
    position: absolute;
    top: 0.7rem;
    right: 0.7rem;
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    font: 1.25rem/1 var(--sans);
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.75);
    cursor: pointer;
}

.nav-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* No JS: the dialog can never open, so leave the nav inline as a plain card. */
html:not(.has-js) .nav-toggle {
    display: none;
}
html:not(.has-js) .site-nav {
    display: block;
    position: static;
    height: auto;
    padding: 0;
    background: none;
}
html:not(.has-js) .nav-close {
    display: none;
}

/* --------------------------------------------------------------- sidebar -- */

.sidebar-card {
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    background: var(--panel);
}

.sidebar-head {
    position: relative;
    padding: var(--cell) calc(var(--cell) / 2);
    border-bottom: 1px solid var(--line);
    background: var(--grad-cool);
    color: #fff;
}

.sidebar-head .mark {
    display: inline-block;
    font: 600 0.68rem/1 var(--mono);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 0.3rem 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.75);
    margin-bottom: 0.8rem;
}

/* h1's one line + p's two lines are each pinned to exact (half-)cell line
   boxes, with no extra margin between them, so the whole head block —
   padding included — comes out to a clean multiple of the grid cell. */
.sidebar-head h1 {
    margin: 0;
    font-size: 1.32rem;
    line-height: var(--cell);
    letter-spacing: -0.015em;
}
.sidebar-head h1 a {
    color: #fff;
    text-decoration: none;
    background: none;
}
.sidebar-head p {
    margin: 0;
    font-size: 0.82rem;
    line-height: calc(var(--cell) / 2);
    color: rgba(255, 255, 255, 0.88);
}

.sidebar-card nav {
    padding: calc(var(--cell) / 2);
}
.sidebar-card nav + nav {
    border-top: 1px dashed var(--rule);
}

.sidebar-card h2 {
    margin: 0 0 0.6rem;
    font: 600 0.66rem/1 var(--mono);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.nav-item {
    position: relative;
    display: block;
    padding: 0.4rem 0.55rem 0.4rem 0.85rem;
    font-size: 0.93rem;
    color: var(--ink);
    text-decoration: none;
    border: 1px solid transparent;
    background: none;
}

.nav-item:hover {
    border-color: var(--line);
    background: #fff;
}

.nav-item.is-active {
    border-color: var(--line);
    background: #fff;
    font-weight: 600;
    box-shadow: 3px 3px 0 var(--line);
}

.nav-item .meta {
    display: block;
    font: 0.7rem/1.4 var(--mono);
    color: var(--ink-soft);
}

/* -------------------------------------------------------------- typography -- */

h1,
h2,
h3 {
    letter-spacing: -0.02em;
}

/* Vertical rhythm: every heading/paragraph/list line-height and margin below
   is a whole (or, where noted, half) multiple of --cell, so block boundaries
   — like the rule under an h2 — always land on a grid line, however much
   text precedes them. */

.content h1 {
    margin: 0; /* 0 var(--cell);*/
    font-size: 2.35rem;
    line-height: calc(var(--cell) * 2);
    background: var(--grad-cool);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    width: fit-content;
}

.content h2 {
    margin: 0 0 -1px;
    font-size: 1.32rem;
    line-height: var(--cell);
    padding-bottom: 0;
    border-bottom: 1px solid var(--line);
    position: relative;
}

.content h3 {
    margin: var(--cell) 0 0;
    font-size: 1.05rem;
    line-height: var(--cell);
}

p {
    padding-top: calc(var(--cell) * 0.25);
    /*padding-bottom: calc(var(--cell) * -0.25);*/
    margin: 0 0 calc(var(--cell) * 0.75);
}

a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}

/* Gradient-text hover is scoped to prose links — on .nav-item it would clip the
   item's own white background to the glyphs and erase the label. */
.content a:hover {
    background: var(--grad-cool);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

ul,
ol {
    padding-top: calc(var(--cell) * 0.25);
    /*padding-bottom: calc(var(--cell) * -0.25);*/
    margin: 0 0 calc(var(--cell) * 0.75);
    /*margin: 0 0 var(--cell);*/
    padding-left: 1.3rem;
}
li {
    margin-bottom: 0;
}

strong {
    font-weight: 650;
}

blockquote {
    position: relative;
    margin-inline: 0;
    margin-bottom: var(--cell);
    padding: calc(var(--cell) / 2) calc(var(--cell) / 2) calc(var(--cell) / 2)
        calc(var(--cell) / 2);
    border: 0.5px solid var(--line);
    background: var(--panel);
    color: var(--bg);
    font-size: 0.95rem;
    background: var(--grad-leaf);
}

blockquote p:first-child {
    padding-top: 0;
}

blockquote p:last-child {
    margin-bottom: 0;
}

code {
    font: 0.88em var(--mono);
    background: #fff;
    border: 1px solid var(--rule);
    padding: 0.05em 0.32em;
}

pre {
    margin-bottom: calc(var(--cell) - 1px);
    padding: calc(var(--cell) / 2 - 1px) var(--cell) calc(var(--cell) / 2);
    overflow-x: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    /*font: 0.86rem/1.6 var(--mono);*/
}
pre code {
    background: none;
    border: 0;
    padding: 0;
    font-size: inherit;
}

img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    background: #fff;
}

hr {
    border: 0;
    border-top: 1px dashed var(--rule);
    margin: calc(var(--cell) * 2) 0;
}

/* ----------------------------------------------------------- article list -- */

.article-list {
    list-style: none;
    margin: var(--cell) 0;
    padding: 0;
}

.article-list li {
    margin: 0 0 calc(var(--cell) / 2);
    padding: calc(var(--cell) / 2);
    border: 1px solid var(--line);
    background: var(--panel);
}

.article-list li:hover {
    box-shadow: var(--shadow);
}

.article-list a {
    font-size: 1.05rem;
    font-weight: 600;
    text-decoration: none;
}
.article-list a:hover {
    text-decoration: underline;
}

.article-list .meta {
    display: block;
    margin-top: 0.15rem;
    font: 0.7rem/1.5 var(--mono);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

/* -------------------------------------------------------------- post bits -- */

.post-date {
    /* Block rather than inline-block: inline-level boxes sit inside an
     anonymous line box with its own strut, which throws off a negative
     top margin's math. Block keeps the margin arithmetic exact. */
    display: block;
    width: fit-content;
    margin: 0;
    margin-bottom: -1px;
    /* line-height + padding-block + the 1px top/bottom border sums to exactly
     one cell, so the badge itself is a full grid row tall. */
    padding: calc(var(--cell) / 4 + 1px) 0.55rem calc(var(--cell) / 4);
    font: 0.72rem var(--sans);
    line-height: calc(var(--cell) / 2);
    color: var(--ink-soft);
    background: var(--panel);
}

.tags {
    /*margin-bottom: 0;*/
}

.recipe-filter {
    display: block;
    width: 100%;
    margin: var(--cell) 0 0;
    padding: calc(var(--cell) / 4);
    border: 1px solid var(--line);
    background: var(--panel);
    font: 1rem var(--sans);
    color: var(--ink);
}

.tag-cloud a.active {
    background: var(--accent);
    color: var(--panel);
    border-radius: 2px;
    padding: 0.1em 0.4em;
}

/* ----------------------------------------------------------------- mobile -- */

@media (max-width: 767px) {
    .content h1 {
        font-size: 1.9rem;
    }

    /* The menu is the screen, not a card floating on it: the frame comes off and
     the content fills the viewport, with roomier tap targets. */
    .site-nav {
        padding: 0;
    }

    .site-nav .sidebar-card {
        display: flex;
        flex-direction: column;
        min-height: 100%;
        border: 0;
        box-shadow: none;
    }

    .site-nav .sidebar-head {
        padding: var(--cell);
    }
    .site-nav .sidebar-head h1 {
        font-size: 1.65rem;
        line-height: var(--cell);
    }
    .site-nav .sidebar-head p {
        font-size: 0.9rem;
        line-height: calc(var(--cell) / 2);
    }

    .site-nav nav {
        padding: var(--cell);
    }
    .site-nav nav:last-of-type {
        margin-top: auto;
    } /* Contact sits at the foot */

    .site-nav .nav-item {
        padding: 0.68rem 0.7rem 0.68rem 1rem;
        font-size: 1.05rem;
    }
    .site-nav .nav-item .meta {
        font-size: 0.74rem;
    }

    .nav-close {
        top: 1rem;
        right: 1rem;
        width: 2.4rem;
        height: 2.4rem;
        font-size: 1.4rem;
    }
}

/* ------------------------------------------- iPad portrait and up: sidebar -- */

@media (min-width: 768px) {
    .shell {
        display: grid;
        grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
        gap: var(--gap);
        /* Top padding is a whole cell so the sidebar and content columns both
       start flush on a grid line. */
        padding: calc(var(--cell) * 2) var(--cell) calc(var(--cell) * 3);
    }

    .nav-toggle,
    .nav-close {
        display: none;
    }

    /* The dialog stops being a dialog and becomes the sidebar column. Author
     styles beat the UA `dialog:not([open]) { display: none }` rule. */
    .site-nav {
        display: block;
        position: sticky;
        top: calc(var(--cell) * 2);
        align-self: start;
        inset: auto;
        width: auto;
        height: auto;
        padding: 0;
        background: none;
        overflow: visible;
    }
}
