/* One stylesheet for every page. Colours and sizes live here. */
:root {
    --text: #000;
    --muted: #444;
    --link: #0000ff;
    --highlight: #ffff00;
    --home-bg: ##5c5c5c;
    --inner-bg: #c8c8c8;
    --panel-bg: #dfdfdf;
    --rule: #b4b4b4;
    --header-h: 40px;
    --font: Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--header-h) + 12px); }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--home-bg);
}
body.inner { background: var(--inner-bg); }

a { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

img, iframe { max-width: 100%; }
img { height: auto; display: block; }

.skip {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--highlight);
    padding: 6px 10px;
    z-index: 200;
}
.skip:focus { left: 8px; top: 8px; }

/* === Header === */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: var(--header-h);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 24px;
    padding: 8px 12px;
    background: inherit;
    background-color: var(--home-bg);
}
body.inner .site-header { background-color: var(--inner-bg); }

.home-link {
    background: var(--highlight);
    color: #000;
    text-decoration: none;
    padding: 2px 4px;
    white-space: nowrap;
}

.site-nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.site-nav a { text-decoration: none; white-space: nowrap; }
.site-nav a:hover { text-decoration: underline; }
.site-nav a[aria-current="page"] { color: #000; background: var(--highlight); padding: 0 3px; }

/* === Home: shader left, text right === */
.home {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    padding: 6px 12px 0;
}

.shader canvas { display: block; width: 100%; height: 100%; }
.shader.interactive canvas { cursor: none; }

/* fills the left half of the window, from under the header to the bottom, and stays put while the text scrolls */
.home .shader {
    position: sticky;
    top: calc(var(--header-h) + 6px);
    height: calc(100vh - var(--header-h) - 18px);
    height: calc(100dvh - var(--header-h) - 18px);
    min-height: 320px;
    background: #ddd;
}

/* the bottom space lives inside the grid, so the shader stays pinned right to the end of the page */
.bio { max-width: 640px; padding-bottom: 60px; }
.bio h2 {
    font-size: 15px;
    font-weight: bold;
    margin: 0 0 6px;
}
.bio h2:not(:first-child) { margin-top: 22px; }

.listing { list-style: none; margin: 0; padding: 0; }
.listing li { margin: 0 0 6px; }
.listing time { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* === Inner pages: sidebar + grey panel === */
.layout {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 0 0 60px;
}

.sidebar {
    position: sticky;
    top: calc(var(--header-h) + 8px);
    flex: 0 0 220px;
    max-height: calc(100vh - var(--header-h) - 16px);
    overflow-y: auto;
    padding: 12px;
    font-size: 13px;
}
.sidebar ul { list-style: none; margin: 0 0 16px; padding: 0; }
.sidebar li { margin: 0 0 6px; }
.sidebar a { text-decoration: none; }
.sidebar a:hover { text-decoration: underline; }
.sidebar a.is-current { color: #000; background: var(--highlight); }
.sidebar-heading { margin: 0 0 6px; color: var(--muted); }
.sidebar-heading a { color: inherit; }
.sidebar-title { display: block; color: var(--muted); font-size: 12px; line-height: 1.3; }
.sidebar a:hover .sidebar-title, .sidebar a.is-current .sidebar-title { color: #000; }

.panel {
    flex: 1;
    min-width: 0;
    max-width: 900px;
    margin-right: 50px;
    padding: 16px 24px 80px;
    background: var(--panel-bg);
}

.panel h1 { font-size: 22px; font-weight: normal; font-style: italic; margin: 4px 0 8px; }
.panel h2 { font-size: 20px; font-style: italic; font-weight: normal; margin: 0 0 4px; }
.panel h2 a { color: inherit; text-decoration: none; }
.panel h2 a:hover { text-decoration: underline; }
.panel p, .panel ul, .panel ol { margin: 0 0 12px; max-width: 70ch; }
.panel section + section, .panel article + article {
    border-top: 1px solid var(--rule);
    margin-top: 32px;
    padding-top: 24px;
}
.subtitle { color: #333; margin-top: 0; }

.project-intro { margin-bottom: 24px; }
.post-date { margin: 0; color: var(--muted); }
.post-title { font-size: 26px !important; }
.to-top { font-size: 13px; text-align: right; max-width: none !important; }
.to-top a { text-decoration: none; }

.shader.corner {
    float: right;
    width: 160px;
    height: 160px;
    margin: 0 0 12px 16px;
}

/* === Portfolio grid === */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.card {
    display: block;
    overflow: hidden;
    color: var(--text);
    background: #f2f2f2;
    text-decoration: none;
    transition: transform 0.15s;
}
.card:hover, .card:focus-visible { transform: translateY(-2px); }
.card-cover { aspect-ratio: 16 / 10; background: var(--inner-bg); overflow: hidden; }
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.card-placeholder { display: grid; place-items: center; width: 100%; height: 100%; }
.card-placeholder svg { width: 32px; height: 32px; fill: #000; }
.card:hover .card-placeholder svg { fill: var(--link); }

.work-section { margin-top: 28px; }
.work-section h2 { margin-bottom: 0; }
.card-body { display: block; padding: 10px 12px 12px; }
.card-title { display: block; font-weight: bold; line-height: 1.3; }
.card:hover .card-title { color: var(--link); text-decoration: underline; }
.card-sub { display: block; font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.4; }

.pager {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 40px;
    padding-top: 16px;
    border-top: 1px solid var(--rule);
    font-size: 14px;
}

@media (prefers-reduced-motion: reduce) { .card { transition: none; } .card:hover { transform: none; } }

/* === Media === */
figure { margin: 16px 0 20px; }
figcaption { font-size: 13px; color: #555; font-style: italic; margin-top: 4px; }
figure .row, .row { display: flex; gap: 2%; margin-bottom: 2%; }
.row > * { flex: 1 1 0; min-width: 0; margin: 0; }
.row img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.float-left { float: left; margin: 4px 16px 12px 0; max-width: 45%; }
.float-right { float: right; margin: 4px 0 12px 16px; max-width: 45%; }
article::after { content: ""; display: table; clear: both; }

.video {
    position: relative;
    aspect-ratio: 16 / 9;
    max-width: 640px;
    margin: 12px 0 20px;
    background: #000;
}
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* === Audio player (static/audio.js) === */
.audio {
    max-width: 640px;
    margin: 12px 0 20px;
    padding: 10px 12px;
    background: #f2f2f2;
}
.audio audio { width: 100%; display: block; }
.audio.is-ready audio { display: none; }
.audio-title { font-style: normal; font-size: 14px; color: var(--text); margin: 0 0 8px; }
.audio-ui { display: flex; align-items: center; gap: 12px; }
.audio-play {
    flex: none;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    background: #000;
    color: #fff;
    cursor: pointer;
}
.audio-play svg { width: 14px; height: 14px; fill: currentColor; }
.audio-play:hover, .audio.is-playing .audio-play { background: var(--link); }
.audio-play:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.audio-play:disabled { background: #888; cursor: default; }
.audio.is-loading .audio-play { opacity: 0.6; }
.audio-time { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.audio.is-error .audio-time { flex: 1; }
.audio.is-error .audio-seek { display: none; }

/* previous / next, for playlists */
.audio-skip {
    flex: none;
    width: 26px;
    height: 36px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: #000;
    cursor: pointer;
}
.audio-skip svg { width: 12px; height: 12px; fill: currentColor; }
.audio-skip:hover { color: var(--link); }
.audio-skip:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.audio-prev { margin-right: -8px; }
.audio-next { margin-left: -8px; }

/* track list, for playlists */
.audio .audio-tracks {
    list-style: none;
    counter-reset: track;
    max-width: none;
    margin: 10px 0 0;
    padding: 0;
    border-top: 1px solid var(--rule);
    font-size: 14px;
}
.audio-tracks li {
    counter-increment: track;
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid var(--rule);
}
.audio-tracks li::before {
    content: counter(track) ".";
    min-width: 1.6em;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.audio-track {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--link);
    text-align: left;
    cursor: pointer;
}
.audio-track:hover { text-decoration: underline; }
.audio-track[aria-current="true"] { color: #000; background: var(--highlight); padding: 0 3px; }


.audio-seek {
    --progress: 0%;
    flex: 1;
    min-width: 0;
    height: 20px;
    margin: 0;
    background: transparent;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
.audio-seek::-webkit-slider-runnable-track {
    height: 4px;
    background: linear-gradient(to right, var(--link) var(--progress), var(--rule) var(--progress));
}
.audio-seek::-moz-range-track { height: 4px; background: var(--rule); }
.audio-seek::-moz-range-progress { height: 4px; background: var(--link); }
.audio-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    margin-top: -4px;
    border: 0;
    border-radius: 0;
    background: #000;
}
.audio-seek::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 0; background: #000; }
.audio-seek:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

mark { background: var(--highlight); }
blockquote { margin: 0 0 12px; padding-left: 12px; border-left: 3px solid var(--rule); }

/* === Small screens === */
@media (max-width: 760px) {
    .home { grid-template-columns: 1fr; }
    .home .shader { position: relative; top: 0; height: 50vh; height: 50svh; min-height: 240px; }

    .layout { flex-direction: column; align-items: stretch; }
    .sidebar {
        position: static;
        max-height: none;
        flex: none;
        padding: 4px 12px 8px;
    }
    .sidebar ul { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 8px; }
    .sidebar li { margin: 0; }
    .panel { margin-right: 0; padding: 16px; }
    .post-title { font-size: 22px !important; }
    .sidebar-title { display: none; }
    .panel { overflow-wrap: anywhere; }
    .float-left, .float-right { float: none; max-width: 100%; margin: 12px 0; }
    .shader.corner { width: 100px; height: 100px; }
}

/* === Buzz on hover (from the original site) === */
@keyframes buzz {
    50%  { transform: translateX(3px) rotate(2deg); }
    100% { transform: translateX(-3px) rotate(-2deg); }
}
.buzz:hover { animation: buzz 0.15s linear infinite; }

@media (prefers-reduced-motion: reduce) {
    .buzz:hover { animation: none; }
    html { scroll-behavior: auto; }
}
