/* ==========================================================================
   axlemike.github.io — site stylesheet
   Conservative CSS on purpose: custom properties, flexbox, grid (with block
   fallback), rgba. Newer features (clamp, env(), backdrop-filter,
   :focus-visible) are always preceded by a plain fallback.
   ========================================================================== */

:root {
    /* Layout */
    --sidebar-width: 220px;
    --sidebar-gutter: 28px;
    --content-max: 760px;
    --content-wide: 1400px;

    /* Typography */
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-ui: var(--font-body);

    /* Colors */
    --bg: #05060a;
    --panel-bg: rgba(10, 11, 16, 0.78);
    --panel-border: rgba(255, 255, 255, 0.07);
    --body-text: #c9ced6;
    --muted-text: #8d94a0;
    --heading-text: #f1f3f6;
    --accent: #5cc6d6;
    --accent-2: #8f86f0;
    --accent-soft: rgba(92, 198, 214, 0.14);

    /* Sidebar */
    --sidebar-bg: rgba(6, 7, 11, 0.92);
    --sidebar-text: #a9b0bb;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.07);
    --sidebar-hover-text: #ffffff;
    --sidebar-active-bg: rgba(92, 198, 214, 0.13);
    --sidebar-active-text: #ffffff;

    /* Submenu (fly-out) */
    --submenu-bg: #12141b;
    --submenu-link-color: #cfd4dc;
    --submenu-hover-bg: rgba(255, 255, 255, 0.08);
    --submenu-hover-text: #ffffff;

    /* Footer */
    --footer-link-color: #aeb4be;
    --footer-link-hover: #ffffff;

    /* Shader cards */
    --thumb-height: 180px;
    --overlay-title-font: var(--font-body);
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    background-color: var(--bg);
    /* Dark native UI: scrollbars, form controls */
    color-scheme: dark;
}

body {
    margin: 0;
    margin-left: var(--sidebar-width);
    padding: 0 var(--sidebar-gutter) 72px;
    min-height: 100%;
    background-color: var(--bg);
    color: var(--body-text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    scrollbar-gutter: stable;
    overflow-x: hidden;
}

/* Centred content column, sitting in the space to the right of the sidebar */
header,
main,
footer {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    max-width: var(--content-max);
    margin-left: auto;
    margin-right: auto;
}

/* Wider column for the shader grid */
body.page-wide header,
body.page-wide main,
body.page-wide footer {
    max-width: var(--content-wide);
}

header {
    padding: 48px 0 8px;
}

h1 {
    margin: 0 0 8px;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 34px;
    font-size: clamp(28px, 2.2vw + 18px, 42px);
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: var(--heading-text);
    text-align: left;
}
h1::after {
    content: "";
    display: block;
    width: 56px;
    height: 3px;
    margin-top: 14px;
    border-radius: 2px;
    background: var(--accent);
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

h2 {
    margin: 28px 0 10px;
    font-size: 19px;
    font-weight: 650;
    line-height: 1.3;
    color: var(--heading-text);
}
main > h2:first-child,
main > section:first-child > h2:first-child {
    margin-top: 0;
}

p {
    margin: 0 0 14px;
    font-size: 16px;
    line-height: 1.65;
}
p:last-child {
    margin-bottom: 0;
}

ul {
    padding-left: 1.3em;
}

/* Main content panel — keeps text readable over the shader */
.main {
    margin-top: 20px;
    padding: 28px 32px;
    background: rgba(10, 11, 16, 0.9);
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    font-size: 16px;
    color: var(--body-text);
}

.lead {
    font-size: 18px;
    color: var(--heading-text);
}

/* In-content links */
main a,
main a:visited {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(92, 198, 214, 0.45);
    text-underline-offset: 3px;
}
main a:hover,
main a:focus {
    color: #ffffff;
    text-decoration-color: currentColor;
}

/* Keyboard focus ring (fallback first, then :focus-visible refinement) */
a:focus,
button:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
    outline: none;
}

/* Simple link lists used on hub pages (Projects, Contact, Sitemap) */
.page-links {
    margin: 0;
    padding-left: 1.2em;
    line-height: 1.9;
}
.page-links ul {
    padding-left: 1.2em;
}

/* ---------------------------------------------------------------- footer */
footer {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--panel-border);
    font-size: 13px;
    color: var(--muted-text);
}
footer p {
    font-size: 13px;
    margin: 0 0 6px;
}
footer ul {
    list-style: none;
    padding: 0;
    margin: 6px 0 0;
    display: flex;
    flex-wrap: wrap;
}
footer li {
    margin: 0 18px 6px 0;
}
footer a,
footer a:link,
footer a:visited {
    color: var(--footer-link-color);
    text-decoration: underline;
    text-underline-offset: 3px;
}
footer a:hover {
    color: var(--footer-link-hover);
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidenav {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    width: var(--sidebar-width);
    height: 100%;
    padding: 24px 12px;
    background-color: #06070b;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--panel-border);
    font-family: var(--font-ui);
}

/* Name / title at the top of the nav */
.sidenav .brand {
    display: block;
    padding: 4px 10px 22px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--panel-border);
    color: var(--heading-text);
    text-decoration: none;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.01em;
}
.sidenav .brand span {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
}

/* Top-level nav items */
.sidebarLink {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 42px;
    margin: 0 0 4px;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background-color: transparent;
    color: var(--sidebar-text);
    font-family: var(--font-ui);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.2;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}
.sidebarLink:hover,
.has-submenu:hover > .sidebarLink,
body:not(.using-mouse) .has-submenu:focus-within > .sidebarLink {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-hover-text);
}

/* Current page */
.sidebarLink.active,
.sidebarLink.active:hover {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    box-shadow: inset 3px 0 0 var(--accent);
}

/* Parent items with a fly-out submenu */
.has-submenu {
    position: relative;
    margin-bottom: 4px;
}
.has-submenu > .sidebarLink {
    margin-bottom: 0;
}
.has-submenu > .sidebarLink::after {
    content: "\203A"; /* › */
    margin-left: auto;
    padding-left: 8px;
    font-size: 18px;
    line-height: 1;
    opacity: 0.45;
}

.has-submenu .submenu {
    display: none;
    position: absolute;
    top: -6px;
    left: 100%;
    z-index: 50;
    min-width: 200px;
    padding: 6px;
    margin-left: 0;
    background-color: var(--submenu-bg);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}
.has-submenu:hover .submenu,
.has-submenu:focus-within .submenu {
    display: block;
}

.submenu a,
.submenu a:visited {
    display: block;
    padding: 9px 12px;
    border-radius: 6px;
    color: var(--submenu-link-color);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color 140ms ease, color 140ms ease;
}
.submenu a:hover,
.submenu a:focus {
    background-color: var(--submenu-hover-bg);
    color: var(--submenu-hover-text);
}

/* Animated label inside a parent item when on one of its subpages
   (sidebar.js injects .title-current / .title-default spans) */
.sidebarLink.has-animated {
    position: relative;
    overflow: hidden;
    height: 42px;
}
.sidebarLink.has-animated span {
    position: absolute;
    left: 12px;
    top: 50%;
    white-space: nowrap;
    -webkit-transform: translateY(-50%);
    transform: translateY(-50%);
    transition: transform 240ms cubic-bezier(.2, .9, .3, 1), opacity 180ms ease;
}
.sidebarLink.has-animated .title-current {
    -webkit-transform: translateY(-50%) translateX(0);
    transform: translateY(-50%) translateX(0);
    opacity: 1;
}
.sidebarLink.has-animated .title-default {
    -webkit-transform: translateY(-50%) translateX(-100%);
    transform: translateY(-50%) translateX(-100%);
    opacity: 0;
}
.sidebarLink.has-animated.show-default .title-current {
    -webkit-transform: translateY(-50%) translateX(100%);
    transform: translateY(-50%) translateX(100%);
    opacity: 0;
}
.sidebarLink.has-animated.show-default .title-default {
    -webkit-transform: translateY(-50%) translateX(0);
    transform: translateY(-50%) translateX(0);
    opacity: 1;
}

/* Short screens (landscape phones/tablets): tighten the sidebar */
@media screen and (max-height: 520px) {
    .sidenav { padding-top: 12px; padding-bottom: 12px; }
    .sidenav .brand { padding-bottom: 10px; margin-bottom: 8px; font-size: 15px; }
    .sidebarLink { min-height: 34px; padding: 7px 12px; margin-bottom: 2px; font-size: 14px; }
    .sidebarLink.has-animated { height: 34px; }
    .has-submenu { margin-bottom: 2px; }
}

/* ==========================================================================
   Page-specific content
   ========================================================================== */

/* Gameography */
.game-list {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
}
.game-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    padding: 10px 0;
    border-bottom: 1px solid var(--panel-border);
}
.game-list li:last-child {
    border-bottom: none;
}
.game-title {
    flex: 1 1 240px;
    margin-right: 16px;
    color: var(--heading-text);
    font-weight: 600;
}
.game-meta {
    flex: 0 1 auto;
    color: var(--muted-text);
    font-size: 14px;
}
.game-year {
    display: inline-block;
    margin-left: 10px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
#gameography h2 {
    padding-left: 12px;
    border-left: 3px solid var(--accent);
}

/* Resume */
.resumeHeader {
    margin: 24px 0 8px;
    padding: 0 0 0 12px;
    border-left: 3px solid var(--accent);
    color: var(--heading-text);
    font-size: 19px;
    font-weight: 650;
    line-height: 1.3;
}
.resumeHeader:first-child {
    margin-top: 0;
}
.ResumeEntry ul {
    margin: 0;
    padding-left: 1.3em;
}
.ResumeEntry li {
    margin-bottom: 8px;
}


/* ==========================================================================
   Project cards (student-projects.html)
   ========================================================================== */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    grid-gap: 18px;
    gap: 18px;
    margin: 0 0 8px;
}
.project-section-note {
    margin-top: -4px;
    color: var(--muted-text);
    font-size: 14px;
}
.project-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    background: rgba(18, 20, 28, 0.92);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
.project-img {
    display: block;
    width: 100%;
    height: auto;
    background-color: #07080c;
}
.project-img-empty {
    position: relative;
    height: 0;
    padding-bottom: 56.25%;
    background-image: radial-gradient(ellipse at 30% 20%, rgba(92, 198, 214, 0.16) 0%, rgba(0, 0, 0, 0) 55%),
                      radial-gradient(ellipse at 80% 90%, rgba(143, 134, 240, 0.16) 0%, rgba(0, 0, 0, 0) 55%);
}
.project-img-empty span {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    margin-top: -0.7em;
    color: rgba(255, 255, 255, 0.35);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-align: center;
    text-transform: uppercase;
}
.project-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    padding: 14px 16px 16px;
}
.project-body h3 {
    margin: 0 0 4px;
    color: var(--heading-text);
    font-size: 17px;
    font-weight: 650;
    line-height: 1.3;
}
.project-meta {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 12.5px;
    font-weight: 500;
}
.project-body p:not(.project-meta) {
    font-size: 14.5px;
    line-height: 1.6;
    margin-bottom: 10px;
}
.project-links {
    margin-top: auto;
    padding-top: 4px;
}
.project-links .shader-btn {
    margin: 4px 8px 0 0;
}

/* ==========================================================================
   Background shader canvas, overlay and toggle
   ========================================================================== */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    display: block;
    pointer-events: none;
}
#bg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    /* Dims the animated background so text and cards read more easily */
    background: rgba(5, 6, 10, 0.28);
    pointer-events: none;
}
/* "Test point lights": coloured lights orbiting the screen centre, like debug
   lights dropped into a scene. Each light is a soft falloff with no hot core
   (roughly 1/(1+d^2) attenuation, approximated with gradient stops).
   Two rings counter-rotate so the colours drift past and blend into each other.
   Each ring is a 150vmax square (bigger than the viewport diagonal) so its
   edges never show while it rotates. Positions are % of that square:
   50% is the screen centre, 23% offset is ~35vmax (outer), 14% is ~21vmax (inner).
   Colours are "r, g, b" variables so each light is easy to retint. */
#bg-overlay::before,
#bg-overlay::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 150vmax;
    height: 150vmax;
    margin: -75vmax 0 0 -75vmax;
    will-change: transform;
}
/* Both rings read their phase from --bg-lights-elapsed, set by sidebar.js from the same
   shared start time the background triangle uses, so the orbit doesn't restart per page.
   (animation-delay is declared after each ring's `animation` shorthand, which would reset it.)
   If you change a ring's period, update the 2040s wrap (their LCM) in sidebar.js too. */
/* Outer ring: four lights, 90° apart */
#bg-overlay::before {
    --red: 255, 80, 70;
    --green: 70, 225, 105;
    --cyan: 60, 210, 230;
    --blue: 80, 125, 255;
    background:
        radial-gradient(circle 48vmax at 73% 50%, rgba(var(--red), 0.18) 0%,   rgba(var(--red), 0.09) 14%,   rgba(var(--red), 0.033) 42%,   rgba(var(--red), 0) 100%),
        radial-gradient(circle 48vmax at 50% 73%, rgba(var(--green), 0.17) 0%, rgba(var(--green), 0.085) 14%, rgba(var(--green), 0.032) 42%, rgba(var(--green), 0) 100%),
        radial-gradient(circle 48vmax at 27% 50%, rgba(var(--cyan), 0.17) 0%,  rgba(var(--cyan), 0.085) 14%,  rgba(var(--cyan), 0.032) 42%,  rgba(var(--cyan), 0) 100%),
        radial-gradient(circle 48vmax at 50% 27%, rgba(var(--blue), 0.19) 0%,  rgba(var(--blue), 0.095) 14%,  rgba(var(--blue), 0.036) 42%,  rgba(var(--blue), 0) 100%);
    animation: bg-lights-orbit 120s linear infinite;
    animation-delay: var(--bg-lights-elapsed, 0s);
}
/* Inner ring: two lights on opposite sides, turning the other way */
#bg-overlay::after {
    --orange: 255, 140, 45;
    --azure: 60, 165, 255;
    background:
        radial-gradient(circle 38vmax at 64% 50%, rgba(var(--orange), 0.17) 0%, rgba(var(--orange), 0.085) 14%, rgba(var(--orange), 0.03) 42%, rgba(var(--orange), 0) 100%),
        radial-gradient(circle 38vmax at 36% 50%, rgba(var(--azure), 0.17) 0%,  rgba(var(--azure), 0.085) 14%,  rgba(var(--azure), 0.03) 42%,  rgba(var(--azure), 0) 100%);
    animation: bg-lights-orbit 85s linear infinite reverse;
    animation-delay: var(--bg-lights-elapsed, 0s);
}
@keyframes bg-lights-orbit {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    #bg-overlay::before,
    #bg-overlay::after { animation: none; }
}

/* Static fallback when WebGL is unavailable (set by background_shader.js) */
html.bg-static body {
    background-color: var(--bg);
    background-image: radial-gradient(ellipse at 50% 45%, rgba(92, 198, 214, 0.10) 0%, rgba(143, 134, 240, 0.06) 28%, rgba(0, 0, 0, 0) 60%),
                      linear-gradient(180deg, #070a12 0%, #030409 100%);
    background-attachment: fixed;
}

.bg-toggle {
    position: fixed;
    right: 14px;
    bottom: 14px;
    right: calc(14px + env(safe-area-inset-right, 0px));
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    z-index: 900;
    padding: 7px 12px;
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    background: rgba(12, 13, 18, 0.85);
    color: var(--muted-text);
    font-family: var(--font-ui);
    font-size: 12px;
    line-height: 1.2;
    cursor: pointer;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: color 160ms ease, border-color 160ms ease;
}
.bg-toggle:hover {
    color: #ffffff;
    border-color: rgba(92, 198, 214, 0.5);
}

/* ==========================================================================
   Shader gallery (shadertoys.html)
   ========================================================================== */
.shader-grid {
    padding: 8px 0 0;
}
.shader-grid-inner {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    grid-gap: 18px;
    gap: 18px;
}
.shader-credits {
    margin: 24px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--panel-border);
    color: var(--muted-text);
    font-size: 12px;
    line-height: 1.6;
}
.shader-note,
.shader-empty {
    color: var(--muted-text);
    font-size: 14px;
}

.shader-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    background: rgba(18, 20, 28, 0.92);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    transition: transform 180ms ease, box-shadow 220ms ease, border-color 220ms ease;
}
.shader-card:hover {
    -webkit-transform: translateY(-3px);
    transform: translateY(-3px);
    border-color: rgba(92, 198, 214, 0.5);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
}

/* Thumbnail: 16:9 box (padding hack works everywhere, no aspect-ratio needed) */
.shader-thumb {
    position: relative;
    display: block;
    width: 100%;
    height: 0;
    padding: 0 0 56.25%;
    margin: 0;
    border: 0;
    overflow: hidden;
    cursor: pointer;
    background-color: #07080c;
    background-image: radial-gradient(ellipse at 30% 20%, rgba(92, 198, 214, 0.14) 0%, rgba(0, 0, 0, 0) 55%),
                      radial-gradient(ellipse at 80% 90%, rgba(143, 134, 240, 0.14) 0%, rgba(0, 0, 0, 0) 55%);
    color: inherit;
    font: inherit;
    text-align: left;
}
.shader-thumb-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: -webkit-filter 200ms ease, filter 200ms ease, transform 300ms ease;
}
.shader-thumb:hover .shader-thumb-img,
.shader-thumb:focus .shader-thumb-img {
    -webkit-filter: brightness(1.12);
    filter: brightness(1.12);
}
.shader-thumb-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 52px;
    height: 52px;
    margin: -26px 0 0 -26px;
    border-radius: 50%;
    background: rgba(5, 6, 10, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    font-size: 18px;
    line-height: 50px;
    text-align: center;
    text-indent: 3px;
    opacity: 0.8;
    transition: opacity 160ms ease, background-color 160ms ease, color 160ms ease, transform 160ms ease;
}
.shader-thumb:hover .shader-thumb-play,
.shader-thumb:focus .shader-thumb-play {
    opacity: 1;
    background: rgba(92, 198, 214, 0.9);
    color: #05060a;
    -webkit-transform: scale(1.08);
    transform: scale(1.08);
}

.shader-badges {
    position: absolute;
    left: 8px;
    top: 8px;
    display: flex;
    flex-wrap: wrap;
    pointer-events: none;
}
.shader-badge {
    display: inline-block;
    margin: 0 6px 6px 0;
    padding: 3px 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.62);
    color: #d8dce3;
    font-size: 11px;
    line-height: 1.3;
    white-space: nowrap;
}
.shader-badge-multipass { color: var(--accent); }

.shader-card-body {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
}
.shader-card-title {
    flex: 1 1 auto;
    margin: 0 10px 0 0;
    color: var(--heading-text);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}
.shader-card-actions {
    display: flex;
    flex: 0 0 auto;
}
.shader-card-actions .shader-btn { margin: 0; }

/* Buttons (used on cards and in the modal) */
.shader-btn,
main a.shader-btn,
main a.shader-btn:visited {
    display: inline-block;
    margin: 0 8px 0 0;
    padding: 7px 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--body-text);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
.shader-btn:hover,
.shader-btn:focus,
main a.shader-btn:hover {
    border-color: rgba(92, 198, 214, 0.6);
    color: #ffffff;
    text-decoration: none;
}

/* Live-run modal */
html.modal-open,
html.modal-open body {
    overflow: hidden;
}
.shader-modal {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: auto;
    background: rgba(0, 0, 0, 0.92);
}
.shader-modal-box {
    max-width: 100%;
    margin: auto;
}
.shader-modal-head {
    display: flex;
    align-items: center;
    margin: 0 0 12px;
}
.shader-modal-title {
    flex: 1 1 auto;
    margin: 0 12px 0 0;
    color: #ffffff;
    font-family: var(--overlay-title-font);
    font-size: 18px;
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.shader-modal-head .shader-btn {
    flex: 0 0 auto;
    color: var(--body-text);
}
.shader-modal-close {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    margin-left: 4px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
}
.shader-modal-close:hover { background: rgba(255, 255, 255, 0.18); }
.shader-stage {
    position: relative;
    max-width: 100%;
    overflow: hidden;
    border-radius: 8px;
    background: #000;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.shader-canvas {
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
}
.shader-status {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--muted-text);
    font-size: 14px;
    text-align: center;
}
.shader-status-error { color: #ffb4b4; }
.shader-status a { color: var(--accent); }
.shader-modal-hint {
    margin: 10px 2px 0;
    color: var(--muted-text);
    font-size: 13px;
}

@media (hover: none) {
    .shader-card:hover { -webkit-transform: none; transform: none; }
}

/* ==========================================================================
   Tablets and phones: the sidebar becomes a wrapping top bar.
   Fly-outs don't work with touch, so the menu is flattened: every submenu
   link is shown as its own tab and the About / Projects parent labels are hidden.
   ========================================================================== */
@media (max-width: 768px) {
    body {
        margin-left: 0;
        padding: 0 16px 72px;
        padding-left: calc(16px + env(safe-area-inset-left, 0px));
        padding-right: calc(16px + env(safe-area-inset-right, 0px));
    }

    .sidenav {
        position: relative;
        z-index: 1000;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        width: auto;
        height: auto;
        margin: 0 -16px;
        padding: 10px 12px;
        padding-top: calc(10px + env(safe-area-inset-top, 0px));
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
    }

    .sidenav .brand {
        flex: 1 0 100%;
        margin: 0 0 8px;
        padding: 2px 6px 10px;
        font-size: 16px;
    }
    .sidenav .brand span { display: inline; margin: 0 0 0 8px; font-size: 11px; }

    .sidebarLink {
        width: auto;
        min-height: 0;
        margin: 0 4px 4px 0;
        padding: 8px 12px;
        font-size: 15px;
    }
    /* Flatten the menu: the wrappers drop out of layout so their links
       become siblings of Home / Blog and wrap together as tabs. */
    .has-submenu,
    .has-submenu .submenu,
    .has-submenu:hover .submenu,
    .has-submenu:focus-within .submenu {
        display: contents;
    }
    .has-submenu > .sidebarLink { display: none; }

    /* Submenu links styled like the top-level tabs */
    .submenu a,
    .submenu a:visited {
        display: flex;
        align-items: center;
        margin: 0 4px 4px 0;
        padding: 8px 12px;
        border-radius: 8px;
        color: var(--sidebar-text);
        font-size: 15px;
        font-weight: 500;
    }
    .submenu a:hover,
    .submenu a:focus {
        background-color: var(--sidebar-hover-bg);
        color: var(--sidebar-hover-text);
    }

    /* Current page (sidebar.js sets aria-current on the matching link) */
    .sidebarLink.active,
    .sidebarLink.active:hover,
    .submenu a[aria-current="page"],
    .submenu a[aria-current="page"]:hover {
        background-color: var(--sidebar-active-bg);
        color: var(--sidebar-active-text);
        box-shadow: inset 0 -2px 0 var(--accent);
    }

    header { padding-top: 28px; }
    .main { margin-top: 14px; padding: 20px 18px; border-radius: 10px; }

    .shader-grid-inner { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
    .shader-modal { padding: 10px; }
}

@media (max-width: 380px) {
    .main { padding: 18px 14px; }
    .shader-grid-inner { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ---------------------------------------------------------------- GitHub contribution calendar (github.html) */
.gh-contrib-section {
    margin-top: 28px;
}
.gh-contrib {
    --gh-gap: 3px;
    font-size: 12px;
    color: var(--muted-text);
}

/* Year picker: "Last year", 2026, 2025, ... */
.gh-contrib-years {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 14px;
}
.gh-contrib-year {
    padding: 5px 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--body-text);
    font: 500 13px/1.2 var(--font-ui);
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
.gh-contrib-year:hover {
    border-color: rgba(92, 198, 214, 0.6);
    color: #ffffff;
}
.gh-contrib-year[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: #ffffff;
}

.gh-contrib-summary {
    margin: 0 0 10px;
    font-size: 14px;
    color: var(--body-text);
}
.gh-contrib-summary strong {
    color: var(--heading-text);
}
.gh-contrib-alltime {
    color: var(--muted-text);
}

/* The chart fills the panel width (squares scale with it). Below its min-width
   (set inline by the script, ~10px per week) it scrolls sideways instead of
   squashing; that only happens on phones. */
.gh-contrib-scroll {
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.gh-contrib-scroll::-webkit-scrollbar { height: 6px; }
.gh-contrib-scroll::-webkit-scrollbar-track { background: transparent; }
.gh-contrib-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 3px;
}
.gh-contrib-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

.gh-contrib-chart {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 6px;
    row-gap: 4px;
}
.gh-contrib-months,
.gh-contrib-grid {
    display: grid;
    column-gap: var(--gh-gap);
    /* grid-template-columns: repeat(<weeks>, 1fr) is set by the script */
}
.gh-contrib-months {
    grid-column: 2;
    grid-row: 1;
    height: 14px;
    font-size: 10px;
    line-height: 14px;
}
.gh-contrib-months span {
    min-width: 0;
    overflow: visible;
    white-space: nowrap;
}
.gh-contrib-days {
    grid-column: 1;
    grid-row: 2;
    display: grid;
    grid-template-rows: repeat(7, 1fr);
    row-gap: var(--gh-gap);
    font-size: 10px;
}
.gh-contrib-days span {
    display: flex;
    align-items: center;
    line-height: 1;
}
.gh-contrib-grid {
    grid-column: 2;
    grid-row: 2;
    grid-template-rows: repeat(7, auto);
    row-gap: var(--gh-gap);
}
.gh-contrib-cell {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 2px;
}
/* Levels use the site accent (teal) instead of GitHub green */
.gh-l0 { background: rgba(255, 255, 255, 0.06); }
.gh-l1 { background: rgba(92, 198, 214, 0.28); }
.gh-l2 { background: rgba(92, 198, 214, 0.5); }
.gh-l3 { background: rgba(92, 198, 214, 0.75); }
.gh-l4 { background: var(--accent); }

.gh-contrib-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--gh-gap);
    margin-top: 8px;
    font-size: 11px;
}
.gh-contrib-legend span:first-child { margin-right: 4px; }
.gh-contrib-legend span:last-child { margin-left: 4px; }
.gh-contrib-legend .gh-contrib-cell {
    display: inline-block;
    width: 11px;
    height: 11px;
}
.gh-contrib-empty {
    margin: 0;
}
